/* ==========================================================================
   Chess Game Analyzer — design system + layout
   ========================================================================== */

/* ---------- tokens: light ---------- */
:root {
  --bg: #f2f2f7;
  --wash: radial-gradient(120% 55% at 50% -12%, #ffffff 0%, rgba(255, 255, 255, 0) 62%), #eef0f5;
  --surface: #ffffff;
  --surface-2: rgba(118, 118, 128, .08);
  --surface-3: rgba(118, 118, 128, .14);
  --fill: rgba(118, 118, 128, .12);   /* iOS-style fills for controls */
  --seg-on: #ffffff;
  --card: rgba(255, 255, 255, .8);
  --card-edge: rgba(255, 255, 255, .9);
  --card-shadow: inset 0 1px 0 rgba(255, 255, 255, .9), 0 1px 2px rgba(0, 0, 0, .04), 0 8px 28px rgba(30, 40, 70, .07);
  --chrome: rgba(255, 255, 255, .7);  /* frosted glass for floating chrome */
  --chrome-edge: rgba(255, 255, 255, .75);
  --chrome-shadow: inset 0 1px 0 rgba(255, 255, 255, .9), 0 10px 34px rgba(30, 40, 70, .14);
  --border: rgba(0, 0, 0, .07);
  --border-strong: rgba(0, 0, 0, .14);
  --text: #1d1d1f;
  --text-2: #3a3a3c;
  --muted: #6e6e73;
  --accent: #007aff;
  --accent-hover: #0068db;
  --accent-ink: #ffffff;
  --accent-text: #0066cc;
  --accent-soft: rgba(0, 122, 255, .11);
  --ring: rgba(0, 122, 255, .4);
  --brass: #ff9500;
  --frame: transparent;
  --shadow-1: none;
  --shadow-2: 0 10px 30px rgba(30, 40, 70, .12);
  --shadow-3: 0 18px 50px -20px rgba(30, 40, 70, .4);
  --bar-bg: rgba(242, 242, 247, .6);
  --graph-top: #3a3a3c;
  --graph-bottom: #ffffff;

  --win: #248a3d;
  --loss: #d70015;
  --draw: #8e8e93;

  --c-brilliant: #18b2a5;
  --c-great: #4b84ea;
  --c-best: #55a63a;
  --c-excellent: #7fb64a;
  --c-good: #8f9d86;
  --c-forced: #9798a3;
  --c-inaccuracy: #e2a923;
  --c-mistake: #ec7f2e;
  --c-miss: #e4573e;
  --c-blunder: #d73535;
  --c-book: #a5825f;
  --engine-arrow: #2f7cf0;

  /* chart roles (validated on the card surface: win/loss pass CVD all-pairs; series and ramp clear contrast floors) */
  --viz-win: #2a78d6;
  --viz-loss: #e34948;
  --viz-draw: #898781;
  --viz-series: #248a3d;
  --viz-grid: #e9e9ee;
  --viz-axis: #c7c7cc;
  /* findability, an ordinal ramp in one hue: hard to see -> tricky -> findable */
  --find-hard: #74c189; --find-hard-ink: #0b2a14;
  --find-tricky: #28a046; --find-tricky-ink: #ffffff;
  --find-findable: #17602b; --find-findable-ink: #ffffff;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --ease: cubic-bezier(.22, .8, .3, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --r-card: 22px;
  --r-ctl: 14px;
  color-scheme: light;
}

/* ---------- tokens: dark ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17171a; --wash: radial-gradient(120% 55% at 50% -12%, #26262d 0%, rgba(23, 23, 26, 0) 62%), #17171a; --cap-outline: rgba(255, 255, 255, .85);
    --surface: #1c1c1e; --surface-2: rgba(118, 118, 128, .16); --surface-3: rgba(118, 118, 128, .26); --fill: rgba(118, 118, 128, .22); --seg-on: #636366;
    --card: rgba(28, 28, 30, .82); --card-edge: rgba(255, 255, 255, .08); --card-shadow: inset 0 1px 0 rgba(255, 255, 255, .05), 0 8px 30px rgba(0, 0, 0, .35);
    --chrome: rgba(36, 36, 40, .72); --chrome-edge: rgba(255, 255, 255, .12); --chrome-shadow: inset 0 1px 0 rgba(255, 255, 255, .1), 0 10px 34px rgba(0, 0, 0, .5);
    --border: rgba(255, 255, 255, .08); --border-strong: rgba(255, 255, 255, .16);
    --text: #f5f5f7; --text-2: #d1d1d6; --muted: #98989d;
    --accent: #0a84ff; --accent-hover: #3497ff; --accent-ink: #ffffff; --accent-text: #4aa3ff; --accent-soft: rgba(10, 132, 255, .18); --ring: rgba(10, 132, 255, .55);
    --brass: #ff9f0a; --frame: transparent;
    --shadow-1: none; --shadow-2: 0 10px 30px rgba(0, 0, 0, .45); --shadow-3: 0 18px 50px -20px rgba(0, 0, 0, .8);
    --bar-bg: rgba(20, 20, 22, .62);
    --graph-top: #2c2c2e; --graph-bottom: #e5e5ea;
    --win: #30d158; --loss: #ff6961;
    --engine-arrow: #4aa3ff;
    --viz-win: #3987e5; --viz-loss: #e66767; --viz-series: #2ea84f; --viz-grid: #2c2c2e; --viz-axis: #48484a;
    --find-hard: #1d5a2c; --find-hard-ink: #e9f7ec;
    --find-tricky: #2fbf52; --find-tricky-ink: #08240f;
    --find-findable: #9be8b0; --find-findable-ink: #08240f;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #17171a; --wash: radial-gradient(120% 55% at 50% -12%, #26262d 0%, rgba(23, 23, 26, 0) 62%), #17171a; --cap-outline: rgba(255, 255, 255, .85);
    --surface: #1c1c1e; --surface-2: rgba(118, 118, 128, .16); --surface-3: rgba(118, 118, 128, .26); --fill: rgba(118, 118, 128, .22); --seg-on: #636366;
    --card: rgba(28, 28, 30, .82); --card-edge: rgba(255, 255, 255, .08); --card-shadow: inset 0 1px 0 rgba(255, 255, 255, .05), 0 8px 30px rgba(0, 0, 0, .35);
    --chrome: rgba(36, 36, 40, .72); --chrome-edge: rgba(255, 255, 255, .12); --chrome-shadow: inset 0 1px 0 rgba(255, 255, 255, .1), 0 10px 34px rgba(0, 0, 0, .5);
    --border: rgba(255, 255, 255, .08); --border-strong: rgba(255, 255, 255, .16);
    --text: #f5f5f7; --text-2: #d1d1d6; --muted: #98989d;
    --accent: #0a84ff; --accent-hover: #3497ff; --accent-ink: #ffffff; --accent-text: #4aa3ff; --accent-soft: rgba(10, 132, 255, .18); --ring: rgba(10, 132, 255, .55);
    --brass: #ff9f0a; --frame: transparent;
    --shadow-1: none; --shadow-2: 0 10px 30px rgba(0, 0, 0, .45); --shadow-3: 0 18px 50px -20px rgba(0, 0, 0, .8);
    --bar-bg: rgba(20, 20, 22, .62);
    --graph-top: #2c2c2e; --graph-bottom: #e5e5ea;
    --win: #30d158; --loss: #ff6961;
    --engine-arrow: #4aa3ff;
    --viz-win: #3987e5; --viz-loss: #e66767; --viz-series: #2ea84f; --viz-grid: #2c2c2e; --viz-axis: #48484a;
    --find-hard: #1d5a2c; --find-hard-ink: #e9f7ec;
    --find-tricky: #2fbf52; --find-tricky-ink: #08240f;
    --find-findable: #9be8b0; --find-findable-ink: #08240f;
    color-scheme: dark;
}

/* ---------- board themes ---------- */
:root { --sq-l: #eed8b5; --sq-d: #b38763; --hl: rgba(255, 214, 72, .5); }
:root[data-board="slate"] { --sq-l: #dfe4e8; --sq-d: #8aa0ad; --hl: rgba(255, 220, 90, .5); }
:root[data-board="sage"] { --sq-l: #e6e9d4; --sq-d: #86a079; --hl: rgba(255, 226, 92, .55); }
:root[data-board="dusk"] { --sq-l: #d3cde6; --sq-d: #7e72aa; --hl: rgba(255, 214, 112, .5); }

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { overflow-x: clip; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--text);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  transition: background-color .3s var(--ease), color .3s var(--ease);
}
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--display); font-weight: 600; letter-spacing: -.01em; margin: 0; font-optical-sizing: auto; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
button { font: inherit; color: inherit; }
::selection { background: var(--accent-soft); }

.ico { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ico.sm { width: 16px; height: 16px; }


/* top progress line (analysis) */
.topline { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 100; pointer-events: none; opacity: 0; transition: opacity .4s; }
.topline.on { opacity: 1; }
.topline > div { height: 100%; width: 0; background: var(--brass); transition: width .35s var(--ease); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 18px; border-radius: var(--r-ctl); border: 1px solid transparent;
  font-weight: 600; font-size: .95rem; cursor: pointer; white-space: nowrap; user-select: none;
  transition: transform .18s var(--ease), box-shadow .25s var(--ease), background-color .2s, color .2s, border-color .2s, filter .2s;
  touch-action: manipulation;
}
.btn:hover { transform: none; }
.btn:active { transform: translateY(0) scale(.97); transition-duration: .06s; }
.btn:disabled { opacity: .55; cursor: default; transform: none; }
.btn-primary {
  color: var(--accent-ink); background: var(--accent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12), 0 1px 0 rgba(0, 0, 0, .15);
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary .ico { transition: transform .25s var(--ease); }
.btn-primary:hover .ico { transform: translateX(3px); }
.btn-ghost { background: transparent; color: var(--text-2); padding: 0 12px; }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-soft { background: var(--accent-soft); color: var(--accent-text); }
.btn-soft:hover { background: color-mix(in srgb, var(--accent) 20%, transparent); }
.btn-sm { height: 38px; padding: 0 12px; font-size: .88rem; border-radius: var(--r-ctl); }
.btn-block { width: 100%; white-space: normal; height: auto; min-height: 44px; padding: 10px 14px; text-align: center; line-height: 1.3; }
.btn.loading { pointer-events: none; }
.btn.loading .ico { display: none; }
.btn.loading::after {
  content: ""; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .45); border-top-color: #fff; animation: spin .7s linear infinite;
}

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px;
  border-radius: var(--r-ctl); border: 1px solid var(--border); background: transparent; color: var(--text-2);
  cursor: pointer; transition: background-color .2s, color .2s, transform .18s var(--ease), border-color .2s;
  touch-action: manipulation;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.icon-btn:active { transform: scale(.94); }

/* segmented control */
.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: var(--r-ctl); background: var(--surface-3); }
.seg button {
  display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; color: var(--muted);
  padding: 6px 12px; border-radius: 7px; font-weight: 600; font-size: .85rem; cursor: pointer;
  transition: background-color .2s, color .2s, box-shadow .2s;
}
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1), 0 0 0 1px var(--border); }
.seg-lg button { padding: 8px 16px; font-size: .9rem; }

/* switch */
.switch {
  appearance: none; -webkit-appearance: none; width: 42px; height: 24px; border-radius: 99px; margin: 0;
  background: var(--surface-3); border: 1px solid var(--border-strong); position: relative; cursor: pointer;
  transition: background-color .25s var(--ease), border-color .25s;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .3s var(--spring);
}
.switch:checked { background: var(--accent); border-color: var(--accent); }
.switch:checked::after { transform: translateX(18px); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50; display: flex; align-items: center; justify-content: space-between;
  max-width: 1280px; margin: 0 auto; padding: calc(12px + env(safe-area-inset-top)) 24px 12px; height: calc(64px + env(safe-area-inset-top));
}
.topbar::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 100vw; transform: translateX(-50%); z-index: -1; background: var(--bar-bg);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border); opacity: 0; transition: opacity .3s;
}
body.scrolled .topbar::before { opacity: 1; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font-family: var(--display); font-weight: 600; font-size: 1.2rem; letter-spacing: -.01em; }
.brand-name em { font-style: italic; color: var(--brass); font-weight: 500; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
  background: var(--accent); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08);
}
.brand-mark img { width: 24px; height: 24px; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .35)); }
.topbar-actions { display: flex; gap: 8px; }

