/* ═══════════════════════════════════════════════════════════════════════════
   FLYWHEEL NINE — NAVY · STEEL · MILLED

   A machine room under blue instrument lighting. Steel plates lifted a
   millimetre off a navy ground on hairline edges, legends silkscreened in
   mono, one signal green for "in range" and one red for the redline.

   Rules this sheet keeps, without exception:
     · Radius is 4 (buttons, chips, plates), 10 (cards, sheets, the stage),
       3 (tags). Never a pill, never a blob. Milled, not moulded.
     · Every raised plate wears the same three layers: solid --surface, a 1px
       --line edge, and a machined top highlight (inset 0 1px 0 white .09).
     · Blue is a fill, a lit edge or a large glyph. Small blue TEXT is
       --accent-d. On a blue FILL, text is --bg.
     · Numerals are IBM Plex Mono, always. Prose is IBM Plex Sans.
     · Motion is 150ms cubic-bezier(.2,.8,.3,1); press is scale(.985). Heavy
       machinery does not bounce.
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  /* Written from JS by applySafeArea(). 0 outside Telegram fullscreen, so
     every utility that reads them collapses on its own. */
  --tg-safe-top: 0px;
  --tg-safe-bottom: 0px;

  /* Duplicated from brand.js so the splash paints correctly on frame one,
     before shell.js has stamped the palette onto <html>. */
  --bg:       #060F1C;
  --surface:  #0D1929;
  --tint:     #12233A;
  --tint-2:   #1B3252;
  --line:     #26445F;
  --ink:      #E6EEF8;
  --ink-2:    #9FB3C8;
  --ink-3:    #7189A3;
  --accent:   #60A5FA;
  --accent-d: #8FC1FF;
  --good:     #34D399;
  --warn:     #FB7185;

  --f-display: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --f-text: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --r: 4px;           /* buttons, chips, plates */
  --r-lg: 10px;       /* cards, sheets, the stage */
  --r-sm: 3px;        /* tags, tracks, switches */
  --edge: 1px solid var(--line);
  --mill: inset 0 1px 0 rgba(157, 182, 208, .09);   /* the machined top face */
  --sh: 0 1px 0 rgba(0, 0, 0, .5), 0 10px 24px -16px rgba(0, 0, 0, .9);
  --t: 150ms cubic-bezier(.2, .8, .3, 1);
  --nav-h: 60px;
}

*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* Overlays set their own display, which outranks the UA rule for [hidden]. */
[hidden] { display: none !important; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg);
  overscroll-behavior: none;
  -webkit-overflow-scrolling: touch;
}

body {
  font-family: var(--f-text);
  font-weight: 450;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; color: inherit; }
button { border: 0; background: none; padding: 0; cursor: pointer; }

/* The icon sprite itself never renders. */
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ── icons ───────────────────────────────────────────────────────────────── */

.ic {
  display: block; flex: none;
  width: 24px; height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ic-s { width: 18px; height: 18px; stroke-width: 1.85; }

/* 40px plate: the icon on every card header. */
.chip {
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  background: var(--tint);
  border: var(--edge);
  border-radius: var(--r);
  box-shadow: var(--mill);
  color: var(--accent-d);
}
.chip--sm { width: 32px; height: 32px; }
.chip--lg { width: 52px; height: 52px; }
.chip--lg .ic { width: 28px; height: 28px; }

/* ── containers: four roles, no new shapes ───────────────────────────────── */

.card {
  background: var(--surface);
  border: var(--edge);
  border-radius: var(--r-lg);
  box-shadow: var(--sh), var(--mill);
  padding: 16px;
  margin-bottom: 12px;
}
.card.is-feature { background: var(--tint); box-shadow: var(--mill); }
.card.is-outline { background: none; box-shadow: none; }

.cardhead { display: flex; align-items: center; gap: 12px; }
.ht { display: flex; flex-direction: column; min-width: 0; margin-right: auto; }
.h-t { font-size: 15px; font-weight: 600; letter-spacing: -0.005em; }
.h-s { font-style: normal; font-size: 12.5px; font-weight: 450; color: var(--ink-2); margin-top: 1px; }

/* ── type ────────────────────────────────────────────────────────────────── */

/* Silkscreened panel legend: mono, small, widely tracked. */
.lbl {
  display: block;
  font-family: var(--f-display);
  font-size: 10px; font-weight: 500;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--ink-2);
  font-style: normal;
}

