/* =============================================================================
 * AUTOMATA PROTOCOL — styles.css
 * A quiet, premium HUD: bleached-stone panels, warm gold accents, thin rules.
 * Nothing competes with the meadow; everything reads at a glance.
 * ========================================================================== */

/* ==========================================================================
   INTERFACE SCALE AND TYPE SIZE (src/access.js)
   ==========================================================================
   --ui-s  scales the whole interface. #ui is laid out in a viewport 1/--ui-s the
           size of the real one and then scaled up to fit, so every layout rule
           in this file sees a smaller window than the player has — which is
           exactly what a bigger interface IS. Two things have to follow that
           lie or they would still measure the real window: the viewport UNITS,
           which are --vw / --vh below (never write vw or vh in this file), and
           the @media size tiers, which access.js re-aims at the same smaller
           window by rewriting their thresholds.
   --ts    scales type only. Every font-size in this file is calc(N * var(--ts))
           except the ability plates and the key legend, whose type is a share
           of a box that --ui-s already sizes.
   Both are 1 until access.js says otherwise, which leaves the file reading
   exactly as it always did. */
:root{
  --ui-s: 1;
  --ts: 1;
  --ui-xf: none;
  --vw: calc(1vw / var(--ui-s));
  --vh: calc(1vh / var(--ui-s));
}

:root{
  --ink:        #0E1A20;
  --ink-soft:   #1B2E38;
  --paper:      #F4F1E6;
  --paper-dim:  #DCD8C8;
  --gold:       #E7B851;
  --gold-hot:   #FFD98A;
  --gold-deep:  #B7893A;
  --teal:       #2E6A80;
  --teal-lit:   #7FD4E8;
  --sky:        #8FC9E8;
  --grass:      #A9DD3E;
  --hp:         #6FD97E;
  --hp-low:     #E8574B;
  --ae:         #FFC24D;
  --xp:         #6ED8E8;
  --danger:     #FF6A5A;

  --glass:      rgba(14, 26, 32, 0.62);
  --glass-lite: rgba(20, 36, 44, 0.44);
  --edge:       rgba(244, 241, 230, 0.16);
  --edge-hot:   rgba(231, 184, 81, 0.55);

  --font: "Inter", "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", "Consolas", "Roboto Mono", monospace;

  --shadow-lg: 0 24px 60px rgba(4, 14, 20, .5), 0 4px 14px rgba(4, 14, 20, .35);
  --shadow-sm: 0 6px 18px rgba(4, 14, 20, .35);

  /* HUD PLATES.
     Neutral grey, not the blue-black ink: the meadow is a saturated chartreuse
     and a blue-tinted panel over it reads as a colour cast, where a
     desaturated one just reads as shade. Opaque enough to carry small type at
     a glance — this is an instrument, and an instrument you have to squint at
     is not reporting anything. */
  --hud-plate:    rgba(17, 21, 24, .62);
  --hud-plate-hi: rgba(24, 29, 32, .74);
  --hud-well:     rgba(8, 11, 13, .80);
  --hud-edge:     rgba(232, 238, 240, .16);
  --hud-shade:    0 2px 16px rgba(0, 0, 0, .34);

  /* THE TOP LANE, declared once and read by both halves of it.
     Down the centre of the screen sit the readout, then the boss bar, then
     the notice column. The boss bar hangs at --boss-top and is never taller
     than --boss-h (its countdown state, set in fixed pixels, is the tallest
     it gets), and #notices starts below that lane. Two numbers instead of two
     opinions: neither element can be moved without moving the other. */
  --boss-top: 64px;
  --boss-h:   46px;
}

*{ box-sizing: border-box; }
html, body{
  margin:0; padding:0; height:100%; overflow:hidden;
  background:#0A1418; color:var(--paper);
  font-family:var(--font);
  -webkit-font-smoothing:antialiased;
  text-rendering:optimizeLegibility;
  user-select:none; -webkit-user-select:none;
}
body.playing{ cursor:none; }

#app{ position:fixed; inset:0; }
#gl{ position:absolute; inset:0; width:100%; height:100%; display:block; }

/* pointer-events is inherited, so one declaration here makes the whole overlay
   click-through; the few interactive pieces (.overlay.shown, #slots) opt back
   in. Do NOT re-declare it on `#ui > *` — that ID-level specificity would beat
   those opt-ins and swallow every click. */
#ui{
  position:absolute; left:0; top:0; pointer-events:none; z-index:10;
  width:calc(100% / var(--ui-s)); height:calc(100% / var(--ui-s));
  transform:var(--ui-xf); transform-origin:0 0;
}

#text-layer{
  position:absolute; inset:0; pointer-events:none; z-index:9;
  overflow:hidden; contain:strict;
}

/* ==========================================================================
   FLOATING COMBAT TEXT
   ========================================================================== */
/* Damage numbers sit ON the battlefield, so they need a hard edge to survive a
   bright meadow — but that is one tight contact shadow, not a coloured halo.
   The old triple-shadow with a 14px glow was the same recipe as the icons and
   read the same way. Weight comes down to match the rest of the interface;
   legibility comes from the shadow and from tabular numerals, not from bulk. */
.dmg-num{
  position:absolute; top:0; left:0;
  font-family:var(--font);
  font-weight:400; font-size:calc(17px * var(--ts) * var(--ui-s)); letter-spacing:.8px;
  font-variant-numeric:tabular-nums;
  color:#FFF6E2;
  text-shadow:0 0 2px rgba(6,13,17,.95), 0 1px 4px rgba(6,13,17,.8);
  /* No will-change here: it promoted all sixty pooled divs to their own
     compositor layer permanently. The transform is animated from JS anyway,
     so the browser promotes the live ones on its own. */
  pointer-events:none; white-space:nowrap;
}
.dmg-num.crit{ font-size:calc(24px * var(--ts) * var(--ui-s)); font-weight:300; letter-spacing:2px; color:var(--gold-hot); }
.dmg-num.player{ color:#FF9A88; }
.dmg-num.heal{ color:#8CF0AF; }
.dmg-num.xp{ color:var(--xp); }
.dmg-num.label{
  font-size:calc(13px * var(--ts) * var(--ui-s)); font-weight:400; letter-spacing:3.4px; color:#EAF6FF;
  text-transform:uppercase;
}
.dmg-num.levelup{
  font-size:calc(22px * var(--ts) * var(--ui-s)); font-weight:200; letter-spacing:7px; color:var(--gold-hot);
  text-transform:uppercase;
}
.dmg-num.big{
  font-size:calc(20px * var(--ts) * var(--ui-s)); font-weight:300; letter-spacing:4px; color:#FFD3C8;
  text-transform:uppercase;
}

/* ==========================================================================
   HUD
   ==========================================================================
   The in-game interface speaks the same language as the menu, because it is
   the same object: hairlines, thin weights, wide tracking, tabular numerals,
   square corners, and gold as the single accent.

   Four things were removed on purpose, and they were most of the "toy" read:
     PILLS      — every readout was a 999px-radius badge with a blurred glass
                  fill. Rounded capsules are app chrome; a rule is instrument.
     GLOW       — every bar and every fill carried a coloured box-shadow. Light
                  belongs in the render, not on the interface laid over it.
     HEAVY TYPE — 700-900 weights throughout, against a menu built on 200-600.
                  Nothing here goes above 500 except a numeral.
     GRADIENTS  — vertical gradients on every fill, which is what makes a bar
                  look like a plastic tube. Fills are flat colour now.

   Colour is only ever meaning: health state, aether, an ability's identity.
   Never decoration.
   ========================================================================== */
#hud{ position:absolute; inset:0; opacity:0; transition:opacity .5s ease; }
#hud.shown{ opacity:1; }

/* --- experience: one hairline across the very top ------------------------- */
#xp-bar{
  position:absolute; top:0; left:0; right:0; height:2px;
  background:rgba(6,13,17,.55);
}
/* No width transition on the per-frame bars (#xp-fill, #boss-fill, #hp-fill,
   #ae-fill): JS rewrites their width sixty times a second, which restarted
   the CSS transition every frame — a reflow per frame that never settled,
   plus 90-180ms of pure display lag. The game loop is the animation. */
#xp-fill{
  height:100%; width:0%; background:var(--xp);
}

/* --- the run readout ------------------------------------------------------ */
#hud-top{
  position:absolute; top:14px; left:50%; transform:translateX(-50%);
  /* STRETCH, NOT BASELINE. Baseline alignment lines up the bottoms of the
     LETTERS, so the clock — the tallest thing in the row — set the line and
     every smaller chip hung below it, sitting on the floor of the plate with
     all the slack above. Only the clock ever looked centred, because only the
     clock defined the baseline. Every chip is now the full height of the row
     and centres its own contents, so all four read as one instrument and the
     dividers between them run edge to edge. */
  display:flex; align-items:stretch; gap:0;
  color:var(--menu-text);
  /* The level, the clock and the phase sit over whatever the camera happens
     to be showing — usually the brightest green on the island, hence the
     plate. A soft shadow under the type, not a hard rim around it: at this
     size a one-pixel contour is as thick as the strokes and only muddies
     them. The plate is what buys the contrast. */
  padding:5px 6px; border-radius:999px;
  background:rgba(6,13,17,.42);
  backdrop-filter:blur(3px); -webkit-backdrop-filter:blur(3px);
  text-shadow:0 1px 6px rgba(3,10,14,.8);
}
/* CENTRED ON EACH OTHER, NOT ON A SHARED BASELINE. A label of 8.5px and a
   value of 15px sharing a baseline leaves the small word sitting low against
   the big number's optical middle, which is what read as "the LV is off".
   Each chip is its own little instrument; its two halves line up together. */
.chip{
  display:flex; align-items:center; justify-content:center; gap:8px;
  padding:0 18px; line-height:1;
  font-variant-numeric:tabular-nums; font-weight:500; font-size:calc(13px * var(--ts));
  letter-spacing:2px;
}
/* Dividers are drawn, not spaced — the readout has to hold together as one
   instrument rather than four floating numbers. */
.chip + .chip{ border-left:1px solid var(--menu-line); }
/* LEGIBLE, NOT DECORATIVE. These were 8.5px at 30% white — small enough and
   faint enough to vanish into the plate behind them, so LV and PH read as
   smudges beside their numbers rather than as words. Bigger, heavier, and at
   a weight of white that survives the meadow underneath. */
.chip-label{
  font-size:calc(10px * var(--ts)); letter-spacing:2px; text-transform:uppercase;
  color:rgba(244,241,230,.62); font-weight:600;
}
/* The clock is the one number read at a glance mid-fight, so it stays the
   largest — but not the thinnest. Weight 200 hairlines vanished the moment
   anything bright passed under them. */
.chip.time{
  font-size:calc(22px * var(--ts)); font-weight:400; letter-spacing:3px;
  color:var(--paper); padding:0 22px;
}
.chip.level #lvl-text{ font-size:calc(16px * var(--ts)); font-weight:600; color:var(--paper); }
.chip.phase #phase-text{ font-size:calc(15px * var(--ts)); font-weight:600; letter-spacing:2px; color:var(--paper); }
.chip.kills{ color:rgba(244,241,230,.72); }
.chip-ico{
  width:11px; height:11px; fill:none; stroke:currentColor;
  stroke-width:2; stroke-linecap:round; stroke-linejoin:round; opacity:.55;
}

/* --- boss bar ------------------------------------------------------------- */
/* The lane it owns is declared in :root, because the notice column starts
   where this one ends. `min-height` states the floor of that lane; its two
   states (a 46px countdown pill, a 26px name-and-track) both live inside it,
   so the bar no longer moves when the countdown becomes the fight. */
#boss-bar{
  position:absolute; top:var(--boss-top); left:50%;
  transform:translateX(-50%) translateY(-10px);
  width:min(540px, calc(58 * var(--vw))); min-height:var(--boss-h); opacity:0;
  display:flex; flex-direction:column; justify-content:flex-end;
  transition:opacity .4s ease, transform .4s cubic-bezier(.2,.9,.3,1);
}
#boss-bar.shown{ opacity:1; transform:translateX(-50%) translateY(0); }
#boss-name{
  text-align:center; font-size:calc(11px * var(--ts)); font-weight:600; letter-spacing:4px;
  text-transform:uppercase; color:#F7D4CB; margin-bottom:8px;
  text-shadow:0 1px 10px rgba(3,10,14,.75);
}
.boss-track{
  position:relative; height:3px;
  background:rgba(6,13,17,.6);
  border-bottom:1px solid rgba(244,241,230,.10);
}
#boss-fill{
  height:100%; width:100%; background:#E8574B;
}
/* Where the machine turns. Visible from the first frame of the fight, so the
   half-health break is something you can see coming rather than a surprise. */
#boss-phase{
  position:absolute; left:40%; top:-3px; bottom:-3px; width:1px;
  background:rgba(244,241,230,.55);
}

/* --- the two modes of the boss bar --- */
#boss-bar:not(.fight) #boss-name,
#boss-bar:not(.fight) .boss-track{ display:none; }
#boss-bar:not(.warning) #boss-warn{ display:none; }

/* ONE LINE OF TYPE, NOT A CAPTION AND A NUMBER.
   The word was 10px at weight 300 with 6px of tracking beside a 19px number
   at weight 200: a whisper next to a hairline, over the brightest green on
   the island. The portal asked for the word at the size of its number, in
   the readout's own face — so both halves share one size, one line box and
   the weights the readout above uses (the clock 400-500, the labels 600), and
   they centre on each other instead of on a baseline, which had sat the
   small word low against the number. Sizes stay in fixed pixels: this pill is
   the tallest thing the boss lane holds, and --boss-h is its height.

   CENTRED ON THE PILL, TOO. Tracking adds space after the LAST letter as well
   as between them, so a tracked word carries an invisible tail that pushes
   the pair off centre; each half gives its tail back with a negative margin.
   The number keeps a two-digit width so the word does not step sideways
   every time the countdown drops from 10 to 9. */
#boss-warn{
  display:flex; align-items:center; justify-content:center; gap:14px;
  padding:9px 22px;
  background:rgba(6,13,17,.58);
  border:1px solid var(--menu-line);
  line-height:1;
  text-shadow:0 1px 6px rgba(3,10,14,.8);
}
#boss-warn-label,
#boss-warn-time{ font-family:var(--font); font-size:calc(20px * var(--ts)); line-height:1; }
#boss-warn-label{
  font-weight:600; letter-spacing:3px; margin-right:-3px; text-transform:uppercase;
  color:#F0DEC4;
}
#boss-warn-time{
  font-weight:500; letter-spacing:1px; margin-right:-1px; color:var(--paper);
  font-variant-numeric:tabular-nums; min-width:2ch; text-align:center;
}
/* Each stage tightens the pulse. It breathes on OPACITY, not on scale and
   shadow — a panel that grows and glows is a notification, and this is an
   instrument reporting that something is coming. */
#boss-bar.warning #boss-warn{ animation:bossPulse 2s ease-in-out infinite; }
#boss-bar.stage2 #boss-warn{ animation-duration:1s; border-color:rgba(232,160,110,.34); }
#boss-bar.stage2 #boss-warn-label{ color:#F0BE92; }
#boss-bar.stage3 #boss-warn{ animation-duration:.42s; border-color:rgba(232,87,75,.55); }
#boss-bar.stage3 #boss-warn-label,
#boss-bar.stage3 #boss-warn-time{ color:#FF9A80; }
@keyframes bossPulse{ 0%,100%{ opacity:1; } 50%{ opacity:.55; } }
/* Enraged: the bar itself goes hot, and the rule under it thickens. */
#boss-bar.phase2 #boss-name{ color:#FF9A80; }
#boss-bar.phase2 .boss-track{ height:4px; }
#boss-bar.phase2 #boss-fill{ background:#FF6A48; }

/* Second boss reads violet, so the bar it owns does too — two bosses have to
   be told apart from the HUD alone, not just from the model. */
#boss-bar.leaper #boss-name{ color:#E4B4FF; }
#boss-bar.leaper #boss-fill{ background:#B04FE8; }
#boss-bar.leaper.phase2 #boss-fill{ background:#D24FE8; }
#boss-bar.leaper.phase2 #boss-name{ color:#F0C4FF; }

/* --- EMP: your instruments drop out for a moment ---------------------------
   Cosmetic only. The pulse never takes control away, it just makes you feel
   it — the HUD tears, desaturates and settles back. */
#hud.emp{ animation:empGlitch 1.15s steps(1,end) 1; }
@keyframes empGlitch{
  0%   { filter:invert(1) brightness(2.4) saturate(0); opacity:.9; transform:translate(0,0); }
  6%   { filter:none; opacity:.18; }
  12%  { filter:brightness(2) saturate(.2); opacity:.85; transform:translate(3px,-2px); }
  18%  { opacity:.1; transform:translate(-4px,1px); }
  26%  { filter:saturate(.15) brightness(1.5); opacity:.7; transform:translate(2px,2px); }
  34%  { opacity:.28; transform:translate(0,0); }
  46%  { filter:saturate(.4); opacity:.85; }
  60%  { opacity:.55; }
  74%  { filter:saturate(.75); opacity:.95; }
  100% { filter:none; opacity:1; transform:translate(0,0); }
}

/* --- bottom: three anchors, and an empty middle above the ability bar ------ */
/* THE ABILITY BAR IS CENTRED ON THE SCREEN, not on what is left over.
   This was three grid columns — vitals, slots, key legend — and the slots sat
   in the middle one. That only LOOKED centred while the outer two happened to
   balance: `1fr` grows past its share for content that does not fit, and the
   vitals plate is wider than half the leftover. With the legend removed the
   right column collapsed and the bar drifted forty pixels off centre. It is
   now placed against the frame itself, which is what the design always meant:
   the middle of the lower frame is where the machine stands, so the bar under
   it belongs on the same axis whatever else the HUD is carrying. */
/* AND THE TWO ANCHORS ARE SIZED AGAINST EACH OTHER, not against guesses.
   Placing both against the frame keeps the bar honestly centred, but it also
   means neither knows the other is there: the vitals plate grows with the
   viewport from the left while the bar grows from the middle outwards, and
   below about 910px they met and overlapped. Tiers cannot fix that — there is
   no width at which it is suddenly false, only widths where the collision is
   small enough to miss.

   So the plate size is DERIVED. `--slot` is whatever is left once the vitals
   have taken their share from both sides of the centred bar, divided by the
   six plates and their gaps, and capped at its natural 54px and at a share of
   the viewport height. One budget, resolved continuously at every size: the
   bar shrinks to meet the room it has instead of running into the vitals, and
   the 52px/46px plate overrides that used to be spelled out per tier are gone
   because the budget already says what they were trying to say. */
#hud-bottom{
  position:absolute; left:0; right:0; bottom:0;
  --hud-pad:18px;
  --hud-pad-x:clamp(14px, calc(3 * var(--vw)), 42px);
  --vitals-w:clamp(148px, calc(24 * var(--vw)), 272px);
  /* The legend is the right-hand anchor and is sized the same way. The budget
     below takes the LARGER of the two so the bar stays honestly centred and
     clear of both, whichever side grows first — the vitals are wider today at
     every supported size, and nothing here quietly depends on that staying
     true. */
  --legend-w:clamp(140px, calc(21 * var(--vw)), 210px);
  --side-w:max(var(--vitals-w), var(--legend-w));
  --slot-gap:clamp(5px, calc(.8 * var(--vw)), 8px);
  /* The dash plate stands apart from the six, and the gap that says so is part
   * of the bar's width — so it is part of the budget too. SEVEN plates, six
   * gaps, and the extra step between the dash and slot 1. */
  --slot-apart:clamp(6px, calc(1 * var(--vw)), 12px);
  --slot:min(54px, calc(11 * var(--vh)),
    calc((calc(100 * var(--vw)) - 2*(var(--hud-pad-x) + var(--side-w)) - 28px
          - 6*var(--slot-gap) - var(--slot-apart)) / 7));
  padding:0 var(--hud-pad-x) var(--hud-pad);
}
#hud-bottom > #vitals{ position:absolute; left:var(--hud-pad-x); bottom:var(--hud-pad); }
#hud-bottom > #legend{ position:absolute; right:var(--hud-pad-x); bottom:var(--hud-pad); }

/* --- vitals ---------------------------------------------------------------
   A bar is a RULE with a number over it, not a container with a number in it.
   The track is 4px; everything else is typography. */
