:root {
  color-scheme: light;
  --page: #f7f6f2; --page-alt: #efede6; --surface: #fcfcfb; --surface-2: #f1f0eb;
  --ink: #0b0b0b; --ink-2: #52514e; --muted: #7d7b75;
  --grid: #e1e0d9; --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10); --border-strong: rgba(11, 11, 11, 0.18);
  --accent: #2a78d6; --accent-ink: #1c5cab;
  --band: rgba(27, 175, 122, 0.14); --band-line: rgba(27, 175, 122, 0.5);
  --good: #006300; --good-bg: rgba(12, 163, 12, 0.12);
  --low: #b42f2f; --low-bg: rgba(208, 59, 59, 0.12);
  --high: #9a5a00; --high-bg: rgba(250, 178, 25, 0.18);
  --a1: #eda100; --a2: #eb6834; --a3: #1baf7a; --a4: #2a78d6; --you: #008300;
  --shadow: 0 1px 2px rgba(0,0,0,0.04), 0 6px 20px rgba(0,0,0,0.05);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 64px; }
html, body { overflow-x: clip; }
body { margin: 0; background: var(--page); color: var(--ink); font: 16px/1.6 Inter, system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
h1, h2 { font-family: Newsreader, Georgia, serif; font-weight: 600; letter-spacing: -0.01em; text-wrap: balance; margin: 0; }
h1 { font-size: clamp(32px, 5vw, 48px); line-height: 1.08; max-width: 800px; }
h2 { font-size: clamp(26px, 3.4vw, 36px); line-height: 1.15; }
h3 { margin: 0 0 8px; font-size: 17px; }
p { margin: 0 0 12px; }
b { font-weight: 600; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 24px; }
@media (max-width: 640px) { .wrap { padding: 0 16px; } }
.mt { margin-top: 20px; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--page) 88%, transparent); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--border); }
.topbar-inner { display: flex; align-items: center; gap: 24px; height: 56px; }
.brand { font-weight: 700; color: var(--ink); text-decoration: none; display: flex; align-items: center; gap: 8px; }
.drop { width: 12px; height: 16px; background: var(--accent); border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; display: inline-block; }
.nav { display: flex; gap: 20px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav a { color: var(--ink-2); text-decoration: none; font-size: 14px; white-space: nowrap; }
.nav a:hover { color: var(--ink); }

/* buttons & inputs */
.btn { font: inherit; font-size: 14px; font-weight: 500; padding: 9px 16px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink); cursor: pointer; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); color: #fff; border-color: transparent; }
.btn.primary:hover { filter: brightness(1.07); background: var(--accent); }
.btn.small { padding: 6px 12px; font-size: 13px; white-space: nowrap; flex: none; }
.link-btn { font: inherit; font-size: 13.5px; background: none; border: none; color: var(--accent-ink); cursor: pointer; padding: 0; text-decoration: underline; text-underline-offset: 3px; }
button:focus-visible, input:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.check { display: inline-flex; gap: 8px; align-items: center; font-size: 14px; color: var(--ink-2); cursor: pointer; }
input[type="range"], input[type="checkbox"] { accent-color: var(--accent); }