.bignum {
  font-family: var(--f-display);
  font-size: clamp(56px, 19vw, 70px);
  font-weight: 700;
  letter-spacing: -0.05em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  margin: 12px 0 2px;
}
.bignum--mid { font-size: 54px; margin: 6px 0 2px; }

.lede {
  margin: 2px 2px 14px;
  font-size: 14px; line-height: 1.55;
  color: var(--ink-2);
}
.note { margin: 12px 0; font-size: 13.5px; line-height: 1.5; color: var(--ink-2); }
.sub  { margin: 6px 0 0; font-size: 13.5px; color: var(--ink-2); }
.footnote {
  margin: 4px 4px 6px;
  font-size: 11.5px; line-height: 1.55;
  color: var(--ink-3);
}

/* ── tags (the shell calls them pills; here they are stamped plates) ─────── */

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--tint-2);
  color: var(--accent-d);
  border-radius: var(--r-sm);
  padding: 5px 9px;
  font-family: var(--f-display);
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase;
  white-space: nowrap;
}
.pill--rank { background: var(--surface); border: var(--edge); }
.pill--quiet { background: none; color: var(--ink-2); padding: 5px 0; }
.pill--quiet:empty { display: none; }
.pill--big { font-size: 12px; padding: 6px 12px; margin-top: 10px; }
.pill.is-done { background: rgba(52, 211, 153, .13); color: var(--good); }

/* ── gauge track ─────────────────────────────────────────────────────────── */

.track {
  height: 8px;
  background: var(--tint);
  border-radius: var(--r-sm);
  overflow: hidden;
  margin-top: 14px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .55);
}
.track .fill {
  display: block; height: 100%; width: 0;
  border-radius: var(--r-sm);
  background: var(--accent);
  box-shadow: 0 0 10px -1px var(--accent);
  transition: width var(--t), background var(--t);
}
.track .fill.is-low { background: var(--warn); box-shadow: 0 0 10px -1px var(--warn); }

.prog { display: flex; justify-content: space-between; gap: 12px; margin-top: 10px; }
.prog-n { display: flex; flex-direction: column; }
.prog-n--end { text-align: right; }
.prog-n b {
  font-family: var(--f-display);
  font-size: 20px; font-weight: 700; line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.prog-n i {
  font-style: normal; font-family: var(--f-display);
  font-size: 10px; font-weight: 500;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-2);
  margin-top: 2px;
}

/* ── buttons ─────────────────────────────────────────────────────────────── */

.btn {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  width: 100%;
  border-radius: var(--r);
  padding: 14px 16px;
  font-size: 14.5px; font-weight: 600;
  letter-spacing: -0.005em;
  text-align: left;
}
/* Ground-colour type on the instrument blue: --bg on --accent clears ~10:1.
   The fill is light, so its text is dark. */
.btn--accent {
  background: var(--accent); color: var(--bg);
  box-shadow: 0 1px 0 rgba(0, 0, 0, .4), 0 8px 20px -12px var(--accent),
              inset 0 1px 0 rgba(255, 255, 255, .35);
}
.btn--soft { background: var(--tint); color: var(--accent-d); border: var(--edge); box-shadow: var(--mill); }
.btn--outline { background: var(--surface); color: var(--ink); border: var(--edge); box-shadow: var(--mill); }
.btn:disabled { opacity: .5; }

.press { transition: transform var(--t), filter var(--t), background var(--t); }
.press:active { transform: scale(.985); filter: brightness(.88); }

.btn--play { padding: 15px 16px; margin-bottom: 12px; }
.btn-ic {
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  background: rgba(6, 15, 28, .22);
  border-radius: var(--r);
}
.btn-tx { display: flex; flex-direction: column; margin-right: auto; }
.btn-tx b {
  font-family: var(--f-display);
  font-size: 20px; font-weight: 700; line-height: 1.1;
  letter-spacing: -0.03em; text-transform: uppercase;
}
.btn-tx i { font-style: normal; font-size: 12.5px; font-weight: 500; opacity: .82; margin-top: 2px; }
.btn-ch { opacity: .65; }