/* settings popover */
.popover {
  position: fixed; z-index: 120; top: calc(62px + env(safe-area-inset-top)); right: max(16px, calc((100vw - 1280px) / 2 + 24px)); width: 320px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-card); padding: 10px 16px;
  box-shadow: var(--shadow-3); transform-origin: top right; animation: pop .22s var(--ease);
}
@keyframes pop { from { opacity: 0; transform: scale(.95) translateY(-6px); } }
.pop-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; }
.pop-row + .pop-row { border-top: 1px solid var(--border); }
.pop-label { font-weight: 600; font-size: .9rem; color: var(--text-2); }
.switch-row { cursor: pointer; }
.swatches { display: flex; gap: 8px; }
.swatches button {
  width: 34px; height: 34px; padding: 0; border-radius: 10px; border: 2px solid transparent; cursor: pointer;
  display: grid; grid-template-columns: 1fr 1fr; overflow: hidden; outline: 2px solid var(--border); outline-offset: -2px;
  transition: transform .2s var(--spring), border-color .2s;
}
.swatches button:hover { transform: scale(1.08); }
.swatches button.active { border-color: var(--accent); outline-color: transparent; }
.swatches i { display: block; }
.swatches [data-v="walnut"] i:first-child { background: #eed8b5; } .swatches [data-v="walnut"] i:last-child { background: #b38763; }
.swatches [data-v="slate"] i:first-child { background: #dfe4e8; } .swatches [data-v="slate"] i:last-child { background: #8aa0ad; }
.swatches [data-v="sage"] i:first-child { background: #e6e9d4; } .swatches [data-v="sage"] i:last-child { background: #86a079; }
.swatches [data-v="dusk"] i:first-child { background: #d3cde6; } .swatches [data-v="dusk"] i:last-child { background: #7e72aa; }

/* ---------- layout ---------- */
main { max-width: 1280px; margin: 0 auto; padding: 0 24px; }
.view { animation: viewIn .45s var(--ease); }
@keyframes viewIn { from { opacity: 0; transform: translateY(10px); } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- hero ---------- */
.hero { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr); gap: 64px; align-items: center; padding: 48px 0 40px; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px; color: var(--brass); font-weight: 600; font-size: .78rem;
  text-transform: uppercase; letter-spacing: .12em; margin-bottom: 18px;
}
.hero h1 { font-size: clamp(2.3rem, 4.8vw, 3.8rem); line-height: 1.05; font-weight: 600; letter-spacing: -.02em; }
.grad { font-style: italic; font-weight: 500; color: var(--accent-text); }
.lede { color: var(--muted); font-size: 1.1rem; max-width: 52ch; margin: 18px 0 28px; }

.search-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); padding: 14px;
  box-shadow: var(--shadow-2); display: flex; flex-direction: column; gap: 12px; max-width: 580px;
}
.search { position: relative; display: flex; gap: 8px; }
.search-ico { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input, #pgn-input {
  flex: 1; min-width: 0; height: 52px; padding: 0 16px 0 46px; border-radius: var(--r-ctl); font: inherit; font-size: 1rem;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  transition: border-color .2s, box-shadow .2s, background-color .2s;
}
.search input::placeholder, #pgn-input::placeholder { color: var(--muted); }
.search input:focus, #pgn-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); background: var(--surface); }
.search .btn { height: 52px; padding: 0 20px; }
.pgn-pane { display: flex; flex-direction: column; gap: 10px; }
#pgn-input { height: auto; padding: 12px 14px; font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; resize: vertical; }
.pgn-pane .btn { align-self: flex-start; }
.recent { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.recent:empty { display: none; }
.recent .lbl { font-size: .8rem; color: var(--muted); margin-right: 2px; }
.recent button {
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2); border-radius: 8px;
  padding: 4px 10px; font-size: .82rem; font-weight: 500; cursor: pointer; transition: all .2s var(--ease);
}
.recent button:hover { border-color: var(--accent); color: var(--accent-text); }

.hero-board { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.demo-frame {
  width: 100%; max-width: 430px; padding: 10px; border-radius: 10px; background: var(--frame);
  box-shadow: var(--shadow-3), inset 0 0 0 1px rgba(255, 255, 255, .06);
}
#demo-board { aspect-ratio: 1; border-radius: 3px; overflow: hidden; }
.demo-caption { font: italic .85rem/1.4 var(--display); color: var(--muted); text-align: center; }

/* ---------- results ---------- */
.results { padding: 8px 0 40px; display: flex; flex-direction: column; gap: 18px; }
.profile:empty { display: none; }
.profile {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap; padding: 18px 20px; border-radius: var(--r-card);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-1); animation: fadeUp .4s var(--ease);
}
.avatar {
  width: 56px; height: 56px; border-radius: 12px; object-fit: cover; flex: none; display: grid; place-items: center;
  font-family: var(--display); font-weight: 600; font-size: 1.5rem; color: var(--accent-ink);
  background: var(--accent);
}
.pf-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pf-name { font-family: var(--display); font-size: 1.45rem; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.title-tag { font-family: var(--font); font-size: .72rem; font-weight: 800; color: #fff; background: #c4302b; border-radius: 6px; padding: 1px 6px; }
.pf-ratings { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.rating-chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: var(--r-ctl); background: var(--surface-2);
  border: 1px solid var(--border); font-weight: 700; font-variant-numeric: tabular-nums;
}
.rating-chip .ico { color: var(--muted); }
.rating-chip small { display: block; font-size: .7rem; font-weight: 600; color: var(--muted); line-height: 1; text-transform: uppercase; letter-spacing: .04em; }
.record { display: flex; flex-direction: column; gap: 6px; min-width: 180px; }
.record-bar { display: flex; height: 8px; border-radius: 99px; overflow: hidden; background: var(--surface-3); }
.record-bar i { display: block; height: 100%; transition: width .8s var(--ease); }
.record-bar { gap: 2px; }
.record-bar .w { background: var(--viz-win); } .record-bar .d { background: var(--viz-draw); } .record-bar .l { background: var(--viz-loss); }
.record-txt { font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.record-txt b { color: var(--text); }

.results-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: var(--r-ctl);
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-weight: 600; font-size: .85rem;
  cursor: pointer; transition: all .2s var(--ease);
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.active { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 50%, transparent); color: var(--accent-text); }
.chip .n { font-size: .75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.chip.active .n { color: inherit; opacity: .8; }

.game-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; }
.game {
  position: relative; display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 14px; align-items: center;
  padding: 14px 16px 14px 18px; border-radius: var(--r-card); background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-1); cursor: pointer; overflow: hidden;
  transition: transform .25s var(--ease), box-shadow .25s var(--ease), border-color .2s;
  animation: fadeUp .45s var(--ease) backwards; animation-delay: calc(var(--i, 0) * 35ms);
}
.game::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--draw); }
.game.win::before { background: var(--win); }
.game.loss::before { background: var(--loss); }
.game:hover, .game:focus-visible { box-shadow: var(--shadow-2); border-color: var(--border-strong); outline: none; }
.res {
  width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; font-family: var(--display);
  font-weight: 600; font-size: 1.15rem; color: var(--draw); background: color-mix(in srgb, var(--draw) 14%, transparent);
}
.game.win .res { color: var(--win); background: color-mix(in srgb, var(--win) 14%, transparent); }
.game.loss .res { color: var(--loss); background: color-mix(in srgb, var(--loss) 14%, transparent); }
.g-main { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.g-opp { display: flex; align-items: center; gap: 7px; white-space: nowrap; overflow: hidden; }
.g-opp b { overflow: hidden; text-overflow: ellipsis; font-weight: 650; }
.g-opp .rt { color: var(--muted); font-variant-numeric: tabular-nums; font-size: .9rem; }
.side-dot { width: 12px; height: 12px; border-radius: 4px; flex: none; border: 1px solid rgba(0, 0, 0, .35); }
.side-dot.w { background: #f4f4f6; } .side-dot.b { background: #2a2d33; border-color: rgba(255, 255, 255, .2); }
.g-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 2px 6px; font-size: .8rem; color: var(--muted); }
.g-meta .ico { width: 14px; height: 14px; }
.g-meta .dotsep { opacity: .5; }
.g-acc { font: 600 .82rem/1 var(--font); font-variant-numeric: tabular-nums; padding: 5px 7px; border-radius: 8px; background: var(--surface-3); color: var(--text-2); }
.game { grid-template-columns: 44px minmax(0, 1fr) auto auto; }
.g-opening { display: flex; align-items: center; gap: 5px; font-size: .78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.g-opening .ico { width: 13px; height: 13px; flex: none; }
.tag-opening { max-width: 100%; }
.tag-opening { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-flex; }
.g-go { color: var(--muted); transition: transform .25s var(--ease), color .2s; }
.game:hover .g-go { transform: translateX(3px); color: var(--accent-text); }
.empty-state { grid-column: 1 / -1; text-align: center; padding: 32px; color: var(--muted); }

.skeleton { pointer-events: none; }
.skeleton .res, .skeleton .sk-line { background: linear-gradient(90deg, var(--surface-3) 0%, var(--surface-2) 50%, var(--surface-3) 100%); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
.skeleton::before { background: var(--surface-3); }
.sk-line { height: 12px; border-radius: 6px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- review header ---------- */
.review-head { display: flex; align-items: center; gap: 12px; padding: 8px 0 18px; }
.rh-title { min-width: 0; flex: 1; }
.rh-title h2 { font-size: 1.4rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rh-title h2 .vs { color: var(--muted); font-weight: 500; margin: 0 6px; }
.rh-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.tag {
  display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 6px;
  background: var(--surface-3); color: var(--text-2); font-size: .76rem; font-weight: 600;
}
.tag .ico { width: 13px; height: 13px; }
.tag.win { background: color-mix(in srgb, var(--win) 16%, transparent); color: var(--win); }
.tag.loss { background: color-mix(in srgb, var(--loss) 16%, transparent); color: var(--loss); }
.rh-actions { display: flex; gap: 8px; }

/* ---------- review grid ---------- */
.review-grid {
  display: grid; gap: 28px; align-items: start;
  grid-template-columns: minmax(0, clamp(380px, calc(100vh - 330px), 660px)) minmax(0, 1fr);
}
.board-col { position: sticky; top: 76px; }
.panel-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

/* player cards */
.player-card { display: flex; align-items: center; gap: 10px; padding: 10px 2px 10px 38px; min-height: 56px; }
.p-avatar {
  width: 36px; height: 36px; border-radius: 8px; flex: none; object-fit: cover; display: grid; place-items: center;
  font-family: var(--display); font-weight: 600; font-size: 1.05rem; box-shadow: var(--shadow-1);
}
.p-avatar.w { background: #f4efe2; color: #2d2b26; border: 1px solid rgba(0, 0, 0, .1); }
.p-avatar.b { background: #2d2b26; color: #f4efe2; border: 1px solid rgba(255, 255, 255, .08); }
.p-avatar.bot { color: var(--accent-ink); background: var(--accent); }
.p-avatar.bot .ico { width: 20px; height: 20px; }
.p-info { min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.p-name { display: flex; align-items: center; gap: 6px; font-weight: 650; white-space: nowrap; overflow: hidden; }
.p-name .rt { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.you { font-size: .64rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; background: var(--accent-soft); color: var(--accent-text); padding: 2px 6px; border-radius: 4px; }
.p-caps { display: flex; align-items: center; min-height: 18px; margin-top: 2px; }
.p-caps img { width: 18px; height: 18px; margin-right: -7px; }
.p-caps img + img.gap { margin-left: 6px; }
.p-caps img.pb { filter: drop-shadow(0 0 1px var(--cap-outline, rgba(255, 255, 255, .55))) drop-shadow(0 0 .5px var(--cap-outline, rgba(255, 255, 255, .55))); }
.p-caps .adv { margin-left: 10px; font-size: .78rem; font-weight: 700; color: var(--muted); }
.p-clock {
  margin-left: auto; font: 600 1.02rem/1 var(--font); font-variant-numeric: tabular-nums; padding: 8px 12px;
  border-radius: 6px; background: var(--surface-3); color: var(--text-2); transition: all .25s var(--ease); min-width: 76px; text-align: center;
}
.p-clock.active { background: var(--text); color: var(--bg); box-shadow: var(--shadow-2); }
.p-clock.low.active { background: var(--loss); color: #fff; }

/* board + eval bar */
.board-row { display: flex; gap: 16px; }
.board-shell { flex: 1; min-width: 0; aspect-ratio: 1; border-radius: 3px; box-shadow: 0 0 0 7px var(--frame), 0 0 0 8px rgba(255, 255, 255, .05), var(--shadow-3); position: relative; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
#board { position: absolute; inset: 0; border-radius: 3px; overflow: hidden; }
.evalbar { position: relative; width: 22px; flex: none; border-radius: 4px; overflow: hidden; background: #2d2b26; outline: 1px solid var(--border-strong); outline-offset: 0; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06), var(--shadow-1); }
.evalbar-fill { position: absolute; left: 0; right: 0; bottom: 0; height: 50%; background: #f4efe2; transition: height .6s var(--ease); }
.evalbar.flipped .evalbar-fill { bottom: auto; top: 0; }
.evalbar::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: color-mix(in srgb, var(--brass) 80%, transparent); }
.evalbar-txt { position: absolute; left: 0; right: 0; text-align: center; font: 700 9.5px/1 var(--font); letter-spacing: -.3px; font-variant-numeric: tabular-nums; z-index: 1; }
.evalbar-txt.on-w { bottom: 6px; color: #2d2b26; }
.evalbar-txt.on-b { top: 6px; color: #f0f1f4; }
.evalbar.flipped .evalbar-txt.on-w { bottom: auto; top: 6px; }
.evalbar.flipped .evalbar-txt.on-b { top: auto; bottom: 6px; }

/* chessboard component */
.cb { position: relative; width: 100%; height: 100%; }
.cb-squares { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); }
.cb-sq { position: relative; transition: background-color .4s; }
.cb-sq.l { background: var(--sq-l); }
.cb-sq.d { background: var(--sq-d); }
.cb-rank, .cb-file { position: absolute; font: 700 clamp(8px, 1.5vw, 12px)/1 var(--font); pointer-events: none; }
.cb-rank { left: 4%; top: 5%; }
.cb-file { right: 5%; bottom: 4%; }
.cb-sq.l .cb-rank, .cb-sq.l .cb-file { color: var(--sq-d); }
.cb-sq.d .cb-rank, .cb-sq.d .cb-file { color: var(--sq-l); }
.cb-hl, .cb-pieces, .cb-badges { position: absolute; inset: 0; pointer-events: none; }
.cb-hl-sq, .cb-check, .cb-piece, .cb-badge-pos { position: absolute; left: 0; top: 0; width: 12.5%; height: 12.5%; }
.cb-hl-sq { background: var(--hl); animation: hlIn .3s var(--ease); }
@keyframes hlIn { from { opacity: 0; } }
.cb-hl-sq.t-blunder, .cb-hl-sq.t-miss { background: color-mix(in srgb, var(--c-blunder) 52%, transparent); }
.cb-hl-sq.t-mistake { background: color-mix(in srgb, var(--c-mistake) 52%, transparent); }
.cb-hl-sq.t-inaccuracy { background: color-mix(in srgb, var(--c-inaccuracy) 52%, transparent); }
.cb-hl-sq.t-brilliant { background: color-mix(in srgb, var(--c-brilliant) 52%, transparent); }
.cb-hl-sq.t-great { background: color-mix(in srgb, var(--c-great) 48%, transparent); }
.cb-hl-sq.t-best, .cb-hl-sq.t-excellent { background: color-mix(in srgb, var(--c-best) 40%, transparent); }
.cb-check { background: radial-gradient(circle, rgba(255, 40, 40, .85) 0%, rgba(230, 20, 20, .5) 35%, rgba(200, 0, 0, 0) 72%); }
.cb-piece {
  background-size: 100% 100%; will-change: transform;
  transition: transform .26s var(--ease);
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .22));
}
.cb-piece.moving { z-index: 2; }
.cb-piece.enter { animation: pieceIn .28s var(--ease); }
.cb-piece.leave { animation: pieceOut .26s var(--ease) forwards; z-index: 0; }
@keyframes pieceIn { from { opacity: 0; scale: .7; } }
@keyframes pieceOut { to { opacity: 0; scale: .6; } }
.cb-noanim .cb-piece { transition: none; }
/* move input (practice mode) */
.cb-interactive { cursor: pointer; }
.cb-dests { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.cb-dest, .cb-sel, .cb-hint { position: absolute; left: 0; top: 0; width: 12.5%; height: 12.5%; }
.cb-dest::after { content: ""; position: absolute; left: 50%; top: 50%; width: 30%; height: 30%; translate: -50% -50%; border-radius: 50%; background: rgba(20, 20, 30, .28); animation: hlIn .2s var(--ease); }
.cb-dest.capture::after { width: 86%; height: 86%; background: none; border: 5px solid rgba(20, 20, 30, .28); box-sizing: border-box; }
.cb-sel { background: color-mix(in srgb, var(--accent) 38%, transparent); }
.cb-hint { border-radius: 4px; box-shadow: inset 0 0 0 4px var(--c-great); animation: hintPulse 1.2s ease-in-out infinite; }
@keyframes hintPulse { 50% { box-shadow: inset 0 0 0 7px color-mix(in srgb, var(--c-great) 55%, transparent); } }
.cb-piece.dragging { transition: none; z-index: 10; scale: 1.12; filter: drop-shadow(0 8px 10px rgba(0, 0, 0, .35)); cursor: grabbing; }
.cb-arrow.wrong { color: var(--c-blunder); opacity: .45; }
.cb-arrows { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 3; }
.cb-arrow { animation: arrowIn .35s var(--ease); }
.cb-arrow line { stroke: currentColor; }
.cb-arrow polygon { fill: currentColor; }
.cb-arrow.best { color: var(--c-best); opacity: .85; }
.cb-arrow.engine { color: var(--engine-arrow); opacity: .72; }
@keyframes arrowIn { from { opacity: 0; } }
.cb-badges { z-index: 4; }
.cb-badge-pos .badge { position: absolute; top: -14%; right: -14%; width: 46%; height: 46%; font-size: clamp(8px, 1.5vw, 14px); margin: 0; animation: badgePop .45s var(--spring); }
@keyframes badgePop { from { transform: scale(0); } }
.cb-badge-pos.edge-r .badge { right: 2%; }
.cb-badge-pos.edge-t .badge { top: 2%; }

/* controls */
.controls {
  display: flex; align-items: center; gap: 6px; margin: 14px 0 0 38px; padding: 6px; border-radius: var(--r-card);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-1);
}
.ctl {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; min-width: 44px; padding: 0 10px;
  border-radius: var(--r-ctl); border: 0; background: transparent; color: var(--text-2); cursor: pointer; font-weight: 600; font-size: .88rem;
  transition: background-color .2s, color .2s, transform .15s var(--ease); touch-action: manipulation;
}
.ctl:hover { background: var(--surface-3); color: var(--text); }
.ctl span { white-space: nowrap; }
.controls { container-type: inline-size; }
.ctl:active { transform: scale(.92); }
.ctl .ico { width: 22px; height: 22px; }
.ctl-play { min-width: 56px; color: var(--accent-ink); background: var(--accent); }
.ctl-play:hover { background: var(--accent-hover); color: var(--accent-ink); }
.ctl-play .ico { fill: currentColor; stroke: none; }
.ctl-sep { flex: 1; }
.ctl-bot { color: var(--accent-text); background: var(--accent-soft); }
.ctl-bot:hover { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--accent-text); }
.ctl-bot .ico { width: 20px; height: 20px; }

/* ---------- cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); padding: 18px;
  box-shadow: var(--shadow-1); animation: fadeUp .5s var(--ease) backwards;
}
.panel-col > .card:nth-child(2) { animation-delay: .05s; }
.panel-col > .card:nth-child(3) { animation-delay: .1s; }
.panel-col > .card:nth-child(4) { animation-delay: .15s; }
.panel-col > .card:nth-child(5) { animation-delay: .2s; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.card-head h3 { font-size: 1.12rem; }

/* summary */
.analyzing { margin-bottom: 16px; }
.an-row { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: .9rem; }
.an-eta { margin-left: auto; color: var(--muted); font-weight: 500; font-size: .82rem; font-variant-numeric: tabular-nums; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--accent-soft); border-top-color: var(--accent); animation: spin .7s linear infinite; flex: none; }
.an-bar { position: relative; height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; margin-top: 10px; }
.an-bar > div { position: relative; height: 100%; width: 0; border-radius: inherit; background: var(--accent); transition: width .35s var(--ease); overflow: hidden; }
.an-bar > div::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .5), transparent); animation: sweep 1.3s linear infinite; }
@keyframes sweep { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.analyzing.error .spinner { display: none; }
.analyzing.error #an-text { color: var(--loss); }

.acc-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.acc { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: var(--r-ctl); background: var(--surface-2); border: 1px solid var(--border); min-width: 0; }
.ring { position: relative; width: 64px; height: 64px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 6; }
.ring .track { stroke: var(--surface-3); }
.ring .val { stroke: var(--ring-c, var(--accent)); stroke-linecap: round; transition: stroke-dashoffset 1.2s var(--ease), stroke .3s; }
.ring-num { position: absolute; inset: 0; display: grid; place-items: center; font: 600 1.12rem/1 var(--display); font-variant-numeric: tabular-nums lining-nums; letter-spacing: -.01em; }
.ring.pending .val { stroke: transparent; }
.ring.pending .ring-num { color: var(--muted); }
.acc-info { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.acc-name { display: flex; align-items: center; gap: 6px; font-weight: 650; font-size: .92rem; white-space: nowrap; overflow: hidden; }
.acc-name span:last-child { overflow: hidden; text-overflow: ellipsis; }
.acc-sub { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; font-weight: 600; }
.acc-rate { font-size: .85rem; color: var(--text-2); }
.acc-sub .src { margin-left: 4px; padding: 1px 6px; border-radius: 6px; background: color-mix(in srgb, var(--c-best) 16%, transparent); color: var(--c-best); text-transform: none; letter-spacing: 0; font-weight: 700; }
.acc-rate b { font-family: var(--display); font-weight: 600; font-size: 1.05rem; color: var(--text); font-variant-numeric: tabular-nums lining-nums; }

.story { margin: 16px 0 0; font: 1rem/1.6 var(--display); color: var(--text-2); animation: fadeUp .4s var(--ease); }
.story b { color: var(--text); font-weight: 650; }
.g-acc.mine { background: transparent; border: 1px dashed var(--border-strong); }
.moments { margin: 14px 0 0; }
.moments:empty { display: none; }
.moments-h { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin-bottom: 8px; }
.moments-row { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.moment {
  display: inline-flex; align-items: center; gap: 6px; flex: none; height: 32px; padding: 0 10px 0 4px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2); font-weight: 600; font-size: .82rem;
  cursor: pointer; transition: all .2s var(--ease); animation: fadeUp .35s var(--ease) backwards; animation-delay: calc(var(--i, 0) * 40ms);
}
.moment .badge { width: 24px; height: 24px; margin: 0; font-size: 10px; }
.moment:hover { border-color: var(--border-strong); color: var(--text); }
.moment.cur { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }

.tally { width: 100%; border-collapse: separate; border-spacing: 0 2px; font-variant-numeric: tabular-nums; table-layout: fixed; }
.tally th { font-size: .78rem; font-weight: 650; color: var(--muted); padding: 0 8px 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tally th:first-child { width: 52%; }
.tally td { padding: 5px 8px; font-size: .9rem; }
.tally td:first-child { border-radius: 6px 0 0 6px; }
.tally td:last-child { border-radius: 0 6px 6px 0; }
.tally td:nth-child(2), .tally td:nth-child(3) { text-align: center; font-weight: 700; }
.tally .lbl { display: flex; align-items: center; gap: 10px; font-weight: 550; }
.tally tr { cursor: pointer; transition: opacity .3s; }
.tally tr:hover td { background: var(--surface-2); }
.tally tr.zero { opacity: .32; }
.tally tr.zero:hover td { background: transparent; }

/* badges */
.badge {
  display: inline-flex; align-items: center; justify-content: center; flex: none; width: 24px; height: 24px; border-radius: 50%;
  color: #fff; font: 800 11px/1 var(--font); letter-spacing: -.6px; vertical-align: middle;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .14), 0 1px 3px rgba(0, 0, 0, .25);
}
.badge.sm { width: 17px; height: 17px; font-size: 8.5px; margin-left: 5px; box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .14); }
.c-brilliant { background: var(--c-brilliant); } .c-great { background: var(--c-great); } .c-best { background: var(--c-best); }
.c-excellent { background: var(--c-excellent); } .c-good { background: var(--c-good); } .c-forced { background: var(--c-forced); }
.c-inaccuracy { background: var(--c-inaccuracy); } .c-mistake { background: var(--c-mistake); } .c-miss { background: var(--c-miss); }
.c-blunder { background: var(--c-blunder); }
.c-book { background: var(--c-book); }

/* coach */
.coach-body { min-height: 64px; }
.coach-body.swap > * { animation: fadeUp .35s var(--ease) backwards; }
.coach-body.swap > *:nth-child(2) { animation-delay: .04s; }
.coach-body.swap > *:nth-child(3) { animation-delay: .08s; }
.coach-body.swap > *:nth-child(4) { animation-delay: .12s; }
.coach-body.swap > *:nth-child(5) { animation-delay: .16s; }
.coach-head { display: flex; align-items: center; gap: 12px; }
.coach-head .badge { width: 40px; height: 40px; font-size: 15px; }
.coach-head .badge.pending { background: var(--surface-3); color: var(--muted); box-shadow: none; }
.coach-title { flex: 1; min-width: 0; font-weight: 650; font-size: 1.04rem; line-height: 1.3; }
.coach-title .san { font-family: var(--display); font-weight: 700; }
.coach-title small { display: block; font-weight: 500; font-size: .8rem; color: var(--muted); margin-top: 2px; }
.eval-pill { flex: none; font: 600 .9rem/1 var(--font); font-variant-numeric: tabular-nums; padding: 8px 10px; border-radius: 10px; min-width: 56px; text-align: center; }
.eval-pill.w { background: #f4efe2; color: #2d2b26; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .1); }
.eval-pill.b { background: #2d2b26; color: #f4efe2; }
.coach-best { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 14px; font-size: .92rem; }
.san-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 9px; background: color-mix(in srgb, var(--c-best) 15%, transparent); color: var(--c-best); font-family: var(--display); font-weight: 700; }
.pv { display: flex; flex-wrap: wrap; gap: 3px 6px; margin-top: 8px; font-size: .85rem; color: var(--muted); }
.pv b { color: var(--text-2); font-weight: 600; }
.why { margin-top: 14px; padding: 12px 14px; border-radius: 14px; border: 1px solid; }
.why-h { display: flex; align-items: center; gap: 6px; font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; margin-bottom: 6px; }
.why-h .ico { width: 15px; height: 15px; }
.why p { margin: 0 0 4px; font-size: .92rem; line-height: 1.5; color: var(--text); }
.why p:last-child { margin: 0; }
.why-blunder, .why-miss { --wc: var(--c-blunder); }
.why-mistake { --wc: var(--c-mistake); }
.why-inaccuracy { --wc: var(--c-inaccuracy); }
.why-brilliant { --wc: var(--c-brilliant); }
.why { background: color-mix(in srgb, var(--wc) 9%, transparent); border-color: color-mix(in srgb, var(--wc) 30%, transparent); }
.why-h { color: var(--wc); }
.chances { display: flex; align-items: center; gap: 10px; margin-top: 12px; font-size: .82rem; color: var(--muted); }
.chances-bar { position: relative; flex: 1; height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.chances-bar i { position: absolute; top: 0; bottom: 0; left: 0; border-radius: inherit; }
.chances-bar .was { background: color-mix(in srgb, var(--c-blunder) 35%, transparent); }
.chances-bar .now { background: var(--text-2); transition: width .6s var(--ease); }
.chances b { color: var(--text); font-variant-numeric: tabular-nums; }
.coach-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.next-line { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--border-strong); font-size: .85rem; }
.next-line .pv { margin-top: 4px; }

.human { margin-top: 14px; }
.human-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.human-list li { display: grid; grid-template-columns: 70px 1fr 42px; align-items: center; gap: 10px; font-size: .9rem; }
.human-list .san { font-weight: 700; font-family: var(--display); }
.human-list .bar { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.human-list .bar > div { height: 100%; border-radius: inherit; background: var(--viz-series); animation: grow .6s var(--ease); transform-origin: left; }
.human-list li.played .san { color: var(--accent-text); }
.human-list .pct { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
@keyframes grow { from { transform: scaleX(0); } }
.human-note { font-size: .88rem; color: var(--text-2); }

/* graph */
.graph-wrap { position: relative; height: 150px; border-radius: 6px; overflow: hidden; cursor: crosshair; }
.graph { width: 100%; height: 100%; display: block; }
.graph .g-top { fill: var(--graph-top); }
.graph .g-area { fill: var(--graph-bottom); transition: d .4s var(--ease); }
.graph .g-line { fill: none; stroke: var(--brass); stroke-width: 2; vector-effect: non-scaling-stroke; opacity: .9; }
.graph .g-mid { stroke: rgba(150, 150, 160, .55); stroke-width: 1; stroke-dasharray: 4 4; vector-effect: non-scaling-stroke; }
.graph .g-cur { stroke: var(--brass); stroke-width: 2; vector-effect: non-scaling-stroke; transition: transform .3s var(--ease); }
.graph .g-hover { stroke: rgba(150, 150, 160, .9); stroke-width: 1; vector-effect: non-scaling-stroke; }
.g-dots { position: absolute; inset: 0; pointer-events: none; }
.g-dot { position: absolute; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .4); animation: badgePop .4s var(--spring) backwards; }
.tchart { margin-top: 18px; }
.tchart-wrap { position: relative; height: 80px; border-radius: 6px; background: var(--surface-2); cursor: pointer; }
.tchart-wrap svg { width: 100%; height: 100%; display: block; }
.tchart .t-mid { stroke: var(--border-strong); stroke-width: 1; vector-effect: non-scaling-stroke; }
.tb { transition: opacity .2s, fill .2s; }
.tb.w { fill: var(--text-2); opacity: .45; }
.tb.b { fill: var(--muted); opacity: .75; }
.tb.t-inaccuracy { fill: var(--c-inaccuracy); opacity: 1; }
.tb.t-mistake { fill: var(--c-mistake); opacity: 1; }
.tb.t-blunder, .tb.t-miss { fill: var(--c-blunder); opacity: 1; }
.tb.t-brilliant { fill: var(--c-brilliant); opacity: 1; }
.tb.t-great { fill: var(--c-great); opacity: 1; }
.tb.cur { fill: var(--brass); opacity: 1; }
.graph-tip {
  position: absolute; top: 8px; transform: translateX(-50%); padding: 5px 9px; border-radius: 8px; white-space: nowrap;
  background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); box-shadow: var(--shadow-2);
  font-size: .8rem; font-weight: 600; pointer-events: none; z-index: 2;
}
.graph-tip .muted { font-weight: 500; }

/* moves */
.moves { position: relative; display: grid; grid-template-columns: 38px 1fr 1fr; gap: 2px 6px; max-height: 360px; overflow-y: auto; font-variant-numeric: tabular-nums; scrollbar-width: thin; }
.moves .no { color: var(--muted); text-align: right; padding: 6px 4px 6px 0; font-size: .85rem; }
.mv {
  display: flex; align-items: center; padding: 5px 10px; border-radius: 6px; cursor: pointer; font-weight: 600; font-size: .92rem;
  transition: background-color .15s, color .15s;
}
.mv:hover { background: var(--surface-3); }
.mv.cur { background: var(--accent); color: var(--accent-ink); }
.mv.empty { cursor: default; }
.mv.empty:hover { background: none; }
.mv.t-blunder:not(.cur), .mv.t-miss:not(.cur) { color: var(--c-blunder); }
.mv.t-mistake:not(.cur) { color: var(--c-mistake); }
.mv.t-inaccuracy:not(.cur) { color: color-mix(in srgb, var(--c-inaccuracy) 85%, var(--text)); }
.mv.t-brilliant:not(.cur) { color: var(--c-brilliant); }
.mv.t-great:not(.cur) { color: var(--c-great); }

/* ---------- insights ---------- */
.results-head { row-gap: 10px; }
.insights { display: flex; flex-direction: column; gap: 16px; animation: viewIn .4s var(--ease); }
.ins-loading { display: flex; align-items: center; gap: 10px; padding: 24px 4px; }
.ins-take { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.take { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--r-card); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-1); animation: fadeUp .45s var(--ease) backwards; animation-delay: calc(var(--i, 0) * 60ms); }
.take p { margin: 0; font-size: .92rem; line-height: 1.5; color: var(--text-2); }
.take b { color: var(--text); }
.take-ico { width: 30px; height: 30px; flex: none; display: grid; place-items: center; color: var(--brass); }
.take-ico .ico { width: 18px; height: 18px; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi { padding: 14px 16px; border-radius: var(--r-card); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-1); min-width: 0; }
.kpi-label { font-size: .8rem; color: var(--muted); font-weight: 600; }
.kpi-value { font: 600 2rem/1.15 var(--display); margin-top: 2px; letter-spacing: -.01em; font-variant-numeric: lining-nums; }
.kpi-sub { font-size: .8rem; color: var(--muted); margin-top: 2px; }
.kpi .segbar { margin-top: 10px; }
.kpi.small { padding: 10px 12px; box-shadow: none; background: var(--surface-2); }
.kpi.small .kpi-value { font-size: 1.4rem; }
.delta { font-weight: 700; }
.delta.up { color: var(--viz-win); }
.delta.down { color: var(--viz-loss); }
.ins-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.ins-card.wide { grid-column: 1 / -1; }
.ins-card .card-head { flex-wrap: wrap; gap: 6px 12px; align-items: center; }
.ins-foot { margin: 8px 0 0; }
/* thin segmented win/draw/loss bar */
.segbar { display: flex; gap: 2px; height: 8px; border-radius: 99px; overflow: hidden; background: var(--surface-3); }
.segbar i { display: block; height: 100%; min-width: 3px; }
.segbar .w, .viz-legend .w { background: var(--viz-win); }
.segbar .d, .viz-legend .d { background: var(--viz-draw); }
.segbar .l, .viz-legend .l { background: var(--viz-loss); }
.viz-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .78rem; color: var(--muted); }
.viz-legend span { display: inline-flex; align-items: center; gap: 6px; }
.viz-legend .sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.viz-legend .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.viz-legend .ln { width: 14px; height: 2px; border-radius: 2px; display: inline-block; background: var(--viz-series); }
/* meter list (openings) */
.meters { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.meters li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; }
.m-name { font-weight: 600; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-fig { font-size: .82rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.meters .segbar { grid-column: 1 / -1; }
/* ranked bars */
.rbars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.rbars li { display: grid; grid-template-columns: minmax(90px, 40%) minmax(0, 1fr) 36px; align-items: center; gap: 10px; }
.rb-label { font-size: .88rem; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rb-track { height: 12px; display: block; }
.rb-track i { display: block; height: 100%; border-radius: 0 4px 4px 0; min-width: 2px; animation: grow .6s var(--ease); transform-origin: left; }
.rbars.win .rb-track i { background: var(--viz-win); }
.rbars.loss .rb-track i { background: var(--viz-loss); }
.rbars.series .rb-track i { background: var(--viz-series); }
.rb-val { font-size: .85rem; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
/* line / dot charts */
.lc { position: relative; width: 100%; }
.lc svg { display: block; cursor: crosshair; overflow: visible; }
.lc .v-grid { stroke: var(--viz-grid); stroke-width: 1; }
.lc .v-tick { fill: var(--muted); font: 500 11px/1 var(--font); font-variant-numeric: tabular-nums; }
.lc .v-line { fill: none; stroke: var(--viz-series); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.lc .v-area { fill: var(--viz-series); opacity: .1; }
.lc .v-end, .lc .v-hover { fill: var(--viz-series); stroke: var(--surface); stroke-width: 2; }
.lc .v-endlabel { fill: var(--text); font: 700 12px/1 var(--font); }
.lc .v-cross { stroke: var(--viz-axis); stroke-width: 1; }
.lc .v-dot { stroke: var(--surface); stroke-width: 2; }
.lc .v-dot.w { fill: var(--viz-win); }
.lc .v-dot.d { fill: var(--viz-draw); }
.lc .v-dot.l { fill: var(--viz-loss); }
.lc .graph-tip { top: -6px; white-space: normal; max-width: min(320px, 80%); text-align: left; }
/* mistake patterns */
.patterns h4 { margin: 0 0 12px; font-size: .9rem; color: var(--text-2); }
.pat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; margin-bottom: 16px; }
.pat-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.pat-empty { margin: 0 0 14px; color: var(--text-2); font-size: .92rem; max-width: 70ch; }
.batch { margin-top: 4px; }
.batch .an-row { flex-wrap: wrap; }
.batch-note { margin-left: 12px; }
/* progress */
.delta.flat { color: var(--muted); font-weight: 600; }
.prog-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.prog-table-wrap { margin-top: 16px; max-height: 340px; overflow: auto; border-radius: 12px; border: 1px solid var(--border); }
.prog-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: .88rem; }
.prog-table th { position: sticky; top: 0; background: var(--surface-2); text-align: left; font-weight: 650; color: var(--muted); font-size: .78rem; padding: 8px 12px; white-space: nowrap; }
.prog-table td { padding: 8px 12px; border-top: 1px solid var(--border); white-space: nowrap; }
.prog-table td:first-child { font-weight: 600; }
.cell-bar { display: inline-block; width: 46px; height: 6px; border-radius: 99px; background: var(--surface-3); margin-right: 8px; vertical-align: middle; overflow: hidden; }
.cell-bar i { display: block; height: 100%; background: var(--viz-series); border-radius: inherit; }
/* winning and losing positions */
.conv-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.4fr); gap: 12px; align-items: start; }
.conv-grid h4, .conv-h { margin: 0 0 10px; font-size: .9rem; color: var(--text-2); }
.conv-h { margin-top: 18px; }
.thrown { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.thrown li { display: flex; gap: 6px; align-items: stretch; }
.thrown .t-play { flex: none; height: auto; min-height: 40px; }
.thrown .t-open { flex: 1; min-width: 0; width: 100%; display: grid; grid-template-columns: 52px minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 8px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font: inherit; font-size: .88rem; cursor: pointer; text-align: left; transition: border-color .2s, transform .2s var(--ease); }
.thrown .t-open:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.t-res { font-weight: 700; font-size: .8rem; text-align: center; padding: 3px 0; border-radius: 7px; background: var(--surface-3); color: var(--text-2); }
.t-res.loss { color: var(--viz-loss); background: color-mix(in srgb, var(--viz-loss) 14%, transparent); }
.t-main { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-peak { color: var(--muted); font-size: .82rem; font-variant-numeric: tabular-nums; }
.t-go { color: var(--accent-text); font-weight: 600; font-size: .82rem; }
/* opening tree */
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 4px; margin-bottom: 14px; font-size: .88rem; }
.crumbs span { color: var(--muted); }
.crumbs button { border: 0; background: none; color: var(--accent-text); font: inherit; font-weight: 600; padding: 3px 6px; border-radius: 7px; cursor: pointer; }
.crumbs button:hover { background: var(--accent-soft); }
.crumbs button:last-child { color: var(--text); }
.tree-body { display: grid; grid-template-columns: minmax(180px, 260px) minmax(0, 1fr); gap: 20px; align-items: start; }
.tree-board { width: 100%; aspect-ratio: 1; border-radius: 10px; overflow: hidden; box-shadow: var(--shadow-2); }
.tree-stat { margin: 8px 0 0; }
.tree-h { font-weight: 650; font-size: .85rem; color: var(--text-2); margin: 0 0 8px; }
.spots-h { margin-top: 20px; }
.spots-note { margin: -4px 0 8px; }
.tree-table { width: 100%; border-collapse: separate; border-spacing: 0 2px; font-variant-numeric: tabular-nums; }
.tree-table tr { cursor: pointer; }
.tree-table td { padding: 7px 8px; font-size: .9rem; }
.tree-table tr:hover td, .tree-table tr:focus-visible td { background: var(--surface-2); }
.tree-table tr:focus-visible { outline: none; }
.tree-table td:first-child { border-radius: 9px 0 0 9px; }
.tree-table td:last-child { border-radius: 0 9px 9px 0; }
.tt-move { font-weight: 650; white-space: nowrap; }
.tt-warn { display: inline-flex; align-items: center; gap: 2px; margin-left: 8px; font-size: .75rem; font-weight: 700; color: var(--c-mistake); }
.tt-warn .ico { width: 13px; height: 13px; }
.tt-n { color: var(--muted); width: 44px; text-align: right; }
.tt-bar { width: 45%; }
.tt-score { width: 48px; text-align: right; font-weight: 600; }
.tree-alert { padding: 12px 14px; border-radius: 14px; margin-bottom: 14px; background: color-mix(in srgb, var(--c-mistake) 9%, transparent); border: 1px solid color-mix(in srgb, var(--c-mistake) 30%, transparent); }
.tree-alert p { margin: 4px 0 10px; font-size: .9rem; color: var(--text-2); }
.ta-h { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: .9rem; color: var(--c-mistake); }
.spots { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.spots li { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 4px 12px; align-items: center; padding: 8px 12px; border-radius: 12px; background: var(--surface-2); }
.sp-line { font-size: .88rem; min-width: 0; overflow-wrap: anywhere; }
.sp-act { display: flex; gap: 6px; }
.sp-act .btn-sm { height: 32px; padding: 0 10px; font-size: .82rem; }

@media (max-width: 980px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .prog-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .conv-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .conv-grid > div:last-child { grid-column: 1 / -1; }
  .ins-grid, .pat-grid { grid-template-columns: minmax(0, 1fr); }
  .batch-note { display: block; margin: 8px 0 0; }
}
@media (max-width: 640px) {
  .tree-body { grid-template-columns: minmax(0, 1fr); }
  .tree-board-wrap { max-width: 280px; }
  .spots li { grid-template-columns: minmax(0, 1fr); }
  .thrown .t-open { grid-template-columns: 44px minmax(0, 1fr) auto; gap: 8px; padding: 8px 10px; }
  .thrown .t-go, .thrown .t-peak-l { display: none; }
  .thrown .t-play { padding: 0 10px; }
  .rbars li { grid-template-columns: minmax(0, 1fr) 36px; gap: 4px 10px; }
  .rb-label { grid-column: 1 / -1; white-space: normal; }
  .kpi-value { font-size: 1.5rem; }
  .results-head .seg { order: -1; }
}

/* ---------- play it out vs a bot ---------- */
.coach { scroll-margin-top: 84px; }
.play-here { margin-top: 12px; color: var(--accent-text); padding: 0 12px 0 8px; }
body.playing .evalbar { visibility: hidden; }
.conv-sub { margin: -4px 0 10px; }
.po-icon .ico { width: 22px; height: 22px; }
.po-elo { font-family: var(--display); color: var(--accent-text); margin-left: 2px; }
.po-label { margin: 16px 0 8px; font-size: .74rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.po-presets { display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); gap: 6px; }
.po-preset {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 9px 6px; border-radius: 12px; cursor: pointer; font: inherit;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2); transition: border-color .2s, background-color .2s, transform .15s var(--ease);
}
.po-preset span { font-size: .78rem; font-weight: 600; }
.po-preset b { font-family: var(--display); font-size: 1.15rem; color: var(--text); font-variant-numeric: tabular-nums; }
.po-preset:hover:not(:disabled) { border-color: var(--border-strong); }
.po-preset:active:not(:disabled) { transform: scale(.96); }
.po-preset.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); box-shadow: 0 0 0 1px var(--accent) inset; }
.po-preset.active b { color: var(--accent-text); }
.po-preset:disabled { cursor: default; opacity: .6; }
.po-side button { display: inline-flex; align-items: center; gap: 8px; }
.po-note { display: flex; gap: 8px; align-items: flex-start; margin: 10px 0 0; font-size: .84rem; color: var(--muted); }
.po-note .ico { flex: none; margin-top: 2px; }
.po-load { margin-top: 16px; }
.po-status { display: flex; align-items: center; gap: 10px; margin-top: 14px; padding: 10px 14px; border-radius: 12px; font-weight: 700; font-size: .92rem; background: var(--surface-2); border: 1px solid var(--border); }
.po-status.turn-you { color: var(--accent-text); background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.po-status.turn-bot { color: var(--text-2); }
.po-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent); animation: poPulse 1.6s ease-in-out infinite; }
@keyframes poPulse { 50% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--accent) 8%, transparent); } }
.po-moves { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 6px; margin-top: 12px; max-height: 132px; overflow-y: auto; font-size: .9rem; }
.po-no { color: var(--muted); font-variant-numeric: tabular-nums; font-size: .82rem; }
.po-mv { font-weight: 650; padding: 2px 7px; border-radius: 7px; background: var(--surface-2); }
.po-mv.mine { color: var(--text); }
.po-mv.theirs { color: var(--text-2); }
.po-mv.last { background: var(--accent-soft); color: var(--accent-text); }
.po-empty { margin: 12px 0 0; min-height: 1.2em; }
.po-resign:hover { color: var(--c-blunder); }
.po-over { display: flex; align-items: center; gap: 16px; margin-top: 14px; }
.po-res { flex: none; padding: 10px 14px; border-radius: 16px; font-family: var(--display); font-weight: 700; font-size: 1.5rem; color: #fff; background: var(--viz-draw); animation: badgePop .5s var(--spring); }
.po-over.win .po-res { background: var(--c-best); }
.po-over.loss .po-res { background: var(--viz-loss); }
@media (prefers-reduced-motion: reduce) { .po-dot { animation: none; } }

/* ---------- practice mode ---------- */
.practice-cta:empty { display: none; }
.practice-cta { margin-top: 14px; }
.practice-btn { height: 50px; font-size: 1rem; }
.retry-btn { margin-top: 12px; }
body.practicing .controls, body.playing .controls { display: none; }
body.practicing .board-shell, body.playing .board-shell { touch-action: none; }
body.practicing .board-shell, body.playing .board-shell { box-shadow: var(--shadow-3), 0 0 0 3px color-mix(in srgb, var(--accent) 55%, transparent); }
body.practicing .coach, body.playing .coach { border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.pr-head { display: flex; align-items: center; gap: 12px; }
.pr-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; color: #fff; background: var(--accent); }
.pr-exit { flex: none; }
.pr-dots { display: flex; gap: 6px; margin: 12px 0 2px; flex-wrap: wrap; }
.pr-dot { width: 22px; height: 6px; border-radius: 99px; background: var(--surface-3); transition: background-color .3s; }
.pr-dot.cur { background: var(--accent); }
.pr-dot.found { background: var(--c-best); }
.pr-dot.revealed { background: var(--c-inaccuracy); }
.pr-dot.skipped { background: var(--border-strong); }
.pr-prompt { margin: 12px 0 0; color: var(--text-2); font-size: .94rem; }
.pr-cls { font-weight: 700; }
.pr-cls.t-blunder, .pr-cls.t-miss { color: var(--c-blunder); }
.pr-cls.t-mistake { color: var(--c-mistake); }
.pr-cls.t-inaccuracy { color: color-mix(in srgb, var(--c-inaccuracy) 85%, var(--text)); }
.pr-result { margin-top: 14px; padding: 12px 14px; border-radius: 14px; border: 1px solid; animation: fadeUp .3s var(--ease); --rc: var(--accent); background: color-mix(in srgb, var(--rc) 9%, transparent); border-color: color-mix(in srgb, var(--rc) 32%, transparent); }
.pr-result p { margin: 4px 0 0; font-size: .93rem; }
.pr-result.ok { --rc: var(--c-best); }
.pr-result.bad { --rc: var(--c-blunder); }
.pr-result.shown { --rc: var(--c-inaccuracy); }
.pr-result.checking { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: .9rem; }
.pr-res-h { display: flex; align-items: center; gap: 6px; font-weight: 800; color: var(--rc); }
.pr-res-h .ico { width: 18px; height: 18px; }
.pr-why { color: var(--text-2); }
.pr-hint { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: .9rem; color: var(--text-2); }
.pr-hint .ico { color: var(--c-great); }
.pr-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.pr-done { display: flex; align-items: center; gap: 16px; }
.pr-score { display: flex; align-items: baseline; gap: 4px; padding: 10px 16px; border-radius: 16px; background: var(--accent); color: #fff; font-family: var(--display); animation: badgePop .5s var(--spring); }
.pr-score b { font-size: 2rem; line-height: 1; }
.pr-title { font-family: var(--display); font-weight: 700; font-size: 1.2rem; }
.pr-list { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.pr-list li { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: .9rem; padding: 4px 6px; border-radius: 8px; }
.pr-list .badge.sm { margin: 0; }
.pr-st { margin-left: auto; font-size: .78rem; font-weight: 700; color: var(--muted); }
.pr-list li.found .pr-st { color: var(--c-best); }
.pr-list li.revealed .pr-st { color: var(--c-inaccuracy); }

/* ---------- faq / footer / toast ---------- */
.faq { padding: 8px 0 24px; }
.faq details { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow-1); max-width: 820px; }
.faq summary { cursor: pointer; padding: 16px 20px; font-weight: 650; list-style: none; display: flex; align-items: center; justify-content: space-between; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font-size: 1.3rem; color: var(--muted); transition: transform .3s var(--ease); }
.faq details[open] summary::after { transform: rotate(45deg); }
.faq-body { padding: 0 20px 18px; color: var(--text-2); font-size: .92rem; animation: fadeUp .35s var(--ease); }
.legend { list-style: none; padding: 0; margin: 12px 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 8px 16px; }
.legend li { display: flex; align-items: center; gap: 10px; }
.legend b { color: var(--text); }

footer { max-width: 1280px; margin: 0 auto; padding: 8px 24px 32px; color: var(--muted); font-size: .76rem; }

.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 200; transform: translateX(-50%); max-width: calc(100vw - 32px);
  display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 14px;
  background: var(--text); color: var(--bg); font-weight: 550; font-size: .9rem; box-shadow: var(--shadow-3);
  animation: toastIn .35s var(--spring);
}
.toast .ico { color: var(--c-mistake); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 16px) scale(.96); } }

/* ---------- tablets & phones ---------- */
@media (max-width: 980px) {
  .hero { grid-template-columns: minmax(0, 1fr); gap: 28px; padding-top: 24px; }
  .hero-board { order: 2; }
  .demo-frame { max-width: 340px; transform: none; }
  .search-card { max-width: none; }

  .review-grid { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .board-col { position: static; max-width: 640px; width: 100%; margin: 0 auto; }
  .panel-col { max-width: 640px; width: 100%; margin: 0 auto; }
  .card { padding: 14px; border-radius: 18px; }

  body.reviewing { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
  body.reviewing .controls {
    position: fixed; z-index: 60; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); margin: 0;
    background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-strong); box-shadow: var(--shadow-3); border-radius: var(--r-card); justify-content: space-between;
  }
  body.reviewing .controls .ctl { flex: 1; min-width: 0; height: 50px; }
  body.reviewing .controls .ctl-play { flex: 1.3; }
  .ctl-sep, .ctl-flip { display: none; }
  .moves { max-height: 280px; }
}
@media (max-width: 980px) and (min-width: 641px) {
  .controls { max-width: 640px; }
}
@media (min-width: 981px) {
  #btn-flip-top { display: none; }
}
@media (max-width: 640px) {
  .topbar { padding: calc(10px + env(safe-area-inset-top)) 14px 10px; height: calc(58px + env(safe-area-inset-top)); }
  #btn-install span { display: none; }
  #btn-install { width: 40px; padding: 0; }
  main { padding: 0 12px; }
  .hero h1 { font-size: 2.1rem; }
  .lede { font-size: 1rem; margin: 14px 0 20px; }
  .search { flex-direction: column; }
  .search input { font-size: 16px; flex: none; width: 100%; }
  .search .btn { width: 100%; }
  .search-ico { top: 26px; }
  #pgn-input { font-size: 16px; }
  .game-grid { grid-template-columns: minmax(0, 1fr); }
  .profile { padding: 14px; gap: 12px; }
  .pf-ratings { margin-left: 0; width: 100%; }
  .rating-chip { flex: 1; min-width: 0; padding: 6px 8px; justify-content: center; }
  .record { width: 100%; }
  .popover { left: 12px; right: 12px; width: auto; }

  body.reviewing .topbar { position: relative; }
  .review-head { padding: 4px 0 10px; gap: 8px; }
  .review-head .btn-ghost span { display: none; }
  .rh-title h2 { font-size: 1.05rem; }
  .rh-meta { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .rh-meta::-webkit-scrollbar { display: none; }
  .tag { flex: none; }
  .rh-actions .icon-btn { width: 36px; height: 36px; }
  .player-card { padding-left: 0; min-height: 44px; padding-top: 4px; padding-bottom: 4px; }
  .p-avatar { width: 30px; height: 30px; border-radius: 8px; font-size: .8rem; }
  .p-clock { font-size: .9rem; padding: 6px 9px; min-width: 64px; }
  .board-row { gap: 6px; }
  .evalbar { width: 16px; border-radius: 6px; }
  .evalbar-txt { font-size: 7.5px; }
  .acc-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
  .acc { flex-direction: column; align-items: flex-start; gap: 8px; padding: 10px; }
  .ring { width: 56px; height: 56px; }
  .legend { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
.c-excellent { letter-spacing: -3px; text-indent: -2px; }

/* ---------- findability (Maia) ---------- */
.find { display: flex; align-items: baseline; gap: 10px; margin-top: 12px; font-size: .9rem; line-height: 1.45; }
.find-tag { flex: none; font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; padding: 3px 7px; border-radius: 4px; background: var(--fb); color: var(--fi); position: relative; top: -1px; }
.find-findable { --fb: var(--find-findable); --fi: var(--find-findable-ink); }
.find-tricky { --fb: var(--find-tricky); --fi: var(--find-tricky-ink); }
.find-hard { --fb: var(--find-hard); --fi: var(--find-hard-ink); }
.find-wait { align-items: center; color: var(--muted); }
.find-text { color: var(--text-2); }
.find-btn { margin-top: 10px; padding: 0 10px 0 8px; height: 34px; color: var(--accent-text); }
.find-sum { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.find-sum h4 { margin: 0 0 10px; }
.find-bar { display: flex; height: 14px; overflow: hidden; gap: 2px; }
.find-bar i:first-child { border-radius: 4px 0 0 4px; }
.find-bar i:last-child { border-radius: 0 4px 4px 0; }
.find-bar i:only-child { border-radius: 4px; }
.find-bar i, .find-legend .sw { background: var(--fl); }
.fl-findable { --fl: var(--find-findable); }
.fl-tricky { --fl: var(--find-tricky); }
.fl-hard { --fl: var(--find-hard); }
.find-legend { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 10px 0 4px; padding: 0; font-size: .86rem; color: var(--text-2); }
.find-legend li { display: flex; align-items: center; gap: 6px; }
.find-legend b { color: var(--text); font-variant-numeric: tabular-nums; margin-left: 2px; }
.find-legend .sw { width: 10px; height: 10px; border-radius: 3px; }
.find-run { margin-top: 10px; }

/* ---------- coach, decluttered ---------- */
.coach-best { margin-top: 14px; }
.coach-best .pv { margin: 0; display: inline-flex; }
.why { margin-top: 14px; padding: 2px 0 2px 14px; border: 0; border-left: 3px solid var(--wc); border-radius: 0; background: none; }
.why-h { display: inline; font-size: inherit; text-transform: none; letter-spacing: 0; font-weight: 700; margin: 0 4px 0 0; }
.why-h .ico { display: none; }
.why p { display: inline; margin: 0; font-size: .95rem; line-height: 1.55; color: var(--text); }
.why p + p::before { content: " "; }
.coach-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 12px; font-size: .84rem; color: var(--muted); }
.coach-meta b { color: var(--text-2); font-variant-numeric: tabular-nums; font-weight: 600; }
.coach-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.coach-actions:empty { display: none; }
.coach-actions .btn { height: 36px; padding: 0 12px; }
.coach-actions .retry-btn, .coach-actions .play-here { margin: 0; }
/* The dock's outer buttons jump between mistakes. */
.ctl-mistake-nav { color: var(--c-mistake); }
.ctl-mistake-nav:disabled { color: var(--muted); opacity: .45; cursor: default; }
.ctl[hidden] { display: none !important; }
.next-line { display: flex; gap: 8px; align-items: baseline; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); font-size: .85rem; }
.next-line .pv { margin: 0; flex: 1; min-width: 0; }
.human { margin-top: 10px; }
#btn-human { justify-content: flex-start; background: none; color: var(--accent-text); padding: 6px 0; min-height: 0; height: auto; font-size: .88rem; }
#btn-human:hover { text-decoration: underline; }
#btn-human.human-loading { color: var(--muted); cursor: default; text-decoration: none; }
#btn-human.human-loading .ico { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.ins-sec { grid-column: 1 / -1; font-size: 1.35rem; margin: 14px 0 -4px; display: flex; align-items: baseline; gap: 12px; }
.ins-sec::after { content: ""; flex: 1; height: 1px; background: var(--border); transform: translateY(-4px); }

/* once games are listed, the hero shrinks to just the search */
#home:has(#results:not([hidden])) .hero { grid-template-columns: minmax(0, 1fr); gap: 0; padding: 24px 0 12px; }
#home:has(#results:not([hidden])) .hero-board,
#home:has(#results:not([hidden])) .lede,
#home:has(#results:not([hidden])) .eyebrow { display: none; }
#home:has(#results:not([hidden])) .hero h1 { font-size: clamp(1.6rem, 3vw, 2.2rem); margin-bottom: 16px; }
@media (max-width: 640px) { #home:has(#results:not([hidden])) .hero h1 { display: none; } }

/* ==========================================================================
   Liquid Glass: frosted floating chrome, soft cards, capsule controls
   ========================================================================== */
body { background: var(--wash); background-attachment: fixed; font-size: 15px; letter-spacing: -.005em; }
h1 { font-weight: 700; letter-spacing: -.035em; }
h2, h3 { font-weight: 650; letter-spacing: -.015em; }
.brand { font-family: var(--display); font-weight: 650; font-size: 1.12rem; letter-spacing: -.02em; }
.brand-name em { font-style: normal; color: inherit; font-weight: inherit; }
.brand-mark { border-radius: 10px; background: var(--accent); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25); }

.card, .game, .profile, .take, .kpi, .search-card { background: var(--card); border: 1px solid var(--card-edge); box-shadow: var(--card-shadow); }
.acc, .kpi.small { background: var(--surface-2); border: 0; box-shadow: none; }
.topbar::before { background: var(--chrome); backdrop-filter: blur(28px) saturate(1.8); -webkit-backdrop-filter: blur(28px) saturate(1.8); border-bottom: 1px solid var(--border); }
.controls, .popover, .toast {
  background: var(--chrome); border: 1px solid var(--chrome-edge); box-shadow: var(--chrome-shadow);
  backdrop-filter: blur(28px) saturate(1.8); -webkit-backdrop-filter: blur(28px) saturate(1.8);
}
body.reviewing .controls { background: var(--chrome); }
.popover { border-radius: 22px; }

.btn, .chip, .seg, .seg button, .recent button, .ctl, .tag, .moment, .icon-btn, .san-chip, .you { border-radius: 999px; }
.btn-soft { background: var(--accent-soft); color: var(--accent-text); }
.btn-ghost:hover, .icon-btn:hover, .ctl:hover { background: var(--fill); }
.icon-btn { border: 0; background: var(--fill); color: var(--text); }
.seg { background: var(--fill); padding: 2px; border-radius: 999px; }
.seg button { color: var(--text-2); }
.seg button.active { background: var(--seg-on); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .12), 0 0 0 .5px rgba(0, 0, 0, .04); }
.chip { background: var(--fill); border-color: transparent; color: var(--text); }
.chip.active { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.chip.active .n { color: inherit; opacity: .8; }
.tag { background: var(--fill); color: var(--text-2); }
.search input, #pgn-input { background: var(--fill); border-color: transparent; }
.search input:focus, #pgn-input:focus { background: var(--surface); }
.recent button { background: var(--fill); border-color: transparent; }

.board-shell, #board { border-radius: 14px; }
.board-shell { box-shadow: 0 18px 44px -20px rgba(0, 0, 0, .55); }
.demo-frame { padding: 0; background: none; border-radius: 18px; box-shadow: 0 24px 60px -24px rgba(0, 0, 0, .5); }
#demo-board { border-radius: 18px; }
.demo-caption { font: .8rem/1.4 var(--font); }
.evalbar { border-radius: 8px; outline: none; box-shadow: inset 0 0 0 1px var(--border-strong); }
.p-clock { border-radius: 10px; }
.p-avatar { border-radius: 50%; }
.avatar { border-radius: 50%; }
.res { border-radius: 12px; font-family: var(--font); font-weight: 700; }
.g-acc { border-radius: 8px; font-family: var(--font); }
.mv { border-radius: 8px; }
.mv.cur { background: var(--accent); color: var(--accent-ink); }
.story { font: .98rem/1.6 var(--font); color: var(--text-2); }
.ring-num { font: 650 1.05rem/1 var(--font); letter-spacing: -.02em; }
.acc-rate b, .kpi-value { font-family: var(--font); font-weight: 700; letter-spacing: -.03em; }
.kpi-value { font-size: 1.85rem; }
.acc-sub { letter-spacing: .04em; }
.card-head h3 { font-size: 1.05rem; }
.topline > div, .an-bar > div { background: var(--accent); }
.hero h1 { font-size: clamp(2.2rem, 4.4vw, 3.4rem); line-height: 1.05; }
.lede { font-size: 1.08rem; }
.game::before { display: none; }
.p-avatar.bot { background: var(--accent); color: #fff; }
.find-tag { border-radius: 6px; }

/* review panel: pinned accuracy, then tabs */
.summary { padding: 12px; }
.summary .analyzing { margin: 4px 4px 14px; }
.panel-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 3px; }
.panel-tabs button { justify-content: center; padding: 9px 0; font-size: .93rem; font-weight: 600; border-radius: 999px; }
.tab-pane { display: flex; flex-direction: column; gap: 16px; animation: fadeUp .3s var(--ease); }
.tab-pane[hidden] { display: none; }
.story-card .story { margin: 0; }
.story-card .story[hidden] + .moments { margin-top: 0; }
.story-card .moments { margin-top: 16px; }
.story-card .practice-cta:empty { display: none; }
.moves { max-height: min(70vh, 640px); }

/* game header: one quiet line of facts instead of pills */
.rh-meta { gap: 0; }
.rh-meta .tag { background: none; padding: 0; height: auto; font-size: .85rem; font-weight: 500; color: var(--muted); border-radius: 0; }
.rh-meta .tag .ico { display: none; }
.rh-meta .tag + .tag::before { content: "·"; margin: 0 7px; color: var(--muted); }
.rh-meta .tag.win { color: var(--win); background: none; font-weight: 600; }
.rh-meta .tag.loss { color: var(--loss); background: none; font-weight: 600; }

/* insights: four tabs, one part at a time */
.ins-tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); max-width: 620px; padding: 3px; }
.ins-tabs button { justify-content: center; padding: 9px 0; font-size: .93rem; font-weight: 600; border-radius: 999px; }
.ins-pane { animation: fadeUp .3s var(--ease); }
.ins-pane[hidden] { display: none; }
.kpis.wide { grid-column: 1 / -1; }
.focus-list { list-style: none; margin: 0; padding: 0; }
.focus-list li { padding: 12px 0; border-top: 1px solid var(--border); font-size: .97rem; line-height: 1.5; color: var(--text-2); }
.focus-list li:first-child { border-top: 0; padding-top: 2px; }
.focus-list li:last-child { padding-bottom: 0; }
.focus-list b { color: var(--text); }
.nudge { display: flex; align-items: center; gap: 16px; justify-content: space-between; flex-wrap: wrap; }
.nudge p { margin: 0; flex: 1; min-width: 240px; color: var(--text-2); font-size: .94rem; }
.nudge b { color: var(--text); }

@media (max-width: 640px) {
  .summary { padding: 8px; }
  .acc { flex-direction: row; align-items: center; gap: 10px; padding: 8px 10px; }
  .ring { width: 46px; height: 46px; }
  .ring-num { font-size: .92rem; }
  .acc-name { font-size: .84rem; }
  .acc-sub { font-size: 0; letter-spacing: 0; }
  .acc-sub .src { font-size: .66rem; margin: 0; }
  .acc-rate { font-size: .8rem; }
  .ins-tabs button { font-size: .86rem; }
}

/* accuracy: two plain tiles above the tabs (no box around them) */
.summary { background: none; border: 0; box-shadow: none; padding: 0; animation: none; }
.summary .analyzing { margin: 0 0 12px; padding: 12px 14px; border-radius: var(--r-card); background: var(--card); border: 1px solid var(--card-edge); box-shadow: var(--card-shadow); }
.summary .acc { background: var(--card); border: 1px solid var(--card-edge); box-shadow: var(--card-shadow); border-radius: 18px; }
.acc-rate { white-space: nowrap; }
@media (max-width: 640px) {
  .summary { padding: 0; }
  .acc-rate-l { font-size: 0; }
  .acc-rate-l::before { content: "Rating"; font-size: .8rem; }
}
/* once games are listed, the search shrinks to just the box */
#home:has(#results:not([hidden])) #src-tabs,
#home:has(#results:not([hidden])) .recent { display: none; }
@media (max-width: 640px) {
  #home:has(#results:not([hidden])) .search { flex-direction: row; }
  #home:has(#results:not([hidden])) .search input { flex: 1; width: auto; min-width: 0; }
  #home:has(#results:not([hidden])) .search .btn { width: auto; padding: 0 16px; }
  #home:has(#results:not([hidden])) .search .btn span { display: none; }
  #home:has(#results:not([hidden])) .search-card { padding: 10px; }
}

/* ---------- board sessions: training and full games against the bot ---------- */
body.session #summary, body.session #panel-tabs, body.session #human, body.session #faq,
body.session .controls, body.session #btn-flip-top { display: none !important; }
body.session .evalbar { visibility: hidden; }
body.training .board-shell { touch-action: none; box-shadow: var(--shadow-3), 0 0 0 3px color-mix(in srgb, var(--accent) 55%, transparent); }
body.training .coach { border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
@media (max-width: 980px) { body.reviewing.session { padding-bottom: calc(16px + env(safe-area-inset-bottom)); } }

/* trainer panel */
.tr-dots { display: flex; gap: 6px; margin: 12px 0 2px; flex-wrap: wrap; }
.tr-dots span { width: 22px; height: 6px; border-radius: 99px; background: var(--surface-3); transition: background-color .3s; }
.tr-dots span.cur { background: var(--accent); }
.tr-dots span.solved { background: var(--c-best); }
.tr-dots span.helped { background: var(--c-inaccuracy); }
.tr-dots span.missed { background: var(--c-mistake); }
.tr-ctx { margin-top: 10px; }
.tr-tag { display: inline-block; margin-left: 2px; padding: 2px 9px; border-radius: 99px; font-size: .75rem; font-weight: 600; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }

/* the Train tab */
.train-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.train-grid .tr-card:first-child { grid-column: 1 / -1; }
.tr-card { display: flex; flex-direction: column; gap: 14px; padding: 20px; }
.tr-head { display: flex; gap: 14px; align-items: flex-start; }
.tr-head h3 { margin: 2px 0 4px; font-size: 1.1rem; }
.tr-head p { margin: 0; }
.tr-icon.threat { background: var(--c-mistake); }
.tr-icon.bot { background: var(--c-best); }
.tr-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.tr-stats div { padding: 10px 12px; border-radius: 14px; background: var(--surface-2); min-width: 0; }
.tr-stats b { display: block; font: 600 1.45rem/1.15 var(--display); font-variant-numeric: tabular-nums; }
.tr-stats span { font-size: .78rem; color: var(--muted); }
.tr-focus .po-label { margin-top: 0; }
.tr-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.tr-empty { margin: 0; color: var(--text-2); }
.tr-scan .an-row { flex-wrap: wrap; }
.tr-botgames { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.tr-botgames li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; background: var(--surface-2); }
.tr-bg-txt { flex: 1; min-width: 0; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tr-res { width: 26px; height: 26px; flex: none; display: grid; place-items: center; border-radius: 8px; font-weight: 700; font-size: .8rem; color: var(--draw); background: color-mix(in srgb, var(--draw) 14%, transparent); }
.tr-res.win { color: var(--win); background: color-mix(in srgb, var(--win) 14%, transparent); }
.tr-res.loss { color: var(--loss); background: color-mix(in srgb, var(--loss) 14%, transparent); }

/* bot picker */
.po-rating { display: flex; align-items: baseline; gap: 10px; }
.po-rating b { font: 600 2rem/1.1 var(--display); font-variant-numeric: tabular-nums; }
.po-rating span { color: var(--muted); font-weight: 600; }
.po-slider { width: 100%; margin: 10px 0 4px; accent-color: var(--accent); }
.po-quick { margin-top: 6px; }
.hero-bot { margin-top: 12px; align-self: flex-start; }
.hero-bot[hidden] { display: none; }
#home:has(#results:not([hidden])) .hero-bot { margin-top: 6px; height: 34px; font-size: .9rem; }

@media (max-width: 980px) {
  .train-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .tr-card { padding: 16px; }
  .tr-stats { gap: 6px; }
  .tr-stats div { padding: 8px 8px; }
  .tr-stats b { font-size: 1.2rem; }
  .tr-stats span { font-size: .7rem; display: block; line-height: 1.2; }
}

/* ---------- Insights: best wins and worst losses, chart switch ---------- */
.hl-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 24px; }
.hl-h { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: 1rem; }
.hl-h::before { content: ""; width: 8px; height: 8px; border-radius: 99px; background: var(--win); }
.hl-h.loss::before { background: var(--loss); }
.hl-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.hl-row { all: unset; box-sizing: border-box; width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); cursor: pointer; transition: background-color .15s; }
.hl-row:hover { background: var(--surface-3); }
.hl-row:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hl-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.hl-opp { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hl-rt { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.hl-sub { font-size: .8rem; color: var(--muted); }
.hl-acc { display: flex; flex-direction: column; align-items: flex-end; flex: none; }
.hl-acc b { font: 600 1.1rem/1.1 var(--display); font-variant-numeric: tabular-nums; }
.hl-acc span { font-size: .68rem; color: var(--muted); }
.hl-foot { margin: 12px 0 0; }
.chart-card .card-head { align-items: center; }
.batch-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin-top: 14px; }
.batch-row .batch-note { margin-left: 0; }
@media (max-width: 640px) {
  .hl-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Insights overview: what to fix first, where games turn ---------- */
.kpis.kpis-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.fix-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.fix-list li { display: flex; gap: 12px; align-items: flex-start; }
.fix-list li + li { padding-top: 14px; border-top: 1px solid var(--border); }
.fix-n { flex: none; width: 28px; height: 28px; border-radius: 99px; display: grid; place-items: center; font-weight: 700; font-size: .9rem; color: #fff; background: var(--c-mistake); }
.fix-body { flex: 1; min-width: 0; }
.fix-h { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; }
.fix-h b { font-size: 1rem; }
.fix-h .muted { font-size: .84rem; }
.fix-body p { margin: 6px 0 0; font-size: .93rem; color: var(--text-2); }
.fix-body .fix-tip { color: var(--text); }
.ex-link { all: unset; cursor: pointer; display: inline-block; margin-top: 8px; font-size: .88rem; font-weight: 600; color: var(--accent-text); }
.ex-link:hover { text-decoration: underline; }
.ex-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.phase-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.phase-tiles .kpi.weak { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--c-mistake) 70%, transparent); }
.phase-tiles .kpi.weak .kpi-sub { color: var(--c-mistake); font-weight: 600; }
.turn-list { margin: 14px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 8px; font-size: .93rem; color: var(--text-2); }
.turn-list b { color: var(--text); }

/* Mistakes tab: each kind of mistake, explained */
.mt-intro { margin: 0 0 10px; }
.mt-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.mt summary { list-style: none; cursor: pointer; display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border-radius: 12px; transition: background-color .15s; }
.mt summary::-webkit-details-marker { display: none; }
.mt summary:hover, .mt[open] summary { background: var(--surface-2); }
.mt-top { display: flex; align-items: baseline; gap: 10px; }
.mt-label { flex: 1; font-weight: 600; }
.mt-label::after { content: "›"; display: inline-block; margin-left: 6px; color: var(--muted); transition: transform .15s; }
.mt[open] .mt-label::after { transform: rotate(90deg); }
.mt-n { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--text-2); }
.mt .rb-track { display: block; height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.mt .rb-track i { display: block; height: 100%; border-radius: inherit; background: var(--viz-series); }
.mt-mean { font-size: .88rem; color: var(--muted); }
.mt-more { padding: 4px 12px 12px; }
.mt-more p { margin: 0; font-size: .92rem; }
@media (max-width: 640px) {
  .kpis.kpis-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .kpis.kpis-3 .kpi { padding: 10px; }
  .kpis.kpis-3 .kpi-value { font-size: 1.35rem; }
  .kpis.kpis-3 .kpi-sub { font-size: .72rem; }
}
