/* Full-resolution UI layer over the pixel-art canvas.
   All text and interface (HUD, menus, dialogs, messages, touch controls) is HTML/CSS so it
   renders at the screen's native resolution. The game art stays on the low-res canvas.
   --u = CSS pixels per game pixel (set by Dom.layout). Brand colors only. */

@font-face {
  font-family: 'Silkscreen';
  src: url('../lib/fonts/Silkscreen-400.woff2') format('woff2');
  font-weight: 400;
  font-display: block;
}
@font-face {
  font-family: 'Silkscreen';
  src: url('../lib/fonts/Silkscreen-700.woff2') format('woff2');
  font-weight: 700;
  font-display: block;
}

:root {
  --ink: #1B1B1B; --paper: #F2EEE3; --grey: #B5B3AD; --pink: #F0479B; --green: #7ED63C;
  --u: 1px;
  /* HUD text scales with the game but never gets too small to read on a phone */
  --hud: clamp(12px, calc(var(--u) * 8.5), 22px);
  /* Safe-area insets reaching into the stage (Dom.layout); 0 when there's no notch */
  --safe-l: 0px; --safe-t: 0px; --safe-r: 0px; --safe-b: 0px;
}

canvas { image-rendering: pixelated; image-rendering: crisp-edges; }

#ui { position: fixed; inset: 0; pointer-events: none; z-index: 5; font-family: 'Silkscreen', monospace;
      color: var(--ink); -webkit-font-smoothing: antialiased; }
#stage { position: absolute; overflow: hidden; }
#stage * { box-sizing: border-box; }
.px { image-rendering: pixelated; image-rendering: crisp-edges; }
button { font: inherit; }

/* ---------------------------------------------------------------- HUD (zine frame) */
/* Zones (see CLAUDE.md, "HUD layout"): one row of three flex boxes, left / middle / right,
   inset from the stage edges by at least the safe area. They share the width, so they can't
   overlap at any screen size; the middle one (the minimap) shrinks first. */
.hud { position: fixed; left: var(--hud-x, 0); top: var(--hud-y, 0); width: var(--hud-w, 100%); height: 0;
       font-size: var(--hud); line-height: 1; }
/* The band (--hud-x/y/w, set by Dom.layout) is the stage, widened into letterbox bars when
   there's room, and always inside the safe area. */
.hud-row { position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: flex-start; gap: 0.6em;
           padding: 0.5em 0.5em 0; }
.hud-left { display: flex; flex-direction: column; align-items: flex-start; gap: 0.55em; flex: none; }
.hud-mid { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 0.5em; padding-top: 0.1em; }
.hud .card { position: relative; }
/* Compact (small screens, set by Dom.layout): shorter meters and smaller hold slots */
#stage.compact .bar { width: 5.2em; }
#stage.compact .slot { width: 1.5em; height: 1.5em; }
#stage.compact .hud-row { gap: 0.4em; }
.card {
  position: absolute; background: var(--paper); border: 0.15em solid var(--ink);
  box-shadow: 0.2em 0.2em 0 var(--pink); padding: 0.35em 0.5em;
}
.card::after { /* photocopy speckle on the paper card */
  content: ''; position: absolute; inset: 0; pointer-events: none; opacity: 0.18;
  background: url('../assets/textures/ink_speckle.png') 0 0 / 30em auto;
}
.meters { transform: rotate(-0.6deg); display: grid;
          grid-template-columns: auto auto; gap: 0.3em 0.5em; align-items: center; }
.meters .label { font-weight: 700; letter-spacing: 0.04em; font-size: 0.85em; }
.bar { position: relative; width: 7.5em; height: 0.75em; border: 0.12em solid var(--ink); background: var(--paper); }
.bar .fill { position: absolute; inset: 0; transform-origin: left center; background-size: 100% 100%; }
.bar .tick { position: absolute; top: -0.2em; bottom: -0.2em; width: 0.12em; background: var(--ink); }
.bar.locked .fill { filter: grayscale(1); opacity: 0.6; }

.right { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 0.35em; }
.slots { display: flex; gap: 0.3em; }
.slot { width: var(--slot, 2.2em); height: var(--slot, 2.2em); border: 0.15em solid var(--ink); background: var(--paper);
        display: grid; place-items: center; box-shadow: 0.12em 0.12em 0 var(--ink); }
.slot.full { background: var(--pink); }
.slot img { width: 85%; height: 85%; object-fit: contain; }
.tag { background: var(--paper); border: 0.12em solid var(--ink); padding: 0.2em 0.4em; font-weight: 700; font-size: 0.85em; }
.tag b { color: var(--pink); }
.iconbtn { pointer-events: auto; cursor: pointer; width: 2.2em; height: 1.8em; padding: 0; border: 0.12em solid var(--ink);
           background: var(--paper); display: grid; place-items: center; }
