/* ==========================================================================
   STAKE-OUT V12 — TotalStationTech field simulator
   --------------------------------------------------------------------------
   Every screen is a .stage: a fixed-aspect box carrying one of the concept-art
   PNGs as its background, with real controls positioned on top in percentages
   measured off the artwork itself. Sizes inside a stage use container units
   (1cqw = 1% of stage width) so the whole screen scales as one piece.
   ========================================================================== */

:root {
  --yellow:        #f5c518;
  --yellow-bright: #ffd83d;
  --blue:          #6e7bff;
  --blue-deep:     #4a4de0;
  --green:         #22d422;
  --red:           #e53935;
  --panel-ink:     #151616;  /* sampled from the player-UI panel interiors */
  --hud-ink:       #0d0e0d;  /* sampled from the player-UI header strip     */

  --font-display: 'Arial Narrow', 'Helvetica Neue', Arial, Helvetica, sans-serif;
  --font-mono:    'Courier New', Consolas, 'Liberation Mono', monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: #050505;
  color: var(--yellow);
  font-family: var(--font-mono);
  min-height: 100%;
  overflow-x: hidden;
}

body {
  user-select: none; -webkit-user-select: none;
  /* a thumb held on a D-pad must not drag the page or pull-to-refresh */
  overscroll-behavior: none;
}

/* ---- scroll lock while playing ------------------------------------------
   app.js puts .is-playing on <html> for the duration of the player screen.
   Sizing in dvh stops the page OVERFLOWING; this stops it MOVING at all, which
   is a different problem: on a phone a drag that starts on the instrument can
   still pan the page, rubber-band it, or retract the address bar mid-shot, and
   any of those shift the gauges under your thumb while you are trying to level
   a bubble to three percent.

   position:fixed on both elements is what actually pins it -- overflow:hidden
   alone is ignored on the body by mobile Safari. touch-action:none then stops
   the browser claiming any drag as a scroll or pinch-zoom gesture before the
   game ever sees it. The menu and the field report are deliberately left
   scrollable; only play is locked. */
html.is-playing, html.is-playing body {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: none;
}

/* ---- screens ------------------------------------------------------------ */
/* Sizing uses dvh, the DYNAMIC viewport height, with vh kept above it as the
   fallback for browsers that don't know dvh. This matters only on phones: vh
   there is the LARGE viewport, measured as if the address bar were retracted,
   so a box sized to 100vh is always taller than what you can actually see and
   the page always has somewhere to scroll to. dvh is the height that is really
   visible right now, so the stage fits and there is nothing to scroll. */
.screen { display: none; }
.screen.is-active {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 0;
}

.stage {
  position: relative;
  container-type: size;
  width: min(100vw, calc(100vh * var(--aw) / var(--ah)));
  width: min(100vw, calc(100dvh * var(--aw) / var(--ah)));
  aspect-ratio: var(--aw) / var(--ah);
  background-repeat: no-repeat;
  background-position: top center;
  background-size: 100% auto;
  overflow: hidden;
}

/* Each stage names its art twice: a plain url() that every browser understands,
   then an image-set() that browsers supporting it use to pick the WebP instead.
   The WebP copies are ~89% smaller (546 KB vs 4.9 MB across the three), and
   anything too old to parse image-set() simply keeps the PNG above it. */
.stage--menu {
  --aw: 1535; --ah: 1230;
  background-image: url("../assets/img/main_menu.png");
  background-image: image-set(url("../assets/img/main_menu.webp") type("image/webp"),
                              url("../assets/img/main_menu.png")  type("image/png"));
}
/* V12: the player stage carries no background image -- the instrument is a
   stack of <img> layers inside it (see SCREEN 2 below). Its frame is the V12
   art cropped to the instrument, 1920x960: at 2:1 it fills far more of a
   landscape phone (about 2.2:1) than V11's 3:2 did, which is most of the
   V12 size increase on mobile. */
.stage--player {
  --aw: 1920; --ah: 960;
  cursor: crosshair;
}
.stage--report {
  --aw: 1536; --ah: 1190;
  background-image: url("../assets/img/field_report.png");
  background-image: image-set(url("../assets/img/field_report.webp") type("image/webp"),
                              url("../assets/img/field_report.png")  type("image/png"));
  background-color: #000;
}

/* ==========================================================================
   SCREEN 1 — MAIN MENU
   ========================================================================== */