.btn--ad { align-items: flex-start; text-align: left; margin-top: 10px; }
.ad-tx { display: flex; flex-direction: column; gap: 3px; }
.ad-tx b { font-size: 14px; font-weight: 600; }
.ad-tx i { font-style: normal; font-size: 11.5px; font-weight: 500; color: var(--ink-2); }
.ad-tx i:empty { display: none; }

.iconbtn {
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  background: var(--surface);
  border: var(--edge);
  border-radius: var(--r);
  box-shadow: var(--mill);
  color: var(--ink);
}

/* ── splash ──────────────────────────────────────────────────────────────── */

#splash {
  position: fixed; inset: 0; z-index: 90;
  background:
    radial-gradient(120% 46% at 50% 34%, rgba(96, 165, 250, .13), rgba(96, 165, 250, 0) 62%),
    var(--bg);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 4px;
  transition: opacity 200ms cubic-bezier(.2, .8, .3, 1);
}
#splash.out { opacity: 0; }
.sp-mark {
  width: 76px; height: 76px;
  display: grid; place-items: center;
  background: var(--tint);
  border: var(--edge);
  border-radius: var(--r-lg);
  box-shadow: var(--sh), var(--mill), 0 0 30px -10px var(--accent);
  color: var(--accent-d);
  margin-bottom: 18px;
}
.sp-mark .ic { width: 38px; height: 38px; }
.sp-name {
  font-family: var(--f-display);
  font-size: 25px; font-weight: 700;
  letter-spacing: 0.02em; text-transform: uppercase;
}
.sp-sub {
  font-family: var(--f-display);
  font-size: 10.5px; font-weight: 500;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--ink-3);
  margin-top: 4px;
}

/* ── frame ───────────────────────────────────────────────────────────────── */

#app {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  /* one soft ceiling lamp over the whole room, nothing else */
  background:
    radial-gradient(150% 40% at 50% -8%, rgba(96, 165, 250, .11), rgba(96, 165, 250, 0) 62%),
    var(--bg);
}

/* The top element carries the fullscreen top inset — the whole chrome band is
   reserved here so the brand line clears Telegram's floating Close / ⋯ row. */
.topbar {
  flex: none;
  padding-top: max(var(--tg-safe-top), env(safe-area-inset-top, 0px));
}
/* Fullscreen already reserves the chrome inset; trim a cosmetic sliver so the
   brand line does not read as a gap, floored at the inset itself. */
[data-fullscreen="1"] .topbar {
  padding-top: max(var(--tg-safe-top),
    calc(max(var(--tg-safe-top), env(safe-area-inset-top, 0px)) - 1.4vh));
}
.brandline {
  display: flex; align-items: center; gap: 9px;
  padding: 11px 16px 9px;
}
.mark {
  width: 30px; height: 30px; flex: none;
  display: grid; place-items: center;
  background: var(--tint);
  border: var(--edge);
  border-radius: var(--r);
  color: var(--accent-d);
}
.mark .ic { width: 19px; height: 19px; }
.wordmark {
  font-family: var(--f-display);
  font-size: 13.5px; font-weight: 700;
  letter-spacing: 0.05em; text-transform: uppercase;
}
/* Rank badge on the right of the brand bar. shell.js writes every
   [data-rank-badge], so this stays in sync with the home hero. */
.brand-rank {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: 5px;
  color: var(--accent-d);
  font-family: var(--f-display);
  font-size: 10.5px; font-weight: 600;
  letter-spacing: 0.09em; text-transform: uppercase;
}

/* ── bottom nav bar: the four tabs, standard mobile position ──────────────────
   A flex-column child of #app, so it pins to the bottom of the fixed viewport
   above the scrolling content. The active tab lights a strip along its top
   edge, the way a bank of machine selectors does. Pads the bottom inset. */
.navbar {
  flex: none;
  display: flex;
  padding: 0 6px;
  padding-bottom: max(var(--tg-safe-bottom), env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--mill);
}
.navtab {
  flex: 1; position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 9px 4px 8px;
  color: var(--ink-3);
  font-family: var(--f-display);
  font-size: 9.5px; font-weight: 500;
  letter-spacing: 0.13em; text-transform: uppercase;
  transition: color var(--t), background var(--t);
}
.navtab .ic { width: 22px; height: 22px; }
.navtab.is-on { color: var(--accent-d); background: var(--tint); }
.navtab.is-on::before {
  content: ""; position: absolute; top: -1px; left: 12px; right: 12px; height: 2px;
  background: var(--accent);
  box-shadow: 0 0 9px 0 var(--accent);
}