.iconbtn img { width: 75%; }

.minimap { position: relative; width: 100%; max-width: 22em; height: 1em;
           background: var(--ink); border: 0.12em solid var(--ink); }
.minimap .line { position: absolute; left: 0.3em; right: 0.3em; top: 50%; height: 0.1em; background: var(--grey); }
.minimap .dot { position: absolute; top: 50%; width: 0.3em; height: 0.3em; margin: -0.15em 0 0 -0.15em; background: var(--paper); }
.minimap .dot.suit { background: var(--grey); height: 0.45em; margin-top: -0.35em; }
.minimap .dot.ufo { background: var(--green); width: 0.5em; height: 0.4em; margin: -0.5em 0 0 -0.25em; }
.minimap .dot.ship { background: var(--pink); width: 0.7em; height: 0.3em; margin: -0.55em 0 0 -0.35em; }
.minimap .dot.end { background: var(--paper); width: 0.15em; height: 0.8em; margin-top: -0.4em; }
/* A level taller than a screen (Metro): the radar is a box, dots at their height too; the
   line is the street along the bottom */
.minimap.tall { height: 2.4em; }
.minimap.tall .line { top: auto; bottom: 0.2em; }
.minimap.tall .dot.end { top: auto; bottom: 0; margin-top: 0; height: 100%; opacity: 0.35; }
/* Crop Circle: the radar (alien tech) shows every animal left, in acid green */
.minimap.crop .line { background: var(--green); opacity: 0.6; }
.minimap.crop .dot.animal { background: var(--green); box-shadow: 0 0 0.25em var(--green); }
.minimap.crop .dot.guest { background: var(--green); }
.minimap .sweep { position: absolute; top: -0.25em; bottom: -0.25em; width: 0.35em; margin-left: -0.175em;
  background: var(--green); box-shadow: 0 0 0.6em 0.2em var(--green); pointer-events: none; }

/* ---------------------------------------------------------------- messages */
.toast { position: absolute; left: 50%; top: 18%; transform: translate(-50%, 0) rotate(-1deg);
         background: var(--paper); border: 0.15em solid var(--ink); box-shadow: 0.18em 0.18em 0 var(--ink);
         padding: 0.3em 0.6em; font-weight: 700; font-size: calc(var(--hud) * 1.05); white-space: nowrap;
         opacity: 0; transition: opacity 0.25s; }
.toast.show { opacity: 1; }

.float { position: absolute; transform: translate(-50%, -50%); font-weight: 700; color: var(--pink);
         font-size: calc(var(--hud) * 1.5); white-space: nowrap;
         text-shadow: 0.08em 0.08em 0 var(--ink), -0.08em 0.08em 0 var(--ink), 0.08em -0.08em 0 var(--ink), -0.08em -0.08em 0 var(--ink);
         animation: floatUp 1.1s ease-out forwards; }
@keyframes floatUp { 0% { transform: translate(-50%, -50%) scale(1.5); opacity: 1; }
                     20% { transform: translate(-50%, -50%) scale(1); }
                     100% { transform: translate(-50%, -160%) scale(1); opacity: 0; } }

/* Sanctuary One warning marker and dock timer */
.marker { position: absolute; top: 0.2em; transform: translateX(-50%); font-size: var(--hud); font-weight: 700;
          text-align: center; color: var(--pink); text-shadow: 0.08em 0.08em 0 var(--ink); white-space: nowrap; }
.marker .chev { font-size: 1.8em; line-height: 0.9; display: block; }
.marker.pulse { animation: pulse 0.6s ease-in-out infinite alternate; }
.marker.calm { animation: none; }
@keyframes pulse { from { opacity: 1; transform: translateX(-50%) scale(1); } to { opacity: 0.45; transform: translateX(-50%) scale(1.12); } }
.docktimer { position: absolute; transform: translate(-50%, 0); background: var(--ink); color: var(--paper);
             border: 0.12em solid var(--pink); padding: 0.15em 0.4em; font-weight: 700; font-size: 0.9em;
             font-size: calc(var(--hud) * 0.9); white-space: nowrap; }
.docktimer b { color: var(--green); }

/* ---------------------------------------------------------------- dialog */
.dialog-wrap { position: absolute; inset: 0; background: rgba(27, 27, 27, 0.55); display: grid; place-items: center; pointer-events: auto; }
.dialog { background: var(--paper); border: 0.2em solid var(--ink); box-shadow: 0.3em 0.3em 0 var(--pink);
          padding: 1em 1.4em; text-align: center; font-size: calc(var(--hud) * 1.2); transform: rotate(-0.8deg); max-width: 92%; }