/* apron below the artwork carrying the START button */
.menu-band {
  position: absolute; left: 0; right: 0;
  top: 82%; bottom: 0;
  background: linear-gradient(to bottom,
              rgba(9,9,10,0) 0%, rgba(9,9,10,.78) 26%, #090a0b 55%, #060607 100%);
  pointer-events: none;
}
.menu-band::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 0.7cqw;
  background-image: repeating-linear-gradient(135deg,
                    var(--yellow) 0 1.1cqw, #0a0a0a 1.1cqw 2.2cqw);
  opacity: .85;
}

.course-complete {
  position: absolute; left: 50%; top: 1.4%;
  transform: translateX(-50%);
  z-index: 6;
  background: linear-gradient(180deg, var(--yellow-bright), var(--yellow));
  color: #0a0a0a;
  font-family: var(--font-display);
  font-weight: 700; letter-spacing: .22cqw;
  font-size: 1.55cqw; padding: .75cqw 2.4cqw;
  clip-path: polygon(1.1cqw 0, 100% 0, calc(100% - 1.1cqw) 100%, 0 100%);
  box-shadow: 0 0 2.5cqw rgba(245,197,24,.55);
  animation: ccPulse 1.6s ease-in-out infinite;
}
@keyframes ccPulse { 0%,100% { opacity: 1; } 50% { opacity: .62; } }

/* --- level rows ----------------------------------------------------------
   The artwork bakes Level 1 in as the highlighted row, so selection state is
   drawn here instead: unselected rows get a dark veil, the selected row gets
   a bright ring and glow. That reads correctly whichever row is chosen. */
.level-hit {
  position: absolute;
  border: 0; padding: 0; margin: 0;
  background: rgba(4,4,5,.62);
  border-radius: 1.25cqw;
  cursor: pointer;
  transition: background .14s ease, box-shadow .14s ease;
}
.level-hit:hover  { background: rgba(4,4,5,.34); }
.level-hit:focus-visible { outline: .22cqw solid #fff; outline-offset: .2cqw; }

.level-hit .hit-ring {
  position: absolute; inset: 0;
  border-radius: 1.25cqw;
  border: .32cqw solid transparent;
  transition: border-color .14s ease, box-shadow .14s ease;
  pointer-events: none;
}
.level-hit.is-selected { background: rgba(4,4,5,0); }
.level-hit.is-selected .hit-ring {
  border-color: var(--yellow-bright);
  box-shadow: 0 0 1.8cqw rgba(255,216,61,.85), inset 0 0 1.2cqw rgba(255,216,61,.35);
}

.lvl1 { left: 5.60%;  top: 39.27%; width: 43.32%; height: 11.38%; }
.lvl2 { left: 50.55%; top: 39.19%; width: 43.13%; height: 11.54%; }
.lvl3 { left: 25.47%; top: 52.44%; width: 48.66%; height: 10.57%; }
.lvl4 { left: 25.47%; top: 64.63%; width: 48.66%; height: 10.57%; }

/* --- mode pill -----------------------------------------------------------
   Redrawn rather than overlaid: the artwork's pill says "BIPOD", so the text
   has to be ours to be able to say "POLE". Styled to match the art's pill. */
.mode-hit {
  position: absolute;
  left: 33.62%; top: 76.91%; width: 32.38%; height: 7.07%;
  border-radius: 1.15cqw;
  background: linear-gradient(180deg, #101a42 0%, #070c1e 60%, #04070f 100%);
  border: .3cqw solid var(--blue-deep);
  box-shadow: 0 0 1.6cqw rgba(90,92,245,.55), inset 0 0 1.2cqw rgba(90,92,245,.22);
  display: grid; place-items: center;
  overflow: hidden;
}
.mode-hit #modeSelect {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  opacity: 0; cursor: pointer;
  font-size: 2cqw;
}
.mode-face {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 2.5cqw;
  letter-spacing: .32cqw;
  color: var(--blue);
  text-shadow: 0 0 1cqw rgba(110,123,255,.7);
  pointer-events: none;
}
.mode-face b { font-size: 2cqw; }

/* --- START --------------------------------------------------------------- */
.ribbon-btn {
  position: absolute;
  display: flex; align-items: center; justify-content: center; gap: 1.5cqw;
  border: .32cqw solid var(--yellow);
  background: linear-gradient(180deg, var(--yellow-bright) 0%, var(--yellow) 55%, #d9ab08 100%);
  color: #0a0a0a;
  font-family: var(--font-display);
  font-weight: 700;
  cursor: pointer;
  border-radius: 1.25cqw;
  box-shadow: 0 0 2.2cqw rgba(245,197,24,.5), 0 .5cqw 1.4cqw rgba(0,0,0,.65);
  transition: transform .1s ease, box-shadow .14s ease, filter .14s ease;
}
.ribbon-btn:hover  { filter: brightness(1.08); box-shadow: 0 0 3.2cqw rgba(255,216,61,.8), 0 .5cqw 1.4cqw rgba(0,0,0,.65); }
.ribbon-btn:active { transform: translateY(.25cqw); }
.ribbon-btn:focus-visible { outline: .22cqw solid #fff; outline-offset: .3cqw; }

.start-btn { left: 33.62%; top: 87.80%; width: 32.38%; height: 7.80%; }
.start-btn .ribbon-label { font-size: 3.4cqw; letter-spacing: .75cqw; }
.start-btn .ribbon-chev  { font-size: 2.6cqw; }

.menu-hint {
  position: absolute; left: 0; right: 0; top: 96.4%;
  margin: 0; text-align: center;
  font-family: var(--font-display);
  font-size: 1.28cqw; letter-spacing: .28cqw;
  color: #8e8e8e;
}

/* ==========================================================================
   SCREEN 2 — PLAYER UI (V12)
   --------------------------------------------------------------------------
   The instrument is a stack of real image layers (index.html), all cut from
   the V12 art and registered to ONE frame by tools/prep_v12_layers.py. That
   frame is the concept master's 1920x1080 cropped to the instrument itself,
   1920 x 960 ("master pixels", y offset 52), so every box below is

       left  = x / 1920        top    = (y - 52) / 960
       width = w / 1920        height = h / 960

   of a master-pixel measurement. The script prints the numbers for the art
   layers; the rest are measured off the same frame and noted where they are
   used. Sizes inside the stage are container units (1cqw = 1% of the stage
   width) so the whole instrument scales as one piece.
   ========================================================================== */

.layer {
  position: absolute;
  display: block;
  max-width: none;
  pointer-events: none;          /* taps go through to the stage / hotspots */
  user-select: none; -webkit-user-select: none;
  -webkit-user-drag: none;
}
.layer-bezel, .layer-screen { left: 0; top: 0; width: 100%; height: 100%; }
.layer-logo-top    { left: 38.385%; top:  2.917%; width: 24.323%; height:  9.479%; }
.layer-logo-bottom { left: 38.802%; top: 83.542%; width: 22.240%; height:  9.792%; }

/* the two gauge faces, cut from the art as circles (dial r174 + 12, vial
   r157.5 + 44) and laid exactly over the same pixels of layer-screen, so a
   gauge can grey out without greying its panel title */
.layer-dial { left: 26.667%; top: 24.688%; width: 19.427%; height: 38.854%; }
.layer-vial { left: 53.698%; top: 23.021%; width: 21.042%; height: 42.083%; }

/* pads and MEASURE buttons: pad_l (34,205)-(422,588), meas_l (122,584)-(333,794),
   pad_r (1495,205)-(1885,588), meas_r (1586,584)-(1797,794) */
.layer-pad-l  { left:  1.771%; top: 15.937%; width: 20.208%; height: 39.896%; }
.layer-pad-r  { left: 77.865%; top: 15.937%; width: 20.312%; height: 39.896%; }
.layer-meas-l { left:  6.354%; top: 55.417%; width: 10.990%; height: 21.875%; }
.layer-meas-r { left: 82.604%; top: 55.417%; width: 10.990%; height: 21.875%; }

/* header — LEVEL on the left of the logo, POINT n OF m on the right, in the
   black strip across the top of the bezel (strip y 94..200, logo x 737..1204) */
.hud-head {
  position: absolute; left: 0; top: 4.2%; width: 100%; height: 7.2%;
  pointer-events: none;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 2.05cqw;
  letter-spacing: .38cqw;
  white-space: nowrap;
}
.hud-side {
  position: absolute; top: 0; height: 100%;
  display: flex; align-items: center; gap: .7cqw;
}
.hud-left  { right: 63.2%; justify-content: flex-end; }   /* ends at x=707  */
.hud-right { left:  64.0%; justify-content: flex-start; } /* starts at x=1229 */
.hud-y   { color: var(--yellow); }
.hud-w   { color: #fff; }

.gauge { position: absolute; display: block; }
/* The canvases keep the engine's own geometry and are placed so the engine's
   r lands on the art's r. POS: engine centre (214,214) r=122 on the art's dial
   centre (698,475) r=174, so 1 unit = 1.4262 master px and the 428-unit canvas
   is 610.4 px square at (392.8, 169.8). BUB: engine (215,215) r=140 on the
   vial (1233,475) r=157.5, 1 unit = 1.125 px, 483.75 px square at
   (991.1, 233.1). Because the vial's pointer maths is all relative to this
   box, steering on the vial behaves exactly as it did in V11. */
.pos-gauge { left: 20.458%; top: 12.270%; width: 31.793%; height: 63.586%; }
.bub-gauge {
  left: 51.621%; top: 18.867%; width: 25.195%; height: 50.391%;
  /* The vial is a drag surface, so the browser must not treat a finger on it
     as a page pan. Without this a touch drag gets claimed as a scroll gesture,
     the browser fires pointercancel at us mid-drag, and the engine reads that
     as "let go" and sends the bubble home -- i.e. the bubble is unsteerable by
     touch. Only became relevant in V11, when steering moved from mousemove to
     pointer events and touch started working at all. */
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

/* ==========================================================================
   ACTIVE / IDLE PANELS (V11 behaviour, V12 geometry)
   --------------------------------------------------------------------------
   Each data-collector panel tells you whether it is the one you may touch:
   thin border while idle, bold while active. POINT POSITION is yellow,
   BUBBLE LEVEL is green.

   These sit exactly on top of the panel outlines painted into the V12 play
   screen, so they recolour that outline rather than drawing a second one
   inside it. Measured off the registered art, the painted lines are 8px:

       POINT POSITION   left x 433..440   right x 959..965   top y 197..204
       BUBBLE LEVEL     left x 975..982   right x 1497..1504 top y 197..204

   Each frame is set 2px outside those and is three-sided: the panels have
   no painted bottom edge of their own -- they open straight onto the readout
   boxes at y=662 -- so there is nothing to recolour there, and a bottom
   border would cut through the down triangle.

   pointer-events is off, so tap-to-measure and the vial's own pointer
   tracking reach straight through. Greying out is BOTH halves of the job:
   .is-dim below is the visual half, the engine's activePanel the functional
   half.
   ========================================================================== */
.panel-frame {
  position: absolute;
  pointer-events: none;
  border-style: solid;
  border-bottom-width: 0 !important;
  border-radius: .7cqw .7cqw 0 0;
  transition: border-width .12s ease, border-color .12s ease, box-shadow .12s ease;
}
/* x 431..967, y 195..662 */
.frame-pos { left: 22.448%; top: 14.896%; width: 27.917%; height: 48.646%; }
/* x 973..1506, y 195..662 */
.frame-bub { left: 50.677%; top: 14.896%; width: 27.760%; height: 48.646%; }

/* idle: 12px, just enough to hide the painted line underneath */
.panel-frame.is-idle   { border-width: .625cqw; box-shadow: none; }
/* active: 16px, plus a soft halo so it reads at a glance */
.panel-frame.is-active { border-width: .833cqw; }

/* Idle colours are deliberately OPAQUE dark shades rather than the bright
   colour at low alpha: a translucent border would let the painted yellow
   outline show through, which on the bubble panel blends to a muddy
   yellow-green instead of reading as a dim green. */
.frame-pos.is-idle   { border-color: #6d5712; }
.frame-pos.is-active { border-color: var(--yellow);
                       box-shadow: 0 -.2cqw 1.5cqw rgba(245, 197, 24, .5); }
.frame-bub.is-idle   { border-color: #14611a; }
.frame-bub.is-active { border-color: var(--green);
                       box-shadow: 0 -.2cqw 1.5cqw rgba(34, 212, 34, .45); }

/* The visual half of "greyed out": drained of colour and darkened. A filter,
   never opacity -- the gauge faces sit over the same art, and turning them
   see-through would just show the undimmed copy underneath. */
.gauge, .readout, .layer-dial, .layer-vial { transition: filter .12s ease; }
.gauge.is-dim, .readout.is-dim,
.layer-dial.is-dim, .layer-vial.is-dim { filter: grayscale(1) brightness(.45); }

/* ---- numeric readouts ---------------------------------------------------
   Over the digit windows of the LEFT / RIGHT and TO / AWAY boxes: x 476..716
   and 807..1047, y 712..790. The painted "ft" to the right of each is left
   as art. The canvas draws the values in the V12 LCD glyphs; the text spans
   are kept for screen readers and headless checks but not shown. */
/* V12.5a: TO/AWAY is the LEFT-hand box and LEFT/RIGHT the right-hand one,
   which is the way a real data collector lays them out -- TO/AWAY nearest the
   up/down triangles it belongs to. The labels are painted into the art, so
   they were swapped in the art too (see the label swap in
   tools/prep_v12_layers.py); these two rules move the values to match. The
   elements and their ids are unchanged: .ro-1 is still LEFT/RIGHT, it just
   lives in the right-hand box now. */
.readout { position: absolute; }
.ro-1 { left: 42.031%; top: 68.750%; width: 12.500%; height: 8.125%; }
.ro-2 { left: 24.792%; top: 68.750%; width: 12.500%; height: 8.125%; }
.ro-canvas, .lcd-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.ro-v, .ro-u {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

/* ---- TIMESTAMP: the level stopwatch -------------------------------------
   The digit window of the TIMESTAMP box, x 1140..1474, y 712..792. app.js
   adds .is-warn past TIME_WARNING_THRESHOLD_SEC and the digits go red. */
.lcd { position: absolute; left: 59.375%; top: 68.750%; width: 17.396%; height: 8.333%; }

/* ---- quit plate ---------------------------------------------------------
   V12.5a: the TOTALSTATIONTECH plate across the bottom of the bezel is the
   way out of a level on a touchscreen, where there is no ESC key. It sits
   exactly on the painted plate (the layer-logo-bottom art) and is marked
   data-nomeasure so a tap on it can never fall through to tap-to-measure. */
.quit-plate {
  position: absolute;
  left: 38.802%; top: 83.542%; width: 22.240%; height: 9.792%;
  z-index: 6;
  -webkit-appearance: none; appearance: none;
  border: 0; padding: 0; margin: 0;
  background-color: transparent;
  border-radius: 1cqw;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background-color .1s ease, box-shadow .1s ease;
}
.quit-plate::-moz-focus-inner { border: 0; }
.quit-plate:hover, .quit-plate:focus-visible {
  background-color: rgba(245,197,24,.15);
  box-shadow: 0 0 1.8cqw rgba(245,197,24,.55);
  outline: none;
}
.quit-plate:active { background-color: rgba(245,197,24,.3); }

/* result toast — shown for the half-second between points, centred across
   both panels (x 433..1504) */
.shot-msg {
  position: absolute; left: 22.552%; width: 55.781%; top: 36.5%;
  margin: 0; text-align: center;
  font-family: var(--font-display);
  font-weight: 700; font-size: 2.3cqw; letter-spacing: .35cqw;
  padding: .9cqw 0;
  background: rgba(0,0,0,.86);
  border-top: .18cqw solid currentColor;
  border-bottom: .18cqw solid currentColor;
  opacity: 0; transition: opacity .12s ease;
  pointer-events: none;
  z-index: 6;
}
.shot-msg.is-on { opacity: 1; }
.shot-msg.pass { color: #4caf50; }
.shot-msg.fail { color: var(--red); }

/* start gate over the two panels: x 433..1504, y 197..662 */
.start-gate {
  position: absolute;
  left: 22.552%; top: 15.104%; width: 55.781%; height: 48.438%;
  background: rgba(0,0,0,.87);
  border-radius: .7cqw;
  display: grid; place-items: center; text-align: center;
  color: var(--yellow);
  font-family: var(--font-display);
  z-index: 4;
}
.start-gate[hidden] { display: none; }
.sg-1 { margin: 0; font-size: 3.4cqw; font-weight: 700; letter-spacing: .6cqw; animation: sgPulse 1.2s infinite; }
.sg-2 { margin: .6cqw 0 0; font-size: 2.2cqw; font-weight: 700; letter-spacing: .45cqw; color: #fff; animation: sgPulse 1.2s infinite; }
/* V12.5a: the quit line made this one line longer, so it is wound in enough
   to keep the whole block inside the gate panel rather than spilling onto the
   readout boxes underneath. */
.sg-3 { margin: 1.4cqw 2.2cqw 0; font-family: var(--font-mono); font-size: 1.08cqw; line-height: 1.55; color: #9a9a9a; letter-spacing: .04cqw; }
@keyframes sgPulse { 0%,100% { opacity: 1; } 50% { opacity: .45; } }

/* ==========================================================================
   SCREEN 3 — FIELD REPORT
   ========================================================================== */

.report-band {
  position: absolute; left: 0; right: 0; top: 86.05%; bottom: 0;
  background: #000;
  pointer-events: none;
}
.report-band::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 0.6cqw;
  background-image: repeating-linear-gradient(135deg,
                    var(--yellow) 0 1cqw, #0a0a0a 1cqw 2cqw);
  opacity: .85;
}

/* meta block values (labels stay part of the artwork) */
.meta-val {
  position: absolute;
  left: 81.90%; width: 15.43%; height: 2.52%;
  background: #000;
  display: flex; align-items: center;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.5cqw;
  letter-spacing: .06cqw;
  color: #fff;
  white-space: nowrap; overflow: hidden;
}
.meta-1 { top: 2.35%; }
.meta-2 { top: 5.46%; }
.meta-3 { top: 8.40%; }
.meta-4 { top: 11.43%; }

/* the table body: ten fixed slots drawn over the artwork's grid */
.report-body {
  position: absolute;
  left: 2.21%; top: 20.50%; width: 95.51%; height: 45.04%;
  background: #000;
  display: grid;
  grid-template-rows: repeat(10, 1fr);
}
.rep-row {
  display: grid;
  grid-template-columns: 20.01% 30.95% 26.04% 23.01%;
  align-items: center;
  border-bottom: 1px solid rgba(255,255,255,.22);
}
.rep-row:last-child { border-bottom: 0; }
.rep-row > div {
  text-align: center;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 2.3cqw;
  letter-spacing: .08cqw;
  border-right: 1px solid rgba(255,255,255,.22);
  height: 100%;
  display: flex; align-items: center; justify-content: center;
}
.rep-row > div:last-child { border-right: 0; }
.rep-c-point { color: var(--yellow); }
.rep-c-time  { color: #fff; }
.rep-c-err   { color: var(--yellow); }

.rep-chip {
  display: inline-block;
  min-width: 62%;
  padding: .32cqw 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 2.35cqw;
  letter-spacing: .25cqw;
  border-radius: .3cqw;
  color: #000;
}
.rep-chip.pass { background: #00e83c; }
.rep-chip.fail { background: #ff1f1f; }

/* summary figures */
.sum {
  position: absolute;
  top: 71.43%; height: 8.40%;
  background: #000;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 7.3cqw;
  line-height: 1;
  letter-spacing: .1cqw;
  color: var(--yellow);
}
.sum.ok  { color: #00e83c; }
.sum.bad { color: #ff1f1f; }
.sum-1 { left: 9.77%;  width: 12.37%; }
.sum-2 { left: 32.55%; width: 11.72%; }
.sum-3 { left: 54.04%; width: 11.39%; }
.sum-4 { left: 74.87%; width: 17.58%; }

/* action buttons */
.report-actions {
  position: absolute; left: 0; right: 0; top: 88.4%;
  display: flex; justify-content: center; gap: 3cqw;
}
.ticket-btn {
  border: .28cqw solid var(--yellow);
  background: linear-gradient(180deg, var(--yellow-bright) 0%, var(--yellow) 55%, #d9ab08 100%);
  color: #0a0a0a;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 2.3cqw;
  letter-spacing: .4cqw;
  padding: 1.1cqw 3.6cqw;
  cursor: pointer;
  clip-path: polygon(1.1cqw 0, 100% 0, 100% calc(100% - 1.1cqw), calc(100% - 1.1cqw) 100%, 0 100%, 0 1.1cqw);
  transition: filter .14s ease, transform .1s ease;
}
.ticket-btn:hover  { filter: brightness(1.09); }
.ticket-btn:active { transform: translateY(.22cqw); }
.ticket-btn:focus-visible { outline: .2cqw solid #fff; outline-offset: .3cqw; }
.ticket-btn--ghost {
  background: #0a0a0a;
  color: var(--yellow);
}
.ticket-btn--ghost:hover { background: #161616; }

.report-note {
  position: absolute; left: 0; right: 0; top: 96.2%;
  margin: 0; text-align: center;
  font-family: var(--font-display);
  font-size: 1.3cqw; letter-spacing: .25cqw;
  color: #8e8e8e;
  min-height: 1.6cqw;
}

/* ==========================================================================
   SCREEN 2 - TOUCH CONTROLS (V12 geometry)
   --------------------------------------------------------------------------
   Real hotspots sitting exactly over the pad and MEASURE art (the layer-pad-*
   and layer-meas-* images). The elements, classes and bindings are V11.2's
   unchanged; V12 only moves them onto the new art, which paints the pads
   about 60% bigger on a landscape phone than the V11 art did -- that, plus
   the wider 2:1 stage, is where the bigger touch targets come from.

   All of their state visuals are drawn over the art, never instead of it:
   a pressed direction lights its wedge, a dead control gets a dark cap, an
   armed MEASURE pulses green. The V12 art has no pressed-state images of its
   own, so these are the V11 overlays, reshaped to the new pads.
   ========================================================================== */
.tc {
  position: absolute; inset: 0;
  z-index: 5;
  pointer-events: none;          /* only the hotspots themselves take taps */
}
.tc-hit {
  position: absolute;
  pointer-events: auto;
  -webkit-appearance: none; appearance: none;
  border: 0; padding: 0; margin: 0;
  background-color: transparent;
  cursor: pointer;
  /* the pads are held, not tapped: kill scroll, pinch and double-tap-zoom so
     a long press drives the player instead of gesturing the page */
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  transition: background-color .08s linear, box-shadow .08s linear;
}
.tc-hit::-moz-focus-inner { border: 0; }

/* --- LEFT PAD: four-way D-pad --------------------------------------------
   All four arrows occupy the SAME box -- the pad art's own box, (34,205) to
   (422,588), whose centre is the pad's centre -- and each is clipped to one
   triangular quarter of it, meeting in the middle. Wedges rather than a plus
   of rectangles so every pixel of the pad belongs to exactly one direction
   and each direction's target is roughly the full width of the pad.
   clip-path clips hit-testing, not just paint, which is what makes this work.

   The pressed and dead looks are painted with a circle the size of the pad
   (closest-side), so they sit on the round pad and not on the square box's
   empty corners. */
.tc-dir {
  left: 1.771%; top: 15.937%;
  width: 20.208%; height: 39.896%;
  border-radius: 0;
}
.dir-up    { clip-path: polygon(50% 50%,   0%   0%, 100%   0%); }
.dir-right { clip-path: polygon(50% 50%, 100%   0%, 100% 100%); }
.dir-down  { clip-path: polygon(50% 50%, 100% 100%,   0% 100%); }
.dir-left  { clip-path: polygon(50% 50%,   0% 100%,   0%   0%); }

.tc-dir.is-down {
  background: radial-gradient(circle closest-side,
              rgba(255,216,61,.42) 0 55%, rgba(245,197,24,.22) 88%, transparent 96%);
}
.tc-dir[disabled] {
  cursor: default;
  background: radial-gradient(circle closest-side, rgba(0,0,0,.42) 0 95%, transparent 96%);
}

/* --- RIGHT PAD: the bubble joystick --------------------------------------
   One round zone covering the whole pad art, (1495,205) to (1885,588).
   Analog: where the thumb sits in the zone is the rod tilt.

   A div rather than a button on purpose: a stick is dragged, not clicked, and
   a button would fire a synthetic click on release that the stage's
   tap-to-measure handler would see as a shot. */
.tc-stick {
  position: absolute;
  pointer-events: auto;
  left: 77.865%; top: 15.937%;
  width: 20.312%; height: 39.896%;
  border-radius: 50%;
  touch-action: none;                 /* a drag here is a stick, never a scroll */
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
  transition: background-color .1s linear;
}

/* the nub: shows where the stick thinks your thumb is. Parked dead centre and
   invisible until touched, so it never fights the painted artwork. */
.stick-nub {
  position: absolute;
  left: 50%; top: 50%;
  width: 30%; aspect-ratio: 1;
  margin: 0;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
  pointer-events: none;
  transition: opacity .1s linear;
}
.tc-stick.is-down .stick-nub { opacity: 1; }
.stick-r .stick-nub { background: radial-gradient(circle at 38% 34%, #dfffd0 12%, #22d422 60%, #0d6b0d 100%); }

.tc-stick.is-down { background-color: rgba(255,255,255,.07); }

/* Both controls go dead with the panel they drive: the D-pad with the position
   dial, the joystick with the vial. */
.tc-stick.is-off { cursor: default; background-color: rgba(0,0,0,.42); }
.tc-stick.is-off .stick-nub { opacity: 0; }

/* --- MEASURE buttons ------------------------------------------------------
   Over the rounded-square MEASURE art: (122,584)-(333,794) and
   (1586,584)-(1797,794). The corner radius follows the art's. */
.tc-measure {
  top: 55.417%; width: 10.990%; height: 21.875%;
  border-radius: 24%;
}
.meas-l { left:  6.354%; }
.meas-r { left: 82.604%; }
.tc-measure.is-down {
  background-color: rgba(245,197,24,.34);
  box-shadow: 0 0 2.2cqw rgba(255,216,61,.8), inset 0 0 1.8cqw rgba(255,216,61,.5);
}

/* V11: locked out until the engine says MEASURE is live. The `disabled`
   attribute is what actually stops the press -- a disabled button fires no
   pointer events at all -- and this is only how that reads on screen: a dark
   cap over the button art so it is obviously not pressable yet. */
.tc-measure[disabled] {
  cursor: default;
  background-color: rgba(0,0,0,.52);
  box-shadow: inset 0 0 1.4cqw rgba(0,0,0,.6);
}
/* and a slow pulse the moment it unlocks */
.tc-measure.is-armed {
  background-color: rgba(34,212,34,.16);
  box-shadow: 0 0 1.8cqw rgba(34,212,34,.55);
  animation: measArm 1.5s ease-in-out infinite;
}
@keyframes measArm {
  0%, 100% { box-shadow: 0 0 1.1cqw rgba(34,212,34,.38); }
  50%      { box-shadow: 0 0 2.6cqw rgba(34,212,34,.85); }
}
@media (prefers-reduced-motion: reduce) {
  .tc-measure.is-armed { animation: none; }
}

/* ==========================================================================
   DOWNLOAD-CONFIRM MODAL
   --------------------------------------------------------------------------
   download_menu_only.png is 1717x916 and already carries the header, the CSV
   mark, the question and both button plates. The three hotspots are measured
   off it: HECK YEAH x[165,850] y[564,751], lol NO x[889,1556] y[564,751], and
   the close octagon around (1545,170) - widened here to a comfortable thumb
   target, since the painted glyph alone is only 80px across.
   ========================================================================== */
.dl-overlay {
  position: fixed; inset: 0;
  z-index: 40;
  background: rgba(3,3,4,.84);
  display: grid; place-items: center;
  padding: 4vmin;
}
.dl-overlay[hidden] { display: none; }

.dl-card {
  position: relative;
  container-type: size;
  width: min(94vw, 860px, calc((100vh - 8vmin) * 1717 / 916));
  aspect-ratio: 1717 / 916;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 100% 100%;
  background-image: url("../assets/img/download_menu_only.png");
  background-image: image-set(url("../assets/img/download_menu_only.webp") type("image/webp"),
                              url("../assets/img/download_menu_only.png")  type("image/png"));
  animation: dlPop .16s ease-out;
}
@keyframes dlPop {
  from { opacity: 0; transform: scale(.94); }
  to   { opacity: 1; transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) { .dl-card { animation: none; } }

.dl-hit {
  position: absolute;
  -webkit-appearance: none; appearance: none;
  border: 0; padding: 0; margin: 0;
  background-color: transparent;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  border-radius: 1.4cqw;
  transition: background-color .1s ease, box-shadow .1s ease, transform .08s ease;
}
.dl-hit::-moz-focus-inner { border: 0; }
.dl-hit:active { transform: translateY(.35cqw); }

.dl-yes   { left:  9.61%; top: 61.57%; width: 39.95%; height: 20.52%; }
.dl-no    { left: 51.78%; top: 61.57%; width: 38.91%; height: 20.52%; }
.dl-close { left: 85.91%; top: 10.92%; width:  8.15%; height: 15.28%; border-radius: 50%; }

.dl-yes:hover,   .dl-yes:focus-visible   { background-color: rgba(255,255,255,.17);
                                           box-shadow: 0 0 2.6cqw rgba(0,232,60,.75); outline: none; }
.dl-no:hover,    .dl-no:focus-visible    { background-color: rgba(255,255,255,.15);
                                           box-shadow: 0 0 2.6cqw rgba(255,31,31,.75); outline: none; }
.dl-close:hover, .dl-close:focus-visible { background-color: rgba(255,255,255,.2);
                                           box-shadow: 0 0 2.2cqw rgba(245,197,24,.9); outline: none; }

/* ---- small viewports ----------------------------------------------------- */
@media (max-width: 720px) {
  .sg-3 { display: none; }
}

/* A phone held upright letterboxes the 3:2 instrument down to about a third of
   the screen height, which puts each D-pad cell under 20px - too small to play
   with a thumb. The controls still work; this only tells the player the
   instrument wants to be held the way a real data collector is. Delete this
   block and the .rotate-hint element in index.html if the hint is not wanted. */
.rotate-hint {
  position: fixed; left: 0; right: 0; top: 7vh;
  margin: 0; text-align: center;
  font-family: var(--font-display);
  font-weight: 700; font-size: 4.6vw; letter-spacing: 1vw;
  color: var(--yellow);
  text-shadow: 0 0 2vw rgba(0,0,0,.95);
  pointer-events: none;
  z-index: 8;
  display: none;
}
@media (orientation: portrait) and (max-width: 900px) {
  #screen-player.is-active .rotate-hint { display: block; animation: sgPulse 1.8s infinite; }
}


/* ==========================================================================
   LEGAL LINKS
   Viewport-fixed rather than placed inside .stage: the menu is a measured
   overlay on the concept art in container-query units, and anything added
   inside it would have to be re-measured. Shown on the menu only.
   ========================================================================== */
#legalBar {
  display: none;
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  padding: 6px 12px calc(6px + env(safe-area-inset-bottom));
  text-align: center;
  font-family: var(--font-display);
  font-size: 11px; letter-spacing: .4px;
  color: rgba(255, 255, 255, .42);
  background: linear-gradient(to top, rgba(0, 0, 0, .85), rgba(0, 0, 0, 0));
  pointer-events: none;
}
html.is-menu #legalBar { display: block; }
#legalBar a { color: rgba(255, 255, 255, .62); text-decoration: none; pointer-events: auto; }
#legalBar a:hover, #legalBar a:focus-visible { color: #ffd23f; }