#vitals{
  justify-self:start; display:flex; flex-direction:column; gap:10px;
  width:var(--vitals-w, min(272px, calc(24 * var(--vw))));
  padding:11px 13px 12px;
  background:var(--hud-plate);
  border:1px solid var(--hud-edge);
  box-shadow:var(--hud-shade);
}
.bar{ position:relative; }
.bar-label{
  display:flex; align-items:baseline; justify-content:space-between; gap:12px;
  margin-bottom:5px;
}
.bar-name{
  /* These two sit in a plate whose width is a budget (--vitals-w) shared with
     the ability bar, so they take at most part of the text-size setting; the
     interface-size setting is what grows the plate itself. */
  font-size:calc(8.5px * min(var(--ts), 1.4)); letter-spacing:3.2px; text-transform:uppercase;
  color:rgba(244,241,230,.50); font-weight:400;
}
#hp-text, #ae-text{
  font-size:calc(12px * min(var(--ts), 1.25)); font-weight:300; letter-spacing:1px;
  color:var(--menu-text); font-variant-numeric:tabular-nums; white-space:nowrap;
}
/* The track is a WELL, not a hairline: a 4px rule at half opacity simply lost
   to the grass. Deeper, darker and taller, so the fill has something to read
   against from any distance. */
.bar-track{
  position:relative; height:6px; overflow:hidden;
  background:var(--hud-well);
  border-bottom:1px solid rgba(244,241,230,.16);
}
.bar-track > div{ position:absolute; left:0; top:0; bottom:0; }
/* The trailing ghost says how much you just lost. Neutral, not red: the loss
   is told by the gap it leaves, and a second red bar only muddies the first. */
#hp-ghost{ background:rgba(244,241,230,.28); transition:none; }
#hp-fill{ background:var(--hp); }
#hp-fill.low{ background:var(--hp-low); }
/* Low health is already shouted by the full-screen grade; here it only needs to
   be stated, so the bar changes colour and the label goes with it. */
#hp-bar:has(#hp-fill.low) .bar-name,
#hp-bar:has(#hp-fill.low) #hp-text{ color:#F0A99E; }
#shield-fill{ background:rgba(200,235,255,.9); }
#ae-fill{ background:var(--ae); }
/* Both variants state their own width, so neither depends on the other's
   silence. Aether is the shorter of the two on purpose: it reads as the
   secondary reserve rather than as a second health bar. */
.bar.hp{ width:100%; }
.bar.ae{ width:74%; }
/* Not enough aether to cast: the aether rule answers, once. */
#ae-bar.flash .bar-track{ animation:aeFlash .38s ease; }
@keyframes aeFlash{
  0%,100%{ background:var(--hud-well); }
  30%{ background:rgba(232,87,75,.62); }
}

/* --- ability bar ----------------------------------------------------------
   Square plates with a hairline, no glass and no glow. Selection is spelled
   the way the menu spells it: a single gold rule. */
#slots{
  position:absolute; left:50%; transform:translateX(-50%);
  bottom:var(--hud-pad);
  display:flex; gap:var(--slot-gap, 8px); pointer-events:auto;
}
/* EVERYTHING INSIDE A PLATE IS A SHARE OF IT, so a plate that shrinks takes
   its contents with it rather than keeping 54px furniture in a 40px room. */
.slot{
  --slot-col:#E7B851;
  position:relative; width:var(--slot, 54px); height:var(--slot, 54px);
  background:var(--hud-plate-hi);
  border:1px solid var(--hud-edge);
  box-shadow:var(--hud-shade);
  overflow:hidden; cursor:pointer;
  transition:transform .18s cubic-bezier(.2,.9,.3,1), border-color .2s, background .2s;
}
/* THE DASH PLATE — first on the bar, and set apart from it.
   It is not one of the six: it answers SPACE, it cannot be selected, it cannot
   be drafted away and it cannot be lost. The step between it and slot 1 is the
   whole of that statement, and the key it carries is a word rather than a
   number for the same reason. */
.slot.dash{ margin-right:var(--slot-apart, 10px); cursor:default; }
.slot.dash .slot-key{
  left:0; right:0; top:6%; text-align:center;
  font-size:clamp(5.5px, calc(var(--slot, 54px) * .115), 7px);
  letter-spacing:.5px;
}
/* It has no selected state to show, so the hover lift would be a promise of a
   click that Space is the only way to make. */
.slot.dash:not(.empty):hover{ transform:none; border-color:var(--hud-edge); }

/* An empty slot keeps its plate. It is a socket you have not filled, not a
   hole — and a transparent one over bright grass was simply not there. */
.slot.empty{ opacity:.42; cursor:default; box-shadow:none; }
.slot:not(.empty):hover{ border-color:var(--menu-line-hi); transform:translateY(-2px); }
/* Selection LIGHTS the plate rather than replacing it: a pale wash on its own
   was invisible over the meadow, because there was nothing dark underneath. */
.slot.sel{
  border-color:var(--menu-line-hi);
  background:linear-gradient(rgba(244,241,230,.11), rgba(244,241,230,.11)), var(--hud-plate-hi);
  transform:translateY(-4px);
}
/* The gold rule, and only on the selected slot — the same single accent the
   menu spends on the active row. */
.slot.sel::after{
  content:''; position:absolute; left:0; right:0; bottom:0; height:2px;
  background:var(--gold);
}
.slot.poor .slot-icon{ opacity:.28; }
.slot.ping{ animation:slotPing .26s cubic-bezier(.2,.9,.3,1); }
/* An autonomous weapon: never selectable, so it must SAY why. The chip reads
   AUTO where a manual slot shows its keybind, which is exactly the promise —
   this one has no key. */
