/* ═══════════════════════════════════════════════════════════════════════════
   RATCHET LINE — MACHINE ROOM · PLUM · SQUARE

   One idea, held everywhere: this is a control panel in a dark plum machine
   room with a single hot pink lamp over it. Steel plates, hairline rules,
   engraved mono labels, hazard stripes where something can hurt you.

   Rules this sheet keeps, without exception:
     · Nothing is round. Radius is 3px (controls) or 5px (plates). Pills are
       square tags. The only circle in the product is the ratchet wheel.
     · Buttons are key caps: a 2px hard bottom edge, pressed down 2px on tap.
       No soft shadows, no glow on interface, no glass.
     · Every number and every micro label is IBM Plex Mono, tabular, uppercase
       at 0.16em. Prose is IBM Plex Sans. Headlines are Archivo, expanded.
     · Pink is a fill or a lamp. Small pink TEXT is --accent-d. On pink FILLS,
       text is --bg. Amber (--warn) means only one thing: this can break.
     · Motion is 130ms cubic-bezier(.2,.9,.25,1). Machines move fast and stop
       hard, so nothing floats and nothing bounces.
   ═══════════════════════════════════════════════════════════════════════════ */

: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:       #1A0812;
  --surface:  #25101B;
  --tint:     #331526;
  --tint-2:   #431B30;
  --line:     #53243B;
  --ink:      #F8E9F0;
  --ink-2:    #C8A4B5;
  --ink-3:    #9B7387;
  --accent:   #F472B6;
  --accent-d: #F9A8D4;
  --good:     #3FD9A0;
  --warn:     #FFA53D;

  /* The pressed edge under every key cap: the accent, driven into shadow. */
  --accent-e: #8E2D62;

  --f-display: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --f-text: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --r: 3px;           /* controls: buttons, chips, tags */
  --r-lg: 5px;        /* plates: panels, sheets, the stage */
  --edge: 1px solid var(--line);
  --t: 130ms cubic-bezier(.2, .9, .25, 1);

  /* Hazard stripes. Used only where something can actually break. */
  --hazard: repeating-linear-gradient(135deg,
    rgba(255, 165, 61, .16) 0 5px, transparent 5px 11px);
  /* Engraved plate: a 1px light line along the top of a dark panel. */
  --engrave: inset 0 1px 0 rgba(255, 255, 255, .045);
}

*, *::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: 400;
  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 ───────────────────────────────────────────────────────────────────
   Square caps and square joins. Rounded strokes read soft; this room is not. */

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

/* 38px tinted chip: the icon on every panel header. Square, engraved. */
.chip {
  width: 38px; height: 38px; flex: none;
  display: grid; place-items: center;
  background: var(--tint);
  border: var(--edge);
  border-radius: var(--r);
  box-shadow: var(--engrave);
  color: var(--accent-d);
}
.chip--sm { width: 30px; height: 30px; }
.chip--lg { width: 50px; height: 50px; }
.chip--lg .ic { width: 26px; height: 26px; }

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

/* The engraved label under every readout. */
.lbl {
  display: block;
  font-family: var(--f-mono);
  font-size: 9.5px; font-weight: 500;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--ink-3);
  font-style: normal;
}

.bignum {
  font-family: var(--f-mono);
  font-size: clamp(54px, 18vw, 66px);
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  margin: 10px 0 6px;
}
.bignum--mid { font-size: 52px; margin: 6px 0 6px; }

.lede {
  margin: 6px 0 16px;
  font-size: 14px; line-height: 1.5;
  color: var(--ink-2);
}
.sub  { margin: 6px 0 0; font-size: 13px; color: var(--ink-2); }
.footnote {
  margin: 6px 0;
  font-size: 11.5px; line-height: 1.5;
  color: var(--ink-3);
}

/* ── tags (square, never lozenges) ───────────────────────────────────────── */

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--tint-2);
  border: var(--edge);
  border-radius: 2px;
  color: var(--accent-d);
  padding: 4px 8px;
  font-family: var(--f-mono);
  font-size: 10.5px; font-weight: 600;
  letter-spacing: 0.10em; text-transform: uppercase;
  white-space: nowrap;
}
.pill--big { font-size: 11px; padding: 5px 10px; margin-top: 10px; }
.pill.is-done { background: rgba(63, 217, 160, .12); border-color: rgba(63, 217, 160, .34); color: var(--good); }

/* ── tracks ──────────────────────────────────────────────────────────────── */

