:root {
  color-scheme: light;
  --bg: #f6f5f1;
  --surface: #fcfcfb;
  --surface-2: #efeee9;
  --border: #dddbd3;
  --text: #0b0b0b;
  --text-2: #52514e;
  --text-3: #7a7973;
  --accent: #2a78d6;
  --accent-ink: #1c5cab;
  --grid: #e6e4dc;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --board: #1f3f7a;
  --board-hole: #f6f5f1;
  --p-human: #e34948;
  --p-ai: #eda100;
  --code-bg: #efeee9;
  --shadow: 0 1px 2px rgb(0 0 0 / .06), 0 4px 16px rgb(0 0 0 / .05);
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211;
    --surface: #1a1a19;
    --surface-2: #232321;
    --border: #34332f;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --text-3: #8f8e86;
    --accent: #5598e7;
    --accent-ink: #86b6ef;
    --grid: #2b2a27;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --board: #1c3566;
    --board-hole: #121211;
    --p-human: #e66767;
    --p-ai: #e3a21a;
    --code-bg: #232321;
    --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 6px 20px rgb(0 0 0 / .3);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211;
  --surface: #1a1a19;
  --surface-2: #232321;
  --border: #34332f;
  --text: #f0efec;
  --text-2: #c3c2b7;
  --text-3: #8f8e86;
  --accent: #5598e7;
  --accent-ink: #86b6ef;
  --grid: #2b2a27;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --board: #1c3566;
  --board-hole: #121211;
  --p-human: #e66767;
  --p-ai: #e3a21a;
  --code-bg: #232321;
  --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 6px 20px rgb(0 0 0 / .3);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-ink); }