.slot.auto .slot-key{ display:none; }
.slot.auto::before{
  content:'AUTO';
  position:absolute; top:3px; right:5px;
  font-size:8px; letter-spacing:1.2px; font-weight:600;
  color:var(--gold, #D9B36C); opacity:.85;
  pointer-events:none;
}
.slot.auto:not(.empty):hover{ transform:none; }
@keyframes slotPing{ 0%{transform:translateY(-4px)} 45%{transform:translateY(-8px)} 100%{transform:translateY(-4px)} }

.slot-icon{
  position:absolute; inset:15% 15% 31%;
  background-size:contain; background-position:center; background-repeat:no-repeat;
  opacity:.70; transition:opacity .2s;
}
.slot.ready .slot-icon{ opacity:1; }
.slot-key{
  position:absolute; top:7%; left:11%;
  font-size:clamp(7px, calc(var(--slot, 54px) * .157), 8.5px); font-weight:400;
  letter-spacing:1px; color:rgba(244,241,230,.50);
}
/* Cooldown is a shutter closing over the plate, with the ability's own colour
   on its leading edge — a gauge, not a dark slab. */
.slot-cd{
  position:absolute; left:0; right:0; bottom:0; height:0%;
  background:rgba(8,11,13,.84);
  border-top:1px solid var(--slot-col);
  pointer-events:none;
}
.slot-cdtext{
  position:absolute; inset:0 0 22%; display:flex; align-items:center; justify-content:center;
  font-size:clamp(11px, calc(var(--slot, 54px) * .278), 15px);
  font-weight:200; letter-spacing:1px; font-variant-numeric:tabular-nums;
  color:var(--paper); opacity:0; transition:opacity .12s;
}
/* Rank as a segmented gauge rather than as dots. */
.slot-rank{ position:absolute; bottom:24%; left:13%; right:13%; display:flex; gap:2px; }
.slot-rank i{ flex:1; height:1.5px; background:rgba(244,241,230,.24); }
.slot-rank i.on{ background:var(--slot-col); }
.slot-name{
  position:absolute; left:0; right:0; bottom:5%; text-align:center;
  font-size:clamp(6px, calc(var(--slot, 54px) * .139), 7.5px);
  font-weight:400; letter-spacing:1.6px; text-transform:uppercase;
  color:rgba(244,241,230,.48);
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
.slot.sel .slot-name{ color:rgba(244,241,230,.78); }

/* ==========================================================================
   NOTICES — one column for everything the game says
   ==========================================================================
   THREE LANES USED TO COLLIDE. Banners hung at 23% of the screen height,
   mid-run hint cards at a fixed 118px (40px on a short window) and toasts in
   the top-right corner: three independent coordinates, so whether two
   messages overlapped was a question about the VIEWPORT rather than about the
   messages. At 720 the boss-signal card ran 118→238 and the wave banner
   started at 166, straight through the middle of it — which is the picture
   the portal sent back.

   They are siblings in one flex column now. Overlap is not something this
   layout avoids; it is something it cannot express — a second message queues
   under the first, and one that leaves closes the gap behind it.

   WHERE THE COLUMN STARTS IS DERIVED, NOT CHOSEN. The readout owns the top of
   the frame, the boss bar hangs under it in a lane of its own, and the
   notices begin below that lane: --boss-top + --boss-h, both declared in
   :root and both read by #boss-bar itself.

   ...OR BELOW THE CALIBRATION CARD, whichever is lower. The calibration's
   cards hang in the same lane and are taller than it, and the calibration
   raises notices of its own. `--tut-clear` is that card's measured bottom
   edge, written by the Tutorial while a card is up and removed when it is
   gone; unset, it is 0 and the lane wins.

   AND IT SITS ABOVE THE OVERLAYS. It used to live inside #hud, which is at
   opacity 0 outside a run — so every toast raised from a menu was written
   into an invisible layer ("Signed in as …", "unlocked for your next run",
   "Ads are unavailable here"), and one raised from the pause panel was drawn
   behind the panel that raised it. This is the one layer allowed to speak
   over a screen, because it is the only layer that speaks FOR one. */
#notices{
  position:absolute; z-index:31;
  top:calc(max(var(--boss-top) + var(--boss-h), var(--tut-clear, 0px)) + 10px);
  left:50%; transform:translateX(-50%);
  display:flex; flex-direction:column; align-items:center;
  gap:clamp(7px, calc(1.3 * var(--vh)), 11px);
  width:min(560px, calc(86 * var(--vw)));
  pointer-events:none;
}
/* The banner is the loudest thing the HUD ever says, and it says it by being
   large and wide-tracked rather than by being heavy and glowing. */
/* A PLATE, NOT A RIM.
 *
 * This was 200-weight type at 12px of tracking, made legible with four hard
 * one-pixel black shadows. That is the wrong tool for a hairline face: the
 * contour is as thick as the strokes it is outlining, so it eats them, and
 * what arrives is a ragged dark smear where a word should be — worst on the
 * long ones, RUSH INBOUND among them.
 *
 * The contrast now comes from behind the letters instead of around them. A
 * blurred dark pill separates the word from whatever the camera is over, which
 * lets the type carry real weight and normal tracking and simply be read. */
.banner{
  font-size:calc(clamp(18px, calc(2.6 * var(--vw)), 28px) * var(--ts)); font-weight:600; letter-spacing:5px;
  text-transform:uppercase; color:var(--paper);
  padding:7px 22px 8px; border-radius:999px;
  background:rgba(6,13,17,.55);
  border:1px solid rgba(244,241,230,.10);
  backdrop-filter:blur(5px) saturate(.95); -webkit-backdrop-filter:blur(5px);
  text-shadow:0 2px 16px rgba(3,10,14,.7);
  opacity:0; transform:translateY(10px);
  transition:opacity .45s ease, transform .55s cubic-bezier(.2,.9,.3,1);
  white-space:nowrap;
}
.banner.in{ opacity:1; transform:translateY(0); }
.banner.warn{ color:#F0D2A8; }
.banner.boss{ color:#F5B8A8; }

/* A toast is the quiet end of the same column: same centre line, a fraction
   of the voice. It slid in from the right when it lived in the corner; in the
   column it drops in like everything else. */
.toast{
  max-width:100%; padding:8px 14px;
  background:rgba(6,13,17,.62); border:1px solid var(--menu-line);
  border-left:2px solid var(--gold);
  font-size:calc(10.5px * var(--ts)); font-weight:400; letter-spacing:1.6px; color:var(--menu-text);
  text-align:center;
  opacity:0; transform:translateY(-7px);
  transition:opacity .3s, transform .35s cubic-bezier(.2,.9,.3,1);
}
.toast.in{ opacity:1; transform:none; }

/* ==========================================================================
   OVERLAYS
   ========================================================================== */
.overlay{
  position:absolute; inset:0; display:flex; align-items:center; justify-content:center;
  opacity:0; visibility:hidden; pointer-events:none;
  transition:opacity .45s ease, visibility .45s;
  background:radial-gradient(ellipse at 50% 45%, rgba(8,18,24,.35), rgba(6,14,18,.82) 75%);
  backdrop-filter:blur(3px) saturate(.9); -webkit-backdrop-filter:blur(3px);
}
.overlay.shown{ opacity:1; visibility:visible; pointer-events:auto; }

/* ==========================================================================
   LEAVING FOR A RUN
   ==========================================================================
   The canvas behind these is fading to black over 0.30s on its own clock, so
   the chrome has to be gone before it — not with it. Panels clear in 0.20s and
   the nav slides out slightly ahead of its own fade, which reads as the menu
   getting out of the way rather than dissolving.

   Interaction is killed on the first frame: the run is already committed, and
   a second press landing during the fade would be a second run. */
.overlay.leaving{
  opacity:0; pointer-events:none;
  transition:opacity .20s cubic-bezier(.5,0,1,1);
}
#menu.leaving .menu-nav{
  transform:translateX(-22px); opacity:0;
  transition:transform .26s cubic-bezier(.5,0,1,1), opacity .17s ease-in;
}
#menu.leaving .menu-brand, #menu.leaving .menu-corner, #menu.leaving .menu-stage{
  opacity:0; transition:opacity .15s ease-in;
}
/* The press. The gold rule that marks the button is the thing that answers —
   it thickens and floods across the row, then the whole panel leaves under it.
   One property, one accent, no new colour. */
.nav-play.fired{
  background:linear-gradient(96deg, rgba(231,184,81,.34), rgba(231,184,81,.08) 62%, transparent);
  border-left-width:5px; padding-left:30px;
  transition:background .14s ease-out, border-left-width .14s ease-out, padding-left .14s ease-out;
}
.nav-play.fired .nav-play-arrow{ opacity:1; transform:translateY(-50%) translateX(9px); }
/* No custom cursor over a transition: there is nothing to aim at yet. */
body.in-transition #cursor{ opacity:0; }

.panel{
  background:linear-gradient(160deg, rgba(24,42,52,.9), rgba(12,24,30,.94));
  border:1px solid var(--edge);
  border-radius:16px; box-shadow:var(--shadow-lg);
  backdrop-filter:blur(18px) saturate(1.15); -webkit-backdrop-filter:blur(18px);
}

/* ==========================================================================
   MAIN MENU
   ==========================================================================
   The island is still rendering behind all of this, so the chrome is
   deliberately thin: hairlines, wide tracking, a lot of negative space, and a
   stage panel translucent enough to keep the meadow visible through it.

   Gold is an ACCENT here, not a fill. It marks exactly two things — the
   selected row and the play arrow — and appears nowhere else, so it still
   means something when it does show up. Everything else is bleached stone.
   ========================================================================== */
:root{
  --menu-ink:    rgba(9, 17, 21, .70);
  --menu-ink-lo: rgba(9, 17, 21, .42);
  --menu-line:   rgba(244, 241, 230, .14);
  --menu-line-hi:rgba(244, 241, 230, .30);
  --menu-text:   rgba(244, 241, 230, .92);
  --menu-dim:    rgba(244, 241, 230, .52);
  --menu-faint:  rgba(244, 241, 230, .30);
}

#menu{ padding:0; align-items:stretch; justify-content:flex-start; }

/* Only enough contrast for the type. A heavier scrim would be throwing away
   the best asset the game has. */
.menu-scrim{
  position:absolute; inset:0; pointer-events:none;
  background:
    linear-gradient(100deg, rgba(6,13,17,.86) 0%, rgba(6,13,17,.62) 34%, rgba(6,13,17,.10) 62%, rgba(6,13,17,0) 80%),
    linear-gradient(0deg, rgba(6,13,17,.55) 0%, rgba(6,13,17,0) 34%);
}

.menu-grid{
  position:relative; z-index:1;
  display:grid; width:100%; height:100%;
  grid-template-columns:minmax(300px, calc(25 * var(--vw))) 1fr;
  grid-template-rows:auto 1fr auto;
  grid-template-areas:"brand stage" "nav stage" "corner stage";
  gap:0 clamp(28px, calc(5 * var(--vw)), 84px);
  padding:clamp(28px, calc(4.2 * var(--vh)), 56px) clamp(28px, calc(4 * var(--vw)), 72px);
}

/* --- brand ---------------------------------------------------------------- */
.menu-brand{ grid-area:brand; display:flex; align-items:center; gap:16px; pointer-events:none; }
.brand-mark{ width:46px; height:46px; flex:none; opacity:.95; }
.brand-mark .mark-body{ fill:none; stroke:var(--paper); stroke-width:2.4; opacity:.9; }
.brand-mark .mark-eye{ fill:var(--teal-lit); opacity:.95; }
.brand-mark .mark-legs path{ fill:none; stroke:var(--paper); stroke-width:2.4; stroke-linecap:round; stroke-linejoin:round; opacity:.5; }
.brand-text{ min-width:0; }
.brand-eyebrow{
  font-size:calc(9.5px * var(--ts)); letter-spacing:4.6px; text-transform:uppercase;
  color:var(--menu-faint); margin-bottom:5px;
}
.brand-title{
  margin:0; font-size:calc(clamp(21px, calc(2 * var(--vw)), 27px) * var(--ts)); font-weight:300;
  letter-spacing:7px; text-transform:uppercase; color:var(--menu-text);
  line-height:1;
}
.brand-title span{ display:block; font-weight:800; letter-spacing:6.4px; margin-top:3px; }

/* --- left column ---------------------------------------------------------- */
.menu-nav{
  grid-area:nav; align-self:center;
  display:flex; flex-direction:column; gap:2px;
  pointer-events:auto; padding-right:12px;
}

/* The one thing a player came here to press. It earns its weight from size and
   a single rule of gold, not from a filled slab — softened at the corners so
   the portal build reads "game", not "console". */
.nav-play{
  position:relative; display:flex; flex-direction:column; align-items:flex-start;
  gap:3px; padding:22px 26px 22px 22px; margin-bottom:22px;
  background:linear-gradient(96deg, rgba(231,184,81,.12), rgba(231,184,81,.02) 62%, transparent);
  border:0; border-left:2px solid var(--gold);
  border-radius:4px 16px 16px 4px;
  color:var(--menu-text); cursor:pointer; text-align:left;
  font-family:inherit;
  transition:background .28s ease, transform .28s cubic-bezier(.2,.9,.3,1), padding-left .28s ease;
}
.nav-play-key{ font-size:calc(clamp(30px, calc(3.4 * var(--vw)), 44px) * var(--ts)); font-weight:200; letter-spacing:9px; text-transform:uppercase; line-height:1; }
.nav-play-sub{ font-size:calc(10px * var(--ts)); letter-spacing:3.4px; text-transform:uppercase; color:var(--menu-dim); }
.nav-play-arrow{
  position:absolute; right:22px; top:50%; width:26px; height:26px;
  transform:translateY(-50%) translateX(-8px); opacity:0;
  fill:none; stroke:var(--gold-hot); stroke-width:1.6; stroke-linecap:round; stroke-linejoin:round;
  transition:opacity .28s ease, transform .28s cubic-bezier(.2,.9,.3,1);
}
.nav-play:hover, .nav-play:focus-visible{
  background:linear-gradient(96deg, rgba(231,184,81,.22), rgba(231,184,81,.04) 62%, transparent);
  padding-left:30px; outline:none;
}
.nav-play:hover .nav-play-arrow, .nav-play:focus-visible .nav-play-arrow{ opacity:1; transform:translateY(-50%) translateX(0); }
.nav-play:active{ transform:translateX(2px); }

.nav-sections{ display:flex; flex-direction:column; }
.nav-item{
  position:relative; display:grid; align-items:baseline;
  grid-template-columns:26px 1fr auto; gap:12px;
  padding:11px 14px 11px 8px; border:0; border-radius:3px 11px 11px 3px;
  background:none; cursor:pointer;
  font-family:inherit; font-size:calc(13.5px * var(--ts)); letter-spacing:3.4px; text-transform:uppercase;
  color:var(--menu-dim); text-align:left;
  transition:color .2s ease, padding-left .2s ease, background .2s ease;
}
.nav-item::before{
  content:""; position:absolute; left:0; top:50%; width:2px; height:0;
  background:var(--gold); transform:translateY(-50%);
  transition:height .24s cubic-bezier(.2,.9,.3,1);
}
.nav-item:hover{ color:var(--menu-text); padding-left:14px; background:rgba(244,241,230,.03); }
.nav-item.active{ color:var(--paper); padding-left:14px; background:rgba(244,241,230,.05); }
.nav-item.active::before{ height:66%; }
.nav-label{ overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.nav-idx{ font-size:calc(9.5px * min(var(--ts), 1.15)); letter-spacing:1.6px; color:var(--menu-faint); font-variant-numeric:tabular-nums; }
.nav-item.active .nav-idx{ color:var(--gold); }
.nav-note{ font-size:calc(9.5px * min(var(--ts), 1.15)); letter-spacing:1.4px; color:var(--menu-faint); text-transform:none; font-variant-numeric:tabular-nums; }

/* --- right stage ---------------------------------------------------------- */
.menu-stage{
  grid-area:stage; position:relative; align-self:stretch;
  margin:clamp(10px, calc(2 * var(--vh)), 26px) 0;
  display:flex; opacity:0; pointer-events:none;
  transform:translateX(14px);
  transition:opacity .3s ease, transform .34s cubic-bezier(.2,.9,.3,1);
}
#menu.panel-open .menu-stage{ opacity:1; pointer-events:auto; transform:translateX(0); }

.menu-panel{
  position:absolute; inset:0; display:none; flex-direction:column;
  background:var(--menu-ink);
  backdrop-filter:blur(16px) saturate(1.05); -webkit-backdrop-filter:blur(16px) saturate(1.05);
  border:1px solid var(--menu-line); border-radius:18px;
  box-shadow:0 30px 80px rgba(3,10,14,.5);
  overflow:hidden;
}
.menu-panel.shown{ display:flex; animation:panelIn .34s cubic-bezier(.2,.9,.3,1); }
@keyframes panelIn{ from{ opacity:0; transform:translateY(8px); } to{ opacity:1; transform:none; } }

.panel-head{ padding:26px 30px 18px; border-bottom:1px solid var(--menu-line); flex:none; }
.panel-head h2{
  margin:0 0 8px; font-size:calc(30px * var(--ts)); font-weight:800; letter-spacing:5px;
  text-transform:uppercase; line-height:1.05;
  background:linear-gradient(115deg,
    var(--paper) 0%, var(--paper) 32%, var(--gold) 50%, var(--gold-hot) 58%, var(--paper) 80%, var(--paper) 100%);
  background-size:220% 100%;
  -webkit-background-clip:text; background-clip:text;
  -webkit-text-fill-color:transparent; color:transparent;
  filter:drop-shadow(0 2px 16px rgba(255,194,77,.3));
  animation:panelTitleShine 7s ease-in-out infinite;
}
@keyframes panelTitleShine{ 0%{ background-position:180% 0; } 100%{ background-position:-60% 0; } }
@supports not ((-webkit-background-clip:text) or (background-clip:text)){
  .panel-head h2{ color:var(--paper); -webkit-text-fill-color:var(--paper); }
}
@media (prefers-reduced-motion: reduce){
  .panel-head h2{ animation:none; background-position:0 0; }
}
.panel-sub{ margin:0; font-size:calc(12px * var(--ts)); line-height:1.6; color:var(--menu-dim); max-width:62ch; }
.panel-body{ flex:1; overflow:auto; padding:24px 30px 30px; }

.menu-close{
  position:absolute; top:14px; right:14px; z-index:3;
  width:32px; height:32px; padding:0; border:1px solid var(--menu-line); border-radius:50%;
  background:rgba(9,17,21,.5); cursor:pointer; opacity:0; pointer-events:none;
  transition:opacity .3s ease, border-color .2s ease, background .2s ease;
}
#menu.panel-open .menu-close{ opacity:1; pointer-events:auto; }
.menu-close svg{ width:14px; height:14px; fill:none; stroke:var(--menu-dim); stroke-width:1.6; stroke-linecap:round; }
.menu-close:hover{ border-color:var(--menu-line-hi); background:rgba(9,17,21,.75); }
.menu-close:hover svg{ stroke:var(--paper); }

/* SCROLLBARS THAT SAY THERE IS MORE BELOW.
   Every scrolling surface in the chrome shares this. They used to be a barely
   visible hairline on a transparent track — invisible against these panels,
   which is why the portal reviewer asked for one at all: with no bar, a panel
   that scrolls looks like a panel that ends. The track is now drawn, the
   thumb has real contrast, and Firefox (which ignores ::-webkit-scrollbar
   entirely and so had NO bar at all) is served by `scrollbar-color`. */
.panel-body, .bst-list, .bst-text, .modal, .menu-grid{
  /* `auto`, not `thin`: on a machine set to overlay scrollbars, `thin` draws
     a bar that only appears while the wheel is turning — which is the same as
     no bar for someone deciding whether the list continues. A reserved gutter
     is a visible one. */
  scrollbar-width:auto;
  scrollbar-color:rgba(244,241,230,.34) rgba(244,241,230,.07);
  scrollbar-gutter:stable;
}
.panel-body::-webkit-scrollbar, .bst-list::-webkit-scrollbar,
.bst-text::-webkit-scrollbar, .modal::-webkit-scrollbar,
.menu-grid::-webkit-scrollbar{ width:10px; }
.panel-body::-webkit-scrollbar-track, .bst-list::-webkit-scrollbar-track,
.bst-text::-webkit-scrollbar-track, .modal::-webkit-scrollbar-track,
.menu-grid::-webkit-scrollbar-track{ background:rgba(244,241,230,.07); border-radius:5px; }
.panel-body::-webkit-scrollbar-thumb, .bst-list::-webkit-scrollbar-thumb,
.bst-text::-webkit-scrollbar-thumb, .modal::-webkit-scrollbar-thumb,
.menu-grid::-webkit-scrollbar-thumb{
  background:rgba(244,241,230,.34); border-radius:5px;
  border:2px solid transparent; background-clip:padding-box;
}
.panel-body::-webkit-scrollbar-thumb:hover, .bst-list::-webkit-scrollbar-thumb:hover,
.bst-text::-webkit-scrollbar-thumb:hover, .modal::-webkit-scrollbar-thumb:hover,
.menu-grid::-webkit-scrollbar-thumb:hover{ background:rgba(244,241,230,.55); background-clip:padding-box; }

/* --- corner --------------------------------------------------------------- */
.menu-corner{
  grid-area:corner; display:flex; align-items:center; justify-content:space-between;
  gap:16px; pointer-events:auto; padding-top:14px;
}
.build{ font-size:calc(9.5px * var(--ts)); letter-spacing:2.2px; color:var(--menu-faint); text-transform:uppercase; }
/* .patreon rules removed with the placeholder link they styled (index.html). */

/* Bottom-right, as asked — anchored to the viewport so it stays out of the way
   of the stage panel rather than fighting it for space. */
@media (min-width:700px){
  .menu-corner{
    position:absolute; right:clamp(28px, calc(4 * var(--vw)), 72px); bottom:clamp(22px, calc(3 * var(--vh)), 40px);
    left:auto; width:auto; justify-content:flex-end; gap:22px; padding:0;
  }
  .menu-grid{ grid-template-areas:"brand stage" "nav stage" "nav stage"; }
  /* AND IT YIELDS TO AN OPEN PANEL AT EVERY SIZE.
     Taken out of the grid, the corner is placed against the viewport while
     the stage is placed against the padding box, so whether they touch is
     decided by two independent `clamp`s on the viewport height — they clear
     each other at 1080 and collide by a few pixels around 600, which is the
     signature of a collision nobody authored. Two tiers used to hide it and
     the band between them was the gap. There is no size at which a username
     printed over an open shop is wanted, so the rule is simply the rule. */
  #menu.panel-open .menu-corner{ opacity:0; pointer-events:none; transition:opacity .2s; }
}

/* ==========================================================================
   SHOP
   The one panel allowed to look like a storefront: rounded cards, a wallet
   that reads at a glance, and exactly one filled control per row — the buy
   button — so the eye lands on the thing that costs cores. Everything else
   keeps the menu's hairline restraint.
   ========================================================================== */
.panel-body.shop section{ margin-bottom:26px; }
.panel-body.shop h4{
  display:flex; align-items:baseline; justify-content:space-between; gap:12px;
  margin:0 0 12px; padding-bottom:7px; border-bottom:1px solid var(--menu-line);
  font-size:calc(9.5px * var(--ts)); font-weight:500; letter-spacing:3.6px; text-transform:uppercase; color:var(--gold);
}
.panel-body.shop h4 em{
  font-style:normal; font-size:calc(8.5px * var(--ts)); letter-spacing:1.6px;
  text-transform:none; color:var(--menu-faint);
}

/* --- the wallet strip ----------------------------------------------------- */
/* In the panel HEAD, on the title's line (Menu._buildShop moves it there): the
   head never scrolls, so the balance stays in view down the whole shelf. The
   head clears the close button on its right, and when the panel is too narrow
   for both the strip wraps under the title — still inside the head. */
.panel-head.shop-headed{
  display:flex; align-items:center; flex-wrap:wrap; gap:10px 22px;
  padding-right:62px;
}
.panel-head.shop-headed h2{ margin:0; flex:none; }
.shop-head{
  flex:1 1 300px; min-width:0;
  display:flex; align-items:center; gap:6px 16px; flex-wrap:wrap;
  padding:9px 15px;
  border:1px solid var(--menu-line); border-radius:12px;
  background:linear-gradient(180deg, rgba(255,194,77,.09), rgba(9,17,21,.44));
}
.shop-head .shop-note{ flex:1 1 180px; min-width:0; line-height:1.45; }
.shop-wallet{ display:flex; align-items:baseline; gap:9px; flex:none; }
.core-ico{
  width:21px; height:21px; align-self:center;
  fill:none; stroke:var(--gold); stroke-width:1.4; stroke-linejoin:round; stroke-linecap:round;
}
.shop-wallet strong{ font-size:calc(23px * var(--ts)); font-weight:600; color:var(--paper); font-variant-numeric:tabular-nums; }
.shop-wallet span{ font-size:calc(9px * var(--ts)); letter-spacing:2.8px; text-transform:uppercase; color:var(--menu-faint); }
.shop-note{ font-size:calc(10.5px * var(--ts)); color:var(--menu-faint); font-style:italic; }

/* --- a multi-column grid of compact cards, not a scrolling list -----------
   The whole catalogue (passives + every common and rare ability) fits the
   panel without a scrollbar because the shelf wraps into columns. Each card
   carries its own buy/equip action full-width at the foot, so the click
   target never shifts between cards. */
.shop-sub{
  margin:16px 0 9px; padding-bottom:5px;
  display:flex; align-items:center; gap:8px;
  font-size:calc(8.5px * var(--ts)); font-weight:600; letter-spacing:3px; text-transform:uppercase;
  color:var(--menu-faint); border-bottom:1px solid var(--menu-line);
}
.shop-sub::before{ content:""; width:8px; height:8px; border-radius:2px; background:currentColor; }
.shop-sub.common{ color:#9aa6ad; }
.shop-sub.rare{ color:#5aa6ea; }
.shop-grid{ display:grid; grid-template-columns:repeat(auto-fill, minmax(236px, 1fr)); gap:10px; }
.shop-item{
  display:grid; grid-template-columns:32px 1fr; align-content:start;
  gap:7px 12px;
  padding:13px 14px;
  border:1px solid var(--menu-line); border-radius:13px;
  background:rgba(9,17,21,.42);
  transition:border-color .18s ease, background .18s ease;
}
.shop-item:hover{ border-color:var(--menu-line-hi); background:rgba(9,17,21,.6); }
.shop-item.equipped{ border-color:var(--edge-hot); background:rgba(255,194,77,.07); }
.shop-ico{ width:32px; height:32px; align-self:start; }
.shop-name{ align-self:center; font-size:calc(11.5px * var(--ts)); letter-spacing:1.7px; text-transform:uppercase; color:var(--menu-text); }
.shop-name em{
  display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden;
  margin-top:4px; font-style:normal;
  font-size:calc(10.5px * var(--ts)); letter-spacing:.2px; text-transform:none; line-height:1.4; color:var(--menu-dim);
}
.shop-pips{ grid-column:1 / -1; display:flex; gap:5px; margin-top:2px; }
.shop-pips i{ width:7px; height:7px; border-radius:50%; border:1px solid var(--menu-line-hi); }
.shop-pips i.on{ background:var(--gold); border-color:var(--gold); box-shadow:0 0 7px rgba(255,194,77,.45); }

.btn.shop-buy{
  grid-column:1 / -1; width:100%; margin-top:2px;
  padding:9px 16px; border-radius:999px;
  font-size:calc(10.5px * var(--ts)); letter-spacing:1.8px;
  color:#0c1317; background:var(--gold); border:1px solid var(--gold);
}
.btn.shop-buy:hover{ background:var(--gold-hot); border-color:var(--gold-hot); color:#0c1317; }
/* Too expensive: still clickable, because the refusal sound teaches the price
   faster than a dead control does. */
.btn.shop-buy.poor,
.btn.shop-buy.poor:hover{
  background:transparent; color:var(--menu-faint); border-color:var(--menu-line);
}
.shop-max{
  grid-column:1 / -1; margin-top:4px; text-align:center;
  font-size:calc(9.5px * var(--ts)); letter-spacing:2.6px; color:var(--gold);
}

/* --- the ad offer, BESIDE the price and never instead of it ----------------
   CrazyGames requires the non-ad option to get equal treatment — same size,
   font and colour — so the price keeps the filled pill and the ad is a quieter
   outline button of the same height next to it. It is an alternative, not the
   headline, and it is the smaller of the two. */
.shop-actions{ grid-column:1 / -1; margin-top:2px; display:flex; align-items:center; gap:9px; }
.shop-actions .btn.shop-buy{ margin-top:0; flex:1; }
/* Equip is a quieter outline beside the gold rank-upgrade price; Basic is the
   label Rune Bolt shows where an Equip button would be (it is always deployed). */
.btn.shop-equip{
  flex:1; margin:0; padding:9px 12px; border-radius:999px;
  font-size:calc(10px * var(--ts)); letter-spacing:1.4px;
  color:var(--menu-text); background:transparent; border:1px solid var(--menu-line-hi);
}
.btn.shop-equip:hover{ border-color:var(--gold); color:var(--gold); }
.shop-item.equipped .btn.shop-equip{ border-color:var(--edge-hot); color:var(--gold); }
.shop-basic{
  flex:1; text-align:center; padding:9px 0;
  font-size:calc(9px * var(--ts)); letter-spacing:2px; color:var(--menu-faint);
}
.shop-actions .shop-max{ flex:1; margin-top:0; }
.btn.shop-ad{
  min-width:0; padding:9px 13px; border-radius:999px;
  display:inline-flex; align-items:center;
  background:transparent; color:var(--gold); border:1px solid var(--menu-line-hi);
}
.btn.shop-ad:hover{
  color:var(--gold); border-color:var(--gold); background:rgba(255,194,77,.12);
}
.btn.shop-ad[disabled]{ opacity:.38; pointer-events:none; }
/* currentColor throughout, so hover and the disabled state carry the glyph
   with them instead of needing a rule each. */
.ad-ico{ width:18px; height:18px; display:block; }
.ad-ico rect{ fill:none; stroke:currentColor; stroke-width:1.6; }
.ad-ico path{ fill:currentColor; stroke:none; }

/* On loan: the same footprint as the button it replaces, so the row does not
   reflow when an ad pays out. */
.shop-loan{
  flex:1; text-align:center; padding:9px 0;
  font-size:calc(9px * var(--ts)); letter-spacing:2.2px; color:var(--edge-hot);
}
.shop-item.onloan{ border-color:var(--edge-hot); background:rgba(255,194,77,.05); }
.shop-loan-note{
  margin:0 0 10px; font-size:calc(10.5px * var(--ts)); font-style:italic; color:var(--gold);
}
.shop-loan-note:empty{ display:none; }

@media (max-width: 760px){
  .shop-grid{ grid-template-columns:1fr; }
}

/* ==========================================================================
   BESTIARY
   A rail of machines, a turntable, and a file. The rail owns its own scroll
   and the file owns another, so the preview never scrolls off the top while
   you read about the thing it is showing — the old version put the viewer
   inside the scrolling column and at the sizes the portal tests for
   readability there was nothing left of either.
   ========================================================================== */
.panel-body.bestiary{
  display:grid; grid-template-columns:minmax(186px, 226px) 1fr;
  gap:24px; padding-right:24px; min-height:0;
}
/* THE BESTIARY GETS ITS SCROLLBARS BACK.
   They were hidden here on purpose — the rail and the file still scrolled by
   wheel and drag, and the panel looked cleaner without them. It was the wrong
   call and the portal reviewer caught it: a panel that scrolls with no bar
   looks like a panel that ENDS, so the machines below the fold may as well not
   exist. Only the horizontal bar stays hidden, because nothing here scrolls
   sideways and a phantom one at the foot of the rail is just noise. */
.panel-body.bestiary,
.panel-body.bestiary *{ -ms-overflow-style:auto; }
.panel-body.bestiary *::-webkit-scrollbar:horizontal{ height:0; display:none; }

/* --- the rail ------------------------------------------------------------- */
.bst-rail{
  display:flex; flex-direction:column; gap:12px; min-height:0;
  border-right:1px solid var(--menu-line); padding-right:12px;
}
.bst-progress{
  font-size:calc(9px * var(--ts)); letter-spacing:2.4px; text-transform:uppercase;
  color:var(--menu-faint); flex:none;
}
.bst-progress span{ color:var(--gold); font-variant-numeric:tabular-nums; }
.bst-bar{
  margin-top:7px; height:2px; background:rgba(244,241,230,.10); border-radius:2px;
  overflow:hidden;
}
.bst-bar i{
  display:block; height:100%; width:0;
  background:linear-gradient(90deg, var(--gold), var(--gold-hot));
  transition:width .5s cubic-bezier(.2,.9,.3,1);
}
.bst-list{ overflow:auto; flex:1; margin:0 -6px; padding:0 6px; outline:none; }
.bst-list:focus-visible{ box-shadow:inset 0 0 0 1px var(--menu-line-hi); border-radius:8px; }
.bst-head{
  display:flex; align-items:baseline; justify-content:space-between; gap:10px;
  margin:14px 0 6px; padding-bottom:6px;
  border-bottom:1px solid var(--menu-line);
  font-size:calc(9px * var(--ts)); font-weight:400; letter-spacing:3.2px; text-transform:uppercase;
  color:var(--gold);
}
.bst-head:first-child{ margin-top:0; }
.bst-head em{ font-style:normal; font-size:calc(8.5px * var(--ts)); letter-spacing:1.4px; color:var(--menu-faint); }
.bst-item{
  display:grid; grid-template-columns:26px 1fr; grid-template-rows:auto auto;
  gap:0 10px; padding:8px 10px; cursor:pointer;
  border-left:2px solid transparent; border-radius:0 8px 8px 0;
  transition:background .18s ease, border-color .18s ease;
}
.bst-item:hover{ background:rgba(244,241,230,.04); }
.bst-item.active{ background:rgba(244,241,230,.07); border-left-color:var(--gold); }
.bst-num{
  grid-row:1 / span 2; align-self:center;
  font-size:calc(10px * var(--ts)); letter-spacing:1px; color:var(--menu-faint);
  font-variant-numeric:tabular-nums;
}
.bst-name{ font-size:calc(12.5px * var(--ts)); letter-spacing:2.2px; text-transform:uppercase; color:var(--menu-text); }
.bst-role{ font-size:calc(9.5px * var(--ts)); letter-spacing:1.1px; color:var(--menu-faint); }
.bst-item.active .bst-num{ color:var(--gold); }
.bst-item.locked .bst-name{ color:var(--menu-faint); font-style:italic; letter-spacing:1.4px; }

/* --- the detail column ---------------------------------------------------- */
/* THE FILE HAS A FLOOR AND THE TURNTABLE DOES NOT.
   These rows were `minmax(190px, 38%) 1fr`, which reads as "the viewer gets at
   least 190px" — and a minimum beats a maximum, so on a short panel the viewer
   took its 190px off the top and the file was left with whatever remained.
   Measured at 800x450 that was SEVEN PIXELS holding 960px of text: a scrollbar
   with nothing beside it. The priority is the other way round. The viewer is a
   proportion with no floor at all, the file carries the minimum, and the one
   that yields when the panel is short is the picture rather than the words. */
.bst-detail{ display:grid; grid-template-rows:minmax(0, 38%) minmax(150px, 1fr); gap:18px; min-height:0; }
.bst-stage{
  position:relative; border:1px solid var(--menu-line); border-radius:14px;
  background:
    radial-gradient(120% 90% at 50% 12%, rgba(143,201,232,.10), transparent 66%),
    rgba(6,13,17,.34);
  overflow:hidden;
}
#bst-canvas{ width:100%; height:100%; display:block; cursor:grab; }
#bst-canvas.dragging{ cursor:grabbing; }
.bst-stage.unavailable::after{
  content:"3D preview unavailable"; position:absolute; inset:0;
  display:flex; align-items:center; justify-content:center;
  font-size:calc(11px * var(--ts)); letter-spacing:2px; color:var(--menu-faint);
}
.bst-stage-hint{
  position:absolute; left:14px; bottom:12px; pointer-events:none;
  font-size:calc(9px * var(--ts)); letter-spacing:2.2px; text-transform:uppercase; color:var(--menu-faint);
}
.bst-ghost{
  position:absolute; right:12px; bottom:11px;
  padding:7px 14px; border:1px solid var(--menu-line); border-radius:999px;
  background:rgba(9,17,21,.62); color:var(--menu-dim); cursor:pointer;
  font-family:inherit; font-size:calc(9px * var(--ts)); letter-spacing:2.2px; text-transform:uppercase;
  transition:color .2s ease, border-color .2s ease;
}
.bst-ghost:hover:not(:disabled){ color:var(--paper); border-color:var(--menu-line-hi); }
.bst-ghost.on{ color:var(--gold-hot); border-color:var(--edge-hot); }
.bst-ghost:disabled{ opacity:.3; cursor:default; }
/* A 2×2 BLOCK IN THE CORNER, NOT A ROW ACROSS THE TOP. The viewer is wide and
   short at every size the portal tests (314×114 at 1077×606), so height is
   the one thing it cannot spare — and a chip row across the top spent a third
   of it, with the anchor's weapon standing underneath the chips. The block
   spends width instead, which the viewer has plenty of, and BestiaryViewer.
   _frame fits the machine into the space to the right of it. */
.bst-variants{
  position:absolute; left:12px; top:11px; z-index:1;
  display:none; grid-template-columns:repeat(2, auto); gap:4px;
}
.bst-variants.shown{ display:grid; }
.bst-var{
  padding:5px 10px; border:1px solid var(--menu-line); border-radius:999px;
  background:rgba(9,17,21,.62); color:var(--menu-faint); cursor:pointer;
  font-family:inherit; font-size:calc(8.5px * var(--ts)); letter-spacing:1.8px; text-transform:uppercase;
  transition:color .18s ease, border-color .18s ease;
}
.bst-var:hover{ color:var(--menu-text); border-color:var(--menu-line-hi); }
.bst-var.on{ color:var(--gold-hot); border-color:var(--edge-hot); }

.bst-text{ overflow:auto; padding-right:8px; min-height:0; }
.bst-class{ font-size:calc(9.5px * var(--ts)); letter-spacing:4px; color:var(--gold); text-transform:uppercase; }
.bst-title{
  margin:6px 0 12px; font-size:calc(24px * var(--ts)); font-weight:300; letter-spacing:5px;
  text-transform:uppercase; color:var(--paper);
}
.bst-lore{ margin:0 0 14px; font-size:calc(13px * var(--ts)); line-height:1.75; color:rgba(244,241,230,.78); max-width:66ch; }
.bst-read{
  margin:0 0 18px; padding:11px 14px;
  border-left:2px solid var(--gold); border-radius:0 8px 8px 0;
  background:rgba(231,184,81,.06);
  font-size:calc(12.5px * var(--ts)); line-height:1.6; color:var(--menu-text);
}
.bst-read span{
  display:block; font-size:calc(8.5px * var(--ts)); letter-spacing:3px; text-transform:uppercase;
  color:var(--gold); margin-bottom:4px;
}
.bst-note{ margin:0; font-size:calc(12px * var(--ts)); line-height:1.6; color:var(--menu-dim); }

/* --- the stat strip -------------------------------------------------------- */
.bst-stats{
  display:grid; grid-template-columns:repeat(auto-fit, minmax(92px, 1fr));
  gap:1px; margin:0 0 4px; background:var(--menu-line);
  border:1px solid var(--menu-line); border-radius:10px; overflow:hidden;
}
.bst-stat{ background:rgba(9,17,21,.5); padding:10px 12px; }
.bst-stat dt{
  font-size:calc(8.5px * var(--ts)); letter-spacing:2.2px; text-transform:uppercase;
  color:var(--menu-faint); margin-bottom:4px;
}
.bst-stat dd{
  margin:0; font-size:calc(15px * var(--ts)); font-weight:600; color:var(--menu-text);
  font-variant-numeric:tabular-nums;
}

/* --- the blocks ------------------------------------------------------------ */
.bst-block{ margin-top:22px; }
.bst-block h4{
  display:flex; align-items:baseline; justify-content:space-between; gap:12px;
  margin:0 0 10px; padding-bottom:7px; border-bottom:1px solid var(--menu-line);
  font-size:calc(10px * var(--ts)); font-weight:500; letter-spacing:3.4px; text-transform:uppercase; color:var(--gold);
}
.bst-block h4 em{
  font-style:normal; font-size:calc(8.5px * var(--ts)); letter-spacing:1.5px;
  color:var(--menu-faint); text-transform:none;
}
.bst-block ol, .bst-block ul{ list-style:none; margin:0; padding:0; }

/* marks and boss tiers share one row shape */
.bst-marks .bst-mark, .bst-marks .bst-tier{
  display:grid; grid-template-columns:26px minmax(0,1fr) auto; gap:2px 12px;
  padding:9px 0; border-bottom:1px solid rgba(244,241,230,.06);
}
.bst-mark.out{ opacity:.42; }
/* EVERY CELL IS NAMED. `.bst-mk-at` used to declare a row and let the grid
   pick its column, and auto-placement put it straight on top of `.bst-mk-num`
   — the overlapping text the portal reviewer photographed. Nothing here is
   auto-placed any more, so the three cells cannot collide at any width. */
.bst-mk{
  grid-column:1; grid-row:1 / span 2; align-self:center; text-align:center;
  font-size:calc(13px * var(--ts)); letter-spacing:1px; color:var(--gold); font-variant-numeric:tabular-nums;
}
.bst-mk-num{
  grid-column:2; grid-row:1; align-self:baseline;
  font-size:calc(10px * var(--ts)); letter-spacing:.6px; color:var(--menu-faint);
}
.bst-mk-num em{ font-style:normal; color:var(--menu-dim); font-variant-numeric:tabular-nums; }
.bst-mk-at{
  grid-column:3; grid-row:1; align-self:baseline;
  font-size:calc(9px * var(--ts)); letter-spacing:1.6px; text-transform:uppercase;
  color:var(--menu-faint); white-space:nowrap;
}
.bst-mk-trait{ grid-column:2 / span 2; grid-row:2; font-size:calc(12px * var(--ts)); line-height:1.55; color:rgba(244,241,230,.78); }
.bst-mk-trait strong{
  display:block; font-size:calc(9.5px * var(--ts)); font-weight:600; letter-spacing:2.2px;
  text-transform:uppercase; color:var(--menu-text); margin-bottom:2px;
}
.bst-mk-trait i{ color:var(--menu-faint); font-style:italic; }
.bst-tiers .bst-mk-trait strong{ display:inline; letter-spacing:.6px; text-transform:none; font-size:calc(12px * var(--ts)); }
/* A tier row has no "at" cell, so its two remaining cells stack in column 2. */
.bst-tier .bst-mk-num{ grid-column:2 / span 2; }

/* repertoire */
.bst-moves .bst-move{
  display:grid; grid-template-columns:minmax(118px, 164px) minmax(0,1fr); gap:3px 14px;
  padding:10px 0; border-bottom:1px solid rgba(244,241,230,.06);
}
.bst-mv-name{
  grid-row:1 / span 2; align-self:start;
  font-size:calc(12px * var(--ts)); letter-spacing:2.4px; text-transform:uppercase; color:var(--menu-text);
}
.bst-mv-name em{
  display:block; margin-top:3px; font-style:normal;
  font-size:calc(8.5px * var(--ts)); letter-spacing:1.6px; color:var(--gold); text-transform:uppercase;
}
.bst-mv-tell, .bst-mv-counter{ font-size:calc(12px * var(--ts)); line-height:1.55; color:rgba(244,241,230,.72); }
.bst-mv-counter{ color:var(--menu-dim); }
.bst-mv-tell em, .bst-mv-counter em{
  display:inline-block; min-width:52px; font-style:normal;
  font-size:calc(8.5px * var(--ts)); letter-spacing:2.4px; text-transform:uppercase; color:var(--menu-faint);
}
.bst-mv-counter em{ color:var(--gold); }

/* phases */
.bst-phases .bst-phase{
  display:grid; grid-template-columns:26px minmax(0,1fr); gap:3px 12px;
  padding:11px 0; border-bottom:1px solid rgba(244,241,230,.06);
}
.bst-ph-n{
  grid-row:1 / span 2; align-self:start; text-align:center;
  font-size:calc(15px * var(--ts)); font-weight:300; color:var(--gold); font-variant-numeric:tabular-nums;
}
.bst-ph-name{ font-size:calc(12px * var(--ts)); letter-spacing:2.6px; text-transform:uppercase; color:var(--menu-text); }
.bst-ph-name em{
  display:block; font-style:normal; font-size:calc(9px * var(--ts)); letter-spacing:1.8px;
  color:var(--menu-faint); text-transform:none; margin-top:2px;
}
.bst-ph-what{ font-size:calc(12px * var(--ts)); line-height:1.6; color:rgba(244,241,230,.74); }

/* armament and reinforcement share the swatch-row shape */
.bst-arms .bst-arm, .bst-affixes .bst-affix{
  display:grid; grid-template-columns:10px minmax(104px, 146px) minmax(0,1fr); gap:3px 12px;
  padding:10px 0; border-bottom:1px solid rgba(244,241,230,.06);
  /* A 104px name column plus a long unbreakable word could push these rows
     past the file's edge in the narrow two-column layout. Nothing in this
     panel may set its own width from its content. */
  overflow-wrap:anywhere;
}
.bst-arm i, .bst-affix i{ grid-row:1 / span 2; width:4px; align-self:stretch; border-radius:2px; }
.bst-affix i{ grid-row:1; }
.bst-arm-name, .bst-af-name{
  grid-row:1 / span 2; align-self:start;
  font-size:calc(11.5px * var(--ts)); letter-spacing:2.2px; text-transform:uppercase; color:var(--menu-text);
}
.bst-af-name{ grid-row:1; align-self:center; }
.bst-arm-name em{
  display:block; font-style:normal; font-size:calc(9px * var(--ts)); letter-spacing:1.4px;
  color:var(--menu-faint); text-transform:none; margin-top:2px;
}
.bst-arm-what{ font-size:calc(12px * var(--ts)); line-height:1.55; color:rgba(244,241,230,.74); }
.bst-arm-answer{ font-size:calc(11.5px * var(--ts)); line-height:1.5; color:var(--menu-dim); }
.bst-af-what{ font-size:calc(11.5px * var(--ts)); line-height:1.5; color:var(--menu-dim); font-variant-numeric:tabular-nums; }

/* --- short and narrow ------------------------------------------------------
   The two sizes the portal tests for readability are 907x510 and 800x450, and
   both are SHORT rather than narrow. Give the turntable less room before the
   file loses any. */
@media (max-height: 620px){
  .bst-detail{ grid-template-rows:minmax(0, 30%) minmax(130px, 1fr); gap:12px; }
  .bst-title{ font-size:calc(19px * var(--ts)); margin-bottom:8px; }
  .bst-lore{ margin-bottom:10px; }
}
/* THE FILE NEEDS ROOM, AND 907x510 IS ONE OF THE SIZES THEY TEST.
   The rail and the file sat side by side down to 899px, which left the file
   about 210px wide at the portal's 907x510 — narrow enough that the armament
   and reinforcement rows ran past its edge. Above a thousand pixels there is
   room for both; below it, the file takes the whole panel and the rail
   becomes a short scrolling strip above it. */
@media (max-width: 1000px){
  .panel-body.bestiary{ grid-template-columns:1fr; gap:14px; }
  .bst-rail{
    border-right:0; border-bottom:1px solid var(--menu-line);
    padding-right:0; padding-bottom:10px; max-height:clamp(120px, calc(26 * var(--vh)), 184px);
  }
  /* Stacked, the rail is already above the viewer, so the viewer no longer has
     to hold a column open beside it — it takes a smaller share and the file
     keeps the rest. */
  .bst-detail{ grid-template-rows:minmax(0, 32%) minmax(170px, 1fr); }
}

/* ---- one column AND a short screen: the panel becomes one document --------
   Stacked, the rail, the turntable and the file are three scrollers competing
   for a panel a few hundred pixels tall, and there is no division of it that
   leaves all three usable — a proportion that keeps the viewer readable starves
   the file, and one that keeps the file readable shrinks the viewer to a
   thumbnail. So they stop competing. The rail is a strip, the turntable keeps a
   height you can actually turn a machine in, the file gives up its own scroll
   and lays out at its full length, and the PANEL scrolls through all three: one
   bar, everything reachable, in the order it is written. It is the same
   bestiary a large screen shows, read as a page instead of as three panes. */
@media (max-width: 1000px) and (max-height: 620px){
  /* The panel stops being a grid as well, for the same reason: a grid divides
     a height, and here nothing is dividing one. */
  .panel-body.bestiary{ display:flex; flex-direction:column; gap:14px; }
  .bst-rail{ flex:none; }
  /* A COLUMN, NOT A TWO-ROW GRID. The grid's job was to divide a fixed height
     between the viewer and the file; here there is no fixed height to divide,
     so the tracks only get in the way — sized against a container that is
     itself sized by them, they resolve to a box far shorter than the text
     inside it, and the file renders only because the overflow happens to be
     visible. A flex column asks the honest question instead: the viewer is
     told its height, the file takes the height its words need, and the panel
     carries the total. */
  .bst-detail{ display:flex; flex-direction:column; gap:12px; flex:none; }
  .bst-stage{ height:clamp(148px, calc(30 * var(--vh)), 200px); flex:none; }
  .bst-text{ overflow:visible; min-height:0; padding-right:0; flex:none; }
}

/* ==========================================================================
   RECORD
   ========================================================================== */
.rec-heroes{ display:grid; grid-template-columns:repeat(auto-fit, minmax(140px, 1fr)); gap:1px; background:var(--menu-line); border:1px solid var(--menu-line); margin-bottom:26px; }
.rec-big{ background:rgba(9,17,21,.5); padding:18px 18px 15px; }
.rec-big strong{ display:block; font-size:calc(27px * var(--ts)); font-weight:300; letter-spacing:1px; color:var(--paper); font-variant-numeric:tabular-nums; }
.rec-big span{ display:block; margin-top:5px; font-size:calc(9px * var(--ts)); letter-spacing:2.6px; text-transform:uppercase; color:var(--menu-faint); }
.rec-cols{ display:grid; grid-template-columns:repeat(auto-fit, minmax(240px, 1fr)); gap:26px 34px; }
.panel-body.record h4, .panel-body.controls h4, .set-group h4{
  margin:0 0 12px; font-size:calc(9.5px * var(--ts)); letter-spacing:3.6px; text-transform:uppercase; color:var(--gold);
}
/* A heading may carry a count on its right; it never competes with the label. */
.panel-body.record h4:has(em){ display:flex; align-items:baseline; justify-content:space-between; gap:12px; }
.panel-body.record h4 em{
  font-style:normal; font-size:calc(8.5px * var(--ts)); letter-spacing:1.6px;
  text-transform:none; color:var(--menu-faint);
}
.panel-body.record dl{ margin:0; }
.rec-row{ display:flex; justify-content:space-between; align-items:baseline; gap:16px; padding:7px 0; border-bottom:1px solid rgba(244,241,230,.07); }
.rec-row dt{ font-size:calc(12px * var(--ts)); color:var(--menu-dim); }
.rec-row dd{ margin:0; font-size:calc(12.5px * var(--ts)); color:var(--menu-text); font-variant-numeric:tabular-nums; text-align:right; }
.rec-breakdown{ margin-top:26px; }
.rec-bar{ display:grid; grid-template-columns:120px 1fr 56px; align-items:center; gap:12px; padding:5px 0; }
.rec-bar-l{ font-size:calc(11px * var(--ts)); letter-spacing:1.6px; text-transform:uppercase; color:var(--menu-dim); }
.rec-bar-t{ height:5px; background:rgba(244,241,230,.07); overflow:hidden; }
.rec-bar-t i{ display:block; height:100%; background:linear-gradient(90deg, rgba(143,201,232,.5), var(--teal-lit)); }
.rec-bar-v{ font-size:calc(11.5px * var(--ts)); text-align:right; color:var(--menu-text); font-variant-numeric:tabular-nums; }
.rec-bar.empty .rec-bar-l, .rec-bar.empty .rec-bar-v{ color:var(--menu-faint); }
.rec-bar.sealed .rec-bar-l{ color:var(--menu-faint); font-style:italic; letter-spacing:2.4px; }
.rec-bar-head{
  margin:16px 0 4px; padding-bottom:5px; border-bottom:1px solid rgba(244,241,230,.07);
  font-size:calc(9px * var(--ts)); font-weight:400; letter-spacing:3.2px; text-transform:uppercase; color:var(--menu-faint);
}
/* The section head already carries the gap; the first group sits right under it. */
.rec-breakdown h4 + .rec-bar-head{ margin-top:2px; }
.rec-foot{ display:flex; align-items:center; justify-content:space-between; gap:16px; margin-top:28px; padding-top:16px; border-top:1px solid var(--menu-line); }
.rec-foot span{ font-size:calc(10.5px * var(--ts)); letter-spacing:1.4px; color:var(--menu-faint); }
.btn.danger{ border-color:rgba(232,87,75,.34); color:#F0A99E; }
.btn.danger:hover{ border-color:rgba(232,87,75,.7); color:#FFCFC6; background:rgba(232,87,75,.1); }

/* ==========================================================================
   SETTINGS
   ========================================================================== */
.set-group{ margin-bottom:30px; }
.set-blurb{ margin:-6px 0 14px; font-size:calc(11.5px * var(--ts)); line-height:1.65; color:var(--menu-faint); max-width:70ch; }
.set-row{
  display:grid; grid-template-columns:minmax(150px, 1fr) minmax(180px, 260px);
  align-items:center; gap:20px; padding:9px 0;
  border-bottom:1px solid rgba(244,241,230,.06);
}
.set-row label{ font-size:calc(12.5px * var(--ts)); color:var(--menu-text); }
.set-row label em{ display:block; margin-top:3px; font-size:calc(10.5px * var(--ts)); font-style:normal; line-height:1.5; color:var(--menu-faint); }
.set-ctrl{ display:flex; align-items:center; gap:12px; justify-content:flex-end; }

.set-row input[type=range]{
  -webkit-appearance:none; appearance:none; width:100%; height:2px;
  background:rgba(244,241,230,.18); outline:none; cursor:pointer;
}
.set-row input[type=range]::-webkit-slider-thumb{
  -webkit-appearance:none; appearance:none; width:13px; height:13px; border-radius:50%;
  background:var(--paper); border:0; cursor:pointer;
  box-shadow:0 0 0 4px rgba(9,17,21,.6); transition:transform .15s ease, background .15s ease;
}
.set-row input[type=range]:hover::-webkit-slider-thumb{ background:var(--gold-hot); transform:scale(1.14); }
.set-row input[type=range]::-moz-range-thumb{
  width:13px; height:13px; border-radius:50%; background:var(--paper); border:0; cursor:pointer;
}
.set-row output{ min-width:46px; text-align:right; font-size:calc(11.5px * var(--ts)); color:var(--menu-dim); font-variant-numeric:tabular-nums; }

.set-row select{
  width:100%; padding:8px 11px; font-family:inherit; font-size:calc(11.5px * var(--ts)); letter-spacing:1.4px;
  color:var(--menu-text); background:rgba(9,17,21,.62); border:1px solid var(--menu-line);
  cursor:pointer; outline:none;
}
.set-row select:hover, .set-row select:focus{ border-color:var(--menu-line-hi); }
.set-row select option{ background:#0C171C; color:var(--paper); }

.switch{
  position:relative; width:42px; height:22px; padding:0; flex:none;
  border:1px solid var(--menu-line); background:rgba(9,17,21,.55);
  border-radius:999px; cursor:pointer; transition:border-color .2s ease, background .2s ease;
}
.switch i{
  position:absolute; top:3px; left:3px; width:14px; height:14px; border-radius:50%;
  background:var(--menu-faint); transition:transform .22s cubic-bezier(.2,.9,.3,1), background .22s ease;
}
.switch:hover{ border-color:var(--menu-line-hi); }
.switch.on{ background:rgba(231,184,81,.16); border-color:rgba(231,184,81,.5); }
.switch.on i{ transform:translateX(20px); background:var(--gold-hot); }

.set-foot{ display:flex; align-items:center; justify-content:space-between; gap:16px; padding-top:18px; border-top:1px solid var(--menu-line); }
#set-storage{ font-size:calc(10.5px * var(--ts)); letter-spacing:1.2px; color:var(--menu-faint); }
#set-storage.warn{ color:#F0C08A; }

/* ==========================================================================
   CONTROLS
   ========================================================================== */
.panel-body.controls{ display:grid; grid-template-columns:repeat(auto-fit, minmax(260px, 1fr)); gap:26px 36px; align-content:start; }
.key-row{ display:grid; grid-template-columns:auto 1fr; gap:14px; align-items:baseline; padding:7px 0; border-bottom:1px solid rgba(244,241,230,.06); }
.key-row dt{ white-space:nowrap; }
.key-row dd{ margin:0; font-size:calc(12px * var(--ts)); color:var(--menu-dim); }
kbd{
  display:inline-block; min-width:22px; padding:3px 7px; text-align:center;
  font-family:var(--mono); font-size:calc(10.5px * var(--ts)); letter-spacing:.6px; color:var(--menu-text);
  background:rgba(244,241,230,.06); border:1px solid var(--menu-line);
  border-bottom-width:2px; border-radius:3px;
}
/* --- fps readout ----------------------------------------------------------- */
#fps-readout{
  position:absolute; top:8px; right:12px; z-index:30; display:none;
  font-family:var(--mono); font-size:calc(11px * var(--ts)); letter-spacing:1px;
  color:rgba(244,241,230,.55); text-shadow:0 1px 4px rgba(0,0,0,.8);
  pointer-events:none;
}
#fps-readout.shown{ display:block; }

/* --- narrow viewports ------------------------------------------------------
   Only a phone-shaped window stacks the menu. Every size the portal tests is
   at least 800 wide, and there the two columns survive (see the viewport
   tiers at the end of this file) — a stacked menu would put the shop, the
   bestiary and the settings under the fold at exactly the sizes they test. */
@media (max-width:699px){
  .menu-grid{
    grid-template-columns:1fr; grid-template-rows:auto auto 1fr auto;
    grid-template-areas:"brand" "nav" "stage" "corner"; gap:18px;
    overflow:auto;
  }
  .menu-stage{ min-height:calc(56 * var(--vh)); transform:none; }
  .menu-scrim{ background:linear-gradient(0deg, rgba(6,13,17,.9), rgba(6,13,17,.55)); }
}

/* ==========================================================================
   BUTTONS
   ==========================================================================
   One button system for every overlay. Outlined by default; `primary` earns a
   single hairline of gold rather than a filled slab, so it reads as the default
   action without turning into a highlighter. */
.btn{
  padding:11px 22px; border:1px solid var(--menu-line);
  background:rgba(9,17,21,.5); color:var(--menu-text);
  font-family:inherit; font-size:calc(11px * var(--ts)); font-weight:600;
  letter-spacing:3px; text-transform:uppercase; cursor:pointer;
  transition:color .18s ease, border-color .18s ease, background .18s ease, transform .18s ease;
}
.btn:hover{ color:var(--paper); border-color:var(--menu-line-hi); background:rgba(244,241,230,.06); }
.btn:active{ transform:translateY(1px); }
.btn:focus-visible{ outline:1px solid var(--edge-hot); outline-offset:2px; }
.btn.primary{ border-color:rgba(231,184,81,.45); color:var(--gold-hot); background:rgba(231,184,81,.08); }
.btn.primary:hover{ border-color:var(--gold); background:rgba(231,184,81,.16); color:#FFE7B4; }
.btn.ghost{ background:none; color:var(--menu-dim); }
.btn.ghost:hover{ color:var(--menu-text); background:rgba(244,241,230,.05); }
.btn.tiny{ padding:8px 14px; font-size:calc(9.5px * var(--ts)); letter-spacing:2.2px; }
.btn:disabled{ opacity:.32; cursor:default; transform:none; }
.btn:disabled:hover{ color:var(--menu-text); border-color:var(--menu-line); background:rgba(9,17,21,.5); }

/* ==========================================================================
   MODALS  (pause, game over)
   ========================================================================== */
/* A MODAL IS NEVER TALLER THAN THE VIEWPORT.
 *
 * `html, body` are overflow:hidden and .overlay centres its child, so a panel
 * that outgrows the screen is clipped equally at both ends and the overflow is
 * simply unreachable. The game-over card's height is DATA-DRIVEN — one chip per
 * ability and one per distinct upgrade taken — so a long, successful run grows
 * a card that hides its own RUN AGAIN button. It got worse the better you
 * played, and at the readability sizes the portal tests (800x450, 907x510) the
 * buttons ended up entirely below the fold.
 *
 * Scrolling the panel is the fix; Enter on the results card (see _onKeyDown)
 * is the belt to this pair of braces. */
.modal{
  width:min(460px, calc(90 * var(--vw))); padding:32px 34px 28px;
  display:flex; flex-direction:column; gap:22px;
  max-height:calc(calc(100 * var(--vh)) - 24px); overflow-y:auto; overscroll-behavior:contain;
  border-radius:0; background:var(--menu-ink);
  border:1px solid var(--menu-line); box-shadow:0 30px 80px rgba(3,10,14,.55);
  animation:panelIn .3s cubic-bezier(.2,.9,.3,1);
}
/* The actions must survive the scroll: pinned to the bottom of the panel with
   the panel's own background under them, so they are reachable at any height. */
.modal .modal-actions{
  position:sticky; bottom:-28px; z-index:1;
  margin:0 -34px -28px; padding:14px 34px 28px;
  background:linear-gradient(rgba(9,17,21,0), var(--menu-ink) 40%);
}
.modal.wide{ width:min(640px, calc(92 * var(--vw))); }
.modal h2{
  margin:0; font-size:calc(15px * var(--ts)); font-weight:700; letter-spacing:6px;
  text-transform:uppercase; color:var(--paper);
}
.modal-actions{ display:flex; gap:12px; }
.modal-actions .btn{ flex:1; }

/* The pause sheet reuses `.set-row`, but its rows are `<label>` elements with a
   bare `<span>` caption — the menu's grid still applies, this only supplies the
   caption style the menu gets from `.set-row label`. */
#pause .settings{ display:flex; flex-direction:column; }
#pause .set-row{ cursor:pointer; }
#pause .set-row > span{ font-size:calc(12.5px * var(--ts)); color:var(--menu-text); }
#pause .set-row.check{ grid-template-columns:1fr auto; }
#pause .set-row input[type=checkbox]{
  width:16px; height:16px; accent-color:var(--gold); cursor:pointer; justify-self:end;
}

/* ==========================================================================
   LEVEL UP  (the draft)
   ==========================================================================
   Cards carry their ability's own colour in `--card-col`; rarity is spelled by
   the weight of the top rule and the glow behind the icon, never by a coloured
   fill. Three of these sit over a live battlefield, so they stay legible
   without drowning it. */
#levelup{ background:radial-gradient(ellipse at 50% 45%, rgba(8,18,24,.52), rgba(5,12,16,.9) 78%); }
/* THE DRAFT MUST FIT, WHATEVER IT IS SHOWN IN.
   It used to be three fixed-width cards on a WRAPPING row inside a block with
   no height of its own. Both halves failed at the same sizes: below about
   660px wide the third card dropped to a second row, and the taller stack then
   overflowed the viewport top and bottom — with `.lu-actions` below the fold,
   which put the ACTIVATE button (the confirmation step the portal asked for)
   out of reach entirely.

   The row no longer wraps. The cards are a flex BASIS rather than a width, so
   three of them share whatever the row has and shrink together instead of one
   of them leaving; every fixed size inside a card is a share of the viewport
   height, so a short screen gets the same card, smaller. `max-height` plus a
   scroll is the backstop for the sizes no proportion can rescue: it is there
   so the button can always be REACHED, never so the card can be clipped. */
.levelup-inner{
  display:flex; flex-direction:column; align-items:center;
  gap:clamp(8px, calc(2.2 * var(--vh)), 20px);
  padding:clamp(10px, calc(2.2 * var(--vh)), 20px) clamp(14px, calc(3 * var(--vw)), 28px);
  width:100%; max-height:100%; box-sizing:border-box;
  /* Both axes named: setting only `overflow-y` leaves the other computing to
     `auto`, which is a horizontal scrollbar under a row that never scrolls. */
  overflow-y:auto; overflow-x:hidden; overscroll-behavior:contain;
}
.lu-head{ text-align:center; }
.lu-eyebrow{ font-size:calc(clamp(8.5px, calc(1.4 * var(--vh)), 9.5px) * var(--ts)); letter-spacing:5px; text-transform:uppercase; color:var(--menu-faint); }
.lu-level{
  margin-top:7px; font-size:calc(clamp(18px, calc(3.6 * var(--vh)), 26px) * var(--ts)); font-weight:200;
  letter-spacing:clamp(6px, calc(1.2 * var(--vh)), 9px);
  text-transform:uppercase; color:var(--paper);
}
.lu-hint{ font-size:calc(clamp(9.5px, calc(1.5 * var(--vh)), 10.5px) * var(--ts)); letter-spacing:1.8px; color:var(--menu-faint); }
.lu-hint b{ color:var(--menu-dim); font-weight:600; }

/* THE ROW MAY NEVER BE SHORTER THAN THE CARDS IN IT.
   This was `min-height:0`, which let the flex column above shrink the row
   whenever the draft ran short of vertical room — and `align-items:stretch`
   then handed every card a height smaller than its own text. A card does not
   clip (its rarity rule and its hover lift both need `overflow` visible), so
   the description and the stack line walked out through the bottom border,
   which is what the portal photographed on the Alacrity card.

   It needs no exotic window: ONE extra wrapped line is enough, and any
   machine without Inter installed wraps a line earlier than this layout was
   measured on — a Chromebook among them. `flex:0 0 auto` makes the row take
   its natural height and lets .levelup-inner scroll on the screen that truly
   cannot hold it. A draft you scroll is readable; a draft that spills is not. */
#cards{
  display:flex; flex-wrap:nowrap; gap:clamp(8px, calc(1.6 * var(--vw)), 18px);
  align-items:stretch; justify-content:center;
  width:100%; flex:0 0 auto;
  /* room for the hover lift, so it cannot summon a scrollbar of its own */
  padding:6px 2px;
}
.card{
  --card-col:#8FC9E8;
  position:relative; flex:0 1 236px; min-width:0;
  min-height:min(298px, calc(44 * var(--vh)));
  display:flex; flex-direction:column; align-items:center; text-align:center;
  padding:clamp(11px, calc(2.4 * var(--vh)), 22px) clamp(10px, calc(1.5 * var(--vw)), 18px) clamp(10px, calc(2 * var(--vh)), 18px);
  cursor:pointer;
  background:linear-gradient(178deg, rgba(20,34,42,.88), rgba(9,17,21,.92));
  border:1px solid var(--menu-line);
  box-shadow:0 20px 50px rgba(3,10,14,.5);
  opacity:0; transform:translateY(16px);
  transition:opacity .3s ease, transform .3s cubic-bezier(.2,.9,.3,1),
             border-color .2s ease, box-shadow .2s ease;
}
.card.in{ opacity:1; transform:none; }
.card::before{
  content:""; position:absolute; top:0; left:0; right:0; height:2px;
  background:var(--card-col); opacity:.55;
}
.card:hover{
  border-color:var(--menu-line-hi);
  border-color:color-mix(in srgb, var(--card-col) 46%, transparent);
  box-shadow:0 26px 60px rgba(3,10,14,.6);
  box-shadow:0 26px 60px rgba(3,10,14,.6), 0 0 0 1px color-mix(in srgb, var(--card-col) 22%, transparent);
  transform:translateY(-5px);
}
.card:hover::before{ opacity:1; }
.card.picked{ border-color:var(--card-col); transform:translateY(-5px) scale(.985); }

/* CONTRAST: these two lines carry the card's identity — its rarity and what
   KIND of offer it is — and both sat under 3:1 against the card fill at 8.5px,
   which is below the readable floor for small text. The rarity keeps its own
   colour but drops the extra opacity multiplier, and the tag moves off the
   faintest ink in the palette. */
.card-rarity{ font-size:calc(9px * var(--ts)); letter-spacing:3.4px; text-transform:uppercase; color:var(--card-col); }
.card-tag{ margin-top:4px; font-size:calc(9px * var(--ts)); letter-spacing:2.6px; text-transform:uppercase; color:var(--menu-dim); }
/* A square plate with a hairline, not a glowing disc. The circle-plus-halo was
   the last "achievement badge" left in the draft, and a line icon needs no
   backing light to read — it needs quiet around it. */
.card-icon{
  width:clamp(40px, calc(8.6 * var(--vh)), 64px); height:clamp(40px, calc(8.6 * var(--vh)), 64px); flex:none;
  margin:clamp(6px, calc(2 * var(--vh)), 18px) 0 clamp(5px, calc(1.7 * var(--vh)), 15px);
  display:flex; align-items:center; justify-content:center;
  border:1px solid var(--menu-line);
  background:rgba(244,241,230,.03);
}
.card:hover .card-icon{ border-color:color-mix(in srgb, var(--card-col) 40%, transparent); }
.card-icon img{ width:clamp(24px, calc(5.4 * var(--vh)), 40px); height:clamp(24px, calc(5.4 * var(--vh)), 40px); }
.card-name{
  font-size:calc(clamp(12.5px, calc(2.1 * var(--vh)), 15px) * var(--ts)); font-weight:600; letter-spacing:2.4px;
  text-transform:uppercase; color:var(--paper);
}
.card-desc{
  margin-top:clamp(5px, calc(1.2 * var(--vh)), 9px); font-size:calc(clamp(10.5px, calc(1.7 * var(--vh)), 12px) * var(--ts));
  line-height:1.5; color:rgba(244,241,230,.74);
}
.card-detail{
  margin-top:auto; padding-top:clamp(6px, calc(1.6 * var(--vh)), 12px);
  font-size:calc(clamp(9.5px, calc(1.5 * var(--vh)), 10.5px) * var(--ts)); letter-spacing:.4px; color:var(--menu-dim);
}
/* And no line of a card may be squeezed below its own text. A flex item keeps
   `flex-shrink:1` by default, so a card that is ever handed less height than
   it needs compresses these boxes while the text inside them stays exactly as
   tall as it was — the name lands on the description, the description lands
   on the stack line. `flex:none` is the half of the fix that does not depend
   on the row above getting its sums right. */
.card-rarity, .card-tag, .card-name, .card-desc, .card-detail{ flex:none; }
.card-key{
  position:absolute; top:10px; right:12px;
  font-size:calc(10px * var(--ts)); letter-spacing:1px; color:var(--menu-faint); font-variant-numeric:tabular-nums;
}
/* Rarity reads as intensity, not as a new palette — and the ladder has to be
   legible with the colour removed. Common and rare were both a 2px rule
   separated only by 20% opacity, so in greyscale (or to a deuteranope, for
   whom rare-blue and epic-violet collapse together) the bottom two frames were
   the same card. Each step now changes the rule's HEIGHT, which survives any
   colour vision. */
.card::before{ height:1px; }
.card.rare::before{ height:2px; opacity:.75; }
.card.epic::before{ height:3px; opacity:.85; }
.card.legendary::before{ height:4px; opacity:1; box-shadow:0 0 14px var(--card-col); }
/* The keyboard route into the draft has to be visible when it is being used. */
.card:focus-visible{
  outline:2px solid var(--card-col);
  outline-offset:3px;
}
.card.legendary .card-name{ color:#FFF3DC; }

/* The reroll button is disabled by CLASS, not by the attribute — the click is
   already guarded in rerollCards(), so this is purely about not lying to the
   player about what is still available. */
#btn-reroll:disabled, #btn-reroll.disabled{
  opacity:.3; cursor:default; color:var(--menu-faint);
}
#btn-reroll.disabled:hover{ color:var(--menu-faint); border-color:var(--menu-line); background:none; }

/* ==========================================================================
   GAME OVER
   ========================================================================== */
.go-head{ display:flex; align-items:baseline; justify-content:space-between; gap:16px; }
.go-best{ font-size:calc(10px * var(--ts)); letter-spacing:2.6px; text-transform:uppercase; color:var(--menu-faint); font-variant-numeric:tabular-nums; }
.go-best.new{ color:var(--gold-hot); animation:goBestPulse 1.1s ease-in-out infinite alternate; }
@keyframes goBestPulse{ from{ text-shadow:0 0 0 rgba(255,194,77,0); } to{ text-shadow:0 0 12px rgba(255,194,77,.7); } }

/* ==========================================================================
   NEW RECORD — the bright, a-little-unhinged celebration. One big burst on the
   death card, one discreet flourish over the HUD the instant a live run passes
   the time to beat. Both respect prefers-reduced-motion (below).
   ========================================================================== */
#go-record{ display:none; margin:4px 0 2px; text-align:center; position:relative; }
#go-record.show{ display:block; }
.go-record-text{
  display:inline-block; vertical-align:middle;
  font-weight:800; font-size:calc(30px * var(--ts)); letter-spacing:8px; text-transform:uppercase;
  background:linear-gradient(100deg,#FFD86B 0%,#FFF6D8 28%,#FFB347 52%,#FFF6D8 74%,#FFD86B 100%);
  background-size:250% 100%;
  -webkit-background-clip:text; background-clip:text; color:transparent;
  filter:drop-shadow(0 0 16px rgba(255,194,77,.55));
}
#go-record.show .go-record-text{
  animation:goRecPop .72s cubic-bezier(.18,1.7,.34,1) both, goRecShine 2.2s linear .6s infinite;
}
.go-record-star{
  display:inline-block; vertical-align:middle; margin:0 14px;
  font-size:calc(19px * var(--ts)); color:#FFE9B0; filter:drop-shadow(0 0 9px rgba(255,194,77,.85));
}
#go-record.show .go-record-star{ animation:goRecStar 1s ease-in-out infinite alternate; }
#go-record.show .go-record-star:last-child{ animation-delay:.5s; }
/* THE SHOCKWAVE IS GONE. It was a ring expanding from behind the words, and
   it could not work here: `.go-record-text` paints its letters with
   `background-clip:text` over `color:transparent`, so anything drawn behind
   it shows THROUGH the glyphs. What the portal reviewer saw was the ring at
   its first frame — a hard 16px circle sitting inside the word RECORD. The
   flourish is carried by the pop, the shine and the two stars; it does not
   need a fourth animation that cannot be drawn correctly. */
@keyframes goRecPop{ 0%{ opacity:0; transform:scale(.35) rotate(-7deg); } 60%{ opacity:1; transform:scale(1.16) rotate(2.5deg); } 100%{ transform:scale(1) rotate(0); } }
@keyframes goRecShine{ 0%{ background-position:250% 0; } 100%{ background-position:-30% 0; } }
@keyframes goRecStar{ 0%{ transform:scale(.7) rotate(-10deg); opacity:.65; } 100%{ transform:scale(1.3) rotate(30deg); opacity:1; } }

/* A notice like any other, and a member of the column — it used to hang at
   top:66px, which is INSIDE the boss bar's lane, so beating your own record
   during a boss fight printed the two through each other. `display:none` is
   what keeps it out of the column's flow while it is not playing; the CSS
   animation still runs on the frame it is displayed, so the flourish is
   unchanged. */
#record-flash{
  position:relative; display:none; pointer-events:none; opacity:0;
  font-weight:700; font-size:calc(15px * var(--ts)); letter-spacing:6px; text-transform:uppercase; white-space:nowrap;
  color:#FFE9B0; text-shadow:0 0 15px rgba(255,194,77,.85), 0 0 40px rgba(255,194,77,.42);
}
#record-flash.play{ display:block; animation:recFlash 2.6s cubic-bezier(.2,.9,.25,1) forwards; }
#record-flash::before{
  content:""; position:absolute; inset:-11px -26px; border-radius:999px;
  border:1px solid rgba(255,194,77,.5); opacity:0;
}
#record-flash.play::before{ animation:recRing 2.6s ease-out forwards; }
@keyframes recFlash{
  0%   { opacity:0; transform:translateY(-16px) scale(.72); filter:blur(7px); }
  12%  { opacity:1; transform:translateY(0) scale(1.12); filter:blur(0); }
  20%  { transform:translateY(0) scale(1); }
  70%  { opacity:1; letter-spacing:6px; }
  100% { opacity:0; transform:translateY(-6px) scale(1); letter-spacing:13px; }
}
@keyframes recRing{ 0%,8%{ opacity:0; transform:scale(.6); } 22%{ opacity:.65; transform:scale(1); } 55%{ opacity:0; transform:scale(1.4); } 100%{ opacity:0; } }

@media (prefers-reduced-motion: reduce){
  .go-best.new, #go-record.show .go-record-text, #go-record.show .go-record-star,
  #record-flash.play, #record-flash.play::before{ animation:none !important; }
  .go-record-text{ background:none; -webkit-text-fill-color:var(--gold-hot); color:var(--gold-hot); }
  #record-flash.play{ opacity:1; }             /* shown, calmly; JS clears it on a timer */
}
/* FIVE STATS, FIVE COLUMNS. The grid was still authored for four, so SALVAGE
   — added later, and the one number the shop depends on — wrapped onto a row
   of its own beside three empty cells. */
.go-stats{
  display:grid; grid-template-columns:repeat(5, 1fr); gap:1px;
  background:var(--menu-line); border:1px solid var(--menu-line);
}
.go-stat{ background:rgba(9,17,21,.5); padding:14px 12px; text-align:center; }
.go-stat label{ display:block; font-size:calc(8.5px * var(--ts)); letter-spacing:2.4px; text-transform:uppercase; color:var(--menu-faint); }
.go-stat div{ margin-top:6px; font-size:calc(21px * var(--ts)); font-weight:300; color:var(--paper); font-variant-numeric:tabular-nums; }
.go-section > label{ display:block; margin-bottom:9px; font-size:calc(9px * var(--ts)); letter-spacing:3.4px; text-transform:uppercase; color:var(--gold); }
.go-section + .go-section{ margin-top:-8px; }
.chip-row{ display:flex; flex-wrap:wrap; gap:8px; min-height:26px; }
.chip-row:empty::after{ content:"—"; font-size:calc(12px * var(--ts)); color:var(--menu-faint); }
.kit-chip{
  --card-col:#8FC9E8;
  display:inline-flex; align-items:center; gap:7px; padding:5px 10px;
  background:rgba(244,241,230,.04);
  border:1px solid var(--menu-line); border-left:2px solid var(--card-col);
  font-size:calc(10.5px * var(--ts)); letter-spacing:1.4px; color:var(--menu-text);
}
.kit-chip img{ width:15px; height:15px; }
.kit-chip b{ color:var(--menu-faint); font-weight:600; font-variant-numeric:tabular-nums; }
.kit-chip.small{ padding:4px 8px; font-size:calc(10px * var(--ts)); }

/* ==========================================================================
   THE CONTROL LEGEND — lower-right of the running game
   ==========================================================================
   The layout the portal handed us as a reference: a name, then the things
   that work it, as bone keycaps and a mouse with one button lit. It used to
   be a panel you opened with a key; the portal's next note was that it must
   not be — a player should not have to pause to find out which key pauses.
   So the same table is printed on the frame instead.

   IT HAS NO PANEL, AND THAT IS THE WHOLE DESIGN PROBLEM SOLVED TWICE OVER.
   The legend that was removed from this corner was a boxed list: a slab of
   grey over the brightest part of the picture, competing with the meadow and
   with the vitals for the same read. What survives that background without a
   box is not type — it is the CAPS. A dark-on-bone key with a hard edge under
   it is the highest-contrast object in the frame and it is instantly
   recognisable as a key, so the caps carry the block and the labels only have
   to name them, quietly, under a contact shadow.

   ONE UNIT SIZES ALL OF IT. --lg-cap is the key; the type, the gaps and the
   mouse are shares of it, so a short window gets a smaller legend rather than
   a clipped last row. Its width is --legend-w, the same number #hud-bottom
   reserves for it in the ability bar's budget — the legend cannot grow into
   the bar, because the bar is already sized around it. */
#legend{
  --lg-cap:clamp(17px, calc(2.6 * var(--vh)), 21px);
  width:var(--legend-w, 180px);
  display:flex; flex-direction:column; gap:calc(var(--lg-cap) * .18);
  /* Print on the frame. Nothing here is pressable — Space is the only way the
     dash fires and every other row is a key — so it must never eat a click
     meant for the island underneath it. */
  pointer-events:none;
  transition:opacity .45s ease, visibility 0s linear 0s;
}
/* Away during the calibration (UI.setLegendShown). Visibility waits for the
   fade before it switches, so the legend leaves smoothly and returns at once;
   the box keeps its place so the ability bar never re-lays itself. */
#legend.off{
  opacity:0; visibility:hidden;
  transition:opacity .3s ease, visibility 0s linear .3s;
}
/* The name leads INTO the caps: right-aligned against a common gutter, so the
   caps stack on the frame's edge and the block has one clean side. */
.lg-row{
  display:grid; grid-template-columns:1fr auto; align-items:center;
  gap:calc(var(--lg-cap) * .45); min-width:0;
}
.lg-name{
  text-align:right; min-width:0;
  font-size:calc(var(--lg-cap) * .52); font-weight:500;
  letter-spacing:.09em; text-transform:uppercase;
  color:rgba(244,241,230,.74);
  /* The damage numbers' recipe, for the same reason: this type sits on the
     meadow with nothing behind it. A tight contact edge, never a halo. */
  text-shadow:0 0 2px rgba(6,13,17,.95), 0 1px 3px rgba(6,13,17,.85);
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.lg-keys{
  display:flex; align-items:center; justify-content:flex-end;
  gap:calc(var(--lg-cap) * .16);
}
/* A REAL KEY at HUD scale: bone cap, dark type, one hard edge underneath. */
.lg-key{
  display:inline-flex; align-items:center; justify-content:center;
  min-width:var(--lg-cap); height:var(--lg-cap);
  padding:0 calc(var(--lg-cap) * .22); border-radius:calc(var(--lg-cap) * .22);
  background:var(--paper); border:1px solid rgba(8,16,20,.6);
  box-shadow:0 1px 0 rgba(8,16,20,.55), 0 1px 4px rgba(6,13,17,.45);
  font-family:inherit; font-size:calc(var(--lg-cap) * .54); font-weight:700;
  letter-spacing:.4px; line-height:1; color:#101D24; white-space:nowrap;
}
/* A range, not a key: "1 – 6" is one row, not six caps. */
.lg-sep{
  font-style:normal; font-size:calc(var(--lg-cap) * .5);
  color:rgba(244,241,230,.72);
  text-shadow:0 0 2px rgba(6,13,17,.95), 0 1px 3px rgba(6,13,17,.85);
}
/* Wider than a cap is tall, because the thing it has to say is WHICH BUTTON —
   a 14px mouse is a pill with a smudge on it. The glyph is 44×64, so this is
   the one row height the cap does not set. */
.lg-mouse{
  width:calc(var(--lg-cap) * .95); height:auto; display:block;
  filter:drop-shadow(0 1px 3px rgba(6,13,17,.5));
}
.lg-mbody{ fill:var(--paper); stroke:rgba(8,16,20,.6); stroke-width:2.5; }
.lg-mb{ fill:transparent; }
.lg-mb.on{ fill:var(--gold-hot); }
.lg-mseam{ stroke:rgba(8,16,20,.45); stroke-width:2; }
.lg-mwheel{ fill:rgba(8,16,20,.45); }
.lg-mmove{ fill:none; stroke:rgba(8,16,20,.5); stroke-width:3; stroke-linecap:round; stroke-linejoin:round; }

/* ==========================================================================
   CURSOR
   ========================================================================== */
#cursor{
  --cur-col:#E7B851;
  position:absolute; top:0; left:0; width:40px; height:40px;
  margin:-20px 0 0 -20px; pointer-events:none; z-index:40;
  transition:opacity .2s;
  will-change:transform;
}
#cursor.hidden{ opacity:0; }
#cursor svg{ width:100%; height:100%; overflow:visible; }
/* THE CROSSHAIR NEVER DIMS.
 *
 * It used to drop to 28% opacity the moment the selected ability went on
 * cooldown — which is to say, the instant you fired. The one thing on screen
 * telling you where your shots were going faded out exactly when you were
 * shooting, and the ability bar was already reporting the cooldown anyway.
 *
 * Readiness is still shown, but only ADDITIVELY: ready adds a glow, not-ready
 * takes it away. Nothing here ever lowers the opacity or shifts the colour of
 * the crosshair itself, so it reads identically at every moment of a fight. */
.cur-ring{
  fill:none; stroke:var(--cur-col); stroke-width:2.2; opacity:1;
  transform-origin:center; transition:filter .18s, r .18s;
}
.cur-dot{ fill:var(--cur-col); opacity:1; }
.cur-tick{ stroke:var(--cur-col); stroke-width:2.4; stroke-linecap:round; opacity:1; }
/* The outline: the same shapes, wider and dark, drawn first. Contrast comes
 * from the edge rather than from the ability's colour, so it holds on grass,
 * on a bright trail and on the pale ground alike. Static — it never repaints
 * with the colour changes above. */
.cur-halo{ pointer-events:none; }
.cur-halo circle, .cur-halo path{
  fill:none; stroke:rgba(6,12,16,.85); stroke-width:5; stroke-linecap:round;
}
.cur-halo circle:nth-child(2){ fill:rgba(6,12,16,.85); stroke-width:3.6; }
#cursor.ready .cur-ring{ filter:drop-shadow(0 0 6px var(--cur-col)); }

/* SUSTAINED FIRE IS ARMED. A second ring outside the crosshair, turning
   slowly — the trigger is held, so something on the cursor is moving even
   when the hand is not. Additive like every other cursor state: it adds a
   mark, it never dims or recolours the crosshair itself. */
#cursor .cur-hold{
  fill:none; stroke:var(--cur-col); stroke-width:1.1; opacity:0;
  stroke-dasharray:5 7; transform-origin:center;
  transition:opacity .2s ease;
}
#cursor.holding .cur-hold{ opacity:.85; animation:curHold 3.2s linear infinite; }
@keyframes curHold{ to{ transform:rotate(360deg); } }

/* ==========================================================================
   LOADING
   ========================================================================== */
#loading{
  position:absolute; inset:0; z-index:100;
  display:flex; align-items:center; justify-content:center;
  background:#000000;
  transition:opacity .65s ease;
}
#loading.gone{ opacity:0; pointer-events:none; }
.load-inner{ display:flex; flex-direction:column; align-items:center; gap:24px; }

