/* 2048. Colour belongs to the tiles: they heat up with each power of two (yellow, orange, red, crimson) and the
   2048 tile turns to ink. Everything around them is plain: solid surfaces, neutral text, hairlines. Green and red
   only mean something (ranked or not, ahead or behind, a good or a costly move). */
:root {
  /* Light and dark are both designed: say so, or Chrome on Android may "darken" the page with its own colours. */
  color-scheme: light dark;
  --bg: #f2f3f5;
  --surface: #ffffff;
  --sunk: #e7e9ec;          /* buttons, segmented controls */
  --tray: #cdd1d7;          /* the board */
  --well: #dadde2;          /* empty squares */
  --ink: #15181d;
  --muted: #5d636c;
  --line: #d9dce1;
  --up: #12804f;
  --down: #c8362b;
  --warn: #b5650d;
  --focus: #15181d;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
  /* Tiles: exponent 1 (2) .. 14+ (16384). */
  --t1: #fbfbfc; --f1: #2b3038;
  --t2: #eceef1; --f2: #2b3038;
  --t3: #f5d27c; --f3: #3b2a00;
  --t4: #f2b45b; --f4: #3a2200;
  --t5: #ec9347; --f5: #3a1700;
  --t6: #e2703b; --f6: #fff;
  --t7: #d24f35; --f7: #fff;
  --t8: #b93634; --f8: #fff;
  --t9: #9c2738; --f9: #fff;
  --t10: #781e3a; --f10: #fff;
  --t11: #15181d; --f11: #f5d27c;
  --t12: #0e5e4e; --f12: #fff;
  --t13: #0b4f73; --f13: #fff;
  --t14: #2b3038; --f14: #fff;
}
:root[data-theme=light] { color-scheme: light; }
:root[data-theme=dark] {
  color-scheme: dark;
  --bg: #131518; --surface: #1c1f24; --sunk: #262a30; --tray: #23272d; --well: #2c3037;
  --ink: #eceef1; --muted: #9aa1ab; --line: #30353c; --up: #43c486; --down: #f0675b; --warn: #e3a04a; --focus: #eceef1;
  --t1: #3a3f47; --f1: #e6e8eb; --t2: #4a5059; --f2: #f2f3f5;
  --t11: #eceef1; --f11: #15181d; --t14: #d6d9de; --f14: #15181d;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) {
    color-scheme: dark;
    --bg: #131518; --surface: #1c1f24; --sunk: #262a30; --tray: #23272d; --well: #2c3037;
    --ink: #eceef1; --muted: #9aa1ab; --line: #30353c; --up: #43c486; --down: #f0675b; --warn: #e3a04a; --focus: #eceef1;
    --t1: #3a3f47; --f1: #e6e8eb; --t2: #4a5059; --f2: #f2f3f5;
    --t11: #eceef1; --f11: #15181d; --t14: #d6d9de; --f14: #15181d;
  }
}

