/* ═══════════════════════════════════════════════════════════════════════════
   GILBERT'S ARCADE — shared design system
   ───────────────────────────────────────────────────────────────────────────
   Concept: a dark room full of lit marquees.

   The shell is monochrome and disciplined. Colour enters only as the light a
   cabinet throws — a hairline glow in each game's own hue — never as a filled
   card. Sixteen games stay distinguishable without the select screen turning
   into a bag of coloured rectangles.

   Grounded in three references (styles.refero.design):
     · Ciridae      — PRIMARY. Void canvas, accent as hairline pulse and never a
                      fill, surfaces separated by tonal step + 1px hairline,
                      zero shadows, three locked type registers, pill = control
                      and rounded-rect = container.
     · Slash        — BORROWED, one job only: the gilded gradient, reserved here
                      for the marquee wordmark and the new-record badge. Never
                      on a button, never as a surface.
     · Active Theory— BORROWED, one job only: frosted translucency
                      (rgba fill + backdrop-blur) as the sole elevation device
                      for overlays. Their unhurried scene pacing is deliberately
                      NOT taken — an arcade should answer instantly.

   Rules that hold everywhere in here:
     · No box-shadow. Depth is tonal step, hairline, and glow.
     · No indigo/violet.
     · Accent is a light source, not a fill.
     · Motion is 120–260ms. Nothing in a game should feel unhurried.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ---- self-hosted type. Nothing here may reach the network at runtime. ---- */
