/* MoveLens styles.
   1. tokens + scenes   2. base + buttons   3. top bar   4. landing   5. review screen   6. board   7. popovers */

/* ============================================================ 1. tokens + scenes */
:root {
  --font: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --accent: #81b64c; --accent-h: #93c85d; --accent-shadow: #4d7a2a; --on-accent: #fff;
  --radius: 16px;
  --light: #f2f5f7; --dark: #b7d0e3;                    /* board colours, set from JS */

  /* move labels */
  --brilliant: #1baca6; --great: #5c8bb0; --best: #81b64c; --excellent: #96bc4b; --good: #96af8b;
  --book: #a88865; --forced: #8f98a3; --inaccuracy: #f7c631; --mistake: #e58f2a; --miss: #ff7769; --blunder: #ca3431;
}

/* A "scene" is the page background plus the colours that sit on it. */
body, body[data-scene="sky"] {
  --scene: url(/static/bg/sky.jpg);
  --panel: rgba(247, 247, 245, .95); --panel-solid: #f7f7f5; --panel-2: #e7e7e3; --field: #fff; --line: #d5d5d0;
  --text: #272522; --muted: #67645e; --nav-bg: rgba(255, 255, 255, .86);
  --hero-text: #fff; --hero-sub: rgba(255, 255, 255, .92); --hero-shadow: 0 2px 18px rgba(8, 40, 90, .45);
  --graph-bg: #5a5853; --graph-fill: #f4f4f2; --shadow: 0 10px 34px rgba(12, 42, 90, .25); --bg-solid: #4b9be0;
  color-scheme: light;
}
body[data-scene="meadow"] { --scene: url(/static/bg/meadow.jpg); --bg-solid: #6fb3ea; }
body[data-scene="dusk"], body[data-scene="night"] {
  --panel: rgba(24, 22, 46, .88); --panel-solid: #1d1a3a; --panel-2: #332f58; --field: #1e1c3a; --line: #4a4577;
  --text: #f1eefb; --muted: #aaa5cc; --nav-bg: rgba(20, 18, 40, .82);
  --hero-text: #fff; --hero-sub: rgba(255, 255, 255, .9); --hero-shadow: 0 2px 18px rgba(0, 0, 0, .5);
  --graph-bg: #3c3869; --graph-fill: #f1eefb; --shadow: 0 10px 34px rgba(0, 0, 0, .45); color-scheme: dark;
}
body[data-scene="dusk"] { --scene: url(/static/bg/dusk.jpg); --bg-solid: #3a2470; }
body[data-scene="night"] {
  --scene: url(/static/bg/night.jpg); --bg-solid: #0b1433;
  --panel: rgba(14, 22, 48, .88); --panel-solid: #101834; --panel-2: #22305e; --field: #121b3b; --line: #34457c; --muted: #9eb0dc; --nav-bg: rgba(8, 14, 34, .82); --graph-bg: #26356a;
}
body[data-scene="slate"] {
  --scene: none; --bg-solid: #262421;
  --panel: #302e2b; --panel-solid: #302e2b; --panel-2: #3b3936; --field: #262421; --line: #484540; --text: #f4f3f2; --muted: #a8a49f; --nav-bg: #302e2b;
  --hero-text: #fff; --hero-sub: #cfcbc6; --hero-shadow: none; --graph-bg: #46433f; --graph-fill: #f4f4f2; --shadow: 0 8px 28px rgba(0, 0, 0, .4); color-scheme: dark;
}
body[data-scene="paper"] {
  --scene: none; --bg-solid: #ebeae6;
  --panel: #fff; --panel-solid: #fff; --panel-2: #f1efec; --field: #fff; --line: #dcd9d4; --text: #272522; --muted: #6b6862; --nav-bg: #fff;
  --hero-text: #272522; --hero-sub: #4f4c46; --hero-shadow: none; --graph-bg: #77746f; --shadow: 0 8px 28px rgba(0, 0, 0, .12); color-scheme: light;
}

/* ============================================================ 2. base + buttons */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 76px; scrollbar-gutter: stable; }
body { margin: 0; min-height: 100vh; font-family: var(--font); color: var(--text); background: var(--bg-solid); -webkit-font-smoothing: antialiased; }
.scene { position: fixed; inset: 0; z-index: -1; background: var(--scene) center / cover no-repeat, var(--bg-solid); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 70%, #fff); outline-offset: 2px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; background: var(--panel-2); color: var(--text);
       border: 1px solid var(--line); border-radius: 10px; padding: 9px 15px; font-weight: 700; font-size: 14px; white-space: nowrap; transition: filter .12s, transform .05s; }
.btn:hover:not(:disabled) { filter: brightness(.96); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent-shadow); box-shadow: 0 4px 0 var(--accent-shadow); font-weight: 800; }
.btn-primary:hover:not(:disabled) { background: var(--accent-h); filter: none; }
.btn-primary:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--accent-shadow); }
.btn.big { padding: 14px 24px; font-size: 18px; border-radius: 12px; width: 100%; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover:not(:disabled) { background: color-mix(in srgb, var(--text) 8%, transparent); filter: none; }
.btn svg, .icon { width: 18px; height: 18px; fill: currentColor; flex: none; }
.link { background: none; border: 0; padding: 0; color: var(--accent-shadow); font-weight: 700; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
body[data-scene="dusk"] .link, body[data-scene="night"] .link, body[data-scene="slate"] .link { color: var(--accent-h); }

input[type=text], select, textarea { background: var(--field); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 15px; width: 100%; }
textarea { font-family: ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace; font-size: 13px; line-height: 1.5; resize: vertical; }
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }

.seg { display: inline-flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; border-radius: 7px; padding: 7px 14px; font-weight: 700; font-size: 14px; cursor: pointer; color: var(--muted); }
.seg button[aria-pressed=true], .seg button[aria-selected=true] { background: var(--panel); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .18); }