.track {
  height: 8px;
  background: var(--tint);
  border: var(--edge);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 8px;
}
.track .fill {
  display: block; height: 100%; width: 0;
  background: var(--accent);
  transition: width var(--t), background var(--t);
}
.track .fill.is-low { background: var(--warn); }

/* ── buttons: key caps ───────────────────────────────────────────────────────
   Every control sits on a 2px hard edge and is driven down onto it when
   pressed. That is the entire interaction language of this build. */

.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  border-radius: var(--r);
  padding: 13px 16px;
  font-size: 14px; font-weight: 600;
  letter-spacing: 0.005em;
  text-align: left;
}
.btn--accent {
  background: var(--accent); color: var(--bg);
  box-shadow: 0 2px 0 var(--accent-e);
}
.btn--soft {
  background: var(--tint); color: var(--accent-d);
  border: var(--edge); box-shadow: 0 2px 0 #14060E;
}
.btn--outline {
  background: var(--surface); color: var(--ink);
  border: var(--edge); box-shadow: 0 2px 0 #14060E;
}
.btn:disabled { opacity: .45; }

.press { transition: transform var(--t), box-shadow var(--t), background var(--t); }
.press:active { transform: translateY(2px); box-shadow: none; }

.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: 13.5px; font-weight: 600; }
.ad-tx i { font-style: normal; font-size: 11px; color: var(--ink-2); }
.ad-tx i:empty { display: none; }

.iconbtn {
  width: 38px; height: 38px; flex: none;
  display: grid; place-items: center;
  background: var(--surface);
  border: var(--edge);
  border-radius: var(--r);
  box-shadow: 0 2px 0 #14060E;
  color: var(--ink);
}

/* Squared compact button, for inline strips. */
.btn--sq {
  width: auto; flex: none;
  padding: 8px 11px;
  font-family: var(--f-mono);
  font-size: 10.5px; letter-spacing: 0.10em; text-transform: uppercase;
  gap: 6px;
}

/* ── splash: one orchestrated entrance, then never again ─────────────────── */

#splash {
  position: fixed; inset: 0; z-index: 90;
  background: var(--bg);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 6px;
  transition: opacity 200ms cubic-bezier(.2, .9, .25, 1);
}
#splash.out { opacity: 0; }
#splash::before {
  /* the lamp over the room */
  content: ""; position: absolute; left: 50%; top: 18%;
  width: 320px; height: 320px; margin: -160px 0 0 -160px;
  background: radial-gradient(circle, rgba(244, 114, 182, .20), transparent 68%);
  pointer-events: none;
}
.sp-mark, .sp-name, .sp-sub {
  position: relative;
  animation: lift 420ms cubic-bezier(.2, .9, .25, 1) both;
}
.sp-mark {
  width: 66px; height: 66px;
  display: grid; place-items: center;
  background: var(--tint);
  border: 1px solid var(--accent);
  border-radius: var(--r-lg);
  box-shadow: var(--engrave);
  color: var(--accent);
  margin-bottom: 14px;
}
.sp-mark .ic { width: 34px; height: 34px; }
.sp-name {
  font-family: var(--f-display);
  font-size: 27px; font-weight: 800;
  font-stretch: 122%;
  letter-spacing: 0.10em; text-transform: uppercase;
  animation-delay: 70ms;
}
.sp-sub {
  font-family: var(--f-mono);
  font-size: 10.5px; font-weight: 500;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--ink-3);
  animation-delay: 140ms;
}
@keyframes lift { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

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

#app {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  background: var(--bg);
}
/* The emergency lamp, fixed over the whole room. One ambient element, no
   animation: it is light, not a feature. */
#app::before {
  content: ""; position: fixed; inset: 0; z-index: 0;
  background:
    radial-gradient(120% 42% at 50% -6%, rgba(244, 114, 182, .13), transparent 70%),
    radial-gradient(90% 30% at 50% 104%, rgba(244, 114, 182, .07), transparent 70%);
  pointer-events: none;
}
#app > * { position: relative; z-index: 1; }