/* Play is the game and nothing else — the top brand bar and bottom nav both
   step aside so the game owns the screen. */
[data-screen="play"] .topbar,
[data-screen="play"] .navbar { display: none; }

main { flex: 1; min-height: 0; position: relative; }

.screen {
  position: absolute; inset: 0;
  display: none;
  flex-direction: column;
  overflow-y: auto;
  padding: 8px 14px 20px;
}
.screen.is-active { display: flex; }
.screen.play { overflow: hidden; padding: 4px 12px 8px; }

/* ── home (the console) ──────────────────────────────────────────────────── */

.rule { height: 1px; background: var(--line); margin: 16px 2px; }

/* Bare hero: the record as a raw counter reading, not wrapped in a card. */
.hero { margin: 8px 2px 0; }
.hero-num {
  font-family: var(--f-display);
  font-size: clamp(58px, 21vw, 82px);
  font-weight: 700; letter-spacing: -0.06em; line-height: 0.92;
  font-variant-numeric: tabular-nums;
}
.hero-meta { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.hero-meta .lbl { margin-right: auto; }
.rankline {
  display: inline-flex; align-items: center; gap: 5px;
  color: var(--accent-d);
  font-family: var(--f-display);
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.09em; text-transform: uppercase;
}

/* Stats as one inline row, thin vertical dividers between figures. */
.figrow { display: flex; margin: 0 2px; }
.fig {
  flex: 1; position: relative;
  display: flex; flex-direction: column; gap: 3px;
  padding: 0 12px;
}
.fig:first-child { padding-left: 0; }
.fig:last-child { padding-right: 0; }
.fig + .fig::before {
  content: ""; position: absolute; left: 0; top: 3px; bottom: 3px; width: 1px;
  background: var(--line);
}
.fig b {
  font-family: var(--f-display);
  font-size: 23px; font-weight: 700; line-height: 1.1;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}
.fig span {
  font-family: var(--f-display);
  font-size: 9.5px; font-weight: 500;
  letter-spacing: 0.13em; text-transform: uppercase;
  color: var(--ink-2);
}

/* Daily challenge: one slim strip — legend, state, inline gauge, reading. */
.daily { display: flex; align-items: center; gap: 10px; margin: 0 2px; }
.daily-l {
  min-width: 0; flex-shrink: 1;
  font-size: 12.5px; font-weight: 500; color: var(--ink-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.daily-state {
  flex: none;
  font-family: var(--f-display);
  font-size: 9.5px; font-weight: 500; letter-spacing: 0.13em; text-transform: uppercase;
  color: var(--ink-3);
}
.daily-state.is-done { color: var(--good); }
.daily-bar {
  flex: 1; min-width: 40px; height: 6px;
  background: var(--tint); border-radius: var(--r-sm); overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .55);
}
.daily-bar i {
  display: block; height: 100%; width: 0;
  background: var(--accent);
  transition: width var(--t), background var(--t);
}
.daily-v {
  flex: none;
  font-family: var(--f-display);
  font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums;
}

/* Boost offer: a slim inline strip, not a padded card. */
.offer-row { display: flex; align-items: center; gap: 11px; margin: 0 2px; }
.offer-tx { display: flex; flex-direction: column; margin-right: auto; min-width: 0; }
.offer-tx b { font-size: 14px; font-weight: 600; }
.offer-tx i { font-style: normal; font-size: 11.5px; font-weight: 500; color: var(--ink-2); }
.offer-tx i span:empty { display: none; }

/* ── play ────────────────────────────────────────────────────────────────── */

.hud {
  flex: none;
  display: flex; align-items: center; gap: 10px;
  padding: 4px 2px 0;
  padding-top: calc(max(var(--tg-safe-top), env(safe-area-inset-top, 0px)) + 8px);
}
.hud-score { display: flex; flex-direction: column; margin-right: auto; line-height: 1; }
.hud-score b {
  font-family: var(--f-display);
  font-size: 36px; font-weight: 700; letter-spacing: -0.055em;
  font-variant-numeric: tabular-nums;
}
.hud-score .lbl { margin-top: 5px; }

/* The in-game pause control: the player's only way out of a round, so it is a
   lit blue plate, never blended into the navy HUD. */
.hud .iconbtn {
  background: var(--tint-2);
  border-color: var(--accent);
  color: var(--accent-d);
}

.pill--combo {
  opacity: 0; transition: opacity var(--t);
  background: var(--accent); color: var(--bg);
  font-size: 14px; letter-spacing: 0;
  box-shadow: 0 0 14px -3px var(--accent);
}
.pill--combo.is-on { opacity: 1; }
.pill--shield { background: var(--tint); border: var(--edge); }

.meter { flex: none; margin: 12px 2px 10px; }
.meter .track { margin-top: 6px; }

.stagewrap {
  flex: 1; min-height: 0; position: relative;
  border: var(--edge);
  border-radius: var(--r-lg);
  box-shadow: var(--sh), var(--mill);
  background: var(--bg);
  overflow: hidden;
  margin-bottom: 6px;
}
/* Four screws holding the instrument glass into the panel. */
.stagewrap::before {
  content: ""; position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background:
    radial-gradient(circle at 11px 11px, rgba(157, 182, 208, .30) 0 1.5px, rgba(0, 0, 0, 0) 2.4px),
    radial-gradient(circle at calc(100% - 11px) 11px, rgba(157, 182, 208, .30) 0 1.5px, rgba(0, 0, 0, 0) 2.4px),
    radial-gradient(circle at 11px calc(100% - 11px), rgba(157, 182, 208, .30) 0 1.5px, rgba(0, 0, 0, 0) 2.4px),
    radial-gradient(circle at calc(100% - 11px) calc(100% - 11px), rgba(157, 182, 208, .30) 0 1.5px, rgba(0, 0, 0, 0) 2.4px);
}
#stage {
  display: block; width: 100%; height: 100%;
  touch-action: none;
  user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none;   /* a HOLD game cannot afford the iOS callout */
}

.startover {
  position: absolute; inset: 0; z-index: 3;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 18px;
  overflow-y: auto;
}
.start-in { width: 100%; max-width: 320px; text-align: left; }
.start-in .chip--lg { margin: 0 auto 12px; }
.start-t {
  display: block; text-align: center;
  font-family: var(--f-display);
  font-size: 20px; font-weight: 700;
  letter-spacing: 0.02em; text-transform: uppercase;
  margin-bottom: 16px;
}
.steps { list-style: none; margin: 0 0 18px; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.step {
  display: flex; align-items: center; gap: 10px;
  border: var(--edge);
  border-radius: var(--r);
  background: var(--tint);
  box-shadow: var(--mill);
  padding: 10px 12px;
}
.step-n {
  width: 22px; height: 22px; flex: none;
  display: grid; place-items: center;
  border-radius: var(--r-sm);
  background: var(--accent);
  color: var(--bg);
  font-family: var(--f-display);
  font-size: 12px; font-weight: 700;
}
.step-tx { display: flex; flex-direction: column; min-width: 0; }
.step-tx b { font-size: 14px; font-weight: 600; }
.step-tx i { font-style: normal; font-size: 12.5px; color: var(--ink-2); line-height: 1.35; margin-top: 1px; }

/* ── rank ────────────────────────────────────────────────────────────────── */

/* A bank of two selectors, not a soft segmented pill. */
.seg {
  display: flex; gap: 4px;
  background: var(--tint);
  border: var(--edge);
  border-radius: var(--r);
  padding: 4px;
  margin: 4px 0 14px;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, .5);
}
.seg-btn {
  flex: 1; position: relative;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 8px;
  border-radius: var(--r-sm);
  font-family: var(--f-display);
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--ink-2);
  transition: background var(--t), color var(--t);
}
.seg-btn.is-on { background: var(--surface); color: var(--accent-d); box-shadow: var(--mill), 0 1px 0 rgba(0, 0, 0, .4); }