* { box-sizing: border-box; }
html { background: var(--bg); }
html, body { margin: 0; color: var(--ink); font: 16px/1.4 var(--font); -webkit-tap-highlight-color: transparent; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
body { min-height: 100dvh; overflow-x: hidden; }
.icon { width: 22px; height: 22px; flex: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.press { transition: scale 120ms var(--ease), background-color 150ms; }
.press:active { scale: .96; }

.app { width: min(100%, 540px); min-height: 100dvh; margin: 0 auto; display: flex; flex-direction: column; align-items: stretch;
  padding: max(10px, env(safe-area-inset-top)) 16px max(12px, env(safe-area-inset-bottom)); gap: 10px; }

/* Status bar: mode, score, rank, account. No container: it sits on the page. */
.dock { display: flex; align-items: center; gap: 8px; min-height: 52px; }
/* The mode is a title with a chevron (it opens the modes); under it, in colour, whether the game counts. */
.menu-btn { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; min-height: 44px; padding: 2px; border: 0;
  border-radius: 8px; background: none; text-align: left; line-height: 1.15; }
.mode-name { display: flex; align-items: center; gap: 2px; font-size: 20px; font-weight: 800; letter-spacing: -.01em; }
.mode-name .icon { width: 18px; height: 18px; color: var(--muted); }
.menu-btn small { font-size: 12px; font-weight: 700; color: var(--st, var(--up)); }
.menu-btn.ranked { --st: var(--up); } .menu-btn.unranked { --st: var(--down); }
.score { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-end; padding-right: 2px; line-height: 1.05; }
.score b { font-size: 28px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; transition: scale 160ms var(--ease); }
.score b.bump { scale: 1.04; transition-duration: 60ms; }
.score small { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.rank { display: flex; flex-direction: column; align-items: center; justify-content: center; border: 0; background: none;
  border-radius: 8px; min-width: 48px; height: 44px; line-height: 1.05; padding: 0 6px; }
.rank b { font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; }
.rank small { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.rank.cta { padding: 0 12px; }
.rank.cta b { display: none; }
.rank.cta small { font-size: 13px; font-weight: 700; color: var(--ink); text-transform: none; letter-spacing: 0; }
.rank.flash { animation: flash 700ms var(--ease); }
@keyframes flash { from { background: color-mix(in srgb, var(--up) 22%, transparent); } }
.me { border: 0; background: none; padding: 0; width: 44px; height: 44px; display: grid; place-items: center; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; overflow: hidden; font-weight: 800; font-size: 14px;
  background: var(--sunk); color: var(--muted); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* Above the board: the Blitz clock, and who you are chasing (or the daily ghost). Plain text, no capsule. */
.race { display: flex; justify-content: center; align-items: center; gap: 16px; min-height: 32px; width: 100%; }
.race[hidden], .race [hidden] { display: none; }
.chase { display: flex; align-items: baseline; gap: 6px; border: 0; background: none; padding: 4px 6px; font-size: 14px; min-width: 0; max-width: 100%; color: var(--muted); }
.chase .dot { display: none; }
.chase b { font-variant-numeric: tabular-nums; font-weight: 800; color: var(--ink); }
.chase.up b { color: var(--up); } .chase.down b { color: var(--down); }
.chase span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clock { position: relative; display: flex; align-items: center; justify-content: center; height: 30px; min-width: 64px; padding: 0 2px 4px;
  font-weight: 800; font-size: 20px; font-variant-numeric: tabular-nums; }
.clock i { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; border-radius: 2px; background: var(--line); overflow: hidden; }
.clock i b { position: absolute; inset: 0; background: var(--ink); transform-origin: left; transition: scale 200ms linear; }
.clock.low { color: var(--down); }
.clock.low i b { background: var(--down); }
.clock.low span { animation: tick 1s steps(1) infinite; }
@keyframes tick { 50% { opacity: .5; } }
.clock.done { color: var(--muted); }

/* Board: a solid tray with sunken squares; tiles are flat with a thicker bottom edge. */
.stage { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; }
.board { position: relative; width: min(100%, max(260px, calc(100dvh - 300px))); aspect-ratio: 1; border-radius: 14px; touch-action: none;
  user-select: none; -webkit-user-select: none; background: var(--tray); }
.grid, .tiles { position: absolute; inset: var(--gap); }
.grid { display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: var(--gap); }
.grid i { background: var(--well); border-radius: calc(var(--cell) * .1); }
.tile {
  position: absolute; left: 0; top: 0; width: var(--cell); height: var(--cell); border-radius: calc(var(--cell) * .1);
  display: grid; place-items: center; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.03em; line-height: 1;
  font-size: calc(var(--cell) * .42);
  transform: translate(calc(var(--x) * (var(--cell) + var(--gap))), calc(var(--y) * (var(--cell) + var(--gap))));
  transition: transform 110ms var(--ease);
  will-change: transform;
  background: var(--tc); color: var(--tf);
  box-shadow: inset 0 calc(var(--cell) * -.045) 0 rgba(0, 0, 0, .14);
}
.tile[data-digits="3"] { font-size: calc(var(--cell) * .35); }
.tile[data-digits="4"] { font-size: calc(var(--cell) * .28); }
.tile[data-digits="5"] { font-size: calc(var(--cell) * .23); }
.tile[data-digits="6"] { font-size: calc(var(--cell) * .19); }
.tile.new { animation: spawn 140ms var(--ease) 60ms both; }
.tile.pop { animation: merge 140ms var(--ease); z-index: 2; }
@keyframes spawn { from { scale: .6; opacity: 0; } }
@keyframes merge { 50% { scale: 1.07; } }
.e1 { --tc: var(--t1); --tf: var(--f1); } .e2 { --tc: var(--t2); --tf: var(--f2); }
.e3 { --tc: var(--t3); --tf: var(--f3); } .e4 { --tc: var(--t4); --tf: var(--f4); } .e5 { --tc: var(--t5); --tf: var(--f5); }
.e6 { --tc: var(--t6); --tf: var(--f6); } .e7 { --tc: var(--t7); --tf: var(--f7); } .e8 { --tc: var(--t8); --tf: var(--f8); }
.e9 { --tc: var(--t9); --tf: var(--f9); } .e10 { --tc: var(--t10); --tf: var(--f10); } .e11 { --tc: var(--t11); --tf: var(--f11); }
.e12 { --tc: var(--t12); --tf: var(--f12); } .e13 { --tc: var(--t13); --tf: var(--f13); }
.e14, .e15, .e16, .e17 { --tc: var(--t14); --tf: var(--f14); }

/* Board overlay: a plain card over a dimmed board. */
.overlay { position: absolute; inset: 0; border-radius: inherit; display: none; place-items: center; padding: 16px; z-index: 5;
  background: color-mix(in srgb, var(--bg) 70%, transparent); }
.overlay.show { display: grid; animation: fade 160ms ease-out; }
.overlay .card { border-radius: 12px; padding: 18px 18px 14px; text-align: center; min-width: min(100%, 260px); background: var(--surface);
  border: 1px solid var(--line); box-shadow: 0 8px 24px -12px rgba(0, 0, 0, .35); animation: rise 180ms var(--ease); }
.overlay small { display: block; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-weight: 700; min-height: 1em; }
.overlay.record small { color: var(--up); }
.overlay h2 { margin: 2px 0 4px; font-size: clamp(34px, 11vw, 50px); font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.overlay p { margin: 0 0 12px; color: var(--muted); font-size: 14px; min-height: 1em; }
.overlay .row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; translate: 0 6px; } }

/* The tiles on the way up: reached ones in their colour, the next one outlined. */
.ladder { list-style: none; margin: 0; padding: 0; display: flex; justify-content: center; gap: 4px; flex: none; }
.ladder .chip { min-width: 0; flex: 0 1 3.4em; padding: 3px 2px; font-size: 11px; transition: background-color 200ms, color 200ms; }
.ladder .todo { background: none; color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); opacity: .7; }
.ladder .next { opacity: 1; box-shadow: inset 0 0 0 1px var(--muted); }
.ladder .top { animation: merge 320ms var(--ease); }
/* What a merge earned, rising from its square; and a new biggest tile swelling across the board once. */
.gain { position: absolute; left: var(--gap); top: var(--gap); width: var(--cell); z-index: 3; pointer-events: none; text-align: center;
  font-weight: 800; font-size: calc(var(--cell) * .2); font-variant-numeric: tabular-nums; color: var(--ink);
  text-shadow: 0 0 4px var(--bg), 0 0 4px var(--bg);
  transform: translate(calc(var(--x) * (var(--cell) + var(--gap))), calc(var(--y) * (var(--cell) + var(--gap)) + var(--cell) * .08));
  animation: gain 700ms ease-out both; }
@keyframes gain { from { opacity: 0; translate: 0 8px; } 20% { opacity: 1; } to { opacity: 0; translate: 0 calc(var(--cell) * -.45); } }
.mile { position: absolute; inset: 0; z-index: 4; pointer-events: none; display: grid; place-items: center; border-radius: inherit;
  font-weight: 800; letter-spacing: -.03em; font-size: calc(var(--cell) * 1.15); font-variant-numeric: tabular-nums; color: var(--tc);
  -webkit-text-stroke: 2px var(--surface); paint-order: stroke fill; box-shadow: inset 0 0 0 4px var(--tc);
  animation: mile 1000ms var(--ease) both; }
@keyframes mile { from { opacity: 0; scale: .7; } 25% { opacity: 1; scale: 1; } 70% { opacity: 1; } to { opacity: 0; scale: 1.08; } }
/* Toolbar: plain labelled actions under the board; full screen is the one icon-only control. */
.toolbar { align-self: center; display: flex; gap: 4px; }
.tool { min-width: 44px; height: 44px; padding: 0 12px; border: 0; border-radius: 8px; background: none; display: inline-flex; align-items: center;
  justify-content: center; gap: 6px; font-weight: 700; font-size: 14px; white-space: nowrap; }
@media (max-width: 440px) { .tool { padding: 0 8px; gap: 5px; } }
.tool .icon { width: 20px; height: 20px; }
.tool:hover { background: var(--sunk); }
.tool[hidden] { display: none; }

/* Buttons: the main action in ink, the rest outlined. */
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 9px 16px; font-weight: 700; font-size: 15px;
  display: inline-flex; align-items: center; gap: 6px; justify-content: center; text-decoration: none; color: inherit; min-height: 44px; }
.btn:hover { background: var(--sunk); }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.primary:hover { background: color-mix(in srgb, var(--ink) 85%, var(--bg)); }

/* Menu (popover) */
.menu { margin: 0; inset: auto; position: fixed; top: calc(max(10px, env(safe-area-inset-top)) + 58px); left: max(16px, calc(50vw - 254px));
  width: min(300px, calc(100vw - 32px)); border-radius: 12px; padding: 6px; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); box-shadow: 0 12px 32px -16px rgba(0, 0, 0, .4); }
.menu:popover-open { animation: rise 140ms var(--ease); }
.menu hr { border: 0; height: 1px; background: var(--line); margin: 6px 8px; }
.mode, .item { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; border: 0; background: none; border-radius: 8px; padding: 8px 12px;
  text-align: left; font-weight: 600; font-size: 15px; text-decoration: none; color: inherit; }
.mode:hover, .item:hover { background: var(--sunk); }
.mode i { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--muted); flex: none; }
.mode[aria-checked=true] i { border-color: var(--ink); background: var(--ink); }
.mode span { display: flex; justify-content: space-between; align-items: baseline; flex: 1; }
.mode small { color: var(--muted); font-weight: 500; }
.sizes { display: flex; gap: 6px; padding: 2px 12px 6px 34px; }
.sizes button, .chips button { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; min-width: 36px; padding: 6px 9px; font-weight: 700; font-size: 13px; }
.sizes button[aria-pressed=true], .chips button[aria-pressed=true] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chips { display: flex; gap: 6px; }