code, .mono { font-family: var(--mono); font-size: .9em; }
code { background: var(--code-bg); padding: .1em .35em; border-radius: 4px; }
pre {
  background: var(--code-bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 14px 16px; overflow-x: auto; font: 13px/1.55 var(--mono); margin: 0;
}
pre code { background: none; padding: 0; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }

/* nav */
.nav {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.nav .wrap { display: flex; align-items: center; gap: 20px; height: 56px; }
.brand { font-weight: 700; text-decoration: none; color: var(--text); display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.brand svg { width: 22px; height: 22px; }
.nav-links { display: flex; gap: 18px; margin-left: auto; overflow-x: auto; scrollbar-width: none; }
.nav-links a { color: var(--text-2); text-decoration: none; font-size: 14px; white-space: nowrap; }
.nav-links a:hover { color: var(--text); }
.theme-btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  border-radius: 8px; width: 34px; height: 34px; cursor: pointer; flex: none; display: grid; place-items: center;
}
@media (max-width: 720px) { .nav-links { display: none; } .theme-btn { margin-left: auto; } }

/* hero */
.hero { padding: 72px 0 40px; }
.eyebrow { font: 600 13px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--accent-ink); }
h1 { font-size: clamp(2.1rem, 5vw, 3.4rem); line-height: 1.08; margin: 14px 0 18px; letter-spacing: -.02em; }
.lede { font-size: 1.15rem; color: var(--text-2); max-width: 680px; margin: 0 0 28px; }
.cta { display: flex; gap: 12px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px; border-radius: 10px;
  font-weight: 600; text-decoration: none; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); cursor: pointer; font: 600 15px var(--sans);
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn:disabled { opacity: .5; cursor: default; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 44px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; }
.stat .num { font: 700 1.75rem/1.1 var(--sans); letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.stat .lbl { color: var(--text-2); font-size: 13.5px; margin-top: 6px; line-height: 1.4; }
@media (max-width: 720px) { .stats { grid-template-columns: repeat(2, 1fr); } }

/* sections */
section { padding: 56px 0; border-top: 1px solid var(--border); }
h2 { font-size: clamp(1.6rem, 3.2vw, 2.1rem); margin: 8px 0 14px; letter-spacing: -.015em; line-height: 1.2; }
h3 { font-size: 1.12rem; margin: 0 0 8px; }
.intro { color: var(--text-2); max-width: 720px; margin: 0 0 32px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 860px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 22px; min-width: 0; }
.card p { margin: 0 0 10px; color: var(--text-2); }
.card p:last-child { margin-bottom: 0; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 14px; margin: 0; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; font-family: var(--mono); font-size: 13px; }
.formula {
  font: 15px/1.5 var(--mono); background: var(--code-bg); border-radius: 8px; padding: 14px 16px;
  margin: 12px 0; overflow-x: auto; white-space: nowrap;
}
.diagram { width: 100%; height: auto; display: block; }
.diagram text { font-family: var(--sans); fill: var(--text); }
.diagram .sub { fill: var(--text-2); font-size: 11px; }
.diagram .box { fill: var(--surface-2); stroke: var(--border); }
.diagram .box.accent { fill: color-mix(in srgb, var(--series-1) 14%, var(--surface)); stroke: var(--series-1); }
.diagram .box.p { fill: color-mix(in srgb, var(--series-2) 14%, var(--surface)); stroke: var(--series-2); }
.diagram .box.v { fill: color-mix(in srgb, var(--series-3) 14%, var(--surface)); stroke: var(--series-3); }
.diagram .edge { stroke: var(--text-3); stroke-width: 1.5; fill: none; }
.diagram .arrowhead { fill: var(--text-3); }

/* play */
.play { display: grid; grid-template-columns: minmax(0, 560px) minmax(0, 1fr); gap: 28px; align-items: start; }
@media (max-width: 900px) { .play { grid-template-columns: 1fr; } }
.board-wrap { position: relative; }
.board {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 2.2%; padding: 3%;
  background: var(--board); border-radius: 16px; box-shadow: var(--shadow);
  touch-action: manipulation; user-select: none; overflow: hidden;
}
.col { display: grid; grid-template-rows: repeat(6, auto); row-gap: 8px; cursor: pointer; border-radius: 999px; padding: 2px; outline: none; }
.board.locked .col { cursor: default; }
.col:hover:not(.full), .col:focus-visible { background: rgb(255 255 255 / .08); }
.board.locked .col:hover { background: none; }
.cell { border-radius: 50%; background: var(--board-hole); box-shadow: inset 0 3px 6px rgb(0 0 0 / .35); position: relative; aspect-ratio: 1; }
.cell.h { background: var(--p-human); }
.cell.a { background: var(--p-ai); }
.cell.h, .cell.a { box-shadow: inset 0 -4px 0 rgb(0 0 0 / .18); }
.cell.drop { animation: drop .32s cubic-bezier(.4, 0, .9, .6); }
@keyframes drop { from { transform: translateY(var(--from, -400%)); } to { transform: translateY(0); } }
.cell.win::after { content: ""; position: absolute; inset: 28%; border-radius: 50%; background: rgb(255 255 255 / .9); }
.cell.last::before { content: ""; position: absolute; inset: 40%; border-radius: 50%; background: rgb(0 0 0 / .25); }
.status { min-height: 1.6em; font-weight: 600; margin: 14px 0 0; display: flex; align-items: center; gap: 10px; }
.dot { width: 14px; height: 14px; border-radius: 50%; display: inline-block; flex: none; }
.dot.h { background: var(--p-human); } .dot.a { background: var(--p-ai); }
.spinner { width: 14px; height: 14px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.panel { display: flex; flex-direction: column; gap: 16px; }
.field label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; font-weight: 600; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface); flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 8px 14px; font: 500 14px var(--sans); color: var(--text-2); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.seg button:disabled { cursor: default; opacity: .6; }
.hint { font-size: 13px; color: var(--text-3); margin: 6px 0 0; }

.analysis h3 { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.analysis h3 small { font-weight: 400; color: var(--text-3); font-size: 12.5px; }
.bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; align-items: end; height: 120px; margin: 10px 0 4px; }
.bar { background: var(--series-1); border-radius: 4px 4px 0 0; min-height: 2px; transition: height .15s; position: relative; }
.bar.best { background: var(--p-ai); }
.bar-lbls { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; text-align: center; font: 12px var(--mono); color: var(--text-3); }
.bar-vals { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; text-align: center; font: 11px var(--mono); color: var(--text-2); min-height: 1.3em; }
.meter { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; display: flex; margin: 8px 0 4px; }
.meter > div { height: 100%; transition: width .2s; }
.meter .mh { background: var(--p-human); } .meter .ma { background: var(--p-ai); }
.meter-lbls { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-2); }
.progress { height: 4px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-top: 8px; }
.progress > div { height: 100%; width: 0; background: var(--accent); transition: width .1s; }
.loadbox { position: absolute; inset: 0; display: grid; place-items: center; background: color-mix(in srgb, var(--bg) 70%, transparent); border-radius: 16px; text-align: center; padding: 20px; }
.loadbox .card { max-width: 340px; }
.loadbox[hidden] { display: none; }

/* charts */
.chart-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 20px 20px 14px; min-width: 0; }
.chart-card h3 { margin-bottom: 2px; }
.chart-card .sub { color: var(--text-2); font-size: 14px; margin: 0 0 12px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--text-2); margin: 0 0 6px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.legend i.dotkey { width: 9px; height: 9px; border-radius: 50%; }
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .axis-text { fill: var(--text-3); font: 11px var(--mono); }
.chart .dlabel { font: 600 11.5px var(--sans); fill: var(--text-2); }
.chart .xhair { stroke: var(--text-3); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .annot { stroke: var(--text-3); stroke-width: 1; stroke-dasharray: 2 4; }
.chart .annot-text { fill: var(--text-2); font: 11px var(--sans); }
.tip {
  position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: var(--shadow); padding: 8px 10px; font-size: 12.5px; white-space: nowrap;
  transform: translate(-50%, calc(-100% - 12px)); z-index: 2; color: var(--text);
}
.tip .t { font-weight: 600; margin-bottom: 4px; color: var(--text); }
.tip .r { display: flex; align-items: center; gap: 6px; color: var(--text-2); }
.tip .r b { color: var(--text); font-variant-numeric: tabular-nums; margin-left: auto; padding-left: 12px; font-weight: 600; }
.tip i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
details.table { margin-top: 10px; font-size: 13px; }
details.table summary { cursor: pointer; color: var(--text-3); }
details.table .scroll { max-height: 240px; overflow: auto; margin-top: 8px; border: 1px solid var(--border); border-radius: 8px; }
details.table table { border-collapse: collapse; width: 100%; font: 12px var(--mono); }
details.table th, details.table td { padding: 4px 10px; text-align: right; border-bottom: 1px solid var(--grid); }
details.table th { position: sticky; top: 0; background: var(--surface-2); color: var(--text-2); font-weight: 600; }
.small-multiples { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 860px) { .small-multiples { grid-template-columns: 1fr; } }
.chart-stack { display: grid; gap: 20px; }

/* bugs */
.bugs { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 860px) { .bugs { grid-template-columns: 1fr; } }
.bug { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 22px; min-width: 0; }
.bug .tag { font: 600 11px var(--mono); text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); }
.bug h3 { margin: 6px 0 10px; }
.bug p { margin: 0 0 10px; color: var(--text-2); font-size: 15px; }
.bug .fix { border-left: 3px solid var(--series-3); padding-left: 12px; color: var(--text); }
.bug .impact { font: 13px var(--mono); color: var(--text); background: var(--surface-2); padding: 8px 10px; border-radius: 6px; margin-top: 12px; }
.bug pre { margin: 10px 0; font-size: 12px; }

footer { border-top: 1px solid var(--border); padding: 32px 0 48px; color: var(--text-3); font-size: 14px; }
footer .wrap { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .cell.drop { animation: none; }
}
