:root {
  --bg: #0d1017; --glow: #17202d;
  --panel: #161c26; --panel-2: #1d2531;
  --line: #3f4c5e;
  --text: #f5f8fb; --muted: #b6c2d2;
  --accent: #4f8cff; --good: #35c88a; --bad: #ff5064; --locked: #c9a4ff;
  --given-bg: #10151d; --given-tx: #94a3bb;
  --sector: #1a2029; --sector-hover: #223042;
  --token-bg: #123047; --locked-bg: #241b38; --locked-ln: #47356b;
  --trail: #7fb3e8; --trail-bg: #14283a; --trail-ln: #33587e;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}
:root[data-theme="light"] {
  --bg: #eef1f6; --glow: #ffffff;
  --panel: #ffffff; --panel-2: #f2f5f9;
  --line: #d3dae3;
  --text: #1b2230; --muted: #64707f;
  --accent: #2f6fe0; --good: #1a9d68; --bad: #e13b4d; --locked: #7b52c9;
  --given-bg: #e7ecf3; --given-tx: #8794a5;
  --sector: #f7f9fc; --sector-hover: #eaf1fb;
  --token-bg: #d9ecff; --locked-bg: #ede4fb; --locked-ln: #cdbafe;
  --trail: #3e7cba; --trail-bg: #e4f1fd; --trail-ln: #b6d6f2;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: radial-gradient(1200px 700px at 50% -15%, var(--glow), var(--bg) 65%); color: var(--text); font-family: var(--font); -webkit-font-smoothing: antialiased; transition: background .25s, color .25s; }
body { display: flex; flex-direction: column; min-height: 100vh; }

/* the banner is a fixed LEFT sidebar — vertical space is scarcer than horizontal,
   so this frees the full viewport height for the board */
.topbar { position: fixed; left: 0; top: 0; bottom: 0; width: 186px; z-index: 15; display: flex; flex-direction: column; align-items: stretch; gap: 14px; padding: 16px 14px; border-right: 1px solid var(--line); background: var(--bg); overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 20px; cursor: pointer; align-self: flex-start; transition: color .12s; }
.brand:hover { color: var(--accent); }
/* the wheel mark inherits the brand's color, so it picks up the hover state for free */
.brand-mark { width: 22px; height: 22px; flex: none; overflow: visible; }
.brand-mark circle, .brand-mark path { fill: none; stroke: currentColor; stroke-linecap: round; }
.bm-ring { stroke-width: 1.7; }
.bm-hub { stroke-width: 1.7; }
.bm-spokes { stroke-width: 1.1; opacity: .6; }
.brand:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
.theme-toggle { border: 1px solid var(--line); background: var(--panel); color: var(--muted); width: 34px; height: 34px; border-radius: 50%; cursor: pointer; font-size: 15px; display: grid; place-items: center; }
.theme-toggle:hover { color: var(--text); }
.stats { display: flex; flex-direction: column; gap: 8px; }
.stat { display: flex; flex-direction: column; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px 13px; min-width: 70px; line-height: 1.15; }
.stat-label { font-size: 10px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.stat-value { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* score badges float over the top corners, outside the sidebar */
.score-float { position: fixed; top: 12px; z-index: 16; display: flex; flex-direction: column; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 7px 18px; min-width: 82px; box-shadow: 0 4px 14px rgba(0,0,0,.15); }
.score-left { left: calc(186px + 18px); }
.score-right { right: 18px; }
.sf-label { font-size: 10px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.sf-val { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.score-right .sf-val { color: var(--accent); }
#targetWord { color: var(--accent); }
.stat-btn { cursor: pointer; font-family: var(--font); color: var(--text); }
.actions { display: flex; flex-direction: column; gap: 8px; margin-top: auto; }

/* phone menu button + scrim (shown only in the phone media query below) */
#menuBtn { display: none; position: fixed; top: 12px; left: 12px; z-index: 24; width: 44px; height: 44px;
  align-items: center; justify-content: center; border-radius: 12px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); font-size: 20px; line-height: 1; cursor: pointer; box-shadow: 0 4px 14px rgba(0,0,0,.18); }
#menuScrim { display: none; position: fixed; inset: 0; z-index: 22; background: rgba(8,10,14,.5); }
/* phone board peek button + its close button */
#boardBtn { display: none; position: fixed; top: 12px; right: 12px; z-index: 24; height: 44px; padding: 0 15px;
  align-items: center; justify-content: center; gap: 6px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); font-family: var(--font); font-size: 14px; font-weight: 700;
  line-height: 1; cursor: pointer; box-shadow: 0 4px 14px rgba(0,0,0,.18); }
#boardClose { display: none; position: fixed; top: 12px; right: 12px; z-index: 26; width: 44px; height: 44px;
  align-items: center; justify-content: center; border-radius: 12px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); font-size: 19px; line-height: 1; cursor: pointer; box-shadow: 0 4px 14px rgba(0,0,0,.18); }