/* Sheets: solid panels that come up from the bottom. */
dialog.sheet { position: fixed; border: 1px solid var(--line); border-bottom: 0; padding: 0; margin: auto auto 0; width: min(100%, 540px); max-height: 88dvh;
  color: var(--ink); background: var(--surface); border-radius: 16px 16px 0 0; overflow: hidden; }
@media (min-width: 700px) { dialog.sheet { margin: auto; border-radius: 16px; border-bottom: 1px solid var(--line); } }
dialog.sheet::backdrop { background: rgba(10, 12, 15, .45); }
dialog.sheet[open] { animation: sheetIn 200ms var(--ease); }
@keyframes sheetIn { from { translate: 0 24px; opacity: 0; } }
.sheet header { display: flex; align-items: center; gap: 10px; padding: 16px 16px 10px; }
.sheet header h2 { margin: 0; font-size: 21px; font-weight: 800; letter-spacing: -.01em; flex: 1; }
.close { border: 1px solid var(--line); background: var(--surface); width: 40px; height: 40px; border-radius: 10px; font-size: 20px; line-height: 1; }
.sheet .body { padding: 0 16px 22px; overflow: auto; max-height: calc(88dvh - 70px); }
.verified { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; color: var(--up); }
.verified .icon { width: 14px; height: 14px; }