.board { display: flex; flex-direction: column; margin-top: 6px; }
.rw {
  position: relative;
  display: flex; align-items: center; gap: 11px;
  padding: 10px 4px;
  border-radius: var(--r);
}
/* The divider is a pseudo-element, not a border-top: a 1px border on a rounded
   box curves up at both ends and reads as a wobble. */
.rw + .rw::before, .row + .row::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 1px;
  background: var(--line);
}
.rw--me::before, .rw--me + .rw::before { display: none; }
.rw-pos {
  min-width: 22px;
  font-family: var(--f-display);
  font-size: 12px; font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink-3);
  text-align: center;
}
.rw-av {
  width: 32px; height: 32px; flex: none;
  display: grid; place-items: center;
  border-radius: var(--r-sm);
  /* shell.js hands each name a hue; keep it quiet so the blue stays the one
     loud colour on the screen. Dark plate, light glyph. */
  background: hsl(var(--h) 24% 19%);
  color: hsl(var(--h) 42% 70%);
  font-family: var(--f-display);
  font-size: 13px; font-weight: 600;
}
.rw-nm { flex: 1; font-size: 14.5px; font-weight: 500; letter-spacing: -0.005em; }
.rw-sc {
  font-family: var(--f-display);
  font-size: 16px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}
.rw--top .rw-pos { color: var(--accent-d); }
.rw--me {
  background: var(--tint);
  border: var(--edge);
  padding-left: 8px; padding-right: 8px;
  margin: 4px 0;
}
.rw--me + .rw, .rw--me { border-top-color: transparent; }
.rw--me .rw-nm { font-weight: 600; }
.rw--me .rw-sc { color: var(--accent-d); }