/* layout */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 20px; box-shadow: var(--shadow); min-width: 0; }
figure { margin: 0; min-width: 0; }
.section { padding: 64px 0; border-top: 1px solid var(--border); }
.section.alt { background: var(--page-alt); }
.section-lede { color: var(--ink-2); max-width: 720px; margin: 10px 0 24px; font-size: 17px; }
.eyebrow { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.fig-title { font-weight: 600; font-size: 14.5px; margin-bottom: 6px; }
.fig-sub { font-weight: 400; color: var(--muted); font-size: 13px; margin-left: 4px; }
.tiny { font-size: 13px; color: var(--muted); margin: 8px 0 0; }

/* hero + game */
.hero { padding: 44px 0 56px; }
.lede { font-size: 17.5px; color: var(--ink-2); margin: 14px 0 26px; max-width: 760px; }
.lede b { color: var(--ink); }
.game { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 28px; padding: 22px; }
@media (max-width: 900px) { .game { grid-template-columns: minmax(0, 1fr); } }
.game-side { min-width: 0; }
.game-charts { display: grid; gap: 12px; align-content: start; min-width: 0; }
.patient-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.patient-desc { font-weight: 600; font-size: 15px; margin-top: 2px; }
.readout { background: var(--surface-2); border-radius: 14px; padding: 14px 16px; }
.readout-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.big { margin: 6px 0 10px; }
.big > span:first-child { font-size: 40px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.big .unit { color: var(--ink-2); font-size: 13.5px; }
.status { font-size: 13px; font-weight: 600; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.status.ok { color: var(--good); background: var(--good-bg); }
.status.low { color: var(--low); background: var(--low-bg); }
.status.high { color: var(--high); background: var(--high-bg); }
.gauge { position: relative; height: 10px; border-radius: 999px; background: var(--grid); }
.gauge-band { position: absolute; top: 0; bottom: 0; left: 31.25%; width: 31.25%; background: var(--band-line); border-radius: 2px; }
.gauge-dot { position: absolute; top: 50%; width: 18px; height: 18px; border-radius: 50%; background: var(--ink); border: 3px solid var(--surface-2); transform: translate(-50%, -50%); transition: left 0.25s ease; }
.gauge-labels { position: relative; display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.gauge-labels .mid { position: absolute; left: 46.875%; transform: translateX(-50%); color: var(--good); font-weight: 600; }
.rate-line { margin-top: 12px; font-size: 14px; color: var(--ink-2); }
.rate-line b { color: var(--ink); font-variant-numeric: tabular-nums; }
.progress { height: 4px; background: var(--grid); border-radius: 4px; margin-top: 12px; overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.2s ease; }
.moves { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 14px; }
.moves button { font: inherit; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 10px 0 8px; border-radius: 12px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink); cursor: pointer; }
.moves button b { font-size: 15px; }
.moves button span { font-size: 11px; color: var(--muted); }
.moves button:hover:not(:disabled) { background: var(--surface-2); }
.moves button:disabled { opacity: 0.35; cursor: default; }
.moves button.ai { border-color: var(--a4); box-shadow: inset 0 0 0 1.5px var(--a4); }
.game-opts { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.hint { font-size: 13.5px; color: var(--ink-2); background: var(--surface-2); padding: 8px 12px; border-radius: 10px; margin: 10px 0 0; }
.result { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 14px; }
.bars { display: grid; gap: 8px; margin: 10px 0 12px; }
.bar-row { display: grid; grid-template-columns: 118px 1fr 44px; align-items: center; gap: 10px; font-size: 13.5px; }
.bar-row .nm { display: flex; align-items: center; gap: 7px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row .track { height: 12px; background: var(--grid); border-radius: 4px; overflow: hidden; }
.bar-row .fill { height: 100%; border-radius: 4px; }
.bar-row .val { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.key { width: 14px; height: 3px; border-radius: 2px; flex: none; display: inline-block; }
.verdict { font-weight: 600; margin: 0; }

/* how */
.how-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 900px) { .how-grid { grid-template-columns: minmax(0, 1fr); } }
.diagram-card svg { width: 100%; height: auto; display: block; color: var(--ink-2); }
.d-box { fill: var(--surface-2); stroke: var(--border-strong); stroke-width: 1.4; }
.d-box.v1 { stroke: var(--accent); stroke-width: 2; }
.d-line { stroke: currentColor; stroke-width: 1.6; fill: none; }
.d-line.accent { stroke: var(--accent); stroke-width: 2.4; }
.d-line.dashed { stroke-dasharray: 4 4; }
.fill-accent { fill: var(--accent); }
.d-title { font: 600 17px Inter, sans-serif; fill: var(--ink); }
.d-label { font: 600 13.5px Inter, sans-serif; fill: var(--ink); }
.d-sub { font: 12.5px Inter, sans-serif; fill: var(--muted); }
.d-sub.strong { fill: var(--ink-2); font-weight: 600; }
.steps { display: grid; gap: 12px; }
.step { display: flex; gap: 14px; color: var(--ink-2); font-size: 15px; }
.step b { color: var(--ink); }
.step .n { flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 700; font-size: 14px; display: grid; place-items: center; margin-top: 1px; }
.why { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: center; }
@media (max-width: 800px) { .why { grid-template-columns: minmax(0, 1fr); } }
.why p { color: var(--ink-2); }
.math { margin-top: 20px; }
.math summary { cursor: pointer; font-weight: 600; }
.eqs { display: grid; gap: 8px; margin-top: 14px; }
.eqs > div { display: flex; gap: 12px; align-items: baseline; overflow-x: auto; }
.eq-tag { flex: none; width: 92px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.eqs code { font: 13.5px ui-monospace, "SF Mono", Menlo, monospace; white-space: nowrap; color: var(--ink); }

/* compare */
.cmp-grid { display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 20px; }
@media (max-width: 900px) { .cmp-grid { grid-template-columns: minmax(0, 1fr); } }
.controls { align-self: start; }
.ctl { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; margin-bottom: 14px; font-size: 14px; }
.ctl label { color: var(--ink-2); }
.ctl output { font-weight: 600; font-variant-numeric: tabular-nums; }
.ctl input { grid-column: 1 / -1; width: 100%; }
.arms-pick { display: grid; gap: 6px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.chip { font: inherit; font-size: 13.5px; display: flex; align-items: center; gap: 9px; padding: 7px 10px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink); cursor: pointer; text-align: left; }
.chip small { display: block; color: var(--muted); font-size: 12px; }
.chip[aria-pressed="false"] { color: var(--muted); background: transparent; border-style: dashed; }
.chip[aria-pressed="false"] .key { background: var(--axis) !important; }
.cmp-main { display: grid; gap: 14px; min-width: 0; align-content: start; }
.score .bar-row { grid-template-columns: 180px 1fr 44px 90px; }
.score .bar-row .vol { color: var(--muted); font-size: 12.5px; text-align: right; font-variant-numeric: tabular-nums; }
.score-head { display: grid; grid-template-columns: 180px 1fr 44px 90px; gap: 10px; font-size: 12px; color: var(--muted); }
.score-head span:nth-child(3), .score-head span:nth-child(4) { text-align: right; }
@media (max-width: 560px) {
  .score .bar-row, .score-head { grid-template-columns: 150px 1fr 40px; }
  .score .bar-row .vol, .score-head span:nth-child(4) { display: none; }
}
.cmp-charts { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 720px) { .cmp-charts { grid-template-columns: minmax(0, 1fr); } }
.cmp-charts .card { padding: 14px 14px 8px; }
.bottomline { display: flex; gap: 24px; align-items: center; margin-top: 20px; }
.bottomline p { margin: 0; color: var(--ink-2); }
.bottomline p b { color: var(--ink); }
.bl-num { font-size: 34px; font-weight: 700; white-space: nowrap; letter-spacing: -0.02em; }
.bl-num .muted { color: var(--muted); font-weight: 500; }
@media (max-width: 640px) { .bottomline { flex-direction: column; align-items: flex-start; gap: 8px; } }

/* charts */
.chart { width: 100%; height: 220px; position: relative; touch-action: pan-y; }
.chart svg { display: block; overflow: visible; }
.ax text { font: 11px Inter, sans-serif; fill: var(--muted); font-variant-numeric: tabular-nums; }
.ax line.grid { stroke: var(--grid); stroke-width: 1; }
.ax line.base { stroke: var(--axis); stroke-width: 1; }
.lbl { font: 11px Inter, sans-serif; fill: var(--muted); }
.series { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.endlabel { font: 600 11px Inter, sans-serif; fill: var(--ink-2); }
.band { fill: var(--band); }
.band-edge { stroke: var(--band-line); stroke-width: 1; stroke-dasharray: 3 3; }
.xhair { stroke: var(--ink-2); stroke-width: 1; opacity: 0.5; }
.hdot { stroke: var(--surface); stroke-width: 2; }
.tip { position: fixed; z-index: 50; pointer-events: none; background: var(--surface); color: var(--ink); border: 1px solid var(--border-strong); border-radius: 10px; padding: 8px 10px; font-size: 12.5px; box-shadow: 0 6px 24px rgba(0,0,0,0.14); min-width: 140px; max-width: 280px; }
.tip .tt-h { color: var(--muted); font-size: 11.5px; margin-bottom: 4px; }
.tip .tt-row { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.tip .tt-row span:first-child { display: flex; align-items: center; gap: 6px; color: var(--ink-2); }
.tip .tt-row b { font-variant-numeric: tabular-nums; }
.tip .tt-key { width: 12px; height: 2.5px; border-radius: 2px; display: inline-block; }

.footer { border-top: 1px solid var(--border); padding: 28px 0 48px; font-size: 13.5px; color: var(--muted); }
.footer p { max-width: 760px; margin: 0; }

@media (max-width: 640px) {
  .section { padding: 44px 0; }
  .hero { padding-top: 28px; }
  .card { padding: 14px; }
  .game { padding: 14px; }
  .nav { gap: 14px; }
  .moves button span { display: none; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } .gauge-dot, .progress i { transition: none; } }