/* The top element carries the fullscreen top inset, 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));
  border-bottom: var(--edge);
  background: var(--surface);
  box-shadow: var(--engrave);
}
[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: 9px 14px;
}
.mark {
  width: 26px; height: 26px; flex: none;
  display: grid; place-items: center;
  background: var(--tint);
  border: 1px solid var(--line);
  border-radius: 2px;
  color: var(--accent);
}
.mark .ic { width: 17px; height: 17px; }
.wordmark {
  font-family: var(--f-display);
  font-size: 15px; font-weight: 800;
  font-stretch: 120%;
  letter-spacing: 0.10em; text-transform: uppercase;
}
.brand-rank {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: 5px;
  color: var(--accent-d);
  font-family: var(--f-mono);
  font-size: 10px; font-weight: 500;
  letter-spacing: 0.10em; text-transform: uppercase;
}

/* ── bottom nav: four square tabs on a steel rail ────────────────────────── */

.navbar {
  flex: none;
  display: flex; gap: 4px;
  padding: 5px 6px;
  padding-bottom: calc(5px + max(var(--tg-safe-bottom), env(safe-area-inset-bottom, 0px)));
  border-top: var(--edge);
  background: var(--surface);
  box-shadow: var(--engrave);
}
.navtab {
  flex: 1; position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 7px 4px 6px;
  border-radius: var(--r);
  border-top: 2px solid transparent;
  color: var(--ink-3);
  font-family: var(--f-mono);
  font-size: 9px; font-weight: 500;
  letter-spacing: 0.13em; text-transform: uppercase;
  transition: color var(--t), background var(--t), border-color var(--t);
}
.navtab .ic { width: 21px; height: 21px; }
.navtab.is-on { color: var(--accent); background: var(--tint); border-top-color: var(--accent); }

/* Play is the game and nothing else. */
[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: 14px 14px 20px;
}
.screen.is-active { display: flex; }
.screen.play { overflow: hidden; padding: 2px 10px 8px; }

/* ── home: the console readout ───────────────────────────────────────────── */

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

/* The record, engraved into a steel plate with a hazard strip down one side. */
.hero {
  position: relative;
  background: var(--surface);
  border: var(--edge);
  border-radius: var(--r-lg);
  box-shadow: var(--engrave);
  padding: 14px 16px 13px 20px;
  overflow: hidden;
}
.hero::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 6px;
  background: var(--accent);
}
.hero-num {
  font-family: var(--f-mono);
  font-size: clamp(50px, 17vw, 68px);
  font-weight: 700; letter-spacing: -0.03em; line-height: 0.95;
  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-mono);
  font-size: 10px; font-weight: 500;
  letter-spacing: 0.10em; text-transform: uppercase;
}

/* Primary action: the big key cap. Label left, arrow right. */
.playcta {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  margin-top: 14px;
  background: var(--accent); color: var(--bg);
  padding: 14px 16px;
  border-radius: var(--r);
  box-shadow: 0 3px 0 var(--accent-e);
}
.playcta:active { transform: translateY(3px); box-shadow: none; }
.playcta-tx { display: flex; flex-direction: column; margin-right: auto; text-align: left; }
.playcta-tx b {
  font-family: var(--f-display);
  font-size: 19px; font-weight: 800; font-stretch: 118%;
  letter-spacing: 0.08em; text-transform: uppercase; line-height: 1.1;
}
.playcta-tx i {
  font-family: var(--f-mono);
  font-style: normal; font-size: 10px; font-weight: 500;
  letter-spacing: 0.10em; text-transform: uppercase;
  opacity: .78; margin-top: 3px;
}
.playcta-ar { width: 22px; height: 22px; opacity: .75; }