/* ── more ────────────────────────────────────────────────────────────────── */

.rows { margin-top: 6px; }
.card > .rows:first-child { margin-top: 0; }
.card.is-outline { padding: 6px 16px; }
.row {
  position: relative;
  display: flex; width: 100%; align-items: center; gap: 12px;
  padding: 13px 2px;
  font-size: 14.5px; font-weight: 500; text-align: left;
  color: var(--ink);
  border-radius: var(--r);
}
.row > span { flex: 1; min-width: 0; }
.row > .ic { color: var(--accent-d); }
.rowbtn { transition: background var(--t); }
.rowbtn:active { background: var(--tint); }
.chev { width: 18px; height: 18px; color: var(--ink-3); }
.row.is-danger, .row.is-danger > .ic, .row.is-danger .chev { color: var(--warn); }

/* An industrial rocker, square in its travel. */
.sw {
  appearance: none; -webkit-appearance: none;
  width: 46px; height: 26px; flex: none;
  background: var(--tint-2);
  border: var(--edge);
  border-radius: var(--r-sm);
  position: relative; margin: 0;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, .55);
  transition: background var(--t), border-color var(--t);
}
.sw::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 20px; height: 20px;
  background: linear-gradient(180deg, #C9D8E8, #7F97AF);
  border-radius: 2px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .55);
  transition: transform var(--t);
}
.sw:checked { background: var(--accent); border-color: var(--accent); }
.sw:checked::after { transform: translateX(20px); }

/* ── section header ──────────────────────────────────────────────────────── */

.sect-h {
  font-family: var(--f-display);
  font-size: 10px; font-weight: 500;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--ink-3);
  margin: 4px 2px 8px;
}
.screen[data-screen="more"] .sect-h:not(:first-child) { margin-top: 4px; }
.board { margin-top: 2px; }

.btn--sq { width: auto; flex: none; border-radius: var(--r-sm); padding: 9px 12px; font-size: 12px; gap: 6px; }

/* ── primary action: in-content Play button ───────────────────────────────────
   A normal button in the Home flow (not a fixed bar), so it never collides
   with the bottom nav. Full-width blue, label left, arrow right. */
.playcta {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  margin: 16px 2px 0;
  background: var(--accent); color: var(--bg);
  padding: 15px 18px;
  border-radius: var(--r);
  box-shadow: 0 1px 0 rgba(0, 0, 0, .4), 0 10px 26px -14px var(--accent),
              inset 0 1px 0 rgba(255, 255, 255, .35);
}
.playcta-tx { display: flex; flex-direction: column; margin-right: auto; text-align: left; line-height: 1.15; }
.playcta-tx b {
  font-family: var(--f-display);
  font-size: 19px; font-weight: 700;
  letter-spacing: 0.02em; text-transform: uppercase;
}
.playcta-tx i { font-style: normal; font-size: 12px; font-weight: 500; opacity: .8; margin-top: 2px; }
.playcta-ar { width: 24px; height: 24px; opacity: .8; }

/* ── overlays ────────────────────────────────────────────────────────────── */

.scrim { position: fixed; inset: 0; z-index: 40; background: rgba(2, 7, 14, .74); }