.seg { display: flex; padding: 3px; border-radius: 10px; background: var(--sunk); margin-bottom: 10px; }
.seg button { flex: 1; border: 0; background: none; padding: 8px 6px; border-radius: 8px; font-weight: 700; font-size: 14px; color: var(--muted); transition: background-color 150ms, color 150ms; }
.seg button[aria-selected=true] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
.subnav { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 36px; margin: 2px 0 6px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.subnav > button { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; width: 36px; height: 36px; flex: none; font-weight: 800; }
.subnav > button:disabled { opacity: .35; }
.subnav .mid { flex: 1; text-align: center; }
.mini-seg { display: flex; gap: 2px; padding: 2px; border-radius: 8px; background: var(--sunk); }
.mini-seg button { border: 0; background: none; border-radius: 6px; padding: 5px 10px; font-size: 12px; font-weight: 700; color: var(--muted); }
.mini-seg button[aria-pressed=true] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }

/* Leaderboard rows: rank, name over moves and play time, score, best tile. */
.lb { list-style: none; margin: 0; padding: 0; font-variant-numeric: tabular-nums; }
.lb .row { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto 3.9em; align-items: center; gap: 12px; padding: 10px 8px; margin: 0 -8px;
  border-top: 1px solid var(--line); cursor: pointer; transition: background-color 120ms; }