.badge { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 50%; font-size: 11px; font-weight: 800; color: #fff; flex: none; line-height: 1; }
.badge.lg { width: 30px; height: 30px; font-size: 15px; }
.badge.xl { width: 44px; height: 44px; font-size: 21px; }

/* ============================================================ 3. top bar */
.topbar { position: sticky; top: 0; z-index: 40; display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 58px; padding: 0 22px;
          background: var(--nav-bg); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 800; font-size: 21px; letter-spacing: -.4px; }
.brand svg { width: 30px; height: 30px; }
.brand b { color: var(--accent-shadow); font-weight: 800; }
body[data-scene="dusk"] .brand b, body[data-scene="night"] .brand b, body[data-scene="slate"] .brand b { color: var(--accent-h); }
.nav-links { display: flex; gap: 4px; }
.nav-links a { text-decoration: none; font-weight: 700; font-size: 14px; color: var(--muted); padding: 8px 12px; border-radius: 9px; }
.nav-links a:hover { color: var(--text); background: color-mix(in srgb, var(--text) 8%, transparent); }
.nav-actions { display: flex; gap: 6px; align-items: center; }
@media (max-width: 1040px) { .nav-links { display: none; } }
@media (max-width: 520px) { .topbar { padding: 0 12px; } .nav-actions .lbl { display: none; } .brand { font-size: 19px; } #keys-btn { display: none; } }

/* ============================================================ 4. landing */
main { max-width: 1320px; margin: 0 auto; padding: 0 20px 40px; container-type: inline-size; }
main.reviewing { padding-bottom: 12px; }
.hero { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr); gap: 44px; align-items: center; padding: 56px 0 48px; min-height: min(760px, calc(100vh - 58px)); }
.hero-copy { color: var(--hero-text); text-shadow: var(--hero-shadow); }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 800; letter-spacing: 1.4px; text-transform: uppercase; background: rgba(255, 255, 255, .2); border: 1px solid rgba(255, 255, 255, .35); padding: 6px 12px; border-radius: 99px; backdrop-filter: blur(6px); }
body[data-scene="paper"] .eyebrow { background: #fff; border-color: var(--line); }
.hero h1 { font-size: clamp(36px, 5.2vw, 64px); line-height: 1.04; letter-spacing: -2px; font-weight: 800; margin: 18px 0 18px; }
.hero h1 em { font-style: normal; color: #fff4a8; }
body[data-scene="paper"] .hero h1 em { color: var(--accent-shadow); }
.hero .lead { font-size: clamp(16px, 1.5vw, 19px); line-height: 1.55; color: var(--hero-sub); max-width: 580px; font-weight: 500; }
.hero-points { display: flex; flex-wrap: wrap; gap: 10px 22px; margin: 26px 0 0; padding: 0; list-style: none; font-weight: 700; font-size: 15px; }
.hero-points li { display: flex; align-items: center; gap: 8px; }
.hero-points .tick { width: 22px; height: 22px; border-radius: 50%; background: var(--accent); display: grid; place-items: center; text-shadow: none; box-shadow: 0 2px 6px rgba(0, 0, 0, .25); }
.hero-points .tick svg { width: 13px; height: 13px; fill: #fff; }
.demo { margin-top: 34px; display: flex; align-items: center; gap: 18px; }
.demo .board-box { width: 216px; flex: none; border-radius: 10px; overflow: hidden; box-shadow: 0 10px 30px rgba(0, 0, 0, .35); }
.demo-note { text-shadow: none; background: var(--panel); color: var(--text); border-radius: 14px; padding: 12px 14px; font-size: 14px; line-height: 1.45; max-width: 260px; box-shadow: var(--shadow); min-height: 74px; }
.demo-note b { display: block; font-size: 15px; margin-bottom: 2px; }
.demo-note .badge { vertical-align: -5px; margin-right: 6px; }
@media (max-width: 980px) { .hero { grid-template-columns: 1fr; padding-top: 34px; min-height: 0; } .demo { display: none; } }

.start-card { background: var(--panel); border-radius: 20px; box-shadow: var(--shadow); padding: 22px; backdrop-filter: blur(10px); }
.start-card h2 { font-size: 22px; letter-spacing: -.4px; margin-bottom: 14px; }
.source-tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.source-tabs button { flex: 1; border: 1px solid var(--line); background: var(--panel-2); border-radius: 10px; padding: 9px 8px; font-weight: 800; font-size: 14px; cursor: pointer; color: var(--muted); }
.source-tabs button[aria-selected=true] { background: var(--field); color: var(--text); border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent); }
.start-card textarea { min-height: 190px; }
.pane-hint { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; margin-top: 8px; font-size: 13.5px; color: var(--muted); }
.finder { display: flex; gap: 8px; }
.finder input { flex: 1; }
.games { margin-top: 10px; max-height: 232px; overflow-y: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--field); }
.games:empty { display: none; }
.games .note { padding: 16px; text-align: center; color: var(--muted); font-size: 14px; }
.game-row { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; width: 100%; text-align: left; padding: 10px 12px; border: 0; border-bottom: 1px solid var(--line); background: transparent; cursor: pointer; }
.game-row:last-child { border-bottom: 0; }
.game-row:hover { background: var(--panel-2); }
.game-row[aria-pressed=true] { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.game-row .who { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.game-row .who i { font-style: normal; color: var(--muted); font-weight: 500; }
.game-row .res { font-weight: 800; font-size: 13px; }
.game-row .meta { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }
.res.win { color: var(--best); } .res.loss { color: var(--blunder); } .res.draw { color: var(--muted); }

.options { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 16px 0; }
.options .wide { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field > span, .field > legend { font-size: 12.5px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; padding: 0; }
.field small { font-size: 12.5px; color: var(--muted); line-height: 1.35; }
.field .seg { display: flex; } .field .seg button { flex: 1; padding: 8px 6px; }
@media (max-width: 560px) { .options { grid-template-columns: 1fr; } }
.alert { margin-top: 12px; background: #fdecea; color: #8c1f17; border: 1px solid #f3b9b3; padding: 10px 14px; border-radius: 10px; font-size: 14px; font-weight: 600; }
.alert.info { background: color-mix(in srgb, var(--accent) 16%, var(--panel-2)); color: var(--text); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); margin: 0 0 14px; font-weight: 500; line-height: 1.45; }
.progress { margin-top: 14px; }
.progress .track { height: 10px; background: var(--panel-2); border-radius: 99px; overflow: hidden; }
.progress .fill { height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width .3s; }
.progress p { margin-top: 8px; font-size: 14px; color: var(--muted); font-weight: 600; }

/* sections after the hero are "sheets": solid panels, so text is readable on any background */
.sheet { background: var(--panel); border-radius: 22px; box-shadow: var(--shadow); padding: clamp(24px, 4vw, 48px); margin-top: 28px; backdrop-filter: blur(10px); }
.sheet-head { max-width: 720px; margin-bottom: 30px; }
.sheet-head .kicker { font-size: 12.5px; font-weight: 800; letter-spacing: 1.4px; text-transform: uppercase; color: var(--accent-shadow); }
body[data-scene="dusk"] .kicker, body[data-scene="night"] .kicker, body[data-scene="slate"] .kicker { color: var(--accent-h); }
.sheet-head h2 { font-size: clamp(26px, 3.2vw, 38px); line-height: 1.12; letter-spacing: -1px; margin: 8px 0 10px; font-weight: 800; }
.sheet-head p { color: var(--muted); font-size: 17px; line-height: 1.55; }

.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; counter-reset: step; }
.step { background: var(--panel-2); border-radius: 16px; padding: 24px; position: relative; }
.step::before { counter-increment: step; content: counter(step); position: absolute; top: 18px; right: 20px; font-size: 54px; font-weight: 800; line-height: 1; color: color-mix(in srgb, var(--text) 9%, transparent); }
.step .ico { width: 46px; height: 46px; border-radius: 12px; background: var(--accent); display: grid; place-items: center; margin-bottom: 16px; box-shadow: 0 3px 0 var(--accent-shadow); }
.step .ico svg { width: 24px; height: 24px; fill: #fff; }
.step h3 { font-size: 19px; margin-bottom: 8px; letter-spacing: -.3px; }
.step p, .step li { color: var(--muted); font-size: 15px; line-height: 1.55; }
.step ul { margin: 8px 0 0; padding-left: 18px; }
@media (max-width: 880px) { .steps { grid-template-columns: 1fr; } }

.features { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.feature { background: var(--panel-2); border-radius: 16px; padding: 22px; }
.feature .ico { width: 40px; height: 40px; border-radius: 11px; background: color-mix(in srgb, var(--accent) 22%, transparent); display: grid; place-items: center; margin-bottom: 14px; }
.feature .ico svg { width: 22px; height: 22px; fill: var(--accent-shadow); }
body[data-scene="dusk"] .feature .ico svg, body[data-scene="night"] .feature .ico svg, body[data-scene="slate"] .feature .ico svg { fill: var(--accent-h); }
.feature h3 { font-size: 16.5px; margin-bottom: 6px; letter-spacing: -.2px; }
.feature p { font-size: 14.5px; line-height: 1.5; color: var(--muted); }

.labels { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.label-card { display: flex; gap: 14px; align-items: flex-start; background: var(--panel-2); border-radius: 14px; padding: 16px; }
.label-card h3 { font-size: 16px; margin-bottom: 3px; }
.label-card p { font-size: 14px; line-height: 1.45; color: var(--muted); }
.label-card .rule { display: inline-block; margin-top: 6px; font-size: 12px; font-weight: 800; color: var(--text); background: var(--panel); border-radius: 6px; padding: 2px 8px; }
.callout { margin-top: 22px; display: flex; gap: 16px; align-items: flex-start; background: color-mix(in srgb, var(--accent) 14%, var(--panel-2)); border-radius: 14px; padding: 18px 20px; font-size: 15px; line-height: 1.55; }
.callout svg { width: 26px; height: 26px; fill: var(--accent-shadow); flex: none; margin-top: 2px; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; align-items: start; }
@media (max-width: 880px) { .two-col { grid-template-columns: 1fr; } }
.how-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 14px; }
.how-list li { display: grid; grid-template-columns: 36px 1fr; gap: 14px; align-items: start; }
.how-list .n { width: 36px; height: 36px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 800; display: grid; place-items: center; box-shadow: 0 2px 0 var(--accent-shadow); }
.how-list b { display: block; margin-bottom: 2px; font-size: 16px; }
.how-list span { color: var(--muted); font-size: 14.5px; line-height: 1.5; }
.mock { background: var(--panel-2); border-radius: 16px; padding: 18px; }
.mock .coach-mock { display: flex; gap: 12px; align-items: flex-start; }
.mock .bubble { margin-bottom: 12px; }

.keys { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px 26px; }
.key-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: 14.5px; }
kbd { display: inline-block; min-width: 26px; text-align: center; padding: 3px 8px; font: 700 12.5px var(--font); background: var(--field); border: 1px solid var(--line); border-bottom-width: 3px; border-radius: 7px; }

.recent { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.recent-card { position: relative; text-align: left; background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px; padding: 16px; cursor: pointer; }
.recent-card:hover { border-color: var(--accent); }
.recent-card .vs { font-weight: 800; font-size: 15px; padding-right: 26px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-card .sub { font-size: 12.5px; color: var(--muted); margin: 3px 0 10px; }
.recent-card .accs { display: flex; gap: 8px; }
.recent-card .accs span { flex: 1; border-radius: 8px; padding: 6px 10px; font-size: 12px; font-weight: 700; display: flex; justify-content: space-between; }
.recent-card .accs .w { background: #f1f1ef; color: #302e2b; } .recent-card .accs .b { background: #1f1e1c; color: #f1f1ef; }
.recent-card .del { position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; padding: 0; border-radius: 8px; }

details.faq { border-bottom: 1px solid var(--line); }
details.faq:last-child { border-bottom: 0; }
details.faq summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; gap: 18px; align-items: center; padding: 18px 2px; font-weight: 800; font-size: 17px; }
details.faq summary::-webkit-details-marker { display: none; }
details.faq summary::after { content: "+"; font-size: 24px; font-weight: 500; color: var(--muted); transition: transform .15s; }
details.faq[open] summary::after { transform: rotate(45deg); }
details.faq p, details.faq ul { padding: 0 2px 20px; color: var(--muted); font-size: 15.5px; line-height: 1.65; max-width: 820px; margin: 0; }
details.faq ul { padding-left: 22px; }
table.depth { border-collapse: collapse; width: 100%; max-width: 640px; margin: 4px 0 18px; font-size: 14.5px; }
table.depth td, table.depth th { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.depth th { color: var(--text); font-size: 12.5px; text-transform: uppercase; letter-spacing: .5px; }
table.depth td { color: var(--muted); }
@media (max-width: 520px) { table.depth { display: block; overflow-x: auto; } }

footer.site { margin: 34px 0 0; padding: 26px 8px 8px; color: var(--hero-sub); text-shadow: var(--hero-shadow); font-size: 13.5px; line-height: 1.7; display: grid; grid-template-columns: 1.4fr 1fr; gap: 24px; }
footer.site a { text-decoration: underline; text-underline-offset: 3px; }
footer.site .fine { opacity: .9; }
footer.site .link { color: inherit; font-size: inherit; }
@media (max-width: 760px) { footer.site { grid-template-columns: 1fr; } }

/* ============================================================ 5. review screen */
.rv { --bar: 28px; --gap: 24px; --sidew: 450px; --pbar-h: 54px; --coach-h: 152px; --graph-h: 84px;
      /* board side = the smaller of what fits the width and what fits the height (so board + player bars always fit the screen) */
      --bs: clamp(300px, min(100cqw - var(--bar) - 8px - var(--gap) - var(--sidew), 100vh - 200px), 860px);
      display: flex; gap: var(--gap); justify-content: center; align-items: flex-start; padding-top: 18px; }
.rv-left { flex: none; width: calc(var(--bs) + var(--bar) + 8px); }
/* The panel is exactly as tall as the board column (two player bars + the board) and NEVER changes height. Whatever the
   coach says and whichever tab is open, nothing on the page moves; content that does not fit scrolls inside its own box. */
.rv-side { flex: 0 1 var(--sidew); min-width: 0; height: calc(var(--bs) + 2 * var(--pbar-h)); display: flex; flex-direction: column;
           background: var(--panel); border-radius: 18px; box-shadow: var(--shadow); overflow: hidden; backdrop-filter: blur(10px); }
@media (max-height: 780px) { .rv { --coach-h: 138px; --graph-h: 56px; } }
@media (max-width: 520px) { .actions .btn svg { display: none; } }
@media (max-width: 960px) {
  .rv { --bar: 22px; --bs: min(100cqw - var(--bar) - 8px, 720px); --coach-h: 186px; --graph-h: 84px; flex-direction: column; align-items: center; padding-top: 10px; }
  .rv-side { flex: none; width: calc(var(--bs) + var(--bar) + 8px); max-width: 100%; height: auto; }
  .rv-side .tab-pane { flex: none; height: 700px; }                /* every tab is the same height, so switching tabs never moves the page */
}

.pbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; height: var(--pbar-h); padding: 6px 0 6px calc(var(--bar) + 8px); color: var(--text); }
.pbar .who { display: flex; align-items: center; gap: 10px; min-width: 0; background: var(--panel); border-radius: 12px; padding: 5px 14px 5px 5px; box-shadow: 0 3px 10px rgba(0, 0, 0, .18); backdrop-filter: blur(8px); }
.avatar { width: 38px; height: 38px; border-radius: 8px; flex: none; display: grid; place-items: center; box-shadow: 0 2px 6px rgba(0, 0, 0, .3); }
.avatar.w { background: #f1f1ef; border: 1px solid #c9c7c3; } .avatar.b { background: #2b2a28; border: 1px solid #55524e; }
.avatar i { width: 78%; height: 78%; background-size: 100% 100%; }
.pbar .id { min-width: 0; }
.pbar .nm { display: flex; align-items: baseline; gap: 6px; font-weight: 800; font-size: 16px; min-width: 0; }
.pbar .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pbar .rating { font-weight: 600; font-size: 14px; opacity: .85; }
.pbar .you { align-self: center; font-size: 10px; font-weight: 800; letter-spacing: .5px; background: var(--accent); color: #fff; border-radius: 99px; padding: 2px 7px; }
.pbar .caps { display: flex; align-items: center; min-height: 18px; margin-top: 2px; }
.pbar .caps .grp { display: inline-flex; margin-right: 6px; }
.pbar .caps i { width: 15px; height: 15px; margin-right: -7px; background-size: 100% 100%; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .35)); }
.pbar .caps .grp i:last-child { margin-right: 0; }
.pbar .caps b { font-size: 12.5px; margin-left: 4px; opacity: .95; }
.pbar .right { display: flex; align-items: center; gap: 10px; }
.pbar .acc { font-size: 13px; font-weight: 700; background: var(--panel); color: var(--muted); border-radius: 10px; padding: 8px 11px; white-space: nowrap; box-shadow: 0 3px 10px rgba(0, 0, 0, .18); }
.pbar .acc b { font-size: 15px; color: var(--text); }
.clock { min-width: 88px; text-align: right; font: 800 24px/1 var(--font); letter-spacing: -.5px; padding: 8px 12px; border-radius: 10px; background: var(--panel); color: var(--text); font-variant-numeric: tabular-nums; box-shadow: 0 3px 10px rgba(0, 0, 0, .18); }
.clock.low { background: #ca3431; color: #fff; }
@media (max-width: 560px) { .clock { font-size: 18px; min-width: 64px; padding: 6px 8px; } .pbar .acc .l { display: none; } .pbar .nm { font-size: 15px; } }

.board-wrap { display: flex; gap: 8px; }
.evalbar { width: var(--bar); height: var(--bs); border-radius: 5px; overflow: hidden; position: relative; background: #403d39; flex: none; box-shadow: 0 2px 8px rgba(0, 0, 0, .25); }
.evalbar .white { position: absolute; left: 0; right: 0; bottom: 0; background: #f4f4f2; transition: height .4s ease; }
.evalbar .val { position: absolute; left: 0; right: 0; font-size: 10.5px; font-weight: 800; text-align: center; z-index: 2; letter-spacing: -.2px; }

/* ============================================================ 6. board */
.board { position: relative; width: var(--bs); height: var(--bs); display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr);
         border-radius: 6px; overflow: hidden; user-select: none; -webkit-user-select: none; touch-action: none; container-type: inline-size; box-shadow: 0 10px 30px rgba(0, 0, 0, .3); }
.board.static { pointer-events: none; }
.sq { position: relative; }
.sq.light { background: var(--light); } .sq.dark { background: var(--dark); }
.sq .hl { position: absolute; inset: 0; opacity: .6; }
.sq.sel::before { content: ""; position: absolute; inset: 0; background: rgba(255, 235, 59, .55); }
.sq.user-hl::before { content: ""; position: absolute; inset: 0; background: rgba(235, 97, 80, .72); }
.sq.check::before { content: ""; position: absolute; inset: 0; background: radial-gradient(circle, rgba(255, 0, 0, .95) 0%, rgba(231, 0, 0, .75) 25%, rgba(169, 0, 0, 0) 80%); }
.sq.legal::after { content: ""; position: absolute; left: 36%; top: 36%; width: 28%; height: 28%; border-radius: 50%; background: rgba(20, 20, 20, .22); z-index: 3; pointer-events: none; }
.sq.legal.cap::after { left: 4%; top: 4%; width: 92%; height: 92%; background: none; border: max(3px, .9cqw) solid rgba(20, 20, 20, .22); }
.sq.over::before { content: ""; position: absolute; inset: 0; box-shadow: inset 0 0 0 max(3px, .7cqw) rgba(255, 255, 255, .85); z-index: 3; }
.piece { position: absolute; inset: 0; z-index: 2; background-size: 100% 100%; background-repeat: no-repeat; pointer-events: none; }
.piece.lifted { opacity: .3; }
.ghost { position: absolute; z-index: 20; pointer-events: none; background-size: 100% 100%; filter: drop-shadow(0 6px 8px rgba(0, 0, 0, .4)); transform: scale(1.12); }
.sq .badge { position: absolute; top: 2%; right: 2%; z-index: 4; width: 38%; height: 38%; font-size: max(7px, 2.5cqw); box-shadow: 0 1px 5px rgba(0, 0, 0, .55); }
.coord { position: absolute; font-size: max(9px, 2.1cqw); font-weight: 800; z-index: 1; line-height: 1; pointer-events: none; }
.coord.f { bottom: 4%; right: 6%; } .coord.r { top: 5%; left: 6%; }
.sq.light .coord { color: var(--dark); } .sq.dark .coord { color: var(--light); }
svg.overlay { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 6; pointer-events: none; }
.promo { position: absolute; z-index: 30; width: 12.5%; background: #fff; border-radius: 6px; box-shadow: 0 8px 28px rgba(0, 0, 0, .5); display: flex; flex-direction: column; }
.promo.up { flex-direction: column-reverse; }
.promo button { aspect-ratio: 1; border: 0; background-size: 86% 86%; background-position: center; background-repeat: no-repeat; background-color: transparent; border-radius: 6px; cursor: pointer; padding: 0; }
.promo button:hover { background-color: #d8e8c0; }

/* Phones and tablets: the move buttons are pinned to the bottom of the screen (the copy inside the panel is hidden) */
#mnav { display: none; }
@media (max-width: 960px) {
  body.reviewing #mnav { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
                         padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); background: var(--panel-solid); border-top: 1px solid var(--line); box-shadow: 0 -8px 24px rgba(0, 0, 0, .2); }
  #mnav .btn { padding: 15px 0; border-radius: 12px; box-shadow: 0 3px 0 color-mix(in srgb, var(--line) 90%, #000); }
  #mnav .btn svg { width: 24px; height: 24px; }
  .rv-side .controls { display: none; }
  main.reviewing { padding-bottom: 96px; }                 /* room so the bar never covers the end of the page */
  body.reviewing .toast { bottom: 92px; }
}

/* side panel */
.panel-head { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px 10px 8px; border-bottom: 1px solid var(--line); }
.panel-head h2 { display: flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 800; letter-spacing: -.2px; }
.panel-head h2 svg { width: 24px; height: 24px; }
.panel-head .tools { display: flex; gap: 2px; }
.panel-head .btn { padding: 8px; border-radius: 9px; }
.tabs { flex: none; display: flex; border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; padding: 11px 6px; border: 0; background: none; font-weight: 800; font-size: 14px; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs button[aria-selected=true] { color: var(--text); border-bottom-color: var(--accent); }
.tab-pane { padding: 14px; flex: 1; min-height: 0; overflow-y: auto; }
#tab-review { display: flex; flex-direction: column; gap: 10px; }

.coach { flex: none; height: var(--coach-h); display: flex; gap: 12px; align-items: flex-start; }
.mascot { width: 64px; height: 64px; border-radius: 50%; flex: none; display: grid; place-items: center; background: var(--mascot, #7a8b9a); box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .18), 0 3px 8px rgba(0, 0, 0, .2); transition: background .25s; }
.mascot i { width: 74%; height: 74%; background-size: 100% 100%; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .3)); }
.bubble { position: relative; flex: 1; min-width: 0; background: var(--panel-2); border-radius: 14px; padding: 11px 13px; min-height: 64px; max-height: 100%; overflow-y: auto; }
.bubble::before { content: ""; position: absolute; left: -7px; top: 22px; border: 8px solid transparent; border-left: 0; border-right-color: var(--panel-2); }
.bubble .top { display: flex; align-items: center; gap: 9px; }
.bubble .ttl { flex: 1; font-weight: 800; font-size: 15.5px; min-width: 0; }
.bubble .ev { font: 800 14px var(--font); background: var(--field); border-radius: 7px; padding: 3px 8px; font-variant-numeric: tabular-nums; }
.bubble p { margin-top: 5px; font-size: 14.5px; line-height: 1.45; color: color-mix(in srgb, var(--text) 85%, transparent); }
.bubble .line { margin-top: 6px; font: 600 12.5px/1.5 ui-monospace, Menlo, Consolas, monospace; color: var(--muted); }
.spinner { width: 15px; height: 15px; border: 2.5px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; vertical-align: -3px; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }

.actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(0, 1.6fr); gap: 7px; flex: none; }
.actions .btn { padding: 10px 4px; font-size: 13.5px; gap: 6px; overflow: hidden; text-overflow: ellipsis; }
.actions .btn svg { width: 16px; height: 16px; }
.actions .btn[aria-pressed=true] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 20%, var(--panel-2)); }
.actions .btn-primary { font-size: 14.5px; }
.mid { position: relative; flex: 1; min-height: 120px; }
.explain { position: absolute; left: 0; right: 0; top: 0; z-index: 3; max-height: 100%; overflow-y: auto; background: var(--panel-solid); border: 1px solid var(--line);
           border-radius: 12px; padding: 12px 14px; font-size: 14px; line-height: 1.55; box-shadow: 0 10px 28px rgba(0, 0, 0, .28); }
.explain .row { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; }
.explain .row span:first-child { color: var(--muted); }
.explain .row b { font-variant-numeric: tabular-nums; }

.moves { position: absolute; inset: 0; overflow-y: auto; border-radius: 12px; background: var(--panel-2); font-size: 14.5px; font-variant-numeric: tabular-nums; }
.mrow { display: grid; grid-template-columns: 38px 1fr 1fr; align-items: center; }
.mrow:nth-child(even) { background: color-mix(in srgb, var(--text) 5%, transparent); }
.mrow .num { color: var(--muted); padding: 7px 0 7px 10px; font-size: 13px; }
.mv { display: flex; align-items: center; gap: 6px; padding: 7px 8px; cursor: pointer; font-weight: 700; border-radius: 6px; min-height: 34px; }
.mv:hover { background: color-mix(in srgb, var(--text) 9%, transparent); }
.mv.cur { background: var(--accent); color: #fff; }
.mv .badge { width: 17px; height: 17px; font-size: 9px; }
.fig { display: inline-block; width: 18px; height: 18px; margin-right: -1px; vertical-align: -4px; background-size: 100% 100%; flex: none; }
.line-box { padding: 8px 10px; border-top: 2px solid #f7c631; display: flex; flex-wrap: wrap; gap: 2px 4px; align-items: center; background: color-mix(in srgb, #f7c631 14%, transparent); }
.line-box .tag { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin-right: 6px; }
.line-box .mv { padding: 3px 6px; min-height: 0; }

.graph-wrap { flex: none; border-radius: 12px; overflow: hidden; position: relative; }
svg.graph { width: 100%; height: var(--graph-h); display: block; cursor: pointer; }
svg.graph .gbg { fill: var(--graph-bg); } svg.graph .gfill { fill: var(--graph-fill); }
.controls { flex: none; display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; }
.controls .btn { padding: 12px 0; border-radius: 12px; box-shadow: 0 3px 0 color-mix(in srgb, var(--line) 90%, #000); }
.controls .btn svg { width: 22px; height: 22px; }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.tile { border-radius: 12px; padding: 10px 14px; min-width: 0; }
.tile span { display: block; font-size: 12.5px; font-weight: 700; opacity: .8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile b { font-size: 30px; font-weight: 800; line-height: 1.15; }
.tile small { font-size: 12px; opacity: .75; margin-left: 4px; }
.tile.w { background: #f1f1ef; color: #302e2b; border: 1px solid #c9c7c3; } .tile.b { background: #1f1e1c; color: #f1f1ef; border: 1px solid #55524e; }
.tile.me { outline: 3px solid var(--accent); outline-offset: 1px; }
.sec-title { font-size: 12.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 18px 0 8px; }
.sec-title:first-child { margin-top: 0; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tbl td, table.tbl th { padding: 5px 6px; }
table.tbl th { font-size: 12px; color: var(--muted); text-align: center; font-weight: 700; max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.tbl td.n { text-align: center; font-weight: 800; width: 62px; font-variant-numeric: tabular-nums; }
table.tbl td.n.zero { color: var(--muted); opacity: .5; font-weight: 500; }
.lab { display: flex; align-items: center; gap: 8px; text-transform: capitalize; }
.phase { display: grid; grid-template-columns: 84px 1fr 1fr; gap: 6px 8px; align-items: center; font-size: 13.5px; }
.phase .pill { background: var(--panel-2); border-radius: 8px; text-align: center; padding: 6px 4px; font-weight: 800; }
.moments { display: grid; gap: 4px; max-height: 250px; overflow-y: auto; }
.moment { display: flex; align-items: center; gap: 10px; text-align: left; border: 0; background: var(--panel-2); border-radius: 10px; padding: 8px 10px; cursor: pointer; font-size: 14px; }
.moment:hover { background: color-mix(in srgb, var(--accent) 18%, var(--panel-2)); }
.moment .t { flex: 1; font-weight: 700; } .moment .t i { font-style: normal; color: var(--muted); font-weight: 600; }
.moment .e { font-weight: 800; font-size: 13px; color: var(--muted); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; background: var(--panel-2); border-radius: 12px; font-weight: 700; font-size: 14.5px; cursor: pointer; }
.switch input { width: 40px; height: 22px; appearance: none; background: var(--line); border-radius: 99px; position: relative; cursor: pointer; transition: background .15s; flex: none; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked { background: var(--accent); } .switch input:checked::after { transform: translateX(18px); }
.elines { display: grid; gap: 6px; margin-top: 12px; }
.eline { display: grid; grid-template-columns: 62px 1fr; gap: 10px; align-items: baseline; text-align: left; width: 100%; border: 0; background: var(--panel-2); border-radius: 10px; padding: 9px 10px; cursor: pointer; }
.eline:hover { background: color-mix(in srgb, var(--accent) 18%, var(--panel-2)); }
.eline .sc { font-weight: 800; font-size: 13.5px; text-align: center; border-radius: 6px; padding: 3px 0; background: #f1f1ef; color: #302e2b; font-variant-numeric: tabular-nums; }
.eline .sc.neg { background: #2b2a28; color: #f1f1ef; }
.eline .pv { font-size: 13.5px; line-height: 1.5; font-weight: 600; word-break: break-word; }
.eline .pv b { font-weight: 800; }
.note { font-size: 13.5px; color: var(--muted); line-height: 1.5; }

/* ============================================================ 7. popovers, modal, toast */
.pop { position: fixed; z-index: 60; top: 64px; right: 14px; width: 420px; max-width: calc(100vw - 20px); max-height: calc(100vh - 80px); overflow-y: auto; background: var(--panel-solid); color: var(--text); border: 1px solid var(--line); border-radius: 18px; padding: 18px; box-shadow: 0 18px 60px rgba(0, 0, 0, .4); backdrop-filter: blur(14px); }
.pop h3, .picker h3 { font-size: 12.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 18px 0 9px; }
.pop h3:first-child, .picker h3:first-child { margin-top: 0; }
.scenes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.chip { border: 2px solid transparent; background: transparent; padding: 4px; border-radius: 12px; cursor: pointer; font-size: 12px; font-weight: 700; color: var(--muted); display: flex; flex-direction: column; gap: 5px; align-items: center; min-width: 0; }
.chip[aria-pressed=true] { border-color: var(--accent); color: var(--text); }
.chip:hover { background: color-mix(in srgb, var(--text) 6%, transparent); }
.chip .th { width: 100%; aspect-ratio: 16 / 9; border-radius: 8px; background-size: cover; background-position: center; border: 1px solid rgba(0, 0, 0, .2); }
.boards { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.boards .chip { padding: 3px; font-size: 10.5px; }
.boards .sw { display: block; width: 100%; aspect-ratio: 1; border-radius: 7px; border: 1px solid rgba(0, 0, 0, .25); }
.piece-sets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.piece-sets .pv { display: flex; width: 100%; background: var(--dark); border-radius: 8px; }
.piece-sets .pv i { flex: 1; aspect-ratio: 1; background-size: 100% 100%; }
.pop .switch { margin-top: 4px; }
/* the same picker inside a wide sheet gets wider grids */
.sheet .picker .scenes { grid-template-columns: repeat(6, 1fr); }
.sheet .picker .boards { grid-template-columns: repeat(12, 1fr); }
.sheet .picker .piece-sets { grid-template-columns: repeat(6, 1fr); }
.sheet .picker .switch { max-width: 360px; }
@media (max-width: 880px) {
  .sheet .picker .scenes { grid-template-columns: repeat(3, 1fr); }
  .sheet .picker .boards { grid-template-columns: repeat(6, 1fr); }
  .sheet .picker .piece-sets { grid-template-columns: repeat(3, 1fr); }
}

.modal { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; background: rgba(8, 12, 24, .55); padding: 16px; backdrop-filter: blur(3px); }
.modal .card { width: min(560px, 100%); max-height: 90vh; overflow-y: auto; background: var(--panel-solid); color: var(--text); border-radius: 20px; padding: 26px; box-shadow: 0 20px 70px rgba(0, 0, 0, .5); }
.modal h2 { font-size: 22px; margin-bottom: 14px; letter-spacing: -.4px; }
.modal .keys { grid-template-columns: 1fr; }
.toast { position: fixed; z-index: 90; left: 50%; bottom: 22px; transform: translateX(-50%); background: #25231f; color: #fff; padding: 11px 18px; border-radius: 12px; font-size: 14.5px; font-weight: 700; box-shadow: 0 8px 30px rgba(0, 0, 0, .4); max-width: calc(100vw - 24px); }