/* Golden snake loader */
.golden-snake {
  --loader-size: 56px;
  --tile-size: 8px;
  position: relative;
  width: var(--loader-size);
  height: var(--loader-size);
  animation: snakeRotate 12s linear infinite;
  margin: 15px 0;
  will-change: transform;
}
.golden-snake .tile {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--tile-size);
  height: var(--tile-size);
  background: hsl(calc(48 - var(--i) * 1.2), 100%, calc(62% - var(--i) * 3%));
  box-shadow: 
    0 0 calc(12px - var(--i) * 0.9px) hsl(calc(48 - var(--i) * 1.2), 100%, calc(60% - var(--i) * 3%)), 
    inset 0 0 2px rgba(255, 255, 255, calc(0.9 - var(--i) * 0.08));
  opacity: calc(1 - var(--i) * 0.06);
  animation: snakeMove 2.4s linear infinite;
  animation-delay: calc((11 - var(--i)) * -0.1s);
  will-change: transform;
}
@keyframes snakeMove {
  0% {
    transform: translate(0, 0) scale(calc(1 - var(--i) * 0.04));
  }
  25% {
    transform: translate(48px, 0) scale(calc(1 - var(--i) * 0.04));
  }
  50% {
    transform: translate(48px, 48px) scale(calc(1 - var(--i) * 0.04));
  }
  75% {
    transform: translate(0, 48px) scale(calc(1 - var(--i) * 0.04));
  }
  100% {
    transform: translate(0, 0) scale(calc(1 - var(--i) * 0.04));
  }
}
@keyframes snakeRotate {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.load-title{
  font-size:calc(13px * var(--ts)); font-weight:800; letter-spacing:11px; color:var(--gold-hot);
  text-shadow:0 0 8px rgba(231,184,81,0.3);
  margin-top:10px;
}
.load-bar{
  width:180px; height:2px; border-radius:2px; overflow:hidden;
  background:rgba(231,184,81,0.1);
}
#loading-bar-fill{
  height:100%; width:0%;
  background:linear-gradient(90deg,var(--gold-deep),var(--gold-hot));
  box-shadow:0 0 10px var(--gold);
  transition:width .35s cubic-bezier(.2,.9,.3,1);
}
#loading-label{
  font-size:calc(10px * var(--ts)); letter-spacing:3px; color:rgba(231, 184, 81, 0.5); font-weight:500;
  min-height:14px;
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
/* WHAT IS NOT HERE ANY MORE, AND WHY.
   This tier used to restate the vitals bars at 200px/150px and the ability
   plates at 52px. Both were fixed numbers standing in for "there is less room
   now", and both were wrong in the same direction: at 800px wide a 200px bar
   sat inside a 190px plate and ran past its own edge, and the 52px plates
   still met the vitals. The bars are percentages of the plate and the plates
   are a share of the space left over (see #hud-bottom), so the sizes follow
   the room continuously and there is nothing left to restate. */