.dialog h2 { margin: 0 0 0.3em; font-size: 1.5em; line-height: 1.05; }
.dialog h2 b { color: var(--pink); }
.dialog p { margin: 0 0 0.9em; font-size: 0.8em; }
.dialog .buttons { display: flex; gap: 0.8em; justify-content: center; flex-wrap: wrap; }
.btn { pointer-events: auto; cursor: pointer; font-weight: 700; font-size: 0.95em; padding: 0.45em 0.9em;
       border: 0.15em solid var(--ink); background: var(--paper); color: var(--ink); box-shadow: 0.15em 0.15em 0 var(--ink); }
.btn.sel, .btn:hover { background: var(--pink); color: var(--paper); }
.btn:active { transform: translate(0.1em, 0.1em); box-shadow: none; }

/* ---------------------------------------------------------------- menu screens */
.screen { position: absolute; inset: 0; font-size: max(11px, calc(var(--u) * 10)); pointer-events: auto; }
.screen .abs { position: absolute; }
.title-h { font-weight: 700; font-size: 2.6em; line-height: 0.95; letter-spacing: 0.01em; }
.title-h .vegan { color: var(--pink); text-shadow: 0.06em 0.06em 0 var(--ink); }
.level-tag { background: var(--pink); color: var(--ink); font-weight: 700; padding: 0.2em 0.5em; transform: rotate(-2deg); font-size: 1.1em; }
.help { font-size: 0.95em; line-height: 1.45; }
.help b { font-weight: 700; }
.prompt { left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--paper); font-weight: 700;
          font-size: 1.5em; padding: 0.2em 0.7em; white-space: nowrap; }
.prompt.blink { animation: blink 1.2s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0.55; } }
.toggles { left: 0; right: 0; display: flex; justify-content: space-between; padding: 0 1.4em; }
.toggle { pointer-events: auto; cursor: pointer; font-weight: 700; font-size: 1em; padding: 0.3em 0.6em;
          border: 0.12em solid var(--ink); background: var(--paper); }
.toggle kbd { font: inherit; color: var(--pink); }
.center { left: 50%; transform: translateX(-50%); text-align: center; white-space: nowrap; }
.h-results { font-size: 2.2em; font-weight: 700; }
.forks { display: flex; gap: 1.6em; justify-content: center; }
.forks img { height: 7.2em; }
.forks img.pop { animation: pop 0.35s ease-out backwards; }
@keyframes pop { from { transform: scale(0.2); } 70% { transform: scale(1.15); } to { transform: scale(1); } }
.stats { font-size: 1.35em; line-height: 1.5; }
.stats b { color: var(--pink); }
.big-pink { font-size: 3em; font-weight: 700; color: var(--pink); text-shadow: 0.06em 0.06em 0 var(--ink); }

/* ---------------------------------------------------------------- debug */
.debug { position: absolute; left: 0.5em; top: 5em; margin: 0; font: 12px/1.3 monospace; color: var(--paper);
         background: rgba(27, 27, 27, 0.8); padding: 0.4em 0.6em; white-space: pre; }

/* ---------------------------------------------------------------- touch controls (full resolution) */
#touch { position: fixed; inset: 0; pointer-events: none; }
#touch.hidden { display: none; }
#touch .zone { position: absolute; left: 0; top: 0; bottom: 0; width: 50%; pointer-events: auto; touch-action: none; }
#touch .pad { position: absolute; border-radius: 50%; background: rgba(27, 27, 27, 0.45);
              border: 3px solid rgba(242, 238, 227, 0.75); pointer-events: none; }
#touch .pad::before, #touch .pad::after { content: ''; position: absolute; left: 50%; top: 50%; background: rgba(242, 238, 227, 0.35); transform: translate(-50%, -50%); }
#touch .pad::before { width: 64%; height: 3px; }
#touch .pad::after { width: 3px; height: 64%; }
#touch .thumb { position: absolute; width: 40%; height: 40%; left: 30%; top: 30%; border-radius: 50%; background: var(--pink);
                border: 3px solid var(--ink); }
#touch .beam { position: absolute; border-radius: 50%; background: var(--green); border: 4px solid var(--ink);
               display: grid; place-items: center; font-weight: 700; font-size: 20px; color: var(--ink);
               pointer-events: auto; touch-action: none; opacity: 0.85; }
#touch .beam.on { background: var(--paper); opacity: 1; }