@font-face{
  font-family:'Barlow Condensed';font-style:normal;font-weight:400;font-display:swap;
  src:url('bc-400.woff2') format('woff2');
  unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face{
  font-family:'Barlow Condensed';font-style:normal;font-weight:600;font-display:swap;
  src:url('bc-600.woff2') format('woff2');
  unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

:root{
  /* — surface ladder (tonal step only, per Ciridae) — */
  --void:#06070a;          /* page canvas, shared with the HQ hub */
  --abyss:#040508;         /* pushed-forward bars: header, dock */
  --cabinet:#0e1016;       /* cabinet body / panel */
  --cabinet-2:#14171f;     /* inset screen well, raised control */

  /* — hairlines — */
  --line:rgba(255,255,255,.08);
  --line-2:rgba(255,255,255,.16);
  --line-3:rgba(255,255,255,.28);

  /* — ink — */
  --ink:#f4f6fb;           /* headings, primary */
  --ink-2:#c7c9d1;         /* body */
  --muted:#9aa3b5;         /* labels, secondary */
  /* Measured, not guessed. The hub's equivalent grey (#5c6477) lands at 3.4:1
     on this canvas, below the 4.5:1 body threshold — and in here it carries
     real copy (every game's hint line), not just decoration. Lifted until it
     clears on BOTH backgrounds it sits on: 4.82:1 on --void, 4.55:1 on
     --cabinet, while staying clearly quieter than --muted at 7.9:1. */
  --faint:#727c93;         /* metadata, hints, disabled */

  /* — the rationed warm notes — */
  --ember:#e8913a;         /* hairline glow, marquee light. NEVER a fill. */
  --copper:#cc9166;        /* genre eyebrow labels only (Slash's exact role) */
  --gilded:linear-gradient(103deg,#ae9357,#fff0cc 40%,#ae9357 70%,#bd9d4f);
  --felt:#46a06a;          /* affirmative state */
  --alarm:#e0574f;         /* destructive / mine / bust */

  /* — per-game accent —
     A game sets --accent on :root (Arcade.init does it), so these derived
     values resolve correctly there. But a custom property declared HERE always
     resolves its inner var() against THIS element, so an element that overrides
     --accent further down the tree (each .cab does) would still get the root
     ember in --accent-dim. Anything setting --accent below :root must set all
     three together — see .cab in the arcade grid. */
  --accent:#e8913a;
  --accent-dim:color-mix(in srgb,var(--accent) 40%,transparent);
  --accent-ghost:color-mix(in srgb,var(--accent) 12%,transparent);

  /* — shape encodes function (Ciridae): pill = you can touch it — */
  --pill:999px;
  --r-panel:14px;          /* content container */
  --r-inset:10px;          /* screen well inside a container */

  /* — type registers. Never cross them. — */
  --chrome:'Barlow Condensed',ui-sans-serif,system-ui,sans-serif; /* UI, uppercase */
  --body:-apple-system,BlinkMacSystemFont,'SF Pro Text','Segoe UI',system-ui,sans-serif;
  --data:ui-monospace,SFMono-Regular,'SF Mono',Menlo,monospace;    /* scores, timers */

  --ease:cubic-bezier(.4,0,.2,1);
  --spring:cubic-bezier(.2,1.1,.3,1);

  /* Safe-area, resolved once. In LANDSCAPE on a notched iPhone the non-zero
     insets are left/right — a layout that only pads the top is broken there. */
  --sa-t:env(safe-area-inset-top,0px);
  --sa-r:env(safe-area-inset-right,0px);
  --sa-b:env(safe-area-inset-bottom,0px);
  --sa-l:env(safe-area-inset-left,0px);
}

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

html{
  -webkit-text-size-adjust:100%;
  /* Stop the whole document rubber-banding under a game board. */
  overscroll-behavior:none;
}

body{
  font-family:var(--body);
  background:var(--void);
  color:var(--ink);
  line-height:1.5;
  -webkit-font-smoothing:antialiased;
  min-height:100vh;          /* fallback first … */
  min-height:100dvh;         /* … then the one that survives mobile chrome */
  overscroll-behavior:none;
  /* Tap highlight is a browser default that makes a custom game feel cheap. */
  -webkit-tap-highlight-color:transparent;
}

/* The room's ambient light: one warm pool, top-centre, as if a marquee above
   the cabinets were lit. Fixed so it never scrolls, and behind everything. */
body::before{
  content:"";position:fixed;inset:0;z-index:-2;pointer-events:none;
  background:
    radial-gradient(90ch 60vh at 50% -12vh,rgba(232,145,58,.10),transparent 70%),
    radial-gradient(70ch 50vh at 50% 108vh,rgba(70,183,212,.05),transparent 70%);
}
/* Vignette. Sells "dark room" and stops the corners feeling flat. */
body::after{
  content:"";position:fixed;inset:0;z-index:-1;pointer-events:none;
  background:radial-gradient(120% 90% at 50% 45%,transparent 55%,rgba(0,0,0,.55));
}

a{color:inherit;text-decoration:none}

/* ── focus. One ring, everywhere, always visible on keyboard. ── */
:focus{outline:none}
:focus-visible{
  outline:2px solid var(--accent);
  outline-offset:2px;
  border-radius:4px;
}

/* ═══ TYPE REGISTERS ═══════════════════════════════════════════════════════
   brand voice  = Barlow Condensed, UPPERCASE, tracked out. Chrome and labels.
   body voice   = system sans, mixed case. Prose and in-game copy.
   system voice = mono. Scores, timers, counts — anything numeric and live.
   A score in the body face, or a sentence in the chrome face, reads broken. */

.chrome,.arc-hd h1,.cab-name,.arc-btn,.eyebrow,.arc-modal h2{
  font-family:var(--chrome);
  text-transform:uppercase;
  letter-spacing:.06em;
  font-weight:600;
  line-height:1.1;
}
.data,.cab-best b,.arc-score b,.arc-stat b{
  font-family:var(--data);
  font-variant-numeric:tabular-nums;
  letter-spacing:-.01em;
}
.eyebrow{
  font-size:10.5px;letter-spacing:.16em;color:var(--copper);font-weight:600;
}

/* ═══ LAYOUT SHELL ═════════════════════════════════════════════════════════ */

.arc-wrap{
  width:100%;
  max-width:1100px;
  margin:0 auto;
  padding-left:max(16px,var(--sa-l));
  padding-right:max(16px,var(--sa-r));
  padding-bottom:calc(28px + var(--sa-b));
}

/* ── the game shell ───────────────────────────────────────────────────────
   Every game is <body class="arc-app"><header class="arc-hd"><div class="stage">.
   The stage takes whatever height is left after the header, measured rather than
   guessed. Subtracting a hardcoded header height (calc(100dvh - 60px)) is the
   bug this exists to prevent: the header is taller than you think once the
   safe-area inset is added, so the board silently gets pushed off the bottom of
   the screen on exactly the device that matters. */
.arc-app{
  display:flex;flex-direction:column;
  height:100vh;height:100dvh;
  overflow:hidden;                  /* the shell never scrolls; boards fit */
}
.arc-app > .arc-hd{position:static;flex:none}
.arc-app > .stage{
  flex:1 1 auto;min-height:0;       /* min-height:0 or flex children refuse to shrink */
  display:flex;flex-direction:column;align-items:center;justify-content:center;
  gap:14px;
  padding:12px max(14px,var(--sa-r)) calc(12px + var(--sa-b)) max(14px,var(--sa-l));
}
@media (orientation:landscape) and (max-height:560px){
  .arc-app > .stage{flex-direction:row;gap:20px;padding-top:8px;padding-bottom:8px}
}

/* ── header: back · title · score · gear ─────────────────────────────────── */
.arc-hd{
  position:sticky;top:0;z-index:40;
  display:flex;align-items:center;gap:12px;
  padding:calc(var(--sa-t) + 10px) max(14px,var(--sa-r)) 10px max(14px,var(--sa-l));
  background:color-mix(in srgb,var(--abyss) 82%,transparent);
  backdrop-filter:blur(14px) saturate(1.3);
  -webkit-backdrop-filter:blur(14px) saturate(1.3);
  border-bottom:1px solid var(--line);
}
/* min-width:0 lets a flex item shrink below its content width — without it the
   title refuses to give ground and pushes the gear off a 320px screen. */
/* 16.5px/.05em rather than 17/.09: the longest names (Backgammon, Minesweeper)
   were truncating at 390px purely on letter-spacing. Tracking is cheaper to
   give up than the name of the game. */
.arc-hd h1{
  font-size:16.5px;margin-right:auto;letter-spacing:.05em;
  min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
}
.arc-hd h1.long{font-size:14.5px;letter-spacing:.03em}
@media (max-width:400px){ .arc-hd h1.long{font-size:13px} }
/* The subtitle is status, not identity — let it ellipsis on its own rather than
   widening the header and pushing the game's name out. */
.arc-hd .sub{
  font-family:var(--data);font-size:10.5px;color:var(--faint);
  text-transform:none;letter-spacing:0;display:block;margin-top:2px;font-weight:400;
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:100%;
}

/* icon control. Pill, ghost, hairline — never filled. */
.arc-ico{
  flex:none;display:grid;place-items:center;
  width:44px;height:44px;border-radius:var(--pill);   /* touch-target floor */
  border:1px solid var(--line-2);background:transparent;color:var(--ink-2);
  cursor:pointer;transition:border-color .18s var(--ease),color .18s var(--ease),transform .18s var(--spring);
}
.arc-ico:hover{border-color:var(--line-3);color:var(--ink)}
.arc-ico:active{transform:scale(.93)}
.arc-ico svg{width:17px;height:17px;stroke:currentColor;fill:none;stroke-width:2.2;
  stroke-linecap:round;stroke-linejoin:round}

/* live score readout in the header — mono, right-aligned, tabular */
.arc-score{display:flex;gap:14px;align-items:baseline;flex:none}
.arc-score span{font-size:9.5px;letter-spacing:.14em;color:var(--faint);
  font-family:var(--chrome);text-transform:uppercase;display:block}
/* nowrap matters: a value like "0 wins" or "0 moves" otherwise breaks onto a
   second line, doubling the header height and squeezing the game title into an
   ellipsis on a perfectly wide screen. */
.arc-score b{font-size:16px;font-weight:600;color:var(--ink);display:block;white-space:nowrap}
.arc-score b.rec{
  background:var(--gilded);-webkit-background-clip:text;background-clip:text;
  -webkit-text-fill-color:transparent;
}

/* ═══ CABINET GRID (the select screen) ═════════════════════════════════════
   A cabinet IS a card, and that is legitimate here: the whole tile is the tap
   target. It earns its container. */

.cabs{
  display:grid;
  grid-template-columns:repeat(auto-fill,minmax(154px,1fr));
  gap:14px;
  margin-top:18px;
}

.cab{
  position:relative;overflow:hidden;
  display:flex;flex-direction:column;
  border:1px solid var(--line);
  border-radius:var(--r-panel);
  background:var(--cabinet);
  padding:0 0 12px;
  cursor:pointer;
  isolation:isolate;
  transition:border-color .22s var(--ease),transform .22s var(--spring);
}
.cab:hover{border-color:var(--line-2);transform:translateY(-3px)}
.cab:active{transform:translateY(0) scale(.985)}

/* The marquee: a lit strip at the top of every cabinet, in that game's hue.
   This is the ONLY place a game's colour appears on the select screen, and it
   appears as light — a glow and a hairline — not as a fill. */
.cab-marquee{
  position:relative;height:36px;flex:none;
  display:grid;place-items:center;padding:0 8px;
  border-bottom:1px solid var(--accent-dim);
  background:
    linear-gradient(180deg,var(--accent-ghost),transparent),
    var(--abyss);
}
.cab-marquee::after{         /* the filament itself */
  content:"";position:absolute;left:14%;right:14%;bottom:-1px;height:1px;
  background:var(--accent);
  box-shadow:0 0 12px 1px var(--accent),0 0 30px 2px var(--accent-dim);
  opacity:.85;
}
/* Scanline texture — rationed to the marquee strip alone. Across a whole page
   it is costume; across a lit sign it is the sign. */
.cab-marquee::before{
  content:"";position:absolute;inset:0;pointer-events:none;opacity:.5;
  background:repeating-linear-gradient(180deg,rgba(0,0,0,.34) 0 1px,transparent 1px 3px);
}
/* The marquee carries the game's NAME — that is what a marquee is for. An
   abbreviation here reads as a rendering bug, not a design choice. Tracking and
   size step down for longer names so nothing ever truncates. */
.cab-glyph{
  font-family:var(--chrome);font-weight:600;font-size:14px;letter-spacing:.18em;
  text-transform:uppercase;color:var(--accent);position:relative;z-index:1;
  text-shadow:0 0 14px var(--accent-dim);
  white-space:nowrap;
}
.cab-glyph.m   {font-size:12.5px;letter-spacing:.11em}   /* 8–10 chars */
.cab-glyph.l   {font-size:11px;letter-spacing:.05em}     /* 11+ chars  */

/* attract-mode well — a small live preview of the game, inset like a screen */
.cab-screen{
  margin:12px 12px 10px;height:74px;flex:none;
  border-radius:var(--r-inset);
  border:1px solid var(--line);
  background:var(--abyss);
  overflow:hidden;position:relative;
  display:grid;place-items:center;
}

.cab-meta{padding:9px 13px 0;display:flex;align-items:baseline;gap:7px;
  flex-wrap:wrap;justify-content:space-between}
.cab-best{font-family:var(--data);font-size:11px;color:var(--faint)}
.cab-best b{color:var(--muted);font-weight:600}
.cab-best.rec b{background:var(--gilded);-webkit-background-clip:text;background-clip:text;
  -webkit-text-fill-color:transparent}

/* ═══ PLAYFIELD ════════════════════════════════════════════════════════════
   Any game board goes inside this. It kills the browser gestures that fight
   with game input: double-tap zoom, text selection on a long press, and the
   rubber-band that makes a swipe feel like the page is loose. */
.playfield{
  touch-action:none;
  -webkit-user-select:none;user-select:none;
  -webkit-touch-callout:none;
  overscroll-behavior:contain;
  position:relative;
}

/* ═══ DEPTH — for INSIDE a playfield only ══════════════════════════════════
   The shell refuses shadows on purpose. A game board is the one place that rule
   is wrong: tiles, cards and dice are physical objects, and a board rendered as
   flat coloured rectangles reads as a wireframe rather than a game.

   So depth lives here, and it comes from MATERIAL, not from motion — a rim of
   light along the top edge, a graded face, a real shadow underneath, a genuine
   3D flip when a card turns over. That reads as craft. Piling on more moving
   parts reads as a screensaver.

   These classes are only valid inside .playfield. Do not use them on chrome. */

:root{
  /* one light source, high and slightly front-left, consistent everywhere */
  --lift-1:0 1px 2px rgba(0,0,0,.45);
  --lift-2:0 2px 4px rgba(0,0,0,.5), 0 6px 14px -6px rgba(0,0,0,.6);
  --lift-3:0 4px 8px rgba(0,0,0,.55), 0 16px 32px -12px rgba(0,0,0,.7);
  --rim:inset 0 1px 0 rgba(255,255,255,.16);      /* top edge catching light */
  --rim-dark:inset 0 -1px 0 rgba(0,0,0,.28);      /* bottom edge in shade */
}

/* A physical playing piece: tile, card, die, chip, peg. */
.piece{
  position:relative;
  box-shadow:var(--rim),var(--rim-dark),var(--lift-2);
  background-image:linear-gradient(180deg,rgba(255,255,255,.10),rgba(0,0,0,.10));
}
.piece.flat{box-shadow:var(--rim),var(--lift-1)}   /* settled / background piece */
.piece.raised{box-shadow:var(--rim),var(--rim-dark),var(--lift-3)}  /* held / active */

/* An inset well the pieces sit in — the opposite lighting, so the board reads
   as carved out rather than stacked on. */
.well{
  background:var(--abyss);
  box-shadow:inset 0 2px 6px rgba(0,0,0,.55), inset 0 -1px 0 rgba(255,255,255,.05);
}

/* Very slight perspective. Enough that pieces feel like they have a top face,
   not so much that the board looks like a 2005 album cover. Keep the angle
   under 6deg; past that, text on the far edge starts to blur. */
.board3d{perspective:1100px;perspective-origin:50% 42%}
.board3d > *{transform:rotateX(3.2deg);transform-style:preserve-3d}

/* Card flip. Genuinely 3D — a card turning over is the clearest case in the
   whole arcade for real depth rather than a cross-fade. */
.flip{transform-style:preserve-3d;transition:transform .26s var(--ease)}
.flip.face-down{transform:rotateY(180deg)}
.flip .face{
  position:absolute;inset:0;backface-visibility:hidden;-webkit-backface-visibility:hidden;
  border-radius:inherit;
}
.flip .face.back{transform:rotateY(180deg)}

/* Die tumble. One turn, lands flat, no spinning-forever nonsense. */
@keyframes tumble{
  0%  {transform:rotateX(0) rotateY(0)}
  100%{transform:rotateX(360deg) rotateY(180deg)}
}
.tumble{animation:tumble .42s var(--ease)}

@media (prefers-reduced-motion:reduce){
  .board3d > *{transform:none}
  .flip{transition:none}
  .tumble{animation:none}
}
/* Depth is decoration for a screen reader and a liability in high contrast. */
@media (forced-colors:active){
  .piece,.piece.raised,.piece.flat,.well{box-shadow:none;background-image:none}
  .board3d > *{transform:none}
}

/* ═══ CONTROLS ═════════════════════════════════════════════════════════════
   Pill = interactive. Rounded-rect = content. Never mixed. (Ciridae) */

.arc-btn{
  display:inline-flex;align-items:center;justify-content:center;gap:8px;
  min-height:44px;padding:0 22px;       /* 44px is the touch-target floor */
  border-radius:var(--pill);
  border:1px solid var(--line-2);
  background:transparent;color:var(--ink);
  font-size:13.5px;cursor:pointer;
  transition:border-color .18s var(--ease),background .18s var(--ease),transform .16s var(--spring);
}
.arc-btn:hover{border-color:var(--line-3);background:rgba(255,255,255,.04)}
.arc-btn:active{transform:scale(.96)}
.arc-btn[disabled]{opacity:.4;cursor:not-allowed;transform:none}

/* The one emphatic control. Scarce on purpose — at most one per screen, per
   Slash's rule about the white pill. Here it is lit in the game's own hue. */
.arc-btn.go{
  border-color:var(--accent);
  color:var(--accent);
  background:var(--accent-ghost);
  box-shadow:0 0 22px -6px var(--accent);
}
.arc-btn.go:hover{background:color-mix(in srgb,var(--accent) 20%,transparent)}
.arc-btn.danger{border-color:color-mix(in srgb,var(--alarm) 55%,transparent);color:var(--alarm)}

.arc-row{display:flex;gap:10px;flex-wrap:wrap;align-items:center;justify-content:center}

/* ═══ OVERLAYS — frosted, per Active Theory. The only elevation device. ═════ */
.arc-scrim{
  position:fixed;inset:0;z-index:90;
  display:grid;place-items:center;
  padding:calc(var(--sa-t) + 16px) max(16px,var(--sa-r)) calc(var(--sa-b) + 16px) max(16px,var(--sa-l));
  background:rgba(2,3,5,.62);
  backdrop-filter:blur(7px);-webkit-backdrop-filter:blur(7px);
  animation:arc-fade .18s var(--ease);
}
.arc-modal{
  width:min(420px,100%);
  max-height:100%;overflow-y:auto;
  border:1px solid var(--line-2);
  border-radius:var(--r-panel);
  background:var(--cabinet);
  padding:24px 22px;
  animation:arc-pop .22s var(--spring);
}
.arc-modal h2{font-size:18px;margin-bottom:10px;letter-spacing:.08em}
.arc-modal p{color:var(--ink-2);font-size:14.5px;margin-bottom:8px}
.arc-modal .arc-row{margin-top:20px}

@keyframes arc-fade{from{opacity:0}to{opacity:1}}
@keyframes arc-pop{from{opacity:0;transform:translateY(10px) scale(.98)}to{opacity:1;transform:none}}

/* settings rows */
.arc-set{display:flex;align-items:center;justify-content:space-between;gap:14px;
  padding:13px 0;border-bottom:1px solid var(--line)}
.arc-set:last-of-type{border-bottom:0}
.arc-set label{font-size:14.5px;color:var(--ink)}
.arc-set small{display:block;color:var(--faint);font-size:12px;margin-top:2px}
.arc-sw{
  flex:none;width:48px;height:29px;border-radius:var(--pill);cursor:pointer;
  border:1px solid var(--line-2);background:rgba(255,255,255,.05);
  position:relative;transition:background .2s var(--ease),border-color .2s var(--ease);
}
.arc-sw::after{
  content:"";position:absolute;top:3px;left:3px;width:21px;height:21px;
  border-radius:50%;background:var(--muted);transition:transform .2s var(--spring),background .2s var(--ease);
}
.arc-sw[aria-checked="true"]{background:var(--accent-ghost);border-color:var(--accent)}
.arc-sw[aria-checked="true"]::after{transform:translateX(19px);background:var(--accent)}

/* toast */
.arc-toast{
  position:fixed;left:50%;bottom:calc(22px + var(--sa-b));z-index:95;
  transform:translateX(-50%);
  padding:11px 20px;border-radius:var(--pill);
  border:1px solid var(--line-2);
  background:rgba(10,12,17,.9);
  backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);
  font-size:13.5px;color:var(--ink);white-space:nowrap;
  animation:arc-toast-in .22s var(--spring);
}
@keyframes arc-toast-in{from{opacity:0;transform:translate(-50%,12px)}to{opacity:1;transform:translate(-50%,0)}}

/* the new-record badge — the second and last home of the gilded gradient */
.arc-rec{
  display:inline-block;padding:3px 11px;border-radius:var(--pill);
  border:1px solid rgba(174,147,87,.5);
  font-family:var(--chrome);font-size:10.5px;letter-spacing:.16em;text-transform:uppercase;
  background:var(--gilded);-webkit-background-clip:text;background-clip:text;
  -webkit-text-fill-color:transparent;
}

/* Gilbert, when he is the opponent */
.gilbert{width:56px;height:56px;flex:none;border-radius:50%;
  border:1px solid var(--line-2);background:var(--abyss);overflow:hidden}
.gilbert svg{width:100%;height:100%;display:block}
.gilbert-say{
  font-size:13.5px;color:var(--ink-2);font-style:normal;
  border-left:2px solid var(--accent-dim);padding-left:11px;min-height:1.5em;
}

/* ═══ ORIENTATION ══════════════════════════════════════════════════════════
   Landscape on a phone is short and wide (a 390x844 device becomes 844x390).
   The failure mode is squeezing the portrait column until the board is
   unreadable. Instead the shell goes side-by-side and the chrome shrinks.
   Games opt in with .arc-stage / .arc-side. */

.arc-stage{
  display:flex;flex-direction:column;align-items:center;gap:16px;
  padding-top:16px;
}
.arc-side{display:contents}   /* portrait: HUD flows inline, no extra box */

@media (orientation:landscape) and (max-height:560px){
  .arc-hd{padding-top:calc(var(--sa-t) + 5px);padding-bottom:5px}
  .arc-hd h1{font-size:14px}
  .arc-hd .sub{display:none}       /* no room, and it is the least important */
  /* Deliberately NOT shrunk below 44px. Landscape is where thumbs are most
     cramped against the screen edge; a smaller target here is exactly wrong. */

  .arc-stage{
    flex-direction:row;
    align-items:center;
    justify-content:center;
    gap:22px;
    padding-top:8px;
  }
  /* HUD becomes a proper column beside the board instead of stacking above it */
  .arc-side{
    display:flex;flex-direction:column;gap:10px;
    min-width:118px;max-width:190px;
  }
  .cabs{grid-template-columns:repeat(auto-fill,minmax(148px,1fr))}
  .arc-modal{padding:18px 20px}
  .arc-modal h2{font-size:16px}
}

/* very small phones in portrait */
@media (max-width:359px){
  .cabs{grid-template-columns:repeat(auto-fill,minmax(132px,1fr));gap:11px}
  .cab-screen{height:62px}

  /* Three 44px controls + a two-column score readout does not fit across a
     320px screen. The touch targets are the one thing that must NOT shrink, so
     the space comes out of the chrome around them: tighter gaps, smaller title,
     and the SCORE/BEST captions drop (the numbers still carry the meaning). */
  .arc-hd{gap:6px;padding-left:max(8px,var(--sa-l));padding-right:max(8px,var(--sa-r))}
  .arc-hd h1{font-size:14px;letter-spacing:.05em}
  .arc-hd .sub{font-size:9.5px}
  .arc-score{gap:9px}
  .arc-score span{display:none}
  .arc-score b{font-size:14px}
}

/* tablet and up: cabinets get roomier, never stretched */
@media (min-width:760px){
  .cabs{grid-template-columns:repeat(auto-fill,minmax(186px,1fr));gap:18px}
  .cab-screen{height:96px}
  .cab-marquee{height:38px}
}

/* ═══ LAUNCH TRANSITION ════════════════════════════════════════════════════
   Opening a game should feel like opening an app, not like following a link.

   These are separate HTML documents, so this uses cross-document View
   Transitions: the browser snapshots the outgoing page, loads the next one, and
   animates between them. Supported in Safari 18+ and Chrome 126+. Where it is
   not supported nothing breaks — you simply get a plain navigation, plus the
   .arc-app entry animation below as a floor.

   Forward (arcade -> game) reads as pushing IN: the room falls back, the game
   rises to meet you. Back reads as the reverse. arcade.js sets .nav-back on
   <html> during a back/forward navigation so the pairing stays honest. */
@view-transition{ navigation:auto }

::view-transition-group(root){ animation-duration:.34s }
::view-transition-old(root),
::view-transition-new(root){
  animation-timing-function:cubic-bezier(.32,.72,0,1);
  mix-blend-mode:normal;         /* default plus-lighter blows out on dark */
}

/* Forward. The outgoing layer clears quickly and the incoming one starts a beat
   later: two long cross-fades over a near-black canvas read as a smear, because
   both layers are dark and neither reads as "on top". A fast handoff is what
   makes it feel like a swap rather than a dissolve. */
::view-transition-old(root){ animation:vt-out-back .18s cubic-bezier(.4,0,1,1) both }
::view-transition-new(root){ animation:vt-in-fwd .30s .05s both }
@keyframes vt-out-back{
  from{opacity:1;transform:scale(1)}
  to  {opacity:0;transform:scale(.965)}
}
@keyframes vt-in-fwd{
  from{opacity:0;transform:scale(1.035)}
  to  {opacity:1;transform:scale(1)}
}

/* back — same motion, mirrored, so returning feels like closing */
html.nav-back::view-transition-old(root){ animation:vt-out-fwd .18s cubic-bezier(.4,0,1,1) both }
html.nav-back::view-transition-new(root){ animation:vt-in-back .30s .05s both }
@keyframes vt-out-fwd{
  from{opacity:1;transform:scale(1)}
  to  {opacity:0;transform:scale(1.04)}
}
@keyframes vt-in-back{
  from{opacity:0;transform:scale(.97)}
  to  {opacity:1;transform:scale(1)}
}

/* The floor, for browsers with no View Transitions: the game shell still
   arrives rather than snapping in. Cheap, and it never blocks input. */
@keyframes arc-enter{
  from{opacity:0;transform:translateY(6px) scale(.994)}
  to  {opacity:1;transform:none}
}
.arc-app{animation:arc-enter .26s cubic-bezier(.32,.72,0,1) both}

/* The cabinet acknowledges the tap before the page turns over. Without this
   there is a dead beat between finger-down and the transition starting, which
   is what makes a web app feel like a website. */
.cab.launching{
  transform:scale(.97);
  border-color:var(--accent);
  transition:transform .13s var(--ease),border-color .13s var(--ease);
}
.cab.launching .cab-marquee::after{
  opacity:1;
  box-shadow:0 0 20px 2px var(--accent),0 0 46px 6px var(--accent-dim);
}

/* ═══ REDUCED MOTION ═══════════════════════════════════════════════════════
   Cut decoration, keep the interface responsive. JS-driven animation must also
   check Arcade.reducedMotion. */
@media (prefers-reduced-motion:reduce){
  *,*::before,*::after{
    animation-duration:.01ms !important;animation-iteration-count:1 !important;
    transition-duration:.01ms !important;scroll-behavior:auto !important;
  }
  .cab:hover{transform:none}
  .cab.launching{transform:none}
  /* A cross-document view transition ignores the blanket rule above, so the
     scale has to be cancelled explicitly or it still zooms. */
  ::view-transition-old(root),::view-transition-new(root){animation:none !important}
}

/* ═══ FORCED COLORS / high contrast ════════════════════════════════════════ */
@media (forced-colors:active){
  .cab,.arc-btn,.arc-ico,.arc-modal{border:1px solid ButtonBorder}
  .cab-marquee::after{display:none}
}

/* utility */
.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;
  clip:rect(0 0 0 0);white-space:nowrap;border:0}
.hide{display:none !important}

/* A cabinet whose game is not on disk yet: dark, unlit, not clickable. Better
   than a tile that looks live and lands on a 404. build_sw.py decides which. */
.cab.soon{
  cursor:default;opacity:.42;filter:saturate(.35);
}
.cab.soon:hover{transform:none;border-color:var(--line)}
.cab.soon .cab-marquee::after{box-shadow:none;opacity:.3}