@media (max-width: 860px){
  .go-stats{ grid-template-columns:repeat(2,1fr); }
}
@media (max-height: 620px){
  .nav-play{ padding:15px 26px 15px 22px; margin-bottom:14px; }
  .nav-item{ padding:8px 14px 8px 8px; }
}

/* =============================================================================
 * TUTORIAL — the calibration opening (src/tutorial.js)
 *
 * One layer above the HUD, below every modal overlay. Cards are pointer-inert:
 * the accept gesture is read from the window, so nothing here steals a click
 * from the game underneath it.
 * ========================================================================== */
#tutorial{ position:absolute; inset:0; pointer-events:none; z-index:12; }
/* ...AND EVERY CONTROL IN IT OPTS BACK IN, in one place.
   The layer is inert so a card can never steal a click from the game beneath
   it, and each interactive piece used to re-enable itself. The orders' OK was
   added later and did not, so it could not be clicked AT ALL — only Enter got
   past it. A card the player is asked to press is a control; this is the list,
   and anything new belongs on it. */
#tutorial .tut-skip,
#tutorial .tut-ro-card,
#tutorial .tut-final{ pointer-events:auto; }
/* Modals must clear the calibration cards. */
.overlay{ z-index:30; }

/* ---- the card ------------------------------------------------------------ */
/* AT THE TOP, AT EVERY SIZE. The camera keeps the machine in the middle of the
   frame, so a card anchored to the bottom edge climbs toward the middle as the
   window grows — on a large screen it sat squarely on the robot it was
   teaching. And it had a second placement: a short-screen tier moved it to the
   top, so which of the two a player got was a question about their monitor.
   One placement now, in the lane under the readout (the boss bar's lane: no
   boss exists during the calibration). Tiers may shrink it; none may move it.
   The notice column clears it — see _holdLane in tutorial.js. */