/* ---------------------------------------------------------------- HUD additions */
.card.item { padding: 0.25em 0.45em; display: flex; align-items: center; gap: 0.45em;
             font-weight: 700; font-size: 0.85em; transform: rotate(0.6deg); }
.hud.touch .card.item { display: none; } /* touch: the USE button shows the item instead */
.card.item .stash-label { letter-spacing: 0.04em; }
.banner { background: var(--ink); color: var(--paper);
          border: 0.12em solid var(--pink); padding: 0.2em 0.6em; font-weight: 700; white-space: nowrap; }
.banner b { color: var(--pink); }
.minimap .dot.guest { background: var(--pink); width: 0.45em; height: 0.45em; margin: -0.225em 0 0 -0.225em; transform: rotate(45deg); }
.btn.disabled { opacity: 0.45; cursor: default; }

/* Audio panel: mute, music volume, effects volume */
.dialog.audio { min-width: 20em; }
.arow { display: flex; align-items: center; gap: 0.5em; margin: 0.35em 0; padding: 0.15em 0.3em; border: 0.12em solid transparent; }
.arow.sel { border-color: var(--pink); }
.alabel { width: 5.2em; font-weight: 700; font-size: 0.9em; }
.btn.astep { width: 2.1em; padding: 0.3em 0; text-align: center; font-size: 1.1em; }
.btn.aswitch { min-width: 7.2em; }
.abar { display: flex; gap: 0.18em; flex: 1; }
.abar i { display: block; width: 0.7em; height: 1.1em; border: 0.1em solid var(--ink); background: var(--paper); }
.abar i.on { background: var(--pink); }
.btn.adone { display: block; margin: 0.7em auto 0; }
.buttons { display: flex; gap: 0.8em; justify-content: center; }

/* ---------------------------------------------------------------- star map (aboard Sanctuary One) */
.starmap { color: var(--paper); }
.sm-title { font-weight: 700; font-size: 1.3em; letter-spacing: 0.04em; }
.sm-title span { color: var(--green); }
.node { position: absolute; transform: translate(-50%, -50%); pointer-events: auto; cursor: pointer; background: none; border: 0;
        padding: 0; color: var(--paper); display: flex; flex-direction: column; align-items: center; gap: 0.25em; }
.node i { font-style: normal; font-weight: 700; width: 2.2em; height: 2.2em; border-radius: 50%; display: grid; place-items: center;
          border: 0.15em solid var(--grey); background: var(--ink); font-size: 1.05em; }
.node span { font-weight: 700; font-size: 0.72em; white-space: nowrap; color: var(--grey); position: absolute; top: 2.9em; }
.node.open i { border-color: var(--pink); background: var(--pink); color: var(--ink); }
.node.done i { border-color: var(--green); background: var(--ink); color: var(--green); }
.node.locked i { border-style: dashed; color: var(--grey); }
.node.soon i { border-style: dotted; color: var(--grey); opacity: 0.7; }
.node.sel i { box-shadow: 0 0 0 0.18em var(--ink), 0 0 0 0.34em var(--green); }
.node.sel span { color: var(--paper); }
.sm-info { line-height: 1.3; padding-right: 8em; }
.sm-name { font-weight: 700; font-size: 1.35em; }
.sm-name i { font-style: normal; color: var(--ink); background: var(--pink); padding: 0 0.3em; }
.sm-tag { color: var(--grey); font-size: 0.85em; margin: 0.2em 0 0.35em; }
.sm-row { display: flex; flex-wrap: wrap; gap: 0.35em; align-items: center; font-size: 0.8em; min-height: 1.4em; }
.sm-best b { color: var(--pink); }
.chip { border: 0.1em solid var(--grey); color: var(--grey); padding: 0.05em 0.35em; }
.chip.on { border-color: var(--pink); color: var(--paper); background: rgba(240, 71, 155, 0.25); }
.sm-action { position: absolute; right: 0; top: 0.2em; }
.sm-launch { font-size: 1.1em; }
.sm-status { font-weight: 700; color: var(--grey); border: 0.12em dashed var(--grey); padding: 0.3em 0.6em; font-size: 0.85em; }
.sm-vest { display: flex; flex-direction: column; align-items: center; }
.sm-vest-title { font-weight: 700; margin-top: 0.5em; letter-spacing: 0.05em; color: var(--pink); }
.vest { position: relative; margin-top: 0.4em; }
.vest-img { position: absolute; inset: 0; width: 100%; height: 100%; }
.rocker { position: absolute; left: 50%; top: 24%; transform: translateX(-50%); font-weight: 700; color: var(--pink);
          font-size: 1.15em; letter-spacing: 0.15em; }