.sheet {
  position: fixed; z-index: 50;
  left: 10px; right: 10px;
  bottom: calc(10px + max(var(--tg-safe-bottom), env(safe-area-inset-bottom, 0px)));
  background: var(--surface);
  border: var(--edge);
  border-radius: var(--r-lg);
  box-shadow: var(--sh), var(--mill);
  display: flex; flex-direction: column;
  max-height: calc(100dvh - max(var(--tg-safe-top), env(safe-area-inset-top, 0px)) - 24px);
  /* Deliberately NOT animated. A sheet that slides in from below sits, for the
     length of the animation, with its own Close button under the fold — and if
     a client throttles animations it stays there. The sheet just appears. */
}
.sheet-head {
  flex: none;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--line);
}
.sheet-head b {
  flex: 1; min-width: 0;
  font-family: var(--f-display);
  font-size: 16px; font-weight: 700;
  letter-spacing: 0.02em; text-transform: uppercase;
}
.sheet-body {
  flex: 1; min-height: 0;
  overflow-y: auto;
  padding: 14px 16px 4px;
  font-size: 14px; line-height: 1.6;
  color: var(--ink-2);
}
.sheet-body p { margin: 0 0 12px; }
.sheet-body ul { margin: 0 0 12px; padding-left: 0; list-style: none; }
.sheet-body li { position: relative; padding-left: 20px; margin-bottom: 10px; }
.sheet-body li::before {
  content: ""; position: absolute; left: 2px; top: 9px;
  width: 7px; height: 7px;
  background: var(--accent);
  border-radius: 1px;
}
.sheet-body b { font-weight: 600; color: var(--ink); }
.sheet-foot { flex: none; padding: 12px 16px 16px; border-top: 1px solid var(--line); }

.modal {
  position: fixed; inset: 0; z-index: 55;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  pointer-events: none;
}
.modal-card {
  pointer-events: auto;
  width: 100%; max-width: 330px;
  background: var(--surface);
  border: var(--edge);
  border-radius: var(--r-lg);
  box-shadow: var(--sh), var(--mill);
  padding: 20px 18px;
  text-align: center;
  animation: rise 180ms cubic-bezier(.2, .8, .3, 1);
}
@keyframes rise { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-card .chip--lg { margin: 0 auto 4px; }
.modal-card .btn { justify-content: center; }
.modal-t {
  display: block;
  font-family: var(--f-display);
  font-size: 19px; font-weight: 700;
  letter-spacing: 0.02em; text-transform: uppercase;
  margin-top: 10px;
}
.modal-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.modal-btns .btn { padding: 13px 10px; font-size: 13.5px; gap: 7px; }
.modal-btns .ic { width: 19px; height: 19px; }

/* The continue countdown: a readout plate, not a bubble. */
.revive {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center;
  pointer-events: none;
}
.revive span {
  display: grid; place-items: center;
  width: 124px; height: 124px;
  background: var(--tint);
  border: var(--edge);
  border-radius: var(--r-lg);
  box-shadow: var(--sh), var(--mill), 0 0 40px -14px var(--accent);
  font-family: var(--f-display);
  font-size: 62px; font-weight: 700; color: var(--accent-d);
  font-variant-numeric: tabular-nums;
  animation: pop 180ms cubic-bezier(.2, .8, .3, 1);
}
@keyframes pop { from { transform: scale(.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.toast {
  position: fixed; z-index: 70;
  left: 16px; right: 16px;
  bottom: calc(96px + max(var(--tg-safe-bottom), env(safe-area-inset-bottom, 0px)));
  background: var(--surface);
  border: var(--edge);
  border-radius: var(--r);
  box-shadow: var(--sh), var(--mill);
  padding: 13px 18px;
  font-size: 13.5px; font-weight: 500;
  text-align: center;
}

/* ── reduce motion: kill all of it ───────────────────────────────────────── */

[data-reduce-motion="1"] *,
[data-reduce-motion="1"] *::before,
[data-reduce-motion="1"] *::after {
  animation: none !important;
  transition: none !important;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* Short phones: the big readouts and the start panel give first. */
@media (max-height: 690px) {
  .bignum { font-size: 50px; }
  .btn-tx b { font-size: 18px; }
  .lede { margin-bottom: 10px; }
  .step { padding: 8px 10px; }
  .start-t { margin-bottom: 12px; }
  .hud-score b { font-size: 32px; }
}