/* AND IT MUST END ABOVE THE MACHINE. The robot's head stands at about 44% of
   the frame's height, so everything below is sized against the HEIGHT
   (clamp on vh): the tallest step — MOVE, keys and a sentence — ends above
   it at every size the portal tests, 800×450 included. Two things buy most of
   that: the card may be as wide as its sentence (an absolute box at left:50%
   is otherwise only allowed HALF the frame, so every sentence broke onto a
   second line), and the four movement keys stand in one row. */
.tut-card{
  position:absolute; left:50%; top:var(--boss-top);
  display:flex; flex-direction:column; align-items:center;
  gap:clamp(3px, calc(.8 * var(--vh)), 8px);
  padding:clamp(8px, calc(1.7 * var(--vh)), 14px) clamp(18px, calc(2.6 * var(--vw)), 26px) clamp(7px, calc(1.4 * var(--vh)), 12px);
  width:max-content; max-width:min(680px, calc(calc(100 * var(--vw)) - 32px)); min-width:220px;
  background:rgba(6,13,17,.74);
  border:1px solid var(--menu-line); border-radius:6px;
  backdrop-filter:blur(4px) saturate(.95); -webkit-backdrop-filter:blur(4px);
  box-shadow:0 14px 44px rgba(0,0,0,.38);
  opacity:0; transform:translateX(-50%) translateY(-12px) scale(.96);
  transition:opacity .36s cubic-bezier(.22,1,.36,1),
             transform .36s cubic-bezier(.22,1,.36,1),
             border-color .32s ease;
}
.tut-card.on{ opacity:1; transform:translateX(-50%) translateY(0) scale(1); }
.tut-card.off{
  opacity:0; transform:translateX(-50%) translateY(-12px) scale(.985);
  transition:opacity .28s cubic-bezier(.55,0,.7,.3),
             transform .28s cubic-bezier(.55,0,.7,.3);
}

.tut-over{
  font-size:calc(9px * var(--ts)); letter-spacing:3.4px; text-transform:uppercase;
  color:var(--menu-faint);
}
.tut-title{
  font-size:calc(clamp(16px, calc(3 * var(--vh)), 21px) * var(--ts)); font-weight:200; letter-spacing:6px; text-transform:uppercase;
  color:var(--paper); padding-left:6px;   /* optical centre against the tracking */
}
.tut-sub{
  font-size:calc(clamp(11px, calc(1.9 * var(--vh)), 12px) * var(--ts)); letter-spacing:.5px; line-height:1.65; text-align:center;
  color:var(--paper-dim);
}

