:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --ink: #17212b;
  --muted: #657180;
  --line: #d9e0e8;
  --panel: #ffffff;
  --banker: #d73342;
  --player: #2364d8;
  --tie: #1d9b63;
  --accent: #0f8f72;
  --warn: #b56017;
  --danger: #b3261e;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, "Microsoft JhengHei", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(100%, 430px);
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto minmax(280px, 46vh) auto;
  gap: 10px;
  padding: max(12px, env(safe-area-inset-top)) 12px max(16px, env(safe-area-inset-bottom));
}

.topbar,
.site-panel,
.assistant-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 20px;
}

h2 {
  font-size: 17px;
}

h3 {
  font-size: 15px;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 3px;
}

.icon-text-button,
.ghost-button,
.upload-button,
.tool-button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 12px;
  font-weight: 700;
  white-space: nowrap;
}

.icon-text-button {
  background: #06c755;
  color: white;
  border-color: #06c755;
}

.site-panel {
  display: grid;
  grid-template-rows: auto auto 1fr;
  min-height: 0;
  overflow: hidden;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
}

.panel-heading.compact {
  padding: 0 0 10px;
}

.status-line {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  padding: 8px 12px;
}

.iframe-wrap {
  position: relative;
  min-height: 0;
  background: #101820;
}

iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.fallback-panel {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 8px;
  padding: 24px;
  text-align: center;
  background: #fbfcfd;
}

.fallback-panel strong {
  font-size: 18px;
}

.fallback-panel span {
  color: var(--muted);
  line-height: 1.5;
}

.assistant-panel {
  padding: 12px;
  display: grid;
  gap: 12px;
}

.recommendation {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.action-text {
  font-size: 34px;
  font-weight: 900;
  line-height: 1;
}

.confidence-ring {
  width: 74px;
  aspect-ratio: 1;
  border: 8px solid #dfeeea;
  border-top-color: var(--accent);
  border-radius: 50%;
  display: grid;
  place-items: center;
}

.confidence-ring span {
  font-size: 19px;
  font-weight: 900;
  line-height: 1;
}

.confidence-ring small {
  color: var(--muted);
  font-size: 11px;
}

.risk-badge {
  width: max-content;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 800;
}

.risk-badge.low {
  background: #e1f4ec;
  color: #08724f;
}

.risk-badge.medium {
  background: #fff0d6;
  color: var(--warn);
}

.risk-badge.high {
  background: #ffe8e7;
  color: var(--danger);
}

.reason-text,
.disclaimer {
  color: var(--muted);
  line-height: 1.45;
  font-size: 14px;
}

.quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 46px;
  gap: 8px;
}

.round-button {
  min-height: 52px;
  border: 0;
  border-radius: 6px;
  color: white;
  font-size: 20px;
  font-weight: 900;
}

.banker {
  background: var(--banker);
}

.player {
  background: var(--player);
}

.tie {
  background: var(--tie);
}

.screenshot-tools {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.upload-button input {
  display: none;
}

.ghost-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.review-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.analysis-details {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

summary {
  cursor: pointer;
  font-weight: 800;
  margin-bottom: 10px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.stats-grid div {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  display: grid;
  gap: 2px;
}

.stats-grid span {
  font-size: 18px;
  font-weight: 900;
}

.stats-grid small {
  color: var(--muted);
  font-size: 12px;
}

.road-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(18px, 1fr));
  grid-auto-rows: 24px;
  gap: 5px;
  min-height: 82px;
}

.road-cell {
  border: 1px solid var(--line);
  border-radius: 4px;
  display: grid;
  place-items: center;
  background: white;
}

.road-dot {
  width: 15px;
  aspect-ratio: 1;
  border-radius: 50%;
}

.road-dot.banker {
  background: var(--banker);
}

.road-dot.player {
  background: var(--player);
}

.road-dot.tie {
  background: var(--tie);
}

.editable .road-cell {
  min-height: 32px;
}

@media (min-width: 431px) {
  body {
    background: #e7ecf1;
  }
}