.lb .row:first-child { border-top: 0; }
.lb .row:hover { background: var(--sunk); }
.lb .row.you { background: color-mix(in srgb, var(--up) 8%, var(--surface)); }
.lb .row.you .nm b::after { content: " · you"; font-weight: 600; color: var(--muted); }
.lb .rk { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 13px; color: var(--muted); }
.lb .rk.m1, .lb .rk.m2, .lb .rk.m3 { color: #1d1400; background: var(--coin); }
.lb .rk.m1 { --coin: #e3b341; } .lb .rk.m2 { --coin: #bcc2cb; color: #1b2028; } .lb .rk.m3 { --coin: #cc8d58; color: #2a1406; }
.lb .nm { display: flex; flex-direction: column; min-width: 0; }
.lb .nm b { font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb .nm small { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.lb .pt { font-size: 16px; font-weight: 800; letter-spacing: -.01em; text-align: right; }
.lb .chip { justify-self: end; }
.lb .gap { height: 18px; border-top: 1px dashed var(--line); margin-top: 8px; }
.lb .live { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--up); margin-left: 7px; vertical-align: 2px; }
.lb .empty { text-align: center; color: var(--muted); padding: 28px 0; }
.chip { display: inline-grid; place-items: center; min-width: 3.6em; padding: 3px 6px; border-radius: 6px; font-weight: 800; font-size: 12px;
  background: var(--tc); color: var(--tf); font-variant-numeric: tabular-nums; }

/* Replay viewer */
.replay { display: flex; flex-direction: column; gap: 12px; }
.rp-meta { display: flex; justify-content: space-between; align-items: baseline; color: var(--muted); font-size: 14px; }
.rp-meta b { color: var(--ink); font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.board.mini { width: min(100%, 360px, calc(88dvh - 240px)); align-self: center; border-radius: 12px; }
.rp-controls { display: flex; align-items: center; gap: 10px; }
.rp-controls .tool { flex: none; width: 52px; padding: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
/* Step one move at a time: the move about to be played is named between the arrows. */
.rp-step { display: flex; align-items: center; gap: 8px; }
.rp-step button { flex: none; width: 52px; height: 44px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font-size: 22px; font-weight: 800; line-height: 1; }
.rp-step button:disabled { opacity: .35; }
.rp-step span { flex: 1; min-width: 0; text-align: center; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rp-step span b { color: var(--ink); font-size: 18px; margin-left: 2px; }
/* The focused moment: a labelled block between hairlines. */
.lesson { display: flex; flex-direction: column; gap: 6px; padding: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.lesson[hidden] { display: none; }
.lesson.bad { --lesson: var(--down); } .lesson.missed { --lesson: var(--warn); } .lesson.away { --lesson: var(--muted); }
.lesson header { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.lesson header b { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--lesson, var(--ink)); }
.lesson header span { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.lesson-text { margin: 0; font-size: 15px; font-weight: 600; line-height: 1.4; }
.lesson-why { margin: 0; font-size: 14px; color: var(--muted); line-height: 1.45; }
.lesson .mini-seg { align-self: flex-start; margin-top: 4px; }
.lesson .mini-seg button { font-size: 13px; padding: 7px 12px; }
.coach-story { display: flex; flex-direction: column; gap: 6px; font-size: 14px; line-height: 1.5; color: var(--muted); }
.coach-story p { margin: 0; } .coach-story p:first-child { color: var(--ink); }
.coach-story:empty { display: none; }
.fork { align-self: center; }
.fork[hidden] { display: none; }

/* Coach: marks on the timeline and a list under the replay. The mark's colour is the kind of moment. */
.rp-track { flex: 1; position: relative; display: flex; align-items: center; min-width: 0; }
.rp-track input { flex: 1; width: 100%; accent-color: var(--ink); margin: 0; }
.ticks { position: absolute; left: 8px; right: 8px; top: 50%; height: 0; pointer-events: none; }
.ticks i { position: absolute; top: -12px; width: 2px; height: 7px; margin-left: -1px; background: var(--ink); }
.ticks i.risk, .ticks i.fatal { background: var(--down); } .ticks i.missed { background: var(--warn); } .ticks i.away { background: var(--muted); }
.ticks i.fatal { height: 9px; top: -14px; }
.grid i.home { box-shadow: inset 0 0 0 2px var(--muted); }
.coach { display: flex; flex-direction: column; gap: 12px; }
.coach[hidden] { display: none; }
/* How the game ended: the first thing the review says. */
.coach-end { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 0; color: var(--ink); font-size: 15px; line-height: 1.45; font-weight: 700; }
.coach-end.bad { color: var(--down); }
.coach-end:not(:disabled):hover { text-decoration: underline; text-underline-offset: 3px; }
.coach-end[hidden] { display: none; }
.coach-sum { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.coach-sum span { display: flex; flex-direction: column; padding: 10px 10px 10px 0; font-size: 12px; color: var(--muted); line-height: 1.25; }
.coach-sum span + span { padding-left: 12px; border-left: 1px solid var(--line); }
.coach-sum b { font-size: 20px; font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; }
.coach-sum .good b { color: var(--up); } .coach-sum .bad b { color: var(--down); }
.moments { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.moments li + li .moment { border-top: 1px solid var(--line); }
.moment { width: 100%; display: grid; grid-template-columns: 8px 3.2em 3.6em minmax(0, 1fr); align-items: center; gap: 8px; text-align: left; border: 0;
  padding: 10px 6px; background: none; font-size: 14px; line-height: 1.35; transition: background-color 120ms; }
.moment::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--ink); }
.moment.risk::before, .moment.fatal::before { background: var(--down); } .moment.missed::before { background: var(--warn); } .moment.away::before { background: var(--muted); }
.moment:hover { background: var(--sunk); }
.moment.on { background: var(--sunk); }
.moment .mv { color: var(--muted); font-weight: 800; font-variant-numeric: tabular-nums; text-align: right; }
.moment .mv::before { content: "#"; opacity: .6; }
.moment .txt { color: var(--ink); }
.moment.fatal .txt { font-weight: 700; }
.moments .clean { color: var(--muted); font-size: 14px; padding: 6px 0; }

.speed { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; height: 44px; min-width: 52px; font-weight: 800; font-variant-numeric: tabular-nums; }

/* Account & settings */
.signin { display: flex; flex-direction: column; gap: 14px; align-items: center; text-align: center; padding: 4px 0 8px; }
.signin p { margin: 0; color: var(--muted); font-size: 14px; }
.who { display: flex; align-items: center; gap: 12px; margin: 0 0 14px; }
.who .avatar { width: 48px; height: 48px; font-size: 18px; }
.who b { display: block; font-size: 17px; }
.who small { color: var(--muted); }
.statgrid { display: grid; grid-template-columns: repeat(3, 1fr); margin: 0 0 16px; border-top: 1px solid var(--line); }
.statgrid div { padding: 10px 0; border-bottom: 1px solid var(--line); }
.statgrid div:not(:nth-child(3n + 1)) { padding-left: 12px; border-left: 1px solid var(--line); }
.statgrid b { display: block; font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.statgrid span { font-size: 12px; color: var(--muted); }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; padding: 6px 0; border-bottom: 1px solid var(--line); font-weight: 600; }
.switch { appearance: none; width: 46px; height: 28px; border-radius: 999px; background: var(--line); position: relative; transition: background-color 150ms; flex: none; margin: 0; cursor: pointer; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: translate 150ms var(--ease); }
.switch:checked { background: var(--up); }
.switch:checked::after { translate: 18px 0; }

.toast { position: fixed; left: 50%; bottom: calc(max(14px, env(safe-area-inset-bottom)) + 66px); translate: -50% 0; max-width: calc(100vw - 32px);
  padding: 10px 14px; border-radius: 10px; font-size: 14px; font-weight: 600; z-index: 50; background: var(--ink); color: var(--bg); animation: rise 160ms var(--ease); }

/* Full screen: the board takes the room; chrome stays reachable. */
:root.full .board { width: min(100%, max(260px, calc(100dvh - 210px))); }
:root.full .app { width: min(100%, 640px); }

@media (prefers-reduced-motion: reduce) {
  .tile, .press, .score b, .switch::after, .clock i b { transition: none; }
  .tile.new, .tile.pop, .gain, .mile, .ladder .top, dialog.sheet[open], .overlay, .overlay .card, .menu:popover-open, .clock.low span, .toast, .rank.flash { animation: none; }
}
@media (max-height: 640px) { .dock { min-height: 46px; } .menu-btn, .rank, .me { height: 40px; } .score b { font-size: 23px; } .stage { gap: 8px; } }

/* Android sign-in hand-off page and credits page */
.auth .signin { margin-top: 14vh; gap: 16px; }
.auth h1 { margin: 0; font-size: 24px; font-weight: 800; }
.auth #slot { min-height: 44px; }
.mark { display: flex; align-items: baseline; gap: 2px; font-weight: 800; font-size: 32px; letter-spacing: -.02em; line-height: 1; color: inherit; text-decoration: none; }
.mark sup { font-size: 13px; color: var(--muted); }
.doc { gap: 8px; line-height: 1.55; padding-top: max(20px, env(safe-area-inset-top)); }