.btn { border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font-family: var(--font); font-size: 14px; font-weight: 600; padding: 9px 16px; border-radius: 10px; cursor: pointer; transition: filter .12s, border-color .12s, transform .08s; }
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.big { background: var(--accent); border-color: var(--accent); color: #fff; font-size: 17px; padding: 12px 34px; }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 12px; font-size: 12px; }
.btn.on { background: var(--bad); border-color: var(--bad); color: #fff; }
/* abandon: lives under the stats in the sidebar, subtle red outline */
#abandonBtn { border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); }
#abandonBtn:hover:not(:disabled) { border-color: var(--bad); }

.status { font-size: 14px; color: var(--muted); min-height: 24px; margin-bottom: 8px; }
.status b { color: var(--text); font-size: 21px; font-weight: 800; }
.status .tok { color: var(--accent); }

.stage { flex: 1; display: flex; align-items: center; justify-content: flex-start; gap: clamp(16px, 4vw, 52px); padding: 10px clamp(12px, 4vw, 48px) 22px; margin-left: 186px; }
.board-col { flex: 0 1 auto; margin-left: clamp(0px, 4vw, 70px); }
#board { width: min(600px, 56vw); height: auto; touch-action: manipulation; display: block; }
.entry-col { flex: 1 1 380px; max-width: 530px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 20px; }

/* layout "scroll" (default): board and entry stack as full-screen sections.
   margin-left is 0 so sections center on the FULL viewport, not the space beside the
   sidebar — widths are capped at 100vw − 2×sidebar so nothing underlaps it */
:root[data-layout="scroll"] .stage { flex-direction: column; align-items: center; gap: 30px; margin-left: 0; }
/* scroll layout: spoke (entry) view comes first, scroll down to the board */
:root[data-layout="scroll"] .entry-col { order: 0; }
:root[data-layout="scroll"] .board-col { order: 1; margin-left: 0; min-height: calc(100vh - 32px); display: flex; align-items: center; }
:root[data-layout="scroll"] #board { width: min(calc(100vh - 36px), calc(100vw - 390px)); }
:root[data-layout="scroll"] .entry-col { width: min(780px, calc(100vw - 390px)); max-width: none; flex: none; min-height: calc(100vh - 60px); display: flex; flex-direction: column; justify-content: center; margin-bottom: 24px; }

/* SVG cells */
.sector { fill: var(--sector); stroke: var(--bg); stroke-width: 2; transition: fill .12s; }
.sector.given { fill: var(--given-bg); }
.sector.locked { fill: var(--locked-bg); stroke: var(--locked-ln); }
.sector.locked.trail { fill: var(--trail-bg); stroke: var(--trail-ln); }
.sector.current { fill: var(--token-bg); stroke: var(--accent); stroke-width: 3; }
.sector.legal { fill: var(--sector); stroke: var(--good); stroke-width: 2.5; cursor: pointer; }
.sector.legal:hover { fill: var(--sector-hover); }
/* sideways (lateral) options: greyed to show they're possible but not where you're guessing */
/* where you're guessing right now: blinking green */
.sector.selected { fill: color-mix(in srgb, var(--good) 14%, var(--sector)); animation: guessBlink 1.05s ease-in-out infinite; }
@keyframes guessBlink {
  0%, 100% { stroke: var(--good); stroke-width: 4.5; }
  50% { stroke: color-mix(in srgb, var(--good) 25%, transparent); stroke-width: 3; }
}
g[data-r] { cursor: default; }
g[data-r]:has(.legal) { cursor: pointer; }
/* finished spokes are still clickable — they open read-only so you can re-read your run */
g[data-r]:has(.reviewable) { cursor: pointer; }
.sector.locked.reviewing { stroke: var(--accent); stroke-width: 3; }

.ct { fill: var(--text); text-anchor: middle; dominant-baseline: middle; font-family: var(--font); font-weight: 700; pointer-events: none; }
/* scope to the per-cell group (g[data-r]) — the spinning wrapper <g> also matches a bare
   `g:has(.locked)`, which would recolor every word (incl. given ones) once a cell is played */
g[data-r]:has(.given) .ct { fill: var(--given-tx); }
.cs { fill: var(--muted); text-anchor: middle; dominant-baseline: middle; font-family: var(--font); opacity: .8; pointer-events: none; }
g[data-r]:has(.locked) .ct { fill: var(--locked); }
g[data-r]:has(.trail) .ct { fill: var(--trail); }
g[data-r]:has(.current) .ct { fill: var(--text); }
.tick { fill: var(--muted); text-anchor: middle; dominant-baseline: middle; font-family: var(--font); opacity: .6; pointer-events: none; }

/* invisible drag surface in the corners outside the ring — spin the board like a dial */
.spin-surface { fill: transparent; pointer-events: all; cursor: grab; touch-action: none; }
.spin-surface:active { cursor: grabbing; }
/* subtle rim marking the draggable dial; clicks pass through it to the surface behind */
.spin-dial { fill: none; stroke: var(--line); stroke-width: 1.5; opacity: .6; pointer-events: none; }
/* the starting-word band is part of the dial — show the grab affordance there too */
.sector.given { cursor: grab; }
.board-col:active .sector.given { cursor: grabbing; }

.divider { stroke-width: 4.5; stroke-linecap: round; pointer-events: none; }

.center-disc { fill: var(--panel-2); stroke: var(--accent); stroke-width: 2.5; }
.center-disc.ready { stroke: var(--good); stroke-width: 4; }
.center-label { fill: var(--muted); text-anchor: middle; letter-spacing: .12em; font-family: var(--font); }
.center-word { fill: var(--accent); text-anchor: middle; dominant-baseline: middle; font-weight: 800; font-family: var(--font); }
.center-rule-full { fill: var(--locked); text-anchor: middle; dominant-baseline: middle; font-weight: 700; font-family: var(--font); }

.spoke-detail { border: 1px solid var(--line); border-radius: 14px; padding: 12px; background: var(--bg); }
.spoke-detail.hidden { display: none; }
.sd-stuck { color: var(--muted); font-size: 14px; line-height: 1.5; padding: 10px 6px; }
.sd-stuck b { color: var(--bad); }

/* looking back at a finished spoke: read-only, so the panel says so and offers a way out */
.sd-review { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 6px 4px; }
.sd-review-label { color: var(--muted); font-size: 13px; font-weight: 600; letter-spacing: .02em; }
.sd-review-exit { border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font-family: var(--font);
  font-size: 12px; font-weight: 600; padding: 5px 12px; border-radius: 10px; cursor: pointer; transition: border-color .12s; }
.sd-review-exit:hover { border-color: var(--accent); }

/* the zoomed pie-slice */
.sd-svg { width: 100%; height: auto; display: block; }
.sw-band { fill: var(--sector); stroke: var(--bg); stroke-width: 2.5; }
.sw-band.given { fill: var(--given-bg); stroke-dasharray: 5 4; }
.sw-band.filled { fill: var(--locked-bg); stroke: var(--locked-ln); }
.sw-band.filled.trail { fill: var(--trail-bg); stroke: var(--trail-ln); }
.sw-band.current { fill: var(--token-bg); stroke: var(--accent); stroke-width: 2; }
.sw-band.empty { fill: var(--sector); }
.sw-band.active { fill: color-mix(in srgb, var(--good) 15%, var(--sector)); stroke: var(--good); stroke-width: 2.5; }
.sw-band.legal { stroke: var(--good); stroke-width: 2; }
.sw-band.impossible { fill: color-mix(in srgb, var(--bad) 12%, var(--sector)); stroke: color-mix(in srgb, var(--bad) 55%, var(--line)); }
/* faded adjacent-spoke columns: purely the zoomed-board context (not playable) */
.sw-band.sw-side { opacity: .45; }
.sw-word.side { opacity: .8; }
.sw-hit { cursor: pointer; }

.sw-word, .sw-rule, .sw-imp, .sw-c-label, .sw-c-word, .sw-c-rule { font-family: var(--font); text-anchor: middle; dominant-baseline: middle; pointer-events: none; }
.sw-word { fill: var(--text); font-weight: 800; }
.sw-word.given { fill: var(--given-tx); }
.sw-word.filled { fill: var(--locked); }
.sw-word.filled.trail { fill: var(--trail); }
.sw-word.current { fill: var(--text); }
.sw-rule { fill: var(--muted); font-size: 10.5px; }
.sw-imp { fill: var(--bad); font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .03em; }
.sw-center { fill: var(--panel-2); stroke: var(--accent); stroke-width: 3; }
.sw-c-label { fill: var(--muted); font-size: 10px; letter-spacing: .12em; }
.sw-c-word { fill: var(--accent); font-size: 20px; font-weight: 800; }
.sw-c-rule { fill: var(--locked); font-size: 11px; font-weight: 700; }

/* the text input, embedded in the active wedge via <foreignObject> */
.sw-fo { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.sd-input { width: 100%; height: 100%; border: none; outline: none; background: transparent; color: var(--text); font-family: var(--font); font-size: 19px; font-weight: 800; text-align: center; padding: 0; }
/* read at a glance while your eyes are on the input, so: bigger than the old 13px */
.sw-hint { text-align: center; color: var(--muted); font-size: 15.5px; margin-top: 10px; line-height: 1.5; }
.sw-hint b { color: var(--good); }
/* the literal pattern (u…d, _n…) — monospaced so the underscores line up as slots */
.sw-pat { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .95em; font-weight: 700;
  color: var(--text); background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px;
  padding: 1px 6px; margin-left: 3px; white-space: nowrap; letter-spacing: .06em; }
/* the innermost ring answers to two rules — the second gets its own line */
.sw-hint-also { display: block; margin-top: 4px; }

.prompt { color: var(--muted); font-size: 13.5px; margin-bottom: 10px; min-height: 20px; line-height: 1.5; }
.prompt b { color: var(--text); }
.prompt .rule-hi { color: var(--good); font-weight: 700; }
.entry-row { display: flex; gap: 8px; }
.word-input { flex: 1; min-width: 0; padding: 12px 16px; font-size: 18px; border-radius: 10px; background: var(--bg); border: 2px solid var(--line); color: var(--text); font-family: var(--font); outline: none; transition: border-color .12s; }
.word-input:focus { border-color: var(--accent); }
.feedback { min-height: 20px; margin-top: 10px; font-size: 13px; }
.feedback.bad { color: var(--bad); }
.feedback.good { color: var(--good); }

.drawer { position: fixed; right: 0; top: 0; bottom: 0; width: min(320px, 84vw); background: var(--panel); border-left: 1px solid var(--line); z-index: 20; display: flex; flex-direction: column; box-shadow: -20px 0 60px rgba(0,0,0,.35); transition: transform .2s; }
.drawer.hidden { transform: translateX(105%); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 16px; border-bottom: 1px solid var(--line); }
.drawer-body { padding: 14px 16px; overflow-y: auto; display: flex; flex-wrap: wrap; gap: 6px; align-content: flex-start; }
.drawer-body span { background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 4px 11px; font-size: 13px; color: var(--muted); }

/* ---- win state: the whole board goes green, a non-modal banner announces it ---- */
.board-col.won .sector { stroke: var(--good); stroke-width: 3; transition: stroke .35s, stroke-width .35s; }
.board-col.won .center-disc { stroke: var(--good); stroke-width: 4.5; }
.board-col.won #board { filter: drop-shadow(0 0 14px color-mix(in srgb, var(--good) 45%, transparent)); }

.win-banner { position: fixed; top: 16px; left: 50%; margin-left: 93px; transform: translateX(-50%); z-index: 20;
  display: flex; align-items: center; gap: 22px; max-width: min(620px, 92vw);
  background: linear-gradient(180deg, color-mix(in srgb, var(--good) 20%, var(--panel)), var(--panel-2));
  border: 2px solid var(--good); border-radius: 16px; padding: 12px 14px 12px 22px;
  box-shadow: 0 12px 38px color-mix(in srgb, var(--good) 32%, transparent); animation: winPop .42s ease-out; }
.win-banner.hidden { display: none; }
.win-banner-text { display: flex; flex-direction: column; text-align: left; }
.win-banner-title { font-size: 22px; font-weight: 800; color: var(--good); line-height: 1.15; }
.win-banner-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.win-banner .btn.big { background: var(--good); border-color: var(--good); flex: none; }
@keyframes winPop { from { transform: translateX(-50%) translateY(-16px) scale(.92); opacity: 0; }
  to { transform: translateX(-50%) translateY(0) scale(1); opacity: 1; } }

/* interactive tutorial */
.tutorial { position: fixed; inset: 0; z-index: 27; display: flex; align-items: center; justify-content: center; padding: 18px; overflow-y: auto;
  background: radial-gradient(1200px 700px at 50% -15%, var(--glow), var(--bg) 65%); }
.tutorial.hidden { display: none; }
.tut-panel { display: flex; flex-direction: column; align-items: center; gap: 14px; width: min(520px, 96vw); margin: auto; }
.tut-stage { width: 100%; }
.tut-svg { width: 100%; height: auto; display: block; }
.tut-coach { width: min(480px, 94vw); text-align: center; display: flex; flex-direction: column; gap: 10px; }
.tut-msg { margin: 0; font-size: 16px; line-height: 1.5; color: var(--text); min-height: 66px; }
.tut-msg b { color: var(--accent); }
.tut-feedback { min-height: 18px; font-size: 13px; color: var(--bad); }
.tut-controls { display: flex; align-items: center; justify-content: center; gap: 18px; }
.tut-skip { background: transparent; border: none; color: var(--muted); font-family: var(--font); font-size: 13px; cursor: pointer; text-decoration: underline; }
.tut-skip:hover { color: var(--text); }
/* pulsing highlight for the cell the tutorial is pointing at */
.tut-hl { stroke: var(--accent) !important; stroke-width: 4 !important; animation: tut-glow 1.5s ease-in-out infinite; }
@keyframes tut-glow {
  0%, 100% { filter: drop-shadow(0 0 2px color-mix(in srgb, var(--accent) 45%, transparent)); }
  50% { filter: drop-shadow(0 0 9px color-mix(in srgb, var(--accent) 80%, transparent)); }
}
@media (prefers-reduced-motion: reduce) { .tut-hl { animation: none; } }

/* landing / greeting screen */
.landing { position: fixed; inset: 0; z-index: 25; display: flex; align-items: center; justify-content: center; overflow: hidden;
  background: radial-gradient(1200px 700px at 50% -15%, var(--glow), var(--bg) 65%); }
.landing.hidden { display: none; }
/* faded, slowly rotating board render for ambiance */
.landing-bg { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; z-index: 0; }
#landingBoard { width: min(128vmin, 940px); height: min(128vmin, 940px); opacity: .16;
  animation: landing-spin 100s linear infinite;
  -webkit-mask-image: radial-gradient(circle at 50% 50%, #000 38%, transparent 74%);
  mask-image: radial-gradient(circle at 50% 50%, #000 38%, transparent 74%); }
@keyframes landing-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { #landingBoard { animation: none; } }
.landing-inner { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 40px; padding: 24px; }
.landing-logo { margin: 0; font-weight: 800; letter-spacing: -.02em; line-height: 1;
  font-size: clamp(64px, 15vw, 120px); color: var(--text); }
.landing-actions { display: flex; flex-direction: column; gap: 14px; width: min(300px, 82vw); }
.landing-btn { width: 100%; text-align: center; font-size: 19px; padding: 15px 24px; }
.landing-btn.secondary { background: transparent; color: var(--accent); border-color: var(--accent); }
.landing-btn.secondary:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 10%, transparent); }

.overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(8,10,14,.7); backdrop-filter: blur(6px); z-index: 30; }
.overlay.hidden { display: none; }
.overlay-card { background: linear-gradient(180deg, var(--panel), var(--panel-2)); border: 1px solid var(--line); border-radius: 20px; padding: 32px 40px; text-align: center; width: min(440px, 92vw); box-shadow: 0 30px 80px rgba(0,0,0,.4); }
.overlay-card h1 { margin: 0 0 12px; font-size: 30px; }
.overlay-card .btn + .btn { margin-left: 10px; }

.overlay-card p { color: var(--muted); margin: 0 0 22px; line-height: 1.5; }

@media (max-width: 900px) {
  /* narrow screens: sidebar reverts to a normal top banner */
  .topbar { position: static; width: auto; flex-direction: row; align-items: center; flex-wrap: wrap; border-right: none; border-bottom: 1px solid var(--line); padding: 12px 16px; overflow: visible; }
  .stats { flex-direction: row; margin-left: auto; flex-wrap: wrap; }
  .actions { flex-direction: row; margin-top: 0; }
  .stage { flex-direction: column; align-items: center; padding: 8px 12px 22px; margin-left: 0; }
  .board-col { margin-left: 0; }
  #board { width: min(560px, 92vw); }
  .entry-col { width: min(560px, 92vw); max-width: none; flex: none; }
  :root[data-layout="scroll"] .board-col { min-height: 0; }
  :root[data-layout="scroll"] #board { width: min(560px, 92vw); }
  :root[data-layout="scroll"] .entry-col { width: min(560px, 92vw); min-height: 0; }
  /* sidebar is a top bar here — drop the score badges to the bottom corners */
  .score-float { top: auto; bottom: 12px; padding: 5px 14px; min-width: 68px; }
  .score-left { left: 12px; }
  .score-right { right: 12px; }
  .sf-val { font-size: 20px; }
  /* sidebar is a top bar here — recentre the win banner on the full width */
  .win-banner { margin-left: 0; }
}
@media (max-width: 620px) { .stats { width: 100%; margin-left: 0; order: 3; } }

/* ============ phone mode: only the spoke view; everything else behind a menu ============ */
@media (max-width: 640px) {
  #menuBtn { display: flex; }

  #boardBtn { display: flex; }

  /* the board is hidden entirely — the spoke view is the whole screen
     (second selector matches the scroll-layout rule's specificity so it wins) */
  .board-col, :root[data-layout="scroll"] .board-col { display: none; }

  /* …until you tap "Board": it takes over the screen as a peek overlay */
  .board-peek .board-col, :root[data-layout="scroll"].board-peek .board-col {
    display: flex; position: fixed; inset: 0; z-index: 25; margin: 0; padding: 62px 10px 16px;
    min-height: 0; align-items: center; justify-content: center;
    background: radial-gradient(1200px 700px at 50% -15%, var(--glow), var(--bg) 65%); }
  .board-peek #board, :root[data-layout="scroll"].board-peek #board { width: min(96vw, 96vh); height: auto; }
  .board-peek #boardClose { display: flex; }
  .board-peek #boardBtn, .board-peek #menuBtn { display: none; }
  .stage { flex-direction: column; margin-left: 0; padding: 0; }
  .entry-col, :root[data-layout="scroll"] .entry-col {
    width: 100vw; max-width: none; min-height: 100vh; order: 0;
    margin: 0; padding: 62px 12px 18px; border: none; border-radius: 0; background: transparent;
    display: flex; flex-direction: column; justify-content: center; touch-action: pan-y; }

  /* the top banner becomes a slide-in left drawer */
  .topbar { position: fixed; left: 0; top: 0; bottom: 0; width: min(286px, 86vw);
    flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 14px; padding: 18px 14px;
    border-right: 1px solid var(--line); border-bottom: none; background: var(--bg); overflow-y: auto;
    z-index: 23; transform: translateX(-100%); transition: transform .22s ease; }
  .menu-open .topbar { transform: translateX(0); box-shadow: 8px 0 40px rgba(0,0,0,.4); }
  .menu-open #menuScrim { display: block; }
  /* the ☰ button is fixed at x 12–56 and floats above the drawer, so start the brand
     (wheel first) clear of it rather than underneath it */
  .topbar .brand { margin-left: 48px; margin-right: 12px; }
  .topbar .stats { flex-direction: column; flex-wrap: nowrap; width: auto; margin-left: 0; order: 0; }
  .topbar .actions { flex-direction: column; margin-top: 6px; order: 0; }
  #abandonBtn { order: 0; }

  /* score badges flow inside the drawer instead of floating in the corners */
  .score-float { position: static; inset: auto; order: 0; width: 100%; min-width: 0;
    flex-direction: row; align-items: center; justify-content: space-between; padding: 8px 14px; box-shadow: none; }
  .sf-label { font-size: 11px; }
  .sf-val { font-size: 20px; }

  /* streamlined phone spoke view: a vertical stack of rectangles, no adjacent spokes */
  .msv { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 440px; margin: 0 auto; }
  .msv-cell { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    border: 2px solid var(--line); border-radius: 15px; background: var(--sector); padding: 12px 14px; min-height: 68px; }
  .msv-tag { font-size: 10px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
  .msv-rule { font-size: 12px; font-weight: 600; color: var(--muted); }
  .msv-word { font-size: 23px; font-weight: 800; color: var(--text); line-height: 1.1; }
  .msv-muted { color: var(--muted); opacity: .5; }
  .msv-given { background: var(--given-bg); border-style: dashed; }
  .msv-given .msv-word { color: var(--given-tx); }
  .msv-filled { background: var(--locked-bg); border-color: var(--locked-ln); }
  .msv-filled .msv-word { color: var(--locked); }
  .msv-filled.msv-trail { background: var(--trail-bg); border-color: var(--trail-ln); }
  .msv-filled.msv-trail .msv-word { color: var(--trail); }
  .msv-current { background: var(--token-bg); border-color: var(--accent); }
  .msv-active { background: color-mix(in srgb, var(--good) 12%, var(--sector)); border-color: var(--good); min-height: 80px; }
  .msv-target { background: var(--panel-2); border-color: var(--accent); border-width: 3px; }
  .msv-target .msv-word { color: var(--accent); font-size: 25px; }
  .msv-target-rule { color: var(--locked); font-weight: 700; }
  .msv-input { width: 100%; border: none; outline: none; background: transparent; text-align: center;
    font-family: var(--font); font-size: 24px; font-weight: 800; color: var(--text); padding: 2px 0; }
  .msv-input::placeholder { color: var(--muted); opacity: .55; font-weight: 600; font-size: 16px; }
}