.vest-col { position: absolute; border-radius: 0.3em; }
.vest-col.sel { box-shadow: 0 0 0 0.12em var(--green); }
.vest-patch { position: absolute; }
.vest-slot { position: absolute; aspect-ratio: 1; border-radius: 50%; border: 0.1em dashed rgba(181, 179, 173, 0.45); }
.sm-vest-count { margin-top: auto; margin-bottom: 0.6em; font-size: 0.85em; color: var(--grey); }
.sm-vest-count b { color: var(--paper); }
.starmap .toggle { color: var(--ink); }

/* ---------------------------------------------------------------- results */
.res-count { font-weight: 700; font-size: 1.9em; white-space: nowrap; }
.res-count b { color: var(--pink); text-shadow: 0.06em 0.06em 0 var(--ink); }
.res-best { font-size: 0.5em; background: var(--pink); color: var(--paper); padding: 0.15em 0.4em; margin-left: 0.6em; vertical-align: middle; }
.res-portraits { display: flex; flex-wrap: wrap; gap: 0.35em; justify-content: center; }
.res-portraits img { height: 2.3em; animation: pop 0.3s ease-out backwards; }
.res-none { color: var(--grey); font-weight: 700; }
.res-patches { display: flex; gap: 2.4em; justify-content: center; }
.res-patch { width: 9.5em; text-align: center; white-space: normal; }
.res-badge { position: relative; width: 5.4em; height: 5.4em; margin: 0 auto 0.4em; }
.res-badge img { width: 100%; height: 100%; }
.res-badge svg { position: absolute; inset: -12%; width: 124%; height: 124%; }
.res-badge circle { fill: none; stroke: var(--pink); stroke-width: 1.6; stroke-dasharray: 117; stroke-dashoffset: 117;
                    animation: stitch 0.7s linear var(--d) forwards; }