/* ---- keycaps ------------------------------------------------------------- */
/* One row: W A S D, in the order the corner legend prints them. */
.tut-keys{ display:flex; align-items:center; gap:clamp(4px, calc(.8 * var(--vh)), 6px); margin:2px 0 1px; }
.tut-krow{ display:flex; gap:clamp(4px, calc(.8 * var(--vh)), 6px); }
.tut-key{
  width:clamp(28px, calc(5.2 * var(--vh)), 38px); height:clamp(28px, calc(5.2 * var(--vh)), 38px);
  display:flex; align-items:center; justify-content:center;
  font:500 14px/1 inherit; font-family:inherit; font-size:calc(clamp(12px, calc(2 * var(--vh)), 14px) * var(--ts));
  letter-spacing:1px; color:var(--paper);
  background:linear-gradient(#1B272D, #121C21);
  border:1px solid var(--menu-line-hi); border-bottom-width:3px; border-radius:6px;
  box-shadow:0 2px 0 rgba(0,0,0,.42), inset 0 1px 0 rgba(244,241,230,.07);
  transition:background .12s, border-color .12s, transform .12s, box-shadow .12s, color .12s;
}
/* Idle: the four keys breathe once each, in reading order — W, then A S D. */
@keyframes tut-keybreathe{
  0%, 26%, 100%{ border-color:var(--menu-line-hi); color:var(--paper); }
  9%{ border-color:var(--gold); color:#FFF6DC; box-shadow:0 2px 0 rgba(0,0,0,.42),
      0 0 14px rgba(231,184,81,.28), inset 0 1px 0 rgba(244,241,230,.07); }
}
.k-w{ animation:tut-keybreathe 2.6s ease-in-out infinite; }
.k-a{ animation:tut-keybreathe 2.6s ease-in-out .28s infinite; }
.k-s{ animation:tut-keybreathe 2.6s ease-in-out .56s infinite; }
.k-d{ animation:tut-keybreathe 2.6s ease-in-out .84s infinite; }
/* DRIVEN, and it stays driven. The MOVE step wants all four directions, so
   each cap keeps a gold rule and a tick once its own has been worked: what is
   left to do is on the card rather than in the player's head. Declared BEFORE
   .held so a key that is done and pressed still reads as pressed. */
.tut-key.done{
  animation:none; position:relative;
  border-color:var(--gold); color:#FFF6DC;
  background:linear-gradient(#2E2718, #1E1A11);
}
.tut-key.done::after{
  content:''; position:absolute; right:-4px; top:-4px;
  width:13px; height:13px; border-radius:50%;
  background:var(--gold); border:1px solid #1A1305;
  /* The tick itself, drawn rather than typed: a glyph would sit differently in
     every fallback font, and this badge is 13px across. */
  background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M5 12.5 10 18 19 7' fill='none' stroke='%231A1305' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-size:11px 11px; background-position:center; background-repeat:no-repeat;
}
/* The REAL key, held: the cap presses down and holds its light. */
.tut-key.held{
  animation:none;
  background:linear-gradient(#2A3A2E, #1A2A20);
  border-color:#63D471; color:#EAFFF2;
  transform:translateY(2px); border-bottom-width:1px;
  box-shadow:0 0 0 rgba(0,0,0,.4), 0 0 16px rgba(99,212,113,.22);
}
/* Inline keycap inside a sentence (the "press 2" step).
   ALIGNED TO THE TEXT IT SITS IN. A fixed -6px shove dropped the cap below
   the baseline of its own sentence — the portal reviewer asked for the
   buttons to line up with their text — so it centres on the line's midline
   instead, and the line box is given room for it so the two rows of a
   two-line sentence stay evenly spaced. */
.tut-key.tut-inline{
  display:inline-flex; width:22px; height:22px; font-size:calc(11px * var(--ts));
  vertical-align:middle; position:relative; top:-1px;
  margin:0 4px; border-bottom-width:2px;
  animation:tut-keybreathe 1.8s ease-in-out infinite;
}
.tut-sub{ line-height:1.9; }
.tut-card.armed .tut-key.tut-inline{
  animation:none; border-color:#63D471; color:#EAFFF2;
  background:linear-gradient(#2A3A2E, #1A2A20);
}

/* ---- the little mouse ---------------------------------------------------- */
.tut-mousewrap{ margin:2px 0 1px; }
.tut-mouse{ height:clamp(30px, calc(5.8 * var(--vh)), 41px); width:auto; aspect-ratio:44 / 64; display:block; }
.tm-body{ fill:rgba(18,28,33,.92); stroke:var(--menu-line-hi); stroke-width:2; }
.tm-seam{ stroke:var(--menu-line-hi); stroke-width:1.6; }
.tm-wheel{ fill:var(--paper-dim); opacity:.55; }
.tm-left{ fill:rgba(231,184,81,0); transition:fill .2s; }
/* AIM: the whole mouse sweeps — small, weighted, believable. */
.tut-mousewrap.wiggle{ animation:tut-wiggle 1.9s cubic-bezier(.45,.05,.55,.95) infinite; }
@keyframes tut-wiggle{
  0%, 100%{ transform:translateX(-9px) rotate(-7deg); }
  50%{ transform:translateX(9px) rotate(7deg); }
}
/* FIRE: the left button ticks like a heartbeat instead of sweeping. */
.tut-mousewrap.click{ animation:tut-clicknudge 1.15s ease-in-out infinite; }
@keyframes tut-clicknudge{ 0%,18%,100%{ transform:scale(1); } 8%{ transform:scale(.94); } }
.tut-mousewrap.click .tm-left{ animation:tut-clickfill 1.15s ease-in-out infinite; }
@keyframes tut-clickfill{
  0%, 18%, 100%{ fill:rgba(231,184,81,0); }
  8%{ fill:rgba(231,184,81,.85); }
}

/* ---- the success beat ---------------------------------------------------- */
.tut-check{
  position:absolute; top:-13px; right:-13px; width:30px; height:30px;
  display:flex; align-items:center; justify-content:center;
  background:#63D471; border-radius:50%;
  box-shadow:0 4px 14px rgba(0,0,0,.4), 0 0 18px rgba(99,212,113,.35);
  opacity:0; transform:scale(.3) rotate(-14deg);
  transition:opacity .26s cubic-bezier(.34,1.56,.64,1),
             transform .34s cubic-bezier(.34,1.56,.64,1);
}
.tut-check svg{
  width:16px; height:16px; fill:none; stroke:#0A1418;
  stroke-width:3.4; stroke-linecap:round; stroke-linejoin:round;
  stroke-dasharray:26; stroke-dashoffset:26;
}
.tut-card.done{ border-color:rgba(99,212,113,.55); }
.tut-card.done .tut-check{ opacity:1; transform:scale(1) rotate(0deg); }
.tut-card.done .tut-check svg{ stroke-dashoffset:0; transition:stroke-dashoffset .28s ease-out .1s; }

/* ---- the goodbye --------------------------------------------------------- */
.tut-final{ padding:24px 44px 20px; gap:12px; }
.tut-final .tut-title{ font-size:calc(27px * var(--ts)); letter-spacing:8px; color:var(--gold); padding-left:8px; }
.tut-hint{
  font-size:calc(9.5px * var(--ts)); letter-spacing:2.8px; text-transform:uppercase;
  color:var(--menu-faint); margin-top:2px;
  animation:tut-hintpulse 1.7s ease-in-out infinite;
}
@keyframes tut-hintpulse{ 0%,100%{ opacity:.45; } 50%{ opacity:1; } }

/* =============================================================================
 * REVIVE OFFER — death's second chance (src/game.js requestReviveAd flow)
 *
 * A shade more "toy" than the rest of the chrome on purpose: rounder, softer,
 * springier — portal players read that shape as "friendly choice", and it
 * keeps the moment from feeling like a punishment screen. The two buttons get
 * EQUAL visual treatment (CrazyGames rule): same size, font and color — the
 * video icon alone marks the ad path.
 * ========================================================================== */
#revive.overlay{ background:radial-gradient(ellipse at 50% 45%, rgba(8,18,24,.30), rgba(6,14,18,.78) 75%); }
.revive-card{
  display:flex; flex-direction:column; align-items:center; gap:10px;
  padding:30px 44px 28px;
  background:linear-gradient(rgba(16,27,33,.94), rgba(10,19,24,.94));
  border:1px solid var(--menu-line-hi);
  border-radius:22px;
  box-shadow:0 24px 70px rgba(0,0,0,.5), inset 0 1px 0 rgba(244,241,230,.06);
  opacity:0; transform:translateY(22px) scale(.86);
}
#revive.shown .revive-card{
  opacity:1; transform:translateY(0) scale(1);
  transition:opacity .3s ease, transform .44s cubic-bezier(.34,1.45,.5,1);   /* the bounce */
}
.revive-title{
  font-size:calc(30px * var(--ts)); font-weight:200; letter-spacing:5px; text-transform:uppercase;
  color:var(--paper); padding-left:5px;
}
.revive-sub{ font-size:calc(12.5px * var(--ts)); letter-spacing:.5px; color:var(--paper-dim); }

/* ---- the countdown ring -------------------------------------------------- */
.revive-ring{ position:relative; width:76px; height:76px; margin-bottom:2px; }
.revive-ring svg{ width:76px; height:76px; transform:rotate(-90deg); }
.rv-track{ fill:none; stroke:var(--menu-line); stroke-width:4; }
.rv-fill{
  fill:none; stroke:var(--gold); stroke-width:4; stroke-linecap:round;
  transition:stroke-dashoffset .12s linear;
  filter:drop-shadow(0 0 6px rgba(231,184,81,.35));
}
#revive-count{
  position:absolute; inset:0; display:flex; align-items:center; justify-content:center;
  font-size:calc(28px * var(--ts)); font-weight:300; color:var(--paper); font-variant-numeric:tabular-nums;
}

/* ---- the two equal buttons ------------------------------------------------ */
.revive-btns{ display:flex; gap:12px; margin-top:10px; }
.revive-btn{
  display:inline-flex; align-items:center; justify-content:center; gap:9px;
  min-width:186px; padding:13px 22px;
  font-size:calc(12.5px * var(--ts)); letter-spacing:1.6px; text-transform:uppercase; color:var(--paper);
  background:rgba(244,241,230,.07);
  border:1px solid var(--menu-line-hi); border-radius:999px;
  cursor:pointer;
  transition:transform .18s cubic-bezier(.34,1.56,.64,1), background .18s, border-color .18s;
}
.revive-btn:hover{
  background:rgba(244,241,230,.13); border-color:rgba(244,241,230,.45);
  transform:translateY(-2px) scale(1.03);
}
.revive-btn:active{ transform:translateY(0) scale(.98); }
.rv-video{ width:17px; height:17px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linejoin:round; }

/* ---- ad in flight --------------------------------------------------------- */
.revive-wait{
  font-size:calc(10px * var(--ts)); letter-spacing:2.4px; text-transform:uppercase;
  color:var(--menu-faint); margin-top:6px;
  opacity:0; height:0; overflow:hidden; transition:opacity .25s;
  animation:tut-hintpulse 1.4s ease-in-out infinite;
}
#revive.pending .revive-wait{ opacity:1; height:auto; }
/* THE WAY OUT NEVER STOPS WORKING. Both buttons used to go pointer-events:none
   here, which — with the countdown held and no key bound in the dead state —
   turned a stalled ad into a modal with no exit at all. Only the ad button is
   locked now, and only so a second request cannot be fired; a real ad renders
   over the page, so the skip underneath is unreachable while one is playing
   and reachable exactly when one is not. */
#revive.pending .revive-btns{ opacity:.5; }
#revive.pending #revive-ad{ pointer-events:none; }
#revive.pending #revive-skip{ opacity:1; }
#revive.pending .rv-fill{ stroke:var(--menu-faint); filter:none; }

/* ---- the landing count ---------------------------------------------------
 * Three beats between "you bought it" and "you are playing again". One digit
 * at a time, huge and centred, punched in and pulled away — the player's cue
 * to find the cursor before the shockwave clears the ring. The layer never
 * takes pointer events: the last beat is a fight, not a button. */
#revive-321{
  position:absolute; inset:0; z-index:26;
  display:flex; align-items:center; justify-content:center;
  pointer-events:none;
  font-size:calc(min(calc(30 * var(--vh)), 260px) * var(--ts)); font-weight:200; line-height:1;
  letter-spacing:-4px; color:var(--paper);
  text-shadow:0 0 60px rgba(143,201,232,.55), 0 6px 40px rgba(0,0,0,.6);
  opacity:0;
}
#revive-321.pop{ animation:rv-count .95s cubic-bezier(.16,.9,.3,1) forwards; }
@keyframes rv-count{
  0%   { opacity:0; transform:scale(1.9); filter:blur(6px); }
  18%  { opacity:1; transform:scale(1);   filter:blur(0); }
  72%  { opacity:.92; transform:scale(1); }
  100% { opacity:0; transform:scale(.82); }
}

/* ---- the game-over card, a shade friendlier ------------------------------
 * Same identity, softer shell: rounder corners and pill buttons so the card
 * reads "web game", not "terminal". Deliberately nothing else. */
#gameover .panel.modal{ border-radius:18px; }
#gameover .btn{ border-radius:999px; }
/* Salvage sits with the run's other numbers but reads as money: gold, with
   the wallet it landed in whispered underneath. */
.go-stat.cores div{ color:var(--gold-hot); }
.go-sub{
  display:block; margin-top:4px;
  font-size:calc(8.5px * var(--ts)); letter-spacing:1.8px; text-transform:uppercase; color:var(--menu-faint);
}

/* =============================================================================
 * FULL LAUNCH — the draft's confirmation, the calibration's new pieces,
 * the revive's third door, and the restart's wait (src/ui.js, src/tutorial.js)
 *
 * All of it is motion in service of one sentence each: "read before you
 * commit", "this is what the run is for", "ads are off, cores work", "an ad
 * is coming, hold on". Every animation here has a reduced-motion form.
 * ========================================================================== */

/* ---- the draft: select, then activate ------------------------------------ */
/* One line for the first draft only, then never again. */
.lu-first{
  margin-top:10px; font-size:calc(12px * var(--ts)); letter-spacing:.6px; color:var(--paper-dim);
  animation:lu-firstin .5s cubic-bezier(.22,1,.36,1) .25s both;
}
.lu-first b{ color:var(--gold); font-weight:600; }
@keyframes lu-firstin{ from{ opacity:0; transform:translateY(5px); } to{ opacity:1; transform:none; } }

.lu-actions{ display:flex; align-items:center; gap:14px; }
/* The button is a locked gate for the first beat: the bar inside it fills
   left to right for LU_LOCK seconds, then the gate opens. The player cannot
   fire a card into the build by mashing the key they were mashing to shoot. */
.btn.lu-activate{
  position:relative; overflow:hidden; min-width:212px; padding:13px 30px;
  border-radius:999px; font-size:calc(11.5px * var(--ts)); letter-spacing:3.2px;
  transition:color .22s ease, border-color .22s ease, background .22s ease,
             transform .18s cubic-bezier(.34,1.56,.64,1), opacity .22s ease;
}
.btn.lu-activate span{ position:relative; }
.btn.lu-activate .lu-lock{
  position:absolute; left:0; top:0; bottom:0; width:100%;
  background:rgba(231,184,81,.16);
  transform:scaleX(0); transform-origin:left center;
  pointer-events:none;
}
.btn.lu-activate[disabled]{ cursor:default; opacity:.55; }
.btn.lu-activate[disabled]:hover{ transform:none; }
#levelup.locked .btn.lu-activate{ opacity:.72; }
#levelup.locked .btn.lu-activate .lu-lock{ background:rgba(244,241,230,.08); }
.btn.lu-activate.ready{
  opacity:1; color:#0c1317; background:var(--gold); border-color:var(--gold);
  animation:lu-readypulse 1.9s ease-in-out .3s infinite;
}
.btn.lu-activate.ready:hover{ background:var(--gold-hot); border-color:var(--gold-hot); transform:translateY(-2px) scale(1.03); }
.btn.lu-activate.ready .lu-lock{ display:none; }
@keyframes lu-readypulse{
  0%,100%{ box-shadow:0 0 0 0 rgba(231,184,81,.45); }
  55%{ box-shadow:0 0 0 9px rgba(231,184,81,0); }
}
/* A confirm with nothing selected, or too early: the gate shakes its head. */
.btn.lu-activate.nudge{ animation:lu-nudge .42s cubic-bezier(.36,.07,.19,.97) both; }
@keyframes lu-nudge{
  10%,90%{ transform:translateX(-1px); } 20%,80%{ transform:translateX(2px); }
  30%,50%,70%{ transform:translateX(-4px); } 40%,60%{ transform:translateX(4px); }
}

/* The selected card lifts and lights up; the others step back a shade, so the
   draft reads as one choice under review rather than three equal offers. */
#levelup.has-sel .card:not(.sel){ opacity:.62; }
#levelup.has-sel .card:not(.sel):hover{ opacity:.9; }
.card.sel{
  border-color:var(--card-col); transform:translateY(-8px) scale(1.02);
  /* Plain shadow first: a browser without color-mix() drops only the second
     declaration and keeps a lifted, bordered card rather than a flat one. */
  box-shadow:0 18px 44px rgba(0,0,0,.45);
  box-shadow:0 18px 44px rgba(0,0,0,.45), 0 0 0 1px color-mix(in srgb, var(--card-col) 55%, transparent),
             0 0 28px color-mix(in srgb, var(--card-col) 26%, transparent);
}
.card.sel::before{ opacity:1; }
.card.sel .card-icon{ border-color:color-mix(in srgb, var(--card-col) 55%, transparent); }
.card.sel .card-key{ color:var(--card-col); }

/* ---- the calibration: space bar, aether, the orders, the way out --------- */
.tut-key.tut-inline.k-space{ width:auto; padding:0 9px; font-size:calc(9.5px * var(--ts)); letter-spacing:2px; }
.tut-sub b{ color:var(--gold); font-weight:600; }
/* A tiny aether bar: it drains, then refills — the whole story of a heavy
   weapon told in one loop, no words. */
/* THE SAME BAR THE HUD DRAWS, not a second one that happens to mean the same
   thing. It used to be a blue capsule while the HUD's aether was a flat gold
   rule, and the portal reviewer quite reasonably asked whether they were even
   the same resource. Every value here is now taken from the `.bar` rules
   above: the well, the 6px height, the square ends, `--ae`, and the label at
   `.bar-name`'s size and tracking. */
.tut-aether{
  display:flex; align-items:center; gap:10px; margin:2px 0 1px;
  font-size:calc(8.5px * var(--ts)); letter-spacing:3.2px; text-transform:uppercase;
  color:rgba(244,241,230,.50);
}
.tut-aether-track{
  width:132px; height:6px; overflow:hidden;
  background:var(--hud-well);
  border-bottom:1px solid rgba(244,241,230,.16);
}
.tut-aether-track i{
  display:block; height:100%;
  background:var(--ae);
  transform-origin:left center;
  animation:tut-aether 2.6s cubic-bezier(.4,0,.2,1) infinite;
}
@keyframes tut-aether{
  0%{ transform:scaleX(1); } 22%{ transform:scaleX(.2); } 34%{ transform:scaleX(.2); }
  88%{ transform:scaleX(1); } 100%{ transform:scaleX(1); }
}

/* The way out: a pill at the corner, always reachable, never in the way. */
/* TOP RIGHT, the one corner nothing else uses during play. It sat bottom right
   above a "key hint" that has since become the control legend, and it was
   drawn straight across the legend's CYCLE and SUSTAINED FIRE rows — in the
   very screenshot the portal sent about the cards. */
.tut-skip{
  position:absolute; right:22px; top:14px; z-index:2;
  pointer-events:auto; cursor:pointer;
  padding:9px 16px; font-family:inherit; font-size:calc(9.5px * var(--ts)); font-weight:600;
  letter-spacing:2.6px; text-transform:uppercase; color:var(--menu-dim);
  background:rgba(6,13,17,.6); border:1px solid var(--menu-line); border-radius:999px;
  backdrop-filter:blur(4px); -webkit-backdrop-filter:blur(4px);
  opacity:0; transform:translateY(-8px);
  transition:opacity .4s ease, transform .4s cubic-bezier(.22,1,.36,1), color .18s, border-color .18s;
}
.tut-skip.on{ opacity:1; transform:none; }
.tut-skip:hover{ color:var(--paper); border-color:var(--menu-line-hi); }
.tut-skip:focus-visible{ outline:2px solid var(--gold); outline-offset:2px; }

/* The orders: three goals, each one arriving a beat after the last. */
/* A BACKSTOP, AND ONLY ON THIS CARD. It is the one that grows — the goals, the
   readout legend and the OK that dismisses it — and a short window must never
   put the objective or its button out of reach. The step cards do NOT get this:
   their success tick is deliberately positioned outside the card (`.tut-check`,
   top:-13px right:-13px), so any overflow rule on them clips the tick off.
   Both axes are named because setting one makes the other compute to `auto`,
   which is a horizontal scrollbar under content that never scrolls sideways. */
.tut-final{
  min-width:min(540px, calc(92 * var(--vw))); padding:22px 34px 18px;
  max-height:calc(calc(100 * var(--vh)) - var(--boss-top) - 12px);
  overflow-y:auto; overflow-x:hidden; overscroll-behavior:contain;
}
.tut-goals{ display:flex; gap:14px; margin:8px 0 4px; }
.tut-goal{
  flex:1 1 0; min-width:130px; display:flex; flex-direction:column; align-items:center; gap:6px;
  padding:14px 12px 12px; border-radius:6px;
  background:rgba(244,241,230,.04); border:1px solid var(--menu-line);
  opacity:0; transform:translateY(10px);
  animation:tut-goalin .55s cubic-bezier(.22,1,.36,1) calc(.35s + var(--i, 0) * .22s) both;
}
@keyframes tut-goalin{ to{ opacity:1; transform:none; } }
.tut-goal-ico{ width:34px; height:34px; display:flex; margin-bottom:2px; }
.tut-goal-ico svg{ width:34px; height:34px; fill:none; stroke:var(--gold); stroke-width:1.6; stroke-linecap:round; stroke-linejoin:round; }
.tut-goal b{ font-size:calc(11px * var(--ts)); font-weight:600; letter-spacing:2.6px; text-transform:uppercase; color:var(--paper); }
.tut-goal span{ font-size:calc(11px * var(--ts)); line-height:1.5; text-align:center; color:var(--paper-dim); }
.tut-final-sub{ font-size:calc(12px * var(--ts)); letter-spacing:.4px; color:var(--menu-dim); }

/* The OK the portal asked for: the orders stay until it is pressed, and it
   does not arm until the card has been up long enough to have been read. */
.tut-actions{ display:flex; justify-content:center; margin-top:4px; }
.btn.tut-ok{ min-width:150px; padding:10px 30px; border-radius:999px; }
.btn.tut-ok[disabled]{ opacity:.4; cursor:default; }
.btn.tut-ok[disabled]:hover{ transform:none; }

/* ==========================================================================
   THE READOUT TOUR — one figure at a time, explained where it lives
   ==========================================================================
   A legend in a box is a key to a map the player is not looking at. This card
   goes to the readout instead: it parks under the chip it is describing, puts
   a gold pointer on it, and TRAVELS to the next one — `left` and `top` are
   transitioned, so it is one pointer walking the instrument rather than four
   cards taking turns. The chip itself lights, which is what makes the sentence
   and the thing it describes the same object. */
.tut-ro-card{
  position:absolute; z-index:6; pointer-events:auto;
  width:min(340px, calc(86 * var(--vw)));
  padding:13px 15px 11px;
  background:rgba(6,13,17,.90);
  border:1px solid rgba(231,184,81,.40); border-radius:8px;
  backdrop-filter:blur(5px) saturate(.95); -webkit-backdrop-filter:blur(5px);
  box-shadow:0 16px 46px rgba(0,0,0,.5);
  opacity:0; transform:translateY(-8px);
  transition:opacity .3s cubic-bezier(.22,1,.36,1),
             transform .3s cubic-bezier(.22,1,.36,1),
             left .42s cubic-bezier(.3,1.05,.35,1),
             top .42s cubic-bezier(.3,1.05,.35,1);
}
.tut-ro-card.on{ opacity:1; transform:none; }
.tut-ro-card.off{ opacity:0; transform:translateY(-6px); }
/* The hop, restarted on every beat so the travel is felt as well as seen. */
.tut-ro-card.step{ animation:tut-roStep .42s cubic-bezier(.3,1.05,.35,1); }
@keyframes tut-roStep{ 0%{ transform:translateY(-5px); } 100%{ transform:none; } }

/* The pointer. Placed against the CHIP rather than against the card, so a card
   pushed off centre by a narrow window still points at what it means. */
.tut-ro-arrow{
  position:absolute; top:-9px; margin-left:-9px; width:0; height:0;
  border-left:9px solid transparent; border-right:9px solid transparent;
  border-bottom:9px solid var(--gold-hot);
  filter:drop-shadow(0 -2px 5px rgba(231,184,81,.45));
  transition:left .42s cubic-bezier(.3,1.05,.35,1);
  animation:tut-roNod 1.5s ease-in-out infinite;
}
@keyframes tut-roNod{ 0%,100%{ margin-top:0; } 50%{ margin-top:-3px; } }

.tut-ro-head{ display:flex; align-items:baseline; gap:10px; }
.tut-ro-head b{
  font-size:calc(16px * var(--ts)); font-weight:600; letter-spacing:1.6px;
  color:var(--gold-hot); font-variant-numeric:tabular-nums;
}
.tut-ro-head span{
  font-size:calc(9.5px * var(--ts)); letter-spacing:3px; text-transform:uppercase; color:var(--menu-faint);
}
.tut-ro-text{ margin:8px 0 0; font-size:calc(12px * var(--ts)); line-height:1.6; color:var(--paper-dim); }
.tut-ro-foot{
  display:flex; align-items:center; justify-content:space-between;
  gap:12px; margin-top:11px;
}
.tut-ro-dots{ display:flex; gap:5px; }
.tut-ro-dots i{
  width:5px; height:5px; border-radius:50%;
  background:rgba(244,241,230,.22); transition:background .25s ease;
}
.tut-ro-dots i.on{ background:var(--gold-hot); }
.btn.tut-ro-next{ padding:7px 18px; font-size:calc(10px * var(--ts)); letter-spacing:2.4px; border-radius:999px; }
.btn.tut-ro-next[disabled]{ opacity:.4; cursor:default; }
.btn.tut-ro-next[disabled]:hover{ transform:none; }

/* The chip being talked about, in the real HUD. */
#hud-top .chip.tut-point{
  border-radius:5px; color:var(--gold-hot);
  background:rgba(231,184,81,.14);
  box-shadow:inset 0 0 0 1px rgba(231,184,81,.5), 0 0 20px rgba(231,184,81,.26);
  animation:tut-chipPulse 1.5s ease-in-out infinite alternate;
}
#hud-top .chip.tut-point .chip-label,
#hud-top .chip.tut-point > span{ color:var(--gold-hot); }
@keyframes tut-chipPulse{
  from{ box-shadow:inset 0 0 0 1px rgba(231,184,81,.34), 0 0 12px rgba(231,184,81,.16); }
  to{ box-shadow:inset 0 0 0 1px rgba(231,184,81,.72), 0 0 26px rgba(231,184,81,.38); }
}
@media (prefers-reduced-motion: reduce){
  .tut-ro-card, .tut-ro-arrow{ transition:opacity .2s ease; animation:none; }
  #hud-top .chip.tut-point{ animation:none; }
}