/* Figures in one row, hairline dividers between. */
.figrow { display: flex; }
.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: 2px; bottom: 2px; width: 1px;
  background: var(--line);
}
.fig b {
  font-family: var(--f-mono);
  font-size: 21px; font-weight: 600; line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.fig span {
  font-family: var(--f-mono);
  font-size: 9px; font-weight: 500;
  letter-spacing: 0.13em; text-transform: uppercase;
  color: var(--ink-3);
}

/* Daily challenge: one slim strip. */
.daily { display: flex; align-items: center; gap: 10px; }
.daily-l {
  min-width: 0; flex-shrink: 1;
  font-size: 12.5px; color: var(--ink-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.daily-state {
  flex: none;
  font-family: var(--f-mono);
  font-size: 9px; 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: 36px; height: 6px;
  background: var(--tint); border: var(--edge); border-radius: 2px; overflow: hidden;
}
.daily-bar i {
  display: block; height: 100%; width: 0;
  background: var(--accent);
  transition: width var(--t);
}
.daily-v {
  flex: none;
  font-family: var(--f-mono);
  font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums;
}

/* Rewarded offer: a hazard-striped strip, because it leaves the app. */
.offer-row {
  display: flex; align-items: center; gap: 11px;
  padding: 10px;
  border: var(--edge); border-radius: var(--r);
  background-image: var(--hazard);
}
.offer-tx { display: flex; flex-direction: column; margin-right: auto; min-width: 0; }
.offer-tx b { font-size: 13.5px; font-weight: 600; }
.offer-tx i { font-style: normal; font-size: 11px; color: var(--ink-2); }
.offer-tx i span:empty { display: none; }

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

.hud {
  flex: none;
  display: flex; align-items: center; gap: 8px;
  padding: 2px 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-mono);
  font-size: 34px; font-weight: 700; letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.hud-score .lbl { margin-top: 5px; }

.hud .iconbtn {
  width: 34px; height: 34px;
  background: var(--tint-2);
  border-color: var(--accent);
  color: var(--accent);
}
.hud .iconbtn .ic { width: 19px; height: 19px; }

.pill--combo {
  opacity: 0; transition: opacity var(--t);
  background: var(--accent); border-color: var(--accent); color: var(--bg);
  font-size: 12px; letter-spacing: 0.04em;
}
.pill--combo.is-on { opacity: 1; }
.pill--shield { background: var(--tint); }

/* The chain-hold readout: mirrors the gauge painted on the stage, so the
   number and the machine can never disagree. */
.meter { flex: none; margin: 10px 2px 8px; }

.stagewrap {
  flex: 1; min-height: 0; position: relative;
  border: var(--edge);
  border-radius: var(--r-lg);
  background: var(--bg);
  box-shadow: var(--engrave);
  overflow: hidden;
  margin-bottom: 4px;
}
#stage { display: block; width: 100%; height: 100%; touch-action: none; }

.startover {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface);
  padding: 16px;
  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: 19px; font-weight: 800; font-stretch: 118%;
  letter-spacing: 0.10em; text-transform: uppercase;
  margin-bottom: 16px;
}
.steps { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.step {
  display: flex; align-items: center; gap: 10px;
  border: var(--edge);
  border-radius: var(--r);
  background: var(--bg);
  padding: 9px 11px;
}
.step-n {
  width: 20px; height: 20px; flex: none;
  display: grid; place-items: center;
  border-radius: 2px;
  background: var(--accent);
  color: var(--bg);
  font-family: var(--f-mono);
  font-size: 11px; font-weight: 700;
}
.step-tx { display: flex; flex-direction: column; min-width: 0; }
.step-tx b { font-size: 13.5px; font-weight: 600; }
.step-tx i { font-style: normal; font-size: 12px; color: var(--ink-2); line-height: 1.35; margin-top: 1px; }

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

.seg {
  display: flex; gap: 4px;
  background: var(--tint);
  border: var(--edge);
  border-radius: var(--r);
  padding: 3px;
  margin: 0 0 14px;
}
.seg-btn {
  flex: 1;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px;
  border-radius: 2px;
  font-family: var(--f-mono);
  font-size: 10.5px; font-weight: 500;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink-3);
  transition: background var(--t), color var(--t);
}
.seg-btn.is-on { background: var(--surface); color: var(--accent-d); box-shadow: var(--engrave); }

.board { display: flex; flex-direction: column; }
.rw {
  position: relative;
  display: flex; align-items: center; gap: 11px;
  padding: 9px 4px;
}
.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-mono);
  font-size: 12px; font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--ink-3);
  text-align: center;
}
.rw-av {
  width: 28px; height: 28px; flex: none;
  display: grid; place-items: center;
  border-radius: 2px;
  /* shell.js hands each name a hue; keep it quiet so the pink stays the one
     loud colour on the screen. */
  background: hsl(var(--h) 22% 18%);
  color: hsl(var(--h) 40% 70%);
  font-family: var(--f-mono);
  font-size: 12px; font-weight: 600;
}
.rw-nm { flex: 1; font-size: 14px; font-weight: 500; }
.rw-sc {
  font-family: var(--f-mono);
  font-size: 15px; font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.rw--top .rw-pos { color: var(--accent); }
.rw--me {
  background: var(--tint);
  border-left: 3px solid var(--accent);
  padding-left: 6px; padding-right: 6px;
  margin: 3px 0;
}
.rw--me .rw-nm { font-weight: 600; }
.rw--me .rw-sc { color: var(--accent-d); }

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

.rows { margin-top: 2px; }
.row {
  position: relative;
  display: flex; width: 100%; align-items: center; gap: 12px;
  padding: 12px 2px;
  font-size: 14px; font-weight: 500; text-align: left;
  color: var(--ink);
}
.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: 16px; height: 16px; color: var(--ink-3); }

