/* ============================================================
   FIFTEEN MINUTES — Florence-inspired design system
   Cream paper, navy ink, chrome yellow, watercolour pastels.
   Comic panels, typewriter eyebrows, bold lowercase slab titles,
   yellow speech bubbles, polaroids, round soft buttons.
   ============================================================ */

:root {
  /* Florence palette */
  --paper:      #FFFDF6;   /* card / panel */
  --cream:      #FAF3E1;
  --ink:        #2C3663;   /* navy ink — lines & text */
  --ink-2:      #646C96;   /* muted navy (kept readable) */
  --hairline:   #E6DFC9;
  --yellow:     #FFD91F;   /* chrome yellow */
  --yellow-soft:#FFF1B0;
  --red:        #E23B2E;   /* needle / alarm */
  --coral:      #F2907B;
  --salmon:     #F7C2AE;
  --teal:       #7FC4B2;
  --teal-pale:  #CDE8E0;
  --blue:       #7CC3E8;   /* Florence blue */
  --blue-pale:  #D3EAF5;
  --sage:       #BCD8A5;
  --sage-pale:  #E2EED2;
  --plum:       #A87CA0;
  --blush:      #F6D8C0;   /* skin */
  --grey-wash:  #DDE2E7;   /* duotone wash */
  --grey-deep:  #97A2B6;

  /* stage-tinted (overridden per chapter) */
  --page:  #FFD91F;        /* page behind the card */
  --wash:  #FFF3C2;        /* big soft washes inside plates */
  --acc:   #F2907B;        /* stage accent used by the art */

  /* legacy aliases still used by engine/art */
  --paper-2: var(--cream);
  --accent:  var(--red);
  --accent-2:var(--yellow);
  --sea:     var(--blue);
  --sky:     var(--paper);
  --sun:     var(--yellow);
  --hill:    var(--sage);
  --good:    #4E9B6E;
  --bad:     #C74334;

  /* ---- type system: two families, one weight scale ----
     A display serif for headings and stamps, a sans for everything else.
     The old monospace and script faces are aliased onto these two so
     every existing rule keeps working while the page renders in two
     families. Label voice now comes from case and tracking, not a
     third typeface. */
  --font-display: "Bree Serif", "Georgia", serif;
  --font-ui:      "Quicksand", "Avenir Next", system-ui, sans-serif;
  --font-title:   var(--font-display);
  --font-body:    var(--font-ui);
  --font-type:    var(--font-ui);      /* was Courier Prime */
  --font-hand:    var(--font-display); /* was Caveat        */

  /* one weight scale — Quicksand carries 400/500/600/700, Bree Serif 400 */
  --w-body: 400;
  --w-med:  500;
  --w-label:600;
  --w-bold: 700;
}

/* Every label that used the typewriter face keeps its role through case
   and tracking instead of a separate family. */
.title-kicker, .sel-eyebrow, .haz-when, .haz-done, .end-stamp, .cb-head,
.hud-obj, .radar-tag, .shop-purse, .lb-cap b, .mp-lock,
.map-caption, .map-progress, .sel-back,
#rotate-gate .rg-sub, .mg-hint, .mg-rule, .jstat .js-k {
  font-family: var(--font-ui);
  font-weight: var(--w-label);
  letter-spacing: .1em;
}

/* ---- chapter moods (page + wash + accent) ------------------ */
body[data-stage="title"]   { --page:#FFD91F; --wash:#FFF3C2; --acc:#F2907B; }
body[data-stage="prep"]    { --page:#FFE694; --wash:#FFF3C2; --acc:#F2907B; }
body[data-stage="t0"]      { --page:#D8DFDA; --wash:#E3E9E4; --acc:#E23B2E;
                             --sea:#9FB6BC; --sage:#C4CFC0; --blue-pale:#DCE5E2; }
body[data-stage="move"]    { --page:#FBD9A8; --wash:#FDEBCB; --acc:#E2652E;
                             --sea:#8FB9C9; }
body[data-stage="wave"]    { --page:#46557B; --wash:#D6DDE8; --acc:#E23B2E;
                             --sea:#5B7DA8; --sage:#AFC0C8; --blue-pale:#C5D3E2;
                             --yellow:#FFD91F; }
body[data-stage="post"]    { --page:#CFD3DE; --wash:#E4E6EC; --acc:#B8763B;
                             --sea:#98AFC4; --sage:#C3CCC0; }
body[data-stage="epilogue"]{ --page:#FFE694; --wash:#FFF3C2; --acc:#F2907B; }

* { margin: 0; padding: 0; box-sizing: border-box; }

/* Mobile WebKit and Chrome inflate the text of block containers they judge
   to be wide columns, and leave short ones alone. That is why a long survey
   option printed larger than a short one on a real phone while Chrome's
   device emulation — which does not run the autosizer — showed them equal.
   Pinning the adjustment to 100% keeps every size the one written here. */
html {
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html, body { height: 100%; }

body {
  background: var(--page);
  color: var(--ink);
  font-family: var(--font-ui);
  transition: background 1.2s ease;
  display: flex;
  justify-content: center;
  -webkit-font-smoothing: antialiased;
}

#frame {
  width: 100%;
  max-width: 560px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
}

/* ============================================================
   HUD — navy ink floating on the pastel page
   ============================================================ */
#hud {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "left clock" "meters meters";
  align-items: center;
  gap: 6px 14px;
  padding: 12px 14px 8px;
  color: var(--ink);
  transition: opacity .6s;
}
#hud.hidden { opacity: 0; pointer-events: none; }
body[data-stage="wave"] #hud { color: #FFFDF6; }

#hud-left { grid-area: left; min-width: 0; }
#hud-loc {
  font-family: var(--font-ui);
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  font-size: 12.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#hud-stage {
  font-family: var(--font-type);
  font-size: 10.5px;
  letter-spacing: .1em;
  text-transform: lowercase;
  opacity: .8;
  margin-top: 3px;
}

#hud-clock { grid-area: clock; }
#hud-clock svg { display: block; }
.clock-label {
  font-family: var(--font-type);
  font-size: 9px;
  letter-spacing: .08em;
  text-anchor: middle;
  fill: var(--ink);
  opacity: .85;
}

/* meters — a full-width strip of five labelled resource cards.
   Each bar is signed: the notch is zero, fill grows right (good, teal)
   or the whole bar turns red as the value goes negative. */
/* FIVE EQUAL COLUMNS, and equal is the whole point: every meter draws
   the same -5..+5, so a bar that is physically shorter than the one
   beside it says something the numbers do not. This was a flex row, and
   a flex row sizes each chip from its own content — which made TIME, the
   shortest word on the bar, narrower than SUPPLIES and MOVEMENT.

   A grid of `1fr` tracks settles it without the old trade-off: in a
   container sized by its content, every `1fr` column takes the width of
   the widest one, so the five are identical AND the longest label still
   prints in full. */
#hud-meters {
  grid-area: meters;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 6px;
  width: 100%;
}
.meter {
  min-width: 0;
  position: relative;
  background: #FFFDF6;
  border: 2px solid rgba(43, 58, 85, .38);
  border-radius: 9px;
  padding: 4px 6px 6px;
  box-shadow: 0 1px 0 rgba(43, 58, 85, .12);
  color: var(--ink);
}
.meter .m-top {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 3px;
  margin-bottom: 3px;
}
/* The label must never clip — "Movement" and "Supplies" are the whole
   point of the meter. Tracking is tightened rather than the word cut. */
.meter .m-label {
  font-family: var(--font-ui);
  font-size: 9.5px;
  font-weight: var(--w-bold);
  letter-spacing: .02em;
  text-transform: uppercase;
  white-space: nowrap;
}
/* ---- the bar, as ten steps ----
   Five each side of centre, standing for the workbook's -5..+5. They
   light outward from the middle, so how far a meter has travelled reads
   as a length rather than as a number to be parsed. */
.meter .m-bar {
  position: relative;
  height: 11px;
  /* Fully rounded at every size. The radius must not be a fraction of the
     stage: scaled down for a phone it stopped reaching half the bar's
     height, and the same bar that reads as a pill on a desktop came out
     square-ended there. */
  border-radius: 999px;
  background: rgba(43, 58, 85, .14);
  border: 1.5px solid rgba(43, 58, 85, .3);
  overflow: hidden;
  display: flex;
  gap: 1px;
  padding: 1.5px;
}
.meter .m-cell {
  flex: 1 1 0;
  min-width: 0;
  border-radius: 1.5px;
  background: rgba(43, 58, 85, .12);
  transition: background .35s ease;
}
.meter .m-cell.neg.on { background: var(--red); }
.meter .m-cell.pos.on { background: var(--good); }

/* ---- the cells a choice just changed ----
   Only the cells that moved flash, and they flash outward from the
   centre one after another, so the run of them is as long as the change
   was. That length is what replaced the +1 / -2 chip: a choice costing
   three reads as three, without a number to parse.

   The bar clips its children, so this brightens the cell itself rather
   than glowing around it — an outer shadow would be cut off at the bar's
   edge. No fill mode either: at the end of the keyframes the cell hands
   back to whatever `.on` says it should be, lit or empty. */
.meter .m-cell.chg { animation: cellFlash .8s ease; }
.meter .m-cell.chg.up   { --flash: #9BEBB8; }
.meter .m-cell.chg.down { --flash: #FFB3A6; }
@keyframes cellFlash {
  0%       { background: var(--flash); }
  8%       { background: #FFFDF6; }
  50%      { background: var(--flash); }
  100%     { }
}
@media (prefers-reduced-motion: reduce) {
  .meter .m-cell.chg { animation: none; }
}
.meter .m-zero {
  position: absolute; top: -2px; bottom: -2px; left: 50%;
  width: 2px; margin-left: -1px;
  background: rgba(43, 58, 85, .55);
  z-index: 2;
}

/* ---- attention, on the bar and nowhere else ----
   The pulse, the glow and the coloured ground all used to sit on the
   whole chip, which dragged the meter's name into the colour with them:
   a drop in Safety turned the word "Safety" red. The state belongs to
   the bar, so that is the only thing that shows it now. The title stays
   the title. */
.meter.crit .m-bar { animation: critPulse 1.6s ease infinite; }
@keyframes critPulse {
  0%, 100% { box-shadow: none; }
  50% { box-shadow: 0 0 0 3px rgba(217, 106, 94, .45); }
}
.meter.bump-up .m-bar,
.meter.bump-down .m-bar { animation: meterPulse .9s ease; }
@keyframes meterPulse { 22% { transform: translateY(-3px) scale(1.07); } 55% { transform: translateY(0) scale(1); } 75% { transform: translateY(-1px) scale(1.03); } }
.meter.bump-up .m-bar   { box-shadow: 0 0 0 2px rgba(107, 163, 104, .45); }
.meter.bump-down .m-bar { box-shadow: 0 0 0 2px rgba(217, 106, 94, .45); }
/* ---- the question mark, and what it opens ----
   Wording: METER_HELP in js/engine.js */
.m-help {
  appearance: none;
  flex: 0 0 auto;
  width: 12px; height: 12px;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
  border: 1.2px solid currentColor;
  border-radius: 50%;
  background: none;
  color: inherit;
  opacity: .6;
  font-family: var(--font-ui);
  font-size: 8.5px;
  font-weight: var(--w-bold);
  line-height: 1;
  cursor: help;
  transition: opacity .14s ease, background .14s ease, color .14s ease;
}
.m-help:hover, .meter.tip-open .m-help {
  opacity: 1;
  background: var(--yellow);
  border-color: var(--ink);
  color: var(--ink);
}
.m-tip {
  position: absolute;
  top: calc(100% + 7px);
  left: 50%;
  transform: translateX(-50%) translateY(-3px);
  width: max(180px, 15em);
  max-width: 44vw;
  z-index: 60;
  padding: 8px 10px;
  border-radius: 8px;
  border: 2px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-weight: var(--w-med);
  font-size: 11.5px;
  line-height: 1.45;
  text-align: left;
  text-transform: none;
  letter-spacing: 0;
  box-shadow: 0 6px 18px rgba(10, 16, 34, .35);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .14s ease, transform .14s ease, visibility .14s;
}
/* the little nib pointing back at the question mark */
.m-tip::before {
  content: "";
  position: absolute;
  top: -6px; left: 50%; margin-left: -6px;
  width: 10px; height: 10px;
  transform: rotate(45deg);
  background: var(--paper);
  border-left: 2px solid var(--ink);
  border-top: 2px solid var(--ink);
}
/* hover on a mouse, tap on a phone — the class is set in js/engine.js */
.meter:hover .m-tip,
.meter.tip-open .m-tip {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}
/* a meter near the right edge would push its bubble off screen */
.meter:last-child .m-tip { left: auto; right: 0; transform: translateY(-3px); }
.meter:last-child .m-tip::before { left: auto; right: 14px; margin-left: 0; }
.meter:last-child:hover .m-tip,
.meter:last-child.tip-open .m-tip { transform: translateY(0); }

/* ============================================================
   THE QUESTION MARK ON A MINI-GAME PAGE
   Wording:       MINIGAME_HELP in js/scenes.js
   Where it sits: `helpIn` on the scene, else the beat's own heading,
                  else the corner — see renderMoment in js/engine.js
   ============================================================
   NOT the status bar's mark. That one is a 12px hint tucked beside a
   label on a cream panel, where small is right and the panel guarantees
   its contrast. This one has to be found at a glance, often over a
   photograph nobody chose for its legibility, sometimes with a finger.
   So it is its own control, and it is built to the standards rather
   than to the other mark's size.

     TARGET SIZE   44x44 CSS px at every screen size, which is WCAG 2.2
                   2.5.5 Target Size (Enhanced), level AAA. The AA
                   minimum is 24x24; this clears it by a factor of ~3.4
                   in area.

     CONTRAST      Ink #2C3663 on chrome yellow #FFD91F is 8.4:1. That
                   passes 1.4.6 Contrast (Enhanced, AAA) for NORMAL text
                   at 7:1 — and the glyph is 24px bold, which counts as
                   large text and only needs 4.5:1 at AAA. The bubble is
                   ink on paper #FFFDF6 at 11.4:1, AAA again.

     BOUNDARY      1.4.11 Non-text Contrast wants 3:1 against whatever is
                   behind it, and what is behind it is any photograph in
                   the game. So the disc carries BOTH a dark ink ring and
                   a pale outer ring: on a light backdrop the ink one
                   reads, on a dark backdrop the pale one does, and there
                   is no picture where neither can.

   Sizes are floors first and `--u` second, so the mark never shrinks
   below the standard on a small screen the way `--u` alone would. */
.mg-help-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  margin-left: calc(var(--u) * 0.7);
  /* Beats that draw their own heading make it click-through so the scene
     underneath stays reachable. The mark is the exception: it is the one
     thing in that row meant to be pressed. */
  pointer-events: auto;
  z-index: 6;
}
.mg-help {
  appearance: none;
  flex: 0 0 auto;
  width: max(44px, calc(var(--u) * 3.6));
  height: max(44px, calc(var(--u) * 3.6));
  display: flex; align-items: center; justify-content: center;
  padding: 0;
  border-radius: 50%;
  background: var(--yellow);
  color: var(--ink);
  border: max(3px, calc(var(--u) * 0.24)) solid var(--ink);
  /* the pale ring that keeps the edge legible on a dark picture, and a
     shadow so the disc sits above the scene rather than in it */
  box-shadow: 0 0 0 max(2px, calc(var(--u) * 0.16)) rgba(255, 253, 246, .95),
              0 max(2px, calc(var(--u) * 0.16)) max(6px, calc(var(--u) * 0.5)) rgba(10, 16, 34, .45);
  font-family: var(--font-ui);
  font-weight: var(--w-bold);
  font-size: max(24px, calc(var(--u) * 2));
  line-height: 1;
  text-shadow: none;              /* a heading over a photo carries one */
  cursor: help;
  transition: transform .14s ease, background .14s ease;
}
.mg-help:hover { transform: scale(1.08); }
.mg-help-wrap.tip-open .mg-help { background: var(--paper); }
/* A focus ring that is visible on both the yellow disc and whatever is
   behind it — 2.4.7, and thick enough for 2.4.13 Focus Appearance. */
.mg-help:focus-visible {
  outline: max(3px, calc(var(--u) * 0.26)) solid var(--ink);
  outline-offset: max(3px, calc(var(--u) * 0.24));
}

/* The bubble. Sized to be read, not squinted at: 14px floor, ink on
   paper, and wide enough that two sentences do not become eight lines. */
.mg-tip {
  position: absolute;
  top: calc(100% + max(10px, var(--u) * 0.9));
  left: 50%;
  transform: translateX(-50%) translateY(-4px);
  width: max(240px, calc(var(--u) * 24));
  max-width: min(68vw, calc(var(--u) * 34));
  z-index: 60;
  padding: max(10px, calc(var(--u) * 0.95)) max(12px, calc(var(--u) * 1.15));
  border-radius: max(9px, calc(var(--u) * 0.75));
  border: max(2.5px, calc(var(--u) * 0.2)) solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-weight: var(--w-med);
  font-size: max(14px, calc(var(--u) * 1.18));
  line-height: 1.5;
  text-align: left;
  text-transform: none;
  letter-spacing: 0;
  text-shadow: none;
  box-shadow: 0 max(6px, calc(var(--u) * 0.5)) max(20px, calc(var(--u) * 1.6)) rgba(10, 16, 34, .4);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .14s ease, transform .14s ease, visibility .14s;
}
/* the nib pointing back at the mark */
.mg-tip::before {
  content: "";
  position: absolute;
  top: max(-8px, calc(var(--u) * -0.66));
  left: 50%;
  width: max(13px, calc(var(--u) * 1.1));
  height: max(13px, calc(var(--u) * 1.1));
  margin-left: max(-6.5px, calc(var(--u) * -0.55));
  transform: rotate(45deg);
  background: var(--paper);
  border-left: max(2.5px, calc(var(--u) * 0.2)) solid var(--ink);
  border-top: max(2.5px, calc(var(--u) * 0.2)) solid var(--ink);
}
/* hover on a mouse, tap on a phone — the class is set in js/engine.js */
.mg-help-wrap:hover .mg-tip,
.mg-help-wrap.tip-open .mg-tip {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* No heading to sit beside: the corner, under the header, stepped left
   of the story-tree button by that button's own width plus a gap —
   the same sum .gr-tally uses to clear it. */
.mg-help-corner {
  position: absolute;
  top: max(84px, calc(var(--u) * 6.8));
  right: calc(max(38px, var(--u) * 3.4) + var(--u) * 2.6);
  margin: 0;
  z-index: 40;
}
/* and its bubble hangs off the right, since there is no room to its own
   right to centre into */
.mg-help-corner .mg-tip {
  left: auto; right: 0;
  transform: translateY(-4px);
}
.mg-help-corner .mg-tip::before {
  left: auto;
  right: max(15px, calc(var(--u) * 1.25));
  margin-left: 0;
}
.mg-help-corner:hover .mg-tip,
.mg-help-corner.tip-open .mg-tip { transform: translateY(0); }

@media (prefers-reduced-motion: reduce) {
  .mg-help, .mg-tip { transition: opacity .14s ease, visibility .14s; }
  .mg-help:hover { transform: none; }
}

/* ============================================================
   SCENE CARD — the white page
   ============================================================ */
#stage-wrap {
  flex: 1;
  display: flex;
  padding: 4px 12px calc(18px + env(safe-area-inset-bottom));
}

#scene {
  flex: 1;
  background: var(--paper);
  border-radius: 14px;
  box-shadow: 0 10px 34px rgba(44, 54, 99, .18);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}
#scene.fading { animation: sceneFade .5s ease; }
@keyframes sceneFade { from { opacity: 0; } to { opacity: 1; } }

/* --- art plate: a comic panel --- */
.art-plate {
  margin: 14px 16px 0;
  flex-shrink: 0;
}
.art-plate svg { display: block; width: 100%; height: auto; }

/* --- scroller --- */
.scene-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 26px 24px;
  scrollbar-width: thin;
  scrollbar-color: var(--ink-2) transparent;
  display: flex;
  flex-direction: column;
}

/* --- narrative text --- */
.para {
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: 17px;
  line-height: 1.78;
  color: var(--ink);
  margin: 0 0 15px;
  opacity: 0;
  transform: translateY(7px);
  animation: paraIn .55s ease forwards;
}
@keyframes paraIn { to { opacity: 1; transform: none; } }
.para em { color: #5A628C; font-style: italic; }
.para strong { font-weight: 700; color: var(--ink); }

/* dialogue — yellow speech bubble */
.para.dialogue {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 11px;
  align-items: start;
}
.para.dialogue .medallion { margin-top: 0; }
.medallion { width: 44px; height: 44px; flex-shrink: 0; }
.medallion svg { width: 100%; height: 100%; display: block; }
.say { position: relative; }
.say .who {
  display: block;
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin: 0 0 3px 4px;
}
.say .line {
  display: inline-block;
  background: var(--yellow);
  color: #2C3663;
  border-radius: 14px;
  border-top-left-radius: 4px;
  padding: 9px 13px 10px;
  font-weight: 600;
  font-size: 16.5px;
  line-height: 1.6;
  position: relative;
}
.say .line::before { content: ""; }
.say .line::after { content: ""; }

.flourish {
  text-align: center;
  color: var(--ink-2);
  font-size: 12px;
  letter-spacing: .7em;
  padding-left: .7em;
  margin: 4px 0 16px;
  opacity: 0;
  animation: paraIn .55s ease forwards;
}

/* toast = a pencil note in the margin */
.whisper {
  font-family: var(--font-hand);
  font-size: 19px;
  font-weight: 500;
  color: var(--ink-2);
  text-align: center;
  margin: 0 0 14px;
  opacity: 0;
  animation: paraIn .8s ease .15s forwards;
}
.whisper::before { content: "— "; }
.whisper::after { content: " —"; }

/* --- tap to continue --- */
.tap-hint {
  margin-top: auto;
  padding-top: 8px;
  text-align: center;
  font-family: var(--font-type);
  font-size: 11px;
  letter-spacing: .28em;
  text-transform: lowercase;
  color: var(--ink-2);
  opacity: .65;
  animation: tapPulse 2.2s ease infinite;
  cursor: pointer;
  user-select: none;
}
@keyframes tapPulse { 50% { opacity: .25; } }

/* --- choices: soft white cards with ink outlines --- */
.choices {
  margin-top: auto;
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.choice {
  appearance: none;
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: 14px;
  color: var(--ink);
  font-family: var(--font-ui);
  /* the same weight as .para — an option is narration the player can press,
     not a heading, and bolding it inverted the panel's hierarchy */
  font-weight: var(--w-med);
  font-size: 15.5px;
  letter-spacing: .01em;
  text-align: left;
  padding: 11px 15px 11px;
  cursor: pointer;
  position: relative;
  opacity: 0;
  animation: paraIn .5s ease forwards;
  transition: background .16s, transform .07s, box-shadow .16s;
  line-height: 1.4;
  box-shadow: 0 2px 0 rgba(44,54,99,.18);
}
.choice:nth-child(2) { animation-delay: .07s; }
.choice:nth-child(3) { animation-delay: .14s; }
.choice:nth-child(4) { animation-delay: .21s; }
.choice:nth-child(5) { animation-delay: .28s; }
.choice:hover:not(.locked) { background: var(--yellow); }
.choice:active:not(.locked) { transform: translateY(1px); box-shadow: 0 1px 0 rgba(44,54,99,.18); }
.choice .sub {
  display: block;
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: 13.5px;
  letter-spacing: 0;
  color: #5A628C;
  margin-top: 3px;
  line-height: 1.5;
}
.choice:hover:not(.locked) .sub { color: #4A5384; }
/* A locked option looks like a disabled button: solid grey, a plain grey
   edge, no shadow and nothing see-through. It used to fade to 60% over a
   dashed edge, which read as a button still loading rather than one that
   is not on offer. */
.choice.locked {
  border-style: solid;
  border-color: var(--grey-deep);
  background: var(--grey-wash);
  color: #7A8091;
  cursor: not-allowed;
  box-shadow: none;
  opacity: 0;
  animation: paraIn .5s ease forwards;
}
@keyframes paraInLocked { to { opacity: .6; transform: none; } }
.choice.locked .lock-note {
  display: block;
  font-family: var(--font-hand);
  font-weight: 500;
  font-size: 16px;
  margin-top: 2px;
}
.choice.locked .lock-note::before { content: "✕ "; font-family: var(--font-ui); font-size: 11px; }
/* A locked option stays reachable — the workbook wants the player able to
   focus and tap it for the explanation — so tapping one flashes the reason
   rather than doing nothing at all. It still never LOOKS pressable: no
   hand cursor and no hover change, the way a disabled button behaves. */
.choice.locked.asked .lock-note { animation: lockNudge .5s ease; }
@keyframes lockNudge {
  25% { color: var(--ink); transform: translateX(2px); }
  60% { color: var(--ink); transform: translateX(-1px); }
}
@media (prefers-reduced-motion: reduce) {
  .choice.locked.asked .lock-note { animation: none; color: var(--ink); }
}

/* ---- primary buttons ----
   One treatment for every button that moves the game forward: Continue,
   Next, Begin, the minigame action buttons. Sentence case, one family,
   one size. The old lowercase wide-tracked label style read as a caption
   rather than something to press. */
.choice.continue {
  text-align: center;
  font-family: var(--font-ui);
  font-weight: var(--w-bold);
  font-size: 15.5px;
  letter-spacing: .01em;
  text-transform: none;
  background: var(--yellow);
  border-radius: 999px;
  color: var(--ink);
}
.choice.continue:hover { background: #FFE45C; }

/* ============================================================
   CHAPTER PLATE — white page, typewriter eyebrow, slab title
   ============================================================ */
.chapter-plate {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 34px;
  cursor: pointer;
  background: var(--paper);
}
.chapter-plate .ch-num {
  font-family: var(--font-type);
  font-size: 17px;
  letter-spacing: .06em;
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 5px;
  text-decoration-thickness: 1.5px;
}
.chapter-plate .ch-orn { display: none; }
.chapter-plate .ch-title {
  font-family: var(--font-title);
  font-size: clamp(34px, 9vw, 44px);
  text-transform: lowercase;
  letter-spacing: .01em;
  margin: 12px 0 6px;
  line-height: 1.12;
}
.chapter-plate .ch-sub {
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: 15px;
  color: var(--ink-2);
  max-width: 40ch;
  line-height: 1.6;
}
.chapter-plate .ch-rule { border: none; margin: 10px 0 0; }
.chapter-plate .ch-rule::after { content: none; }
.chapter-plate .ch-spot { width: 200px; max-width: 60%; margin-top: 26px; }
.chapter-plate .ch-spot svg { width: 100%; height: auto; display: block; }

/* ============================================================
   TITLE SCREEN — now THE COVER, at the end of this file
   ============================================================ */

/* ============================================================
   MAP SCREEN — hand-drawn map with navy pins
   ============================================================ */
.map-wrap { padding: 14px 16px 0; flex-shrink: 0; }
.map-wrap svg { width: 100%; height: auto; display: block; }
.map-caption {
  font-family: var(--font-type);
  text-align: center;
  font-size: 11px; letter-spacing: .12em; text-transform: lowercase;
  color: var(--ink-2); margin-top: 7px;
}
.map-pin { cursor: pointer; }
.map-pin circle.ring { transition: r .2s; }
.map-pin:hover circle.ring { r: 13; }
.map-pin.done { opacity: .35; cursor: default; }
.map-pin.closed { opacity: .28; cursor: default; }
.pin-label {
  font-family: var(--font-hand);
  font-size: 16px; font-weight: 600; letter-spacing: .01em;
  text-transform: none;
  paint-order: stroke;
  stroke-width: 4px;
}

/* ============================================================
   SHOP — the outfitter, Florence shelf style
   ============================================================ */
.shop-head {
  display: flex; justify-content: space-between; align-items: center;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 8px; margin-bottom: 4px;
}
/* The title prints as it is written in PREP02_SHOP.title — it used to be
   forced to lowercase here, which quietly overrode the capitals. */
.shop-title {
  font-family: var(--font-title); font-size: 22px;
}
/* No pill behind it. The purse used to sit on a yellow lozenge, which
   forced the coin there to take a different face from the coins on the
   shelf — two currencies in one screen. It reads as a number now, at the
   same weight as the prices it is counting down. */
.shop-purse {
  font-family: var(--font-type); font-weight: 700;
  font-size: max(15px, calc(var(--u) * 1.55));
  color: var(--ink);
}
/* The shelf is capped and centred. Left to the full width of the panel
   the price sat a screen away from the name it belonged to, which is the
   gap that made the rows hard to read on a desktop. */
.shop-list {
  display: flex; flex-direction: column;
  width: 100%;
  max-width: 34em;
  margin: 0 auto;
}
/* picture · name · price */
.shop-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 2px calc(var(--u) * 1.1);
  padding: calc(var(--u) * 0.7) calc(var(--u) * 0.6);
  border-bottom: 1px solid var(--hairline);
  border-radius: 10px;
  cursor: pointer;
  transition: background .15s;
}
.shop-item:hover:not(.cant) { background: var(--yellow-soft); }
 /* `max(14px, …)` holds the size that already reads well on a phone and
    lets it grow with the stage on a desktop, where a flat 14px was small
    against everything around it. */
.shop-item .si-name {
  font-family: var(--font-ui); font-weight: 700;
  font-size: max(14px, calc(var(--u) * 1.42));
  line-height: 1.3;
}
.shop-item .si-name .tick { color: var(--good); margin-right: 6px; }
.shop-item .si-price {
  font-family: var(--font-type); font-weight: 700;
  font-size: max(14px, calc(var(--u) * 1.42));
  text-align: right;
  white-space: nowrap;
}
.shop-item .si-desc {
  grid-column: 2 / -1;
  font-family: var(--font-ui); font-weight: 500; font-size: 13px; color: var(--ink-2);
  line-height: 1.45;
}
.shop-item.owned { background: var(--yellow-soft); }
.shop-item.owned .si-price { color: var(--good); }
.shop-item.cant { opacity: .45; cursor: default; }
.shop-actions { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }

/* the shelf is a row of buttons, so it must not inherit button chrome */
.shop-item {
  appearance: none;
  background: none;
  border: none;
  border-bottom: 1px solid var(--hairline);
  text-align: left;
  width: 100%;
  color: inherit;
  font: inherit;
}
.shop-item:disabled { cursor: default; }

/* what the basket is actually worth, updating as items go in */
.shop-foot {
  margin-top: 10px;
  padding-top: 9px;
  border-top: 2px solid var(--ink);
  font-family: var(--font-ui);
  font-weight: var(--w-label);
  font-size: 14px;
}
.shop-foot b { font-size: 16px; }
.shop-foot.full b { color: var(--good); }
.shop-foot.short b { color: var(--ink-2); }
.shop-foot span {
  display: block;
  font-weight: var(--w-body);
  font-size: 12.5px;
  color: var(--ink-2);
  margin-top: 2px;
}
/* the leave button is dead until something is in the basket */
.choice.continue:disabled {
  opacity: .45;
  cursor: default;
  background: var(--cream);
}

/* the character brief shown before the first decision, one beat at a time */
.intro-name {
  font-family: var(--font-display);
  font-size: 26px;
  line-height: 1.1;
  margin-bottom: 8px;
}
.intro-dots {
  display: flex;
  gap: 6px;
  margin-top: 12px;
}
.intro-dots span {
  width: 7px; height: 7px;
  border-radius: 50%;
  border: 1.5px solid var(--ink-2);
  opacity: .5;
}
.intro-dots span.on { background: var(--ink); border-color: var(--ink); opacity: 1; }

/* ============================================================
   EPILOGUE CARDS — polaroids
   ============================================================ */
.ep-card {
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: 6px;
  padding: 14px 16px 12px;
  margin: 0 0 14px;
  position: relative;
  box-shadow: 0 3px 0 rgba(44,54,99,.15);
  opacity: 0; animation: paraIn .6s ease forwards;
}
.ep-card:nth-child(odd)  { transform: rotate(-.5deg); }
.ep-card:nth-child(even) { transform: rotate(.4deg); }
.ep-card .ep-head {
  display: flex; align-items: center; gap: 12px; margin-bottom: 7px;
}
.ep-card .ep-name {
  font-family: var(--font-title); font-size: 20px; text-transform: lowercase;
}
.ep-card .ep-line { font-family: var(--font-ui); font-weight: 500; font-size: 14.5px; line-height: 1.65; }
.ep-card:nth-child(2) { animation-delay: .12s; }
.ep-card:nth-child(3) { animation-delay: .24s; }
.ep-card:nth-child(4) { animation-delay: .36s; }
.ep-card:nth-child(5) { animation-delay: .48s; }
.ep-card:nth-child(6) { animation-delay: .60s; }

.journey-stats {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px 18px;
  margin: 6px 0 16px;
}
.jstat { border-left: 3px solid var(--yellow); padding-left: 10px; }
.jstat .js-k {
  font-family: var(--font-type); font-size: 9.5px;
  letter-spacing: .1em; text-transform: lowercase; color: var(--ink-2);
}
.jstat .js-v { font-family: var(--font-title); font-size: 19px; margin-top: 2px; }

/* section heading inside scene body */
.scene-h {
  font-family: var(--font-title);
  font-size: 24px; text-transform: lowercase; text-align: center;
  margin: 2px 0 6px;
  opacity: 0; animation: paraIn .5s ease forwards;
}

/* ============================================================
   MINIGAMES — shared chrome
   ============================================================ */
.mg-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 14px 16px 18px;
  overflow-y: auto;
}
.mg-title {
  font-family: var(--font-ui);
  font-weight: var(--w-label);
  font-size: 13px;
  letter-spacing: .12em;
  text-transform: uppercase;
  text-align: center;
  color: var(--ink-2);
  margin-bottom: 4px;
}
.mg-goal {
  font-family: var(--font-ui);
  font-weight: var(--w-label);
  font-size: 15.5px;
  text-align: center;
  color: var(--ink);
  margin: 0 auto 10px;
  max-width: 46ch;
  line-height: 1.5;
}
.mg-stage {
  position: relative;
  border: 2.5px solid var(--ink);
  border-radius: 12px;
  overflow: hidden;
  background: var(--paper);
  flex-shrink: 0;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.mg-stage svg { display: block; width: 100%; height: auto; }
.mg-under { margin-top: 12px; }
/* Feedback the player reads mid-play — never decorative, never small. */
.mg-note {
  font-family: var(--font-ui);
  font-weight: var(--w-med);
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  text-align: center;
  margin-top: 8px;
  min-height: 22px;
}
.mg-keys {
  font-family: var(--font-ui);
  font-weight: var(--w-med);
  font-size: 12.5px;
  letter-spacing: .04em;
  color: var(--ink-2);
  text-align: center;
  margin-top: 8px;
}
.mg-keys b {
  display: inline-block;
  border: 1.5px solid var(--ink-2);
  border-radius: 5px;
  padding: 0 6px;
  margin: 0 2px;
  font-weight: 400;
  background: #fff;
}
.mg-done .mg-keys, .mg-done .mg-note { opacity: .5; }
.mg-after { margin-top: 12px; }
.mg-after .choices { margin-top: 0; }

/* big round action button (shutter / heave) */
.mg-btnrow { display: flex; justify-content: center; margin-top: 12px; }
.mg-bigbtn {
  appearance: none;
  width: 82px; height: 82px;
  border-radius: 50%;
  border: 3px solid var(--ink);
  background: var(--yellow);
  color: var(--ink);
  font-family: var(--font-ui);
  font-weight: var(--w-bold);
  font-size: 14px;
  letter-spacing: .01em;
  text-transform: none;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(44,54,99,.3);
  transition: transform .06s, box-shadow .06s, background .15s;
}
.mg-bigbtn:hover { background: #FFE45C; }
.mg-bigbtn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(44,54,99,.3); }
.mg-bigbtn:disabled { opacity: .4; cursor: default; }

/* --- photo minigame --- */
.mg-photo-tray {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 12px;
}
.polaroid {
  width: 74px;
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: 3px;
  padding: 4px 4px 3px;
  box-shadow: 0 2px 0 rgba(44,54,99,.2);
  transform: rotate(-1.6deg);
}
.polaroid:nth-child(even) { transform: rotate(1.8deg); }
.polaroid .ph {
  height: 52px;
  border-radius: 2px;
  background: var(--grey-wash);
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.polaroid .ph svg { width: 100%; height: 100%; }
.polaroid .cap {
  font-family: var(--font-hand);
  font-size: 12.5px;
  line-height: 1.1;
  text-align: center;
  color: var(--ink-2);
  padding-top: 3px;
  min-height: 16px;
}
.polaroid.empty { opacity: .5; border-style: dashed; box-shadow: none; }
.polaroid.empty .ph { background: repeating-linear-gradient(45deg, #F0EAD8 0 6px, #FAF5E6 6px 12px); }
.polaroid.snap { animation: snapIn .45s cubic-bezier(.2,1.6,.4,1); }
@keyframes snapIn { 0% { transform: scale(.6) rotate(6deg); opacity: 0; } 100% { opacity: 1; } }

@keyframes shutterFlash { 0% { opacity: .9; } 100% { opacity: 0; } }
.shutter-flash {
  position: absolute; inset: 0; background: #fff; opacity: 0;
  pointer-events: none;
}
.shutter-flash.on { animation: shutterFlash .35s ease forwards; }

/* --- timing bar (cart) --- */
.mg-bar-wrap { padding: 0 10px; }
.mg-bar {
  position: relative;
  height: 46px;
  background: #fff;
  border: 2.5px solid var(--ink);
  border-radius: 12px;
  overflow: hidden;
}
.mg-bar .zone {
  position: absolute; top: 0; bottom: 0;
  background: var(--blue-pale);
  border-left: 2px dashed var(--ink);
  border-right: 2px dashed var(--ink);
}
.mg-bar .ticks {
  position: absolute; inset: 0;
  pointer-events: none;
}
.mg-bar .needle {
  position: absolute; top: -4px; bottom: -4px;
  width: 4px;
  background: var(--red);
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(255,255,255,.6);
}
.mg-bar.hit .zone { background: var(--teal-pale); animation: zonePop .5s ease; }
@keyframes zonePop { 30% { background: var(--teal); } }
.mg-bar.miss { animation: barShake .4s ease; }
@keyframes barShake {
  20% { transform: translateX(-5px); } 45% { transform: translateX(4px); }
  70% { transform: translateX(-2px); } 100% { transform: none; }
}

/* --- a running count under a beat (the go-bag's clock) --- */
.mg-count {
  font-family: var(--font-type);
  font-weight: 700;
  font-size: 15px;
  text-align: center;
  margin-top: 10px;
  letter-spacing: .1em;
  color: var(--ink);
}
.mg-count .big { font-size: 21px; }

/* ============================================================
   CHARACTER SELECT — Florence chapters list
   ============================================================ */
.select-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 34px 28px 26px;
  overflow-y: auto;
  background: var(--paper);
}
.sel-eyebrow {
  font-family: var(--font-type);
  font-size: 13px;
  text-align: center;
  text-decoration: underline;
  text-underline-offset: 5px;
  text-decoration-thickness: 1.5px;
}
.sel-title {
  font-family: var(--font-title);
  font-size: clamp(26px, 7vw, 32px);
  text-transform: lowercase;
  text-align: center;
  margin: 10px 0 6px;
}
.sel-sub {
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: 13.5px;
  color: var(--ink-2);
  text-align: center;
  max-width: 44ch;
  margin: 0 auto 20px;
  line-height: 1.6;
}
.sel-list { display: flex; flex-direction: column; gap: 11px; }
.sel-card {
  display: grid;
  grid-template-columns: 32px 54px 1fr;
  gap: 12px;
  align-items: center;
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: 14px;
  padding: 11px 14px;
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(44,54,99,.18);
  transition: background .15s, transform .07s;
  opacity: 0;
  animation: paraIn .5s ease forwards;
}
.sel-card:nth-child(2) { animation-delay: .06s; }
.sel-card:nth-child(3) { animation-delay: .12s; }
.sel-card:nth-child(4) { animation-delay: .18s; }
.sel-card:nth-child(5) { animation-delay: .24s; }
.sel-card:hover:not(.locked) { background: var(--yellow-soft); }
.sel-card:active:not(.locked) { transform: translateY(1px); }
.sel-card.locked {
  border-style: dashed;
  border-color: var(--ink-2);
  background: transparent;
  box-shadow: none;
  cursor: default;
  opacity: 0;
  animation: paraInLocked .5s ease forwards;
}
.sel-card.done { background: var(--paper); }
.sel-num {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--yellow);
  border: 2px solid var(--ink);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 13px;
}
.sel-card.done .sel-num { background: var(--teal); color: #fff; }
.sel-card.locked .sel-num { background: transparent; border-style: dashed; }
.sel-med { width: 54px; height: 54px; }
.sel-med svg { width: 100%; height: 100%; display: block; }
.sel-name { font-family: var(--font-title); font-size: 18px; text-transform: lowercase; }
.sel-tag { font-family: var(--font-ui); font-weight: 500; font-size: 12px; color: var(--ink-2); line-height: 1.45; margin-top: 1px; }
.sel-stamp { font-family: var(--font-hand); font-size: 15.5px; color: #3E7D64; margin-top: 3px; }
.sel-soon { font-family: var(--font-type); font-size: 10px; color: var(--ink-2); margin-top: 3px; text-transform: lowercase; }
.sel-cont { font-family: var(--font-type); font-size: 10.5px; margin-top: 4px; color: var(--ink); }
.sel-restart { text-decoration: underline; cursor: pointer; }

/* ============================================================
   MENU BUTTON + PAUSE SHEET
   ============================================================ */
#menu-btn {
  position: absolute;
  top: 12px; left: 12px;
  z-index: 40;
  width: 40px; height: 40px;
  border-radius: 12px;
  border: 2px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(44,54,99,.25);
  transition: background .15s, transform .07s;
}
#menu-btn:hover { background: var(--yellow); }
#menu-btn:active { transform: translateY(1px); box-shadow: 0 1px 0 rgba(44,54,99,.25); }
body[data-stage="wave"] #menu-btn { background: #fff; }

/* when the menu button is visible, give the HUD's top row room —
   the meter strip below keeps the full width */
#hud-left { padding-left: 50px; }

#sheet-veil {
  position: fixed; inset: 0;
  background: rgba(44, 54, 99, .35);
  z-index: 90;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  transition: opacity .25s ease;
}
#sheet-veil.open { opacity: 1; }
#sheet {
  width: 100%;
  max-width: 560px;
  background: var(--paper);
  border: 2.5px solid var(--ink);
  border-bottom: none;
  border-radius: 22px 22px 0 0;
  padding: 12px 22px calc(22px + env(safe-area-inset-bottom));
  transform: translateY(30px);
  transition: transform .25s ease;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
#sheet-veil.open #sheet { transform: translateY(0); }
#sheet .choice { opacity: 1; animation: none; }

/* ============================================================
   SCREEN SHAKE (the earthquake beat, TSU-SHARED-T0-01)

   ---- HOW HARD AND HOW FAST IT SHAKES — EDIT THE TWO NUMBERS ----
     --quake-strength  how far the picture swings at its widest, in
                       pixels. The tilt follows it, so this one number
                       sets the whole strength. Was 7; smaller is calmer.
     --quake-cycle     how long one full shake takes. Bigger is SLOWER.
                       Was .55s.
   The picture is drawn 12% larger than the screen (.sk-bg), so a
   strength up to about 30 never shows its edge.
   ---------------------------------------------------------------- */
.shaking, .shaking-soft {
  --quake-strength: 2;
  --quake-cycle: 1.5s;
}
/* Every step is a share of --quake-strength: at 7 these are exactly the
   pixel offsets and tilts the shake was first drawn with. */
@keyframes screenShake {
  0%   { transform: translate(0, 0) rotate(0); }
  12%  { transform: translate(calc(var(--quake-strength) * -1px),    calc(var(--quake-strength) *  .43px))  rotate(calc(var(--quake-strength) * -.0714deg)); }
  25%  { transform: translate(calc(var(--quake-strength) *  .857px), calc(var(--quake-strength) * -.571px)) rotate(calc(var(--quake-strength) *  .0571deg)); }
  38%  { transform: translate(calc(var(--quake-strength) * -.714px), calc(var(--quake-strength) * -.429px)) rotate(calc(var(--quake-strength) * -.0429deg)); }
  50%  { transform: translate(calc(var(--quake-strength) *  1px),    calc(var(--quake-strength) *  .571px)) rotate(calc(var(--quake-strength) *  .0714deg)); }
  63%  { transform: translate(calc(var(--quake-strength) * -.857px), calc(var(--quake-strength) *  .286px)) rotate(calc(var(--quake-strength) * -.0571deg)); }
  76%  { transform: translate(calc(var(--quake-strength) *  .571px), calc(var(--quake-strength) * -.714px)) rotate(calc(var(--quake-strength) *  .0429deg)); }
  88%  { transform: translate(calc(var(--quake-strength) * -.429px), calc(var(--quake-strength) *  .286px)) rotate(calc(var(--quake-strength) * -.0286deg)); }
  100% { transform: translate(0, 0) rotate(0); }
}
.shaking { animation: screenShake var(--quake-cycle) linear infinite; }
.shaking-soft { animation: screenShake calc(var(--quake-cycle) * 2) linear infinite; }
.sk-btnrow { display: flex; justify-content: center; margin-top: 14px; }
.sk-btn {
  appearance: none;
  font-family: var(--font-ui);
  font-weight: var(--w-bold);
  font-size: 15.5px;
  letter-spacing: .01em;
  text-transform: none;
  background: var(--yellow);
  color: var(--ink);
  border: 3px solid var(--ink);
  border-radius: 999px;
  padding: 16px 26px;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(44,54,99,.3);
  animation: skPulse 1s ease infinite;
}
@keyframes skPulse { 50% { transform: scale(1.06); } }
.sk-btn:active { transform: translateY(2px); }

/* ============================================================
   ENDING PLATE — one of four, selected by the workbook
   (no fail states in this revision: a run always finishes)
   ============================================================ */
.end-plate {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 34px 32px;
  background: var(--paper);
  overflow-y: auto;
}
.end-stamp {
  font-family: var(--font-type);
  font-size: 12px;
  letter-spacing: .18em;
  text-transform: lowercase;
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 6px;
  padding: 4px 12px 3px;
  transform: rotate(-2deg);
  margin-bottom: 14px;
  opacity: 0; animation: paraIn .5s ease forwards;
}
.end-protected   .end-stamp { color: var(--good); border-color: var(--good); }
.end-constrained .end-stamp { color: #B8763B; border-color: #B8763B; }
.end-exposure    .end-stamp { color: var(--red); border-color: var(--red); }
.end-title {
  font-family: var(--font-title);
  font-size: clamp(22px, 5.4vw, 30px);
  line-height: 1.15;
  margin-bottom: 12px;
  opacity: 0; animation: paraIn .5s ease .1s forwards;
}
.end-body { max-width: 56ch; text-align: left; }
.end-body .para { font-size: 15px; }
.end-body { width: 100%; max-width: 58ch; text-align: left; }
.end-plate .choices { width: 100%; max-width: 380px; margin-top: 4px; }

/* ---- reflection ---- */
/* One voice for the whole page: the description sits above, then every
   question below it is the same size, weight and rhythm. */
.refl-intro {
  width: 100%; max-width: var(--refl-w);
  margin-inline: auto;
  padding-left: 17px;
  text-align: left;
  font-family: var(--font-ui);
  font-weight: var(--w-med);
  font-size: 16px;
  line-height: 1.7;
  color: var(--ink-2);
  margin-bottom: 18px;
  opacity: 0; animation: paraIn .5s ease forwards;
}
.refl-list {
  width: 100%; max-width: var(--refl-w);
  margin-inline: auto;
  text-align: left;
  display: flex; flex-direction: column;
  gap: 12px;
  margin-bottom: 22px;
}
.refl-q {
  font-family: var(--font-display);
  font-weight: var(--w-body);
  font-size: 19px;
  line-height: 1.45;
  color: var(--ink);
  padding-left: 14px;
  border-left: 3px solid var(--yellow);
  opacity: 0; animation: paraIn .5s ease forwards;
}
.refl-q:nth-child(2) { animation-delay: .1s; }
.refl-q:nth-child(3) { animation-delay: .2s; }

/* ============================================================
   RESULT — what the settled choice did
   ============================================================ */
/* ---- two container treatments, nothing else ----
   .panel  — a bordered white card: outcomes, callbacks, the shop
   accent bar — a quiet note with no box: what you picked, character asides
   Both differ only by accent colour, so the panel reads as one surface
   instead of five competing boxes. */
.shop-card {
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: #fff;
  padding: 10px 14px;
}

/* The rolled question and its answer read as one sentence in the same
   voice as the rest of the panel — no card, no second surface. */
.prb-line {
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--ink-2);
  margin-top: 10px;
  opacity: 0; animation: paraIn .5s ease .2s forwards;
}
.prb-line b { font-weight: var(--w-bold); color: var(--ink); }
.prb-line.success b { color: var(--good); }
.prb-line.failure b { color: var(--bad); }
.prb-line.partial b { color: #B8763B; }

/* ============================================================
   CALLBACK — delayed feedback from an earlier choice
   ============================================================ */
.cb-head {
  font-family: var(--font-type);
  font-size: 11px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin-bottom: 8px;
}
/* The sentences themselves are plain text, read the same way a Situation
   is read. They used to sit in a bordered white card, which put a second
   surface inside a panel that was already white — the label above is
   enough to say where they came from. */
.cb-text {
  font-size: 14.5px;
  line-height: 1.55;
  text-align: left;
  color: var(--ink);
  opacity: 0; animation: paraIn .5s ease .1s forwards;
}
/* Several at once become a list, so two pieces of feedback do not run
   together into one paragraph. */
.cb-list {
  margin: 0;
  padding-left: 1.2em;
  list-style: disc;
  opacity: 0; animation: paraIn .5s ease .1s forwards;
}
.cb-item {
  font-size: 14.5px;
  line-height: 1.55;
  text-align: left;
  color: var(--ink);
  margin-bottom: 6px;
}
.cb-item:last-child { margin-bottom: 0; }
.cb-item::marker { color: var(--ink-2); }

/* HUD event-type chip — what this decision is about.
   Replaces the removed countdown; the workbook gives no usable clock. */
.hud-obj {
  display: inline-block;
  font-family: var(--font-type);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: lowercase;
  color: var(--ink);
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 4px 11px 3px;
  max-width: 26ch;
  line-height: 1.3;
  text-align: center;
  box-shadow: 0 2px 0 rgba(44,54,99,.18);
}
.hud-obj:empty { display: none; }

/* ============================================================
   THE ARRIVAL RADAR — a small map of the estimated first-wave
   arrival, top right, from the natural warning to the wave.
   ============================================================ */
.radar {
  position: relative;
  display: block;
  /* the HUD is pointer-events:none so it never blocks the scene beneath;
     the radar is the one thing in it you can actually click */
  pointer-events: auto;
  width: 132px;
  aspect-ratio: 2080 / 1348;
  margin-top: 7px;
  padding: 0;
  border: 2px solid var(--ink);
  border-radius: 9px;
  background: var(--paper);
  overflow: hidden;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 2px 0 rgba(44, 54, 99, .2), 0 5px 16px rgba(6, 10, 24, .35);
  /* a slow breath so it reads as something you can open */
  animation: radarBreathe 3.4s ease-in-out infinite;
}
.radar img { width: 100%; height: 100%; object-fit: cover; object-position: 12% 62%; display: block; }
.radar:hover { border-color: var(--red); }
.radar:hover .radar-tag { background: var(--red); }
@keyframes radarBreathe {
  0%, 100% { transform: scale(1); box-shadow: 0 2px 0 rgba(44,54,99,.2), 0 5px 16px rgba(6,10,24,.35); }
  50%      { transform: scale(1.035); box-shadow: 0 2px 0 rgba(44,54,99,.2), 0 7px 22px rgba(226,59,46,.5); }
}
.radar-tag {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  background: rgba(44, 54, 99, .82);
  color: #FFFDF6;
  font-family: var(--font-type);
  font-size: 9.5px;
  letter-spacing: .12em;
  text-align: center;
  padding: 2px 0 1.5px;
}

/* the 5 / 10 / 15 minute contours; a live one breathes */
.radar-rings, .lb-figure .radar-rings {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}
.radar-rings .rr,
.radar-rings .rr-halo {
  fill: none;
  opacity: 0;
  vector-effect: non-scaling-stroke;
}
.radar-rings .rr { stroke: #E23B2E; stroke-width: 1.4; }
.radar-rings .rr-halo { stroke: #FFFDF6; stroke-width: 3.6; }
.radar-rings .rr.live { animation: ringPulse 2.2s ease-in-out infinite; }
.radar-rings .rr-halo.live { animation: ringHalo 2.2s ease-in-out infinite; }
.radar-rings .rr-src { fill: #E23B2E; stroke: #FFFDF6; stroke-width: .5; opacity: .55; }
.radar-rings .rr-src.live { opacity: 1; animation: ringPulse 2.2s ease-in-out infinite; }
@keyframes ringPulse {
  0%, 100% { opacity: .35; stroke-width: 1.4; }
  50%      { opacity: 1;   stroke-width: 3.4; }
}
@keyframes ringHalo {
  0%, 100% { opacity: .2; stroke-width: 3.6; }
  50%      { opacity: .7; stroke-width: 6.4; }
}
@media (prefers-reduced-motion: reduce) {
  .radar { animation: none; }
  .radar-rings .rr.live,
  .radar-rings .rr-halo.live,
  .radar-rings .rr-src.live { animation: none; opacity: .9; }
  .radar-rings .rr.live { stroke-width: 2.6; }
}

/* ---- the full image, opened from the radar or the ending ---- */
#lightbox {
  position: fixed; inset: 0; z-index: 300;
  display: flex; align-items: center; justify-content: center;
  padding: 3vh 3vw;
  background: rgba(10, 14, 30, .78);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity .22s ease;
}
#lightbox.open { opacity: 1; }
.lb-inner {
  position: relative;
  max-width: min(1180px, 94vw);
  max-height: 94vh;
  display: flex; flex-direction: column; gap: 10px;
  transform: scale(.965);
  transition: transform .22s ease;
}
#lightbox.open .lb-inner { transform: scale(1); }
.lb-figure {
  position: relative;
  min-height: 0;
  border: 3px solid var(--ink);
  border-radius: 12px;
  overflow: hidden;
  background: var(--paper);
  box-shadow: 0 18px 48px rgba(6, 10, 24, .6);
}
.lb-figure img { display: block; width: 100%; height: auto; max-height: 78vh; object-fit: contain; }
.lb-figure .rr { stroke-width: 2.2; }
.lb-figure .rr-halo { stroke-width: 5.5; }
.lb-cap {
  color: #FFFDF6;
  font-size: 13px;
  line-height: 1.55;
  max-width: 78ch;
  text-shadow: 0 1px 4px rgba(6, 10, 24, .9);
}
.lb-cap b { display: block; font-family: var(--font-title); font-size: 16px; margin-bottom: 2px; }
.lb-close {
  position: absolute; top: -6px; right: -6px;
  transform: translate(35%, -35%);
  font-family: var(--font-type);
  font-size: 11px; letter-spacing: .16em;
  background: var(--yellow);
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  padding: 6px 14px 5px;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(44, 54, 99, .3);
}
.lb-close:hover { background: #FFE45C; }

/* ---- painted backdrops (assets/*.png) as a scene plate ----
   The drawn plates take their mood from the stage variables. A photo
   cannot, so the light is graded instead: ordinary at the warning, a
   little harder as the street fills.

   The later stages are NOT graded. T+10 and after used to be darkened and
   desaturated on top of the picture, which read as a dark film laid over
   artwork that already carries its own light — the night scene most of
   all. Those pictures are shown as drawn. */
.art-photo {
  display: block;
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: center 58%;
  transition: filter .6s ease;
}
body[data-stage="t0"]   .art-photo { filter: saturate(.9) brightness(.97); }
body[data-stage="move"] .art-photo { filter: saturate(1.05) contrast(1.04) sepia(.1) brightness(.9); }

/* ---- the inundation map on the ending plate ---- */
.end-map {
  display: block;
  width: 100%;
  max-width: 56ch;
  margin: 4px 0 14px;
  padding: 0;
  border: 2px solid var(--ink);
  border-radius: 12px;
  overflow: hidden;
  background: var(--paper);
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(44, 54, 99, .2);
  opacity: 0; animation: paraIn .6s ease .5s forwards;
}
.end-map img { display: block; width: 100%; height: auto; aspect-ratio: 2076 / 1360; }
.end-map:hover { border-color: var(--red); }
.em-cap {
  display: block;
  font-family: var(--font-type);
  font-size: 10.5px;
  letter-spacing: .14em;
  color: #FFFDF6;
  background: rgba(44, 54, 99, .88);
  padding: 4px 0 3px;
}

/* the character clause the workbook repeats on every option, shown once */

/* the character standing in the scene, to the right of the text */
.scene-portrait {
  position: absolute;
  right: 1.5%;
  bottom: 0;
  height: 74%;
  max-width: 25%;
  object-fit: contain;
  object-position: bottom right;
  z-index: 5;
  pointer-events: none;
  filter: drop-shadow(0 6px 14px rgba(44,54,99,.3));
  animation: portraitIn .45s ease both;
}
@keyframes portraitIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
/* keep the text and the buttons clear of the portrait */
#scene:has(.scene-portrait) .paras,
#scene:has(.scene-portrait) .after { margin-right: 22%; }
@media (max-width: 620px) {
  .scene-portrait { display: none; }
  #scene:has(.scene-portrait) .paras,
  #scene:has(.scene-portrait) .after { margin-right: 0; }
}

/* the $100 shelf sits inside the same glass card as the text */
/* the option you just took, while the result loads */
.choice.taken { background: var(--yellow); }
.choice[disabled]:not(.locked):not(.taken) { opacity: .55; }

/* ending and reflection buttons always stack */
.end-plate .choices { grid-template-columns: 1fr; }
.end-plate .choice { justify-content: center; text-align: center; }

.shop-card { max-height: 74% !important; }
.shop-card .shop-head { margin-top: 4px; }
.shop-card .shop-list { margin-bottom: 2px; }

/* ---- map used as a choice surface ---- */
.map-pin.picked .pin-dot { background: var(--red); transform: scale(1.15); }
.map-pin.closed { opacity: .5; }
.map-pick {
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: #fff;
  padding: 9px 12px;
  margin-top: 8px;
}
.map-pick.empty {
  border-style: dashed;
  color: var(--ink-2);
  font-size: 13px;
}
.map-pick.locked { border-style: dashed; border-color: var(--ink-2); }
.mp-text { font-size: 13.5px; font-weight: 600; line-height: 1.5; }
.mp-lock {
  font-family: var(--font-hand);
  font-size: 16px;
  color: var(--ink-2);
  margin-top: 3px;
}
.mp-lock::before { content: "✕ "; font-family: var(--font-ui); font-size: 11px; }

/* HUD portrait + class chip */
#hud-loc { display: flex; align-items: center; gap: 8px; }
#hud-port { width: 28px; height: 28px; flex-shrink: 0; }
#hud-port svg { width: 100%; height: 100%; display: block; }
#hud-clock { display: flex; flex-direction: column; align-items: center; gap: 4px; }
#hud-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-type);
  font-weight: 700;
  font-size: 11.5px;
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 2px 10px 1px;
  color: var(--ink);
}

/* ============================================================
   MINIGAME: go-bag packing
   ============================================================ */
.bag-wrap { display: flex; flex-direction: column; gap: 12px; }
.bag-shelf {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.bag-item {
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: 10px;
  padding: 8px 9px 7px;
  cursor: pointer;
  transition: background .15s, opacity .2s, transform .15s;
  box-shadow: 0 2px 0 rgba(44,54,99,.15);
}
.bag-item:hover { background: var(--yellow-soft); }
.bag-item.packed { opacity: .35; background: var(--cream); box-shadow: none; transform: scale(.97); }
/* These are the labels the player is choosing between — they carry the
   decision, so they read at body size, not caption size. */
.bag-item .bi-name { font-family: var(--font-ui); font-weight: var(--w-bold); font-size: 14.5px; line-height: 1.3; }
.bag-item .bi-size { font-family: var(--font-ui); font-weight: var(--w-label); font-size: 12px; color: var(--ink-2); margin-top: 3px; }
.bag-item .bi-note { font-family: var(--font-ui); font-weight: var(--w-body); font-size: 13px; color: var(--ink-2); line-height: 1.35; margin-top: 3px; }
.bag-bag {
  border: 2.5px solid var(--ink);
  border-radius: 14px;
  background: var(--yellow-soft);
  padding: 10px 12px;
}
.bag-bag .bb-head { font-family: var(--font-ui); font-weight: var(--w-label); font-size: 13px; margin-bottom: 7px; }
.bag-slots { display: flex; gap: 6px; flex-wrap: wrap; }
.bag-slot {
  width: 44px; height: 44px;
  border: 2px dashed var(--ink-2);
  border-radius: 8px;
  background: #fff;
  display: flex; align-items: center; justify-content: center;
}
.bag-slot.full { border-style: solid; border-color: var(--ink); animation: snapIn .3s ease; }
.bag-slot svg { width: 30px; height: 30px; }
.bag-slot .half { font-family: var(--font-type); font-size: 9px; color: var(--ink-2); }

/* The lane beat's own styles live with the drain's, at CLEAR THE
   LANE below — both are full-bleed beats on the same shell. */

/* ============================================================
   MINIGAME: nine words
   ============================================================ */
.nw-phone {
  background: #fff;
  border: 2.5px solid var(--ink);
  border-radius: 18px;
  padding: 14px 14px 12px;
  max-width: 420px;
  margin: 0 auto;
}
.nw-top {
  display: flex; justify-content: space-between; align-items: baseline;
  font-family: var(--font-type); font-size: 11px;
  border-bottom: 1.5px solid var(--hairline);
  padding-bottom: 7px; margin-bottom: 10px;
}
.nw-batt { font-weight: 700; }
.nw-batt.low { color: var(--red); animation: tapPulse 1.2s ease infinite; }
.nw-msg {
  min-height: 64px;
  border: 2px dashed var(--salmon);
  border-radius: 12px;
  padding: 8px 9px;
  display: flex; flex-wrap: wrap; gap: 6px;
  align-content: flex-start;
  margin-bottom: 10px;
}
.nw-msg .nw-word { background: var(--yellow); }
.nw-count { font-family: var(--font-type); font-size: 10px; text-align: right; color: var(--ink-2); margin: -6px 2px 8px 0; }
.nw-count.over { color: var(--red); font-weight: 700; }
.nw-pool { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.nw-word {
  appearance: none;
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 12.5px;
  background: var(--salmon);
  color: var(--ink);
  border: 1.5px solid var(--ink);
  border-radius: 8px;
  padding: 5px 9px 4px;
  cursor: pointer;
  transition: transform .08s, background .12s;
}
.nw-word:hover { transform: translateY(-1px); }
.nw-word:active { transform: translateY(0); }
.nw-word.used { opacity: .25; pointer-events: none; }
.nw-send-row { display: flex; justify-content: center; margin-top: 12px; }
.nw-dim .nw-phone { background: #F3EFE4; }


/* ============================================================
   MINIGAME: roof marks
   ============================================================ */
.mk-list {
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: 10px;
  padding: 8px 14px 9px;
  margin-top: 12px;
}
.mk-head { font-family: var(--font-type); font-size: 10.5px; color: var(--ink-2); margin-bottom: 4px; }
.mk-entry {
  font-family: var(--font-hand);
  font-size: 16.5px;
  color: var(--ink-2);
  border-bottom: 1px dashed var(--hairline);
  min-height: 22px;
}
.mk-entry.chalked { color: var(--ink); animation: snapIn .4s ease; }
.mk-fig { animation: tapPulse 1.8s ease infinite; }

/* what a scored moment paid out */
.mg-score {
  text-align: center;
  font-family: var(--font-ui);
  font-weight: var(--w-bold);
  font-size: 15px;
  letter-spacing: .02em;
  margin: 10px auto 2px;
  padding: 7px 16px;
  border-radius: 999px;
  border: 2px solid;
  width: fit-content;
}
.mg-score.up { color: var(--good); border-color: var(--good); background: rgba(78, 155, 110, .16); }
.mg-score.down { color: #FF9C8F; border-color: #FF9C8F; background: rgba(199, 67, 52, .18); }


/* ============================================================
   MINIGAME: the key
   ============================================================ */
.key-wrap {
  background: #fff;
  border: 2.5px solid var(--ink);
  border-radius: 16px;
  padding: 16px 18px;
  max-width: 430px;
  margin: 0 auto;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
.key-svg { width: 150px; display: block; margin: 0 auto; }
.key-mem { min-height: 40px; margin-top: 6px; }
.key-line {
  font-family: var(--font-hand);
  font-size: 17.5px;
  color: var(--ink-2);
  text-align: center;
  line-height: 1.5;
  opacity: 0;
  animation: paraIn .8s ease forwards;
}

/* ============================================================
   misc
   ============================================================ */
/* ============================================================
   TOWN BOARD — the Luna Bay orientation map image, cropped to
   its labelled right side, with clickable location pins
   ============================================================ */
.map-board {
  margin: 12px 12px 0;
  border: 2.5px solid var(--ink);
  border-radius: 16px;
  overflow: hidden;
  background: #BFE0EE;
  box-shadow: 0 3px 0 rgba(44, 54, 99, .18);
}
.map-canvas {
  position: relative;
  width: 168%;
  margin-left: -68%;
}
.map-canvas img { width: 100%; display: block; }
.map-pin {
  position: absolute;
  transform: translate(-50%, -50%);
  background: none; border: none; padding: 0;
  cursor: pointer;
  z-index: 2;
  -webkit-tap-highlight-color: transparent;
}
.pin-dot {
  display: block;
  width: 27px; height: 27px;
  margin: 0 auto;
  border-radius: 50%;
  background: var(--ink);
  border: 3px solid #fff;
  color: #fff;
  font: 700 13px/21px var(--font-ui);
  text-align: center;
  box-shadow: 0 2px 8px rgba(20, 30, 60, .4);
}
.map-pin:not(.done):not(.closed) .pin-dot { animation: pinPulse 1.6s ease infinite; }
@keyframes pinPulse {
  0%, 100% { box-shadow: 0 2px 8px rgba(20, 30, 60, .4); }
  50% { box-shadow: 0 2px 8px rgba(20, 30, 60, .4), 0 0 0 7px rgba(44, 54, 99, .22); }
}
.pin-tag {
  position: absolute;
  left: 50%; transform: translateX(-50%);
  bottom: calc(100% + 4px);
  background: #FFFDF6;
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 2px 10px 3px;
  font-family: var(--font-ui);
  font-size: 11px; font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  box-shadow: 0 2px 0 rgba(44, 54, 99, .2);
}
.map-pin.lbl-bottom .pin-tag { bottom: auto; top: calc(100% + 4px); }
.map-pin.closed { opacity: .45; filter: grayscale(.7); cursor: default; }
/* a place left on the map for orientation, but not on offer */
.map-pin.dead {
  opacity: .34; filter: grayscale(1);
  cursor: default; pointer-events: none;
}
.map-pin.dead .pin-dot { animation: none; }
.map-pin.done { cursor: default; }
.map-pin.done .pin-dot { background: var(--good); animation: none; }
.map-pin.done .pin-tag { opacity: .75; }
.map-caption {
  margin: 10px 16px 0;
  text-align: center;
  font-family: var(--font-type);
  font-size: 11.5px;
  letter-spacing: .08em;
  color: var(--ink);
  opacity: .85;
}

/* ============================================================
   DIALOGUE BOX — visual-novel style (portrait, name chip, one
   line at a time, tap to advance)
   ============================================================ */
#scene { position: relative; }
.dlg-veil {
  position: absolute; inset: 0;
  background: rgba(30, 38, 66, .48);
  opacity: 0;
  transition: opacity .25s ease;
  pointer-events: none;
  z-index: 5;
}
.dlg-portrait {
  position: absolute;
  right: 2px; bottom: 4px;
  height: min(62vh, 470px);
  max-width: 62%;
  object-fit: contain;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity .22s ease, transform .22s ease;
  pointer-events: none;
  z-index: 6;
  filter: drop-shadow(0 6px 18px rgba(20, 30, 60, .45));
}
.scene-body.vn .dlg-veil { opacity: 1; }
.scene-body.vn .dlg-portrait { opacity: 1; transform: translateY(0); }
.dlg-dock { position: relative; z-index: 7; }
.dlg-dock { margin-top: auto; padding-top: 10px; }
.dlg-name {
  display: inline-block;
  margin: 0 0 -12px 26px;
  position: relative; z-index: 2;
  background: var(--yellow);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 3px 14px 4px;
  font-family: var(--font-display);
  font-size: 14px;
  color: var(--ink);
  box-shadow: 0 2px 0 rgba(44, 54, 99, .2);
}
.dlg-box {
  position: relative;
  display: flex; align-items: flex-start; gap: 12px;
  background: #FFFDF6;
  border: 2.5px solid var(--ink);
  border-radius: 16px;
  padding: 16px 18px 18px;
  min-height: 96px;
  box-shadow: 0 3px 0 rgba(44, 54, 99, .18);
}
.dlg-box.pop { animation: dlgPop .16s ease; }
@keyframes dlgPop { 0% { transform: translateY(4px); opacity: .6; } 100% { transform: translateY(0); opacity: 1; } }
.dlg-port { width: 56px; height: 56px; flex-shrink: 0; margin-top: 2px; }
.dlg-port svg { width: 100%; height: 100%; display: block; }
.dlg-text {
  flex: 1;
  font-size: 17px;
  line-height: 1.62;
  color: var(--ink);
  align-self: center;
}
.dlg-box:not(.speaking) .dlg-text { color: rgba(43, 58, 85, .92); }
.dlg-adv {
  position: absolute; right: 14px; bottom: 8px;
  font-size: 13px; color: var(--ink); opacity: .75;
  animation: advBounce 1.2s ease infinite;
  pointer-events: none;
}
@keyframes advBounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(4px); } }
.dlg-dock.no-line .dlg-box { display: none; }
.dlg-dock .choices { margin-top: 12px; }
.scene-body.dlg-mode { display: flex; flex-direction: column; }
.scene-body.dlg-mode .paras:empty { display: none; }

/* the countdown — real time until the wave */
.tsu-clock {
  display: flex; flex-direction: column; align-items: center;
  gap: 1px;
  background: #FFFDF6;
  border: 2.5px solid var(--red);
  border-radius: 12px;
  padding: 6px 14px 7px;
  box-shadow: 0 2px 0 rgba(44, 54, 99, .2);
}
.tsu-clock .tsu-label {
  font-family: var(--font-type);
  font-size: 9px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--red);
}
.tsu-clock b {
  font-family: var(--font-type);
  font-size: 24px;
  line-height: 1.05;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.tsu-clock.low { animation: tsuLow 1s ease infinite; }
.tsu-clock.low b { color: var(--red); }
@keyframes tsuLow {
  0%, 100% { box-shadow: 0 2px 0 rgba(44, 54, 99, .2); }
  50% { box-shadow: 0 0 0 4px rgba(217, 106, 94, .35); }
}
body[data-stage="wave"] .tsu-clock { background: #fff; }

/* random-character button on the select screen */
.sel-random {
  margin-top: 14px;
  width: 100%;
  text-align: center;
}
/* AUD-QA-04: the helper line needs its own line and clear separation */
.sel-random .sub { display: block; margin-top: 6px; }
.sel-back {
  margin-top: 8px;
  width: 100%;
  text-align: center;
  font-family: var(--font-type);
  font-size: 12px;
  letter-spacing: .14em;
  background: transparent;
  border-style: dashed;
}

/* ---- hazard select: two scenarios, one town ---- */
.haz-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  width: 100%;
  margin-top: 6px;
}
.haz-card {
  appearance: none;
  text-align: left;
  background: #fff;
  border: 2.5px solid var(--ink);
  border-radius: 16px;
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  color: var(--ink);
  box-shadow: 0 3px 0 rgba(44, 54, 99, .22);
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}
.haz-card:hover { transform: translateY(-3px); box-shadow: 0 7px 0 rgba(44, 54, 99, .22); }
.haz-card:active { transform: translateY(0); }
.haz-art { height: 96px; overflow: hidden; border-bottom: 2.5px solid var(--ink); background: var(--wash); }
.haz-art svg { width: 100%; height: 100%; display: block; object-fit: cover; }
.haz-body { padding: 11px 15px 14px; }
.haz-when {
  font-family: var(--font-type);
  font-size: 10.5px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.haz-name {
  font-family: var(--font-title);
  font-size: 19px;
  line-height: 1.2;
  margin: 3px 0 5px;
}
.haz-blurb { font-size: 13px; line-height: 1.55; color: #4A5384; }
.haz-done {
  margin-top: 7px;
  font-family: var(--font-type);
  font-size: 10.5px;
  letter-spacing: .1em;
  color: var(--good);
}
@media (max-width: 620px) {
  .haz-list { grid-template-columns: 1fr; }
  .haz-art { height: 74px; }
}

.hidden { display: none !important; }

@media (max-width: 620px) {
  #stage-wrap { padding: 2px 6px calc(12px + env(safe-area-inset-bottom)); }
  .scene-body { padding: 14px 18px 18px; }
  .para { font-size: 15px; }
  #hud { padding: 10px 10px 5px; }
  #hud-meters { gap: 5px; }
  .meter { padding: 3px 5px 5px; }
  .meter .m-label { font-size: 8.5px; letter-spacing: 0; }
  .meter .m-bar { height: 14px; }
  .m-help { width: 11px; height: 11px; font-size: 8px; }
  .m-tip { font-size: 10.5px; width: max(150px, 13em); }
  .mg-wrap { padding: 12px 12px 14px; }
}
@media (max-height: 750px) {
  .art-plate { margin: 10px 12px 0; }
}

/* ============================================================
   ============================================================
   LANDSCAPE 16:9 STAGE  — the game lives inside a fixed-ratio
   canvas (1920×1080 at desktop scale, proportionally smaller or
   larger elsewhere). Everything below is sized in `--u`, which
   is 1% of the stage width, so the whole UI scales as one piece
   on every device. Text carries px floors so it stays legible
   on a phone held sideways.
   ============================================================
   ============================================================ */
:root {
  /* 1% of the 16:9 stage width. `dvh` rather than `vh` so the stage shrinks
     when a phone browser shows its own header instead of being sized to a
     viewport the player cannot see all of. js/viewport.js replaces this
     with a live measurement below. */
  --u: min(1vw, 1.7778vh);          /* 1% of the 16:9 stage width */
  --u: min(1vw, 1.7778dvh);         /* dvh where it is understood */
  --fs-xs: max(9px,  calc(var(--u) * 0.95));
  --fs-sm: max(10px, calc(var(--u) * 1.15));
  --fs-md: max(12px, calc(var(--u) * 1.42));
  --fs-lg: max(14px, calc(var(--u) * 1.85));
  --fs-xl: max(18px, calc(var(--u) * 2.7));
  --gap:   calc(var(--u) * 1.1);
  --radius: calc(var(--u) * 0.95);
}

html, body { height: 100%; overflow: hidden; }
html, body { height: 100dvh; }
body {
  align-items: safe center;
  background: #1b2340;                /* letterbox surround */
}

/* ============================================================
   THE BROWSER'S OWN HEADER

   Held sideways, Safari and Chrome keep a URL bar and a tab strip on
   screen. Chrome shrinks the viewport for it; Safari leaves the viewport
   alone and pushes the visible strip down. Either way the stage was being
   measured against space the player cannot see, so its bottom edge — the
   Continue button, the Zip button, the choices — ended up behind the
   browser's furniture.

   js/viewport.js reports the strip that is really visible. The stage is
   measured from it, and the page starts below wherever it begins.
   ============================================================ */
html.has-vv {
  --u: min(calc(var(--vv-w) / 100), calc(var(--vv-h) / 56.25));
}
html.has-vv body {
  /* the visible strip, plus the gap above it the header occupies */
  height: calc(var(--vv-top) + var(--vv-h));
  padding-top: var(--vv-top);
}
/* Nothing should need this once the stage is measured from the visible
   strip, but a floor on a font size can still push a panel past its box.
   The page scrolls rather than hiding what is left over. */
body { overflow-y: auto; overscroll-behavior-y: contain; }

/* Full-screen overlays are positioned against the layout viewport, which
   still runs underneath the header, so they take the same offset. */
html.has-vv #rotate-gate,
html.has-vv #sheet-veil,
html.has-vv #draw,
html.has-vv #sv-confirm,
html.has-vv #sv-why-modal,
html.has-vv #share-veil,
html.has-vv #toast-layer {
  top: var(--vv-top);
  height: var(--vv-h);
}

/* ============================================================
   THE IMMEDIATE RESULT, AS A TOAST
   Duration: TOAST_MS in js/engine.js
   How far below the status bar: TOAST_LOWER_U in js/engine.js
   ============================================================
   A settled choice has no page of its own any more. What it did arrives
   on the NEXT page instead, at the top under the status bar, and takes
   itself away again.

   The layer spans the stage and catches no clicks; the toast inside it is
   the only thing drawn, so the page underneath stays fully usable while
   one is up. */
#toast-layer {
  position: absolute; inset: 0;
  z-index: 200;
  pointer-events: none;
  display: flex;
  justify-content: center;
  /* flex-start, not the default stretch — a stretched toast grows to the
     full height of the layer, which is the whole stage */
  align-items: flex-start;
  /* Clear of the floating status bar. This is only the starting value —
     runToasts() MEASURES the bar and writes the real padding-top before it
     shows anything, because the bar is part `--u` and part pixel floors and
     so is proportionally taller on a phone than on a desktop. A single
     multiple of `--u` left a big gap on one and a tight one on the other.
     See TOAST_GAP_PX in js/engine.js. */
  padding: max(62px, calc(var(--u) * 6.2)) calc(var(--u) * 2) 0;
}
/* ---- the drop ----
   The outer element is the one that travels. It starts a full screen's
   worth above its place (--toast-rise is written by runToasts, and is the
   distance down to the resting line) and falls into position, overshoots
   a little, and settles. #toast-layer is clipped at the status bar's lower
   edge, so none of the journey above that line is ever drawn: what the
   player sees is the bubble coming out from behind the bar. */
.toast {
  width: fit-content;
  /* the floor keeps a phone's larger text to two lines, not three */
  max-width: min(100%, max(calc(var(--u) * 62), 500px));
  opacity: 0;
  transform: translateY(calc(-1 * var(--toast-rise, 90px) - 100%));
}
/* The bounce is in the KEYFRAMES, so the timing function must not have
   one of its own: an overshooting bezier on top of overshooting keyframes
   fights itself, and the toast arrives, overshoots, and then wanders back
   up in a way that reads as a glitch rather than as weight. A plain
   decelerating ease between the marks, and the marks do the acting. */
.toast.in  { animation: toastDrop .52s cubic-bezier(.3, .72, .4, 1) forwards; }
.toast.out { animation: toastLift .3s cubic-bezier(.55, 0, .8, .45) forwards; }

@keyframes toastDrop {
  0%   { opacity: 0; transform: translateY(calc(-1 * var(--toast-rise, 90px) - 100%)) scale(.92); }
  30%  { opacity: 1; }
  /* lands past the mark and squashes, the way a dropped thing does */
  55%  { transform: translateY(8%) scale(1.05, .93); }
  72%  { transform: translateY(-4%) scale(.98, 1.04); }   /* rebounds, stretches */
  86%  { transform: translateY(2%) scale(1.01, .99); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
/* and back the way it came, crouching once before it goes */
@keyframes toastLift {
  0%   { opacity: 1; transform: translateY(0) scale(1); }
  22%  { opacity: 1; transform: translateY(9%) scale(1.04, .94); }
  100% { opacity: 0; transform: translateY(calc(-1 * var(--toast-rise, 90px) - 100%)) scale(.92); }
}

/* ---- the bob ----
   The inner element carries the idle, which is why it is a separate box:
   the outer one is mid-transform for the whole of the drop and cannot
   also be breathing. It waits for the landing, then never quite settles —
   a message that is still talking to you. */
.toast-in {
  position: relative;
  display: block;
  /* generous room round the words: the bubble is the thing to notice */
  padding: max(14px, calc(var(--u) * 1.3)) max(26px, calc(var(--u) * 2.8));
  transform-origin: 50% 0;
}
.toast.in .toast-in { animation: toastBob 2.9s ease-in-out .54s infinite; }
@keyframes toastBob {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  30%      { transform: translateY(-3.5%) rotate(-.55deg); }
  65%      { transform: translateY(2%) rotate(.4deg); }
}

/* ---- the bubble ----
   An svg, not a border: it has a tail, and a tail is not something a box
   can grow. The path is generated at the measured pixel size by
   drawToastBubble() in js/engine.js — see the note there for why it is
   measured rather than stretched. The tail hangs above the text box, in
   the gap over the toast, pointing back at the bar it came from. */
.toast-bg {
  position: absolute;
  left: 0; right: 0;
  width: 100%;
  z-index: 0;
  overflow: visible;
  pointer-events: none;
  filter: drop-shadow(0 calc(var(--u) * 0.45) calc(var(--u) * 1.2) rgba(10, 16, 34, .42));
}
.toast-bg path { fill: var(--paper); stroke: var(--ink); stroke-linejoin: round; }

.toast-text {
  position: relative;
  z-index: 1;                      /* over the bubble it sits in */
  display: block;
  font-family: var(--font-ui);
  font-weight: var(--w-label);
  font-size: max(14px, calc(var(--u) * 1.4));
  line-height: 1.38;
  color: var(--ink);
  text-align: center;
}

/* Motion is the request here, so it cannot simply be switched off — but
   travel and bobbing are what make people ill, and neither is carrying
   meaning the words do not. What is left is the arrival itself. */
@media (prefers-reduced-motion: reduce) {
  .toast { transform: none; }
  .toast.in  { animation: toastFadeIn .26s ease forwards; }
  .toast.out { animation: toastFadeOut .26s ease forwards; }
  .toast.in .toast-in { animation: none; }
  @keyframes toastFadeIn  { to { opacity: 1; transform: none; } }
  @keyframes toastFadeOut { to { opacity: 0; transform: none; } }
}

/* ============================================================
   THE STORM — full-screen lightning (the rain and thunder are sound:
   js/sound.js). No dark layer: the scene shows as drawn, and only the
   flash and the fork play over it.
   Which nodes: STORM_NODES in js/scenes.js
   How it looks: STORM in the same file
   The strikes themselves: setStorm() in js/engine.js
   ============================================================
   `fixed`, so it is the whole screen and not the letterboxed stage —
   the flash washes the black bars too, the way weather does not stop at
   the edge of a window. It catches no clicks.

   It sits at 22: over the scene and the status bar (20), which is what
   makes it light the whole picture INCLUDING the meters, and under the
   toast scrim (25), the menu (30) and Back (41), so a flash never washes
   out the thing the player is being asked to read. */
#storm {
  position: fixed; inset: 0;
  z-index: 22;
  pointer-events: none;
  opacity: 0;
  transition: opacity .8s ease;
}
#storm.on { opacity: 1; }

/* The flash. Cold and blue-white, brightest at the top, because the
   light is coming from the sky and not from the room. --flash is rolled
   per flicker in js/engine.js so no two are the same brightness. */
.storm-flash {
  position: absolute; inset: 0;
  background:
    linear-gradient(to bottom,
      rgba(226, 238, 255, 1) 0%,
      rgba(206, 224, 255, .72) 38%,
      rgba(188, 210, 250, .32) 72%,
      rgba(180, 205, 250, .12) 100%);
  opacity: 0;
  mix-blend-mode: screen;
}
.storm-flash.on { opacity: var(--flash, .8); }

/* The fork. Drawn top-down across the screen by boltPaths(); the glow is
   what stops it reading as a white scribble. */
.storm-bolt {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  opacity: 0;
  filter: drop-shadow(0 0 6px rgba(190, 220, 255, .95))
          drop-shadow(0 0 22px rgba(150, 190, 255, .75));
}
.storm-bolt.on { opacity: 1; animation: stormBolt .42s ease-out forwards; }
@keyframes stormBolt {
  0%   { opacity: 0; }
  8%   { opacity: 1; }
  40%  { opacity: .85; }
  100% { opacity: 0; }
}
.storm-bolt path { fill: none; stroke: #F2F8FF; stroke-linecap: round; stroke-linejoin: round; }
.storm-bolt .sb-main { stroke-width: 3.4; }
.storm-bolt .sb-fork { stroke-width: 1.8; opacity: .85; }

/* A full-screen strobe is the one effect in this game that can actually
   hurt someone, so asking for less motion turns the flashing OFF rather
   than slowing it down. What is left is the weather without the strike:
   the rain. js/engine.js does not start the strike loop at all in this
   mode, and this rule is the belt to that brace. */
@media (prefers-reduced-motion: reduce) {
  .storm-flash, .storm-bolt { display: none; }
}

/* ---- the scrim under a toast ----
   While one is up the page is waiting, so nothing in the scene takes a
   click: the scrim covers everything and takes them all itself. A click
   or tap on it dismisses the toast — see toastScrim() in js/engine.js —
   so it carries a pointer.

   Its z-index is the whole trick. It lives inside #frame, which is a
   stacking context, and sits at 25 — above #scene and the HUD (20) and
   below the three controls that must stay live: the menu (30), Back (41)
   and the story tree (41). Nothing has to opt out; the order does it.

   `fixed` rather than `absolute` so it covers the letterbox bars too and
   really is the whole screen. */
#toast-scrim {
  position: fixed; inset: 0;
  z-index: 25;
  cursor: pointer;
  background: rgba(10, 16, 34, .2);
  opacity: 0;
  transition: opacity .22s ease;
}
#toast-scrim.on { opacity: 1; }

/* The stage is letterboxed and cannot scroll itself, so every full-screen
   panel inside it carries its own scroller. Without this, a short landscape
   viewport — a phone held sideways — traps any content taller than the
   stage with no way to reach it. */
.title-screen, .select-screen, .chapter-plate, .mg-wrap, .scene-body {
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
}
/* …except while a minigame is being played with the finger. */
.mg-wrap:has(.ch-scene), .mg-wrap:has(.rd-screen) { touch-action: none; }
body::before {                        /* stage-tinted glow behind the canvas */
  content: "";
  position: fixed; inset: 0;
  background: radial-gradient(ellipse at center, var(--page) 0%, #141a30 140%);
  opacity: .55;
  pointer-events: none;
}

#frame {
  width: calc(var(--u) * 100);
  height: calc(var(--u) * 56.25);
  max-width: none;
  min-height: 0;
  background: var(--page);
  overflow: hidden;
  box-shadow: 0 calc(var(--u) * 1.2) calc(var(--u) * 4) rgba(0, 0, 0, .5);
  transition: background 1.2s ease;
  z-index: 2;
}

/* ---------------- rotate gate (portrait phones) ---------------- */
#rotate-gate {
  position: fixed; inset: 0; z-index: 200;
  display: none;
  flex-direction: column; align-items: center; justify-content: center;
  gap: 18px;
  background: #1b2340;
  color: #FFFDF6;
  text-align: center;
  padding: 30px;
}
#rotate-gate .rg-phone {
  width: 84px; height: 132px;
  border: 4px solid #FFFDF6;
  border-radius: 14px;
  animation: rgTurn 2.4s ease-in-out infinite;
}
@keyframes rgTurn {
  0%, 30%   { transform: rotate(0deg); }
  55%, 85%  { transform: rotate(-90deg); }
  100%      { transform: rotate(0deg); }
}
#rotate-gate .rg-title {
  font-family: var(--font-title);
  font-size: 24px;
}
#rotate-gate .rg-sub {
  font-family: var(--font-type);
  font-size: 13px;
  opacity: .8;
  max-width: 300px;
  line-height: 1.6;
}
/* The gate is driven by a class the engine sets, not by a raw media query.
   A media query flips the instant the viewport crosses square, so a phone
   tipped a few degrees — or a keyboard opening — could snap the gate over
   the game mid-sentence. The engine debounces the change and only asks
   when the screen is clearly portrait AND clearly too narrow to play. */
body.ask-rotate #rotate-gate { display: flex; }
body.ask-rotate #frame, body.ask-rotate #toast-layer { visibility: hidden; }

/* ============================================================
   HUD — a full-width command bar with icons
   ============================================================ */
#hud {
  grid-template-columns: auto 1fr auto;
  grid-template-areas: "left meters clock";
  align-items: center;
  gap: calc(var(--u) * 1.4);
  padding: calc(var(--u) * 0.9) calc(var(--u) * 1.5) calc(var(--u) * 0.8) calc(var(--u) * 5.6);
  height: calc(var(--u) * 9.4);
  background: rgba(255, 253, 246, .55);
  border-bottom: max(2px, calc(var(--u) * 0.16)) solid var(--ink);
}
body[data-stage="wave"] #hud { background: rgba(30, 40, 70, .45); }

#hud-left { min-width: calc(var(--u) * 13); }
#hud-loc { font-size: var(--fs-sm); letter-spacing: .14em; gap: calc(var(--u) * 0.6); }
#hud-port { width: calc(var(--u) * 2.6); height: calc(var(--u) * 2.6); }
#hud-stage { font-size: var(--fs-xs); margin-top: calc(var(--u) * 0.2); }

/* Widened so the five labels print in full — "Movement" and "Supplies"
   were being clipped to "MOVEM…" at every stage width. */
#hud-meters {
  grid-area: meters;
  gap: calc(var(--u) * 0.6);
  max-width: calc(var(--u) * 74);
  margin: 0 auto;
}
.meter {
  padding: calc(var(--u) * 0.42) calc(var(--u) * 0.5) calc(var(--u) * 0.55);
  border-radius: calc(var(--u) * 0.7);
  border-width: max(2px, calc(var(--u) * 0.14));
}
.meter .m-top { gap: calc(var(--u) * 0.25); margin-bottom: calc(var(--u) * 0.3); }
.m-ico {
  width: calc(var(--u) * 1.15); height: calc(var(--u) * 1.15);
  flex-shrink: 0; display: block;
}
.m-ico svg { width: 100%; height: 100%; display: block; }
.m-name { display: flex; align-items: center; gap: calc(var(--u) * 0.28); min-width: 0; flex: 1 1 auto; }
/* sized so the longest label — MOVEMENT — prints in full */
.meter .m-label { font-size: max(9px, calc(var(--u) * 0.86)); letter-spacing: 0; }
.meter .m-bar { height: calc(var(--u) * 0.95); }
.m-help {
  width: max(11px, calc(var(--u) * 1.05));
  height: max(11px, calc(var(--u) * 1.05));
  font-size: max(8px, calc(var(--u) * 0.72));
}
.m-tip { font-size: max(10.5px, calc(var(--u) * 1.05)); }

/* ---- the change badge: which way a meter just went ----
   Drawn by renderMeters in js/engine.js, and only on the meters a choice
   actually moved. It hangs off the card's top-right corner and it is
   meant to be seen first — if it sits over a corner of the label or the
   bar for a moment and a half, that is the trade it is making.

   It pops rather than fades in — a change to a resource is an event, and
   an event should arrive. Then it holds long enough to be caught out of
   the corner of the eye and lifts away, leaving the bar it was pointing
   at. Green up, red down, matching the cell sweep beneath it.

   The white ring is what separates it from the cream card behind it; the
   shadow is what stops that ring disappearing into the card. */
.m-chip {
  position: absolute;
  top: calc(var(--u) * -1.15);
  right: calc(var(--u) * -0.6);
  z-index: 3;
  width: max(26px, calc(var(--u) * 2.6));
  height: max(26px, calc(var(--u) * 2.6));
  display: flex; align-items: center; justify-content: center;
  border-radius: 999px;
  border: max(2.5px, calc(var(--u) * 0.24)) solid #FFFDF6;
  box-shadow: 0 max(1px, calc(var(--u) * 0.09)) max(4px, calc(var(--u) * 0.34)) rgba(10, 16, 34, .45);
  color: #FFFDF6;
  pointer-events: none;
  animation: mChip 1.5s cubic-bezier(.2, .8, .3, 1) forwards;
}
/* the same two colours the lit cells use, so the badge and the bar under
   it are plainly the same signal — see .m-cell.pos.on / .m-cell.neg.on */
.m-chip.up   { background: var(--good); }
.m-chip.down { background: var(--red); }
/* one arrow path, turned over for a fall */
.m-arrow { width: 62%; height: 62%; display: block; }
.m-chip.down .m-arrow { transform: rotate(180deg); }
@keyframes mChip {
  0%   { opacity: 0; transform: scale(.4) translateY(calc(var(--u) * 0.5)); }
  16%  { opacity: 1; transform: scale(1.18) translateY(0); }
  26%  { transform: scale(1) translateY(0); }
  70%  { opacity: 1; transform: scale(1) translateY(0); }
  100% { opacity: 0; transform: scale(.96) translateY(calc(var(--u) * -1.1)); }
}
/* Motion is the whole message here, so it cannot simply be switched off:
   without it the badge would never leave. It stops bouncing and travelling
   and just holds, then fades. */
@media (prefers-reduced-motion: reduce) {
  .m-chip { animation: mChipCalm 1.5s ease forwards; }
  @keyframes mChipCalm {
    0%, 70% { opacity: 1; }
    100%    { opacity: 0; }
  }
}

/* the countdown, with a wave icon */
/* the event-type chip and the arrival radar stack down the right edge */
#hud-clock {
  grid-area: clock;
  display: flex; flex-direction: column;
  align-items: flex-end;
  gap: calc(var(--u) * 0.5);
}
.radar { width: calc(var(--u) * 13); margin-top: 0; border-width: max(2px, calc(var(--u) * 0.16)); }
.radar-tag { font-size: max(8px, calc(var(--u) * 0.82)); }
#hud-clock svg.clockface { width: calc(var(--u) * 6.4); height: auto; }
.tsu-clock {
  flex-direction: row; align-items: center;
  gap: calc(var(--u) * 0.7);
  padding: calc(var(--u) * 0.5) calc(var(--u) * 1.1);
  border-radius: calc(var(--u) * 0.8);
  border-width: max(2px, calc(var(--u) * 0.18));
}
.tsu-ico { width: calc(var(--u) * 2.4); height: calc(var(--u) * 2.4); flex-shrink: 0; }
.tsu-ico svg { width: 100%; height: 100%; display: block; }
.tsu-text { display: flex; flex-direction: column; align-items: flex-start; line-height: 1; }
.tsu-clock .tsu-label { font-size: var(--fs-xs); letter-spacing: .1em; }
.tsu-clock b { font-size: calc(var(--fs-xl) * 0.86); }

#hud-chip {
  font-size: var(--fs-xs);
  padding: calc(var(--u) * 0.35) calc(var(--u) * 0.9);
  border-radius: 999px;
  gap: calc(var(--u) * 0.4);
}
#hud-chip svg { width: calc(var(--u) * 1.3); height: calc(var(--u) * 1.3); }

/* menu button */
#menu-btn {
  top: calc(var(--u) * 1.2); left: calc(var(--u) * 1.2);
  width: calc(var(--u) * 3.4); height: calc(var(--u) * 3.4);
  border-radius: calc(var(--u) * 0.9);
  border-width: max(2px, calc(var(--u) * 0.15));
}
#menu-btn svg { width: calc(var(--u) * 1.7); height: calc(var(--u) * 1.7); }

/* ============================================================
   SCENE — art panel above, dialogue docked across the bottom
   ============================================================ */
#stage-wrap {
  padding: calc(var(--u) * 0.9) calc(var(--u) * 1.4) calc(var(--u) * 1.2);
  min-height: 0;            /* let the fixed stage height win over content */
  overflow: hidden;
}
#scene { border-radius: calc(var(--u) * 1.1); min-height: 0; }
#scene > * { min-height: 0; }

.art-plate {
  margin: calc(var(--u) * 1) calc(var(--u) * 1.4) 0;
  flex: 1 1 auto;
  min-height: 0;
  display: flex; align-items: center; justify-content: center;
}
.art-plate svg { width: auto; height: 100%; max-width: 100%; max-height: 100%; }

.scene-body { padding: calc(var(--u) * 1) calc(var(--u) * 2.2) calc(var(--u) * 1.4); }
.scene-body.dlg-mode { flex: 0 0 auto; }
.para { font-size: var(--fs-md); line-height: 1.6; margin-bottom: calc(var(--u) * 0.9); }

/* dialogue box */
.dlg-dock { padding-top: calc(var(--u) * 0.7); }
.dlg-name {
  margin: 0 0 calc(var(--u) * -1.05) calc(var(--u) * 2);
  padding: calc(var(--u) * 0.3) calc(var(--u) * 1.2) calc(var(--u) * 0.4);
  font-size: var(--fs-md);
  border-width: max(2px, calc(var(--u) * 0.14));
}
.dlg-box {
  gap: calc(var(--u) * 1.1);
  padding: calc(var(--u) * 1.3) calc(var(--u) * 1.6) calc(var(--u) * 1.4);
  min-height: calc(var(--u) * 8.4);
  border-radius: calc(var(--u) * 1.1);
  border-width: max(2px, calc(var(--u) * 0.18));
}
.dlg-port { width: calc(var(--u) * 4.2); height: calc(var(--u) * 4.2); }
.dlg-text { font-size: var(--fs-md); line-height: 1.55; }
.dlg-adv { font-size: var(--fs-sm); right: calc(var(--u) * 1); bottom: calc(var(--u) * 0.6); }

/* portraits get the full height of the stage on the right */
.dlg-portrait {
  right: calc(var(--u) * 0.5);
  bottom: 0;
  height: 92%;
  max-width: 40%;
}

/* ============================================================
   CHOICES — bigger targets, two columns when they fit
   ============================================================ */
.choices {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: calc(var(--u) * 0.7);
  margin-top: calc(var(--u) * 0.8);
}
.choices > .choice:only-child,
.choices > .choice.continue { grid-column: 1 / -1; }
.choice {
  font-size: var(--fs-md);
  padding: calc(var(--u) * 0.95) calc(var(--u) * 1.4);
  border-radius: calc(var(--u) * 0.9);
  border-width: max(2px, calc(var(--u) * 0.16));
  min-height: calc(var(--u) * 4.2);
  display: flex; align-items: center;
}
.choice .sub, .choice .lock-note { font-size: var(--fs-xs); }

/* ============================================================
   MAP — the big one. Full stage height, side rail beside it.
   ============================================================ */
#scene:has(.map-board) { flex-direction: row; align-items: stretch; overflow: hidden; }
.map-board {
  margin: calc(var(--u) * 1);
  flex: 1 1 auto;
  min-width: 0; min-height: 0;
  position: relative;
  border-radius: calc(var(--u) * 1.1);
  border-width: max(2px, calc(var(--u) * 0.18));
  overflow: hidden;
}
/* the image is anchored to the board HEIGHT and pinned right, so the
   labelled east side of Luna Bay fills the frame and the open sea
   falls off the left edge. Pin %s stay true to the full image box. */
.map-canvas {
  position: absolute;
  top: 55.7%; right: 0;          /* anchored right; nudged so the top pin clears */
  transform: translateY(-50%);
  height: 127%;                  /* zoom that keeps every pin (py 10–80) in frame */
  aspect-ratio: 2082 / 1390;
  width: auto;
  margin: 0;
}
.map-canvas img { width: 100%; height: 100%; object-fit: fill; }
.map-side {
  flex: 0 0 calc(var(--u) * 30);
  display: flex; flex-direction: column;
  padding: calc(var(--u) * 1.2) calc(var(--u) * 1.4) calc(var(--u) * 1.2) 0;
  min-height: 0;
}
.map-side .map-caption {
  font-size: var(--fs-sm);
  letter-spacing: .1em;
  padding: 0 0 calc(var(--u) * 0.8);
  text-align: left;
}
.map-side .scene-body { padding: 0; overflow-y: auto; flex: 1; }
.map-side .choices { grid-template-columns: 1fr; }

/* pins scale with the stage */
.pin-dot {
  width: calc(var(--u) * 2.1); height: calc(var(--u) * 2.1);
  border-width: max(2px, calc(var(--u) * 0.2));
  font-size: var(--fs-sm);
  line-height: calc(var(--u) * 1.7);
}
.pin-tag {
  font-size: var(--fs-xs);
  padding: calc(var(--u) * 0.22) calc(var(--u) * 0.75) calc(var(--u) * 0.3);
  border-width: max(2px, calc(var(--u) * 0.13));
  bottom: calc(100% + var(--u) * 0.4);
}
.map-pin.lbl-bottom .pin-tag { top: calc(100% + var(--u) * 0.4); }

/* ============================================================
   MINIGAMES / SHOP / PLATES — scale into the wider canvas
   ============================================================ */
/* minigames: title and controls hold their place, the art takes the rest */
.mg-wrap {
  /* the HUD floats over the stage, so the chrome starts below it —
     otherwise the control line runs under the meters */
  padding: calc(var(--u) * 11.5) calc(var(--u) * 2) calc(var(--u) * 1.4);
  display: flex; flex-direction: column;
  height: 100%; min-height: 0;
  overflow-y: auto;          /* content-heavy games stay reachable */
}
.mg-title { font-size: var(--fs-sm); flex: 0 0 auto; }
.mg-goal { font-size: var(--fs-md); flex: 0 0 auto; max-width: calc(var(--u) * 62); margin-inline: auto; }
/* stages carry an inline aspect-ratio, so cap the HEIGHT and let the box
   hug it — otherwise a full-width stage pushes the controls off the canvas */
/* stages carry an inline aspect-ratio, so cap the HEIGHT — the SVG inside
   keeps its own ratio via preserveAspectRatio and centres itself */
/* the host holds the stage plus each game's own controls: it takes the
   leftover height, and the stage shrinks inside it */
.mg-host {
  flex: 1 1 0;
  min-height: 0;
  display: flex; flex-direction: column;
  /* `safe` keeps content that is taller than the host from spilling out of
     the top, where it used to run up under the header */
  justify-content: safe center;
  gap: calc(var(--u) * 0.5);
  overflow: hidden;
}
/* Each stage carries its own aspect ratio. Forcing it to full width made
   the height fall out of that ratio, which left the taller games — the
   viewfinder especially — running at well under half the room available.
   Height leads instead: the stage takes what the host has left after the
   game's own controls, and the ratio decides the width. */
.mg-stage {
  flex: 1 1 auto;
  min-height: 0;
  max-height: 100%;
  width: auto;
  max-width: 100%;
  margin: 0 auto;
}
.mg-stage svg { width: 100%; height: 100%; display: block; }
.mg-note { font-size: var(--fs-md); flex: 0 0 auto; }
.mg-keys { font-size: var(--fs-sm); }
.bi-name { font-size: var(--fs-md); }
.bi-size, .bi-note { font-size: var(--fs-sm); }
.bb-head { font-size: var(--fs-sm); }
.si-name, .si-price { font-size: var(--fs-md); }
.si-desc, .shop-foot span { font-size: var(--fs-sm); }
.shop-foot { font-size: var(--fs-md); }
.mg-after, .sk-btnrow, .mg-controls { flex: 0 0 auto; }

.chapter-plate { padding: calc(var(--u) * 3) calc(var(--u) * 6); }
.ch-num { font-size: var(--fs-sm); }
.ch-title { font-size: var(--fs-xl); }
.ch-sub { font-size: var(--fs-md); }

.end-plate { padding: calc(var(--u) * 2.2) calc(var(--u) * 6); }
.end-title { font-size: var(--fs-lg); }
.end-body .para { font-size: var(--fs-md); }
.refl-q { font-size: var(--fs-lg); }
.refl-intro { font-size: var(--fs-md); }
.cb-text, .cb-item, .mp-text { font-size: var(--fs-md); }
.intro-name { font-size: var(--fs-xl); }
.prb-line { font-size: var(--fs-md); }

/* select screen uses the width: cards in two columns */
.select-screen { padding: calc(var(--u) * 2) calc(var(--u) * 4); }
.sel-title { font-size: var(--fs-xl); }
.sel-sub { font-size: var(--fs-sm); }
.sel-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: calc(var(--u) * 0.9); }
.sel-name { font-size: var(--fs-md); }
.sel-tag, .sel-cont, .sel-stamp { font-size: var(--fs-xs); }
.sel-med { width: calc(var(--u) * 4.4); height: calc(var(--u) * 4.4); }
.sel-random { margin-top: calc(var(--u) * 1.2); }

/* pause sheet becomes a centred modal in landscape */
#sheet {
  max-width: calc(var(--u) * 44);
  margin: auto;
  border-radius: calc(var(--u) * 1.4);
  padding: calc(var(--u) * 1.8) calc(var(--u) * 2);
}
#sheet-veil { display: flex; align-items: center; justify-content: center; }

.whisper { font-size: var(--fs-sm); }
.journey-stats { gap: calc(var(--u) * 0.8); }
.js-k { font-size: var(--fs-xs); }
.js-v { font-size: var(--fs-sm); }
.ep-card { padding: calc(var(--u) * 1.2); }
.ep-name { font-size: var(--fs-md); }
.ep-line { font-size: var(--fs-sm); }

/* Phone-sized landscape stages: hold type at fixed, legible sizes rather
   than letting it scale down with the canvas, and trade a little art height
   for a taller dialogue box. */
@media (max-height: 480px) {
  :root {
    --fs-xs: 9px;
    --fs-sm: 10.5px;
    --fs-md: 12.5px;
    --fs-lg: 15px;
    --fs-xl: 21px;
  }
  .dlg-box { min-height: calc(var(--u) * 10); padding: calc(var(--u) * 1.1) calc(var(--u) * 1.3); }
  .dlg-text { line-height: 1.45; }
  #hud { height: calc(var(--u) * 11); padding-left: calc(var(--u) * 6); }
  /* A FIXED height, not a scaled one, and the same one the bar has on a
     desktop stage. At phone scale --u is about 6.7px, so the old `1 x --u`
     bar stood 6.7px tall and its 1.5px border and 1.5px padding ate 6 of
     them: the red and green run came out under a pixel thick, a line rather
     than a bar. Everything else about it — the frame, the fully rounded
     ends, the cells — is left exactly as the desktop bar has it. */
  .meter .m-bar { height: 14px; }
  .m-ico { width: calc(var(--u) * 1.8); height: calc(var(--u) * 1.8); }
  .choice { min-height: calc(var(--u) * 5); padding: calc(var(--u) * 0.7) calc(var(--u) * 1.1); }
  /* give the meter chips room so no label has to truncate */
  .meter { min-width: calc(var(--u) * 12.8); padding: calc(var(--u) * 0.28) calc(var(--u) * 0.45); }
  .meter .m-label { letter-spacing: .01em; }
  .m-ico { width: calc(var(--u) * 1.6); height: calc(var(--u) * 1.6); }
  #hud-meters { gap: calc(var(--u) * 0.3); }
  .map-hud { top: calc(var(--u) * 15.5); width: calc(var(--u) * 30); }
}

.map-progress {
  display: flex; align-items: center;
  gap: calc(var(--u) * 0.45);
  font-family: var(--font-type);
  font-size: var(--fs-xs);
  letter-spacing: .06em;
  color: var(--ink);
  opacity: .85;
  padding-bottom: calc(var(--u) * 0.9);
  border-bottom: max(1px, calc(var(--u) * 0.08)) dashed rgba(44, 54, 99, .3);
  margin-bottom: calc(var(--u) * 0.9);
}
.mp-ico { width: calc(var(--u) * 1.4); height: calc(var(--u) * 1.4); flex-shrink: 0; }
.mp-ico svg { width: 100%; height: 100%; display: block; }

/* ============================================================
   ============================================================
   FULL-BLEED IMMERSIVE STAGE
   The scene art IS the game world: it covers the entire 16:9
   canvas, edge to edge. Every piece of UI floats on top of it
   as glass — no cards, no header bar, no page.
   ============================================================
   ============================================================ */

/* --- the world layer ------------------------------------- */
#stage-wrap {
  position: absolute; inset: 0;
  padding: 0;
  z-index: 1;
}
#scene {
  border-radius: 0;
  box-shadow: none;
  overflow: hidden;
  /* the plate's own paper, extended to every edge, so the drawing bleeds
     into the world instead of sitting on a card */
  background:
    radial-gradient(ellipse at 50% 42%, rgba(255,255,255,.9) 0%, rgba(255,253,246,0) 62%),
    var(--paper);
}
#scene:has(.chapter-plate), #scene:has(.fail-plate),
#scene:has(.title-screen), #scene:has(.select-screen) { background: var(--page); }
#scene:has(.map-board) { background: #BFE0EE; }
.art-plate {
  position: absolute; inset: 0;
  margin: 0;
  z-index: 0;
  display: block;
  pointer-events: none;
}
.art-plate .plate-svg { width: 100%; height: 100%; display: block; }
.art-plate .plate-edge { display: none; }        /* no comic-panel border */

/* light + shadow so the art reads as a lit place, not a flat drawing */
#scene::after {
  content: "";
  position: absolute; inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(to bottom, rgba(12,18,38,.38) 0%, rgba(12,18,38,.06) 15%, rgba(12,18,38,0) 28%),
    linear-gradient(to top,    rgba(12,18,38,.66) 0%, rgba(12,18,38,.22) 20%, rgba(12,18,38,0) 42%),
    radial-gradient(ellipse at 50% 46%, rgba(0,0,0,0) 58%, rgba(10,16,34,.16) 100%);
}
/* screens that are their own full-page composition keep a clean field */
#scene:has(.chapter-plate)::after,
#scene:has(.fail-plate)::after,
#scene:has(.title-screen)::after,
#scene:has(.select-screen)::after,
#scene:has(.mg-wrap)::after { background: none; }

/* --- the HUD: glass, floating, no bar --------------------- */
#hud {
  position: absolute; top: 0; left: 0; right: 0;
  z-index: 20;
  height: auto;
  display: block;
  padding: calc(var(--u) * 1.1) calc(var(--u) * 1.5);
  background: none;
  border-bottom: none;
  pointer-events: none;
}
body[data-stage="wave"] #hud { background: none; }

/* ---- one header row: who you are on the left, resources on the right ----
   The meters used to sit on a second line under the label, which stacked
   two bars down the left of the screen and covered the art. */
#hud {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: calc(var(--u) * 2);
}
#hud-left {
  position: static;
  min-width: 0;
  flex: 0 1 auto;
  display: flex; flex-direction: row; align-items: center;
  gap: calc(var(--u) * 0.9);
  margin-left: calc(var(--u) * 4.4);
  text-shadow: 0 calc(var(--u) * 0.1) calc(var(--u) * 0.5) rgba(6, 10, 24, .85);
}
#hud-loc, #hud-stage { color: #FFFDF6; }
#hud-loc { font-size: var(--fs-sm); display: flex; align-items: center; gap: calc(var(--u) * 0.8); }
/* the second line is gone: one configurable line is all the header carries */
#hud-stage { display: none; }
#hud-port {
  border-radius: 50%;
  background: rgba(255, 253, 246, .9);
  box-shadow: 0 0 0 max(2px, calc(var(--u) * 0.13)) rgba(255, 253, 246, .55);
}
/* the event-type chip is design meta; the dialogue already says what this is */
.hud-obj { display: none; }

/* the five meters: compact glass chips, held to the right of the header */
#hud-meters {
  position: static;
  flex: 0 0 auto;
  margin: 0;
  max-width: none;
  width: auto;
  gap: calc(var(--u) * 0.45);
  padding: calc(var(--u) * 0.5);
  background: rgba(14, 20, 42, .42);
  border: max(1px, calc(var(--u) * 0.09)) solid rgba(255, 253, 246, .22);
  border-radius: calc(var(--u) * 0.9);
  backdrop-filter: blur(calc(var(--u) * 0.5));
  -webkit-backdrop-filter: blur(calc(var(--u) * 0.5));
  box-shadow: 0 calc(var(--u) * 0.3) calc(var(--u) * 1.2) rgba(6, 10, 24, .45);
}
.meter {
  background: none;
  border: none;
  box-shadow: none;
  border-radius: calc(var(--u) * 0.5);
  padding: calc(var(--u) * 0.3) calc(var(--u) * 0.5);
  color: #FFFDF6;
  min-width: calc(var(--u) * 8.2);
}
.meter .m-label { color: rgba(255, 253, 246, .82); }
.meter .m-bar {
  background: rgba(255, 253, 246, .16);
  border-color: rgba(255, 253, 246, .28);
}
.meter .m-cell { background: rgba(255, 253, 246, .13); }
.meter .m-zero { background: rgba(255, 253, 246, .5); }

/* The same rule as the light theme: state shows on the bar, never on
   the name above it. These used to set a coloured ground on the whole
   chip, which took the title with it. */
.meter.crit .m-bar { animation: critPulseGlass 1.6s ease infinite; }
@keyframes critPulseGlass {
  0%, 100% { box-shadow: none; }
  50% { box-shadow: 0 0 0 max(2px, calc(var(--u) * 0.18)) rgba(217, 106, 94, .55); }
}
.meter.bump-up .m-bar   { background: rgba(107, 163, 104, .3); }
.meter.bump-down .m-bar { background: rgba(217, 106, 94, .3); }

/* the arrival radar, tucked under the meters on the right */
#hud-clock {
  position: absolute;
  top: calc(var(--u) * 7.4); right: calc(var(--u) * 1.5);
  pointer-events: auto;
}
#hud-clock svg.clockface {
  filter: drop-shadow(0 calc(var(--u) * 0.2) calc(var(--u) * 0.7) rgba(6, 10, 24, .6));
  opacity: .96;
}
.tsu-clock {
  background: rgba(14, 20, 42, .58);
  border-color: rgba(226, 59, 46, .9);
  backdrop-filter: blur(calc(var(--u) * 0.5));
  -webkit-backdrop-filter: blur(calc(var(--u) * 0.5));
  box-shadow: 0 calc(var(--u) * 0.3) calc(var(--u) * 1.2) rgba(6, 10, 24, .5);
}
.tsu-clock b { color: #FFFDF6; }
body[data-stage="wave"] .tsu-clock { background: rgba(14, 20, 42, .58); }
#hud-chip {
  background: rgba(14, 20, 42, .5);
  border: max(1px, calc(var(--u) * 0.09)) solid rgba(255, 253, 246, .25);
  color: #FFFDF6;
  backdrop-filter: blur(calc(var(--u) * 0.4));
  -webkit-backdrop-filter: blur(calc(var(--u) * 0.4));
}

/* menu button: glass, over the world */
#menu-btn {
  z-index: 30;
  background: rgba(14, 20, 42, .5);
  border-color: rgba(255, 253, 246, .38);
  color: #FFFDF6;
  backdrop-filter: blur(calc(var(--u) * 0.4));
  -webkit-backdrop-filter: blur(calc(var(--u) * 0.4));
  box-shadow: 0 calc(var(--u) * 0.25) calc(var(--u) * 0.9) rgba(6, 10, 24, .45);
}
#menu-btn:hover { background: rgba(226, 59, 46, .8); }
body[data-stage="wave"] #menu-btn { background: rgba(14, 20, 42, .6); }

/* --- dialogue: overlays the world, anchored low ----------- */
.scene-body {
  position: absolute; inset: 0;
  z-index: 10;
  padding: 0 calc(var(--u) * 4) calc(var(--u) * 2);
  display: flex; flex-direction: column; justify-content: flex-end;
  overflow: visible;
  pointer-events: none;
}
.scene-body > * { pointer-events: auto; }
.scene-body.dlg-mode { flex: none; }
.dlg-dock { margin-top: 0; padding-top: 0; }
.dlg-box {
  border-width: max(3px, calc(var(--u) * 0.22));
  box-shadow: 0 calc(var(--u) * 0.55) calc(var(--u) * 2.4) rgba(6, 10, 24, .55),
              0 calc(var(--u) * 0.2) 0 rgba(44, 54, 99, .35);
}
/* a soft darkening under the dock so the box reads on pale art too */
.dlg-dock::before {
  content: "";
  position: absolute;
  left: calc(var(--u) * -4); right: calc(var(--u) * -4);
  bottom: calc(var(--u) * -2.4); top: calc(var(--u) * -3.5);
  background: radial-gradient(ellipse at 50% 80%, rgba(8,13,30,.5) 0%, rgba(8,13,30,0) 72%);
  pointer-events: none;
  z-index: -1;
}
.dlg-dock { position: relative; }
.dlg-portrait {
  right: calc(var(--u) * 2);
  bottom: calc(var(--u) * 7.5);
  height: 78%;
  max-width: 34%;
  z-index: 6;
  filter: drop-shadow(0 calc(var(--u) * 0.6) calc(var(--u) * 1.6) rgba(6, 10, 24, .6));
}
/* the veil is now a gentle darkening of the world, not a grey sheet */
.dlg-veil { background: rgba(10, 16, 34, .10); z-index: 2; }

/* narrative panels (stat blocks, epilogue cards, map text) get glass.
   The story text's own box is now DIALOGUE GLASS, at the end of this
   file; the cream look here is what the shop shelf keeps. */
.paras:not(:empty) {
  max-height: 62%;
  overflow-y: auto;
  background: rgba(255, 253, 246, .93);
  border-radius: calc(var(--u) * 1);
  padding: calc(var(--u) * 1.2) calc(var(--u) * 1.6);
  margin-bottom: calc(var(--u) * 0.9);
  box-shadow: 0 calc(var(--u) * 0.5) calc(var(--u) * 2) rgba(6, 10, 24, .45);
  backdrop-filter: blur(calc(var(--u) * 0.6));
  -webkit-backdrop-filter: blur(calc(var(--u) * 0.6));
}
.whisper {
  align-self: center;
  background: rgba(14, 20, 42, .62);
  color: #FFFDF6;
  border-radius: 999px;
  padding: calc(var(--u) * 0.4) calc(var(--u) * 1.3);
  margin-bottom: calc(var(--u) * 0.8);
  backdrop-filter: blur(calc(var(--u) * 0.4));
  -webkit-backdrop-filter: blur(calc(var(--u) * 0.4));
}

/* choices sit on the world, right where the eye already is */
.choices { margin-top: calc(var(--u) * 0.7); }
.choice {
  background: rgba(255, 253, 246, .96);
  box-shadow: 0 calc(var(--u) * 0.35) calc(var(--u) * 1.3) rgba(6, 10, 24, .45);
}
.choice:hover:not(.locked) { background: var(--yellow); transform: translateY(calc(var(--u) * -0.12)); }

/* --- map: the town IS the screen -------------------------- */
#scene:has(.map-board) { display: block; }
.map-board {
  position: absolute; inset: 0;
  margin: 0;
  border: none;
  border-radius: 0;
  z-index: 0;
}
/* pushed down so the artwork's own printed title card clears the bottom
   edge of the canvas, and anchored right so the labelled east side leads */
.map-canvas { height: 118%; top: 60%; right: calc(var(--u) * -1); }

/* map furniture floats on the town: a caption chip up top, an action bar
   along the bottom. No side rail — the map is the screen. */
.map-side { display: none; }
/* every pin sits in the map's right half, so the town's chrome lives down
   the left edge, under the meters — floating glass, not a side pane */
.map-hud {
  position: absolute;
  top: calc(var(--u) * 14); left: calc(var(--u) * 1.5);
  width: calc(var(--u) * 27);
  z-index: 14;
  display: flex; flex-direction: column; align-items: flex-start;
  gap: calc(var(--u) * 0.5);
  pointer-events: none;
}
.map-hud .map-caption {
  text-align: left;
  background: rgba(14, 20, 42, .6);
  color: #FFFDF6;
  border-radius: 999px;
  padding: calc(var(--u) * 0.45) calc(var(--u) * 1.2);
  font-size: var(--fs-sm);
  letter-spacing: .1em;
  backdrop-filter: blur(calc(var(--u) * 0.5));
  -webkit-backdrop-filter: blur(calc(var(--u) * 0.5));
  box-shadow: 0 calc(var(--u) * 0.3) calc(var(--u) * 1.1) rgba(6, 10, 24, .45);
}
.map-hud .map-progress {
  margin: 0; padding: 0; border: none;
  color: #FFFDF6;
  opacity: .9;
  text-shadow: 0 calc(var(--u) * 0.1) calc(var(--u) * 0.5) rgba(6, 10, 24, .9);
}
.map-hud .map-note {
  max-width: 100%;
  text-align: left;
  background: rgba(14, 20, 42, .74);
  color: #FFFDF6;
  border-radius: calc(var(--u) * 0.8);
  padding: calc(var(--u) * 0.5) calc(var(--u) * 1.2);
  backdrop-filter: blur(calc(var(--u) * 0.5));
  -webkit-backdrop-filter: blur(calc(var(--u) * 0.5));
  box-shadow: 0 calc(var(--u) * 0.3) calc(var(--u) * 1.1) rgba(6, 10, 24, .45);
}
.map-hud .map-note:empty { display: none; }
.map-hud .map-note .para { margin: 0; font-size: var(--fs-sm); color: #FFFDF6; }
.map-whisper {
  position: absolute; top: calc(var(--u) * 1.4); left: 50%;
  transform: translateX(-50%); z-index: 15; pointer-events: none;
}
/* only the action lives at the bottom, as a compact pill */
.map-foot {
  position: absolute;
  left: calc(var(--u) * 1.5);
  bottom: calc(var(--u) * 1.6);
  z-index: 14;
  display: flex;
}
.map-foot .choice {
  width: auto;
  min-height: 0;
  padding: calc(var(--u) * 0.8) calc(var(--u) * 1.6);
  border-radius: 999px;
  font-size: var(--fs-sm);
}
.map-foot:empty { display: none; }
.pin-dot { box-shadow: 0 calc(var(--u) * 0.2) calc(var(--u) * 0.8) rgba(6, 10, 24, .6); }

/* --- minigames: a lit table in a dark room ---------------- */
.mg-wrap {
  position: relative;
  z-index: 10;
  background: rgba(10, 16, 34, .55);
}
/* Every word of minigame chrome is white on the dark table. Mixing white
   headings with ink-grey key hints and white key chips made the lines under
   the controls the hardest thing on the screen to read. */
.mg-title, .mg-goal, .mg-note, .mg-keys, .mg-keys b,
.mg-count, .mg-count .big, .mg-hint, .mg-rule {
  color: #FFFDF6;
  text-shadow: 0 calc(var(--u) * 0.1) calc(var(--u) * 0.5) rgba(6, 10, 24, .8);
}
.mg-keys b {
  background: rgba(255, 253, 246, .12);
  border-color: rgba(255, 253, 246, .6);
}
.mg-stage {
  border-radius: calc(var(--u) * 0.9);
  overflow: hidden;
  box-shadow: 0 calc(var(--u) * 0.5) calc(var(--u) * 2) rgba(6, 10, 24, .55);
}

/* --- stage / ending plates: cinematic full screen ---------- */
.chapter-plate, .end-plate {
  position: relative; z-index: 10;
  height: 100%;
  display: flex; flex-direction: column; justify-content: center;
}
/* a long ending must never push its buttons off the canvas */
.end-plate {
  justify-content: flex-start;
  overflow-y: auto;
  padding-top: calc(var(--u) * 2.2);
  padding-bottom: calc(var(--u) * 2.2);
}
.end-plate .end-body, .end-plate .end-map { flex: 0 0 auto; }
/* the buttons follow the content instead of being pinned to the floor,
   so a short ending does not leave half a screen of nothing */
.end-plate .choices { margin-top: calc(var(--u) * 2); padding-top: 0; }

/* ============================================================
   SMALL LANDSCAPE STAGES — final word on sizing.
   This block must stay last: media queries add no specificity,
   so the phone tier has to come after the immersive rules.
   ============================================================ */
@media (max-height: 480px) {
  .meter {
    min-width: calc(var(--u) * 10.8);
    padding: calc(var(--u) * 0.28) calc(var(--u) * 0.5);
  }
  .meter .m-label { letter-spacing: .01em; }
  .m-ico { width: calc(var(--u) * 1.55); height: calc(var(--u) * 1.55); }
  #hud-meters { gap: calc(var(--u) * 0.3); top: calc(var(--u) * 5.8); }
  .map-hud { top: calc(var(--u) * 15.5); width: calc(var(--u) * 30); }
  .dlg-portrait { height: 72%; max-width: 30%; bottom: calc(var(--u) * 8.5); }
  .scene-body { padding: 0 calc(var(--u) * 2.4) calc(var(--u) * 1.5); }
}

/* ============================================================
   LUNA BAY COMMUNITY REGISTER — the opening survey

   Two screens: a cover with the illustration beside a navy panel,
   and a clipboard card that carries all five questions. Both are
   landscape-first and sized in --u like the rest of the stage.
   All wording lives in js/survey.js.
   ============================================================ */
#scene:has(.sv-screen), #scene:has(.sv-cover) { background: var(--page); }
#scene:has(.sv-screen)::after, #scene:has(.sv-cover)::after { background: none; }

/* ---- the clipboard ---- */
.sv-screen {
  position: relative; z-index: 10;
  height: 100%;
  display: flex; align-items: center; justify-content: center;
  padding: calc(var(--u) * 3.4) calc(var(--u) * 3) calc(var(--u) * 2.2);
  overflow-y: auto;
  min-height: 0;
}
.sv-clip {
  position: absolute;
  top: calc(var(--u) * 0.4);
  left: 50%; transform: translateX(-50%);
  width: calc(var(--u) * 13);
  height: auto;
  z-index: 3;
  filter: drop-shadow(0 calc(var(--u) * 0.2) calc(var(--u) * 0.5) rgba(20, 26, 40, .3));
}
.sv-card {
  width: 100%;
  max-width: calc(var(--u) * 88);
  background: var(--paper);
  border: max(2px, calc(var(--u) * 0.16)) solid var(--ink);
  border-radius: calc(var(--u) * 1.4);
  padding: calc(var(--u) * 2.4) calc(var(--u) * 3) calc(var(--u) * 1.6);
  box-shadow: 0 calc(var(--u) * 0.8) calc(var(--u) * 2.4) rgba(20, 26, 40, .22);
  display: flex; flex-direction: column;
  min-height: calc(var(--u) * 44);
}
.sv-head {
  display: flex; justify-content: space-between; align-items: baseline;
  padding-bottom: calc(var(--u) * 0.9);
  border-bottom: max(1px, calc(var(--u) * 0.09)) solid var(--ink);
}
.sv-reg {
  font-family: var(--font-ui);
  font-weight: var(--w-bold);
  font-size: var(--fs-sm);
  letter-spacing: .1em;
  text-transform: uppercase;
}
.sv-count {
  font-family: var(--font-ui);
  font-weight: var(--w-bold);
  font-size: var(--fs-lg);
  letter-spacing: .04em;
}
.sv-q {
  font-family: var(--font-display);
  font-weight: var(--w-body);
  font-size: calc(var(--fs-xl) * 1.02);
  line-height: 1.15;
  margin: calc(var(--u) * 1.4) 0 calc(var(--u) * 0.3);
}
.sv-help {
  font-family: var(--font-ui);
  font-size: var(--fs-sm);
  color: var(--ink-2);
  padding-bottom: calc(var(--u) * 0.9);
  border-bottom: max(1px, calc(var(--u) * 0.09)) solid var(--ink);
}
.sv-body { flex: 1 1 auto; padding: calc(var(--u) * 1.2) 0; min-height: 0; }

/* ---- options ---- */
.sv-opts { display: grid; gap: 0 calc(var(--u) * 4); }
.sv-opts.cols-1 { grid-template-columns: 1fr; }
.sv-opts.cols-2 { grid-template-columns: 1fr 1fr; }
.sv-opt {
  appearance: none;
  background: none;
  border: none;
  border-bottom: max(1px, calc(var(--u) * 0.07)) solid rgba(44, 54, 99, .28);
  text-align: left;
  display: flex; align-items: center;
  gap: calc(var(--u) * 1.1);
  padding: calc(var(--u) * 0.95) calc(var(--u) * 0.3);
  cursor: pointer;
  color: var(--ink);
  font-family: var(--font-ui);
  font-weight: var(--w-med);
  font-size: var(--fs-md);
  line-height: 1.35;
  transition: background .12s ease;
}
.sv-opt.wide { grid-column: 1 / -1; }
.sv-opt:hover { background: var(--yellow-soft); }
/* The mark keeps a floor size: below it the 2px border ate most of the box
   and the filled dot inside came out a couple of pixels across on a phone.
   The fill is a share of the box rather than a fixed inset, so it scales
   with the mark instead of vanishing as the mark shrinks. */
.sv-mark {
  flex: 0 0 auto;
  width: max(19px, calc(var(--u) * 1.5)); height: max(19px, calc(var(--u) * 1.5));
  border: max(2px, calc(var(--u) * 0.15)) solid var(--ink);
  position: relative;
}
.sv-mark.dot { border-radius: 50%; }
.sv-mark.box { border-radius: calc(var(--u) * 0.22); }
.sv-opt.on .sv-mark::after {
  content: "";
  position: absolute; inset: 18%;
  background: var(--ink);
  border-radius: inherit;
}
.sv-opt.on { font-weight: var(--w-bold); }

/* Options that read DOWN each column instead of across each row.
   `--sv-rows` is written on the element by the renderer, which is the
   only part CSS cannot work out for itself: the browser fills a column
   to that many rows before it starts the next one. An uneven list
   leaves the remainder in the last column — five options over two
   columns give three on the left and two on the right. */
.sv-opts.flow-col {
  grid-auto-flow: column;
  grid-template-rows: repeat(var(--sv-rows, 4), auto);
}

/* Q3 prints two single-select lists side by side */
.sv-dual { display: grid; grid-template-columns: 1fr 1fr; gap: 0 calc(var(--u) * 4); }

/* One option and anything that hangs off it. The slot is the grid item,
   so a follow-up opening below an option pushes the options under it
   down rather than overlapping them. */
.sv-slot { display: flex; flex-direction: column; min-width: 0; }
.sv-slot > .sv-opt { width: 100%; }

/* ---- a follow-up question, nested under the option that opens it ---- */
.sv-follow {
  margin: calc(var(--u) * 0.7) 0 calc(var(--u) * 0.9) calc(var(--u) * 2.6);
  padding-left: calc(var(--u) * 1.2);
  border-left: max(2px, calc(var(--u) * 0.16)) solid var(--yellow);
}
.sv-fq {
  font-family: var(--font-ui);
  font-weight: var(--w-bold);
  font-size: var(--fs-sm);
  line-height: 1.35;
  color: var(--ink);
  padding-bottom: calc(var(--u) * 0.25);
}
.sv-fopts { display: flex; flex-wrap: wrap; gap: 0 calc(var(--u) * 1.6); }
.sv-fopt {
  appearance: none;
  background: none;
  border: none;
  text-align: left;
  display: flex; align-items: center;
  gap: calc(var(--u) * 0.7);
  padding: calc(var(--u) * 0.45) 0;
  cursor: pointer;
  color: var(--ink);
  font-family: var(--font-ui);
  font-weight: var(--w-med);
  font-size: var(--fs-sm);
  line-height: 1.3;
}
/* smaller than the question's own marks, so the nesting reads at a glance */
.sv-fopt .sv-mark {
  width: max(15px, calc(var(--u) * 1.15)); height: max(15px, calc(var(--u) * 1.15));
}
.sv-fopt.on { font-weight: var(--w-bold); }
.sv-fopt.on .sv-mark::after {
  content: "";
  position: absolute; inset: 18%;
  background: var(--ink);
  border-radius: inherit;
}
.sv-gh {
  font-family: var(--font-ui);
  font-weight: var(--w-bold);
  font-size: var(--fs-md);
  letter-spacing: .06em;
  text-transform: uppercase;
  padding-bottom: calc(var(--u) * 0.5);
}
.sv-dual .sv-opt { padding: calc(var(--u) * 0.62) calc(var(--u) * 0.3); }

/* ---- footer ---- */
.sv-foot {
  display: flex; justify-content: space-between; align-items: center;
  gap: calc(var(--u) * 1.5);
  padding-top: calc(var(--u) * 1.1);
  border-top: max(1px, calc(var(--u) * 0.09)) solid var(--ink);
}
.sv-num {
  font-family: var(--font-ui);
  font-weight: var(--w-bold);
  font-size: var(--fs-sm);
  letter-spacing: .1em;
  text-transform: uppercase;
}
/* Left to right: leave the survey, step back, go on — plainest to
   strongest, so the eye lands on Continue. */
.sv-btns { display: flex; align-items: center; gap: calc(var(--u) * 1); }
.sv-skip, .sv-back, .sv-go {
  appearance: none;
  font-family: var(--font-ui);
  font-weight: var(--w-bold);
  font-size: var(--fs-md);
  letter-spacing: .01em;
  padding: calc(var(--u) * 0.85) calc(var(--u) * 2);
  border-radius: calc(var(--u) * 0.7);
  border: max(2px, calc(var(--u) * 0.16)) solid var(--ink);
  cursor: pointer;
  color: var(--ink);
}
/* the way out is text only — no fill, no border */
.sv-skip {
  background: none;
  border-color: transparent;
  font-weight: var(--w-med);
  color: var(--ink-2);
  padding-inline: calc(var(--u) * 0.8);
  text-decoration: underline;
  text-underline-offset: .2em;
}
.sv-skip:hover { color: var(--ink); }
.sv-back { background: var(--paper); }
.sv-back:hover { background: var(--cream); }
.sv-go { background: var(--yellow); }
.sv-go:hover:not(:disabled) { background: #FFE45C; }
.sv-go:disabled { opacity: .4; cursor: default; background: var(--cream); }

/* ---- the cover ---- */
.sv-cover {
  position: relative; z-index: 10;
  height: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
}
/* ---- cover artwork ----
   Two layouts, set by COPY.cover.layout in js/survey.js:
     split  picture in the left half, panel in the right
     full   picture behind everything, panel floating over it
   A supplied photo fills its area and is cropped to COPY.cover.focus.
   The drawn scene is a wide band, so it is never cropped — it sits
   centred at full width on its own field. If a supplied photo fails to
   load, .fallback swaps the drawn scene back in. */
.sv-art {
  position: relative;
  overflow: hidden;
  background: var(--paper);
  display: flex; align-items: center;
}
.sv-drawn { width: 100%; }
.sv-art svg { width: 100%; height: auto; display: block; }

.sv-photo {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
/* with a photo present the drawn scene is only the safety net */
.sv-art.has-photo .sv-drawn { display: none; }
.sv-art.has-photo.fallback .sv-photo { display: none; }
.sv-art.has-photo.fallback .sv-drawn { display: block; }

/* full-bleed: the picture is the whole screen, the panel floats over it */
.sv-cover.full { grid-template-columns: 1fr; position: relative; }
.sv-cover.full .sv-art { position: absolute; inset: 0; }
.sv-cover.full .sv-panel {
  position: relative;
  z-index: 2;
  margin-left: auto;
  width: min(52%, calc(var(--u) * 52));
  background: var(--sv-panel-bg);
}
/* a soft edge so the panel does not cut the picture with a hard line */
.sv-cover.full .sv-panel::before {
  content: "";
  position: absolute; top: 0; bottom: 0; right: 100%;
  width: calc(var(--u) * 8);
  background: linear-gradient(to right, rgba(22, 38, 92, 0), var(--sv-panel-bg));
  pointer-events: none;
}
.sv-place {
  position: absolute; top: calc(var(--u) * 1.6); left: calc(var(--u) * 1.8);
  font-family: var(--font-ui);
  font-weight: var(--w-bold);
  font-size: var(--fs-sm);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #FFFDF6;
  text-shadow: 0 1px 4px rgba(10, 16, 34, .8);
}
/* ---- the survey panel colour ----
   One place sets it, and it is fully opaque in both layouts. Change
   --sv-panel-bg to recolour the panel. */
:root { --sv-panel-bg: #16265C; }
.sv-panel {
  background: var(--sv-panel-bg);
  color: #FFFDF6;
  padding: calc(var(--u) * 3) calc(var(--u) * 3.4);
  display: flex; flex-direction: column;
  overflow-y: auto;
  min-height: 0;
}
.sv-kicker {
  align-self: flex-end;
  font-family: var(--font-ui);
  font-weight: var(--w-bold);
  font-size: var(--fs-sm);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--yellow);
}
.sv-speaker {
  font-family: var(--font-ui);
  font-weight: var(--w-bold);
  font-size: var(--fs-sm);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #7FC7C0;
  margin-top: calc(var(--u) * 1.2);
}
.sv-rule {
  display: flex; align-items: center;
  border-top: max(1px, calc(var(--u) * 0.08)) solid rgba(255, 253, 246, .35);
  margin: calc(var(--u) * 0.7) 0 calc(var(--u) * 1.4);
  position: relative;
}
.sv-rule span {
  position: absolute; left: 22%; top: calc(var(--u) * -0.42);
  width: calc(var(--u) * 0.85); height: calc(var(--u) * 0.85);
  background: var(--yellow);
  transform: rotate(45deg);
}
.sv-title {
  font-family: var(--font-display);
  font-weight: var(--w-body);
  font-size: calc(var(--fs-xl) * 1.06);
  line-height: 1.3;
}
/* The note is an ordinary paragraph. Only the few words named by
   COPY.cover.noteLink inside it are clickable — see .sv-note-link. */
.sv-note {
  margin-top: calc(var(--u) * 1.4);
  font-family: var(--font-ui);
  font-size: var(--fs-sm);
  line-height: 1.55;
  color: rgba(255, 253, 246, .88);
  text-align: left;
}
/* The link itself: a <button> reset back to reading as a run of words
   inside the sentence, and the only part of the note that takes a click. */
.sv-note-link {
  appearance: none;
  display: inline;
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  font-weight: var(--w-bold);
  color: #FFFDF6;
  text-decoration: underline;
  text-underline-offset: .18em;
  cursor: pointer;
}
.sv-note-link:hover { color: var(--yellow); }
.sv-note-link:focus-visible { outline: 2px solid var(--yellow); outline-offset: 2px; }
.sv-actions { margin-top: auto; padding-top: calc(var(--u) * 2); display: flex; flex-direction: column; gap: calc(var(--u) * 1); }
.sv-choice {
  appearance: none;
  background: rgba(255, 253, 246, .06);
  border: max(2px, calc(var(--u) * 0.14)) solid transparent;
  border-radius: calc(var(--u) * 0.5);
  color: #FFFDF6;
  text-align: left;
  font-family: var(--font-ui);
  font-weight: var(--w-med);
  font-size: var(--fs-lg);
  padding: calc(var(--u) * 1.1) calc(var(--u) * 1.4);
  cursor: pointer;
  display: flex; align-items: center; gap: calc(var(--u) * 1.1);
  transition: background .14s ease, border-color .14s ease;
}
.sv-choice::before {
  content: "";
  flex: 0 0 auto;
  width: calc(var(--u) * 0.8); height: calc(var(--u) * 0.8);
  background: var(--yellow);
  transform: rotate(45deg);
}
/* Yes keeps the panel's own glass button — the shape .sv-choice already
   defines — and no ring. The way out drops to plain text, so the two are
   told apart by weight rather than by colour, matching the Skip / Continue
   pair inside the survey. */
.sv-choice.primary { border-color: transparent; background: rgba(255, 253, 246, .06); }
.sv-choice.decline {
  background: none;
  border-color: transparent;
  padding-inline: calc(var(--u) * 0.4);
  font-size: var(--fs-md);
  color: rgba(255, 253, 246, .78);
  text-decoration: underline;
  text-underline-offset: .22em;
}
.sv-choice.decline::before { display: none; }
.sv-choice:hover { background: rgba(255, 253, 246, .14); }
.sv-choice.decline:hover { background: none; color: #FFFDF6; }

/* portrait / narrow: one column, and the clipboard keeps its shape */
@media (max-width: 620px) {
  .sv-cover { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .sv-opts.cols-2, .sv-dual { grid-template-columns: 1fr; }
  /* one column means there is nothing left to flow down, and leaving the
     column flow on would have kept cutting the list into short columns
     that then stacked in the wrong reading order */
  .sv-opts.flow-col { grid-auto-flow: row; grid-template-rows: none; }
}

/* ============================================================
   ENDING / REFLECTION BUTTONS
   Both choices at the end of a run carry equal weight, so neither is
   painted yellow by default. Colour arrives on hover only.
   ============================================================ */
.end-plate .choices { display: flex; flex-direction: column; gap: 10px; }
.end-plate .choice,
.end-plate .choice.continue {
  font-family: var(--font-ui);
  font-weight: var(--w-bold);
  font-size: 15.5px;
  letter-spacing: .01em;
  text-transform: none;
  text-align: center;
  justify-content: center;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 999px;
  color: var(--ink);
}
.end-plate .choice:hover,
.end-plate .choice.continue:hover { background: var(--yellow); }

/* ============================================================
   SHARE — the picture, the link and the platforms, on one page
   Every word: SHARE_COPY in js/engine.js; the picture: SHARE_CARD
   ============================================================
   The window is measured in stage units (--u, 1% of the 16:9 stage), not
   pixels, so it is the same share of the screen on a phone as on a big
   monitor: half the stage wide, and short enough that the picture, the
   link and the three buttons all fit without scrolling. Pixel floors
   only keep the smallest phone's text readable, and the picture is the
   one thing that gives way if a screen is shorter still.

   The rules are scoped to #share-veil so a done Copy stays yellow even
   where the touch rules repaint a hovered button. */
#share-veil {
  position: fixed; inset: 0; z-index: 320;
  display: flex; align-items: center; justify-content: center;
  padding: calc(var(--u) * 2);
  background: rgba(10, 16, 34, .58);
  opacity: 0; transition: opacity .2s ease;
}
#share-veil.open { opacity: 1; }
#share-veil .share-panel {
  display: flex; flex-direction: column;
  width: calc(var(--u) * 50);
  max-width: 100%;
  max-height: 100%;
  overflow: hidden;
  background: var(--paper);
  border: max(2px, calc(var(--u) * 0.2)) solid var(--ink);
  border-radius: calc(var(--u) * 1.4);
  padding: calc(var(--u) * 1.5) calc(var(--u) * 1.7) calc(var(--u) * 1.3);
  box-shadow: 0 calc(var(--u) * 1.4) calc(var(--u) * 4) rgba(10, 16, 34, .45);
  transform: translateY(calc(var(--u) * 0.8));
  transition: transform .2s ease;
}
#share-veil.open .share-panel { transform: none; }
#share-veil .share-head {
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: calc(var(--u) * 0.8);
  border-bottom: max(1.5px, calc(var(--u) * 0.16)) solid var(--ink);
  margin-bottom: calc(var(--u) * 1.1);
}
#share-veil .share-title {
  font-family: var(--font-display);
  font-size: max(15px, calc(var(--u) * 1.9));
  line-height: 1;
}
#share-veil .share-x {
  appearance: none; background: none; border: none;
  font-size: max(20px, calc(var(--u) * 2.4)); line-height: 1;
  color: var(--ink-2);
  cursor: pointer;
  padding: 0 calc(var(--u) * 0.3);
}
#share-veil .share-x:hover { color: var(--ink); }

/* the picture: the Luna Bay picture with the result and the character
   over it, built from the real files so it shows on every browser. Every
   size inside is a share of the card's width (cqw) handed over by
   shareCardHtml() from SHARE_CARD, so it matches the drawn file exactly. */
#share-veil .share-shot {
  flex: 0 0 auto;
  margin: 0;
}
#share-veil .share-card {
  container-type: inline-size;
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #7CC3E8;
  border: max(1.5px, calc(var(--u) * 0.16)) solid var(--ink);
  border-radius: calc(var(--u) * 0.9);
  user-select: none;
}
#share-veil .share-card-bg {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
}
#share-veil .share-card-who {
  position: absolute;
  top: var(--fig-t); right: var(--fig-r);
  height: var(--fig-h); width: auto;
  filter: drop-shadow(0 .5cqw 1.8cqw rgba(10, 16, 34, .3));
}
#share-veil .share-card-text {
  position: absolute;
  left: var(--x); top: var(--y);
  width: var(--w);
  box-sizing: border-box;
  padding: var(--pad);
  background: var(--panel);
  border-radius: var(--r);
  box-shadow: 0 .67cqw 2.5cqw rgba(10, 16, 34, .22);
  color: var(--ink);
  text-align: left;
}
#share-veil .share-card-brand {
  font-family: var(--font-ui); font-weight: 700;
  font-size: var(--brand); line-height: 1.2;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#share-veil .share-card-type {
  font-family: var(--font-display); font-weight: 400;
  font-size: var(--type); line-height: 1.25;
  color: var(--type-ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#share-veil .share-card-story {
  margin: 0;
  font-family: var(--font-ui); font-weight: 500;
  font-size: var(--story); line-height: var(--line);
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: var(--lines); line-clamp: var(--lines);
  overflow: hidden;
}

/* the link and Copy */
#share-veil .share-row {
  flex: 0 0 auto;
  display: flex; gap: calc(var(--u) * 0.8); align-items: stretch;
  margin-top: calc(var(--u) * 1.1);
}
#share-veil .share-url {
  flex: 1 1 auto;
  min-width: 0;
  height: max(30px, calc(var(--u) * 3.3));
  padding: 0 calc(var(--u) * 1);
  font-family: var(--font-ui);
  font-weight: var(--w-med);
  font-size: max(11px, calc(var(--u) * 1.12));
  color: var(--ink);
  background: var(--cream);
  border: max(1.5px, calc(var(--u) * 0.16)) solid var(--ink);
  border-radius: calc(var(--u) * 0.8);
}
#share-veil .share-url:focus { outline: 2px solid var(--yellow); outline-offset: 1px; }
#share-veil .share-copy {
  flex: 0 0 auto;
  min-width: calc(var(--u) * 8);
  height: max(30px, calc(var(--u) * 3.3));
  padding: 0 calc(var(--u) * 1.4);
  appearance: none;
  font-family: var(--font-ui);
  font-weight: var(--w-bold);
  font-size: max(11.5px, calc(var(--u) * 1.15));
  background: var(--paper);
  color: var(--ink);
  border: max(1.5px, calc(var(--u) * 0.16)) solid var(--ink);
  border-radius: calc(var(--u) * 0.8);
  cursor: pointer;
}
#share-veil .share-copy:hover { background: var(--yellow); }
/* copied: filled yellow like the game's other done buttons, for good */
#share-veil .share-copy.done,
#share-veil .share-copy.done:hover { background: var(--yellow); }

/* the platforms: three buttons, one row, the same width each */
#share-veil .share-to {
  flex: 0 0 auto;
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: calc(var(--u) * 0.9);
  margin-top: calc(var(--u) * 0.9);
}
#share-veil .share-btn {
  appearance: none;
  height: max(32px, calc(var(--u) * 3.5));
  padding: 0 calc(var(--u) * 0.8);
  font-family: var(--font-ui);
  font-weight: var(--w-bold);
  font-size: max(12px, calc(var(--u) * 1.25));
  color: var(--ink);
  background: var(--paper);
  border: max(2px, calc(var(--u) * 0.16)) solid var(--ink);
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}
#share-veil .share-btn:hover { background: var(--yellow); }
/* a finger leaves a "hover" behind after a tap; only Copied stays yellow */
@media (hover: none), (pointer: coarse) {
  #share-veil .share-copy:not(.done):hover,
  #share-veil .share-btn:hover { background: var(--paper); }
}

/* what a platform button did, in one line — nothing at all until then */
#share-veil .share-note:empty { display: none; }
#share-veil .share-note {
  flex: 0 0 auto;
  margin-top: calc(var(--u) * 0.7);
  font-family: var(--font-ui);
  font-weight: var(--w-med);
  font-size: max(10.5px, calc(var(--u) * 1));
  line-height: 1.35;
  color: var(--ink-2);
  text-align: center;
}

/* ---- landscape: the photo game's tray was sized for a phone column ---- */
.mg-photo-tray { gap: calc(var(--u) * 0.8); margin-top: calc(var(--u) * 0.9); }
.polaroid { width: calc(var(--u) * 7.4); padding: calc(var(--u) * 0.4); border-radius: calc(var(--u) * 0.25); }
.polaroid .cap { font-size: var(--fs-xs); }

/* ---- landscape: side-panel games ----
   The viewfinder and the roof-marks board both carry a list of results
   under them. Stacked, that list ate more than a third of the height and
   left the stage itself far too short. In landscape the panel moves
   beside the stage, so the stage takes the full height of the host. */
.mg-wrap:has(.mg-photo-tray) .mg-host,
.mg-wrap:has(.mk-list) .mg-host {
  flex-direction: row;
  align-items: stretch;
  gap: calc(var(--u) * 1.6);
}
.mg-wrap:has(.mg-photo-tray) .mg-stage,
.mg-wrap:has(.mk-list) .mg-stage {
  flex: 0 1 auto;
  height: 100%;
  width: auto;
  margin: 0;
}
.mg-side {
  flex: 0 0 auto;
  width: calc(var(--u) * 26);
  display: flex; flex-direction: column;
  justify-content: center;
  gap: calc(var(--u) * 0.8);
  min-width: 0;
}
.mg-side .mg-photo-tray { flex-wrap: wrap; justify-content: flex-start; margin: 0; }
.mg-side .mg-btnrow { margin: 0; justify-content: flex-start; }
.mg-side .mg-note, .mg-side .mg-keys { text-align: left; margin: 0; }
.mg-side .mk-list { margin: 0; }

/* ============================================================
   CHARACTER BRIEF — one full-screen picture per sentence
   Artwork paths live in INTRO_BEATS in js/engine.js. Every slide is the
   character's own: no shared opening frame, and no portrait beside the
   picture. Until a file exists the placeholder shows, labelled with the
   path to create, so dropping the asset in is the only step needed.
   ============================================================ */
.intro-art {
  position: absolute; inset: 0;
  z-index: 0;
  overflow: hidden;
  background: var(--wash);
}
.intro-img, .intro-ph {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  animation: paraIn .45s ease;
}
.intro-img { object-fit: cover; display: block; }
.intro-ph { display: none; align-items: center; justify-content: center; }
/* the placeholder only appears when there is no picture to show */
.intro-art.missing .intro-img { display: none; }
.intro-art.missing .intro-ph { display: flex; }
.intro-ph svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.intro-ph-tag {
  position: relative;
  display: flex; flex-direction: column; align-items: center;
  gap: calc(var(--u) * 0.5);
  padding: calc(var(--u) * 1.6) calc(var(--u) * 2.4);
  background: rgba(255, 253, 246, .92);
  border: max(2px, calc(var(--u) * 0.16)) dashed var(--ink-2);
  border-radius: calc(var(--u) * 0.9);
  text-align: center;
  max-width: 80%;
}
.ph-mark {
  font-family: var(--font-ui);
  font-weight: var(--w-bold);
  font-size: var(--fs-lg);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink);
}
.ph-path {
  font-family: var(--font-ui);
  font-weight: var(--w-med);
  font-size: var(--fs-sm);
  color: var(--ink-2);
  word-break: break-all;
}
.ph-n {
  font-family: var(--font-ui);
  font-weight: var(--w-label);
  font-size: var(--fs-xs);
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-2);
}

/* ============================================================
   REFLECTION — one measure for the whole page
   The description, every question and both buttons share a width, so
   the column reads as one block instead of three.
   ============================================================ */
/* One measure for the column. A ch value would drift, because ch is
   relative to each element's own font — the description, the questions and
   the buttons all set different ones. */
.reflect-plate { --refl-w: calc(var(--u) * 54); }
.reflect-plate .choices {
  width: 100%;
  max-width: var(--refl-w);
  margin-left: auto;
  margin-right: auto;
}

/* the shake order is a one-shot: once given — or once the time is up —
   its button leaves the screen and the end panel opens */
.sk-btn.gone { display: none; }

/* ============================================================
   PHOTO — the five subjects breathe until they are captured
   A slow double pulse marks what still needs photographing, so the
   goal is visible rather than guessed at. It stops on capture.
   ============================================================ */
.ph-ring {
  fill: none;
  stroke: var(--red);
  stroke-width: 3;
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
  animation: phBreath 2.4s ease-in-out infinite;
}
.ph-ring-2 { animation-delay: 1.2s; }
.ph-mark.shot .ph-ring { animation: none; opacity: 0; }
@keyframes phBreath {
  0%   { opacity: 0;   transform: scale(.72); }
  35%  { opacity: .85; transform: scale(1); }
  70%  { opacity: 0;   transform: scale(1.28); }
  100% { opacity: 0;   transform: scale(1.28); }
}
@media (prefers-reduced-motion: reduce) {
  .ph-ring { animation: none; opacity: .5; }
  .ph-mark.shot .ph-ring { opacity: 0; }
}

/* ============================================================
   MINIGAME CHROME — skip, control hint, packing size
   ============================================================ */
/* Bottom right of the canvas, and a child of #scene rather than of the
   scrolling .mg-wrap, so it neither drifts with the content nor lands on
   the game's own controls. It is removed the moment a game finishes. */
.mg-skip {
  position: absolute;
  bottom: calc(var(--u) * 1.6); right: calc(var(--u) * 1.9);
  z-index: 30;
  appearance: none;
  font-family: var(--font-ui);
  font-weight: var(--w-bold);
  font-size: var(--fs-sm);
  letter-spacing: .04em;
  color: #FFFDF6;
  background: rgba(10, 16, 34, .5);
  border: max(2px, calc(var(--u) * 0.13)) solid rgba(255, 253, 246, .6);
  border-radius: 999px;
  padding: calc(var(--u) * 0.45) calc(var(--u) * 1.4);
  min-height: max(34px, calc(var(--u) * 3.4));   /* a thumb-sized target */
  min-width: max(74px, calc(var(--u) * 8));
  cursor: pointer;
}
.mg-skip:hover { background: rgba(10, 16, 34, .8); border-color: #FFFDF6; }
.mg-wrap { position: relative; }

/* the control line sits with the goal and is written for the device */
.mg-controls-note {
  text-align: center;
  font-family: var(--font-ui);
  font-weight: var(--w-med);
  font-size: var(--fs-sm);
  color: #FFFDF6;
  opacity: .92;
  margin: calc(var(--u) * -0.4) auto calc(var(--u) * 0.8);
  max-width: calc(var(--u) * 62);
  text-shadow: 0 calc(var(--u) * 0.1) calc(var(--u) * 0.5) rgba(6, 10, 24, .8);
}

/* packing: bigger type across the board */
.bag-item .bi-name { font-size: calc(var(--fs-md) * 1.12); }
.bag-item .bi-note { font-size: var(--fs-sm); }
.bag-bag .bb-head { font-size: var(--fs-md); }
.bag-slot { width: calc(var(--u) * 4.4); height: calc(var(--u) * 4.4); }
.bag-slot svg { width: 74%; height: 74%; }

/* ---- portrait swap: the go-bag, or a per-node variant ----
   Both work the same way. The new figure sits over the ordinary one; if
   its file is missing, `nobag` (the bag) or `novar` (a node's variant —
   PORTRAIT_VARIANTS in js/scenes.js) drops it, the ordinary portrait
   shows through, and a chip names the file that is wanted. */
.portrait-swap { position: absolute; inset: 0; pointer-events: none; }
.portrait-swap .fallback, .portrait-swap .portrait-ph { display: none; }
.portrait-swap.nobag .scene-portrait:not(.fallback),
.portrait-swap.novar .scene-portrait:not(.fallback) { display: none; }
.portrait-swap.nobag .fallback,
.portrait-swap.novar .fallback { display: block; }
.portrait-swap.nobag .portrait-ph,
.portrait-swap.novar .portrait-ph {
  display: block;
  position: absolute;
  right: calc(var(--u) * 1.4); bottom: calc(var(--u) * 10);
  z-index: 12;
  font-family: var(--font-ui);
  font-weight: var(--w-bold);
  font-size: var(--fs-xs);
  letter-spacing: .08em;
  text-transform: uppercase;
  text-align: center;
  color: var(--ink);
  background: rgba(255, 253, 246, .94);
  border: max(2px, calc(var(--u) * 0.14)) dashed var(--ink-2);
  border-radius: calc(var(--u) * 0.6);
  padding: calc(var(--u) * 0.5) calc(var(--u) * 0.9);
}
.portrait-swap .portrait-ph small { font-weight: var(--w-med); text-transform: none; letter-spacing: 0; }

/* ============================================================
   INFORMATION PAGE — [PLACEHOLDER]
   ============================================================ */
.info-screen {
  position: relative; z-index: 10;
  height: 100%;
  display: flex; align-items: center; justify-content: center;
  padding: calc(var(--u) * 3) calc(var(--u) * 4);
  overflow-y: auto; min-height: 0;
}
.info-card {
  position: relative;
  width: 100%; max-width: calc(var(--u) * 72);
  background: var(--paper);
  border: max(2px, calc(var(--u) * 0.16)) solid var(--ink);
  border-radius: calc(var(--u) * 1.4);
  padding: calc(var(--u) * 3) calc(var(--u) * 3.4);
  box-shadow: 0 calc(var(--u) * 0.8) calc(var(--u) * 2.4) rgba(20, 26, 40, .22);
}
.info-ph {
  position: absolute; top: calc(var(--u) * -1.1); left: calc(var(--u) * 2.4);
  font-family: var(--font-ui);
  font-weight: var(--w-bold);
  font-size: var(--fs-xs);
  letter-spacing: .12em;
  text-transform: uppercase;
  background: var(--yellow);
  border: max(2px, calc(var(--u) * 0.14)) solid var(--ink);
  border-radius: 999px;
  padding: calc(var(--u) * 0.28) calc(var(--u) * 1.1);
}
.info-eyebrow {
  font-family: var(--font-ui);
  font-weight: var(--w-label);
  font-size: var(--fs-sm);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.info-title {
  font-family: var(--font-display);
  font-weight: var(--w-body);
  font-size: var(--fs-xl);
  line-height: 1.15;
  margin: calc(var(--u) * 0.5) 0 calc(var(--u) * 1.4);
}
.info-points { list-style: none; display: flex; flex-direction: column; gap: calc(var(--u) * 0.9); }
.info-points li {
  font-family: var(--font-ui);
  font-weight: var(--w-med);
  font-size: var(--fs-md);
  line-height: 1.6;
  padding-left: calc(var(--u) * 1.6);
  position: relative;
}
.info-points li::before {
  content: "";
  position: absolute; left: 0; top: calc(var(--u) * 0.65);
  width: calc(var(--u) * 0.7); height: calc(var(--u) * 0.7);
  background: var(--yellow);
  border: max(1.5px, calc(var(--u) * 0.1)) solid var(--ink);
  transform: rotate(45deg);
}
.info-card .choice.continue { margin-top: calc(var(--u) * 2.4); width: 100%; justify-content: center; text-align: center; }

/* intro nav: Back sits beside Next */
.choices.intro-nav { flex-direction: row; gap: calc(var(--u) * 1); }
.intro-nav .intro-back { flex: 0 0 auto; min-width: calc(var(--u) * 12); justify-content: center; text-align: center; background: var(--paper); }
.intro-nav .continue { flex: 1 1 auto; }

/* ============================================================
   ============================================================
   SMALL SCREENS — phones held sideways

   The stage is landscape everywhere, so a phone is a short, wide
   canvas. Three things went wrong there and are fixed here:

     · choice buttons grew with their text until they filled the
       screen and pushed the dialogue up under the status bar
     · the HUD spent its width on a location chip and an event-type
       chip, leaving the meters squeezed
     · long option text set at the desktop size overflowed

   This block must stay last: media queries add no specificity, so
   the phone tier has to come after the immersive rules.
   ============================================================
   ============================================================ */
@media (max-height: 430px), (max-width: 820px) {

  /* ---- HUD: the meters are the only thing worth the width ---- */
  #hud {
    grid-template-columns: auto 1fr auto;
    grid-template-areas: "left meters clock";
    padding: calc(var(--u) * 0.7) calc(var(--u) * 1.2) calc(var(--u) * 0.6) calc(var(--u) * 5.2);
    height: auto;
  }
  /* the meters sit centred now, so the header line has room to stay */
  #hud-stage { display: none; }
  #hud-loc span { max-width: calc(var(--u) * 20); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #hud-left { min-width: 0; }
  #hud-port { width: calc(var(--u) * 3.4); height: calc(var(--u) * 3.4); }
  /* the event-type chip goes too — the dialogue already says what this is */
  .hud-obj { display: none; }
  #hud-meters { max-width: none; gap: calc(var(--u) * 0.5); }

  /* the radar moves up into the space the chip left */
  #hud-clock { align-self: start; }
  .radar { margin-top: 0; width: calc(var(--u) * 15); }
  .radar-tag { font-size: calc(var(--fs-xs) * .92); }

  /* ---- choices: never tall enough to shove the dialogue away ---- */
  .after .choices { gap: calc(var(--u) * 0.6); }
  .after .choice {
    min-height: 0;
    padding: calc(var(--u) * 0.7) calc(var(--u) * 1.1);
    /* long option text steps down rather than growing the button */
    font-size: clamp(10px, calc(var(--u) * 1.22), 15px);
    line-height: 1.3;
    max-height: calc(var(--u) * 9);
    overflow-y: auto;
  }
  /* The helper line on a normal option is noise on a small screen, but
     the reason an option is locked is the whole point of showing it —
     so that one stays, sized to sit inside the button rather than
     stretch it. */
  .choice .sub { display: none; }
  .choice.locked .lock-note {
    display: block;
    font-size: clamp(9px, calc(var(--u) * 1.02), 12px);
    line-height: 1.35;
    margin-top: calc(var(--u) * 0.35);
    /* long reasons wrap and scroll inside the button, never past it */
    max-height: calc(var(--u) * 5.2);
    overflow-y: auto;
    overflow-wrap: anywhere;
  }
  .choice.locked .lock-note::before { font-size: inherit; }
  /* a locked option needs a little more room than a plain one */
  .after .choice.locked { max-height: calc(var(--u) * 13); }

  /* ---- the dialogue keeps its own room ---- */
  .scene-body { padding: calc(var(--u) * 1) calc(var(--u) * 1.6) calc(var(--u) * 1.2); }
  .dlg-box, .paras { max-height: calc(var(--u) * 26); overflow-y: auto; }
  .para { font-size: clamp(11px, calc(var(--u) * 1.3), 16px); line-height: 1.5; }

  /* ---- minigame chrome shrinks with everything else ---- */
  .mg-wrap { padding: calc(var(--u) * 11) calc(var(--u) * 1.2) calc(var(--u) * 1); }
  .mg-goal { font-size: clamp(11px, calc(var(--u) * 1.3), 15px); }
  .mg-controls-note { font-size: clamp(10px, calc(var(--u) * 1.1), 13px); }
  /* narrower, but never below a comfortable tap target */
  .mg-skip {
    padding: calc(var(--u) * 0.35) calc(var(--u) * 1.1);
    bottom: max(10px, calc(var(--u) * 1.2)); right: max(10px, calc(var(--u) * 1.3));
  }

  /* ---- the opening screens stay reachable ---- */
  .info-card { padding: calc(var(--u) * 2) calc(var(--u) * 2.2); }
  .sv-card { padding: calc(var(--u) * 1.8) calc(var(--u) * 2); min-height: 0; }
  .sv-opt { padding: calc(var(--u) * 0.7) calc(var(--u) * 0.3); }
}

/* Very short stages: the dialogue grows to fit its words rather than
   scrolling inside a sliver.

   The picture is NOT hidden here any more. This used to say
   `.art-plate { display: none }`, from when the art was a panel stacked
   above the text and taking its height. It is the full-screen background
   now and takes no room from anything, so hiding it only left the screen
   blank white on any window 380px tall or less — a phone held sideways,
   or a short browser window. */
@media (max-height: 380px) {
  .dlg-box, .paras { max-height: none; }
}

/* ============================================================
   ============================================================
   PASS: header, packing, radio, signs, map, scrolling
   ============================================================
   ============================================================ */

/* ---- 2. Back and Next are the same button, different word ---- */
.choices.intro-nav { flex-direction: row; gap: calc(var(--u) * 1); }
.intro-nav .choice.continue {
  flex: 1 1 0;
  justify-content: center;
  text-align: center;
}
.intro-nav .intro-back { flex: 0 0 calc(var(--u) * 16); }

/* ---- 3/4/5. packing ---- */
/* four across so the whole shelf fits without scrolling */
.bag-shelf { grid-template-columns: repeat(4, 1fr); gap: calc(var(--u) * 0.7); }
.bag-item { padding: calc(var(--u) * 0.7) calc(var(--u) * 0.8); }
/* once zipped nothing on the shelf responds */
.bag-wrap.zipped .bag-item { pointer-events: none; opacity: .55; }
.bag-wrap.zipped .bag-item.packed { opacity: .9; }
/* the shelf note is gone; the control line under the goal carries it */
.bag-hint:empty { display: none; margin: 0; min-height: 0; }

/* ---- 8. radio: set, then the instruction, then the controls ---- */
.mg-stagenote {
  text-align: center;
  font-family: var(--font-ui);
  font-weight: var(--w-med);
  font-size: var(--fs-md);
  line-height: 1.5;
  color: #FFFDF6;
  max-width: calc(var(--u) * 62);
  margin: calc(var(--u) * 1) auto calc(var(--u) * 0.2);
  text-shadow: 0 calc(var(--u) * 0.1) calc(var(--u) * 0.5) rgba(6, 10, 24, .8);
}

/* a bare minigame has no title or goal, so its chrome starts higher */
.mg-wrap.bare { padding-top: calc(var(--u) * 11.5); }
.mg-wrap.bare .mg-controls-note { margin-top: calc(var(--u) * 0.6); }
/* the control line sits under the stage on these, so it comes after */
.mg-wrap.bare .mg-host { order: 0; }
.mg-wrap.bare .mg-stagenote { order: 1; }
.mg-wrap.bare .mg-controls-note { order: 2; }
.mg-wrap.bare .mg-after { order: 3; }


/* ---- 11/12. the map rail clears its own button ---- */
.map-caption { display: none; }
.map-hud { top: calc(var(--u) * 12); bottom: calc(var(--u) * 9); overflow-y: auto; }
.map-foot { z-index: 12; }

/* ---- 13. every full-screen panel scrolls on iOS ----
   The ending and reflection plates had overflow-y but no touch rules, so
   iOS handed the gesture to the locked page behind them and nothing moved. */
.end-plate, .reflect-plate, .info-screen, .sv-screen, .sv-panel,
.title-screen, .select-screen, .chapter-plate, .mg-wrap, .scene-body {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
}

/* ============================================================
   ============================================================
   PASS: intro buttons, meter placement, minigame viewports
   ============================================================
   ============================================================ */

/* ---- 1. Back and Next share the row, half each ----
   `.choices > .choice.continue` spans the whole grid, which is right for a
   lone Continue and wrong for a pair — so the pair opts out. */
.choices.intro-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: calc(var(--u) * 1);
}
.choices.intro-nav > .choice.continue { grid-column: auto; }
.intro-nav .choice.continue {
  width: 100%;
  justify-content: center;
  text-align: center;
}
/* Back is the quieter of the two: it never takes the forward colour */
.intro-nav .intro-back { background: var(--paper); }
.intro-nav .intro-back:hover { background: var(--cream); border-color: var(--ink-2); }

/* ---- 2. the meters sit centred and low enough for their own chips ----
   A +1 rising out of a meter used to clear the top of the screen. The row
   now starts below the header line, and the radar keeps the corner. */
#hud { align-items: flex-start; }
#hud-meters {
  position: absolute;
  top: calc(var(--u) * 3.6);
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
}
#hud-clock {
  top: calc(var(--u) * 1.2);
  right: calc(var(--u) * 1.5);
}

/* ---- 4. the control line is a header, above the game ---- */
.mg-controls-note { order: -1; margin: 0 auto calc(var(--u) * 0.9); }
.mg-wrap.bare .mg-controls-note { order: -1; margin-top: 0; }
/* the radio keeps its instruction under the set */
.mg-wrap:has(.mg-stagenote) .mg-controls-note { order: 2; margin: calc(var(--u) * 0.3) auto 0; }
.mg-wrap:has(.mg-stagenote) .mg-host { order: 0; }
.mg-wrap:has(.mg-stagenote) .mg-stagenote { order: 1; }
.mg-wrap:has(.mg-stagenote) .mg-after { order: 3; }



/* ============================================================
   ============================================================
   THE HEADER — one row, left to right:

       menu · avatar · name · status bar · radar

   This block is last on purpose. Three earlier blocks each laid the
   header out their own way (a two-row grid, a three-area grid, and a
   set of absolutely-positioned pieces) and fought each other. Every
   one of those is neutralised here, so this is the only place the
   header's layout is decided.
   ============================================================
   ============================================================ */
#hud {
  position: absolute; top: 0; left: 0; right: 0;
  z-index: 20;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: calc(var(--u) * 1.4);
  height: auto;
  /* the menu button is absolute at the far left; this clears it */
  padding: calc(var(--u) * 0.8) calc(var(--u) * 1.4) calc(var(--u) * 0.8) calc(var(--u) * 5.8);
  background: none;
  border-bottom: none;
  pointer-events: none;
}
#hud > * { pointer-events: auto; }

/* avatar + the character's name */
#hud-left {
  position: static;
  inset: auto;
  flex: 0 0 auto;
  display: flex; flex-direction: row; align-items: center;
  gap: calc(var(--u) * 0.8);
  margin: 0;
}
#hud-loc {
  display: flex; align-items: center;
  gap: calc(var(--u) * 0.8);
  font-size: var(--fs-md);
  white-space: nowrap;
}
#hud-loc span { max-width: none; overflow: visible; }
#hud-stage { display: none; }
#hud-port {
  flex: 0 0 auto;
  width: calc(var(--u) * 3.4); height: calc(var(--u) * 3.4);
}

/* the status bar takes the middle and centres itself in it */
#hud-meters {
  position: static;
  inset: auto;
  transform: none;
  flex: 1 1 auto;
  min-width: 0;
  justify-content: center;
  margin: 0;
}

/* the radar closes the row, at the size it already had */
#hud-clock {
  position: static;
  inset: auto;
  flex: 0 0 auto;
  align-self: center;
  margin: 0;
}

/* ============================================================
   HEADER — name over the current node
   ============================================================ */
.hud-who { display: flex; flex-direction: column; line-height: 1.15; }
.hud-name {
  font-family: var(--font-ui);
  font-weight: var(--w-bold);
  font-size: var(--fs-md);
  letter-spacing: .1em;
  text-transform: uppercase;
}
.hud-node {
  font-family: var(--font-ui);
  font-weight: var(--w-med);
  font-size: var(--fs-xs);
  letter-spacing: .04em;
  opacity: .75;
  white-space: nowrap;
  max-width: calc(var(--u) * 26);
  overflow: hidden; text-overflow: ellipsis;
}

/* ============================================================
   SKIP-SURVEY CONFIRMATION
   Wording: SURVEY.COPY.confirmSkip in js/survey.js
   ============================================================ */
#sv-confirm {
  position: fixed; inset: 0; z-index: 340;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: rgba(10, 16, 34, .6);
  opacity: 0; transition: opacity .18s ease;
}
#sv-confirm.open { opacity: 1; }
.svc-panel {
  width: 100%; max-width: 460px;
  background: var(--paper);
  border: 2.5px solid var(--ink);
  border-radius: 16px;
  padding: 24px 24px 20px;
  box-shadow: 0 18px 50px rgba(10, 16, 34, .45);
  transform: translateY(8px);
  transition: transform .18s ease;
}
#sv-confirm.open .svc-panel { transform: none; }
.svc-title { font-family: var(--font-display); font-size: 22px; line-height: 1.15; }
.svc-body {
  font-family: var(--font-ui);
  font-weight: var(--w-med);
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--ink-2);
  margin: 10px 0 20px;
}
.svc-actions { display: flex; gap: 10px; }
.svc-btn {
  appearance: none;
  flex: 1 1 0;
  font-family: var(--font-ui);
  font-weight: var(--w-bold);
  font-size: 14.5px;
  padding: 12px 14px;
  border-radius: 999px;
  border: 2px solid var(--ink);
  cursor: pointer;
  color: var(--ink);
  background: var(--paper);
}
.svc-btn.solid { background: var(--yellow); }

/* ============================================================
   "WHY WE ARE ASKING" — opened by the note on the survey cover
   Wording: SURVEY.COPY.cover.why in js/survey.js
   ============================================================ */
#sv-why-modal {
  position: fixed; inset: 0; z-index: 340;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: rgba(10, 16, 34, .6);
  opacity: 0; transition: opacity .18s ease;
}
#sv-why-modal.open { opacity: 1; }
/* ---- one panel, one set of paddings ----
   Top and bottom are the SAME value, and that value is derived from the
   close button rather than guessed at, so the two can never drift apart:
   the top used to be padded to clear the button while the bottom kept a
   smaller number of its own, and the dialog sat visibly low in its own
   box. Every part of it is in pixels, so the two stay equal at every
   screen size — there is no per-device override of any of them. */
.svw-panel {
  --dlg-close: 30px;                /* the close button's box */
  --dlg-inset: 10px;                /* how far it sits from the corner */
  --dlg-pad: calc(var(--dlg-close) + var(--dlg-inset) + 2px);
  position: relative;               /* the close button anchors to this */
  width: 100%; max-width: 460px;
  background: var(--paper);
  border: 2.5px solid var(--ink);
  border-radius: 16px;
  padding: var(--dlg-pad) 28px;
  box-shadow: 0 18px 50px rgba(10, 16, 34, .45);
  transform: translateY(8px);
  transition: transform .18s ease;
}
#sv-why-modal.open .svw-panel { transform: none; }
.svw-close {
  position: absolute;
  top: var(--dlg-inset); right: var(--dlg-inset);
  appearance: none;
  width: var(--dlg-close); height: var(--dlg-close);
  display: flex; align-items: center; justify-content: center;
  background: none;
  border: 2px solid var(--ink);
  border-radius: 50%;
  color: var(--ink);
  cursor: pointer;
  transition: background .14s ease;
}
.svw-close:hover { background: var(--yellow); }
.svw-body {
  font-family: var(--font-ui);
  font-weight: var(--w-med);
  font-size: 14.5px;
  line-height: 1.65;
  color: var(--ink-2);
  text-align: center;
  margin: 0;
}

/* ============================================================
   A SHELF PICTURE, LARGER — opened by clicking the picture on a
   row of the PREP-02 shop. Built in showShopZoom in js/engine.js.

   Same furniture and the same padding rule as the dialog above:
   ONE value on all four sides, derived from the close button so the
   button can never crowd the picture. All of it in pixels, so it is
   equal at every screen size.
   ============================================================ */
#shop-zoom {
  position: fixed; inset: 0; z-index: 340;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: rgba(10, 16, 34, .6);
  opacity: 0; transition: opacity .18s ease;
}
#shop-zoom.open { opacity: 1; }
.sz-panel {
  --dlg-close: 30px;
  --dlg-inset: 10px;
  --dlg-pad: calc(var(--dlg-close) + var(--dlg-inset) + 2px);
  position: relative;
  background: var(--paper);
  border: 2.5px solid var(--ink);
  border-radius: 16px;
  padding: var(--dlg-pad);
  box-shadow: 0 18px 50px rgba(10, 16, 34, .45);
  transform: translateY(8px);
  transition: transform .18s ease;
}
#shop-zoom.open .sz-panel { transform: none; }
.sz-close {
  position: absolute;
  top: var(--dlg-inset); right: var(--dlg-inset);
  appearance: none;
  width: var(--dlg-close); height: var(--dlg-close);
  display: flex; align-items: center; justify-content: center;
  background: none;
  border: 2px solid var(--ink);
  border-radius: 50%;
  color: var(--ink);
  cursor: pointer;
  transition: background .14s ease;
}
.sz-close:hover { background: var(--yellow); }
/* Bounded on both axes so a tall picture cannot outgrow a short screen
   and a wide one cannot outgrow a narrow phone. */
.sz-img {
  display: block;
  width: auto; height: auto;
  max-width: min(62vw, 380px);
  max-height: min(52dvh, 380px);
  object-fit: contain;
}
/* the stand-in for a picture that has not been drawn yet */
.sz-ph { display: none; }
.sz-panel.noart .sz-img { display: none; }
.sz-panel.noart .sz-ph {
  display: flex; align-items: center; justify-content: center;
  width: min(62vw, 240px); height: min(38dvh, 240px);
  padding: 12px;
  text-align: center;
  font-family: var(--font-ui);
  font-weight: var(--w-med);
  font-size: 12px;
  color: var(--ink-2);
  border: 2px dashed var(--ink-2);
  border-radius: 10px;
  background: repeating-linear-gradient(45deg,
    #E6E0CE 0 7px, #F4EFE0 7px 14px);
}

/* ============================================================
   REFERENCE MAPS on the reflection page — a horizontal strip
   ============================================================ */
.map-strip {
  display: flex;
  flex: 0 0 auto;   /* the column must not squeeze the captions away */
  gap: calc(var(--u) * 1.4);
  width: 100%;
  max-width: var(--refl-w);
  margin: 0 auto calc(var(--u) * 2);
  padding-bottom: calc(var(--u) * 0.8);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
}
.map-card {
  flex: 0 0 auto;
  width: calc(var(--u) * 30);
  scroll-snap-align: start;
  background: var(--paper);
  border: max(2px, calc(var(--u) * 0.14)) solid var(--ink);
  border-radius: calc(var(--u) * 0.9);
  overflow: hidden;
  cursor: pointer;
  text-align: left;
  transition: transform .14s ease;
}
.map-card.missing { cursor: default; }
.mc-figure { position: relative; aspect-ratio: 16 / 11; background: var(--wash); }
.mc-figure img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mc-ph {
  display: none;
  position: absolute; inset: 0;
  flex-direction: column; align-items: center; justify-content: center;
  gap: calc(var(--u) * 0.3);
  text-align: center;
  background: repeating-linear-gradient(45deg, var(--wash) 0 8px, rgba(44,54,99,.06) 8px 16px);
  font-family: var(--font-ui);
}
.mc-ph span { font-weight: var(--w-bold); font-size: var(--fs-sm); letter-spacing: .1em; text-transform: uppercase; }
.mc-ph small { font-size: var(--fs-xs); color: var(--ink-2); }
.map-card.missing .mc-figure img { display: none; }
.map-card.missing .mc-ph { display: flex; }
.map-card figcaption {
  padding: calc(var(--u) * 0.9) calc(var(--u) * 1.1) calc(var(--u) * 1.1);
  border-top: max(1px, calc(var(--u) * 0.08)) solid var(--hairline);
  font-family: var(--font-ui);
  font-weight: var(--w-body);
  font-size: var(--fs-sm);
  line-height: 1.45;
  color: var(--ink-2);
}
.map-card figcaption b {
  display: block;
  font-weight: var(--w-bold);
  font-size: var(--fs-md);
  color: var(--ink);
  margin-bottom: calc(var(--u) * 0.3);
}

/* ============================================================
   HOVER — only where a pointer can actually hover

   On a touch screen a tap leaves the last-tapped element stuck in its
   hover state until something else is tapped. Every hover effect is
   turned off there; the active state still gives the press feedback.
   ============================================================ */
@media (hover: none), (pointer: coarse) {
  /* A tap leaves :hover stuck on until something else is tapped, so every
     hover style here restates the element's OWN resting look.

     This used to say `background: inherit`, which was the bug behind the
     Back button turning yellow: inherit takes the parent's background, and
     a transparent parent let the yellow page show straight through the
     button. Nothing here inherits. */
  .choice:hover, .choice:hover:not(.locked) { background: rgba(255, 253, 246, .96); transform: none; }
  .choice.locked:hover { background: var(--grey-wash); }
  .choice.continue:hover { background: var(--yellow); transform: none; }
  .intro-nav .intro-back:hover { background: var(--paper); border-color: var(--ink); }
  .end-plate .choice:hover, .end-plate .choice.continue:hover { background: var(--paper); }
  .sel-card:hover, .haz-card:hover { background: #fff; transform: none; }
  .sv-opt:hover { background: none; }
  .sv-choice:hover, .sv-choice.primary:hover { background: rgba(255, 253, 246, .06); border-color: transparent; }
  .sv-choice.decline:hover { background: none; color: rgba(255, 253, 246, .78); }
  .shop-item:hover:not(.cant) { background: none; }
  .bag-item:hover { background: #fff; }
  .map-card:hover { transform: none; }
  .mg-bigbtn:hover, .sk-btn:hover { background: var(--yellow); }
  .mg-skip:hover { background: rgba(10, 16, 34, .5); border-color: rgba(255, 253, 246, .6); }
  .sv-go:hover:not(:disabled) { background: var(--yellow); }
  .sv-skip:hover { background: none; color: var(--ink-2); }
  .sv-back:hover, .svc-btn:hover { background: var(--paper); }
  .svc-btn.solid:hover { background: var(--yellow); }
  /* a press still reads */
  .choice:active:not(.locked) { transform: translateY(1px); }
}

/* ============================================================
   MAP PAGE — a titled page, not a captioned panel
   ============================================================ */
.map-title {
  font-family: var(--font-display);
  font-weight: var(--w-body);
  font-size: calc(var(--fs-xl) * 1.15);
  line-height: 1.1;
  color: #FFFDF6;
  text-shadow: 0 calc(var(--u) * 0.15) calc(var(--u) * 0.8) rgba(6, 10, 24, .85);
  margin-bottom: calc(var(--u) * 1.4);
  background: none;
  padding: 0;
}
/* the chosen place names itself above its description */
.mp-name {
  font-family: var(--font-ui);
  font-weight: var(--w-bold);
  font-size: var(--fs-lg);
  line-height: 1.2;
  color: var(--ink);
  margin-bottom: calc(var(--u) * 0.5);
}
/* the button matches the panel above it */
.map-foot .choice, .map-foot .choice.continue {
  width: 100%;
  justify-content: center;
  text-align: center;
}

/* the Go there button spans the same column as the panel above it */
.map-foot { width: calc(var(--u) * 27); }
.map-foot .choice, .map-foot .choice.continue {
  width: 100%;
  justify-content: center;
  text-align: center;
}

/* ============================================================
   MINIGAMES ON A SMALL SCREEN

   The packing shelf and the viewfinder both carry controls under or
   beside the stage. On a short screen those fell past the bottom edge
   with no way to reach them. Each game scrolls inside its own wrap,
   and the stage gives up height first so the buttons stay on screen.
   ============================================================ */
@media (max-height: 430px), (max-width: 820px) {
  /* The wrap is the scroller. The host has to stop clipping and stop
     shrinking, or it swallows the overflow and the wrap never learns
     there is anything below the fold. */
  .mg-wrap { overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .mg-host {
    flex: 0 0 auto;
    min-height: 0;
    overflow: visible;
    justify-content: flex-start;
  }

  /* ---- packing ---- */
  .bag-wrap { display: flex; flex-direction: column; gap: calc(var(--u) * 0.8); }
  .bag-shelf { gap: calc(var(--u) * 0.6); }
  .bag-item { padding: calc(var(--u) * 0.7) calc(var(--u) * 0.8); }
  .bag-item .bi-name { font-size: clamp(11px, calc(var(--u) * 1.28), 15px); }
  .bag-slot { width: calc(var(--u) * 3.6); height: calc(var(--u) * 3.6); }
  /* the zip button always stays reachable at the end of the scroll */
  .bag-wrap .mg-btnrow { padding-bottom: calc(var(--u) * 1.2); }

  /* ---- photo ----
     Stays side by side on a phone too: viewfinder left, the five frames
     right in two rows, Snap under them. */
  .mg-side { width: calc(var(--u) * 24); padding-bottom: calc(var(--u) * 1.2); }
  .polaroid { width: calc(var(--u) * 6.6); }
}

/* ============================================================
   PHOTO — viewfinder left, frames right in two rows, Snap below
   ============================================================ */
.mg-wrap:has(.mg-photo-tray) .mg-host { flex-direction: row; align-items: stretch; }
.mg-side .mg-photo-tray {
  display: grid;
  grid-template-columns: repeat(3, 1fr);   /* five frames land 3 + 2 */
  gap: calc(var(--u) * 0.6);
  justify-items: center;
  margin: 0;
}
.mg-side .polaroid { width: 100%; }
/* Snap centres under the frames, but shifted clear of the Skip button,
   which now holds the bottom right corner of the canvas. */
.mg-side .mg-btnrow {
  justify-content: center;
  margin-top: calc(var(--u) * 1);
  padding-right: calc(var(--u) * 9);
}

/* ============================================================
   PACKING SHELF — four square tiles to a row, centred

   The shelf used to stretch to the full canvas, which made each item a
   wide, short letterbox and pushed the bag and the Zip button below the
   fold. It is capped and centred instead, and each tile is a square, so
   eight items still come to two rows that fit one screen at every size.
   ============================================================ */
.bag-shelf {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  width: min(100%, calc(var(--u) * 37));
  margin-inline: auto;
  gap: calc(var(--u) * 0.7);
}
.bag-item {
  aspect-ratio: 1 / 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: calc(var(--u) * 0.25);
  padding: calc(var(--u) * 0.5);
  text-align: center;
  overflow: hidden;             /* a long note can never stretch the square */
  transform: none;              /* the packed state shrinks it; nothing else */
}
.bag-item.packed { transform: scale(.94); }
/* A square tile can be narrower than the longest label, so the label
   breaks inside the word rather than being clipped by the edge — but only
   when it actually has to. `anywhere` counted those break points when
   sizing the box and split words that had room; `break-word` leaves the
   measurement alone, and the full-width line box gives it that room. */
.bag-item .bi-name {
  width: 100%;
  /* sized to the tile it sits in, not to the page: at the old body size a
     one-word label ran wider than its own square */
  font-size: clamp(11px, calc(var(--u) * 1.35), 17px);
  line-height: 1.2;
  overflow-wrap: break-word;
  hyphens: auto;
}
.bag-item .bi-note {
  margin-top: 0;
  font-size: clamp(9px, calc(var(--u) * 1), 12px);
  line-height: 1.25;
}
/* the bag sits directly under the shelf and shares its width, so the two
   read as one column rather than a grid floating on a wide tray */
.bag-bag { width: min(100%, calc(var(--u) * 37)); margin-inline: auto; }

/* ============================================================
   CHARACTER SELECT — five slanted panels

   Four parallel diagonals cut the canvas into five full-height
   parallelograms. Each panel is one band wide plus half a slant on each
   side, pulled back by a negative margin, so the cut edges meet exactly
   and no seam or gap shows between them. The two outer panels keep a
   straight edge against the frame so the corners stay filled.
   ============================================================ */
.pick-screen {
  --slant: calc(var(--u) * 5.5);
  position: absolute; inset: 0;
  padding: 0;
  overflow: hidden;
}
.pick-rail {
  display: flex;
  height: 100%;
  overflow: hidden;
}
.pick-panel {
  flex: 1 1 0;
  min-width: 0;
  position: relative;
  margin-inline: calc(var(--slant) / -2);
  cursor: pointer;
  background: linear-gradient(to bottom,
              color-mix(in srgb, var(--tint) 45%, #FFFDF6) 0%,
              var(--tint) 100%);
  clip-path: polygon(var(--slant) 0, 100% 0, calc(100% - var(--slant)) 100%, 0 100%);
  transition: filter .18s ease;
  -webkit-tap-highlight-color: transparent;   /* no grey flash on tap */
}
/* the outer two square off against the frame */
.pick-panel.first { clip-path: polygon(0 0, 100% 0, calc(100% - var(--slant)) 100%, 0 100%); }
.pick-panel.last  { clip-path: polygon(var(--slant) 0, 100% 0, 100% 100%, 0 100%); }

/* the hairline that reads as the cut */
.pick-panel::after {
  content: "";
  position: absolute; inset: 0;
  pointer-events: none;
  border-left: max(2px, calc(var(--u) * 0.16)) solid var(--ink);
  clip-path: inherit;
}
.pick-panel.first::after { border-left: none; }

/* the figure stands at the foot of the panel */
.pk-art {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 62%;
  background-repeat: no-repeat;
  background-position: bottom center;
  background-size: contain;
  pointer-events: none;
}
.pk-q {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: calc(var(--u) * 22);
  line-height: 1;
  color: rgba(44, 54, 99, .3);
}

.pk-body {
  position: relative; z-index: 2;
  height: 100%;
  display: flex; flex-direction: column;
  gap: calc(var(--u) * 0.8);
  /* The slant eats into the left of every panel at the top, so the text is
     inset past it. The top inset clears the Back button, which floats over
     the first panel — every panel takes the same one so the names line up
     across the screen. */
  padding: calc(var(--u) * 5.8) calc(var(--u) * 1.5) calc(var(--u) * 2);
  padding-left: calc(var(--u) * 1.5 + var(--slant));
  text-align: left;
}
/* the outer panels are cut off square, and their boxes hang half a slant
   past the frame, so their gutters are measured differently */
.pick-panel.first .pk-body { padding-left: calc(var(--u) * 1.5 + var(--slant) / 2); }
.pick-panel.last .pk-body { padding-right: calc(var(--u) * 1.5 + var(--slant) / 2); }
.pk-name {
  font-family: var(--font-display);
  font-size: calc(var(--fs-lg) * 1.15);
  line-height: 1.05;
  color: var(--ink);
}
.pk-intro {
  font-family: var(--font-ui);
  font-weight: var(--w-med);
  font-size: var(--fs-sm);
  line-height: 1.4;
  color: var(--ink);
  opacity: .88;
}
.pk-cta {
  margin-top: auto;
  align-self: flex-start;
  appearance: none;
  font-family: var(--font-ui);
  font-weight: var(--w-bold);
  font-size: var(--fs-md);
  color: var(--ink);
  background: var(--yellow);
  border: max(2px, calc(var(--u) * 0.16)) solid var(--ink);
  border-radius: 999px;
  padding: calc(var(--u) * 0.7) calc(var(--u) * 2);
  min-height: max(34px, calc(var(--u) * 3.4));
  box-shadow: 0 calc(var(--u) * 0.25) 0 var(--ink);
  cursor: pointer;
}
/* a run already finished announces itself in the button, quietly */
.pick-panel.is-again .pk-cta { background: var(--paper); }

.pick-back {
  position: absolute;
  top: calc(var(--u) * 1.4); left: calc(var(--u) * 1.6);
  z-index: 20;
  appearance: none;
  font-family: var(--font-ui);
  font-weight: var(--w-bold);
  font-size: var(--fs-sm);
  letter-spacing: .04em;
  color: var(--ink);
  background: var(--paper);
  border: max(2px, calc(var(--u) * 0.14)) solid var(--ink);
  border-radius: 999px;
  padding: calc(var(--u) * 0.5) calc(var(--u) * 1.4);
  min-height: max(32px, calc(var(--u) * 3.2));
  cursor: pointer;
}
.pk-cta, .pick-back { -webkit-tap-highlight-color: transparent; }

/* the select screen is its own full-bleed composition */
#scene:has(.pick-screen) { background: var(--paper); }
#scene:has(.pick-screen)::after { background: none; }

/* HOVER — stated only where a pointer can really hover.
   Turning hover OFF for touch leaves the effect defined and relies on a
   later rule undoing it, which is one stylesheet edit away from coming
   back. Stated this way round, a touch device never matches the rule at
   all, so there is nothing to undo. */
@media (hover: hover) and (pointer: fine) {
  .pick-panel:hover { filter: brightness(1.06); }
  .pk-cta:hover { background: #FFE45C; }
  .pick-panel.is-again .pk-cta:hover { background: var(--cream); }
  .pick-back:hover { background: var(--cream); }
}

/* ============================================================
   MOBILE — a safe strip along the bottom edge

   The dialogue, the portrait and the Continue button all sat hard
   against the bottom of the canvas, where a phone's own home bar and
   gesture strip live. The dialogue column is bottom-aligned, so one
   deeper bottom padding lifts the box and its buttons together; the
   portrait is lifted by the same amount so it still stands on the same
   line as the text.
   ============================================================ */
@media (max-height: 430px), (max-width: 820px) {
  :root { --safe-bottom: max(calc(var(--u) * 3.4), calc(14px + env(safe-area-inset-bottom))); }

  .scene-body { padding-bottom: var(--safe-bottom); }
  .scene-portrait { bottom: var(--safe-bottom); height: 68%; }
  /* the map screen's own footer button gets the same clearance */
  .map-foot { padding-bottom: var(--safe-bottom); }
  /* and so does a minigame's Continue, which prints inside the wrap */
  .mg-wrap { padding-bottom: var(--safe-bottom); }
  .mg-skip { bottom: var(--safe-bottom); }
  /* the veil under the dock follows the box up rather than staying put */
  .dlg-dock::before { bottom: calc(var(--u) * -1.2); }
  /* the pick screen's Play buttons sit on the same line as everything else */
  .pk-body { padding-bottom: var(--safe-bottom); }
}

/* ============================================================
   PACKING ON A SHORT SCREEN — the whole beat on one page

   The shelf, the bag, the clock and Zip all have to be visible at once:
   a player who has to scroll to find Zip is playing a different game.
   These are the tightenings that buy the room, in the order they cost
   the least legibility.
   ============================================================ */
@media (max-height: 430px), (max-width: 820px) {
  /* the header is far shorter here than the shared top padding assumes */
  .mg-wrap:has(.bag-wrap) { padding-top: calc(var(--u) * 6.6); }
  .bag-wrap { gap: calc(var(--u) * 0.5); }
  .bag-bag { padding: calc(var(--u) * 0.6) calc(var(--u) * 1); }
  .bag-bag .bb-head { margin-bottom: calc(var(--u) * 0.4); }
  .bag-slots { gap: calc(var(--u) * 0.5); }
  .bag-slot { width: calc(var(--u) * 3.1); height: calc(var(--u) * 3.1); }
  .bag-wrap .mg-count { margin: 0; }
  .bag-wrap .mg-btnrow { padding-bottom: 0; margin-top: 0; }
  .bag-wrap .mg-bigbtn {
    width: auto; height: auto;
    min-height: max(38px, calc(var(--u) * 5));
    border-radius: 999px;
    padding: calc(var(--u) * 0.7) calc(var(--u) * 3);
  }
  /* four squares still, just a shade smaller than the desktop shelf */
  .bag-shelf, .bag-bag { width: min(100%, calc(var(--u) * 33)); }
}

/* ============================================================
   STAGE VIDEO — a clip as the bridge between two stages

   The clip owns the canvas: no HUD, no meters, no vignette, nothing but
   the picture and the menu button. Continue arrives in the bottom right
   when the clip has run, in the same corner Skip holds elsewhere, so the
   way on is always found in the same place.
   ============================================================ */
.video-screen { position: absolute; inset: 0; background: #05070E; }
.vid-el {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  /* the whole frame, letterboxed — a clip is never cropped to fit */
  object-fit: contain;
  background: #05070E;
  display: block;
}
/* no page furniture while a clip is running */
#scene:has(.video-screen) { background: #05070E; }
#scene:has(.video-screen)::after { background: none; }

.vid-go {
  position: absolute;
  bottom: calc(var(--u) * 2.4); right: calc(var(--u) * 2.4);
  z-index: 30;
  appearance: none;
  font-family: var(--font-ui);
  font-weight: var(--w-bold);
  font-size: var(--fs-md);
  color: var(--ink);
  background: var(--yellow);
  border: max(2px, calc(var(--u) * 0.16)) solid var(--ink);
  border-radius: 999px;
  padding: calc(var(--u) * 0.8) calc(var(--u) * 2.6);
  min-height: max(38px, calc(var(--u) * 3.8));
  box-shadow: 0 calc(var(--u) * 0.28) 0 var(--ink);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  animation: vidGoIn .32s ease both;
}
@keyframes vidGoIn {
  from { opacity: 0; transform: translateY(calc(var(--u) * 1.2)); }
  to   { opacity: 1; transform: none; }
}

/* shown only when the browser refuses to start the clip on its own */
.vid-play {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 30;
  appearance: none;
  width: calc(var(--u) * 9); height: calc(var(--u) * 9);
  min-width: 62px; min-height: 62px;
  border-radius: 50%;
  border: max(2px, calc(var(--u) * 0.16)) solid var(--ink);
  background: var(--yellow);
  color: var(--ink);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.vid-play svg { width: 62%; height: 62%; }

@media (max-height: 430px), (max-width: 820px) {
  .vid-go { bottom: var(--safe-bottom); right: max(12px, calc(var(--u) * 1.6)); }
}
@media (hover: hover) and (pointer: fine) {
  .vid-go:hover, .vid-play:hover { background: #FFE45C; }
}

/* ============================================================
   VERSION STAMP — bottom left of the canvas, on every screen

   It lives outside #scene so no screen has to draw it. The bottom left
   of this game runs from cream paper to a black video frame depending on
   the page, so the label carries its own whisper of a backing rather
   than trying to pick a text colour that reads on both.

   It sits in the strip the dialogue and its buttons already keep clear
   at the foot of the canvas, and is inert to clicks.
   ============================================================ */
#version {
  position: absolute;
  left: calc(var(--u) * 1.2);
  bottom: calc(var(--u) * 0.75);
  z-index: 40;
  pointer-events: none;
  user-select: none;
  font-family: var(--font-ui);
  font-weight: var(--w-label);
  font-size: clamp(9px, calc(var(--u) * 0.95), 11px);
  letter-spacing: .09em;
  line-height: 1;
  color: rgba(255, 253, 246, .8);
  background: rgba(10, 16, 34, .3);
  border-radius: 999px;
  padding: calc(var(--u) * 0.34) calc(var(--u) * 0.72);
}
@media (max-height: 430px), (max-width: 820px) {
  /* into the safe strip the rest of the mobile layout was lifted out of */
  #version { left: max(7px, calc(var(--u) * 1)); bottom: max(5px, calc(var(--u) * 0.6)); }
}

/* ============================================================
   CHARACTER SELECT — the actions inside a panel

   Continue and Start Again stack: the button first, the way to throw
   the run away underneath it as text, so the two are never mistaken
   for each other in a hurry.
   ============================================================ */
.pk-acts {
  margin-top: auto;
  display: flex; flex-direction: column;
  align-items: flex-start;
  gap: calc(var(--u) * 0.5);
}
.pk-cta { margin-top: 0; }
/* the first panel's stack would otherwise finish in the same corner as
   the version stamp, so every panel's foot clears that strip */
.pick-panel .pk-body { padding-bottom: calc(var(--u) * 3.4); }
.pk-again {
  appearance: none;
  background: none;
  border: none;
  padding: calc(var(--u) * 0.25) calc(var(--u) * 0.2);
  font-family: var(--font-ui);
  font-weight: var(--w-med);
  font-size: clamp(10px, calc(var(--u) * 1.05), 13px);
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: .2em;
  /* it prints over the character art, so it carries its own paper halo
     rather than relying on whatever is behind it */
  text-shadow: 0 0 calc(var(--u) * 0.55) var(--paper),
               0 0 calc(var(--u) * 0.22) var(--paper),
               0 0 calc(var(--u) * 0.9) var(--paper);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* ============================================================
   RANDOM DRAW — the modal that picks a character

   Four avatars in a row with a highlight running between them. The
   highlight is a ring and a lift, not a colour change, so the character
   art underneath stays readable while it moves.
   ============================================================ */
#draw {
  position: fixed; inset: 0;
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: calc(var(--u) * 2);
  background: rgba(8, 12, 28, .58);
  opacity: 0;
  transition: opacity .18s ease;
}
#draw.open { opacity: 1; }
.draw-panel {
  width: min(100%, calc(var(--u) * 64));
  max-height: 100%;
  overflow-y: auto;
  background: var(--paper);
  border: max(3px, calc(var(--u) * 0.22)) solid var(--ink);
  border-radius: calc(var(--u) * 1.2);
  box-shadow: 0 calc(var(--u) * 0.9) calc(var(--u) * 3) rgba(6, 10, 24, .45);
  padding: calc(var(--u) * 1.8) calc(var(--u) * 2) calc(var(--u) * 1.6);
  transform: translateY(calc(var(--u) * 1.4));
  transition: transform .2s ease;
}
#draw.open .draw-panel { transform: none; }

.draw-line {
  font-family: var(--font-display);
  font-size: calc(var(--fs-lg) * 1.02);
  line-height: 1.25;
  color: var(--ink);
  text-align: center;
  margin-bottom: calc(var(--u) * 1.3);
}
.draw-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: calc(var(--u) * 0.9);
}
.draw-cell {
  position: relative;
  border-radius: calc(var(--u) * 0.8);
  border: max(2px, calc(var(--u) * 0.16)) solid transparent;
  background: linear-gradient(to bottom,
              color-mix(in srgb, var(--tint) 40%, #FFFDF6) 0%, var(--tint) 100%);
  padding: calc(var(--u) * 0.5) calc(var(--u) * 0.4) calc(var(--u) * 0.5);
  text-align: center;
  transition: transform .1s ease, border-color .1s ease, filter .1s ease;
}
.dc-art {
  height: calc(var(--u) * 9);
  background-repeat: no-repeat;
  background-position: bottom center;
  background-size: contain;
}
.dc-name {
  margin-top: calc(var(--u) * 0.35);
  font-family: var(--font-ui);
  font-weight: var(--w-bold);
  font-size: clamp(10px, calc(var(--u) * 1.15), 14px);
  color: var(--ink);
}
/* the moving highlight */
.draw-cell.on {
  border-color: var(--ink);
  transform: translateY(calc(var(--u) * -0.4));
  filter: brightness(1.08);
}
/* where it came to rest */
.draw-cell.won {
  border-color: var(--ink);
  box-shadow: 0 calc(var(--u) * 0.32) 0 var(--ink);
  animation: drawWin .34s ease;
}
@keyframes drawWin {
  0%   { transform: translateY(calc(var(--u) * -0.4)) scale(1); }
  45%  { transform: translateY(calc(var(--u) * -0.75)) scale(1.05); }
  100% { transform: translateY(calc(var(--u) * -0.4)) scale(1); }
}

.draw-acts {
  margin-top: calc(var(--u) * 1.5);
  display: flex; align-items: center; justify-content: center;
  gap: calc(var(--u) * 1);
  /* the buttons arrive with the result, not before it */
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease;
}
.draw-acts.ready { opacity: 1; pointer-events: auto; }
.draw-dice, .draw-play {
  appearance: none;
  font-family: var(--font-ui);
  font-weight: var(--w-bold);
  font-size: var(--fs-md);
  color: var(--ink);
  border: max(2px, calc(var(--u) * 0.16)) solid var(--ink);
  background: var(--paper);
  box-shadow: 0 calc(var(--u) * 0.26) 0 var(--ink);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.draw-dice {
  width: max(44px, calc(var(--u) * 4.4));
  height: max(44px, calc(var(--u) * 4.4));
  border-radius: calc(var(--u) * 0.7);      /* square: the draw-again key */
  display: flex; align-items: center; justify-content: center;
  padding: 0;
}
.draw-dice svg { width: 62%; height: 62%; }
.draw-play {
  min-height: max(44px, calc(var(--u) * 4.4));
  border-radius: 999px;
  background: var(--yellow);
  padding: 0 calc(var(--u) * 3.4);
}

@media (hover: hover) and (pointer: fine) {
  .pk-again:hover { opacity: 1; }
  .draw-dice:hover { background: var(--cream); }
  .draw-play:hover { background: #FFE45C; }
}
@media (max-height: 430px), (max-width: 820px) {
  .draw-panel { padding: calc(var(--u) * 1.3) calc(var(--u) * 1.5); }
  .draw-line { font-size: var(--fs-md); margin-bottom: calc(var(--u) * 0.9); }
  .dc-art { height: calc(var(--u) * 7.6); }
  .draw-acts { margin-top: calc(var(--u) * 1.1); }
}

/* ============================================================
   SELECT — the portrait sits above the buttons

   The figure used to stand on the floor of the panel, which put the CTA
   over its feet. It is lifted clear of the action stack instead, so the
   character is whole and the button has its own ground.
   ============================================================ */
/* clears the tallest stack — Continue with Start Again under it */
.pk-art { bottom: calc(var(--u) * 9.4); height: 52%; }
@media (max-height: 430px), (max-width: 820px) {
  /* the mobile stack is shorter, but the lift is the same idea — measured
     against the tallest case, a panel carrying Continue AND Start Again */
  .pk-art { bottom: calc(var(--u) * 8.4 + var(--safe-bottom)); height: 48%; }
}

/* ---- the erase line: the smallest print on the screen ---- */
.pick-erase {
  position: absolute;
  bottom: calc(var(--u) * 0.7);
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  appearance: none;
  background: none;
  border: none;
  padding: calc(var(--u) * 0.3) calc(var(--u) * 0.6);
  font-family: var(--font-ui);
  font-weight: var(--w-med);
  font-size: clamp(8px, calc(var(--u) * 0.92), 11px);
  letter-spacing: .06em;
  color: var(--ink);
  opacity: .5;
  text-decoration: underline;
  text-underline-offset: .22em;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  /* it prints over whichever panel it lands on */
  text-shadow: 0 0 calc(var(--u) * 0.5) var(--paper), 0 0 calc(var(--u) * 0.2) var(--paper);
}

/* ============================================================
   DRAW — Play centred, the dice beside it

   A three-track row: an empty track, Play, then the dice. The outer
   tracks are equal, so Play sits on the panel's centre line however wide
   the dice is, instead of being pushed off it.
   ============================================================ */
/* The pair sits on the panel's centre line as one group. It used to be a
   three-track grid that centred Play alone and hung the dice off its
   right, which left the row looking pushed to one side. */
.draw-acts {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: calc(var(--u) * 1);
}
.draw-acts > span { display: none; }      /* the old spacer track */
/* the dice is the icon and nothing else */
.draw-dice {
  background: none;
  border: none;
  box-shadow: none;
  border-radius: 0;
  width: max(40px, calc(var(--u) * 4));
  height: max(40px, calc(var(--u) * 4));
  color: var(--ink);
  opacity: .72;
}
.draw-dice svg { width: 100%; height: 100%; }
@media (hover: hover) and (pointer: fine) {
  .draw-dice:hover { background: none; opacity: 1; }
  .pick-erase:hover { opacity: .85; }
}

/* ============================================================
   EVERY PAGE REACHABLE

   The stage is letterboxed and does not scroll itself, so each full-screen
   panel carries its own scroller. Most already did; these are the ones
   that did not, and on a short landscape phone they were the pages where
   content could sit below the fold with no way to reach it.
   ============================================================ */
.pk-body,
.map-hud,
.video-screen,
#sheet {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  min-height: 0;
}
/* the pins stay put; only the text column beside them scrolls */
.map-hud { pointer-events: none; }
.map-hud > * { pointer-events: auto; }

/* A flex box that centres its content clips the top of anything taller
   than the box, which puts the start of a long panel out of reach even
   with a scrollbar. `safe` keeps the overflow at the bottom, where the
   scroll can get to it. */
.sv-screen { align-items: safe center; }
.end-plate, .chapter-plate, .title-screen { justify-content: safe center; }
.end-plate { justify-content: flex-start; }

/* ============================================================
   HEADER — the name and the meters start where the menu ends

   Two paddings were stacking: the header clears the menu button, and
   #hud-left carried a 50px inset from the older layout where the button
   sat inside the flow. Together they left a dead strip more than half a
   button wide between the menu and the avatar, and the meters paid for
   it — five chips squeezed into what was left.

   The header's own padding clears the button and nothing else adds to it.
   ============================================================ */
#hud-left { padding-left: 0; }
#hud {
  /* button inset + button width + a gap, and no more */
  padding-left: calc(var(--u) * 1.2 + var(--u) * 3.4 + var(--u) * 0.9);
}
#hud-meters { flex: 1 1 auto; min-width: 0; }

/* ============================================================
   MINIGAME SKIP — at the foot of the content, not over it

   Pinned to the canvas corner the button sat on top of whatever the game
   had drawn there. It is the last item in the wrap now: bottom right of
   the content, scrolling with it, overlapping nothing.
   ============================================================ */
.mg-skip {
  position: static;
  align-self: flex-end;
  flex: 0 0 auto;
  margin-top: calc(var(--u) * 0.9);
}
/* the photo beat no longer has to steer around it */
.mg-side .mg-btnrow { padding-right: 0; }

/* ============================================================
   PACKING — bigger squares

   The page scrolls, so the tiles do not have to be small enough for the
   whole beat to fit one screen. They are sized for the longest label
   instead.
   ============================================================ */
@media (max-height: 430px), (max-width: 820px) {
  .bag-shelf, .bag-bag { width: min(100%, calc(var(--u) * 42)); }
  .bag-item { padding: calc(var(--u) * 0.6); }
  .bag-item .bi-name { font-size: clamp(12px, calc(var(--u) * 1.55), 16px); }
}

/* ============================================================
   VIDEO — one button, two jobs

   While the clip runs it is a Skip and wears the minigame's own skip
   styling; when the clip ends it becomes Continue and takes the yellow.
   ============================================================ */
.vid-go.as-skip {
  color: #FFFDF6;
  background: rgba(10, 16, 34, .5);
  border-color: rgba(255, 253, 246, .6);
  box-shadow: none;
  font-size: var(--fs-sm);
  letter-spacing: .04em;
  padding: calc(var(--u) * 0.55) calc(var(--u) * 1.8);
  min-height: max(34px, calc(var(--u) * 3.4));
  animation: none;
}
@media (hover: hover) and (pointer: fine) {
  .vid-go.as-skip:hover { background: rgba(10, 16, 34, .8); border-color: #FFFDF6; }
}

/* ============================================================
   CHARACTER SELECT — the figure is the panel, the text sits on it

   The art used to start below the writing, so the panel read as a text
   block with a small picture under it. It fills the panel now and the
   name and introduction print over the top of it. Each line carries its
   own paper halo instead of a scrim, so the figure stays visible behind
   the words rather than being dimmed by a wash.
   ============================================================ */
/* Large enough that the writing prints over the top of the figure, but
   stopping short of putting a paragraph across its face — the character's
   own face is the one part of the panel that has to stay readable. */
.pk-art { height: 58%; }
/* The same halo repeated compounds its alpha, which builds a dense paper
   ground tight around the letterforms. A rectangle behind the text would
   read as a box on the artwork; this only covers what the words cover. */
.pk-name, .pk-intro {
  text-shadow:
    0 0 calc(var(--u) * 0.26) var(--paper),
    0 0 calc(var(--u) * 0.26) var(--paper),
    0 0 calc(var(--u) * 0.26) var(--paper),
    0 0 calc(var(--u) * 0.6) var(--paper),
    0 0 calc(var(--u) * 0.6) var(--paper),
    0 0 calc(var(--u) * 1.5) var(--paper);
}
.pk-intro { font-size: clamp(10px, calc(var(--u) * 1.18), 14px); }

@media (max-height: 430px), (max-width: 820px) {
  .pk-art { height: 56%; }
  /* smaller here so it covers less of the figure on a short screen */
  .pk-intro { font-size: clamp(9px, calc(var(--u) * 1.02), 12px); line-height: 1.35; }
  .pk-name { font-size: calc(var(--fs-lg) * 1.02); }
}

/* ============================================================
   MAP ON A SMALL SCREEN — title, panel, button, in that order

   The title took two lines at display size, which left the selected
   place's panel taller than the space under it. The panel was then cut
   off mid-sentence at the column's edge, and its clipped white block ran
   down to where the Go There button sits, so the button looked covered
   even though it still worked.

   The column is a proper stack now: a smaller title that holds one line,
   the panel taking whatever height is left and scrolling inside itself,
   and a clear gap above the button, which keeps its own band.
   ============================================================ */
@media (max-height: 430px), (max-width: 820px) {
  .map-hud {
    top: calc(var(--u) * 11);
    bottom: calc(var(--u) * 11);      /* clears the button band and its gap */
    width: calc(var(--u) * 33);
    overflow: hidden;                  /* the panel scrolls, not the column */
  }
  .map-title {
    flex: 0 0 auto;
    font-size: clamp(14px, calc(var(--u) * 2.3), 20px);
    margin-bottom: calc(var(--u) * 0.7);
  }
  .map-pick {
    /* hugs its own content, capped by the column so it can never run into
       the button band; only a panel taller than that scrolls */
    flex: 0 1 auto;
    max-height: 100%;
    min-height: 0;
    width: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
  .map-foot { width: calc(var(--u) * 33); }
  /* the lock reason was set in the display face at a fixed 16px, which on
     a phone ran larger than the choice it explains */
  .mp-name { font-size: clamp(12px, calc(var(--u) * 1.5), 16px); }
  .mp-text { font-size: clamp(10px, calc(var(--u) * 1.24), 14px); line-height: 1.35; }
  .mp-lock {
    font-family: var(--font-ui);
    font-size: clamp(10px, calc(var(--u) * 1.18), 13px);
    line-height: 1.35;
  }
  .mp-lock::before { font-size: inherit; }
}

/* ============================================================
   SURVEY COVER — a ground to wait on

   The cover photo is the heaviest asset on the opening screen. Until it
   arrives the art panel shows a flat tinted ground with a slow pulse, so
   a slow connection reads as loading rather than as a broken page. Every
   control on the panel already works while it waits.
   ============================================================ */
.sv-art.loading {
  background:
    linear-gradient(115deg,
      rgba(255, 253, 246, 0) 35%,
      rgba(255, 253, 246, .16) 50%,
      rgba(255, 253, 246, 0) 65%) 0 0 / 220% 100% no-repeat,
    linear-gradient(160deg, #2C3663 0%, #1b2340 100%);
  animation: svSheen 1.5s ease-in-out infinite;
}
.sv-art.loading .sv-photo { opacity: 0; }
.sv-photo { transition: opacity .35s ease; }
@keyframes svSheen {
  from { background-position: 140% 0, 0 0; }
  to   { background-position: -60% 0, 0 0; }
}
@media (prefers-reduced-motion: reduce) {
  .sv-art.loading { animation: none; }
}

/* ============================================================
   RANDOM DRAW — the dice button carries its word

   Same shape as the survey's Back button, and the same full round as the
   Play button beside it so the pair reads as one row.
   ============================================================ */
.draw-dice {
  width: auto;
  height: auto;
  min-height: max(44px, calc(var(--u) * 4.4));
  border-radius: 999px;
  border: max(2px, calc(var(--u) * 0.16)) solid var(--ink);
  background: var(--paper);
  box-shadow: 0 calc(var(--u) * 0.26) 0 var(--ink);
  opacity: 1;
  padding: 0 calc(var(--u) * 1.6);
  gap: calc(var(--u) * 0.7);
}
.draw-dice svg { width: max(18px, calc(var(--u) * 1.9)); height: max(18px, calc(var(--u) * 1.9)); flex: 0 0 auto; }
.dice-word {
  font-family: var(--font-ui);
  font-weight: var(--w-bold);
  font-size: var(--fs-md);
  color: var(--ink);
  white-space: nowrap;
}
@media (hover: hover) and (pointer: fine) {
  .draw-dice:hover { background: var(--cream); opacity: 1; }
}

/* ============================================================
   LOCK NOTE — the reason an option cannot be taken

   It used to print in the display face at its own fixed size, which read
   as a different voice from the choice it explains. It now takes the
   choice's own family and size, sits on its own line under the button
   text, and is italic so it is still clearly a note rather than part of
   the option. The ✕ stays in front of it.

   The wording itself is the workbook's — Choices, "Disabled reason",
   with the character override in Character Variants. The stand-in used
   where a row leaves that cell blank is NO_REASON in js/rules.js.
   ============================================================ */
/* The button is a flex row so its text and its note sat side by side.
   A locked one becomes a column, which puts the note on its own line
   under the choice it explains. */
.choice.locked {
  flex-direction: column;
  align-items: flex-start;
}
.choice.locked .lock-note {
  display: block;
  width: 100%;
  font-family: inherit;
  font-weight: var(--w-med);
  font-size: inherit;
  font-style: italic;
  line-height: 1.35;
  margin-top: calc(var(--u) * 0.45);
  color: #5F6577;
}
.choice.locked .lock-note::before {
  content: "\00d7\00a0";
  font-family: inherit;
  font-size: inherit;
  font-style: normal;
}
@media (max-height: 430px), (max-width: 820px) {
  .choice.locked .lock-note {
    font-size: inherit;
    margin-top: calc(var(--u) * 0.4);
  }
  .choice.locked .lock-note::before { font-size: inherit; }
}


/* ============================================================
   MAP — the place panel is a card laid over the town

   It carries its own close button and its own Go there, so everything
   about a chosen place lives in one box. Tapping the map behind it puts
   it away. A place that is not on offer opens the same panel with the
   reason in it and no way through.
   ============================================================ */
.map-title {
  position: absolute;
  top: calc(var(--u) * 11);
  left: calc(var(--u) * 1.8);
  z-index: 13;
  margin: 0;
  max-width: calc(var(--u) * 40);
  font-size: calc(var(--fs-lg) * 1.15);
  pointer-events: none;
}
.map-pick {
  position: absolute;
  top: calc(var(--u) * 17);
  left: calc(var(--u) * 1.8);
  z-index: 15;
  width: min(calc(100% - var(--u) * 3.6), calc(var(--u) * 34));
  max-height: calc(100% - var(--u) * 20);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  margin: 0;
  padding: calc(var(--u) * 1.3) calc(var(--u) * 1.5) calc(var(--u) * 1.4);
  box-shadow: 0 calc(var(--u) * 0.8) calc(var(--u) * 2.4) rgba(6, 10, 24, .35);
  animation: mpIn .18s ease both;
}
@keyframes mpIn {
  from { opacity: 0; transform: translateX(calc(var(--u) * -1.6)); }
  to   { opacity: 1; transform: none; }
}
.mp-close {
  position: absolute;
  top: calc(var(--u) * 0.6); right: calc(var(--u) * 0.6);
  appearance: none;
  width: max(30px, calc(var(--u) * 3)); height: max(30px, calc(var(--u) * 3));
  border-radius: 50%;
  border: none;
  background: none;
  color: var(--ink-2);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.mp-close svg { width: 62%; height: 62%; }
.map-pick .mp-name { padding-right: calc(var(--u) * 3); }
.mp-go {
  width: 100%;
  margin-top: calc(var(--u) * 1.1);
  justify-content: center;
  text-align: center;
}
/* the old footer band is gone — the button lives in the panel now */
.map-foot { display: none; }
@media (hover: hover) and (pointer: fine) {
  .mp-close:hover { color: var(--ink); }
}
@media (max-height: 430px), (max-width: 820px) {
  .map-title {
    top: calc(var(--u) * 9.4);
    left: calc(var(--u) * 1.4);
    font-size: clamp(13px, calc(var(--u) * 2.1), 18px);
    max-width: calc(var(--u) * 44);
  }
  .map-pick {
    top: calc(var(--u) * 14);
    left: calc(var(--u) * 1.4);
    width: min(calc(100% - var(--u) * 2.8), calc(var(--u) * 36));
    max-height: calc(100% - var(--u) * 16);
  }
}

/* ============================================================
   MINIGAME LAB — every beat on one page

   A test surface, not part of the story: a scrollable grid of cards, one
   per minigame, each opening the beat through the same code the run uses.
   Four to a row on the stage, fewer as it narrows, and every card the
   same size so the grid reads as a list of equals.
   ============================================================ */
/* The Minigames button that opens this page is styled with Start, under
   THE COVER at the end of this file. */

.lab-screen {
  position: absolute; inset: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: calc(var(--u) * 7) calc(var(--u) * 3) calc(var(--u) * 3);
  background: var(--page);
}
.lab-title {
  font-family: var(--font-display);
  font-weight: var(--w-body);
  font-size: calc(var(--fs-xl) * 0.9);
  color: var(--ink);
  margin-bottom: calc(var(--u) * 0.4);
}
.lab-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: calc(var(--u) * 1.2);
  align-items: stretch;
}
.lab-card {
  appearance: none;
  min-height: calc(var(--u) * 11);
  display: flex; flex-direction: column;
  align-items: flex-start; justify-content: flex-start;
  gap: calc(var(--u) * 0.3);
  text-align: left;
  padding: calc(var(--u) * 1.1) calc(var(--u) * 1.2);
  background: var(--paper);
  border: max(2px, calc(var(--u) * 0.16)) solid var(--ink);
  border-radius: calc(var(--u) * 0.9);
  box-shadow: 0 calc(var(--u) * 0.28) 0 var(--ink);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.lc-name {
  font-family: var(--font-ui);
  font-weight: var(--w-bold);
  font-size: var(--fs-md);
  color: var(--ink);
  line-height: 1.2;
}
.lc-id {
  font-family: var(--font-ui);
  font-weight: var(--w-label);
  font-size: var(--fs-xs);
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.lc-where {
  margin-top: auto;
  font-family: var(--font-ui);
  font-size: calc(var(--fs-xs) * 0.94);
  color: var(--ink-2);
  opacity: .85;
  overflow-wrap: anywhere;
}
/* the way back out, on the list and inside every beat it opens */
.lab-back {
  position: absolute;
  top: calc(var(--u) * 1.4); left: calc(var(--u) * 1.6);
  z-index: 40;
}
#scene:has(.lab-screen) { background: var(--page); }
#scene:has(.lab-screen)::after { background: none; }

@media (hover: hover) and (pointer: fine) {
  .lab-card:hover { background: var(--cream); }
}
@media (max-height: 430px), (max-width: 820px) {
  .lab-screen { padding: calc(var(--u) * 6.4) calc(var(--u) * 1.8) var(--safe-bottom); }
  .lab-grid { gap: calc(var(--u) * 0.9); }
  .lab-card { min-height: calc(var(--u) * 12); padding: calc(var(--u) * 0.9); }
}
@media (max-width: 620px) {
  .lab-grid { grid-template-columns: repeat(2, 1fr); }
}

/* In the lab the Back pill stands where the menu button does in a run,
   and it is wider than that button, so the header's left inset grows to
   clear it. Nothing else about the header changes. */
body.in-lab #hud { padding-left: calc(var(--u) * 9.4); }

/* ============================================================
   MINIGAME PASS — one Continue shape, full-bleed backdrops, and
   panels that carry their own tally and their own way on.

   Every beat now ends on the same small pill rather than a bar the
   width of the page: a lone Continue is one button, not a list of
   options, and it should be no wider than its own word.
   ============================================================ */
.mg-after .choices { margin-top: 0; padding-top: 0; }
.mg-after .choices > .choice.continue {
  grid-column: 1 / -1;
  justify-self: center;        /* grid (landscape) */
  align-self: center;          /* flex column (portrait) */
  width: auto;
  min-width: 0;
  min-height: max(34px, calc(var(--u) * 3.6));
  padding: calc(var(--u) * 0.7) calc(var(--u) * 2.4);
}

/* ============================================================
   SHAKE — one picture, one order

   The backdrop fills the canvas and is drawn a little larger than it,
   so the shake can never uncover an edge. The shake is on the picture;
   the button holds still and stays pressable.

   PER-CHARACTER BACKDROPS, and two of them — the room while it shakes and
   the room once everybody is down. Both are ordinary background pictures,
   assets/bg/tsu_02_<who>_before.jpg and _after.jpg, named by the backdrop
   tables in js/scenes.js like every other picture in the game. Until a
   file is there the beat shows a hatched placeholder naming it.
   ============================================================ */
.mg-wrap:has(.sk-scene) { padding: 0; overflow: hidden; }
.mg-wrap:has(.sk-scene) .mg-host { overflow: visible; }
.sk-scene {
  position: absolute; inset: 0;
  z-index: 1;
  overflow: hidden;
  display: flex; flex-direction: column;
  align-items: center; justify-content: flex-end;
  padding-bottom: calc(var(--u) * 4.5);
}
.sk-bg {
  position: absolute;
  top: -6%; left: -6%;
  width: 112%; height: 112%;
  z-index: 0;
  background: var(--page);
}
/* two pictures, stacked: standing while it shakes, down once the order is
   given. Both are in the page from the start so the swap has nothing to
   load — only which one is showing changes. */
.sk-plate {
  position: absolute; inset: 0;
  opacity: 1;
  transition: opacity .3s ease;
}
.sk-plate img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sk-plate.noimg img { display: none; }
.sk-plate.noimg {
  background: repeating-linear-gradient(45deg,
    #E6E0CE 0 calc(var(--u) * 1.1), #F4EFE0 calc(var(--u) * 1.1) calc(var(--u) * 2.2));
}
.sk-after { opacity: 0; }
.sk-scene.said .sk-before { opacity: 0; }
.sk-scene.said .sk-after { opacity: 1; }
.sk-ph { display: none; }
.sk-plate.noimg .sk-ph {
  display: block;
  position: absolute; left: 50%; top: 44%;
  transform: translate(-50%, -50%);
  font-family: var(--font-ui);
  font-weight: var(--w-bold);
  font-size: var(--fs-sm);
  letter-spacing: .1em;
  text-transform: uppercase;
  text-align: center;
  color: var(--ink-2);
  background: rgba(255, 253, 246, .92);
  border: max(2px, calc(var(--u) * 0.14)) dashed var(--ink-2);
  border-radius: calc(var(--u) * 0.8);
  padding: calc(var(--u) * 0.9) calc(var(--u) * 1.6);
  white-space: nowrap;
}
.sk-ph small { font-weight: var(--w-med); text-transform: none; letter-spacing: 0; }
.sk-btnrow { position: relative; z-index: 2; margin: 0; }

/* ============================================================
   PHOTO — full-bleed camera, the title and camera line over the top
   (the shared .gr-head), a viewfinder dead centre, and a tray along
   the bottom that fills the way a hand of cards fills. The red circles
   round the subjects are drawn in the picture itself: their size is
   each target's `r` in PHOTO_TARGETS, js/minigames.js.

   THE BACKDROP — drop a file at assets/photo/water.jpg and it covers
   the drawn panorama. Until it is there the drawing shows with a
   [placeholder] chip naming the file.
   ============================================================ */
.mg-wrap:has(.ph-scene) { padding: 0; overflow: hidden; }
.mg-wrap:has(.ph-scene) .mg-host { overflow: visible; }
.ph-scene {
  position: absolute; inset: 0;
  z-index: 1;
  overflow: hidden;
  background: var(--paper);
}
.ph-view {
  position: absolute; inset: 0;
  cursor: grab;
  touch-action: none;
  user-select: none; -webkit-user-select: none;
}
.ph-view:active { cursor: grabbing; }
.ph-view > #ph-svg { display: block; width: 100%; height: 100%; }

/* The viewfinder is where the shutter aims, so it sits dead centre. Its
   size is the width: as large as fits between the camera line under the
   title and the Snap button, which sits under the viewfinder. The lines
   are drawn in the viewfinder's own units, so a bigger viewfinder wants a
   smaller stroke-width to keep them the same weight on screen. */
.ph-finder {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: calc(var(--u) * 38);
  max-width: 60%;
  z-index: 3;
  pointer-events: none;
}
.ph-finder #ph-brackets {
  fill: none;
  stroke: #FFFDF6;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 2px rgba(10, 16, 34, .9));
  transition: stroke .15s;
}
.ph-finder.hot #ph-brackets { stroke: var(--yellow); }

/* the shutter: under the viewfinder, and clear of the tray along the
   bottom. The camera line is under the title now (.ph-head). */
.ph-controls {
  position: absolute;
  left: 50%; bottom: calc(var(--u) * 12.6);
  transform: translateX(-50%);
  z-index: 4;
  display: flex; flex-direction: column; align-items: center;
}
.ph-snap {
  appearance: none;
  min-width: max(78px, calc(var(--u) * 8.6));
  min-height: max(38px, calc(var(--u) * 4));
  border-radius: 999px;
  border: max(3px, calc(var(--u) * 0.2)) solid var(--ink);
  background: var(--yellow);
  color: var(--ink);
  font-family: var(--font-ui);
  font-weight: var(--w-bold);
  font-size: var(--fs-md);
  cursor: pointer;
  box-shadow: 0 calc(var(--u) * 0.25) 0 rgba(44, 54, 99, .35);
}
.ph-snap:hover { background: #FFE45C; }
.ph-snap:active { transform: translateY(calc(var(--u) * 0.16)); }
.ph-snap:disabled { opacity: .45; cursor: default; }

/* the tray: empty until the first shot lands in it */
.ph-tray {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 5;
  height: calc(var(--u) * 11.5);
  display: flex; align-items: center;
  gap: calc(var(--u) * 1);
  padding: calc(var(--u) * 0.8) calc(var(--u) * 1.6);
  background: rgba(10, 16, 34, .86);
  border-top: max(2px, calc(var(--u) * 0.16)) solid var(--ink);
}
.ph-card {
  flex: 0 0 auto;
  width: calc(var(--u) * 12);
  background: #fff;
  border: max(2px, calc(var(--u) * 0.14)) solid var(--ink);
  border-radius: calc(var(--u) * 0.5);
  padding: calc(var(--u) * 0.35) calc(var(--u) * 0.35) calc(var(--u) * 0.25);
  box-shadow: 0 calc(var(--u) * 0.3) calc(var(--u) * 0.8) rgba(6, 10, 24, .45);
  transform: rotate(-1.4deg);
  animation: snapIn .45s cubic-bezier(.2, 1.6, .4, 1);
}
.ph-card:nth-child(even) { transform: rotate(1.6deg); }
.ph-shot {
  height: calc(var(--u) * 6);
  border-radius: calc(var(--u) * 0.3);
  overflow: hidden;
  background: var(--grey-wash);
}
.ph-shot svg { display: block; width: 100%; height: 100%; }
.ph-cap {
  font-family: var(--font-hand);
  font-size: var(--fs-sm);
  line-height: 1.15;
  text-align: center;
  color: var(--ink-2);
  padding-top: calc(var(--u) * 0.25);
}
.ph-bgph {
  position: absolute;
  left: 50%; top: calc(var(--u) * 1.4);
  transform: translateX(-50%);
  z-index: 2;
  font-family: var(--font-ui);
  font-weight: var(--w-bold);
  font-size: var(--fs-xs);
  letter-spacing: .1em;
  text-transform: uppercase;
  text-align: center;
  color: var(--ink-2);
  background: rgba(255, 253, 246, .9);
  border: max(2px, calc(var(--u) * 0.12)) dashed var(--ink-2);
  border-radius: calc(var(--u) * 0.7);
  padding: calc(var(--u) * 0.4) calc(var(--u) * 1.1);
  white-space: nowrap;
  pointer-events: none;
}
.ph-bgph small { font-weight: var(--w-med); text-transform: none; letter-spacing: 0; }



/* ============================================================
   THE BEAT TITLE — one heading, one size, one face

   A beat with no eyebrow above it has no other heading, so the engine sets
   its goal as the beat's title (`mg-goal-title`, js/engine.js). Every such
   beat — the radio, the go-bag, the climb, the count, the class — reads the
   same: the display face at the large step, centred over the panel, and
   ordered above the control line rather than under it.
   ============================================================ */
.mg-goal.mg-goal-title {
  order: -2;
  font-family: var(--font-display);
  font-weight: var(--w-body);
  font-size: var(--fs-lg);
  line-height: 1.25;
  letter-spacing: .005em;
  max-width: calc(var(--u) * 58);
  margin: 0 auto calc(var(--u) * 1);
}
/* The packing shelf is the one beat whose content already filled the canvas,
   so a heading on top of it pushed Zip it off the bottom. It starts higher
   instead — still clear of the meters, which end around 6u. */
.mg-wrap:has(.bag-wrap) { padding-top: calc(var(--u) * 8.2); }

/* ============================================================
   SHOP_CYCLONE — the shelf, and the clock emptying it

   The tsunami shop's item rows are reused wholesale, so the two markets
   read as the same place. What differs is the head — a countdown where
   the purse was — and what a sold row looks like.
   ============================================================ */
/* Full-bleed on the market's own picture, with the shelf card centred on
   it — the same shape the tsunami shop has, so the two read as one place.
   The picture is the one CY-SHARED-24H-01 shows behind the decision. */
.mg-wrap:has(.cs-scene) { padding: 0; overflow: hidden; position: relative; }
.mg-wrap:has(.cs-scene) .mg-host { flex: 1 1 auto; min-height: 0; }
.cs-scene {
  position: absolute; inset: 0;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  padding: max(84px, calc(var(--u) * 6.8)) calc(var(--u) * 2) calc(var(--u) * 2);
  background: var(--page);
}
.cs-bg {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  user-select: none;
}
.cs-scene.nobg .cs-bg { display: none; }

.cs-wrap {
  position: relative;              /* above the picture */
  z-index: 2;
  width: 100%;
  max-width: calc(var(--u) * 56);
  max-height: 100%;
  margin: 0 auto;
  display: flex; flex-direction: column;
  min-height: 0;
}
.cs-wrap .shop-head { margin-top: 0; }
.cs-wrap .shop-list { min-height: 0; overflow-y: auto; }
/* the shelf's Continue sits where the tsunami shop's does */
.cs-wrap .after { flex: 0 0 auto; margin-top: calc(var(--u) * 0.8); }
.cs-clock {
  font-family: var(--font-ui);
  font-weight: var(--w-bold);
  font-size: var(--fs-lg);
  min-width: calc(var(--u) * 3.4);
  text-align: center;
  color: var(--ink);
  background: var(--yellow);
  border: max(2px, calc(var(--u) * 0.14)) solid var(--ink);
  border-radius: 999px;
  padding: 0 calc(var(--u) * 0.9);
  font-variant-numeric: tabular-nums;
}
.cs-clock.low { background: var(--salmon); }
/* a row that has gone: struck through, greyed, and out of reach */
.shop-item.cs-sold {
  opacity: .38;
  cursor: default;
  background: none;
}
.shop-item.cs-sold:hover { background: none; }
.shop-item.cs-sold .si-name,
.shop-item.cs-sold .si-desc { text-decoration: line-through; }
.shop-item.cs-sold .si-price { color: var(--red); text-decoration: none; }
.cs-note {
  font-family: var(--font-ui);
  font-weight: var(--w-label);
  font-size: var(--fs-md);
  text-align: center;
  color: var(--red);
  min-height: calc(var(--u) * 2);
  margin-top: calc(var(--u) * 0.6);
}

/* ============================================================
   THE MINIGAME LIST — a section per scenario, and a fold for the rest
   ============================================================ */
.lab-section {
  font-family: var(--font-display);
  font-weight: var(--w-body);
  font-size: var(--fs-lg);
  color: var(--ink);
  margin: calc(var(--u) * 2.2) 0 calc(var(--u) * 1);
}
.lab-fold summary {
  cursor: pointer;
  list-style: none;
  display: flex; align-items: center;
  gap: calc(var(--u) * 0.8);
  width: fit-content;
  -webkit-tap-highlight-color: transparent;
}
.lab-fold summary::-webkit-details-marker { display: none; }
.lab-fold summary::before {
  content: "";
  width: 0; height: 0;
  border-left: calc(var(--u) * 0.7) solid var(--ink);
  border-top: calc(var(--u) * 0.45) solid transparent;
  border-bottom: calc(var(--u) * 0.45) solid transparent;
  transition: transform .16s ease;
}
.lab-fold[open] summary::before { transform: rotate(90deg); }
.lab-fold summary:hover { opacity: .75; }

/* ============================================================
   MAPPED BACKDROPS — the tsunami background table

   A backdrop named in BG_FILES / TSU_BACKDROPS (js/scenes.js) fills the
   scene the way the older painted plates do. Until its file exists the
   wrapper flips to a placeholder naming the slot number and the exact
   path to create, so the empty ones are visible at a glance.
   ============================================================ */
.art-photo-wrap { position: absolute; inset: 0; }
.art-photo-wrap .art-photo { width: 100%; height: 100%; }
.art-photo-wrap.missing .art-photo { display: none; }
.art-ph { display: none; }
.art-photo-wrap.missing .art-ph {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: calc(var(--u) * 0.4);
  text-align: center;
  background: repeating-linear-gradient(45deg,
    #E6E0CE 0 calc(var(--u) * 1.1), #F4EFE0 calc(var(--u) * 1.1) calc(var(--u) * 2.2));
}
.art-ph .ph-mark {
  font-family: var(--font-ui);
  font-weight: var(--w-bold);
  font-size: var(--fs-md);
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.art-ph .ph-path,
.art-ph .ph-n {
  font-family: var(--font-ui);
  font-weight: var(--w-med);
  font-size: var(--fs-sm);
  color: var(--ink-2);
}
.art-ph .ph-n { opacity: .75; }

/* ============================================================
   THE CHAPTER PLATE — one title, one button

   The eyebrow, the standfirst and the spot drawing are gone; the title
   is the page. Titles are written in title case in STAGE_TITLE
   (js/engine.js) and printed as written, so the table is what you read.
   ============================================================ */
.chapter-plate .ch-title {
  text-transform: none;
  margin: 0;
  max-width: calc(var(--u) * 60);
}
.chapter-plate .choices {
  margin-top: calc(var(--u) * 3);
  padding-top: 0;
  width: auto;
}
.chapter-plate .choices > .choice.continue {
  grid-column: 1 / -1;
  justify-self: center;
  align-self: center;
  width: auto;
  min-width: 0;
  min-height: max(34px, calc(var(--u) * 3.6));
  padding: calc(var(--u) * 0.7) calc(var(--u) * 2.6);
}
.chapter-plate { cursor: default; }

/* ============================================================
   THE MAP — the title needs a card behind it to be readable

   White text with a shadow disappeared over the pale streets in the
   middle of the map image. It sits on paper now.
   ============================================================ */
.map-title {
  color: var(--ink);
  text-shadow: none;
  background: rgba(255, 253, 246, .94);
  border: max(2px, calc(var(--u) * 0.16)) solid var(--ink);
  border-radius: calc(var(--u) * 0.9);
  padding: calc(var(--u) * 0.6) calc(var(--u) * 1.4);
  box-shadow: 0 calc(var(--u) * 0.3) calc(var(--u) * 1) rgba(6, 10, 24, .3);
  width: fit-content;
}

/* ============================================================
   THE ENDING — one page: what happened, the reflection folded under
   it, and the three ways out
   ============================================================ */
.end-fold {
  width: 100%;
  max-width: var(--refl-w, calc(var(--u) * 54));
  margin: calc(var(--u) * 1.6) auto 0;
  text-align: left;
  border-top: max(2px, calc(var(--u) * 0.14)) solid var(--hairline);
  border-bottom: max(2px, calc(var(--u) * 0.14)) solid var(--hairline);
}
.end-fold-head {
  cursor: pointer;
  list-style: none;
  display: flex; align-items: center;
  gap: calc(var(--u) * 0.8);
  padding: calc(var(--u) * 1.1) 0;
  font-family: var(--font-display);
  font-weight: var(--w-body);
  font-size: var(--fs-lg);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}
.end-fold-head::-webkit-details-marker { display: none; }
.end-fold-head::before {
  content: "";
  width: 0; height: 0;
  border-left: calc(var(--u) * 0.7) solid var(--ink);
  border-top: calc(var(--u) * 0.45) solid transparent;
  border-bottom: calc(var(--u) * 0.45) solid transparent;
  transition: transform .16s ease;
}
.end-fold[open] .end-fold-head::before { transform: rotate(90deg); }
.end-fold-head:hover { opacity: .75; }
/* every question reads the same, the opening one included */
.end-fold .refl-list {
  display: flex; flex-direction: column;
  gap: calc(var(--u) * 0.9);
  padding: 0 0 calc(var(--u) * 1.4);
}
.end-fold .refl-q {
  font-family: var(--font-ui);
  font-weight: var(--w-med);
  font-size: var(--fs-md);
  line-height: 1.5;
  color: var(--ink);
  text-align: left;
  margin: 0;
}


/* ============================================================
   THE ENDING — one centred column

   The page used to stack from the top with a thin margin above it, so a
   short ending sat high on the screen with everything below it empty.
   It is a column in the middle of the canvas now: `safe center` so a long
   ending still scrolls from its own top rather than losing its first line
   off the ceiling.
   ============================================================ */
.end-plate {
  justify-content: safe center;
  align-items: center;
  text-align: center;
  padding-top: calc(var(--u) * 6);
  padding-bottom: calc(var(--u) * 4);
  gap: calc(var(--u) * 0.4);
}
/* who you played, over the ending */
.end-plate .end-title {
  font-family: var(--font-display);
  font-weight: var(--w-body);
  font-size: calc(var(--fs-xl) * 0.95);
  line-height: 1.15;
  color: var(--ink);
  text-align: center;
  margin: 0 0 calc(var(--u) * 1.2);
}
.end-plate .end-body {
  width: 100%;
  max-width: calc(var(--u) * 50);
  margin-inline: auto;
  text-align: center;
}
.end-plate .end-body .para { text-align: center; }
/* the reflection is a narrower column than the ending it folds under */
.end-plate .end-fold {
  max-width: calc(var(--u) * 32);
  margin-inline: auto;
}
.end-plate .end-fold-head { justify-content: center; }
.end-plate .choices {
  width: 100%;
  max-width: calc(var(--u) * 26);
  margin: calc(var(--u) * 2.2) auto 0;
  align-items: center;
}
.end-plate .choices > .choice { width: 100%; }

/* ============================================================
   THE PHOTO BEAT ON A SMALL CANVAS

   Skip is a flow item at the foot of the content everywhere else (see
   MINIGAME SKIP above), and that is right for a beat whose content is a
   column. This one is full-bleed: the wrap has no padding and nothing in
   normal flow, so a static Skip landed at the top right, half outside the
   canvas, and the wrap's own overflow clipped it. On this beat it goes
   back to the corner, over the tray, where it is always reachable. The
   tray's left end holds the cards; its right end is empty.
   ============================================================ */
.mg-wrap:has(.ph-scene) .mg-skip {
  position: absolute;
  align-self: auto;
  margin: 0;
  right: calc(var(--u) * 1.6);
  bottom: calc(var(--u) * 1.4);
  z-index: 40;
}

/* A short canvas floors the type and the shutter at their pixel minimums,
   which makes the stack under the viewfinder taller in `--u` terms than
   the spacing assumed. The viewfinder gives up the difference. */
@media (max-height: 430px), (max-width: 820px) {
  .ph-finder { width: calc(var(--u) * 30); }
  .ph-controls { bottom: calc(var(--u) * 12); }
  /* a phone's header is about 52px tall, not the 84px the title clears on
     a desktop, so the title comes up under it like the other beats' do */
  .ph-scene .gr-head { top: 58px; }
}

/* ============================================================
   THE ENDING — the reflection sits inside the ending, not beside it

   The fold used to be its own block under the body, ruled off top and
   bottom. It is part of the same column now: the rules are gone, it
   takes the body's width, and its heading reads from the left like the
   questions it opens onto.
   ============================================================ */
.end-plate .end-body .end-fold {
  border: none;
  max-width: none;
  width: 100%;
  margin: calc(var(--u) * 1.2) 0 0;
  text-align: left;
}
.end-plate .end-body .end-fold-head {
  justify-content: flex-start;
  padding: calc(var(--u) * 0.6) 0;
}
.end-plate .end-body .refl-list { padding-bottom: calc(var(--u) * 0.4); }

/* ---- YOUR STORY: the reflection's section, but open --------------
   It carries `.end-fold` so every rule above applies to it unchanged —
   the width, the left edge, the heading's face and rhythm. What it drops
   is everything that says "there is more behind this": the disclosure
   triangle, the pointer, the hover. Nothing folds away here, because this
   passage is the ending itself. */
/* One line, not three: "Your Story: A Deadly Risk (Kai)". It is a flex row
   already — .end-fold-head is — so the three spans sit on the baseline
   together and wrap as a unit only when a narrow canvas forces it. */
.end-story-head {
  cursor: default;
  margin: 0;
  flex-wrap: wrap;
  align-items: baseline;
  gap: calc(var(--u) * 0.45);
  line-height: 1.25;
}
.end-story-head::before { display: none; }
.end-story-head:hover { opacity: 1; }
/* The label opens the line, so it steps back and lets the title carry it. */
.end-story-lead { color: var(--ink-2); }
.end-story-title { color: var(--ink); }
/* the character it belongs to, as the byline on the end of the line */
.end-story-who {
  font-family: var(--font-ui);
  font-weight: var(--w-med);
  font-size: var(--fs-md);
  color: var(--ink-2);
  white-space: nowrap;
}
/* the passage reads from the left with the questions below it, not
   centred like the bare paragraph this section replaced */
.end-plate .end-body .end-story .para {
  text-align: left;
  margin-bottom: calc(var(--u) * 1.1);
}

/* every button at the end is the same width, and none of them wraps */
.end-plate .choices { max-width: calc(var(--u) * 34); }
.end-plate .choices > .choice {
  width: 100%;
  white-space: nowrap;
  padding-inline: calc(var(--u) * 1.2);
}

/* the first section heading sits straight under the page title, a little
   closer than the gap the ones between grids keep */
.lab-section-first { margin-top: calc(var(--u) * 1.4); }

/* ============================================================
   THE HEADER AVATAR — a photograph, with the drawing behind it

   Paths are in HUD_AVATAR (js/engine.js); see assets/avatars/README.md.
   Both the picture and the drawn medallion are in the DOM, and the
   drawing only surfaces when the file is not there.
   ============================================================ */
#hud-port { position: relative; overflow: hidden; border-radius: 50%; }
#hud-port .hud-face {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 50%;
  border: max(1.5px, calc(var(--u) * 0.14)) solid var(--ink);
  background: var(--paper);
}
#hud-port .hud-drawn { display: none; }
#hud-port .hud-drawn svg { width: 100%; height: 100%; display: block; }
#hud-port.nophoto .hud-face { display: none; }
#hud-port.nophoto .hud-drawn { display: block; }

/* ============================================================
   THE CHARACTER RAIL — the main button never moves

   Start Again holds its line under the main button on every panel, shown
   or not, so Play and Continue sit at the same height all the way along
   the rail. And the erase line, the one control that destroys something,
   moves out of the panels to the page's own top right corner.
   ============================================================ */
.pk-again.is-empty {
  visibility: hidden;
  pointer-events: none;
}
.pick-erase {
  top: calc(var(--u) * 1.5);
  right: calc(var(--u) * 1.8);
  bottom: auto;
  left: auto;
  transform: none;
}

/* ============================================================
   BACKDROPS — a ground to wait on

   The same sheen the survey cover uses, on every photographic backdrop
   and every introduction slide. The picture fades up over it as it
   arrives. Both load and error clear the wait (see photoPlate in
   js/engine.js), so the sheen only keeps running on a request that has
   genuinely stalled.
   ============================================================ */
.art-photo-wrap.loading,
.intro-art.loading {
  background:
    linear-gradient(115deg,
      rgba(255, 253, 246, 0) 35%,
      rgba(255, 253, 246, .16) 50%,
      rgba(255, 253, 246, 0) 65%) 0 0 / 220% 100% no-repeat,
    linear-gradient(160deg, #2C3663 0%, #1b2340 100%);
  animation: svSheen 1.5s ease-in-out infinite;
}
/* the picture fades up as it arrives rather than snapping in */
.art-photo, .intro-img { transition: opacity .35s ease; }
.art-photo-wrap.loading .art-photo,
.intro-art.loading .intro-img { opacity: 0; }
/* a slot with no file at all shows its placeholder, not the sheen */
.art-photo-wrap.missing, .intro-art.missing { animation: none; }
@media (prefers-reduced-motion: reduce) {
  .art-photo-wrap.loading, .intro-art.loading { animation: none; }
}

/* ============================================================
   PICK IT UP — the T0-03 item picker
   The items and their pictures:  T0_PICKUP_ITEMS in js/scenes.js
   Where each character's are:    PICKUP_PLACES in js/scenes.js
   Inside the counter, cabinet:   PICKUP_BOX_ART in js/scenes.js
   The words on it:               PICKUP_TEXT in js/scenes.js
   ============================================================
   The beat runs full-bleed: the character's own T0-03 picture fills the
   whole stage and the heading, hint, tally and button sit on top of it.
   The wrap keeps no padding and draws nothing of its own. */
.mg-wrap:has(.gr-scene) {
  padding: 0;
  overflow: hidden;
  position: relative;
}
.mg-wrap:has(.gr-scene) .mg-host { flex: 1 1 auto; min-height: 0; }
.mg-wrap:has(.gr-scene) .mg-after { display: none; }

.gr-scene {
  position: absolute; inset: 0;
  overflow: hidden;
  background: var(--ink);
}
/* Full screen means filling it: the picture crops rather than letterboxes,
   so there is never a bar down the side. Item positions are percentages of
   this box, which is the same box the picture is cropped into. */
.gr-bg {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  user-select: none;
}
.gr-scene.nobg { background: #2C3663; }

/* The two lines of copy, over the top of the picture. The beat is
   full-bleed, so the HUD floats above it rather than beside it — the
   offset has to clear the HUD's own height, which is driven by pixel
   padding and so barely changes with the stage. Hence the px floor. */
.gr-head {
  position: absolute;
  left: 0; right: 0;
  top: max(84px, calc(var(--u) * 6.8));
  text-align: center;
  pointer-events: none;
  z-index: 3;
  padding: 0 calc(var(--u) * 8);
  /* The picture underneath is whatever art was supplied, so the copy
     cannot rely on it being dark. Repeating the same soft shadow builds
     a pool of shade that follows the letterforms — legible on a pale
     wall as well as a night street, without drawing a box. */
  text-shadow: 0 1px 2px rgba(10, 16, 34, .95),
               0 0 calc(var(--u) * 0.5) rgba(10, 16, 34, .85),
               0 0 calc(var(--u) * 0.5) rgba(10, 16, 34, .85),
               0 0 calc(var(--u) * 1.4) rgba(10, 16, 34, .7);
}
.gr-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: var(--w-body);
  font-size: var(--fs-xl);
  line-height: 1.15;
  color: #FFFDF6;
}
.gr-hint {
  margin: calc(var(--u) * 0.35) 0 0;
  font-family: var(--font-ui);
  font-weight: var(--w-med);
  font-size: var(--fs-sm);
  line-height: 1.3;
  color: rgba(255, 253, 246, .9);
}

.gr-field { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
/* the field itself lets clicks through to the outlines under it */
.gr-field > * { pointer-events: auto; }

/* One item. It STANDS on its point: `left`/`top` are the bottom middle of
   the object, in percent of the picture, so a spot holds its place at
   every screen size and an item set on a table sits on it. The button is
   the picture; the name hangs directly under it.
     --s     how big, against the others (the row's `size`)
     --foot  how much of the picture is empty under the object, pulled
             below the point so the object itself touches it
     --h     a picture cut from the background: its exact height, in
             stage units, so it lies over the spot it was cut from */
.gr-spot {
  --s: 1;
  --foot: 0;
  --box: max(30px, calc(var(--u) * 4.4));
  position: absolute;
  transform: translate(-50%, -100%);
  transform-origin: 50% 100%;
  appearance: none;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center;
  /* the breathing that makes a spot findable without a hunt */
  animation: grBreath 2.4s ease-in-out infinite;
}
/* staggered, so the scene pulses like a room rather than a metronome */
.gr-spot:nth-child(3n)   { animation-delay: -.8s; }
.gr-spot:nth-child(3n+1) { animation-delay: -1.6s; }

@keyframes grBreath {
  0%, 100% { transform: translate(-50%, -100%) scale(1); }
  50%      { transform: translate(-50%, -100%) scale(1.08); }
}

.gr-img {
  display: block;
  width: calc(var(--box) * var(--s));
  height: calc(var(--box) * var(--s));
  margin-bottom: calc(var(--box) * var(--s) * var(--foot) * -1);
  object-fit: contain;
  filter: drop-shadow(0 calc(var(--u) * 0.2) calc(var(--u) * 0.4) rgba(10, 16, 34, .55));
}
/* cut from the background: its own shape and size, and no shadow of its
   own — the picture under it already has one */
.gr-spot.cut .gr-img {
  width: auto;
  height: calc(var(--u) * var(--h) * var(--s));
  margin-bottom: 0;
  filter: none;
}
/* the halo behind an item, and the whole mark when there is no picture */
.gr-spot::before {
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  width: calc(max(44px, calc(var(--u) * 6.4)) * var(--s));
  height: calc(max(44px, calc(var(--u) * 6.4)) * var(--s));
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 214, 0, .5) 0%, rgba(255, 214, 0, 0) 68%);
  pointer-events: none;
}
.gr-dot {
  width: max(24px, calc(var(--u) * 3.4));
  height: max(24px, calc(var(--u) * 3.4));
  border-radius: 50%;
  background: var(--yellow);
  border: max(2px, calc(var(--u) * 0.18)) solid var(--ink);
}

/* the placeholder that names the file a spot is waiting for */
.gr-ph { display: none; }
.gr-spot.noart .gr-img { display: none; }
.gr-spot.noart .gr-ph {
  display: block;
  max-width: max(84px, calc(var(--u) * 11));
  background: repeating-linear-gradient(45deg,
    rgba(255, 253, 246, .92) 0 6px, rgba(255, 236, 150, .92) 6px 12px);
  color: var(--ink);
  border: max(2px, calc(var(--u) * 0.14)) dashed var(--ink);
  border-radius: calc(var(--u) * 0.35);
  padding: calc(var(--u) * 0.4) calc(var(--u) * 0.5);
  font-family: var(--font-ui);
  font-size: max(8px, calc(var(--u) * 0.78));
  line-height: 1.1;
  word-break: break-all;
}

/* The name, directly under the object. No plate behind it: a caption on
   the picture, held legible by its own shadow rather than by a box. */
.gr-name {
  position: absolute;
  left: 50%; top: 100%;
  transform: translateX(-50%);
  margin-top: calc(var(--u) * 0.15);
  font-family: var(--font-ui);
  font-weight: var(--w-bold);
  font-size: max(10px, calc(var(--u) * 1.02));
  line-height: 1.1;
  letter-spacing: .01em;
  color: #FFFDF6;
  text-align: center;
  /* a long name breaks onto two lines rather than running into the next */
  width: max-content;
  max-width: max(50px, calc(var(--u) * 4.8));
  pointer-events: none;
  text-shadow: 0 1px 2px rgba(10, 16, 34, .95),
               0 0 calc(var(--u) * 0.4) rgba(10, 16, 34, .9),
               0 0 calc(var(--u) * 0.4) rgba(10, 16, 34, .9),
               0 0 calc(var(--u) * 1) rgba(10, 16, 34, .7);
}
.gr-tick {
  position: absolute;
  top: calc(var(--u) * -0.35); right: calc(var(--u) * -0.5);
  width: max(17px, calc(var(--u) * 1.8));
  height: max(17px, calc(var(--u) * 1.8));
  display: none;
  align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--yellow);
  border: max(2px, calc(var(--u) * 0.14)) solid var(--ink);
  color: var(--ink);
  font-size: max(10px, calc(var(--u) * 1));
}

/* A crowded row (untangle in js/minigames.js): every name on one line,
   and every other one a line lower, so neighbours never sit side by side. */
.gr-spot.tight .gr-name { white-space: nowrap; max-width: none; }
.gr-spot.low .gr-name { margin-top: calc(var(--u) * 0.15 + 1.15em); }
.gr-spot.low2 .gr-name { margin-top: calc(var(--u) * 0.15 + 2.3em); }
/* while a drawing is open it covers the way out, so the button steps
   out of sight until it closes rather than peeping from under it */
.gr-scene.box-open .gr-controls { visibility: hidden; }

/* taken: it stops breathing, dims back into the room and shows the tick */
.gr-spot.took {
  animation: none;
  transform: translate(-50%, -100%) scale(.92);
  opacity: .58;
}
.gr-spot.took::before { opacity: 0; }
.gr-spot.took .gr-tick { display: flex; }

/* Hands full (PICKUP_LIMIT in js/scenes.js): whatever is not taken goes
   grey, faded into the room, and stops breathing — no halo, no glow. It
   still takes a click, which says why (.gr-toast below). */
.gr-scene.full .gr-spot:not(.took) { animation: none; cursor: not-allowed; }
.gr-scene.full .gr-spot:not(.took)::before { opacity: 0; }
.gr-scene.full .gr-spot:not(.took) .gr-img {
  opacity: .5;
  filter: grayscale(1) drop-shadow(0 calc(var(--u) * 0.2) calc(var(--u) * 0.4) rgba(10, 16, 34, .4));
}
/* a picture cut from the background goes grey where it lies, and solid,
   or the coloured one under it would show through */
.gr-scene.full .gr-spot.cut:not(.took) .gr-img { opacity: 1; filter: grayscale(1); }
.gr-scene.full .gr-spot:not(.took) .gr-name { opacity: .6; }

/* ...and the word on it: "You can only carry four items with you." Just
   under the title and its clock, over the line of help — the script sets
   `top` from where that row ends — for PICKUP_FULL_MS, then gone. It
   catches no clicks, so the room stays live under it. */
.gr-toast {
  position: absolute;
  left: 50%;
  z-index: 30;
  width: max-content;
  max-width: min(90%, calc(var(--u) * 60));
  padding: calc(var(--u) * 0.75) calc(var(--u) * 2.2);
  background: var(--paper);
  border: max(2.5px, calc(var(--u) * 0.2)) solid var(--ink);
  border-radius: 999px;
  box-shadow: 0 calc(var(--u) * 0.8) calc(var(--u) * 2.2) rgba(10, 16, 34, .4);
  font-family: var(--font-ui);
  font-weight: var(--w-label);
  font-size: max(13px, calc(var(--u) * 1.35));
  line-height: 1.3;
  color: var(--ink);
  text-align: center;
  opacity: 0;
  transform: translate(-50%, calc(var(--u) * -0.6)) scale(.94);
  transition: opacity .2s ease, transform .2s ease;
  pointer-events: none;
}
.gr-toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---- the things that open: Ravi's counter, Lina's cabinet ----
   On the picture, a glowing outline traced round it (over a darker line,
   so it holds on pale walls), breathing with the items, and its name on
   it as a button. Either opens its panel. The outlines' points are in
   PICKUP_PLACES in js/scenes.js. */
.gr-boxes {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  z-index: 2;
  pointer-events: none;
  overflow: visible;
}
.gr-box-under {
  fill: none;
  stroke: rgba(10, 16, 34, .55);
  stroke-width: 9;
  stroke-linejoin: round;
}
.gr-box-shape {
  fill: rgba(255, 214, 0, .14);
  stroke: var(--yellow);
  stroke-width: 5;
  stroke-linejoin: round;
  pointer-events: all;
  cursor: pointer;
  animation: grBoxGlow 2.4s ease-in-out infinite;
}
.gr-box-shape:hover { fill: rgba(255, 214, 0, .26); }
@keyframes grBoxGlow {
  0%, 100% { stroke-opacity: 1; fill-opacity: 1; }
  50%      { stroke-opacity: .5; fill-opacity: .55; }
}
.gr-box-label {
  position: absolute;
  transform: translate(-50%, -50%);
  z-index: 3;
  display: inline-flex; align-items: center;
  gap: calc(var(--u) * 0.4);
  appearance: none;
  padding: calc(var(--u) * 0.3) calc(var(--u) * 0.9);
  border-radius: 999px;
  border: max(2px, calc(var(--u) * 0.15)) solid var(--ink);
  background: var(--yellow);
  color: var(--ink);
  font-family: var(--font-ui);
  font-weight: var(--w-bold);
  font-size: max(11px, calc(var(--u) * 1.1));
  line-height: 1.15;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 calc(var(--u) * 0.2) calc(var(--u) * 0.5) rgba(10, 16, 34, .45);
}
.gr-box-label:hover { background: #FFE45C; }
.gr-box-label:focus-visible { outline: max(2px, calc(var(--u) * 0.16)) solid #FFFDF6; outline-offset: 2px; }
/* how many of its things are taken */
.gr-box-n {
  min-width: 1.5em;
  padding: 0 .35em;
  border-radius: 999px;
  background: var(--ink);
  color: var(--yellow);
  font-size: .86em;
  line-height: 1.45;
  text-align: center;
}
.gr-box-n[hidden] { display: none; }

/* The drawing that opens: straight over the picture, no panel and no
   dimming round it, under the title and its clock (the script sets `top`
   from where that row ends, so the clock is never covered) and as large
   as the room below allows — the script sets --art-w. It keeps its shape
   and its items stand in it, sized in percent of the drawing (--item,
   from PICKUP_BOX_ART). Only its items and its cross take clicks: the
   room round it, and under its empty corners, stays live. */
.gr-box-panel {
  position: absolute;
  left: 50%;
  z-index: 21;
  transform: translate(-50%, calc(var(--u) * 0.8));
  opacity: 0;
  transition: opacity .18s ease, transform .18s ease;
  pointer-events: none;
}
.gr-box-panel.open { opacity: 1; transform: translate(-50%, 0); }
.gr-box-panel[hidden] { display: none; }
.gr-box-panel .gr-spot,
.gr-box-panel .gr-box-close { pointer-events: auto; }
/* the cross, inside the drawing at its top right (PICKUP_BOX_ART.close) */
.gr-box-close {
  position: absolute;
  transform: translate(-50%, -50%);
  z-index: 2;
  appearance: none;
  width: max(32px, calc(var(--u) * 3));
  height: max(32px, calc(var(--u) * 3));
  display: flex; align-items: center; justify-content: center;
  padding: 0;
  border-radius: 50%;
  border: max(2px, calc(var(--u) * 0.16)) solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 calc(var(--u) * 0.2) calc(var(--u) * 0.5) rgba(10, 16, 34, .35);
}
.gr-box-close:hover { background: var(--yellow); }
.gr-box-close:focus-visible { outline: max(2px, calc(var(--u) * 0.16)) solid #FFFDF6; outline-offset: 2px; }
.gr-box-close svg {
  width: 52%; height: 52%;
  fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round;
}
.gr-box-art {
  position: relative;
  width: var(--art-w, calc(var(--u) * 60));
  aspect-ratio: var(--aspect, 1.5);
  container-type: size;
}
.gr-box-img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
  user-select: none;
  /* lifted off the picture behind it */
  filter: drop-shadow(0 calc(var(--u) * 0.8) calc(var(--u) * 1.4) rgba(10, 16, 34, .55));
}
/* the items inside, sized from the drawing so they keep their place on
   its shelves at every size */
.gr-box-art .gr-spot { --box: calc(var(--u) * 5); }
@supports (width: 1cqh) {
  .gr-box-art .gr-spot { --box: calc(var(--item, 18) * 1cqh); }
}
.gr-box-art .gr-name { font-size: max(10px, calc(var(--u) * 1.05)); }

/* A phone holds the labels at a size it can read, which on this beat is
   large against the items: so there they are a touch smaller and break
   word by word, keeping each one about as wide as its item. */
@media (max-height: 430px), (max-width: 820px) {
  .gr-scene .gr-name { font-size: 9px; line-height: 1.05; max-width: 36px; }
  .gr-box-label { font-size: 10px; padding: 3px 8px; }
}

.gr-tally {
  position: absolute;
  /* The same offset .gr-head uses, and for the same reason: the beat is
     full-bleed and the HUD floats ON it rather than above it, so anything
     pinned to the true top of the picture is drawn behind the meters.

     The right inset steps around the story-tree button, which holds
     this corner at this exact height — it is that button's own width
     plus a gap, so the two stay clear of each other at every size. */
  top: max(84px, calc(var(--u) * 6.8));
  right: calc(max(38px, var(--u) * 3.4) + var(--u) * 2.6);
  z-index: 4;
  color: #FFFDF6;
  font-family: var(--font-ui);
  font-weight: var(--w-bold);
  font-size: var(--fs-sm);
  letter-spacing: .06em;
  text-shadow: 0 1px 2px rgba(10, 16, 34, .95),
               0 0 calc(var(--u) * 0.4) rgba(10, 16, 34, .9),
               0 0 calc(var(--u) * 0.4) rgba(10, 16, 34, .9),
               0 0 calc(var(--u) * 1) rgba(10, 16, 34, .7);
}
/* The clock sits beside the title rather than off in a corner, because a
   corner is exactly where nobody looking at the title is looking. The row
   wraps only when the pair genuinely will not fit, and the clock then
   drops under the title still centred and still first in the eye's path.
   Seconds come from PICKUP_SECONDS in js/scenes.js, the words in front of
   the number from PICKUP_TEXT.clock in the same file. */
.gr-headline {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: calc(var(--u) * 0.5) calc(var(--u) * 1.2);
}
.gr-clock {
  display: inline-flex;
  align-items: baseline;
  gap: calc(var(--u) * 0.5);
  padding: calc(var(--u) * 0.35) calc(var(--u) * 0.9);
  border-radius: 999px;
  background: rgba(10, 16, 34, .55);
  border: max(1.5px, calc(var(--u) * 0.12)) solid rgba(255, 253, 246, .5);
  color: #FFFDF6;
  font-family: var(--font-ui);
  font-weight: var(--w-bold);
  font-size: var(--fs-md);
  letter-spacing: .04em;
  white-space: nowrap;                  /* the label never breaks off the number */
  transition: background .2s ease, border-color .2s ease, color .2s ease;
}
/* The label is the quieter half — it says the same thing every second, so
   the number is what carries the weight. */
.gr-clock-label {
  font-weight: var(--w-med);
  font-size: var(--fs-sm);
  opacity: .92;
}
.gr-clock-n {
  min-width: calc(var(--u) * 1.7);      /* two digits, so 10 -> 9 does not jump */
  text-align: center;
  font-variant-numeric: tabular-nums;   /* the box does not twitch per digit */
}
/* the last few seconds, and the moment it runs out */
.gr-clock.low {
  background: rgba(217, 106, 94, .85);
  border-color: #FFFDF6;
  animation: grClock 1s ease infinite;
}
.gr-clock.out { animation: none; }
@keyframes grClock { 50% { transform: scale(1.09); } }
@media (prefers-reduced-motion: reduce) { .gr-clock.low { animation: none; } }

.gr-controls {
  position: absolute;
  left: 0; right: 0; bottom: calc(var(--u) * 2);
  z-index: 4;
  display: flex; justify-content: center;
}

/* ---- time up — and the end panel every beat closes on ----
   Covers the picture so the beat is plainly over, and holds the run
   there until Continue is pressed. One panel for every beat that ends on
   a message (endPanel in js/minigames.js); each one's wording is in its
   own *_TEXT table in js/scenes.js — the picker's is PICKUP_TEXT.timeUp
   and .timeUpGo. Over everything the beat draws, whatever its layers. */
.gr-over {
  position: absolute; inset: 0;
  z-index: 50;
  display: flex; align-items: center; justify-content: center;
  padding: calc(var(--u) * 3);
  background: rgba(10, 16, 34, .68);
  opacity: 0; transition: opacity .22s ease;
}
.gr-over.open { opacity: 1; }
.gr-over-box {
  display: flex; flex-direction: column; align-items: center;
  gap: calc(var(--u) * 1.8);
  max-width: calc(var(--u) * 56);
  padding: calc(var(--u) * 3) calc(var(--u) * 4);
  background: var(--paper);
  border: max(2.5px, calc(var(--u) * 0.2)) solid var(--ink);
  border-radius: calc(var(--u) * 1.4);
  box-shadow: 0 calc(var(--u) * 1.2) calc(var(--u) * 3) rgba(10, 16, 34, .5);
  transform: translateY(calc(var(--u) * 0.8));
  transition: transform .22s ease;
}
.gr-over.open .gr-over-box { transform: none; }
.gr-over-text {
  margin: 0;
  font-family: var(--font-display);
  font-weight: var(--w-body);
  font-size: var(--fs-lg);
  line-height: 1.2;
  color: var(--ink);
  text-align: center;
  text-wrap: balance;          /* two even lines, never one word left alone */
}
/* the beat is over, so the question mark in the corner — the one beat
   that keeps it there, outside the picture — has nothing left to explain */
#scene:has(.gr-over.open) .mg-help-corner { visibility: hidden; }
.gr-over-go {
  width: auto; height: auto;
  border-radius: 999px;
  padding: calc(var(--u) * 0.9) calc(var(--u) * 2.6);
  font-size: var(--fs-md);
  line-height: 1.1;
}
/* the button is a pill here, not the round stamp the other beats use */
.gr-go {
  width: auto;
  height: auto;
  border-radius: 999px;
  padding: calc(var(--u) * 0.95) calc(var(--u) * 2.6);
  font-size: var(--fs-md);
  line-height: 1.1;
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  .gr-spot { animation: none; }
  .gr-box-shape { animation: none; }
  .gr-toast, .gr-toast.on { transform: translate(-50%, 0); }
}

/* ============================================================
   CLEAR THE DRAIN — CY-SHARED-72H-02
   The rubbish and where it sits: DRAIN_ITEMS in js/scenes.js
   The words on it:               DRAIN_TEXT in js/scenes.js
   ============================================================
   The shell is the picker's, class for class — .gr-scene, .gr-bg,
   .gr-head, .gr-controls — so both full-bleed beats are one layout. Only
   the rubbish is its own thing, and everything below is about that.

   Square, because a heap of rubbish is a heap of shapes and giving each
   one a different footprint reads as a ranking that is not there. One
   box, one size, whatever the picture inside it turns out to be. */
/* The heap sits in whichever box is showing the picture — .gr-scene in
   the mini-game, .art-photo-wrap on the situation screen. Both are the
   full stage, so a percentage lands in the same place in each. */
.dr-field { position: absolute; inset: 0; z-index: 2; }
/* On the situation screen the heap is scenery: it is looked at, not
   touched, and every click belongs to the choices over the top of it. */
.dr-still, .dr-still .dr-item { pointer-events: none; }

/* The mini-game crops its picture exactly as the situation screen does.
   Without this the two would frame the same photograph differently and
   the heap would jump the moment the beat opened. */
.dr-scene .gr-bg { object-position: 50% 58%; }

.dr-item {
  position: absolute;
  transform: translate(-50%, -50%);
  appearance: none;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  line-height: 0;
  /* Square, and scaled per item by --dr-scale from the row's own `size`.
     The px floor keeps a piece tappable on a phone, where --u is small. */
  width:  calc(max(38px, var(--u) * 5.4) * var(--dr-scale, 1));
  height: calc(max(38px, var(--u) * 5.4) * var(--dr-scale, 1));
  /* The shadow is what separates one piece from the piece underneath
     it. The breathing is further down — THE DRAIN'S PIECES BREATHE. */
  filter: drop-shadow(0 calc(var(--u) * 0.18) calc(var(--u) * 0.36) rgba(10, 16, 34, .5));
  transition: transform .12s ease, filter .12s ease;
}
/* Pieces overlap, so the one under the cursor lifts to say which one a
   tap would take. Touch has no hover and does not need the answer. */
@media (hover: hover) {
  .dr-item:hover {
    transform: translate(-50%, -50%) scale(1.06);
    filter: drop-shadow(0 calc(var(--u) * 0.3) calc(var(--u) * 0.6) rgba(10, 16, 34, .6));
  }
}
.dr-item:focus-visible {
  outline: max(2.5px, calc(var(--u) * 0.2)) solid var(--yellow);
  outline-offset: calc(var(--u) * 0.2);
  border-radius: calc(var(--u) * 0.3);
}
.dr-img {
  width: 100%; height: 100%;
  object-fit: contain;
  display: block;
  user-select: none;
}
/* the mark a piece falls back to when its row names no picture at all */
.dr-blank {
  display: block;
  width: 100%; height: 100%;
  border-radius: calc(var(--u) * 0.4);
  background: #6E6A55;
  border: max(2px, calc(var(--u) * 0.16)) solid var(--ink);
}
/* the placeholder that names the file a piece is waiting for */
.dr-ph { display: none; }
.dr-item.noart .dr-img { display: none; }
.dr-item.noart .dr-ph {
  display: flex; align-items: center;
  width: 100%; height: 100%;
  box-sizing: border-box;
  background: repeating-linear-gradient(45deg,
    rgba(255, 253, 246, .92) 0 6px, rgba(255, 236, 150, .92) 6px 12px);
  color: var(--ink);
  border: max(2px, calc(var(--u) * 0.14)) dashed var(--ink);
  border-radius: calc(var(--u) * 0.35);
  padding: calc(var(--u) * 0.3);
  font-family: var(--font-ui);
  font-size: max(7px, calc(var(--u) * 0.68));
  line-height: 1.05;
  word-break: break-all;
}
/* Cleared: it lifts out of the heap and is gone. Kept in the layout with
   no pointer events rather than removed, so the pieces underneath do not
   shuffle up a z-index as the heap empties. */
.dr-item.gone {
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -50%) scale(1.35) rotate(8deg);
  transition: opacity .26s ease, transform .26s cubic-bezier(.3, .7, .4, 1);
}

/* Skip is a flow item at the foot of the content everywhere else, and
   this beat has no flow: the wrap has no padding and nothing in normal
   flow, so a static Skip lands half outside the canvas. It goes to the
   corner, where it is reachable — and it matters more here than on most
   beats, because until the last piece is cleared it is the only way off
   this screen. */

.mg-wrap:has(.dr-scene) .mg-skip {
  position: absolute;
  align-self: auto;
  margin: 0;
  right: calc(var(--u) * 1.6);
  bottom: calc(var(--u) * 1.4);
  z-index: 40;
}

@media (prefers-reduced-motion: reduce) {
  .dr-item, .dr-item.gone { transition: none; }
  .dr-item.gone { transform: translate(-50%, -50%); }
}

/* ============================================================
   GAME CURRENCY — the coin drawn before every number in the shop
   The drawing itself: SHOP_CURRENCY in js/scenes.js
   ============================================================
   Used by the purse in the corner and by every price. The number never
   carries a symbol of its own, so swapping the drawing swaps the
   currency everywhere it appears. */
.money {
  display: inline-flex;
  align-items: center;
  gap: .32em;
  white-space: nowrap;
}
/* sized off the text it sits beside, so it tracks any font-size change */
.money .cur {
  width: 1.05em;
  height: 1.05em;
  flex: 0 0 auto;
  display: block;
}
/* Deliberately no per-place override. One coin, one colour, wherever it
   appears — recolour the whole shop by setting --coin-face once on
   .money, never on a single spot. */

/* ============================================================
   SHOP ITEM PICTURES — the square at the head of each row
   Paths: the `img` field on each item in PREP02_SHOP, js/scenes.js
   ============================================================ */
.si-pic {
  position: relative;
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  width: max(38px, calc(var(--u) * 4));
  aspect-ratio: 1 / 1;
  border-radius: calc(var(--u) * 0.5);
  background: var(--yellow-soft);
  overflow: hidden;
}
.si-pic img {
  width: 100%; height: 100%;
  object-fit: contain;
  display: block;
}
/* the placeholder that names the file the row is waiting for */
.si-ph { display: none; }
.si-pic.noart img { display: none; }
.si-pic.noart {
  background: repeating-linear-gradient(45deg,
    var(--paper) 0 5px, var(--yellow-soft) 5px 10px);
  border: 1px dashed var(--ink);
}
.si-pic.noart .si-ph {
  display: block;
  padding: 2px;
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: max(7px, calc(var(--u) * 0.66));
  line-height: 1.05;
  text-align: center;
  word-break: break-all;
}
/* a row that names no picture keeps the column so the names still line up */
.si-pic.empty { background: none; }
/* A picture that opens the larger view says so: its own cursor, and a
   ring on hover, so it reads as a second target inside the row. */
.si-pic[data-zoom] { cursor: zoom-in; }
.si-pic[data-zoom]:hover { box-shadow: 0 0 0 2px var(--ink); }

/* ============================================================
   ENDING PAGE — title lines and the picture
   Lines:   END_TITLE_PARTS in js/engine.js
   Picture: END_IMAGE in js/engine.js
   ============================================================
   .end-title is the stack; each row inside it is one entry from
   END_TITLE_PARTS, so a new row needs only a class named here. */
.end-title { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.end-name {
  font-family: var(--font-title);
  font-size: clamp(22px, 5.4vw, 30px);
  line-height: 1.15;
}
/* The ending type — Fatal, Seriously Affected, Survived with Losses,
   Survived Safely. It is the first thing the page says and the one line
   the player came for, so it is sized to be read across the room rather
   than as a caption on something else. */
.end-tag {
  font-family: var(--font-ui);
  font-weight: var(--w-bold);
  font-size: clamp(16px, 3.6vw, 23px);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink);
  background: var(--yellow);
  border: max(2px, calc(var(--u) * 0.18)) solid var(--ink);
  border-radius: 999px;
  padding: calc(var(--u) * 0.5) calc(var(--u) * 1.5);
  text-align: center;
}
/* A quiet line for the title area, in the register the character's name
   used to be printed in. Nothing uses it today — the name reads inside
   the Your Story section now, as `.end-story-who` — but it is what a new
   END_TITLE_PARTS row reaches for when it wants to sit under the pill
   without competing with it. */
.end-who {
  font-family: var(--font-ui);
  font-weight: var(--w-med);
  font-size: clamp(11px, 2.6vw, 13px);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-2);
}
/* the Fatal ending's pill: this one is not good news */
.end-death .end-tag { background: var(--red); color: #FFFDF6; }

.end-art {
  position: relative;
  width: 100%;
  max-width: 380px;
  aspect-ratio: 16 / 9;
  margin: 4px 0 12px;
  border: 2px solid var(--ink);
  border-radius: 12px;
  overflow: hidden;
  background: var(--yellow-soft);
  flex: 0 0 auto;
  opacity: 0; animation: paraIn .5s ease .16s forwards;
}
.end-art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.end-art-ph { display: none; }
.end-art.noart img { display: none; }
.end-art.noart {
  background: repeating-linear-gradient(45deg,
    var(--paper) 0 8px, var(--yellow-soft) 8px 16px);
  border-style: dashed;
}
.end-art.noart .end-art-ph {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 3px;
  font-family: var(--font-ui);
  color: var(--ink-2);
  text-align: center;
  padding: 8px;
}
.end-art-ph .ph-mark { font-weight: var(--w-bold); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; }
.end-art-ph .ph-path { font-size: 11px; word-break: break-all; }


/* ============================================================
   FAILURE — a status bottomed out and the run stops
   Every word of it: FAIL_TEXT and friends in js/engine.js
   ============================================================ */
#fail-veil {
  position: fixed; inset: 0; z-index: 360;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: rgba(10, 16, 34, .78);
  opacity: 0; transition: opacity .22s ease;
}
#fail-veil.open { opacity: 1; }
html.has-vv #fail-veil { top: var(--vv-top); height: var(--vv-h); }
.fail-panel {
  width: 100%; max-width: 520px;
  max-height: 100%;
  overflow-y: auto;
  background: var(--paper);
  border: 2.5px solid var(--ink);
  border-radius: 16px;
  padding: 24px 24px 22px;
  box-shadow: 0 18px 50px rgba(10, 16, 34, .5);
  transform: translateY(10px);
  transition: transform .22s ease;
}
#fail-veil.open .fail-panel { transform: none; }
.fail-title {
  font-family: var(--font-display);
  font-size: 26px;
  line-height: 1.1;
  margin: 0 0 14px;
}
.fail-list { display: flex; flex-direction: column; gap: 14px; }
/* one block per status that bottomed out; two at once read as two */
.fail-item {
  border-left: 3px solid var(--red, #C8402F);
  padding-left: 12px;
}
.fail-meter {
  display: inline-block;
  font-family: var(--font-ui);
  font-weight: var(--w-bold);
  font-size: 11px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--red, #C8402F);
  margin-bottom: 3px;
}
.fail-head {
  font-family: var(--font-ui);
  font-weight: var(--w-bold);
  font-size: 15.5px;
  line-height: 1.3;
}
.fail-body {
  font-family: var(--font-ui);
  font-weight: var(--w-med);
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink-2);
  margin: 4px 0 0;
}
.fail-acts { display: flex; flex-direction: column; gap: 9px; margin-top: 20px; }
/* Both buttons are the same button. Run Again carries `.continue`, which
   is normally the yellow pill, but neither of these is the recommended
   way out of a failed run — one restarts it, one leaves — so they are
   given one shape, one weight and one colour, the way the ending page
   treats its own pair. Colour arrives on hover, for whichever is under
   the cursor. */
.fail-acts .choice,
.fail-acts .choice.continue {
  width: 100%;
  font-family: var(--font-ui);
  font-weight: var(--w-bold);
  font-size: 15.5px;
  letter-spacing: .01em;
  text-transform: none;
  text-align: center;
  justify-content: center;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 999px;
  color: var(--ink);
}
.fail-acts .choice:hover,
.fail-acts .choice.continue:hover { background: var(--yellow); }

/* ============================================================
   DESTINATION — "choose where to go" at TSU-SHARED-T5-01
   Places: DESTINATIONS in js/scenes.js · Game: js/minigames.js
   ============================================================
   Full-bleed like the picker, and built the same way: an absolutely
   positioned scene with the places sitting on it as percentage
   coordinates, so each one holds its spot at every screen size. */
.mg-wrap:has(.ds-scene) { padding: 0; overflow: hidden; position: relative; }
.mg-wrap:has(.ds-scene) .mg-host { flex: 1 1 auto; min-height: 0; }
.mg-wrap:has(.ds-scene) .mg-after { display: none; }
.ds-scene {
  position: absolute; inset: 0;
  overflow: hidden;
  background: var(--page);
}
.ds-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ds-head {
  position: absolute; left: 0; right: 0;
  top: max(84px, calc(var(--u) * 6.8));
  z-index: 3;
  text-align: center;
  padding: 0 calc(var(--u) * 8);
  pointer-events: none;
}
.ds-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: var(--w-body);
  font-size: var(--fs-xl);
  line-height: 1.15;
  color: var(--ink);
}
.ds-hint {
  margin: calc(var(--u) * 0.35) 0 0;
  font-family: var(--font-ui);
  font-weight: var(--w-med);
  font-size: var(--fs-sm);
  color: var(--ink-2);
}
.ds-field { position: absolute; inset: 0; z-index: 2; }
.ds-place {
  position: absolute;
  transform: translate(-50%, -50%);
  appearance: none;
  display: flex; flex-direction: column; align-items: center;
  gap: calc(var(--u) * 0.5);
  padding: calc(var(--u) * 0.6);
  background: none; border: none;
  cursor: pointer;
  color: var(--ink);
}
.ds-mark {
  display: flex; align-items: center; justify-content: center;
  width: max(38px, calc(var(--u) * 4.2));
  height: max(38px, calc(var(--u) * 4.2));
  border-radius: 50%;
  border: max(2px, calc(var(--u) * 0.18)) solid var(--ink);
  background: var(--paper);
  font-size: var(--fs-lg);
  box-shadow: 0 calc(var(--u) * 0.25) 0 rgba(44, 54, 99, .25);
  transition: background .14s ease, transform .1s ease;
}
.ds-place:hover .ds-mark { background: var(--yellow); }
.ds-place.took .ds-mark { background: var(--yellow); transform: scale(1.08); }
.ds-label {
  display: flex; flex-direction: column; align-items: center;
  font-family: var(--font-ui);
  line-height: 1.2;
  /* no plate behind the words — the same rule the picker's labels follow */
  text-shadow: 0 1px 2px var(--paper), 0 0 calc(var(--u) * 0.6) var(--paper),
               0 0 calc(var(--u) * 0.6) var(--paper);
}
.ds-name { font-weight: var(--w-bold); font-size: var(--fs-md); }
.ds-note { font-weight: var(--w-med); font-size: var(--fs-sm); color: var(--ink-2); }
.ds-place.took .ds-name { text-decoration: underline; text-underline-offset: .2em; }
.ds-controls {
  position: absolute;
  left: 0; right: 0; bottom: calc(var(--u) * 2);
  z-index: 4;
  display: flex; justify-content: center;
}
.ds-go {
  width: auto; height: auto;
  border-radius: 999px;
  padding: calc(var(--u) * 0.95) calc(var(--u) * 2.6);
  font-size: var(--fs-md);
  line-height: 1.1;
}
.ds-go[disabled] { opacity: .45; cursor: not-allowed; }

/* ============================================================
   STORY TREE — the button, top right under the header
   ============================================================ */
#tree-btn {
  position: absolute;
  right: calc(var(--u) * 1.2);
  top: max(84px, calc(var(--u) * 6.8));
  z-index: 41;
  appearance: none;
  width: max(38px, calc(var(--u) * 3.4));
  height: max(38px, calc(var(--u) * 3.4));
  display: flex; align-items: center; justify-content: center;
  padding: 0;
  border: max(2px, calc(var(--u) * 0.14)) solid var(--ink);
  border-radius: calc(var(--u) * 0.6);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(44, 54, 99, .2);
  transition: background .14s ease, transform .07s ease;
}
#tree-btn svg { width: 62%; height: 62%; fill: currentColor; }
#tree-btn:hover { background: var(--yellow); }
#tree-btn:active { transform: translateY(2px); box-shadow: none; }
#tree-btn.hidden { display: none; }

/* ============================================================
   STORY TREE — the page
   Nodes are the events this character can reach; see js/tree.js
   ============================================================
   The tree is a layer OVER the game, not a screen that replaces it, so
   whatever the player was looking at is still there underneath and
   still holds its own state — a minigame keeps playing, a shop keeps its
   basket, a result page stays a result page.

   Everything inside the chart (.tr-world) is sized in plain pixels, not
   in stage units: the chart has its own zoom, and its node sizes are the
   numbers js/tree.js lays it out with. HEAD_H there is the title bar
   here — 2px border + 30px bar — so if one changes, change the other. */
#tree-veil {
  position: absolute; inset: 0;
  z-index: 300;
}
html.has-vv #tree-veil { top: var(--vv-top); height: var(--vv-h); }

.tr-screen {
  /* ---- THE TREE'S OWN COLOURS — EDIT HERE ---- */
  --tr-bg:       #EEF0F4;   /* the page behind the chart */
  --tr-line:     #B3B9C6;   /* a line not taken */
  --tr-lit:      #2F6BD8;   /* the path this run took */
  --tr-shut:     #DDE1E8;   /* a node not reached yet */
  --tr-shut-ink: #7A828F;
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  background: var(--tr-bg);
}

/* ---- the bar: name, key, buttons ----
   The heading carries the spacer, so the key and the buttons always sit
   together at the right edge. The side padding clears a notch. */
.tr-bar {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: max(18px, calc(var(--u) * 1.4));
  padding: max(10px, calc(var(--u) * 0.75)) max(18px, calc(var(--u) * 1.4), env(safe-area-inset-right, 0px))
           max(10px, calc(var(--u) * 0.75)) max(18px, calc(var(--u) * 1.4), env(safe-area-inset-left, 0px));
  background: var(--paper);
  border-bottom: 2px solid var(--ink);
  z-index: 2;
}
.tr-heading {
  display: flex; flex-direction: column; gap: 2px;
  line-height: 1.1; margin-right: auto; min-width: 0;
}
.tr-h1 { font-family: var(--font-title); font-size: max(21px, calc(var(--u) * 1.65)); color: var(--ink); white-space: nowrap; }
.tr-h2 {
  font-family: var(--font-ui); font-weight: var(--w-bold);
  font-size: max(10.5px, calc(var(--u) * 0.82)); letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tr-legend { display: flex; gap: max(14px, calc(var(--u) * 1.1)); flex-wrap: nowrap; }
.tr-key {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--font-ui); font-weight: var(--w-med);
  font-size: max(12px, calc(var(--u) * 0.94)); color: var(--ink-2);
  white-space: nowrap;
}
.tr-key .sw { flex: 0 0 auto; width: max(12px, calc(var(--u) * 0.94)); height: max(12px, calc(var(--u) * 0.94)); border-radius: 3px; border: 1.5px solid var(--ink); }
.tr-key .sw.now  { background: var(--yellow); }
.tr-key .sw.open { background: #fff; }
.tr-key .sw.shut { background: var(--tr-shut); border-color: #98A0AE; }
.tr-key .sw.path { width: max(18px, calc(var(--u) * 1.4)); height: 0; border: 0; border-top: 3px solid var(--tr-lit); border-radius: 2px; }
.tr-acts { display: flex; gap: 8px; flex: 0 0 auto; }
.tr-btn {
  appearance: none;
  min-height: max(36px, calc(var(--u) * 2.8));
  padding: max(6px, calc(var(--u) * 0.45)) max(15px, calc(var(--u) * 1.15));
  font-family: var(--font-ui); font-weight: var(--w-bold); font-size: max(13px, calc(var(--u) * 1.02));
  border: 2px solid var(--ink); border-radius: 999px;
  background: var(--paper); color: var(--ink); cursor: pointer;
  white-space: nowrap;
}
.tr-btn:hover { background: var(--yellow); }
.tr-btn.solid { background: var(--yellow); }
.tr-btn:focus-visible { outline: 3px solid var(--tr-lit); outline-offset: 2px; }

/* ---- the pannable surface ---- */
.tr-canvas {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  cursor: grab;
  touch-action: none;          /* the gestures are ours, not the browser's */
  background-image:
    linear-gradient(rgba(44,54,99,.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(44,54,99,.05) 1px, transparent 1px);
  background-size: 26px 26px;
}
.tr-canvas.grabbing { cursor: grabbing; }
.tr-world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.tr-bands, .tr-nodes { position: absolute; left: 0; top: 0; }
.tr-wires { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }

/* ---- one band per chapter, named at the top ---- */
.tr-band {
  position: absolute; top: 0;
  border-radius: 16px;
  background: rgba(44, 54, 99, .035);
}
.tr-band.odd { background: rgba(44, 54, 99, .075); }
.tr-band-head {
  position: absolute; left: 0; right: 0; top: 16px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 0 12px;
  text-align: center;
}
.tr-band-num {
  font-family: var(--font-ui); font-weight: var(--w-bold);
  font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-2);
}
.tr-band-name {
  max-width: 100%;
  font-family: var(--font-title); font-size: 16px; line-height: 1.15;
  color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---- lines ---- */
.tr-edge {
  fill: none; stroke: var(--tr-line); stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}
.tr-edge.lit { stroke: var(--tr-lit); stroke-width: 3.2; }
.tr-arrow { fill: var(--tr-line); }
.tr-arrow.lit { fill: var(--tr-lit); }
/* where several scenes all lead on to the same few */
.tr-hub { fill: #fff; stroke: var(--tr-line); stroke-width: 2.5; }
.tr-hub.lit { stroke: var(--tr-lit); fill: var(--tr-lit); }

/* ---- one node ---- */
.tr-node {
  position: absolute;
  border: 2px solid var(--ink);
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
  font-family: var(--font-ui);
  box-shadow: 0 2px 0 rgba(44, 54, 99, .12);
}
.tr-head {
  display: flex; align-items: center; gap: 6px;
  height: 30px; box-sizing: border-box;
  padding: 0 10px;
  background: rgba(44, 54, 99, .05);
  border-bottom: 1.5px solid rgba(44, 54, 99, .16);
}
.tr-title {
  flex: 1 1 auto; min-width: 0;
  font-weight: var(--w-bold); font-size: 13.5px; line-height: 1.2;
  color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tr-nlock { flex: 0 0 auto; display: flex; color: #8A919D; }
.tr-nlock .tr-lock { width: 12px; height: 12px; }
.tr-body { display: flex; flex-direction: column; gap: 5px; padding: 7px 10px 8px; }
/* the choice this run took, in two lines at most */
.tr-pick { display: flex; align-items: flex-start; gap: 7px; }
.tr-id {
  flex: 0 0 auto;
  width: 16px; height: 16px; margin-top: 1px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 4px;
  background: var(--ink); color: var(--paper);
  font-weight: var(--w-bold); font-size: 10px;
}
.tr-txt {
  flex: 1 1 auto; min-width: 0;
  font-weight: var(--w-med); font-size: 12px; line-height: 1.35;
  color: var(--ink);
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
  overflow: hidden;
}
.tr-deltas { display: flex; flex-wrap: wrap; gap: 4px; padding-left: 23px; }
.tr-d {
  font-weight: var(--w-bold); font-size: 10px; line-height: 1.5;
  padding: 0 6px; border-radius: 999px; white-space: nowrap;
}
.tr-d.up   { background: rgba(46, 139, 87, .15); color: #1F6B41; }
.tr-d.down { background: rgba(200, 64, 47, .13); color: #A6321F; }
.tr-more {
  display: flex; align-items: center; gap: 5px;
  font-weight: var(--w-med); font-size: 11.5px; line-height: 1.3;
  color: var(--ink-2);
}
.tr-pick + .tr-more, .tr-deltas + .tr-more { padding-left: 23px; }
.tr-lock { width: 11px; height: 11px; flex: 0 0 auto; fill: currentColor; }

/* the three states a node can be in */
.tr-node.now {
  box-shadow: 0 0 0 4px var(--yellow), 0 8px 20px rgba(44, 54, 99, .25);
}
.tr-node.now .tr-head { background: var(--yellow); }
.tr-node.shut {
  background: var(--tr-shut);
  border-color: #A3AAB7;
  box-shadow: none;
}
.tr-node.shut .tr-head { background: #CFD4DC; border-bottom-color: #B9BFCA; }
.tr-node.shut .tr-title { color: var(--tr-shut-ink); }
.tr-node.shut .tr-more { color: #8A919D; }

/* ---- how to move it: said once, then it fades ---- */
.tr-hint {
  position: absolute; left: 50%;
  bottom: max(12px, env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(44, 54, 99, .85);
  color: #fff;
  font-family: var(--font-ui); font-weight: var(--w-med); font-size: max(12px, calc(var(--u) * 0.94));
  white-space: nowrap;
  pointer-events: none;
  transition: opacity .5s ease;
}
.tr-hint.gone { opacity: 0; }

/* A tablet or a small laptop: the key tightens up. */
@media (max-width: 1100px) {
  .tr-bar { gap: 14px; }
  .tr-legend { gap: 11px; }
  .tr-key { font-size: 11px; gap: 5px; }
}
/* A phone in landscape. The bar becomes one tight row so the chart keeps
   as much of the short screen as it can; the buttons stay finger-sized. */
@media (max-height: 500px), (max-width: 820px) {
  .tr-bar { gap: 10px; padding-top: 6px; padding-bottom: 6px; }
  .tr-h1 { font-size: 17px; }
  .tr-h2 { font-size: 9px; }
  .tr-legend { gap: 9px; }
  .tr-key { font-size: 10.5px; gap: 4px; }
  .tr-key .sw { width: 10px; height: 10px; border-width: 1.2px; }
  .tr-key .sw.path { width: 14px; height: 0; border-top-width: 3px; }
  .tr-btn { min-height: 34px; padding: 4px 12px; font-size: 12px; }
  .tr-hint { font-size: 11px; padding: 5px 12px; }
}
/* Narrower still. The yellow ring and the blue path explain themselves;
   grey against white is the difference that needs a key, so that stays. */
@media (max-width: 760px) {
  .tr-legend .k-now, .tr-legend .k-path { display: none; }
}


/* ---- the shop's item pictures sit on nothing ----
   They are real cut-outs now, so there is no tile behind them. Later in
   the file than the rule that gave them one, so this wins; a missing
   picture still shows its hatched placeholder (.si-pic.noart). */
.si-pic { background: none; }

/* ============================================================
   THE DRAIN'S PIECES BREATHE
   Only the ones that can be clicked: the mini-game's, never the still
   pile laid over the choice page. It animates the `scale` property, not
   `transform`, so it composes with the translate that places each piece
   and with the hover lift, instead of fighting them. A cleared piece
   stops, so its lift-away plays from where it was.
   ============================================================ */
.dr-field:not(.dr-still) .dr-item:not(.gone) {
  animation: drBreath 2.4s ease-in-out infinite;
}
/* staggered, so the heap moves like a heap and not a metronome */
.dr-field:not(.dr-still) .dr-item:nth-child(3n)   { animation-delay: -.8s; }
.dr-field:not(.dr-still) .dr-item:nth-child(3n+1) { animation-delay: -1.6s; }
@keyframes drBreath {
  0%, 100% { scale: 1; }
  50%      { scale: 1.08; }
}
@media (prefers-reduced-motion: reduce) {
  .dr-field .dr-item { animation: none; }
}

/* ---- no yellow on the shop's rows either ----
   Hovering or owning an item no longer tints its row. An owned item still
   shows its tick and its green price, so the basket stays readable. */
.shop-item:hover:not(.cant), .shop-item.owned { background: none; }

/* ---- the header portrait: solid white behind the avatar ----
   The avatars are transparent PNGs (AVATAR_PNG in js/engine.js), so the
   circle needs a ground of its own. It was a translucent cream, which a
   dark photograph showed through. */
#hud-port { background: #fff; }

/* ---- the cyclone market locks a line with aria-disabled, not disabled ----
   A disabled button would swallow the click on its picture, and a line that
   has sold out can still be opened larger. So the row's cursor follows the
   attribute, and the picture keeps its zoom cursor. */
.shop-item[aria-disabled="true"] { cursor: default; }
.shop-item[aria-disabled="true"] .si-pic[data-zoom] { cursor: zoom-in; }

/* ============================================================
   THE CYCLONE MARKET — the whole shelf on screen, on any screen
   ============================================================
   Six items as a shelf of tiles, three across and two down, so nothing
   scrolls. The stage is always landscape — a phone held upright gets the
   rotate screen first — so what a small screen has to spare is width,
   not height. Two rows leave a finger-sized tile even on a phone whose
   browser bar is showing (about 300px of height).

   The panel may use the full height between the header and the bottom
   edge. Every other shop card stops at 74%, which is what squeezed this
   list to a single visible row on a phone. The list keeps its scroll as
   a last resort, for a screen shorter than any phone.

   Scoped to .cs-wrap — the tsunami shop's list is untouched.
   ============================================================ */
.cs-wrap.shop-card {
  max-width: calc(var(--u) * 74);
  max-height: 100% !important;          /* over .shop-card's 74% */
  padding: max(5px, calc(var(--u) * 0.8)) max(10px, calc(var(--u) * 1.1));
}
.cs-wrap .shop-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-rows: 1fr;                  /* every tile the same height */
  gap: calc(var(--u) * 0.8);
  max-width: none;
  padding-top: calc(var(--u) * 0.6);
}
/* picture on the left; the name over its tag on the right */
.cs-wrap .shop-item {
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: auto auto;
  align-content: center;
  column-gap: calc(var(--u) * 0.8);
  row-gap: 0;
  padding: calc(var(--u) * 0.45) calc(var(--u) * 0.7);
  border: max(1px, calc(var(--u) * 0.1)) solid var(--hairline);
  border-radius: calc(var(--u) * 0.8);
}
.cs-wrap .si-pic {
  grid-row: 1 / span 2;
  width: max(24px, calc(var(--u) * 4.6));
}
.cs-wrap .shop-item .si-name {
  grid-column: 2; grid-row: 1; align-self: end;
  font-size: max(12px, calc(var(--u) * 1.42));
  line-height: 1.25;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cs-wrap .shop-item .si-price {
  grid-column: 2; grid-row: 2; align-self: start;
  text-align: left;
  font-size: max(10.5px, calc(var(--u) * 1.15));
  line-height: 1.25;
}
/* One line, always held open, so the sold-out note arriving at zero does
   not push the panel taller in the last second. */
.cs-wrap .cs-note {
  min-height: 1.35em;
  line-height: 1.35;
  margin-top: calc(var(--u) * 0.5);
}
.cs-wrap .after { margin-top: calc(var(--u) * 0.6); }
/* the home-bar inset along the bottom of a notched phone */
.cs-scene { padding-bottom: max(calc(var(--u) * 2), env(safe-area-inset-bottom, 0px)); }
/* On a phone the header is only about 52px tall — its bars and labels
   are fixed sizes (the #hud rule in the short-screen block), so it barely
   changes with the screen. The market's top gap follows it there rather
   than keeping the 84px the larger header needs. */
@media (max-height: 430px), (max-width: 820px) {
  .cs-scene { padding-top: 60px; }
}
/* Skip goes to the corner, as on every full-bleed beat (the pick-up, the
   lane, the drain). */
.mg-wrap:has(.cs-scene) .mg-skip {
  position: absolute;
  align-self: auto;
  margin: 0;
  right: calc(var(--u) * 1.6);
  bottom: calc(var(--u) * 1.4);
  z-index: 40;
}
/* On a narrow stage the shelf and Skip want the same bottom-right corner:
   Skip is about 74px wide on any phone (its sizes have pixel floors) and
   the panel is most of the stage. So the market keeps that corner for
   Skip and the panel centres in the space to its left, the same size as
   everywhere else, rather than letting the two overlap — on the smallest
   phones Skip sat on the end of Continue.

   Narrow means a stage under ~760px wide: a window that narrow, or one
   short enough (427px) that the 16:9 stage is that narrow inside it.
   Above that the corner already leaves Skip at least ~12px of room. */
@media (max-width: 760px), (max-height: 427px) {
  .cs-wrap { margin: 0 calc(84px + var(--u) * 1.6) 0 0; }
}

/* ============================================================
   THE TSUNAMI SHOP — the panel hugs its shelf
   The shelf itself: PREP02_SHOP in js/scenes.js
   ============================================================
   The panel used to take the whole width of the stage while the shelf
   inside it stopped at 34em, so a desktop showed a narrow list in a wide
   empty card, with the title bar and Continue stretched across all of it.
   Now the panel is as wide as the shelf plus a margin of its own, and it
   sits centred on the screen.

   The shelf's width grows with the stage — it used to stay 544px on any
   screen while the row text grew, so a large monitor crammed big words
   into a small list — and never drops below the 34em a phone needs. The
   title row spans the shelf, and Continue is only as wide as its word.
   Scoped to .shop-tsu: the cyclone market (.cs-wrap) is untouched. */
.paras.shop-tsu {
  align-self: center;
  width: fit-content;
  max-width: 100%;
  padding: calc(var(--u) * 1.4) calc(var(--u) * 2.4) calc(var(--u) * 1.6);
}
.shop-tsu .shop-list {
  width: max(34em, calc(var(--u) * 42.5));
  max-width: 100%;
}
.shop-tsu .after .choices { margin-top: calc(var(--u) * 1); }
.shop-tsu .choices > .choice.continue {
  justify-self: center;
  width: auto;
  min-width: 0;
  min-height: max(34px, calc(var(--u) * 3.6));
  padding: calc(var(--u) * 0.7) calc(var(--u) * 2.8);
  justify-content: center;
}

/* ============================================================
   THE COUNT — Lina's headcount, TSU-LINA-T5-01
   Pictures, sizes, speeds and words: COUNT_* in js/scenes.js
   The walking and the counter:       countGame in js/minigames.js
   ============================================================
   Full screen on the drain's shell (.gr-scene, .gr-bg, .gr-head): the
   picture fills the stage, the title floats on it, the class walks in
   the band between the title and the bar, and the bar sits at the
   bottom centre with Skip on the far right of the same line. */
.mg-wrap:has(.cn-scene) .mg-skip,
.mg-wrap:has(.hd-scene) .mg-skip,
.mg-wrap:has(.rd-scene) .mg-skip,
.mg-wrap:has(.sg-scene) .mg-skip,
.mg-wrap:has(.jg-scene) .mg-skip,
.mg-wrap:has(.ln-scene) .mg-skip,
.mg-wrap:has(.ch-scene) .mg-skip {
  position: absolute;
  align-self: auto;
  margin: 0;
  right: calc(var(--u) * 1.6);
  bottom: calc(var(--u) * 1.4);
  z-index: 40;
}

/* ---- the class ----
   Every child is positioned by js/minigames.js, by its FEET: the picture
   is drawn standing on the point it is moved to. Height is the one size
   that is set (COUNT_SCENE.size); the width follows the picture. */
/* the herd draws the same children, so it sets the same height */
.cn-scene, .hd-scene { --cn-h: max(32px, calc(var(--u) * var(--cn-kid, 6.5))); }
.cn-field {
  position: absolute; inset: 0;
  z-index: 2;
  overflow: hidden;
  pointer-events: none;
}
.cn-kid {
  position: absolute;
  left: 0; top: 0;
  height: var(--cn-h);
  will-change: transform;
}
/* The picture, which turns to face the way the child walks. The tick is
   its sibling, not its child, so the tick never reads backwards. */
.cn-body {
  height: 100%;
  transition: opacity .3s ease;
}
.cn-kid.flip .cn-body { transform: scaleX(-1); }
.cn-kid img {
  display: block;
  height: 100%;
  width: auto;
  user-select: none;
  -webkit-user-select: none;
}

/* ---- already counted ----
   The COUNT_START children counted before the beat begins look the way a
   picked item does in Take What You Can Reach: dimmed back, with the same
   yellow tick at the corner. What is left bright is what is left to count. */
.cn-kid.checked .cn-body { opacity: .58; }
.cn-tick {
  position: absolute;
  top: -6%; right: -18%;
  width: max(16px, calc(var(--cn-h) * .27));
  height: max(16px, calc(var(--cn-h) * .27));
  display: none;
  align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--yellow);
  border: max(1.5px, calc(var(--cn-h) * .03)) solid var(--ink);
  color: var(--ink);
  font-family: var(--font-ui);
  font-weight: var(--w-bold);
  font-size: max(9px, calc(var(--cn-h) * .15));
  line-height: 1;
  box-shadow: 0 1px 2px rgba(10, 16, 34, .3);
}
.cn-kid.checked .cn-tick { display: flex; }
/* a soft shadow on the ground, so a child stands ON the picture */
.cn-kid::after {
  content: "";
  position: absolute;
  left: 16%; right: 16%; bottom: -3%;
  height: 9%;
  border-radius: 50%;
  background: rgba(40, 30, 20, .24);
  z-index: -1;
}
/* a picture that is missing: a hatched box naming the file it wants */
.cn-ph { display: none; }
.cn-kid.noart .cn-body { aspect-ratio: 9 / 20; }
.cn-kid.noart img { display: none; }
.cn-kid.noart .cn-ph {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%;
  padding: 2px;
  background: repeating-linear-gradient(45deg,
    var(--paper) 0 5px, var(--yellow-soft) 5px 10px);
  border: 1px dashed var(--ink);
  border-radius: 4px;
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: max(7px, calc(var(--u) * 0.62));
  line-height: 1.05;
  text-align: center;
  word-break: break-all;
}

/* ---- the bar at the bottom: the count's quiz, the herd's tally ----
   Never wider than the space between the two Skip-sized margins, so on
   the narrowest phone it still clears Skip in the corner. */
.cn-dock {
  position: absolute;
  left: 50%; bottom: calc(var(--u) * 1.4);
  transform: translateX(-50%);
  z-index: 5;
  display: flex; flex-direction: column; align-items: center;
  gap: calc(var(--u) * 0.6);
  width: max-content;
  max-width: calc(100% - 2 * (max(74px, calc(var(--u) * 8)) + var(--u) * 3.2));
  padding: calc(var(--u) * 0.9) calc(var(--u) * 1.8) calc(var(--u) * 0.85);
  background: rgba(10, 16, 34, .62);
  border-radius: calc(var(--u) * 1.6);
  backdrop-filter: blur(calc(var(--u) * 0.4));
  -webkit-backdrop-filter: blur(calc(var(--u) * 0.4));
  box-shadow: 0 calc(var(--u) * 0.4) calc(var(--u) * 1.6) rgba(6, 10, 24, .35);
}
/* ---- the quiz: the question, and one button per answer ----
   The box sits higher than the herd's bar, well clear of the bottom
   edge — and on a phone above its safe strip (--safe-bottom), where the
   home bar lives. The question is set large, in the display face, and
   the answers are big, even buttons in one row — a tap target on every
   screen. The one picked turns yellow and the others step back; the end
   panel then gives the verdict (endPanel in js/minigames.js). */
.cn-quiz {
  bottom: calc(var(--u) * 4.4);
  gap: calc(var(--u) * 1);
  padding: calc(var(--u) * 1.3) calc(var(--u) * 2.2) calc(var(--u) * 1.4);
}
.cn-q {
  margin: 0;
  max-width: calc(var(--u) * 54);
  text-align: center;
  color: #FFFDF6;
  font-family: var(--font-display);
  font-weight: var(--w-body);
  font-size: max(18px, calc(var(--u) * 2.2));
  line-height: 1.2;
  text-wrap: balance;
}
.cn-opts {
  display: flex; align-items: center; justify-content: center;
  gap: calc(var(--u) * 1.2);
}
.cn-opt {
  appearance: none;
  flex: 0 0 auto;
  min-width: max(64px, calc(var(--u) * 8.4));
  height: max(44px, calc(var(--u) * 4.6));
  padding: 0 calc(var(--u) * 1.6);
  border-radius: 999px;
  border: max(2px, calc(var(--u) * 0.18)) solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-weight: var(--w-bold);
  font-size: max(20px, calc(var(--u) * 2.4));
  font-variant-numeric: tabular-nums;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(44, 54, 99, .3);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform .06s, box-shadow .06s, background .15s, opacity .2s;
}
.cn-opt:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 rgba(44, 54, 99, .3); }
.cn-opt.picked { background: var(--yellow); }
.cn-opt:disabled { cursor: default; }
.cn-opt:disabled:not(.picked) { opacity: .45; box-shadow: none; }
@media (hover: hover) and (pointer: fine) {
  .cn-opt:hover:not(:disabled) { background: var(--yellow); }
}
.cn-hint {
  margin: 0;
  max-width: calc(var(--u) * 54);
  text-align: center;
  color: #FFFDF6;
  font-family: var(--font-ui);
  font-weight: var(--w-med);
  font-size: max(12px, calc(var(--u) * 1.25));
  line-height: 1.35;
}

/* A phone's header is about 52px tall rather than the 84px the title
   clears on a desktop, so the title comes up under it — every pixel it
   gives back is room for the class to walk in — and the bar tightens. */
@media (max-height: 430px), (max-width: 820px) {
  .cn-scene .gr-head, .hd-scene .gr-head { top: 58px; }
  .cn-dock { gap: 4px; padding: 6px 12px 7px; }
  .cn-opts { gap: 8px; }
  .cn-hint { font-size: 11px; line-height: 1.3; }
  .cn-quiz { bottom: calc(var(--safe-bottom) + 8px); gap: 6px; padding: 8px 16px 10px; }
  .cn-q { font-size: 17px; }
}
/* The smallest phones (a stage under ~600px wide): the instruction holds
   to two lines rather than three, which is a third more ground to walk. */
@media (max-width: 600px), (max-height: 340px) {
  .cn-dock { padding: 5px 8px 6px; }
  .cn-hint { font-size: 10.5px; }
  .cn-quiz { padding: 7px 12px 8px; }
  .cn-q { font-size: 16px; }
}

/* ============================================================
   THE HERD — Lina's class, CY-LINA-24H-01
   Pictures, sizes, speeds and words: HERD_* in js/scenes.js
   The walking and the steering:      herdGame in js/minigames.js
   ============================================================
   The count's layout, part for part: the plaza fills the stage, the
   title floats on it, everyone walks in the band between the title and
   the bar, the bar sits at the bottom centre and Skip on the far right
   of the same line (see THE COUNT above, which both share). The children
   ARE the count's children — .cn-kid, .cn-body, .cn-tick — and a child
   brought in takes the same tick a counted child wears there. It is not
   dimmed, though: the area already sets it apart, and the class it ends
   on should look like children, not like spent buttons.

   What is the herd's own: the assembly area, Lina, the spot she is
   walking to, and the tally in the bar. */
.hd-scene {
  --hd-lina-h: max(52px, calc(var(--u) * var(--hd-lina, 11)));
  /* a held finger walks Lina; it must never scroll or zoom the page */
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

/* ---- the assembly area ----
   Placed and sized by js/minigames.js from HERD_SCENE.zone. Painted on
   the ground: a warm wash with a dashed line, the same marking the old
   board used, and its name on a tab across the top edge. It breathes
   gently until the class is in, and brightens as each child arrives. */
.hd-zone {
  position: absolute;
  z-index: 1;
  border-radius: calc(var(--u) * 1.6);
  background: rgba(255, 241, 176, .55);
  border: max(2.5px, calc(var(--u) * 0.24)) dashed var(--ink);
  box-shadow: 0 0 0 max(3px, calc(var(--u) * 0.3)) rgba(255, 253, 246, .5),
              inset 0 0 calc(var(--u) * 2) rgba(255, 217, 31, .35);
  pointer-events: none;
  animation: hdZone 2.6s ease-in-out infinite;
}
@keyframes hdZone {
  50% { box-shadow: 0 0 0 max(5px, calc(var(--u) * 0.55)) rgba(255, 217, 31, .45),
                    inset 0 0 calc(var(--u) * 2) rgba(255, 217, 31, .5); }
}
.hd-zone.pop { animation: hdZonePop .6s ease; }
@keyframes hdZonePop {
  30% { background: rgba(255, 217, 31, .6);
        box-shadow: 0 0 0 max(6px, calc(var(--u) * 0.7)) rgba(255, 217, 31, .6),
                    inset 0 0 calc(var(--u) * 2) rgba(255, 217, 31, .6); }
}
.hd-scene.done .hd-zone { animation: none; border-style: solid; }
.hd-zone-label {
  position: absolute;
  left: 50%; top: 0;
  transform: translate(-50%, -55%);
  padding: calc(var(--u) * 0.3) calc(var(--u) * 1.1);
  border-radius: 999px;
  background: var(--ink);
  color: #FFFDF6;
  font-family: var(--font-ui);
  font-weight: var(--w-bold);
  font-size: var(--fs-sm);
  letter-spacing: .08em;
  text-transform: uppercase;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(10, 16, 34, .35);
}

/* ---- Lina ----
   Positioned by her FEET, like the children. The box is the figure
   itself: js/minigames.js finds it inside the portrait and writes its
   place as --l-x0/--l-y0 (top-left) and --l-w/--l-h (size), each a share
   of the whole picture, and --l-ar the figure's own proportions. The
   picture is then drawn large enough, and far enough up and left, that
   only the figure falls inside the box. */
.hd-lina {
  --l-x0: 0; --l-y0: 0; --l-w: 1; --l-h: 1;
  position: absolute;
  left: 0; top: 0;
  height: var(--hd-lina-h);
  aspect-ratio: var(--l-ar, .42);
  will-change: transform;
}
.hd-lina-body {
  position: absolute; inset: 0;
  transform-origin: 50% 100%;
}
.hd-lina img {
  position: absolute;
  height: calc(100% / var(--l-h));
  width: auto;
  max-width: none;
  left: calc(-100% * var(--l-x0) / var(--l-w));
  top: calc(-100% * var(--l-y0) / var(--l-h));
  user-select: none;
  -webkit-user-select: none;
  pointer-events: none;
}
/* the ring at her feet: this is the one you move */
.hd-lina::before {
  content: "";
  position: absolute;
  left: 50%; bottom: 0;
  width: 170%; height: 20%;
  transform: translate(-50%, 45%);
  border-radius: 50%;
  background: rgba(255, 217, 31, .38);
  border: max(2px, calc(var(--u) * 0.2)) solid var(--yellow);
  box-shadow: 0 0 0 1px rgba(44, 54, 99, .35);
  z-index: -1;
}
/* a step in her walk, from the feet, only while she is moving */
.hd-lina.walking .hd-lina-body { animation: hdWalk .5s ease-in-out infinite; }
@keyframes hdWalk {
  25% { transform: translateY(-2.5%) rotate(-1.8deg); }
  50% { transform: none; }
  75% { transform: translateY(-2.5%) rotate(1.8deg); }
}
/* her picture missing: the count's hatched box, at her size */
.hd-lina .cn-ph { display: none; }
.hd-lina.noart { aspect-ratio: 9 / 22; }
.hd-lina.noart img { display: none; }
.hd-lina.noart .cn-ph {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%;
  padding: 2px;
  background: repeating-linear-gradient(45deg,
    var(--paper) 0 5px, var(--yellow-soft) 5px 10px);
  border: 1px dashed var(--ink);
  border-radius: 4px;
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: max(7px, calc(var(--u) * 0.62));
  line-height: 1.05;
  text-align: center;
  word-break: break-all;
}

/* in the area: the tick, at full colour — see the note above */
.hd-scene .cn-kid.checked .cn-body { opacity: 1; }

/* A child running from her hops as it goes. It moves on `translate`, not
   `transform`, so the turn the picture already carries is left alone. */
.hd-scene .cn-kid.run .cn-body { animation: hdHop .3s ease-in-out infinite; }
@keyframes hdHop { 50% { translate: 0 -7%; } }

/* where a tap or a held finger is sending her — it stays until she is there */
.hd-target {
  position: absolute;
  left: 0; top: 0;
  z-index: 1;
  width: max(18px, calc(var(--u) * 2.2));
  height: max(18px, calc(var(--u) * 2.2));
  border-radius: 50%;
  border: max(2px, calc(var(--u) * 0.2)) solid #FFFDF6;
  box-shadow: 0 0 0 max(1.5px, calc(var(--u) * 0.12)) var(--ink);
  opacity: 0;
  transition: opacity .15s ease;
}
.hd-target.on { opacity: .9; animation: hdTarget 1s ease-in-out infinite; }
@keyframes hdTarget { 50% { scale: .7; } }

/* ---- the bar: the tally, and under it how to move ----
   It is the count's bar (.cn-dock, .cn-hint). When the class is in, the
   tally says so and Continue takes the hint's place. */
.hd-tally {
  margin: 0;
  display: flex; align-items: baseline; justify-content: center;
  gap: .3em;
  color: #FFFDF6;
  font-family: var(--font-ui);
  font-weight: var(--w-bold);
  font-size: var(--fs-md);
  letter-spacing: .02em;
  white-space: nowrap;
}
.hd-n {
  display: inline-block;
  color: var(--yellow);
  font-size: 1.55em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.hd-tally.bump .hd-n { animation: hdBump .5s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes hdBump { 35% { transform: scale(1.45); } }
.hd-go[hidden] { display: none; }
.hd-go { opacity: 0; transition: opacity .3s ease; }
.hd-go.in { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .hd-zone, .hd-zone.pop, .hd-lina.walking .hd-lina-body,
  .hd-scene .cn-kid.run .cn-body, .hd-target.on, .hd-tally.bump .hd-n { animation: none; }
  .hd-go { transition: none; }
}

/* ============================================================
   SEARCH THE DIAL — the radio, TSU-SHARED-T0-02 · C
   The marks, timings, colour and words: RADIO_* in js/scenes.js
   The volume:                           RADIO_SOUND, same file
   The dial, the display and the sound:  radioGame in js/minigames.js
   ============================================================
   Full screen on one solid colour, and the radio fills it as an OBJECT —
   flat and ink-outlined like everything else in the game, in its own
   palette and its own two faces: a carry handle and an aerial over the
   case, a speaker grille, the display, two knobs, and the tuning window
   with the needle. The scene is a column: the title, then the radio
   taking every pixel left, then a strip at the foot for Skip — which the
   beat turns into Continue once every mark has been checked. */
.rd-scene {
  --rd-bg: #232B5C;
  --rd-edge: max(2.5px, calc(var(--u) * 0.26));      /* the ink outline */
  --rd-shell: var(--teal);
  --rd-shell-hi: #AEDCCF;
  --rd-shell-lo: #5E9F8E;
  --rd-glass: #1C2250;
  --rd-foot-h: calc(max(34px, calc(var(--u) * 3.4)) + var(--u) * 2.8);
  display: flex;
  flex-direction: column;
  padding: max(84px, calc(var(--u) * 6.8)) calc(var(--u) * 3) var(--rd-foot-h);
  background: var(--rd-bg);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
/* the heading is part of the column here, not floating over a picture */
.rd-scene .gr-head { position: static; padding: 0 calc(var(--u) * 8); }
.rd-hint { color: rgba(255, 253, 246, .9); }
.rd-scene.done .rd-hint { color: var(--yellow); }

.rd-set {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  margin-top: max(6px, calc(var(--u) * 1));
}

/* ---- the object ----
   --rd-cap is the room over the case for the handle and the aerial,
   --rd-feet the room under it for the feet. */
.rd-radio {
  --rd-cap: max(16px, calc(var(--u) * 3.4));
  --rd-feet: max(5px, calc(var(--u) * 0.8));
  --rd-strap: max(5px, calc(var(--u) * 0.9));
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: var(--rd-cap) 0 var(--rd-feet);
}
/* the carry handle: an ink arch, the strap inside it, and the gap under
   the strap painted in the background colour */
.rd-carry {
  position: absolute;
  top: 0; left: 24%; right: 24%;
  height: calc(var(--rd-cap) + var(--rd-edge) * 2 + 6px);
  border-radius: max(12px, calc(var(--u) * 2.2)) max(12px, calc(var(--u) * 2.2)) 0 0;
  background: var(--ink);
}
.rd-carry::before {
  content: "";
  position: absolute;
  inset: var(--rd-edge) var(--rd-edge) 0;
  border-radius: max(10px, calc(var(--u) * 2)) max(10px, calc(var(--u) * 2)) 0 0;
  background: var(--rd-shell-lo);
}
.rd-carry::after {
  content: "";
  position: absolute;
  left: calc(var(--rd-edge) + var(--rd-strap));
  right: calc(var(--rd-edge) + var(--rd-strap));
  top: calc(var(--rd-edge) + var(--rd-strap));
  bottom: 0;
  border: var(--rd-edge) solid var(--ink);
  border-bottom: 0;
  border-radius: max(6px, calc(var(--u) * 1.2)) max(6px, calc(var(--u) * 1.2)) 0 0;
  background: var(--rd-bg);
}
/* the aerial, leaning out from the top right */
.rd-aerial {
  position: absolute;
  right: 15%;
  bottom: calc(100% - var(--rd-cap) - var(--rd-edge));
  width: max(5px, calc(var(--u) * 0.55));
  height: calc(var(--rd-cap) * 1.6);
  border: max(1.5px, calc(var(--u) * 0.15)) solid var(--ink);
  border-radius: 99px;
  background: linear-gradient(90deg, #B7C0CF, #F2F4F8 45%, #A5AFC0);
  transform-origin: 50% 100%;
  transform: rotate(24deg);
}
.rd-aerial::after {
  content: "";
  position: absolute;
  left: 50%;
  top: calc(max(5px, calc(var(--u) * 0.6)) * -1);
  width: max(10px, calc(var(--u) * 1.1));
  height: max(10px, calc(var(--u) * 1.1));
  transform: translateX(-50%);
  border-radius: 50%;
  background: #E6EAF0;
  border: max(1.5px, calc(var(--u) * 0.15)) solid var(--ink);
}
.rd-foot {
  position: absolute;
  bottom: 0;
  width: 9%;
  height: calc(var(--rd-feet) + var(--rd-edge) * 2 + 4px);
  border: var(--rd-edge) solid var(--ink);
  border-top: 0;
  border-radius: 0 0 max(5px, calc(var(--u) * 0.7)) max(5px, calc(var(--u) * 0.7));
  background: var(--rd-shell-lo);
}
.rd-foot.l { left: 9%; }
.rd-foot.r { right: 9%; }

/* the case: flat teal with a lit top edge, a shaded base and its shadow */
.rd-case {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: max(8px, calc(var(--u) * 1.2));
  padding: max(10px, calc(var(--u) * 1.6)) max(12px, calc(var(--u) * 2.2)) max(10px, calc(var(--u) * 1.4));
  background: var(--rd-shell);
  border: var(--rd-edge) solid var(--ink);
  border-radius: max(16px, calc(var(--u) * 2.6));
  box-shadow:
    inset 0 max(5px, calc(var(--u) * 0.8)) 0 var(--rd-shell-hi),
    inset 0 calc(max(6px, calc(var(--u) * 1)) * -1) 0 var(--rd-shell-lo),
    0 max(5px, calc(var(--u) * 0.8)) 0 rgba(8, 12, 36, .45);
}
.rd-top {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  gap: max(8px, calc(var(--u) * 1.4));
}
.rd-grille {
  flex: 0 0 22%;
  border: var(--rd-edge) solid var(--ink);
  border-radius: max(10px, calc(var(--u) * 1.6));
  background:
    radial-gradient(circle, var(--ink) 0 32%, transparent 36%)
      50% 50% / max(9px, calc(var(--u) * 1.25)) max(9px, calc(var(--u) * 1.25)),
    var(--rd-shell-lo);
}
.rd-knobs {
  flex: 0 0 auto;
  width: max(38px, calc(var(--u) * 6.6));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-evenly;
}
/* grey, so they read as part of the case and not as something to press —
   the red grip on the dial is the only thing the player handles */
.rd-knob {
  position: relative;
  display: block;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #A9B2C2;
  border: var(--rd-edge) solid var(--ink);
  box-shadow: inset 0 calc(max(3px, calc(var(--u) * 0.4)) * -1) 0 #8A94A8,
              0 max(3px, calc(var(--u) * 0.4)) 0 rgba(8, 12, 36, .35);
}
.rd-knob.tune { width: max(32px, calc(var(--u) * 5.4)); }
.rd-knob.vol { width: max(22px, calc(var(--u) * 3.4)); }
/* the knob's mark, on a layer of its own so it turns about the centre;
   the tuning knob follows the needle (--rd-turn, set by the beat) */
.rd-knob::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: linear-gradient(var(--ink), var(--ink)) 50% 10% / max(3px, calc(var(--u) * 0.38)) 30% no-repeat;
  transform: rotate(40deg);
}
.rd-knob.tune::after { transform: rotate(var(--rd-turn, 0deg)); transition: transform .12s ease-out; }

/* ---- the display ---- */
.rd-screen {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  container-type: size;
  background: var(--rd-glass);
  border: var(--rd-edge) solid var(--ink);
  border-radius: max(10px, calc(var(--u) * 1.4));
  box-shadow: inset 0 0 0 max(3px, calc(var(--u) * 0.4)) #2B3468,
              inset 0 max(6px, calc(var(--u) * 1)) max(12px, calc(var(--u) * 2)) rgba(0, 0, 0, .45);
}
.rd-wave {
  position: absolute;
  left: 0; top: 22%;
  width: 100%; height: 56%;
  overflow: visible;
}
.rd-wave path {
  fill: none;
  stroke: var(--teal);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
  opacity: .9;
}
/* The display carries the wave and the message and nothing else. How
   many marks are checked is the corner tally (.rd-tally, below), and the
   frequencies are on the tuning window. */
.rd-status {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 0 calc(var(--u) * 2);
  font-family: var(--font-ui);
  font-weight: var(--w-bold);
  font-size: calc(var(--u) * 5);
  font-size: min(calc(var(--u) * 6), 34cqh, 11cqw);
  line-height: 1;
  letter-spacing: .1em;
  text-transform: uppercase;
  text-align: center;
  white-space: nowrap;
  color: var(--coral);
  /* a halo the colour of the glass first, so the wave passes behind the
     letters rather than through them, then the warm glow */
  text-shadow: 0 0 2px var(--rd-glass), 0 0 .18em var(--rd-glass), 0 0 .3em var(--rd-glass),
               0 0 calc(var(--u) * 1.2) rgba(242, 144, 123, .5);
}
.rd-scene.stopped .rd-status { animation: rdOn .3s ease both, rdBreathe 2.2s ease-in-out .3s infinite; }
@keyframes rdOn { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
@keyframes rdBreathe { 50% { opacity: .72; } }
/* switched off by Continue: the message dims and holds still */
.rd-scene.off .rd-status { opacity: .3; animation: none; transition: opacity .5s ease; }

/* ---- the tuning window ----
   One drag surface: the window with its marks, and the row under it on
   the case where the needle's grip sits. Marks, the highlight and the
   needle share .rd-scale, so a percentage means the same place to each;
   --rd-x is where the needle is and --rd-gap the space between marks. */
.rd-dial {
  --rd-track-h: max(62px, calc(var(--u) * 9.4));
  --rd-handle-h: max(30px, calc(var(--u) * 4.2));
  /* the marks' run inside the window: the left leaves room for the band
     name ("FM") beside the first frequency, the right for half the last */
  --rd-pad-l: calc(var(--rd-num) * 4.2);
  --rd-pad-r: calc(var(--rd-num) * 2.1);
  /* a mark, top to bottom: dot, gap, tick, gap, frequency — and where
     that stack starts in the window, and where its frequency line is */
  --rd-num: max(13px, calc(var(--u) * 2));
  --rd-vgap: max(3px, calc(var(--u) * 0.45));
  --rd-tick: max(8px, calc(var(--u) * 1.3));
  --rd-dot: max(10px, calc(var(--u) * 1.15));
  --rd-stack-top: calc((var(--rd-track-h) - var(--rd-dot) - var(--rd-tick) - var(--rd-num) - var(--rd-vgap) * 2) / 2);
  --rd-num-top: calc(var(--rd-stack-top) + var(--rd-dot) + var(--rd-tick) + var(--rd-vgap) * 2);
  /* the foot of every tick, big and small: the line they all stand on */
  --rd-tick-foot: calc(var(--rd-stack-top) + var(--rd-dot) + var(--rd-vgap) + var(--rd-tick));
  --rd-minor-h: max(3px, calc(var(--rd-tick) * 0.4));
  --rd-minor-h2: max(4px, calc(var(--rd-tick) * 0.65));
  position: relative;
  flex: 0 0 auto;
  height: calc(var(--rd-track-h) + var(--rd-handle-h));
  cursor: ew-resize;
  touch-action: none;
  outline: none;
}
.rd-track {
  position: absolute;
  left: 0; right: 0; top: 0;
  height: var(--rd-track-h);
  background: var(--paper);
  border: var(--rd-edge) solid var(--ink);
  border-radius: max(10px, calc(var(--u) * 1.4));
  box-shadow: inset 0 max(4px, calc(var(--u) * 0.6)) 0 rgba(44, 54, 99, .08);
}
.rd-dial:focus-visible .rd-track { box-shadow: 0 0 0 3px var(--yellow); }
.rd-scale {
  position: absolute;
  left: var(--rd-pad-l); right: var(--rd-pad-r);
  top: 0; bottom: 0;
}
/* the band name, at the left of the window, on the frequencies' line */
.rd-band {
  position: absolute;
  z-index: 3;
  left: calc(var(--rd-num) * 0.9);
  top: var(--rd-num-top);
  font-family: var(--font-ui);
  font-weight: var(--w-bold);
  font-size: var(--rd-num);
  line-height: 1;
  letter-spacing: .04em;
  color: var(--ink-2);
  pointer-events: none;
}
/* a mark: the dot that lights yellow once it has been checked, its tick,
   and under them its frequency */
.rd-mark {
  position: absolute;
  top: 0;
  width: 0;
  height: var(--rd-track-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--rd-vgap);
}
.rd-num {
  position: relative;
  z-index: 3;
  font-family: var(--font-ui);
  font-weight: var(--w-bold);
  font-size: var(--rd-num);
  line-height: 1;
  color: var(--ink);
  white-space: nowrap;
}
.rd-mark.at .rd-num { color: var(--red); }
.rd-tick {
  position: relative;
  z-index: 1;
  width: max(2px, calc(var(--u) * 0.24));
  height: var(--rd-tick);
  border-radius: 1px;
  background: var(--ink);
}
.rd-lamp {
  position: relative;
  z-index: 3;
  width: var(--rd-dot);
  height: var(--rd-dot);
  border-radius: 50%;
  border: max(1.5px, calc(var(--u) * 0.14)) solid var(--ink-2);
  background: var(--paper);
  transition: background .2s ease, border-color .2s ease, box-shadow .2s ease;
}
/* checked: the dot lit, with a glow round it */
.rd-mark.done .rd-lamp {
  background: var(--yellow);
  border-color: #C9A300;
  box-shadow: 0 0 0 max(2px, calc(var(--u) * 0.2)) rgba(255, 217, 31, .35),
              0 0 max(6px, calc(var(--u) * 0.9)) rgba(255, 200, 0, .9);
}
.rd-mark.pop .rd-lamp { animation: rdPop .5s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes rdPop { 35% { transform: scale(1.9); } }

/* The small marks between the numbered ones: thinner, shorter and a
   little fainter, standing on the same line as the big ticks — taller on a
   whole MHz, shortest on the halves. RADIO_DIAL.minor sets how many. */
.rd-minor {
  position: absolute;
  z-index: 1;
  top: calc(var(--rd-tick-foot) - var(--rd-minor-h));
  height: var(--rd-minor-h);
  width: max(1px, calc(var(--u) * 0.14));
  transform: translateX(-50%);
  border-radius: 1px;
  background: var(--ink-2);
  pointer-events: none;
}
.rd-minor.whole {
  top: calc(var(--rd-tick-foot) - var(--rd-minor-h2));
  height: var(--rd-minor-h2);
}

/* a soft red wash behind the mark the needle is on */
.rd-hl {
  position: absolute;
  top: var(--rd-edge);
  height: calc(var(--rd-track-h) - var(--rd-edge) * 2);
  width: min(calc(var(--rd-gap) * .6), calc(var(--u) * 7));
  left: var(--rd-x, 50%);
  transform: translateX(-50%);
  border-radius: max(6px, calc(var(--u) * 0.8));
  background: rgba(226, 59, 46, .12);
  transition: left 70ms ease-out;
  pointer-events: none;
}
/* ---- the rail the grip slides along ----
   A groove in the case under the window, from the first mark to the last
   and a little past each — there so the grip riding on it reads as a
   slider, not a button. */
.rd-rail {
  position: absolute;
  z-index: 1;
  left: calc(var(--u) * -1.6); right: calc(var(--u) * -1.6);
  top: calc(var(--rd-track-h) + var(--rd-handle-h) / 2);
  height: max(9px, calc(var(--u) * 0.9));
  transform: translateY(-50%);
  border-radius: 999px;
  background: rgba(20, 28, 58, .34);
  box-shadow: inset 0 max(2px, calc(var(--u) * 0.22)) max(3px, calc(var(--u) * 0.32)) rgba(6, 10, 24, .45),
              0 max(1px, calc(var(--u) * 0.12)) 0 rgba(255, 253, 246, .45);
  pointer-events: none;
}
/* the needle: red, down through the dot and the tick to just above the
   frequency, then — after a gap the frequency sits in, so the number it
   is on stays readable — on again as a stem to its grip on the case, with
   an arrow either side. It jumps from mark to mark; the short ease is the
   detent, not a glide. */
.rd-pointer {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--rd-x, 50%);
  width: 0;
  z-index: 2;
  transition: left 70ms ease-out;
  pointer-events: none;
}
.rd-line, .rd-stem {
  position: absolute;
  left: 0;
  width: max(3px, calc(var(--u) * 0.36));
  transform: translateX(-50%);
  border-radius: 2px;
  background: var(--red);
}
.rd-line {
  top: calc(var(--rd-stack-top) - var(--rd-vgap));
  height: calc(var(--rd-dot) + var(--rd-tick) + var(--rd-vgap) * 2.5);
}
.rd-stem {
  top: calc(var(--rd-num-top) + var(--rd-num) + var(--rd-vgap) * 0.5);
  bottom: calc(var(--rd-handle-h) / 2);
}
.rd-handle {
  position: absolute;
  left: 0; bottom: 0;
  height: var(--rd-handle-h);
  transform: translateX(-50%);
  display: flex; align-items: center;
  gap: max(5px, calc(var(--u) * 0.6));
}
.rd-grip {
  flex: 0 0 auto;
  width: max(16px, calc(var(--u) * 1.8));
  height: max(24px, calc(var(--u) * 3));
  border-radius: max(5px, calc(var(--u) * 0.6));
  background: var(--red);
  border: max(2px, calc(var(--u) * 0.18)) solid var(--ink);
  box-shadow: 0 max(2px, calc(var(--u) * 0.3)) 0 var(--ink);
}
.rd-scene.dragging .rd-grip {
  transform: translateY(max(1px, calc(var(--u) * 0.15)));
  box-shadow: 0 max(1px, calc(var(--u) * 0.15)) 0 var(--ink);
}
.rd-arrow {
  flex: 0 0 auto;
  display: flex;
  width: max(11px, calc(var(--u) * 1.3));
  height: max(13px, calc(var(--u) * 1.6));
}
.rd-arrow svg { width: 100%; height: 100%; fill: var(--ink); }
.rd-arrow.l { animation: rdNudgeL 1.1s ease-in-out infinite; }
.rd-arrow.r { animation: rdNudgeR 1.1s ease-in-out infinite; }
@keyframes rdNudgeL {
  0%, 100% { transform: translateX(0); opacity: .55; }
  50% { transform: translateX(calc(var(--u) * -0.8)); opacity: 1; }
}
@keyframes rdNudgeR {
  0%, 100% { transform: translateX(0); opacity: .55; }
  50% { transform: translateX(calc(var(--u) * 0.8)); opacity: 1; }
}
/* nowhere to go that way: that arrow steps aside */
.rd-pointer.first .rd-arrow.l, .rd-pointer.last .rd-arrow.r { visibility: hidden; }

/* ---- how many are checked: the corner under the header ----
   The picker's own tally (.gr-tally) — same place, same face — turning
   yellow with the hint when every mark is done. */
/* centred on the story-tree button beside it, which holds this corner
   at the same height on every screen */
.rd-tally {
  top: calc(max(84px, calc(var(--u) * 6.8)) + max(38px, calc(var(--u) * 3.4)) / 2);
  transform: translateY(-50%);
  white-space: nowrap;
}
.rd-scene.done .rd-tally { color: var(--yellow); }

/* A phone: the header is shorter, so the column starts higher — and the
   radio's own floors, set for a desktop, would leave the display a strip.
   So the handle and aerial get less room over the case, the case and the
   tuning window tighten, and the display takes what that gives back. */
@media (max-height: 430px), (max-width: 820px) {
  .rd-scene { padding-top: 58px; }
  .rd-scene .gr-head { padding: 0 calc(var(--u) * 6); }
  .rd-radio { --rd-cap: 14px; --rd-feet: 4px; --rd-strap: 4px; }
  /* the aerial leans in a little, clear of the tally in the corner */
  .rd-aerial { right: 21%; }
  .rd-case { padding: 7px 10px 6px; gap: 6px; }
  .rd-top { gap: 7px; }
  .rd-dial { --rd-track-h: 54px; --rd-handle-h: 26px; --rd-dot: 11px; --rd-tick: 7px; }
  .rd-knob.tune { width: 30px; }
  .rd-knob.vol { width: 20px; }
}
/* The smallest phones (a stage about 320px tall): the hint goes, and the
   window gives up a little more height. */
@media (max-height: 340px) {
  .rd-hint { display: none; }
  .rd-radio { --rd-cap: 11px; }
  .rd-dial { --rd-track-h: 48px; --rd-handle-h: 24px; --rd-dot: 10px; --rd-tick: 6px; --rd-vgap: 2px; }
  .rd-knob.tune { width: 26px; }
  .rd-knob.vol { width: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  .rd-arrow.l, .rd-arrow.r, .rd-mark.pop .rd-lamp,
  .rd-scene.stopped .rd-status { animation: none; }
  .rd-pointer, .rd-hl, .rd-knob.tune::after { transition: none; }
}

/* ============================================================
   READ THE SIGNS — the sign fork, TSU-SHARED-T5-01 and the cyclone's
   road out of CY-SHARED-24H-02
   The picture, the crowds and the words:  SIGN_* in js/scenes.js
   The roads, the signs and the walkers:   signsGame in js/minigames.js
   ============================================================
   Full screen on the drain's shell (.gr-scene, .gr-bg, .gr-head). The
   picture fills the stage; the roads, the people on them and the signs
   are laid out over it in screen pixels by js/minigames.js, again
   whenever the stage changes size. */
.sg-scene {
  --sg-tar-edge: #F3EEE2;
  background: #7EC3EC;
}
/* The picture's own horizon is pinned to one height of the screen at
   every shape of screen (object-position), then the picture is scaled
   up — from its bottom edge to lift that horizon, from its top edge to
   lower it — until it meets the fork's. The numbers come from
   js/minigames.js. */
.sg-bg {
  object-position: 50% var(--sg-img-hz, 59.6%);
  transform-origin: var(--sg-origin, 50% 100%);
  transform: scale(var(--sg-zoom, 1));
}
/* no picture: a plain sky and meadow, meeting on the fork's horizon */
.sg-scene.nobg {
  background: linear-gradient(180deg,
    #63BCF0 0, #BCE5F8 calc(var(--sg-hz, 42%) - 0.5%),
    #CDE3A9 var(--sg-hz, 42%), #9DC566 calc(var(--sg-hz, 42%) + 18%), #719E4E 100%);
}

.sg-fork {
  position: absolute; inset: 0;
  z-index: 1;
  transition: opacity .24s ease;
}
.sg-fork.out { opacity: 0; }
.sg-scene.wrong .sg-fork { animation: barShake .4s ease; }

/* ---- the roads ----
   Drawn in layers, so where the roads overlap at the bottom they read as
   one road: every verge, then every surface, then the lines on top. */
.sg-roads {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
}
/* a darker band of grass along each side, so a road lies IN the grass */
.sg-verges polygon { fill: #4F7F35; opacity: .3; }
.sg-tars polygon { fill: url(#sg-tar-tone); }
.sg-edge, .sg-dash polygon { fill: var(--sg-tar-edge); }
.sg-edge { opacity: .9; }
.sg-dash { opacity: .95; }
/* One road's own area, over everything: what a click lands on, and its
   wash — yellow while it is pointed at, then the verdict. */
.sg-road {
  fill: var(--yellow);
  fill-opacity: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: fill-opacity .14s ease, fill .14s ease;
}
.sg-scene.done .sg-road { cursor: default; }
.sg-road.hot { fill-opacity: .3; }
.sg-road.good, .sg-road.shown { fill: var(--good); fill-opacity: .42; }
.sg-road.bad { fill: var(--bad); fill-opacity: .5; }

/* ---- the people walking up the roads ----
   Each picture stands on the point js/minigames.js gives it, by its feet,
   and is mirrored now and then so the same eight do not read as a row of
   twins. */
.sg-crowd {
  position: absolute; inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.sg-folk {
  position: absolute;
  width: auto;
  transform: translateX(-50%);
  user-select: none;
  -webkit-user-select: none;
}
.sg-folk.flip { transform: translateX(-50%) scaleX(-1); }

/* ---- the signs on their poles ----
   The button is the sign itself; the pole hangs below it, standing at
   the road's left edge, so the sign reads as that road's. */
.sg-signs {
  position: absolute; inset: 0;
  pointer-events: none;
}
.sg-sign {
  position: absolute;
  appearance: none;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  pointer-events: auto;
  cursor: pointer;
  transition: transform .16s ease;
  -webkit-tap-highlight-color: transparent;
}
.sg-scene.done .sg-sign { cursor: default; }
.sg-sign.hot { transform: translateY(calc(var(--u) * -0.5)); }
.sg-sign:focus { outline: none; }
.sg-sign:focus-visible .sg-plate {
  outline: max(3px, calc(var(--u) * 0.25)) solid var(--yellow);
  outline-offset: max(3px, calc(var(--u) * 0.3));
  border-radius: calc(var(--u) * 0.4);
}
.sg-plate {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%; height: 100%;
  object-fit: contain;
  object-position: 50% 100%;
  filter: drop-shadow(0 calc(var(--u) * 0.25) calc(var(--u) * 0.35) rgba(20, 34, 18, .4));
  user-select: none;
  -webkit-user-select: none;
}
.sg-pole {
  position: absolute;
  z-index: 0;
  left: var(--sg-pole-x);
  top: 80%;
  width: max(4px, 6%);
  height: var(--sg-pole-h);
  transform: translateX(-50%);
  border-radius: 2px 2px 0 0;
  background: linear-gradient(90deg, #A9B2C2 0 45%, #7D8697 45% 100%);
  box-shadow: inset 0 0 0 1px rgba(36, 44, 60, .35);
}
/* its shadow on the grass */
.sg-pole::after {
  content: "";
  position: absolute;
  left: 50%; bottom: -3px;
  width: 520%; height: 7px;
  transform: translateX(-35%);
  border-radius: 50%;
  background: rgba(30, 50, 20, .28);
}

/* the verdict on a sign: a tick on the right one, a cross on a wrong one */
.sg-mark {
  position: absolute;
  z-index: 2;
  top: -6%; right: -6%;
  width: max(22px, 24%);
  aspect-ratio: 1;
  display: none;
  align-items: center; justify-content: center;
  border-radius: 50%;
  border: max(2px, calc(var(--u) * 0.18)) solid #FFFDF6;
  color: #FFFDF6;
  font-family: var(--font-ui);
  font-weight: var(--w-bold);
  font-size: max(13px, calc(var(--u) * 1.5));
  line-height: 1;
  box-shadow: 0 calc(var(--u) * 0.2) calc(var(--u) * 0.5) rgba(10, 16, 34, .35);
}
.sg-sign.good .sg-mark, .sg-sign.shown .sg-mark, .sg-sign.bad .sg-mark {
  display: flex;
  animation: snapIn .32s ease both;
}
.sg-sign.good .sg-mark, .sg-sign.shown .sg-mark { background: var(--good); }
.sg-sign.good .sg-mark::before, .sg-sign.shown .sg-mark::before { content: "\2713"; }
.sg-sign.bad .sg-mark { background: var(--bad); }
.sg-sign.bad .sg-mark::before { content: "\2715"; }

/* ---- a right pick: a tick in the middle of the screen ----
   Up for a second, then gone, and then the next fork — the timing is
   TOAST_MS in js/minigames.js, the words SIGN_TEXT.right in
   js/scenes.js. */
.sg-toast {
  position: absolute;
  left: 50%; top: 50%;
  z-index: 20;
  display: flex; align-items: center;
  gap: calc(var(--u) * 1);
  padding: calc(var(--u) * 1) calc(var(--u) * 2.4) calc(var(--u) * 1) calc(var(--u) * 1.1);
  background: var(--paper);
  border: max(2.5px, calc(var(--u) * 0.2)) solid var(--ink);
  border-radius: 999px;
  box-shadow: 0 calc(var(--u) * 0.8) calc(var(--u) * 2.2) rgba(10, 16, 34, .4);
  opacity: 0;
  transform: translate(-50%, -50%) scale(.85);
  transition: opacity .2s ease, transform .2s ease;
  pointer-events: none;
}
.sg-toast.on { opacity: 1; transform: translate(-50%, -50%); }
.sg-toast-tick {
  flex: none;
  width: max(30px, calc(var(--u) * 3.6));
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--good);
  color: #FFFDF6;
}
.sg-toast-tick svg {
  width: 62%; height: 62%;
  fill: none; stroke: currentColor;
  stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round;
}
.sg-toast-text {
  font-family: var(--font-display);
  font-weight: var(--w-body);
  font-size: var(--fs-lg);
  line-height: 1.1;
  color: var(--ink);
  white-space: nowrap;
}

/* ---- the right signs, in a row on the end panel ----
   Every sign that marks this scenario's evacuation route, on one line
   and all one size; on a narrow screen they shrink rather than wrap. */
.sg-key {
  display: flex; flex-wrap: nowrap; justify-content: center;
  gap: calc(var(--u) * 1.2);
  width: 100%;
}
.sg-key-sign {
  flex: 0 1 auto;
  min-width: 0;
  width: calc(var(--u) * 8);
  height: calc(var(--u) * 8);
  object-fit: contain;
  filter: drop-shadow(0 calc(var(--u) * 0.2) calc(var(--u) * 0.3) rgba(20, 34, 18, .3));
  user-select: none;
  -webkit-user-select: none;
}

/* the smallest phones: the line under the title goes, so the signs keep
   their size */
@media (max-height: 340px) {
  .sg-hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .sg-fork, .sg-sign, .sg-road, .sg-toast { transition: none; }
  .sg-scene.wrong .sg-fork, .sg-sign .sg-mark { animation: none; }
}

/* ============================================================
   KEEP CLIMBING — the last climb, TSU-SHARED-T10-01 (choice A)
   The picture, the road's line, who climbs, every word: JOG_* in js/scenes.js
   The slider and the walk:                               jogGame in js/minigames.js
   ============================================================
   Full screen on the drain's shell (.gr-scene, .gr-bg, .gr-head). The
   climber and the slider are laid out over the picture in screen pixels
   by js/minigames.js, from the road's line in the picture. */
.jg-scene { background: #7EC8F2; }
.jg-scene.nobg {
  background: linear-gradient(162deg, #7EC8F2 0 52%, #A86F45 52% 100%);
}

/* ---- the climber ----
   Stands by the feet on the point it is given, on the middle of the road.
   The portrait is cut down to what is drawn in it (--l-* from
   js/minigames.js), the same way the herd's Lina is. */
.jg-walk {
  position: absolute; inset: 0;
  z-index: 2;
  pointer-events: none;
}
.jg-hero {
  --l-x0: 0; --l-y0: 0; --l-w: 1; --l-h: 1;
  position: absolute;
  left: 0; top: 0;
  height: max(48px, calc(var(--u) * var(--jg-size, 12)));
  aspect-ratio: var(--l-ar, .42);
  will-change: transform;
}
.jg-body {
  position: absolute; inset: 0;
  transform-origin: 50% 100%;
}
.jg-hero img {
  position: absolute;
  height: calc(100% / var(--l-h));
  width: auto;
  max-width: none;
  left: calc(-100% * var(--l-x0) / var(--l-w));
  top: calc(-100% * var(--l-y0) / var(--l-h));
  user-select: none;
  -webkit-user-select: none;
}
/* a soft shadow on the road under the feet */
.jg-hero::after {
  content: "";
  position: absolute;
  left: 50%; bottom: 0;
  width: 86%; height: 9%;
  transform: translate(-50%, 45%);
  border-radius: 50%;
  background: rgba(30, 34, 40, .28);
  z-index: -1;
}
/* a step in the walk, from the feet, only while the handle is moving */
.jg-hero.moving .jg-body { animation: jgStep .42s ease-in-out infinite; }

/* ---- a walking spritesheet (THE WALK in js/minigames.js) ----
   One canvas fills the figure's box and the frames are drawn into it —
   the climb's Kai and Sari, and Sari on the crossing (.ch-body). Walking
   is its own step, so the climber's bob goes; the figure turns to face
   the way the slider is going, and its shadow keeps to the feet rather
   than the width of the box every stride fits in. */
.walk-sprite {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
  pointer-events: none;
}
.jg-hero.sprite.moving .jg-body { animation: none; }
.jg-hero.sprite.left .jg-body { transform: scaleX(-1); }
.jg-hero.sprite::after { width: 58%; }
@keyframes jgStep {
  25% { transform: translateY(-3%) rotate(-1.5deg); }
  50% { transform: none; }
  75% { transform: translateY(-3%) rotate(1.5deg); }
}

/* ---- the slider: one long track under the road ----
   Its left edge and width are set by js/minigames.js so the handle's
   travel is exactly the climb: the climber always stands right above
   the middle of the handle. */
.jg-slider {
  --knob: max(42px, calc(var(--u) * 4.6));
  --pad: max(4px, calc(var(--u) * 0.42));
  --jg-v: 0;
  position: absolute;
  z-index: 5;
  left: 20%; width: 60%;
  bottom: calc(var(--u) * 1.4);
  height: calc(var(--knob) + var(--pad) * 2);
  border-radius: 999px;
  background: rgba(20, 28, 58, .62);
  box-shadow: 0 0 0 max(2px, calc(var(--u) * 0.16)) rgba(255, 253, 246, .6),
              inset 0 calc(var(--u) * 0.25) calc(var(--u) * 0.7) rgba(0, 0, 0, .35),
              0 calc(var(--u) * 0.35) calc(var(--u) * 1.2) rgba(10, 16, 34, .35);
  -webkit-backdrop-filter: blur(calc(var(--u) * 0.4));
  backdrop-filter: blur(calc(var(--u) * 0.4));
  touch-action: none;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}
.jg-slider.held { cursor: grabbing; }
.jg-slider.done { cursor: default; }
.jg-slider:focus-visible {
  box-shadow: 0 0 0 max(3px, calc(var(--u) * 0.25)) var(--yellow),
              inset 0 calc(var(--u) * 0.25) calc(var(--u) * 0.7) rgba(0, 0, 0, .35);
}
/* how far it has come: a yellow wash up to the handle */
.jg-fill {
  position: absolute;
  left: var(--pad); top: var(--pad);
  height: var(--knob);
  width: calc(var(--knob) + (100% - var(--knob) - var(--pad) * 2) * var(--jg-v));
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255, 217, 31, .12), rgba(255, 217, 31, .42));
}
.jg-slider.done .jg-fill { background: rgba(78, 155, 110, .5); }
/* the words, with a light running through them, fading as the handle
   sets off */
.jg-label {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  gap: calc(var(--u) * 0.9);
  padding-left: var(--knob);
  font-family: var(--font-ui);
  font-weight: var(--w-bold);
  font-size: max(15px, calc(var(--u) * 1.75));
  letter-spacing: .04em;
  white-space: nowrap;
  color: transparent;
  background: linear-gradient(100deg, rgba(255, 253, 246, .6) 0 40%, #FFFFFF 50%, rgba(255, 253, 246, .6) 60% 100%);
  background-size: 250% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  animation: jgShine 2.6s linear infinite;
  opacity: calc(1 - var(--jg-v) * 2.4);
  pointer-events: none;
}
@keyframes jgShine {
  from { background-position: 100% 0; }
  to { background-position: 0 0; }
}
.jg-chev { display: inline-flex; gap: calc(var(--u) * 0.15); }
.jg-chev b {
  width: max(7px, calc(var(--u) * 0.7));
  height: max(7px, calc(var(--u) * 0.7));
  border-top: max(2px, calc(var(--u) * 0.22)) solid #FFFDF6;
  border-right: max(2px, calc(var(--u) * 0.22)) solid #FFFDF6;
  transform: rotate(45deg);
  opacity: .3;
  animation: jgChev 1.2s ease-in-out infinite;
}
.jg-chev b:nth-child(2) { animation-delay: .15s; }
.jg-chev b:nth-child(3) { animation-delay: .3s; }
@keyframes jgChev { 40% { opacity: 1; } }
/* the handle */
.jg-knob {
  position: absolute;
  top: var(--pad);
  left: calc(var(--pad) + (100% - var(--knob) - var(--pad) * 2) * var(--jg-v));
  width: var(--knob); height: var(--knob);
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--yellow);
  border: max(2px, calc(var(--u) * 0.18)) solid var(--ink);
  color: var(--ink);
  box-shadow: 0 calc(var(--u) * 0.2) 0 var(--ink);
  box-sizing: border-box;
}
.jg-knob svg {
  width: 56%; height: 56%;
  fill: none; stroke: currentColor;
  stroke-width: 3; stroke-linecap: round; stroke-linejoin: round;
}
.jg-ok-icon { display: none; }
.jg-slider.done .jg-knob { background: var(--good); color: #FFFDF6; }
.jg-slider.done .jg-go-icon { display: none; }
.jg-slider.done .jg-ok-icon { display: block; }
.jg-slider.done .jg-label { opacity: 0; }
@media (hover: hover) and (pointer: fine) {
  .jg-slider:not(.done):hover .jg-knob { background: #FFE45C; }
}

/* A phone: the handle gives up a little size, so the slider stays clear
   of the road at the foot of the climb. The whole track is the thing to
   drag, so a smaller handle is no smaller a target. */
@media (max-height: 430px), (max-width: 820px) {
  .jg-slider { --knob: 36px; --pad: 3px; }
}

@media (prefers-reduced-motion: reduce) {
  .jg-label, .jg-chev b, .jg-hero.moving .jg-body { animation: none; }
}

/* ============================================================
   CLEAR THE LANE — TSU-SHARED-T5-02A, Kai's beat
   The pictures, where they lie, the sidewalks, every word: LANE_* in js/scenes.js
   The carrying and the dropping:                          laneGame in js/minigames.js
   ============================================================
   Full screen on the drain's shell (.gr-scene, .gr-bg, .gr-head). The
   clean street fills the stage; every thing on it is placed in screen
   pixels by js/minigames.js, from where it lies in the picture. */
.ln-scene { background: #5F6A82; touch-action: none; }
.ln-scene.nobg { background: linear-gradient(180deg, #8CCBF2 0 38%, #5F6A82 38% 100%); }

/* ---- the two sidewalks ----
   Nothing shows until something is in hand; then both light up, and the
   one under the pointer lights brighter. */
.ln-zones {
  position: absolute;
  left: 0; top: 0; width: 100%; height: 100%;
  z-index: 1;
  pointer-events: none;
  overflow: visible;
}
.ln-zone {
  fill: var(--yellow);
  fill-opacity: 0;
  stroke: var(--yellow);
  stroke-opacity: 0;
  stroke-width: 3px;
  vector-effect: non-scaling-stroke;
  stroke-linejoin: round;
  transition: fill-opacity .18s ease, stroke-opacity .18s ease;
}
.ln-scene.carrying .ln-zone { fill-opacity: .2; stroke-opacity: .75; animation: lnZone 1.1s ease-in-out infinite; }
.ln-scene.carrying .ln-zone.hot { fill-opacity: .42; stroke-opacity: 1; animation: none; }
@keyframes lnZone { 50% { fill-opacity: .3; } }

/* ---- the things in the road ----
   Each is placed by js/minigames.js; the button only carries the picture
   and the keyboard focus. A press is matched against the picture itself
   by the script, so the button takes no pointer events of its own. */
.ln-field { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.ln-item {
  position: absolute;
  appearance: none;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  pointer-events: none;
}
.ln-item img {
  display: block;
  width: 100%; height: 100%;
  user-select: none;
  -webkit-user-select: none;
}
.ln-scene:not(.done) { cursor: grab; }
.ln-scene.carrying { cursor: grabbing; }
/* the one in hand lifts off the road */
.ln-item.dragging img {
  filter: drop-shadow(0 calc(var(--u) * 0.6) calc(var(--u) * 0.7) rgba(10, 16, 34, .45));
}
.ln-item.springing {
  transition: left .26s cubic-bezier(.3, .8, .4, 1), top .26s cubic-bezier(.3, .8, .4, 1),
              width .26s cubic-bezier(.3, .8, .4, 1), height .26s cubic-bezier(.3, .8, .4, 1);
}
.ln-item:focus { outline: none; }
.ln-item:focus-visible img {
  outline: max(3px, calc(var(--u) * 0.25)) solid var(--yellow);
  outline-offset: max(2px, calc(var(--u) * 0.2));
  border-radius: calc(var(--u) * 0.4);
}

@media (prefers-reduced-motion: reduce) {
  .ln-zone, .ln-item.springing { transition: none; }
  .ln-scene.carrying .ln-zone { animation: none; }
}

/* ============================================================
   WAIT FOR A GAP — Ravi's crossing, TSU-SHARED-T0-02 (choice B)
   The picture, its lines, speeds, every word: CHANNEL_* in js/scenes.js
   The crowds, the crossing and the controls: channelGame in js/minigames.js
   ============================================================
   Full screen on the drain's shell (.gr-scene, .gr-bg, .gr-head). Ravi
   and every walker are placed in screen pixels by js/minigames.js; nearer
   ones (lower on the screen) are drawn over farther ones. */
.ch-scene { background: #9AA3AA; touch-action: none; }
.ch-scene.nobg { background: linear-gradient(180deg, #A8DDF7 0 37%, #9AA3AA 37% 100%); }
.ch-field {
  position: absolute; inset: 0;
  z-index: 2;
  overflow: hidden;
  pointer-events: none;
}

/* ---- the crowd ----
   Each walker is one picture, sized and placed for how far off it is;
   a small bob makes the row read as walking. */
.ch-walker {
  position: absolute;
  left: 0; top: 0;
  width: auto;
  transform-origin: 50% 100%;
  will-change: transform;
  user-select: none;
  -webkit-user-select: none;
  /* the step: its own small rise and fall, on top of where the script puts it */
  animation: chStep .52s ease-in-out infinite;
  animation-delay: calc(var(--ch-bob, 0s) * -1);
}
@keyframes chStep { 50% { translate: 0 -2.4%; } }

/* ---- Ravi ----
   Two frames stacked; the one showing is `.on`. Turned to face left while
   he wheels left. The ring under him is green where he is safe and turns
   red while a wave is coming at him in his lane. */
.ch-ravi {
  position: absolute;
  left: 0; top: 0;
  will-change: transform;
}
.ch-body {
  position: absolute; inset: 0;
  transform-origin: 50% 100%;
}
.ch-ravi.left .ch-body { transform: scaleX(-1); }
.ch-frame {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  object-position: 50% 100%;
  opacity: 0;
  /* a short blend at each change, so the arm glides from one frame to the
     next rather than jumping — the chair is the same in both */
  transition: opacity .09s linear;
  user-select: none;
  -webkit-user-select: none;
}
.ch-frame.on { opacity: 1; }
.ch-ring {
  position: absolute;
  left: 50%; bottom: 0;
  width: 112%; height: 16%;
  transform: translate(-50%, 42%);
  border-radius: 50%;
  border: max(2px, calc(var(--u) * 0.2)) solid rgba(78, 155, 110, .9);
  background: rgba(78, 155, 110, .22);
  transition: border-color .15s ease, background-color .15s ease;
}
.ch-ravi.danger .ch-ring {
  border-color: rgba(199, 67, 52, .95);
  background: rgba(199, 67, 52, .28);
  animation: chRing .5s ease-in-out infinite;
}
@keyframes chRing { 50% { background: rgba(199, 67, 52, .1); } }
.ch-ravi.bumped .ch-body { animation: chBump .42s ease; }
@keyframes chBump {
  20% { transform: translateX(-4%) rotate(-3deg); }
  45% { transform: translateX(3%) rotate(2deg); }
  70% { transform: translateX(-2%); }
}
.ch-ravi.left.bumped .ch-body { animation-name: chBumpL; }
@keyframes chBumpL {
  0%, 100% { transform: scaleX(-1); }
  20% { transform: scaleX(-1) translateX(-4%) rotate(-3deg); }
  45% { transform: scaleX(-1) translateX(3%) rotate(2deg); }
  70% { transform: scaleX(-1) translateX(-2%); }
}
/* a push back puts its words in the hint line, for a moment */
.ch-hint.alert { color: var(--yellow); }

/* ---- the two buttons ---- */
.ch-pad {
  position: absolute;
  left: 50%; bottom: calc(var(--u) * 1.4);
  transform: translateX(-50%);
  z-index: 6;
  display: flex;
  gap: max(14px, calc(var(--u) * 2.2));
}
.ch-btn {
  width: max(56px, calc(var(--u) * 6));
  height: max(56px, calc(var(--u) * 6));
  display: flex; align-items: center; justify-content: center;
  appearance: none;
  border-radius: 50%;
  border: max(2px, calc(var(--u) * 0.18)) solid var(--ink);
  background: var(--yellow);
  color: var(--ink);
  box-shadow: 0 calc(var(--u) * 0.28) 0 var(--ink);
  cursor: pointer;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}
.ch-btn svg {
  width: 52%; height: 52%;
  fill: none; stroke: currentColor;
  stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round;
}
.ch-btn.held { transform: translateY(calc(var(--u) * 0.24)); box-shadow: 0 calc(var(--u) * 0.04) 0 var(--ink); }
@media (hover: hover) and (pointer: fine) {
  .ch-btn:hover { background: #FFE45C; }
}
.ch-scene.done .ch-pad { display: none; }

@media (prefers-reduced-motion: reduce) {
  .ch-walker, .ch-ravi.danger .ch-ring, .ch-ravi.bumped .ch-body { animation: none; }
}

/* ============================================================
   CHOOSE THE SCENARIO — v8

   The character page's own Back button in the top left (it goes to the
   title screen here), the page title level with it, and the two scenario
   cards centred in the room below: a square picture, the name, and how
   many of the characters have reached an ending. Everything is measured
   in stage units, so a card keeps the same shape on a phone and on a wide
   monitor instead of stretching sideways.

   Pictures: assets/scenario/ — see HAZARDS in js/engine.js.
   ============================================================ */
.haz-screen {
  position: absolute; inset: 0;
  padding: calc(var(--u) * 1.4) calc(var(--u) * 4) calc(var(--u) * 2.6);
  display: flex; flex-direction: column; align-items: center;
}
.haz-title {
  margin: 0;
  /* the same height as the Back button, so the two share one line */
  min-height: max(32px, calc(var(--u) * 3.2));
  display: flex; align-items: center;
  font-size: var(--fs-xl);
  line-height: 1.1;
  text-transform: none;
}
.haz-list {
  flex: 1;
  display: flex; justify-content: center; align-items: center;
  gap: calc(var(--u) * 4);
  width: 100%;
  margin: 0;
  padding-top: calc(var(--u) * 1.2);
}
.haz-card {
  width: calc(var(--u) * 32);
  flex: 0 0 auto;
  display: flex; flex-direction: column;
  border-width: max(2px, calc(var(--u) * 0.16));
  border-radius: calc(var(--u) * 1.6);
  box-shadow: 0 calc(var(--u) * 0.35) 0 rgba(44, 54, 99, .22);
  -webkit-tap-highlight-color: transparent;
}
.haz-art {
  display: block;
  height: auto;
  aspect-ratio: 1;
  border-bottom: max(2px, calc(var(--u) * 0.16)) solid var(--ink);
  background: var(--wash);
}
.haz-art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.haz-body {
  display: flex; flex-direction: column;
  gap: calc(var(--u) * 0.35);
  padding: calc(var(--u) * 1.2) calc(var(--u) * 1.6) calc(var(--u) * 1.4);
}
.haz-name {
  margin: 0;
  font-family: var(--font-title);
  font-size: calc(var(--fs-lg) * 1.15);
  line-height: 1.15;
}
.haz-done {
  margin: 0;
  font-family: var(--font-ui);
  font-weight: var(--w-bold);
  font-size: var(--fs-sm);
  letter-spacing: .04em;
  color: var(--ink-2);
}
/* a scenario with at least one ending reached says so in green */
.haz-card.has-runs .haz-done { color: var(--good); }
@media (hover: hover) and (pointer: fine) {
  .haz-card:hover {
    transform: translateY(calc(var(--u) * -0.3));
    box-shadow: 0 calc(var(--u) * 0.65) 0 rgba(44, 54, 99, .22);
  }
}

/* ============================================================
   THE BRIEF — Next always in the same place

   Next / Begin always takes the right half, including on the first beat
   where there is no Back, so the forward button never moves under the
   thumb.
   ============================================================ */
/* as specific as `.choices.intro-nav > .choice.continue`, which would
   otherwise put a lone Next back in the first column */
.choices.intro-nav > .choice.continue.intro-go { grid-column: 2; }

/* ============================================================
   LOCKED OPTIONS — a padlock in front of the words

   The padlock stands at the left, centred on the option's own words; the
   reason sits under the words, lined up with them, in red. The button is
   a two-column grid for this: padlock | words, then an empty cell | the
   reason. The wording is the workbook's — see LOCK NOTE above.
   ============================================================ */
.choice.locked {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas:
    "ico  text"
    ".    note";
  align-items: center;
  align-content: center;
  column-gap: 1em;
}
.choice.locked .lock-ico {
  grid-area: ico;
  width: 1.6em; height: 1.92em;
  display: block;
  color: inherit;
  transform-origin: 50% 20%;
}
.choice.locked .lock-text { grid-area: text; }
.choice.locked .lock-note {
  grid-area: note;
  color: #A3463D;
}
/* tapping a locked option gives the padlock a small shake, alongside the
   nudge its reason already gets */
.choice.locked.asked .lock-ico { animation: lockShake .45s ease; }
@keyframes lockShake {
  20% { transform: rotate(-9deg); }
  45% { transform: rotate(7deg); }
  70% { transform: rotate(-4deg); }
}
@media (prefers-reduced-motion: reduce) {
  .choice.locked.asked .lock-ico { animation: none; }
}

/* ============================================================
   BACK ARROW — the scenario and character pages

   The same button as before, words removed: a circle the height the pill
   was, with the arrow in it. Its words are still on the button for screen
   readers and as the tooltip (HAZARD_COPY.back, PICK_BACK in js/engine.js).
   The lab's own "← Back" buttons keep their words.
   ============================================================ */
.pick-back.arrow-back {
  width: max(32px, calc(var(--u) * 3.2));
  height: max(32px, calc(var(--u) * 3.2));
  min-height: 0;
  padding: 0;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.pick-back.arrow-back svg { width: 54%; height: 54%; display: block; }

/* ============================================================
   THE MENU — the volume, and two text buttons under it

   What the menu button opens: the volume (a speaker, the slider and its
   value), then Back to the game and Back to the main menu. No title and
   no pills: two lines of bold text, each a full-width tap target,
   underlined under the pointer. The panel is only as wide as two short
   lines need. The words are in index.html.
   ============================================================ */
#sheet {
  max-width: max(240px, calc(var(--u) * 30));
  gap: calc(var(--u) * 0.3);
  padding: calc(var(--u) * 1.2) calc(var(--u) * 1.6);
}
#sheet .sheet-btn {
  appearance: none;
  width: 100%;
  min-height: max(40px, calc(var(--u) * 4.2));
  padding: calc(var(--u) * 0.5) calc(var(--u) * 1);
  background: none;
  border: none;
  box-shadow: none;
  font-family: var(--font-ui);
  font-weight: var(--w-bold);
  font-size: var(--fs-md);
  letter-spacing: .01em;
  line-height: 1.3;
  color: var(--ink);
  text-align: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
#sheet .sheet-btn:active { opacity: .6; }
#sheet .sheet-btn:focus-visible {
  outline: max(2px, calc(var(--u) * 0.16)) solid var(--ink);
  outline-offset: 2px;
  border-radius: calc(var(--u) * 0.6);
}
@media (hover: hover) and (pointer: fine) {
  #sheet .sheet-btn:hover {
    text-decoration: underline;
    text-decoration-thickness: max(1.5px, calc(var(--u) * 0.14));
    text-underline-offset: .28em;
  }
}

/* ---- the volume, on top -------------------------------------------
   One row: a speaker, the slider, the value (THE MENU in js/engine.js).
   The speaker shows how loud — data-level 0 crossed out, 1 one wave, 2
   two — and yellow fills the track up to the thumb: --val, kept in step
   by the script. A hairline under it sets it apart from the buttons. */
#sheet .sheet-vol {
  --tr: max(8px, calc(var(--u) * 0.7));      /* the track's height */
  --th: max(22px, calc(var(--u) * 2));       /* the thumb's size */
  --bd: max(2px, calc(var(--u) * 0.16));     /* their ink line */
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  column-gap: calc(var(--u) * 0.9);
  padding: calc(var(--u) * 0.3) calc(var(--u) * 0.8) calc(var(--u) * 0.5);
  margin-bottom: calc(var(--u) * 0.3);
  border-bottom: max(1.5px, calc(var(--u) * 0.12)) solid rgba(44, 54, 99, .16);
}
#sheet .sheet-vol-icon {
  display: block;
  width: max(26px, calc(var(--u) * 2.5));
  height: max(26px, calc(var(--u) * 2.5));
  color: var(--ink);
  overflow: visible;
}
#sheet .sheet-vol-icon .spk { fill: currentColor; stroke: currentColor; stroke-width: 1.2; stroke-linejoin: round; }
#sheet .sheet-vol-icon .w1,
#sheet .sheet-vol-icon .w2,
#sheet .sheet-vol-icon .off { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
#sheet .sheet-vol[data-level="0"] .w1,
#sheet .sheet-vol[data-level="0"] .w2,
#sheet .sheet-vol[data-level="1"] .w2,
#sheet .sheet-vol:not([data-level="0"]) .off { display: none; }
#sheet .sheet-vol-val {
  min-width: 3.1em;                          /* 0% to 100% without a shuffle */
  text-align: right;
  font-family: var(--font-ui);
  font-weight: var(--w-bold);
  font-size: var(--fs-sm);
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
#sheet-vol {
  --val: 100%;
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  min-width: 0;
  height: max(36px, calc(var(--u) * 3.4));   /* the tap target, taller than it looks */
  margin: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
#sheet-vol::-webkit-slider-runnable-track {
  height: var(--tr);
  border: var(--bd) solid var(--ink);
  border-radius: 999px;
  background: linear-gradient(to right, var(--yellow) 0 var(--val), var(--grey-wash) var(--val) 100%);
}
#sheet-vol::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: var(--th);
  height: var(--th);
  margin-top: calc((var(--tr) - var(--th)) / 2);
  border: var(--bd) solid var(--ink);
  border-radius: 50%;
  background: var(--paper);
  box-shadow: 0 2px 0 rgba(44, 54, 99, .3);
}
#sheet-vol::-moz-range-track {
  height: var(--tr);
  border: var(--bd) solid var(--ink);
  border-radius: 999px;
  background: var(--grey-wash);
}
#sheet-vol::-moz-range-progress {
  height: var(--tr);
  border: var(--bd) solid var(--ink);
  border-radius: 999px;
  background: var(--yellow);
}
#sheet-vol::-moz-range-thumb {
  width: var(--th);
  height: var(--th);
  box-sizing: border-box;
  border: var(--bd) solid var(--ink);
  border-radius: 50%;
  background: var(--paper);
  box-shadow: 0 2px 0 rgba(44, 54, 99, .3);
}
#sheet-vol:focus { outline: none; }
#sheet-vol:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px var(--yellow), 0 0 0 5px var(--ink); }
#sheet-vol:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 3px var(--yellow), 0 0 0 5px var(--ink); }

/* ============================================================
   THE TIMER BUTTON — a button that is its own clock
     "Get down and cover your head"   the shake, TSU-SHARED-T0-01
     "Looks good, let's go"           the picker, TSU-SHARED-T0-03

   Two layers. Underneath, the button is solid white; over it, solid
   yellow fills in from the left, and the time is up when it reaches the
   right edge. js/minigames.js moves it by setting --tb-p (0 to 1).

   From its warning point the button shakes and flashes red. The shake's
   button keeps on after its time is up, until it is pressed — a late
   press costs Safety -1. The picker's gives way to its "You have to go
   now" panel when its clock reaches zero.

   How long each one runs and where its warning starts are in
   js/scenes.js: `time` and `warnAt` in MOMENTS.shake; PICKUP_SECONDS and
   PICKUP_WARN_AT for the picker.

   ---- EDIT HERE — these change both buttons ----------------------
     --tb-under   the bottom layer: solid white, under the yellow fill
                  (transparent would show the picture through it instead)
     --tb-alarm   the warning red at its strongest: the game's alarm red
                  (--red, #E23B2E) at 90%
     --tb-blink   one red flash. .5s is two a second; keep it to three or
                  fewer a second, since faster flashing can set off seizures

   ---- HOW HARD THE BUTTONS SHAKE — EDIT THE TWO NUMBERS ------------
     --tb-shake   how far the button swings to each side, in pixels. The
                  tilt follows it, so this one number sets the strength.
                  Was about 4, with a 1.4° tilt; smaller is calmer, 0 stops it
     --tb-jolt    how long one shake takes, there and back. Bigger is
                  SLOWER. Was .3s
   (The picture behind the shake's button shakes too — that is
   --quake-strength and --quake-cycle, under SCREEN SHAKE further up.)

   To give one button a value of its own, set it on that button alone:
   `.gr-go.timer-btn { --tb-shake: 0; }` would stop only the picker's.

   With reduced motion the buttons do not shake, and the red stays on
   instead of flashing.
   ============================================================ */
.timer-btn {
  --tb-under: #FFFFFF;
  --tb-alarm: rgba(226, 59, 46, .9);
  --tb-blink: .5s;
  --tb-shake: 1.5;
  --tb-jolt: .4s;
  position: relative;
  overflow: hidden;
  isolation: isolate;
  background: var(--tb-under);
  /* The frosted-glass bottom layer, switched off for now. To bring it
     back, add these two lines here again:
       -webkit-backdrop-filter: blur(4px);
       backdrop-filter: blur(4px);                                      */
}
/* the buttons' own hover yellows (and the phone rule that paints them
   solid yellow) would cover the white, so the timer keeps it */
.timer-btn:hover { background: var(--tb-under); }
.tb-fill, .tb-alarm {
  position: absolute; inset: 0;
  z-index: -1;                      /* over the white, under the words */
  pointer-events: none;
}
.tb-fill {
  background: var(--yellow);
  transform-origin: left center;
  transform: scaleX(var(--tb-p, 0));
}
.tb-alarm { background-color: transparent; }
.tb-label { position: relative; }

.timer-btn.tb-warn {
  animation: tbJolt var(--tb-jolt) linear infinite,
             tbGlow var(--tb-blink) ease-in-out infinite;
}
/* the red holds, then snaps back: a slow fade spent too long half-red,
   where neither the dark words nor the white ones can be read */
.timer-btn.tb-warn .tb-alarm { animation: tbAlarm var(--tb-blink) linear infinite; }
.timer-btn.tb-warn .tb-label { animation: tbAlarmText var(--tb-blink) linear infinite; }
/* every step is a share of --tb-shake: at 1.5 it swings 1.5px each way
   and tilts .3 of a degree */
@keyframes tbJolt {
  0%, 100% { transform: translateX(0) rotate(0); }
  25%      { transform: translateX(calc(var(--tb-shake) * -1px)) rotate(calc(var(--tb-shake) * -.2deg)); }
  75%      { transform: translateX(calc(var(--tb-shake) *  1px)) rotate(calc(var(--tb-shake) *  .2deg)); }
}
@keyframes tbGlow {
  0%, 100% { box-shadow: 0 3px 0 rgba(44, 54, 99, .3), 0 0 0 0 rgba(226, 59, 46, 0); }
  50%      { box-shadow: 0 3px 0 rgba(44, 54, 99, .3), 0 0 0 calc(var(--u) * .45) rgba(226, 59, 46, .5); }
}
@keyframes tbAlarm {
  0%, 35%, 100% { background-color: transparent; }
  50%, 85%      { background-color: var(--tb-alarm); }
}
/* The words do not fade: they switch to white the moment the red is three
   quarters in (47.5%) and back as it falls past the same point (87.5%),
   where dark and white words stand out from it equally. */
@keyframes tbAlarmText {
  0%, 47.4%, 87.6%, 100% { color: var(--ink); }
  47.5%, 87.5%           { color: #fff; }
}
@media (prefers-reduced-motion: reduce) {
  .timer-btn.tb-warn {
    animation: none;
    box-shadow: 0 3px 0 rgba(44, 54, 99, .3), 0 0 0 calc(var(--u) * .45) rgba(226, 59, 46, .5);
  }
  .timer-btn.tb-warn .tb-alarm { animation: none; background-color: var(--tb-alarm); }
  .timer-btn.tb-warn .tb-label { animation: none; color: #fff; }
}

/* ============================================================
   THE COVER — the homepage (renderTitle in js/engine.js)

   The picture fills the stage. Everything on it is measured in --px,
   one pixel of the 1920 x 1080 design, so the numbers below are the
   design's own and the buttons grow and shrink with the picture.

   ---- START — the design's values as given ----------------------
   275 x 116, centred, 569 from the top; padding 30 / 80; white;
   shadow 0 4 20 at 25% black; fully round. Roboto Bold 48 on 56,
   tracking 0.04em, #399FDB.

   ---- MINIGAMES — the same button at half the size ---------------
   Every number is half of Start's, and it sits 40 in from the
   bottom-right corner. Its words never print smaller than 12px, so
   it stays readable on a phone; the padding is in em, so the pill
   grows with them.
   ---------------------------------------------------------------- */
.title-screen {
  --px: calc(var(--u) / 19.2);        /* the stage is 100u = 1920 design px */
  position: absolute; inset: 0;
  display: block;
  padding: 0;
  overflow: hidden;
  touch-action: manipulation;
  background: #33B0F8;                /* the picture's own sea, until it arrives */
}
.cv-bg {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  user-select: none; -webkit-user-select: none;
  pointer-events: none;
}

.cv-start, .lab-open {
  appearance: none;
  border: none;
  display: flex; flex-direction: row;
  justify-content: center; align-items: center;
  background: #FFFFFF;
  box-shadow: 0 calc(var(--px) * 4) calc(var(--px) * 20) rgba(0, 0, 0, .25);
  border-radius: 9999px;
  font-family: 'Roboto', system-ui, sans-serif;
  font-style: normal;
  font-weight: 700;
  text-align: center;
  letter-spacing: .04em;
  color: #399FDB;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.cv-start {
  position: absolute;
  width: calc(var(--px) * 275);
  height: calc(var(--px) * 116);
  left: calc(50% - var(--px) * 275 / 2);
  top: calc(var(--px) * 569);
  padding: calc(var(--px) * 30) calc(var(--px) * 80);
  gap: calc(var(--px) * 10);
  font-size: calc(var(--px) * 48);
  line-height: calc(var(--px) * 56);
}
.lab-open {
  position: absolute;
  right: calc(var(--px) * 40); bottom: calc(var(--px) * 40);
  z-index: 20;
  font-size: max(12px, calc(var(--px) * 24));
  line-height: 1.1667;                /* 28 on 24, as Start is 56 on 48 */
  padding: .625em 1.6667em;           /* 15 / 40 on 24, as Start is 30 / 80 on 48 */
}
.cv-start:active, .lab-open:active { transform: scale(.97); }
.cv-start:focus-visible, .lab-open:focus-visible {
  outline: max(2px, calc(var(--px) * 4)) solid #399FDB;
  outline-offset: max(2px, calc(var(--px) * 4));
}
/* a phone keeps its home bar along the bottom edge; Minigames takes the
   same clearance from it as every other button there */
@media (max-height: 430px), (max-width: 820px) {
  .lab-open { right: max(12px, calc(var(--px) * 40)); bottom: var(--safe-bottom); }
}

/* ============================================================
   DIALOGUE GLASS — the story text on glass, the choices solid

   The box that carries a Situation is frosted glass: the scene shows
   through it blurred, under a wash of the glass's own colour. The
   character brief and the delayed-feedback page use the same box, so
   they wear the same glass. The choices keep their solid cream cards
   with the navy border.

   ---- CHANGE THE GLASS HERE ----
   The five settings in the first rule below are the whole look:
     --glass-color    the glass's colour, any CSS colour (#FFFFFF white)
     --glass-opacity  how much of that colour lies over the scene:
                      0% clear glass ... 100% solid colour
     --glass-blur     how blurred the scene behind is: 0 sharp ... 3 very soft
     --glass-light    the scene behind, before the colour goes over it:
                      1 as it is, above 1 lighter, below 1 darker
     --glass-text     the words: var(--ink) navy on a light glass,
                      var(--paper) cream on a dark one
   Keep the words readable. A light glass with navy words wants the
   scene lighter and enough colour over it; a dark glass with cream
   words wants the scene darker.
   The dark navy glass tried first: #0E142A, 50%, 1.6, .7, var(--paper).

   The shop shelf (.shop-card) is built on the same element and keeps
   its cream card.
   ============================================================ */
.paras:not(.shop-card) {
  --glass-color:   #FFFFFF;
  --glass-opacity: 60%;
  --glass-blur:    1.6;
  --glass-light:   1.35;
  --glass-text:    var(--ink);
}
.paras:not(:empty):not(.shop-card) {
  background: color-mix(in srgb, var(--glass-color) var(--glass-opacity), transparent);
  -webkit-backdrop-filter: blur(calc(var(--u) * var(--glass-blur))) saturate(1.4) brightness(var(--glass-light));
  backdrop-filter: blur(calc(var(--u) * var(--glass-blur))) saturate(1.4) brightness(var(--glass-light));
  /* the glass edge, drawn inside so the box keeps its size and place */
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .5),
              0 calc(var(--u) * 0.5) calc(var(--u) * 2) rgba(6, 10, 24, .3);
  color: var(--glass-text);
  scrollbar-color: color-mix(in srgb, var(--glass-text) 45%, transparent) transparent;
}
.paras:not(.shop-card) .para,
.paras:not(.shop-card) .cb-text,
.paras:not(.shop-card) .cb-item { color: var(--glass-text); }
/* the small print takes the words' colour, a little quieter */
.paras:not(.shop-card) .cb-head,
.paras:not(.shop-card) .cb-item::marker { color: color-mix(in srgb, var(--glass-text) 78%, transparent); }
.paras:not(.shop-card) .intro-dots span { border-color: color-mix(in srgb, var(--glass-text) 80%, transparent); }
.paras:not(.shop-card) .intro-dots span.on { background: var(--glass-text); border-color: var(--glass-text); }
/* No blur to be had — a browser without it, or a player who has asked
   for less transparency: the same colour, close to solid, so the words
   read just as well without the scene behind them. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .paras:not(:empty):not(.shop-card) {
    background: color-mix(in srgb, var(--glass-color) 92%, transparent);
  }
}
@media (prefers-reduced-transparency: reduce) {
  .paras:not(:empty):not(.shop-card) {
    background: color-mix(in srgb, var(--glass-color) 92%, transparent);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

/* ============================================================
   CHOICES RISE — an event's choices arrive from below the screen
   (showChoices and riseIn in js/engine.js)

   Each choice rises from just below the bottom edge of the screen to
   its place, one after another, with a small overshoot. How far below
   it starts is measured for each one by js/engine.js (--rise, the
   distance from its place down to the bottom edge), so the upper row
   travels further than the lower and every choice comes into view at
   the very edge. With reduced motion they fade in where they stand.

   Only the decision's choices rise. Continue, Next and the other single
   buttons keep their fade.

   ---- CHANGE THE RISE HERE ----
     --rise-time   how long each choice takes to rise
     --rise-step   the wait before the next choice starts
     --rise-wait   the pause after the page opens, before the first one
   ============================================================ */
.after > .choices.rise {
  --rise-time: .6s;
  --rise-step: .08s;
  --rise-wait: .25s;
}
.after > .choices.rise > .choice {
  opacity: 1;
  animation: choiceRise var(--rise-time) cubic-bezier(.34, 1.3, .64, 1) backwards;
  animation-delay: calc(var(--rise-wait) + var(--i) * var(--rise-step));
}
/* from just under the bottom edge, its shadow included, up to its place */
@keyframes choiceRise {
  from { translate: 0 calc(var(--rise, 100%) + var(--u) * 4); }
}
@media (prefers-reduced-motion: reduce) {
  .after > .choices.rise > .choice { animation: choiceFade .3s ease backwards; }
}
@keyframes choiceFade { from { opacity: 0; } }
