:root {
  --bg: #0f1320;
  --panel: #1a2030;
  --panel2: #222a3d;
  --ink: #e8ecf5;
  --muted: #97a0b5;
  --accent: #4da3ff;
  --max: #e2574c;   /* P1 / MAX = red */
  --min: #f2c14e;   /* P2 / MIN = yellow */
  --line: #38415a;
  --good: #56c596;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
.hidden { display: none !important; }
code { background: #0008; padding: 1px 5px; border-radius: 4px; font-size: 0.85em; }

/* ── Start screen ───────────────────────────────────────────────────────── */
#start-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 32px;
  max-width: 540px;
  width: 100%;
  box-shadow: 0 20px 60px #0006;
}
.card h1 { margin: 0 0 6px; font-size: 26px; }
.sub { color: var(--muted); margin: 0 0 24px; line-height: 1.5; }
.setting { margin-bottom: 20px; }
.setting > label { display: block; font-weight: 600; margin-bottom: 8px; font-size: 14px; }
.opts { display: flex; flex-wrap: wrap; gap: 10px 18px; }
.opts label { font-weight: 400; color: var(--ink); font-size: 14px; cursor: pointer; }
.hint { color: var(--muted); font-size: 12.5px; margin: 8px 0 0; min-height: 16px; }
.hint.warn { color: var(--min); }
button.primary {
  background: var(--accent);
  color: #06101f;
  border: 0;
  padding: 12px 20px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  width: 100%;
  margin-top: 6px;
}
button.primary:hover { filter: brightness(1.08); }
.foot { color: var(--muted); font-size: 12px; margin: 16px 0 0; line-height: 1.5; }

/* ── Game screen ────────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.hud { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.hud-pill {
  background: var(--panel2);
  border: 1px solid var(--line);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
}
.hud-pill.on { background: #16341f; border-color: #2f7d4f; color: var(--good); }
.hud-pill.off { background: #3a1f1f; border-color: #7d3f2f; color: #ff9d8a; }
.status { color: var(--muted); font-size: 14px; }
button.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}
button.ghost:hover { background: var(--panel2); }

.layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 18px;
  padding: 18px 20px;
  align-items: start;
}
@media (max-width: 880px) { .layout { grid-template-columns: 1fr; } }

/* AI vs AI: board centered, a tree on each side (symmetric). */
.layout.mode-aivs { grid-template-columns: 1fr minmax(320px, 380px) 1fr; }
@media (max-width: 1100px) { .layout.mode-aivs { grid-template-columns: 1fr; } }
.mode-aivs .center { display: flex; flex-direction: column; }
.mode-aivs .tree-col.side { min-height: 480px; }
.aivs-info {
  margin-top: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}
.cmp-row.p1 { border-left-color: var(--max); }
.cmp-row.p2 { border-left-color: var(--min); }
.tree-head.p1 { border-left: 3px solid var(--max); padding-left: 8px; }
.tree-head.p2 { border-left: 3px solid var(--min); padding-left: 8px; }

.topbar-btns { display: flex; gap: 10px; align-items: center; }
button.primary.small { width: auto; padding: 8px 14px; font-size: 13px; margin-top: 0; }
button.primary.small:disabled { opacity: 0.4; cursor: default; }

/* Board */
.board { display: flex; flex-direction: column; gap: 6px; }
.cf-colbar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cf-coldrop {
  background: var(--panel2);
  border: 1px solid var(--line);
  color: var(--accent);
  border-radius: 6px;
  padding: 4px 0;
  cursor: pointer;
  font-size: 12px;
}
.cf-coldrop:disabled { opacity: 0.25; cursor: default; }
.cf-coldrop:not(:disabled):hover { background: #2c3650; }
.cf-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  background: #14306b;
  padding: 8px;
  border-radius: 12px;
}
.cf-cell { aspect-ratio: 1; display: grid; place-items: center; cursor: pointer; }
.cf-disc {
  width: 84%;
  height: 84%;
  border-radius: 50%;
  background: var(--bg);
  box-shadow: inset 0 3px 8px #0009;
}
.cf-disc.p1 { background: radial-gradient(circle at 35% 30%, #ff8074, var(--max)); box-shadow: none; }
.cf-disc.p2 { background: radial-gradient(circle at 35% 30%, #ffe089, var(--min)); box-shadow: none; }
.cf-disc.last { outline: 3px solid #fff8; outline-offset: -3px; }

/* Progress panel */
.progress {
  margin-top: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
}
.prog-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.prog-label { font-size: 12px; color: var(--muted); width: 120px; flex: none; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.depth-chip {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel2);
  color: var(--muted);
}
.depth-chip.running { color: var(--accent); border-color: var(--accent); }
.depth-chip.done { color: var(--good); border-color: #2f7d4f; background: #16341f; }
.depth-chip.aborted { color: #ff9d8a; border-color: #7d3f2f; }
.bar-wrap { flex: 1; height: 8px; background: var(--panel2); border-radius: 999px; overflow: hidden; }
.bar { height: 100%; width: 0; background: var(--accent); transition: width 0.1s linear; }
.time-label { font-size: 12px; color: var(--muted); width: 90px; text-align: right; flex: none; font-variant-numeric: tabular-nums; }

/* Two-method comparison card */
.compare-card { margin-top: 4px; }
.cmp-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 8px 10px;
  border-radius: 8px;
  margin-bottom: 6px;
  background: var(--panel2);
  border-left: 3px solid var(--line);
}
.cmp-row.none { border-left-color: #ff9d8a; }
.cmp-row.ord { border-left-color: var(--good); }
.cmp-name { font-size: 12.5px; font-weight: 600; }
.cmp-name small { display: block; font-weight: 400; color: var(--muted); font-size: 10.5px; }
.cmp-stat { font-size: 12px; color: var(--muted); white-space: nowrap; }
.cmp-stat b { font-size: 18px; color: var(--ink); font-variant-numeric: tabular-nums; }
.cmp-result { font-size: 13px; color: var(--ink); margin: 8px 2px 4px; line-height: 1.5; }
.cmp-result b { color: var(--accent); }
.invariant { font-size: 12px; color: var(--good); margin: 4px 2px 0; }

/* Two trees side by side */
.right.two-trees {
  background: transparent;
  border: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 1100px) { .right.two-trees { grid-template-columns: 1fr; } }
.tree-col {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  min-height: 420px;
}
.tree-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
  flex-wrap: wrap;
  gap: 8px;
}
.tree-head b { color: var(--ink); font-variant-numeric: tabular-nums; }
.tree-head.none { border-left: 3px solid #ff9d8a; padding-left: 8px; }
.tree-head.ord { border-left: 3px solid var(--good); padding-left: 8px; }
.legend { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.sw { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.sw.max { background: var(--max); }
.sw.min { background: var(--min); }
.sw.pruned { background: var(--panel2); border: 1px dashed var(--muted); }
.tree-host { overflow: auto; max-height: 70vh; }
.tree-empty { color: var(--muted); font-size: 14px; padding: 40px; text-align: center; }

.tree-svg { display: block; }
.tree-edge { stroke: var(--line); stroke-width: 1.6; }
.tree-edge.pruned { stroke: var(--muted); stroke-dasharray: 4 4; opacity: 0.5; }
.tree-node { stroke-width: 1.5; }
.tree-node.max { fill: #3a2422; stroke: var(--max); }
.tree-node.min { fill: #3a3220; stroke: var(--min); }
.tree-node.pruned { fill: var(--panel2); stroke: var(--muted); stroke-dasharray: 4 3; }
.tree-node.terminal { stroke-width: 2.5; }
.tree-label { fill: var(--ink); font-size: 11px; font-family: inherit; }
.tree-label.title { fill: var(--muted); font-size: 10px; }
.tree-label.val { font-weight: 700; font-variant-numeric: tabular-nums; }
.tree-label.ab { fill: var(--muted); font-size: 9.5px; }
.pruned-label { fill: var(--muted); font-size: 11px; }