.res-patch.fresh .res-badge img { animation: patchOn 0.35s ease-out calc(var(--d) + 0.65s) backwards; }
.res-patch.missed .res-badge img { filter: grayscale(1); opacity: 0.25; }
.res-pname { font-weight: 700; font-size: 0.95em; }
.res-pstatus { font-size: 0.78em; line-height: 1.3; margin-top: 0.2em; }
.res-patch.fresh .res-pstatus { color: var(--pink); font-weight: 700; animation: pop 0.3s ease-out calc(var(--d) + 0.9s) backwards; }
.res-patch.missed .res-pname { color: #8c8a85; }
.res-unlock { left: 0; right: 0; text-align: center; font-weight: 700; }
.res-unlock span { background: var(--ink); color: var(--paper); padding: 0.2em 0.6em; }
@keyframes stitch { to { stroke-dashoffset: 0; } }
@keyframes patchOn { from { transform: scale(1.6) rotate(-12deg); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------------------------------------------------------------- tutorial tips and edge warnings */
/* Tips sit on the dirt strip below the ground, so they never cover animals, farmers or throws.
   With touch controls they fit in the gap between the pad and the USE / BEAM buttons. */
.hint { position: absolute; left: 50%; bottom: calc(1.5% + var(--safe-b)); transform: translate(-50%, 0.4em); max-width: 58%; text-align: center;
        background: var(--paper); border: 0.15em solid var(--ink); box-shadow: 0.18em 0.18em 0 var(--pink);
        padding: 0.3em 0.6em; font-weight: 700; font-size: var(--hud); line-height: 1.3; opacity: 0;
        transition: opacity 0.3s, transform 0.3s; pointer-events: none; }
.hint.show { opacity: 1; transform: translate(-50%, 0); }
.hint.touch { left: 47%; max-width: 42%; }
.hint b { background: var(--pink); color: var(--paper); padding: 0 0.3em; margin-right: 0.45em; }
.edgewarn { position: absolute; transform: translateY(-50%); background: var(--ink); color: var(--pink);
            border: 0.15em solid var(--pink); padding: 0.15em 0.4em; font-weight: 700; font-size: calc(var(--hud) * 1.3); }
.edgewarn.left { left: calc(0.3em + var(--safe-l)); }
.edgewarn.right { right: calc(0.3em + var(--safe-r)); }
.edgewarn.pulse { animation: warnBlink 0.45s ease-in-out infinite alternate; }
@keyframes warnBlink { from { opacity: 1; } to { opacity: 0.35; } }

/* ---------------------------------------------------------------- USE button (held power-up) */
#touch .use { position: absolute; border-radius: 50%; background: var(--pink); border: 3px solid var(--ink);
              display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
              font-weight: 700; font-size: 12px; color: var(--ink); pointer-events: auto; touch-action: none; opacity: 0.9; }
#touch .use img { height: 46%; }
#touch .use .count { position: absolute; right: -4px; top: -4px; background: var(--ink); color: var(--paper); font-size: 12px;
                     line-height: 1; padding: 2px 3px; border: 2px solid var(--paper); }
#touch .use .count:empty { display: none; }
#touch .use.empty { background: rgba(27, 27, 27, 0.5); border: 3px dotted rgba(242, 238, 227, 0.8); color: rgba(242, 238, 227, 0.75); }
#touch .use.empty img { display: none; }
#touch .use.on { background: var(--paper); opacity: 1; }

/* ---------------------------------------------------------------- item slot and SEEN tag */
.card.item .slotbox { width: 2.3em; height: 2.3em; border: 0.14em dotted var(--ink); display: grid; place-items: center; position: relative; }
.card.item.has .slotbox { border-style: solid; background: var(--pink); }
.card.item .slotbox img { width: 80%; height: 80%; object-fit: contain; }
.card.item .count { position: absolute; right: -0.6em; bottom: -0.5em; background: var(--ink); color: var(--paper);
                    font-size: 0.8em; padding: 0 0.2em; line-height: 1.2; }
.card.item .keytag { position: absolute; left: -0.5em; top: -0.55em; font: inherit; font-size: 0.7em; line-height: 1.1;
                     background: var(--paper); color: var(--pink); border: 0.1em solid var(--ink); padding: 0 0.15em; }
.card.item:not(.has) .keytag { color: var(--grey); }
/* A power-up flying into the HUD */
.flyer { position: fixed; z-index: 20; pointer-events: none; filter: drop-shadow(0.15em 0.15em 0 var(--ink)); }
.worldtag { background: var(--ink); color: var(--paper); }
.worldtag.on { background: var(--paper); color: var(--ink); }
.seen { position: absolute; transform: translate(-50%, -100%); background: var(--pink); color: var(--paper);
        border: 0.12em solid var(--ink); padding: 0.05em 0.35em; font-weight: 700; font-size: calc(var(--hud) * 0.85);
        white-space: nowrap; pointer-events: none; }

/* ---------------------------------------------------------------- the ending (scenes/EndingScene.js) */
.end-caption { font-size: 1.35em; font-weight: 700; color: var(--paper); text-shadow: 0.08em 0.08em 0 var(--ink); }
.end-caption b { color: var(--pink); }
.end-skip { right: calc(1.2em + var(--safe-r)); bottom: calc(1em + var(--safe-b)); font-size: 1em; }
.end-credits { left: 10%; right: 10%; top: 12%; bottom: 12%; overflow: hidden; text-align: center; color: var(--paper);
               -webkit-mask-image: linear-gradient(transparent, #000 15%, #000 85%, transparent); mask-image: linear-gradient(transparent, #000 15%, #000 85%, transparent); }
.cr-roll { animation-name: credits-roll; animation-timing-function: linear; animation-fill-mode: both; }
@keyframes credits-roll { from { transform: translateY(100%); } to { transform: translateY(-100%); } }
.cr-h { color: var(--pink); font-weight: 700; font-size: 1.1em; margin-top: 2.2em; }
.cr-t { font-size: 1.25em; line-height: 1.5; margin-top: 0.3em; }
.end-thanks { display: flex; flex-direction: column; align-items: center; gap: 0.8em; white-space: normal; width: 90%; }
.end-big { font-size: 3.4em; line-height: 1; }
.end-sub { color: var(--paper); font-size: 1.2em; }
.end-book { pointer-events: auto; display: inline-block; margin-top: 0.6em; font-weight: 700; font-size: 1.3em; color: var(--ink);
            background: var(--paper); border: 0.15em solid var(--ink); box-shadow: 0.2em 0.2em 0 var(--pink); padding: 0.5em 0.9em;
            text-decoration: none; transform: rotate(-1deg); }
.end-book:hover { background: var(--pink); color: var(--paper); }

/* The finished battle vest's stamp (the star map) */
.vest-stamp { position: absolute; left: 50%; top: 100%; transform: translate(-50%, -50%) rotate(-6deg); pointer-events: auto; cursor: pointer;
              font: inherit; font-weight: 700; font-size: 1em; line-height: 1.05; color: var(--pink); background: rgba(27, 27, 27, 0.85);
              border: 0.18em solid var(--pink); padding: 0.25em 0.5em; letter-spacing: 0.08em; }
.vest-stamp:hover { background: var(--pink); color: var(--paper); }

/* ---------------------------------------------------------------- fuel cells and the Bureau's ETA */
.meters .fuel { display: flex; align-items: center; gap: 0.12em; height: 1em; min-width: 7.5em; }
#stage.compact .meters .fuel { min-width: 5.2em; }
.meters .fuel img { height: 1.05em; width: auto; }
.meters .fuel .inf { font-weight: 700; font-size: 1.1em; margin-left: 0.2em; }
.meters .fuel .none { font-weight: 700; font-size: 0.75em; color: var(--pink); }
.eta { background: var(--paper); color: var(--ink); border: 0.12em solid var(--ink); box-shadow: 0.12em 0.12em 0 var(--ink);
       padding: 0.2em 0.5em; font-weight: 700; font-size: 0.85em; white-space: nowrap; }
.eta b { font-size: 1.15em; margin-left: 0.2em; font-variant-numeric: tabular-nums; }
/* The last 30 seconds: hot pink, pulsing */
.eta.hot { background: var(--pink); color: var(--paper); animation: etaPulse 0.5s ease-in-out infinite alternate; }
@keyframes etaPulse { from { transform: scale(1); } to { transform: scale(1.12); } }
@media (prefers-reduced-motion: reduce) { .eta.hot { animation: none; } }
.res-timerow { font-weight: 700; font-size: 1em; }
.res-time b { color: var(--pink); }
.res-time i { font-style: normal; background: var(--pink); color: var(--paper); padding: 0.1em 0.4em; margin-left: 0.4em; }
.res-out { text-align: center; white-space: normal; width: 80%; }
.res-out .big-pink { font-size: 2.2em; }
.res-out p { font-size: 1.15em; line-height: 1.45; margin: 0.6em 0 0; }
.res-out .res-note { font-size: 0.9em; color: #6d6b66; }
.res-unlock span + span { margin-left: 0.6em; }
.sm-lifetime { font-weight: 700; font-size: 0.95em; color: var(--grey); letter-spacing: 0.03em; }
.sm-lifetime b { color: var(--pink); font-size: 1.15em; }
.sm-action { text-align: right; }
.sm-time { font-size: 0.75em; color: var(--grey); margin-top: 0.45em; white-space: nowrap; }
.sm-time b { color: var(--pink); }

/* ---------------------------------------------------------------- the fuel card (loss of life) */
.fuelcard-wrap { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.fuelcard { background: var(--paper); border: 0.2em solid var(--ink); box-shadow: 0.3em 0.3em 0 var(--pink);
            padding: 0.8em 1.6em 0.9em; text-align: center; font-size: calc(var(--hud) * 1.15); transform: rotate(-1.5deg);
            animation: fcIn 0.22s ease-out both; }
.fuelcard-wrap.out .fuelcard { animation: fcOut 0.2s ease-in both; }
.fc-cell { position: relative; width: 3.5em; height: 4em; margin: 0 auto 0.4em; }
.fc-cell img { position: absolute; inset: 0; width: 100%; height: 100%; }
/* The cell empties from the top down over the first part of the card */
.fc-empty { clip-path: inset(0 0 100% 0); animation: fcDrain calc(var(--t) * 0.55) steps(8) 0.15s forwards; }
.fc-title { font-weight: 700; letter-spacing: 0.05em; }
.fc-left { font-weight: 700; font-size: 1.4em; margin-top: 0.2em; }
.fc-left b { color: var(--pink); }
.fc-row { display: flex; gap: 0.25em; justify-content: center; margin-top: 0.45em; min-height: 1.2em; }
.fc-row img { height: 1.2em; }
.fc-row img.gone { animation: fcBlink 0.3s steps(1) 3; }
@keyframes fcIn { from { transform: rotate(-1.5deg) scale(0.3); opacity: 0; } to { transform: rotate(-1.5deg) scale(1); opacity: 1; } }
@keyframes fcOut { to { transform: rotate(-1.5deg) scale(0.6); opacity: 0; } }
@keyframes fcDrain { to { clip-path: inset(0 0 0 0); } }
@keyframes fcBlink { 50% { opacity: 0.2; } }
/* Flashing effects off: no blinking, and the card just appears */
.fuelcard-wrap.calm .fuelcard, .fuelcard-wrap.calm .fc-row img.gone { animation: none; }

/* ---------------------------------------------------------------- story scenes (interstitials)
   The zine treatment belongs here: paper, rough ink panel borders, pink tags, halftone. */
.story { color: var(--ink); cursor: pointer; font-size: max(8.5px, calc(var(--u) * 10)); }
/* A small stage (an iPhone SE in landscape gets a 320x180 canvas): smaller portraits and a wide
   balloon, so the longest lines still fit */
.story.tiny .st-setting { top: 7%; height: 27%; }
.story.tiny .st-portrait { top: 38%; width: 15%; height: 36%; }
.story.tiny .st-left { left: 2.5%; } .story.tiny .st-right { right: 2.5%; }
.story.tiny .st-balloon { left: 19%; right: 19%; top: 37%; min-height: 40%; padding: 0.5em 0.7em 1.1em; }
.story.tiny .st-text { font-size: 1.1em; line-height: 1.35; min-height: 0; }
.story.tiny .st-caption { font-size: 0.8em; left: 0.4em; top: auto; bottom: 0.4em; max-width: 92%; }
.story.tiny .st-name { font-size: 0.8em; }
.story.tiny .st-hint { bottom: 1.5%; }
.st-panel { position: absolute; background: var(--ink); border: 0.22em solid var(--ink); overflow: hidden;
            box-shadow: 0.3em 0.3em 0 var(--pink); --tilt: rotate(0deg); transform: var(--tilt);
            /* rough, hand-cut edges */
            clip-path: polygon(0.6% 1.5%, 35% 0%, 70% 1.2%, 99.4% 0.3%, 100% 40%, 99.2% 98.6%, 60% 100%, 22% 98.8%, 0% 99.6%, 0.8% 55%); }
.st-panel img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* Halftone dots, like a cheap print */
.st-halftone { position: absolute; inset: 0; pointer-events: none; mix-blend-mode: multiply; opacity: 0.3;
               background-image: radial-gradient(circle, rgba(27, 27, 27, 0.9) 28%, transparent 30%);
               background-size: 0.42em 0.42em; }
.st-setting { left: 5.5%; right: 5.5%; top: 9%; height: 37%; --tilt: rotate(-0.6deg); }
.st-caption { position: absolute; left: 0.8em; top: 0.7em; background: var(--pink); color: var(--paper); font-weight: 700;
              padding: 0.2em 0.55em; font-size: 0.95em; letter-spacing: 0.05em; transform: rotate(-1.5deg);
              box-shadow: 0.15em 0.15em 0 var(--ink); }
.st-portrait { top: 50%; width: 19%; height: 43%; background: var(--paper); transition: filter 0.2s, opacity 0.2s; }
.st-portrait img { object-fit: contain; object-position: center bottom; }
.st-portrait .st-halftone { opacity: 0.12; }
.st-left { left: 4%; --tilt: rotate(-1.2deg); }
.st-right { right: 4%; --tilt: rotate(1.2deg); }
.st-portrait.quiet { filter: grayscale(0.6) brightness(0.85); opacity: 0.7; }
.st-name { position: absolute; left: 0.3em; bottom: 0.3em; background: var(--pink); color: var(--paper); font-weight: 700;
           padding: 0.1em 0.45em; font-size: 0.9em; transform: rotate(-2deg); }
.st-portrait.quiet .st-name { background: var(--ink); }
.st-balloon { position: absolute; left: 25%; right: 25%; top: 52%; min-height: 28%; background: var(--paper);
              border: 0.2em solid var(--ink); border-radius: 0.6em; padding: 0.7em 0.9em 1.3em; box-shadow: 0.25em 0.25em 0 var(--ink); }
/* The tail points at whoever's speaking */
.st-balloon::before { content: ''; position: absolute; top: 40%; width: 1.1em; height: 1.1em; background: var(--paper);
                      border: 0.2em solid var(--ink); border-top: 0; border-right: 0; }
.st-balloon.from-left::before { left: -0.75em; transform: rotate(45deg); }
.st-balloon.from-right::before { right: -0.75em; transform: rotate(-135deg); }
.st-text { font-size: 1.25em; line-height: 1.45; font-weight: 700; white-space: normal; min-height: 4.3em; }
.st-more { position: absolute; right: 0.7em; bottom: 0.35em; color: var(--pink); font-size: 1.1em; animation: blink 0.8s steps(1) infinite; }
.st-hint { position: absolute; left: 0; right: 0; bottom: 2.6%; text-align: center; font-size: 0.8em; font-weight: 700; color: #6d6b66; }
.st-skip { position: absolute; right: 2.6%; top: 1.8%; pointer-events: auto; cursor: pointer; font: inherit; font-weight: 700;
           font-size: 0.95em; padding: 0.25em 0.7em; background: var(--ink); color: var(--paper); border: 0.12em solid var(--ink);
           box-shadow: 0.15em 0.15em 0 var(--pink); z-index: 2; }
@media (prefers-reduced-motion: reduce) { .st-more { animation: none; } }
.sm-story { display: block; margin: 0.35em 0 0 auto; font-size: 0.8em; padding: 0.25em 0.6em; }