/* A hint card mid-run (the boss warning): the calibration's card, but it is
   NOT positioned like one. It is a notice, so it is laid out by the notice
   column with every other message (see #notices) — a static child, centred by
   the column, queued behind whatever is already up. Its own transform must
   therefore drop the translateX(-50%) that .tut-card centres itself with, or
   it would sit half a card to the left of the queue. */
.tut-card.tut-hint-card{
  position:relative; left:auto; top:auto; bottom:auto;
  width:100%; min-width:0; max-width:min(520px, 100%);
  transform:translateY(10px) scale(.97);
}
.tut-card.tut-hint-card.on{ transform:none; }
.tut-card.tut-hint-card.off{ transform:translateY(-10px) scale(.985); }
.tut-card.tut-hint-card .tut-title{ font-size:calc(20px * var(--ts)); letter-spacing:6px; color:#F0A99E; }

/* ---- the revive's third door ---------------------------------------------- */
.revive-btns{ flex-wrap:wrap; justify-content:center; }
.rv-core{ width:17px; height:17px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linejoin:round; }
.revive-btn:disabled, .revive-btn.poor{
  opacity:.45; cursor:default; border-style:dashed;
}
.revive-btn:disabled:hover, .revive-btn.poor:hover{ transform:none; background:rgba(244,241,230,.07); }
#revive.pending #revive-cores{ pointer-events:none; }
/* `hidden` has to beat the button's own display, or a blocked ad button
   stays on screen — the one thing the ad rules forbid. */
.revive-btn[hidden]{ display:none; }
.revive-note{
  font-size:calc(9.5px * var(--ts)); letter-spacing:2.2px; text-transform:uppercase;
  color:var(--menu-faint); margin-top:4px;
}

/* ---- run again, held until the interstitial settles ---------------------- */
.btn-spin{
  display:none; width:12px; height:12px; margin-right:9px; vertical-align:-1px;
  border:2px solid rgba(231,184,81,.25); border-top-color:var(--gold-hot); border-radius:50%;
  animation:btn-spin .8s linear infinite;
}
@keyframes btn-spin{ to{ transform:rotate(360deg); } }
#gameover.busy .btn{ pointer-events:none; opacity:.55; }
#gameover.busy #btn-again{ opacity:1; cursor:progress; }
#gameover.busy #btn-again .btn-spin{ display:inline-block; }
/* The draft while its midgame is in flight (UI._pick): the chosen card stays
   lit, everything else is inert, and ACTIVATE says why nothing is happening. */
#levelup.busy .card, #levelup.busy .btn{ pointer-events:none; }
#levelup.busy #btn-reroll{ opacity:.45; }
#levelup.busy #btn-activate{ cursor:progress; }
#levelup.busy #btn-activate .btn-spin{ display:inline-block; }

/* ---- the controls panel's footer ----------------------------------------- */
.ctl-foot{
  display:flex; align-items:center; justify-content:space-between; gap:14px;
  margin-top:18px; padding-top:14px; border-top:1px solid rgba(244,241,230,.06);
  font-size:calc(11.5px * var(--ts)); color:var(--menu-dim);
}

@media (prefers-reduced-motion: reduce){
  .lu-first, .tut-goal, .tut-aether-track i, .btn.lu-activate.ready,
  .btn.lu-activate.nudge, .btn-spin{ animation:none !important; }
  .tut-goal{ opacity:1; transform:none; }
  .tut-aether-track i{ transform:scaleX(.55); }
  .tut-skip{ transition:none; }
  .card.sel{ transform:none; }
  .btn-spin{ border-top-color:var(--gold-hot); border-color:var(--gold-hot); border-radius:2px; }
}

/* ---- the portal account, in the corner ----------------------------------- */
.menu-user{
  display:flex; align-items:center; gap:9px;
  font-size:calc(10px * var(--ts)); letter-spacing:1.6px; color:var(--menu-dim); text-transform:none;
}
.menu-user[hidden]{ display:none; }
.menu-user-pic{
  width:22px; height:22px; border-radius:50%; object-fit:cover;
  border:1px solid var(--menu-line-hi); background:rgba(244,241,230,.06);
}
.menu-user-pic[hidden]{ display:none; }
.menu-user-name{ color:var(--menu-text); }
.menu-user::before{
  content:""; width:6px; height:6px; border-radius:50%;
  background:#63D471; box-shadow:0 0 8px rgba(99,212,113,.5);
}

/* =============================================================================
 * THE PORTAL'S SMALL VIEWPORTS
 *
 * CrazyGames tests ten sizes. Six are under 700px tall, two (800×450 and
 * 821×462) are under 470. Every screen that matters — the menu with a panel
 * open, the draft, the calibration cards and the orders, the results card —
 * has to be complete inside those without a scrollbar and without covering
 * the machine. Two tiers: width (the menu keeps its two columns down to 700,
 * only a phone-shaped window stacks) and height (everything shrinks together
 * at 520, keeping its proportions, so nothing reads as "the small version").
 * ========================================================================== */

/* ---- 700–899 wide: two columns, tighter ---------------------------------- */
@media (max-width:899px) and (min-width:700px){
  .menu-grid{ grid-template-columns:minmax(200px, calc(30 * var(--vw))) 1fr; gap:0 22px; padding:20px 24px; }
  .brand-title{ font-size:calc(19px * var(--ts)); letter-spacing:5px; }
  .brand-title span{ letter-spacing:4.6px; }
  .nav-play{ padding:13px 20px 13px 18px; margin-bottom:12px; }
  .nav-item{ padding:7px 12px 7px 8px; }
  .menu-stage{ margin:6px 0; }
  .menu-corner{ right:20px; bottom:14px; gap:14px; }
}

/* ---- under 520 tall: the whole chrome, a size down ----------------------- */
@media (max-height:520px){
  /* menu */
  .menu-grid{ padding:14px 22px 12px; }
  .brand-eyebrow{ display:none; }
  .brand-title{ font-size:calc(18px * var(--ts)); }
  .nav-play{ padding:10px 18px 10px 16px; margin-bottom:8px; }
  .nav-item{ padding:5px 12px 5px 8px; }
  .menu-stage{ margin:4px 0; }
  .panel-head{ padding:12px 18px 8px; }
  .panel-head h2{ font-size:calc(18px * var(--ts)); margin-bottom:3px; letter-spacing:3px; }
  .panel-head.shop-headed{ padding-right:46px; row-gap:6px; }
  .shop-head{ padding:6px 12px; }
  .shop-wallet strong{ font-size:calc(19px * var(--ts)); }
  .panel-sub{ font-size:calc(11px * var(--ts)); line-height:1.4; }
  .panel-body{ padding:12px 18px 16px; }
  .menu-close{ top:8px; right:8px; width:28px; height:28px; }
  .menu-corner{ bottom:10px; }

  /* HUD — the plates size themselves from the space budget (#hud-bottom);
     only the padding this tier can still usefully say is said here. */
  #hud-top{ top:8px; }
  #vitals{ padding:8px 10px 9px; gap:7px; }
  #hud-bottom{ --hud-pad:10px; }
  /* The notice column needs no tier: it starts under the boss lane, and the
     boss lane is the same two constants at every size. */

  /* the draft: the card and its contents are viewport-relative now, so this
     tier only sets what is genuinely a short-screen decision. */
  .lu-level{ margin-top:3px; }
  .lu-first{ margin-top:5px; }
  .btn.lu-activate{ padding:9px 22px; min-width:176px; }
  .btn.tiny{ padding:7px 12px; }

  /* the calibration: the step cards size themselves from the height (see
     .tut-card) and need nothing here; the orders fit whole */
  .tut-sub{ line-height:1.5; }
  .tut-final{ padding:12px 20px 10px; gap:6px; min-width:min(520px, calc(92 * var(--vw))); }
  .tut-final .tut-title{ font-size:calc(20px * var(--ts)); letter-spacing:6px; }
  .tut-goals{ gap:8px; margin:4px 0 2px; }
  .tut-goal{ min-width:110px; padding:8px 8px 8px; gap:3px; }
  .tut-goal-ico, .tut-goal-ico svg{ width:24px; height:24px; }
  .tut-goal b{ font-size:calc(9.5px * var(--ts)); letter-spacing:2px; }
  .tut-goal span{ font-size:calc(10px * var(--ts)); line-height:1.4; }
  .tut-final-sub{ font-size:calc(10.5px * var(--ts)); }
  .tut-hint{ margin-top:0; }
  .btn.tut-ok{ padding:8px 24px; min-width:130px; }
  /* The tour card sits under a readout that has itself moved up; it stays the
     same card, just tighter. */
  .tut-ro-card{ width:min(300px, calc(88 * var(--vw))); padding:11px 13px 9px; }
  .tut-ro-head b{ font-size:calc(14px * var(--ts)); }
  .tut-ro-text{ margin-top:6px; font-size:calc(11px * var(--ts)); line-height:1.5; }
  .tut-ro-foot{ margin-top:9px; }
  .tut-skip{ padding:7px 12px; }

  /* the results card: five stats in a row, chips tight, actions pinned */
  .modal{ padding:18px 24px 16px; gap:12px; max-height:calc(calc(100 * var(--vh)) - 12px); }
  .modal .modal-actions{ margin:0 -24px -16px; padding:10px 24px 16px; bottom:-16px; }
  .go-stats{ grid-template-columns:repeat(5, 1fr); }
  .go-stat{ padding:8px 6px; }
  .go-stat div{ font-size:calc(17px * var(--ts)); margin-top:3px; }
  .go-section > label{ margin-bottom:5px; }
  .go-section + .go-section{ margin-top:-4px; }
  .chip-row{ min-height:22px; gap:6px; }
  .kit-chip{ padding:3px 7px; font-size:calc(10px * var(--ts)); }

  /* the second chance */
  .revive-card{ gap:6px; }
  .revive-btn{ min-width:160px; padding:10px 16px; font-size:calc(11.5px * var(--ts)); }
}

/* ---- the menu tour: what the Shop and the Bestiary are for ---------------
 * Reuses the calibration's card so the two read as one voice. It waits for
 * the player: no timer, one button.
 *
 * IT IS CENTRED IN THE STAGE, AND ONLY THERE. It used to float against the
 * frame — right-anchored and vertically centred, then a media query moved it
 * to the bottom centre below 900px wide — which is two layouts for one card:
 * a Chromebook got a different screen from a desktop, and at 800×450 the
 * bottom-centred version sat across the very nav rows it was pointing at.
 * #menu-tour is a layer over the STAGE column of the menu grid, so the card
 * is placed by the grid at every size and cannot reach the nav.
 *
 * It yields to a panel rather than sitting on top of one: opening SHOP while
 * the card describes SHOP would otherwise cover the answer. */
#menu-tour{
  grid-area:stage; position:relative; z-index:4;
  display:flex; align-items:center; justify-content:center;
  padding:clamp(10px, calc(2 * var(--vh)), 26px) 0;
  pointer-events:none;
  transition:opacity .28s ease;
}
#menu.panel-open #menu-tour{ opacity:0; pointer-events:none; }
.tour-card{
  position:relative; left:auto; right:auto; top:auto; bottom:auto;
  width:min(420px, 100%); max-width:100%; min-width:0;
  transform:translateY(10px) scale(.97);
  align-items:flex-start; text-align:left;
  pointer-events:auto;
}
.tour-card.on{ transform:none; }
.tour-card.off{ transform:translateY(-10px) scale(.985); }
.tour-card .tut-title{ font-size:calc(20px * var(--ts)); letter-spacing:6px; padding-left:0; }
.tour-card .tut-sub{ text-align:left; line-height:1.65; }
.tour-card .tut-sub b{ color:var(--gold); font-weight:600; }
.btn.tour-next{ align-self:flex-end; margin-top:4px; border-radius:999px; }

/* The row being described, marked while its card is up. */
.nav-item.tour-lit{
  color:var(--paper); padding-left:14px; background:rgba(231,184,81,.10);
}
.nav-item.tour-lit::before{ height:66%; }
.nav-item.tour-lit .nav-idx{ color:var(--gold); }

/* No width tier for the tour card. It is placed by the menu grid now, so the
   grid's own breakpoints are the only ones it needs — a second placement is
   exactly what the portal reported as "a different position on Chromebook". */
@media (prefers-reduced-motion: reduce){
  .tour-card{ transition:opacity .2s ease; }
}

/* =============================================================================
 * KEY BINDINGS (the Controls panel — src/menu.js, src/controls.js)
 *
 * A slot is a button around a <kbd>, so the editor looks like the reference it
 * replaced and a bound key is still a key. Empty slots are dashed, the slot
 * that is waiting for a key is gold.
 * ========================================================================== */
.panel-body.controls > .ctl-help,
.panel-body.controls > .ctl-foot{ grid-column:1 / -1; }
.ctl-help{
  margin:0; max-width:70ch; line-height:1.65;
  font-size:calc(11.5px * var(--ts)); color:var(--menu-faint);
}
.bind-row dt{ display:flex; gap:6px; }
.bind-key{
  padding:0; margin:0; border:0; background:none; cursor:pointer;
  font:inherit; color:inherit; white-space:nowrap;
}
.bind-key kbd{
  min-width:36px; cursor:pointer;
  transition:border-color .15s ease, color .15s ease, background .15s ease;
}
.bind-key:hover kbd, .bind-key:focus-visible kbd{ border-color:var(--menu-line-hi); background:rgba(244,241,230,.12); }
.bind-key:focus-visible{ outline:1px solid var(--edge-hot); outline-offset:2px; }
.bind-key.empty kbd{ color:var(--menu-faint); border-style:dashed; }
.bind-key.listening kbd{ color:var(--gold-hot); border-color:var(--gold); background:rgba(231,184,81,.14); }

/* =============================================================================
 * REDUCE MOTION / REDUCE FLASHING (src/access.js puts the classes on <body>)
 *
 * The stylesheet's four @media (prefers-reduced-motion) blocks are switched by
 * the same setting — access.js rewrites their condition — so what follows is
 * only what those blocks never covered: the HUD's own slides, lifts and pulses.
 * Nothing here removes information, only the movement that delivers it.
 * ========================================================================== */
body.reduce-motion .menu-panel.shown,
body.reduce-motion .slot.ping,
body.reduce-motion #cursor.holding .cur-hold,
body.reduce-motion #boss-bar.warning #boss-warn{ animation:none; }
body.reduce-motion .slot,
body.reduce-motion .slot.sel,
body.reduce-motion .slot:not(.empty):hover{ transform:none; transition:border-color .2s, background .2s; }
body.reduce-motion .banner,
body.reduce-motion .toast{ transform:none; transition:opacity .25s ease; }
body.reduce-motion #boss-bar{ transform:translateX(-50%); transition:opacity .3s ease; }
body.reduce-motion .menu-stage,
body.reduce-motion #menu.panel-open .menu-stage{ transform:none; transition:opacity .2s ease; }

body.reduce-flash #hud.emp,
body.reduce-flash #ae-bar.flash .bar-track,
body.reduce-flash #boss-bar.warning #boss-warn{ animation:none; }