/* Industrial toggle: a square knob in a square slot. */
.sw {
  appearance: none; -webkit-appearance: none;
  width: 46px; height: 24px; flex: none;
  background: var(--tint-2);
  border: var(--edge);
  border-radius: 2px;
  position: relative; margin: 0;
  transition: background var(--t), border-color var(--t);
}
.sw::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px;
  background: var(--ink-3);
  border-radius: 1px;
  transition: transform var(--t), background var(--t);
}
.sw:checked { background: rgba(244, 114, 182, .22); border-color: var(--accent); }
.sw:checked::after { transform: translateX(22px); background: var(--accent); }

/* Section header: an engraved label with an accent tab driven into its left. */
.sect-h {
  position: relative;
  font-family: var(--f-mono);
  font-size: 9.5px; font-weight: 500;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--ink-3);
  padding-left: 10px;
  margin: 2px 0 8px;
}
.sect-h::before {
  content: ""; position: absolute; left: 0; top: 2px; bottom: 2px; width: 3px;
  background: var(--accent);
}
.screen[data-screen="rank"] .sect-h { margin-top: 4px; }

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

.scrim { position: fixed; inset: 0; z-index: 40; background: rgba(9, 3, 6, .74); }

.sheet {
  position: fixed; z-index: 50;
  left: 8px; right: 8px;
  bottom: calc(8px + 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(--engrave), 0 -8px 40px -20px #000;
  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. */
}
.sheet-head {
  flex: none;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 12px 11px;
  border-bottom: var(--edge);
}
.sheet-head b {
  flex: 1; min-width: 0;
  font-family: var(--f-display);
  font-size: 16px; font-weight: 800; font-stretch: 116%;
  letter-spacing: 0.08em; text-transform: uppercase;
}
.sheet-body {
  flex: 1; min-height: 0;
  overflow-y: auto;
  padding: 14px 16px 4px;
  font-size: 13.5px; line-height: 1.55;
  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: 18px; margin-bottom: 10px; }
.sheet-body li::before {
  content: ""; position: absolute; left: 0; top: 8px;
  width: 7px; height: 7px;
  background: var(--accent);
}
.sheet-body b { font-weight: 600; color: var(--ink); }
.sheet-foot { flex: none; padding: 12px 16px 16px; border-top: var(--edge); }

.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: 328px;
  background: var(--surface);
  border: var(--edge);
  border-top: 3px solid var(--accent);
  border-radius: var(--r-lg);
  box-shadow: var(--engrave), 0 20px 60px -30px #000;
  padding: 18px 16px;
  text-align: center;
  animation: slam 160ms cubic-bezier(.2, .9, .25, 1);
}
/* Machines do not float in. This lands. */
@keyframes slam { from { transform: translateY(-8px) scale(.99); opacity: 0; } to { transform: none; 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: 18px; font-weight: 800; font-stretch: 116%;
  letter-spacing: 0.08em; text-transform: uppercase;
  margin-top: 10px;
}
.modal-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.modal-btns .btn { padding: 12px 8px; font-size: 13px; gap: 6px; }
.modal-btns .ic { width: 18px; height: 18px; }

.revive {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center;
  pointer-events: none;
}
.revive span {
  display: grid; place-items: center;
  width: 118px; height: 118px;
  background: var(--tint);
  border: 1px solid var(--accent);
  border-radius: var(--r-lg);
  font-family: var(--f-mono);
  font-size: 60px; font-weight: 700; color: var(--accent);
  animation: slam 160ms cubic-bezier(.2, .9, .25, 1);
}

.toast {
  position: fixed; z-index: 70;
  left: 14px; right: 14px;
  bottom: calc(92px + max(var(--tg-safe-bottom), env(safe-area-inset-bottom, 0px)));
  background: var(--surface);
  border: var(--edge);
  border-left: 3px solid var(--accent);
  border-radius: var(--r);
  padding: 12px 14px;
  font-family: var(--f-mono);
  font-size: 11px; letter-spacing: 0.10em; text-transform: uppercase;
  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 readouts give first, the stage never does. */
@media (max-height: 690px) {
  .hero-num { font-size: 46px; }
  .bignum { font-size: 46px; }
  .lede { margin-bottom: 12px; }
  .step { padding: 7px 10px; }
  .hud-score b { font-size: 28px; }
}
