/* Family Maze — dark arcade cabinet look.
   The stage box preserves the game aspect ratio (must match CONFIG.GRID: 21 / 23), and
   Stage 5B sizes it from the viewport: `--tile-px` is the one number js/layout.js writes
   after measuring the HUD row, the D-pad, the inspector and the cabinet padding (Stage 5D.4b
   removed the gameplay instruction footer, so there is nothing left to measure there, and the
   number comes from the blocks that are actually in the page). That same number is what makes
   the HUD row as wide as the maze, which is why it is spelled `calc(var(--cols) * var(--tile-px))`
   here rather than remembered in pixels. */

:root {
  --bg: #05070f;
  --panel: #0b1020;
  --ink: #e8ecff;
  --accent: #5de8c8;
  --wall: #2d4bd6;
  --muted: #8a94b8;
  --aspect: 21 / 23;
  --cols: 21;                  /* CONFIG.GRID.COLS, the number the maze box is built from */
  --player: #5de8c8;          /* same as CONFIG.COLORS.PLAYER, so a life icon is the player */

  /* The cabinet's own breathing room and the gaps between its blocks. These are the numbers
     the layout measures off the page rather than mirroring, so the stylesheet and js/layout.js
     read the same resolved value — including the safe-area inset below, which is what keeps the
     maze out of a phone's notch and browser chrome.

     Stage 5B.1b: the gap is 6px at EVERY window, not only a short one. A desktop maze is
     height-limited at every laptop and monitor size this game is played on, so the room
     between the blocks is the maze's own room and the maze gives it back tile for tile;
     12px was decorative and 8px still is. The 10px margin stays, because that one IS the
     outer breathing room the cabinet asks for around the game unit (8-12px, plus whatever
     the device reports as unsafe). */
  --margin: 10px;
  --gap: 6px;

  /* Stage 5B: whole CSS pixels per tile. js/layout.js overwrites this with the largest whole
     number that still fits the viewport; 18px is CONFIG.TILE_SIZE, the fallback for a page
     where the layout could not measure (an old browser, or the file:// shell). Stage 5D.4b reads
     it in a second place — the HUD row is built from it, so the row and the maze are one width
     by construction rather than two numbers that happen to agree. */
  --tile-px: 18px;

  /* Stage 5B.1a: the band a mobile browser covers with its own interface. The page is laid out
     in the *layout* viewport, but only the *visual* viewport is actually visible, and the two
     differ on a phone: an expanded toolbar or control centre, a pinch-zoom, or a page the browser
     has scrolled while its chrome is expanded all leave the visible band inside a taller layout
     viewport. js/layout.js writes the band's four offsets here from `window.visualViewport`, and
     they join the safe-area inset in the cabinet's padding, so the whole HUD + maze unit sits
     inside what is really on screen and js/layout.js — which measures that resolved padding —
     costs the maze exactly the room the browser took. All zero where the visible viewport is the
     whole page (a desktop, or a phone whose chrome is collapsed). */
  --viewport-top: 0px;
  --viewport-right: 0px;
  --viewport-bottom: 0px;
  --viewport-left: 0px;

  /* Stage 5A: the touch controls. `--pad-button` stays at or above CONFIG.TOUCH.MIN_BUTTON_PX
     (44 px) at every viewport this game is played on, which is what makes every control
     thumb-sized rather than mouse-sized; the pad scales with the shorter viewport axis so
     it keeps its proportions in portrait and in landscape alike. Stage 5A.1a sizes the two
     panels with the same number, so a landscape window keeps a thumb-sized cross on one
     side of the maze and thumb-sized actions on the other. */
  --pad-button: clamp(48px, 9vmin, 64px);
  --pad-gap: 6px;

  /* Stage 5J.5: the ONE logo contract (see `<img class="fm-logo">` in index.html). The ratio below
     is the intrinsic size the supplied PNG carries (1024 x 248, restated from `width`/`height`
     attributes) so a header can copy the contract without re-measuring the file; the two widths are
     the floor and the ceiling that contract draws at, shared by the menu now and — when Stage 5J.5’s
     successor dresses the gameplay header — by the HUD. Nothing here remembers a rendered pixel
     height: the height always comes from the width and the ratio, which is what keeps the wordmark
     undistorted and unresampled. */
  --fm-logo-ratio: 1024 / 248;
  --fm-logo-min-w: 180px;
  --fm-logo-max-w: 620px;

  /* Stage 5J.7: the HEIGHT budget the compact gameplay header dresses its logo inside, restated
     once so the header can derive the logo's WIDTH from it through `--fm-logo-ratio` instead of
     remembering a box. It is the heading's own line box — `line-height: 1` times the very clamp
     `.title` below asks for its font-size — so the wordmark costs js/layout.js the same row the
     FAMILY MAZE text line used to, and the maze never gives the header a tile. ([q#50] doubles the
     wordmark's room from this budget through `--hud-logo-scale` below, so that last clause is the
     predecessor's: the maze now gives the header back part of a tile, measured rather than remembered.) */
  --hud-title-line: clamp(11px, 2.4vmin, 18px);

  /* [q#50]: the ONE size asked for on top of Stage 5J.7 — the gameplay header's logo at twice its
     VISIBLE linear size. It is a scale on that stage's height budget, never a remembered box: the
     heading's own text still reads at `--hud-title-line` and keeps its ink, tracking and one-line rule
     (the `alt` fallback Chrome paints keeps them too, in the bigger room the box now reserves), only
     the wordmark grows, so its ink keeps its own ratio, its own sharpness and its own glyphs.
     The scale is linear on both axes, which is what the artwork needs: the shipped 512x124 raster
     fills 98.6% of its box's width and 94.4% of its height with ink (measured off its own alpha),
     so twice the box is twice the visible wordmark rather than twice an empty box. What the bigger
     box costs, js/layout.js measures and the maze gives back through its own whole-tile fit; the
     existing maze-width cap and the existing narrow/short hide policy are what keep the doubled
     wordmark inside every window this game is played on, with no new breakpoint of this stage's
     own. */
  --hud-logo-scale: 2;

  /* Stage 5J.5 drew the two blues from the supplied art; Stage 5J.8 turns them into the ONE shared
     cabinet frame (see `.arcade-frame` below) that every dedicated screen page adopts, so the two
     hexes live once here and the mini-maze, the frame and the pellet accents are one look. The
     strokes are fixed CSS px, not a stretched raster and not a scaled viewBox: the frame box may
     be any size at any window, the lines may not thicken and one pellet may not stretch.

     Stage 5J.8 — the shared frame contract. `--frame-stroke` is the outer band, `--frame-stroke-inner`
     the supplied art’s own second line, `--frame-inset` the breathing between the screen’s own box
     and the band (inside the cabinet’s safe-area padding, which already carries the device inset and
     the browser’s own band offsets), `--frame-inner-inset`/`--frame-notch-inset` the two layers’ own
     offsets inside the frame, and `--frame-accent-tile` one pellet’s fixed size. `--frame-content`
     is the contract’s content area: everything a screen puts on the page belongs inside the band,
     so a screen that fills its width insets its panel by this number rather than by a remembered
     pixel. One implementation, four adoptions (`#menu`, `#score-view`, and the two pages `js/menu.js`
     writes into `.screen`) — no screen copies a border. */
  --frame-outer: #3932eb;
  --frame-inner: #8174ff;
  --frame-stroke: 12px;
  --frame-stroke-inner: 2px;
  --frame-inset: clamp(4px, 1.4vmin, 16px);
  --frame-inner-inset: 0px;
  --frame-notch-inset: calc(0px - var(--frame-stroke));
  --frame-accent-tile: 24px;
  --frame-gap: 8px;
  /* All three painted layers reserve space. Keep accents along the outer edge, and place
     content beyond whichever layer reaches deepest, including an entire pellet tile. */
  --frame-decoration-depth: max(calc(var(--frame-stroke) + var(--frame-inner-inset) + var(--frame-stroke-inner)), calc(var(--frame-stroke) + var(--frame-notch-inset) + var(--frame-accent-tile)));
  --frame-content: calc(var(--frame-inset) + var(--frame-decoration-depth) + var(--frame-gap));

  /* The same contract’s content-side numbers: the one stack gap every dedicated page puts between
     its heading, its body and its way back, and the two type sizes the pages share — a page title
     and body copy read at. Restated once so no page carries its own remembered clamp. */
  --frame-page-gap: clamp(10px, 2.2vmin, 26px);
  --frame-title-size: clamp(15px, 3.2vmin, 32px);
  --frame-line-size: clamp(18px, 2.2vmin, 21px);
  --frame-section-title: clamp(20px, 2.6vmin, 26px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: radial-gradient(circle at 50% 20%, #101730 0%, var(--bg) 70%);
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.cabinet {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--gap);
  /* The breathing room around the whole game unit, plus whatever the device reports as unsafe
     (a notch, a punch-hole camera, a browser's edge), plus the band the browser's own interface
     covers (Stage 5B.1a, the `--viewport-*` offsets js/layout.js writes). Padding rather than a
     margin because the padding is what js/layout.js measures: the maze cannot reach into a notch,
     into the browser's chrome, or out of the visible band, and the HUD/maze unit moves to sit
     inside the band instead of being cropped by it. */
  padding: calc(var(--margin) + env(safe-area-inset-top) + var(--viewport-top))
           calc(var(--margin) + env(safe-area-inset-right) + var(--viewport-right))
           calc(var(--margin) + env(safe-area-inset-bottom) + var(--viewport-bottom))
           calc(var(--margin) + env(safe-area-inset-left) + var(--viewport-left));
}

/* Stage 5D.4: the game unit's wrapper — HUD, playfield and both board panels (Stage 5D.4b took the
   gameplay instruction footer out of the unit and out of the page). Off the game
   route js/menu.js sets `hidden`, and the rule below puts the WHOLE subtree out of the layout
   (`display: none`: no geometry, nothing focusable, nothing reachable by a pointer or a key) on
   every dedicated menu page. While the wrapper IS in the page it is `display: contents`, so its
   children are the cabinet's own flex blocks again — every Stage 5B gap, measurement and tile the
   earlier stages recorded comes out byte-identical under the game route. The `[hidden]` rule is
   declared after, and on a more specific selector, so the attribute js/menu.js writes always wins. */
.game {
  display: contents;
}

.game[hidden] {
  display: none;
}

/* The terminal score destination needs no maze or gameplay controls. In particular,
   ten scores and the way back must fit in landscape without the maze claiming height. */
.game .hud[hidden],
.game .playfield[hidden] {
  display: none;
}

/* Stage 5B: the HUD is one compact block above the maze, so the two read as one game unit.
   Stage 5B.1b puts FAMILY MAZE on its own line at the top of that block: `flex-direction:
   column` with `align-items: center` centres the title and the stats row on the same vertical
   axis the maze is centred on (the maze is centred in the playfield column, the column is the
   cabinet's content box), and the stats row keeps sitting directly above the maze. The block
   still claims exactly one measured box — js/layout.js reads `.hud` — so the maze is fitted
   around a title that is really in the page. What keeps that title from costing the maze a
   whole tile is the 6px gap and a line box kept near the font's own height. */
.hud {
  width: 100%;
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

/* Stage 5J.7 turns this row's TEXT presentation over to the one logo contract (`<img class="fm-logo">`
   in index.html) and keeps every property this rule still owns: the heading's line box, its ink, its
   shadow and its tracking are what the logo's own `alt` fallback is painted in when the PNG cannot
   load, and `text-align: center` is what keeps that one fallback line centred on the row. The height
   budget now lives in `--hud-title-line` (the same clamp), because the header needs the LENGTH to
   derive the logo's width from — see `.hud .fm-logo` below. */
.title {
  margin: 0;
  line-height: 1;               /* the heading claims its own line and nothing more */
  font-size: var(--hud-title-line);
  letter-spacing: 0.22em;
  color: var(--accent);
  text-shadow: 0 0 12px rgba(93, 232, 200, 0.35);
  text-align: center;
}

/* Stage 5J.7 — the same contract, the header's own size. `.fm-logo` above owns the contract and
   deliberately carries no size; this rule gives the HUD its size, and it sizes a HEIGHT budget,
   never a box: the width is that budget times the contract's own ratio, so the wordmark keeps its
   proportions and `height: auto` comes back out at the budget exactly. The budget is `--hud-title-line`
   (the heading's line box) and the width is capped by `calc(var(--cols) * var(--tile-px))`, the
   maze's own rendered width — the same expression `.stats` builds the read-out row from — so the
   logo can never be wider than the row it sits over and the HUD's measured height, the tile the
   fit chooses and the five read-outs stay the predecessor's at every window. No percentage of the
   heading here: the heading shrink-wraps the logo, so a percentage would be a percentage of the
   thing it is meant to bound. `white-space: nowrap` keeps a fallback line the logo's `alt` paints
   on ONE line of the heading's own height — a fallback wider than the reserved box overflows into
   the HUD's own empty room, it never grows the row and never leans on the stats. */
/* [q#50] restates only the size of this rule: the height budget is `--hud-title-line` times
   `--hud-logo-scale` (2), so the wordmark reads at twice its visible linear size while the heading's
   own text and the `alt` fallback keep their old line box. The width is still that budget through
   the contract's ratio, still capped by `calc(var(--cols) * var(--tile-px))` — the maze's own
   rendered width, the same expression `.stats` builds the read-out row from — so the logo can never
   be wider than the row it sits over, never taller than the budget it just spent, and never distorted
   (`height: auto` still comes out of the width). The cap is not binding at any window where the
   heading is shown: twice the budget is at most 148.6 CSS px wide, while the maze is at least ~483
   px wide there, which is why the doubled target fits whole rather than being silently shrunk. */
.hud .fm-logo {
  width: min(calc(var(--cols) * var(--tile-px)),
             calc(var(--hud-title-line) * var(--hud-logo-scale) * var(--fm-logo-ratio)));
  max-width: calc(var(--cols) * var(--tile-px));
  height: auto;                       /* the width above, through the ratio: no distortion */
  max-height: calc(var(--hud-title-line) * var(--hud-logo-scale));
  color: var(--accent);               /* the fallback reads in the heading's own ink */
  letter-spacing: 0.22em;             /* ditto its tracking */
  line-height: 1;
  white-space: nowrap;
  text-align: center;
}

/* Stage 5B.1b: 4px of panel padding instead of 6px. Labels and read-outs keep their own font
   sizes (readability is a font decision); the padding is the frame the layout spends, and the
   maze is height-limited on a desktop window, so 2px top and bottom is room handed to the maze.

   Stage 5D.4b: the row is as wide as the maze it sits above, and the five read-outs are spread
   across that width instead of hunched in the middle. `calc(var(--cols) * var(--tile-px))` is the
   maze's OWN rendered width — the stage is `21 * var(--tile-px)` wide and js/layout.js writes that
   one number for the page it just measured — so the row follows the maze through a resize, an
   orientation flip, a notch inset or a different device, and no fixed width anywhere in the row
   can disagree with the maze it belongs to. `max-width: 100%` keeps the row inside the cabinet's
   content box whatever the fit decided, and `flex-wrap: wrap` keeps it inside the row's own width:
   both are the guard against a horizontal scroll, and a wrapped row costs the maze height, which
   is what js/layout.js measures.

   `justify-content: space-between` is the even distribution — the outer pair sits against the
   row's own padding and the four inner gaps come out equal at every width — with `gap` and the
   horizontal padding as clamps so the distribution has somewhere to go on a phone. Typography
   and icons keep their sizes; the room they were packed in is what changed. */
.stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  width: calc(var(--cols) * var(--tile-px));
  max-width: 100%;
  gap: clamp(6px, 1.6vmin, 18px);
  padding: 4px clamp(6px, 1.6vmin, 18px);
  background: var(--panel);
  border: 1px solid rgba(120, 150, 255, 0.25);
  border-radius: 10px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  /* Stage 5D.4b: the remembered 56px is gone. Its job was to keep five stats on one line on a
     phone, and the row's own width now decides that: the row is the maze's width, so the five
     read-outs and the clamped gaps either fit it — they do at every window the suite measures —
     or the row wraps, which is the same guard as before and costs the maze height rather than
     width. */
}

.stat span {
  font-size: clamp(9px, 1.6vmin, 11px);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat output, .stat button {
  font-size: clamp(13px, 2.6vmin, 18px);
  color: var(--ink);
}

/* The lives display. One row of icons under the label, cut with the same wedge the player
   is drawn with, so the relationship needs no legend: bright = still in hand, dim = a slot
   already spent. Three slots with two bright reads as "two of three left" at a glance, and
   there is no number beside it saying the same thing again. */
.stat.lives {
  gap: 5px;
}

.stat.lives output {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 0;
  font-size: 0;
}

.life-icon {
  display: block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--player);
  clip-path: polygon(50% 50%, 100% 25%, 100% 0%, 0% 0%, 0% 100%, 100% 100%, 100% 75%);
}

.life-icon.life-spent {
  background: rgba(93, 232, 200, 0.14);
}

/* Game + debug inspector + touch pad. The inspector is never drawn over the maze: one column
   (so it falls below the game) on a narrow viewport, two columns (so it sits to the right) once
   there is room for it. The breakpoint mirrors CONFIG.DEBUG.INSPECTOR_BREAKPOINT_PX, which is
   the same rule in JS, so `data-layout` on the aside always agrees with the CSS; the D-pad's
   column mirrors CONFIG.TOUCH.PAD_BREAKPOINT_PX the same way.

   The playfield is as wide as the cabinet's content box, and the maze is as big as js/layout.js
   says it can be inside that box — HUD row, pad, inspector and padding all measured, the footer having
   been removed in Stage 5D.4b —
   so nothing here imposes a maximum on the maze and the maze never has to be shrunk to suit the
   page. `justify-items: center` keeps the maze in the middle of its own column, which is what
   centred the console on a short window before and is what centres it on a wide one now.

   The second column only exists while the inspector is actually shown. A hidden inspector is
   `display: none`, but a grid track would still be reserved for it, and that reserved width is
   what would leave the maze off centre in normal play — `:has()` keeps the layout one column
   wide until debug turns the inspector on, so no offset is tied to a particular viewport size. */
.playfield {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--gap);
  align-items: start;
  justify-items: center;
  width: 100%;
}

@media (min-width: 860px) {
  .playfield:has(.inspector:not([hidden])) {
    grid-template-columns: minmax(0, 1fr) minmax(240px, 300px);
  }
}

/* The maze box: the tile the layout chose, times the grid. `aspect-ratio` keeps the 21 / 23
   shape whatever the tile is, and the canvas fills exactly that box with a backing store of
   the same size in device pixels — never a stretched or resampled version of a fixed one. */
.stage {
  position: relative;
  width: calc(var(--cols) * var(--tile-px));
  aspect-ratio: var(--aspect);
  background: #080b16;
  border: 0;
  border-radius: 0;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45), inset 0 0 24px rgba(45, 75, 214, 0.18);
  overflow: hidden;
}

/* Fallback for browsers without `aspect-ratio`: padding reserves the same box,
   so the canvas still has a height to fill instead of collapsing to zero. */
.stage::before {
  content: "";
  display: block;
  padding-top: calc(100% * 23 / 21);
}

@supports (aspect-ratio: 1) {
  .stage::before { display: none; }
}

.stat button {
  border: 0;
  padding: 0;
  background: transparent;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.stat button:focus-visible { outline: 2px solid var(--accent); }

canvas {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.notice {
  width: 100%;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid rgba(242, 226, 107, 0.45);
  border-radius: 10px;
  background: rgba(242, 226, 107, 0.12);
  color: #f2e26b;
  font-size: 13px;
  line-height: 1.4;
}

/* Stage 5D.1/5D.4 (and Stage 5J.5's retro treatment of the same page): the main menu — a dedicated
   full-screen arcade page. The game wrapper is `display: none` behind it, so the menu is the whole
   page: the dark navy -> soft blue-purple gradient, the supplied logo in its own heading, the
   supplied 960x480 mini-maze and its pellet field, the blue frame around the whole page, and the
   four controls in a grid — two by two on a phone, four across only where the labels fit — in
   exactly the markup order Play / How to Play / High Scores / Settings.

   `flex-grow: 1` fills the cabinet's content box, which the cabinet padding already keeps inside
   the visible band (safe-area insets and the `--viewport-*` offsets js/layout.js writes), so the
   page fits a window that has the room for it. Nothing here CAPS the page's height: content that
   does not fit (a phone at 200% browser zoom) grows the page and the menu scrolls to reach it —
   the surface allows that gesture, the controls below keep theirs. Declared after `display: flex`
   and on a more specific selector, so the `hidden` attribute js/menu.js writes always wins and a
   menu that is not the current screen leaves the page entirely — out of the maze's room, out of
   focus order, unreachable by a pointer or a key. */
.menu {
  width: 100%;
  margin: 0;
  flex-grow: 1;
  position: relative;            /* the absolutely placed logo sits near its top */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(12px, 2.6vmin, 30px);
  /* [q#46] the menu’s own asymmetric room, restated once so no rule remembers it. The page keeps
     centring its stack, and these two numbers are what lean it: `--menu-head-room` is extra room
     put *between* the wordmark and the decoration, which lifts the logo toward the top and sits the
     controls lower at the same time (the whole stack grows, centring splits the growth), and
     `--menu-stage-room` is the art’s own room above the controls. Both follow the axis that runs
     out first, so a short window that has no room for the bias takes the small end of the clamp
     rather than losing a control to the fold. */
  --menu-head-room: clamp(8px, 8vh, 72px);
  --menu-stage-room: clamp(8px, 3.2vmin, 30px);
  background: linear-gradient(168deg, #0b1030 0%, #1a2150 52%, #2b2d63 100%);
  /* Stage 5J.8: the page adopts the shared cabinet frame, so the menu keeps its heading, its
     mini-maze and its four controls inside the contract’s own content area. The frame sits `--frame-inset`
     inside this box and paints a `--frame-stroke` band there, so the content is inset by
     `--frame-content` (that band plus the breathing room) rather than by a remembered px: the
     band never crosses a control, a heading or the art, and a box whose label cannot fit inside
     that area is capped below rather than left to reach under the band. */
  padding: var(--frame-content);
}

.menu[hidden] {
  display: none;
}

/* Stage 5J.5 — the logo contract, presentation half. ONE rule set for ONE element, so the menu
   heading now and the gameplay header later ask for the same thing: the element keeps its own
   intrinsic ratio (`height: auto` beside the markup’s `width`/`height` attributes and the
   `--fm-logo-ratio` fallback), never a remembered height, never `object-fit` stretching, and its
   `alt` text is painted in the page’s own ink at a readable size — that is the fallback a browser
   shows when the PNG is missing, and it needs no second element to exist.

   The size is NOT here: it comes from the context (`.menu .fm-logo` below), which is what lets a
   later header choose its own width without inventing a second contract. */
.fm-logo {
  display: block;
  margin: 0 auto;
  width: 100%;
  max-width: 100%;
  height: auto;                       /* follows the width: intrinsic ratio, no distortion */
  aspect-ratio: var(--fm-logo-ratio);  /* the ratio restated, for a browser that ignores the attrs */
  overflow: visible;
  color: var(--ink);                  /* the `alt` fallback reads in the page’s own ink */
  font-family: inherit;
  font-size: clamp(15px, 2.6vmin, 26px);
  letter-spacing: 0.06em;
  line-height: 1.2;
  text-transform: none;
}

.menu .fm-logo {
  /* The menu’s own width for that contract: driven by the viewport, capped by the panel, never
     by a remembered height. `min(62vw, 74vh)` is the axis that runs out first in a short landscape
     window, so the wordmark keeps its proportions in portrait and in landscape alike. */
  width: clamp(var(--fm-logo-min-w), min(62vw, 74vh), var(--fm-logo-max-w));
  max-width: 88%;
}

.menu .menu-heading {
  margin: 0;
  /* [q#46] the logo sits toward the top of the page: this room belongs to the heading, so it grows
     the stack rather than moving a single element, and centring splits the growth — the wordmark
     lifts and the controls below the enlarged decoration drop. It is `vh`-driven because on a phone
     the page has vertical room to spare, which is exactly where the lift is wanted. */
  margin-bottom: var(--menu-head-room);
  width: 100%;                 /* the heading spans the panel, so the logo's own cap is the panel's room
                                 — measured against the panel, never against the logo it holds */
  text-align: center;
  line-height: 1;
  color: var(--ink);
}

/* Stage 5J.5 — the decoration layers. Both are `aria-hidden`, carry an empty `alt`, and take
   `pointer-events: none`: a tap or a key can never land on them, and a reader never meets them.
   They are also never a substitute for game art — the mini-maze carries no faces, no people and
   no gameplay entity, and nothing here is drawn from the sprite registry. */
/* Stage 5J.5 drew the decoration layers; Stage 5J.8 makes the frame ONE component the whole page
   shares. `.arcade-frame` is the adoption element — `<div class="arcade-frame" aria-hidden="true">`
   inside a screen — and these three rule sets are the whole implementation: an outer band, the
   supplied art’s own thinner line, and the pellet accents riding their OWN layer as a fixed tile
   that repeats, so the count of pellets grows with the frame and the size of one never does.
   Nothing here is `border-image`, nothing is a `100%` background size, nothing is a full-screen
   raster: the geometry is content-sized and every thickness is a fixed px token, so the same
   declaration serves a 960px menu band and a 300px High Scores band alike.

   The layer is decoration only: `aria-hidden` on the element (so a reader never meets it and it is
   out of the accessibility tree), `pointer-events: none` on all three rule sets (so a tap, a swipe
   or a click can never land on it), `z-index: 0` (the screen’s own content paints above it), and
   no `animation`/`transition` of any kind — the accents are static by default, there is nothing
   ornamental to flash and nothing a reduced-motion preference has to stop.

   A screen that adopts it must carry `position: relative` (the frame is placed against its screen’s
   own box, `inset` by `--frame-inset`), and must keep its content inside `--frame-content`. */
.arcade-frame {
  position: absolute;
  inset: var(--frame-inset);
  border: var(--frame-stroke) solid var(--frame-outer);
  border-radius: 0;
  pointer-events: none;
  z-index: 0;
}

.arcade-frame::before {
  /* the supplied art’s own second, thinner line, at a fixed 2px whatever the page is */
  content: '';
  position: absolute;
  inset: var(--frame-inner-inset);
  border: var(--frame-stroke-inner) solid var(--frame-inner);
  pointer-events: none;
}

.arcade-frame::after {
  /* Independent pellet accents: the supplied 24-unit pellet sheet tiled at a FIXED tile, so
     the COUNT of pellets grows with the frame and the size of one never does. Four runs —
     one along each edge — and no stretched border image. */
  content: '';
  position: absolute;
  inset: var(--frame-notch-inset);
  pointer-events: none;
  background-image: url(../assets/menu/decorations/pellet.svg),
                    url(../assets/menu/decorations/pellet.svg),
                    url(../assets/menu/decorations/pellet.svg),
                    url(../assets/menu/decorations/pellet.svg);
  background-repeat: repeat-x, repeat-x, repeat-y, repeat-y;
  background-position: 0 0, 0 100%, 0 0, 100% 0;
  background-size: var(--frame-accent-tile) var(--frame-accent-tile);
}

.menu .menu-stage {
  display: flex;
  flex-direction: column;             /* art above controls, the reading order on a phone */
  align-items: center;
  justify-content: center;
  gap: var(--menu-stage-room);        /* [q#46] the art’s own room above the controls */
  max-width: 100%;                    /* Stage 5J.8: the stage belongs to its page’s content area */
}

.menu .menu-art {
  /* The shared 960x480 art box. `--menu-art-w` is the one size, `--menu-art-step` is the supplied
     field’s own 24-unit pellet grid (960/40) in CSS px, and `--menu-art-scale` is the transform the
     box and everything inside it already shares — the room a later cast overlay would be placed in.
     Nothing inside the box is scaled on its own, so the maze lines and the pellets stay on one
     coordinate system at every window.

     [q#46] the decoration is now the page’s widest element: the box takes the long axis of the
     window up to 88vw / 72vh rather than 70vw / 58vh, which is a 24% wider box at every laptop and
     short-landscape window the game is played on (522 CSS px → 648 at 1440x900, 348 → 432 at
     1440x600, 226 → 281 at the short landscape 844x390). A phone window has no horizontal room
     left: there the same declaration lands on the `max-width: 96%` cap below it, which is what
     keeps the art inside the shared band, never a sideways scroll. */
  position: relative;
  --menu-art-w: clamp(220px, min(88vw, 72vh), 860px);
  --menu-art-step: calc(var(--menu-art-w) / 40);
  --menu-art-scale: 1;
  width: var(--menu-art-w);
  max-width: 96%;
  transform: scale(var(--menu-art-scale));
  transform-origin: center;
  pointer-events: none;
}

.menu .menu-art .menu-maze {
  display: block;
  width: 100%;                        /* the box the art defines; height follows its own 2:1 ratio */
  height: auto;
}

.menu .menu-art .menu-pellets {
  /* the pellet field, on that same box: same viewBox, same uniform scale, so the two layers cannot
     drift apart and neither is stretched */
  position: absolute;
  inset: 0;
  width: 100%;
  height: auto;
}

.menu .menu-art .menu-chase {
  /* Stage 5J.6: the menu's decorative chase sits on the SAME box as the two supplied layers, so
     it shares the one 960x480 coordinate system and the one uniform `--menu-art-scale` the box
     applies - a position authored in the art's own units can only land against that grid. The
     backing store follows the box on the art's own 2:1 ratio (js/menu-chase.js sizes it from the
     measured box times the device pixel ratio, the same way js/renderer.js keeps the maze crisp),
     so nothing here resamples or stretches a figure. A reduced-motion preference changes what that
     module paints (one static canonical frame each, no cadence to run); it changes nothing here,
     because no part of this layer moves in CSS and nothing about it flashes. */
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}


.menu .menu-controls {
  display: grid;
  grid-template-columns: repeat(2, 1fr);   /* two by two: a phone’s thumb reaches a quarter, not a row */
  gap: clamp(8px, 2.2vmin, 18px) clamp(6px, 2vmin, 16px);
  justify-content: center;
}

/* Generously sized arcade buttons: every target stays comfortably above the 44 px thumb floor at
   every window the game is played on (the `min-height` clamp bottoms out at 52 px, which is where
   the two-by-two lands on a phone and four-across on a desktop). Stage 5J.5 puts them in a grid
   rather than a column, so the horizontal padding is viewport-driven too: a narrow window may
   never be forced to scroll sideways by four labels that refuse to fit. `position: relative`
   keeps a control above the decoration layer (which is `pointer-events: none` anyway) and keeps
   its own `:focus-visible` ring visible outside the box. */
.menu button {
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
  position: relative;
  z-index: 1;
  min-height: clamp(52px, 7vmin, 92px);
  padding: clamp(11px, 2.2vmin, 16px) clamp(12px, 5.2vw, 28px);
  border: 1px solid rgba(120, 150, 255, 0.35);
  border-radius: 12px;
  background: var(--panel);
  color: var(--ink);
  font-family: inherit;
  font-size: clamp(14px, 2.8vmin, 26px);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

/* Stage 5J.5 review of that gesture rule. `touch-action: none` belongs on the CONTROLS — a tap
   activates one, it must not pan the page or select the button's own label — and it stays there. It
   does NOT belong on `.menu` any more: the menu page may grow past a short window (four controls
   beside a wordmark at 200% browser zoom does), and a page whose own surface refuses panning leaves
   the rest out of reach with no way to get there. The menu surface therefore takes `pan-y
   pinch-zoom`: vertical scrolling and pinch zoom are allowed, sideways drift is not (the page must
   never scroll sideways — the layout sections assert that), and gameplay keeps its own untouched
   rules on the canvas, the D-pad and the action panel. */
.menu button, .screen, .screen button, .menu-back, #score-view .board-rows, #score-view .board-rows li {
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.menu {
  touch-action: pan-y pinch-zoom;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

@media (min-width: 1100px) {
  .menu .menu-controls {
    /* Four across, but only on a window wide enough that every label keeps its own line at the size
       the type is rendered at here. The task's 900 px is guidance, not the break: at 900 px the
       widest label (HOW TO PLAY / HIGH SCORES) plus its own padding does not fit four times, so the
       break sits where the fit was measured. Shorter windows keep the two-by-two. */
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (orientation: landscape) and (max-height: 480px) and (min-width: 600px) {
  .menu .menu-stage {
    /* A short landscape window: the controls sit BESIDE the art, which is where a thumb reaches
       them when the page is only a few rows tall. `min-width: 600px` is the window that actually
       has room for the art box AND the control block side by side; below it the two would not fit
       across, so the page stacks them again and grows vertically instead — a menu must never be
       made to scroll sideways to reach a control. */
    flex-direction: row;
  }
}

.menu button:focus-visible, .menu-back:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.menu button:active, .menu-back:active {
  background: var(--accent);
  color: var(--bg);
}

/* Stage 5K.1 ([q#73]) — the START screen: the menu BEHIND a gate, and one large native START in
   front of it. Every pixel of that treatment lives here; `js/startup.js` only names the states
   (`data-startup="pending"` on the menu, `hidden` on the overlay) and `index.html` carries the
   elements. No new artwork, no second menu, no raster: the blurred background is the existing
   `#menu` page above, blurred as a whole, with the gate outside it so the button and its own words
   are never blurred.

   The four numbers are fixed tokens rather than per-window values: the blur is a fraction of the
   shorter axis (a phone blurs less because it has less to blur, and a desktop never blurs into an
   unreadable mush), the dim is one opacity, and the scrim is the page's own `--bg` with alpha, so
   the gate sits on the same cabinet rather than on a new colour. `--startup-blur` bottoms out above
   the point where the layout stops reading as a menu and tops out below the point where a whole
   page of blur costs the browser a expensive repaint of a large layer. */
:root {
  --startup-blur: clamp(4px, 1.1vmin, 10px);
  --startup-dim: 0.55;
  --startup-scrim: rgba(5, 7, 15, 0.62);
}

/* The gated menu. `filter`/`opacity` are the whole visual answer, and they are on the PANEL, not on
   a copy of it. `pointer-events: none` is a belt beside the native `inert` attribute js/startup.js
   sets (out of the tab order, out of hit testing, out of the accessibility tree): a tap, a swipe and
   a Tab must all miss the four controls behind the gate, so there is no click-through into Play and
   no competing action for a screen reader to find. The gate overlay below is a SIBLING of this block,
   which is what keeps its own button and its own words out of the blur. */
.menu[data-startup="pending"] {
  filter: blur(var(--startup-blur));
  opacity: var(--startup-dim);
  pointer-events: none;
}

/* The overlay itself: fixed, so it costs the cabinet's flex layout — and therefore js/layout.js's
   measurement — nothing at all, and full-bleed, so a tap anywhere in the window lands on the gate
   rather than through it. Its padding is the cabinet's own safe-area recipe (the device inset plus
   the `--viewport-*` band js/layout.js writes), which is what keeps the button out of a phone's
   notch, home indicator and browser chrome. */
.start-gate {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  grid-auto-flow: row;
  place-content: center;
  justify-items: center;
  align-content: center;
  gap: clamp(10px, 2.2vmin, 20px);
  padding: calc(var(--margin) + env(safe-area-inset-top) + var(--viewport-top))
           calc(var(--margin) + env(safe-area-inset-right) + var(--viewport-right))
           calc(var(--margin) + env(safe-area-inset-bottom) + var(--viewport-bottom))
           calc(var(--margin) + env(safe-area-inset-left) + var(--viewport-left));
  background: var(--startup-scrim);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.start-gate[hidden] {
  display: none;
}

/* One prominent button, comfortably above the 44 px thumb floor at every window this game is played
   on (its `min-height` bottoms out at 56 CSS px, its `min-width` at 190 px) and unblurred, in the
   page's own accent ink on the page's own accent colour — the highest-contrast pair this page
   already owns, which is what keeps it readable on top of a dimmed cabinet. `:focus` rather than
   `:focus-visible` on purpose: this gate focuses its own button on boot, a programmatic focus a
   browser does not always count as keyboard-driven, and a gate with one control should always show
   where it is. */
.start-button {
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
  min-height: clamp(56px, 9vmin, 104px);
  min-width: clamp(190px, 46vw, 420px);
  padding: clamp(12px, 2.4vmin, 20px) clamp(18px, 6vw, 40px);
  border: 2px solid rgba(232, 236, 255, 0.78);
  border-radius: 14px;
  background: var(--accent);
  color: var(--bg);
  font-family: inherit;
  font-size: clamp(20px, 4.4vmin, 42px);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.start-button:focus {
  outline: 3px solid var(--ink);
  outline-offset: 4px;
}

.start-button:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 4px;
}

.start-button:active {
  background: var(--ink);
  color: var(--bg);
}

.start-hint {
  margin: 0;
  max-width: min(86vw, 420px);
  color: var(--ink);
  font-size: clamp(13px, 2.2vmin, 20px);
  letter-spacing: 0.06em;
  text-align: center;
}

/* The gate's one note line, and the only line this stage can add to the page. Fixed and centred near
   the bottom, inside the same safe-area recipe, so it never pushes a control, never costs the layout
   a row and never covers a control it would have to be read past. Empty and `hidden` unless the host
   refused the unlock. */
.startup-note {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--margin) + env(safe-area-inset-bottom) + var(--viewport-bottom) + 8px);
  z-index: 31;
  max-width: min(92vw, 620px);
  margin: 0;
  padding: clamp(8px, 1.6vmin, 14px) clamp(12px, 2.4vmin, 18px);
  border: 1px solid rgba(120, 150, 255, 0.35);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink);
  font-size: clamp(13px, 2.2vmin, 18px);
  text-align: center;
}

.startup-note[hidden] {
  display: none;
}

/* Reduced motion is answered by NOT animating: the gate appears with the page and the reveal is a
   state change, so nothing here is required to move. The only motion this stage owns is the blur
   easing off when the menu is entered, and it is inside `no-preference` alone. Under `reduce` the
   reveal is instantaneous (no transition at all) and the gate still stands, still works and still
   reveals — a preference never becomes a gate. */
@media (prefers-reduced-motion: no-preference) {
  .menu {
    transition: filter 320ms linear, opacity 320ms linear;
  }
}

@media (prefers-reduced-motion: reduce) {
  .menu {
    transition: none;
  }
  .start-gate, .start-button, .startup-note {
    animation: none;
    transition: none;
  }
}

/* Stage 5D.4: the secondary pages are dedicated full-screen arcade pages on the same theme as the
   menu — same gradient, game unit hidden behind them (the `#game-area` wrapper is `display: none`
   while any of them shows. Their content (heading, copy and `Back to menu`) is
   written by js/menu.js, in a column so the heading, the scrolling copy, the board's own table and
   the one way back stack and stay centred. */
/* Stage 5J.8 adds `position: relative` to this host: the shared cabinet frame (`.arcade-frame`)
   is placed against its screen’s own box, so the host is the frame’s containing block. Nothing else
   about the page’s treatment moves, and an absolutely placed decoration layer costs the flex layout
   — and therefore js/layout.js’s measurement of this block — nothing.

   The frame is adopted INSIDE this block by `js/menu.js`’s `writeShell`, which writes the one
   decoration element as this page’s first child (see the adoption in js/menu.js and the contract
   comment on `.arcade-frame`). `hidden` still takes the whole subtree, the frame included, out of
   the layout, out of focus order and out of reach of a pointer or a key. */
.screen {
  position: relative;              /* the shared frame’s containing block (Stage 5J.8) */
  padding-block: var(--frame-content);   /* Stage 5J.8: the guide/Settings stack belongs inside the
                                          shared band; its width already follows `--frame-content` */
  width: 100%;
  margin: 0;
  flex-grow: 1;                  /* fills the cabinet's content box: a full-screen page, no scrolling */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--frame-page-gap);
  background: linear-gradient(168deg, #0b1030 0%, #1a2150 52%, #2b2d63 100%);
}

.screen[hidden] {
  display: none;
}

.screen h2 {
  margin: 0;
  line-height: 1;
  font-size: var(--frame-title-size);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

/* A dedicated page reads at page scale, not at HUD scale: the copy is for reading, and the one
   line that says a page is a shell (SETTINGS is Stage 5D.3's delivered page, whose options are
   still a pending decision rather than a control) is the one a player should not mistake for a
   finished page, so it carries the accent. */
.screen p {
  margin: 0;
  font-size: clamp(12px, 1.9vmin, 17px);
  line-height: 1.45;
  color: var(--muted);
}

.screen p.screen-note {
  color: var(--accent);
  font-size: clamp(11px, 1.7vmin, 15px);
  letter-spacing: 0.08em;
}

/* Stage 5D.2/5D.4: the page's copy sits in a body of its own, between the heading above it and the
   one `Back to menu` control below it. On the two pages that still keep this treatment — HIGH SCORES
   and SETTINGS — the body caps its own height and scrolls the rest inside itself, so the copy scrolls
   independently of the page (`overscroll-behavior: contain`, so the cabinet never starts scrolling
   sideways or vertically because of a long page), and the heading, the way back and the controls stay
   whole whatever the copy's length is. HOW TO PLAY is NOT one of them any more: Stage 5D.4a takes the
   cap and the inner scroller away for that page (see the `data-screen="howto"` block below, whose
   selector beats these rules whatever the order). `js/layout.js` measures whichever height this box
   ends up with for the routes where the maze is in the page. `touch-action: pan-y` is the one gesture
   this surface gives back: the block itself keeps `none` (no pinch, no selection), but a page of copy
   is made to be scrolled by a thumb — inside its own box on these two pages, down the document on the
   guide. */
.screen-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: none;
  width: min(86%, 620px);        /* a narrow centred reading column, not a wall of text edge to edge */
  margin: auto;
  padding: 12px 18px;
  background: rgba(8, 12, 26, 0.62);
  border: 1px solid rgba(120, 150, 255, 0.25);
  border-radius: 12px;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  max-height: min(34vh, 312px);
  touch-action: pan-y;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* The body is Tab-reachable (a keyboard has to be able to reach the copy, and a screen reader has to
   have a named region to enter), so it takes the same focus ring the menu controls take. */
.screen-body:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Stage 5D.4a — the HOW TO PLAY page's own layout, and nothing else's. `js/menu.js`'s `writeShell`
   marks the frame with the screen it carries, so this block reads `data-screen="howto"` and the High
   Scores and Settings frames keep the Stage 5D.4 presentation above untouched.

   Two facts change for the guide, and they are the two a reader of the page calls wrong on a phone:

   * the panel is as wide as the window it is read in — 8px inside the cabinet's own 10px padding, so
     about 18px to each edge of a 390px phone — and a centred 1100px column once the window is wide
     enough that a 1100px reading measure is still a measure, not a wall of text;
   * the panel has NO capped height: it grows with its copy and the DOCUMENT scrolls to reach the rest.
     The cap and the inner scroller were this page's workaround for long copy in a short window, and
     they left 12 paragraphs to scroll inside a thumb-sized box. The media queries below still cap the
     OTHER pages' bodies; the selector here is more specific, so the guide ignores them.

   The type gets the size a page of instructions is read at: 18-21px for the copy and for the way
   back at every window this game is played on, with the page's own title bigger still. Stage 5J.4
   added that third fact, and it is presentation only: the guide is six SCANNABLE SECTIONS
   (`.screen-section`, each with a real `<h3 class="screen-heading">` over its own lines), so the six
   headings read as headings — bigger than the copy, letterspaced, uppercase, in the accent colour —
   and the sections breathe apart from each other. The arcade treatment (panel, gradient, thumb-sized
   Back control, focus ring) stays the Stage 5D.4's. */
.screen[data-screen="howto"] {
  gap: clamp(16px, 2.4vmin, 26px);   /* heading -> panel -> Back, each with comfortable spacing */
}

.screen[data-screen="howto"] h2 {
  font-size: clamp(22px, 3.4vmin, 34px);   /* the page's title, above the six section headings */
  letter-spacing: 0.14em;
}

.screen[data-screen="howto"] .screen-body {
  width: min(calc(100% - (var(--frame-content) * 2)), 1100px);   /* the guide sits inside the shared
     frame’s content area: nearly full width on a phone, a centred 1100px column on a desktop */
  height: auto;
  max-height: none;                  /* the content decides; the page scrolls, the panel does not */
  overflow: visible;
  overscroll-behavior: auto;
  gap: clamp(14px, 2vmin, 22px);    /* the six sections breathe apart from each other */
  padding: 16px 20px;
}

.screen[data-screen="howto"] .screen-section {
  display: flex;
  flex-direction: column;
  gap: 8px;                          /* heading -> its lines -> its lines, inside one section */
}

.screen[data-screen="howto"] .screen-heading {
  margin: 0;
  font-size: var(--frame-section-title);   /* a heading sits above the copy, it does not compete with it */
  line-height: 1.2;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}

/* Stage 5J.10 — the guide's own illustrations, and nothing else's. An illustration belongs to the
   section it explains, between that section's heading and its own lines, so a reader meets
   heading -> picture -> copy and no picture ever stands behind words. Both are decoration only:
   the box and every image carry `aria-hidden`, an empty `alt` and `pointer-events: none` (the module
   writes the first two, this block the third), take no tab stop and own no control, so a reader
   never meets them and a thumb never lands on one — and none of them is `position: absolute`
   against the page, so all of them sit inside the panel, which is inside the shared band.

   The mini-maze band reuses #33's TWO supplied 960x480 layers on ONE box exactly as the menu's art
   box does: the maze layer is in flow and defines the box, the pellet field covers it with the same
   viewBox, the same intrinsic size and no scale of its own, so the two layers cannot drift apart and
   neither is stretched — `aspect-ratio` restates that field's own 2:1 so the box holds it before
   either file answers. It reads quieter than the copy on purpose (a lower `opacity` on the whole box,
   never on one layer), because decoration that competes with a line of instructions is the thing
   this stage was asked to avoid.

   A face is ONE static canonical idle frame, sized from the cell its own manifest declares: `height`
   decides the box and `width: auto` follows that declared ratio, so a face never distorts and the
   artwork keeps its own share of its cell at every window. The row wraps rather than squeezing faces
   on a narrow window. Nothing here animates or flashes, so a reduced-motion preference has nothing
   to stop and nothing to fall back to. */
.screen[data-screen="howto"] .screen-art {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: clamp(4px, 1vmin, 10px);
  max-width: 100%;
  margin: auto;                          /* centred in its own section, never flush to the panel */
  pointer-events: none;
}

.screen[data-screen="howto"] .screen-art.screen-art-field {
  position: relative;                    /* the pellet field is placed against the maze's own box */
  flex: none;
  width: clamp(150px, 26vmin, 320px);    /* smaller than the reading measure: the copy stays primary */
  max-width: 100%;
  height: auto;
  aspect-ratio: 2 / 1;                   /* the supplied layers' own 960 / 480 */
  opacity: 0.86;                         /* the blue maze and its yellow dots stay behind the words */
}

.screen[data-screen="howto"] .screen-art .screen-art-maze {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
}

.screen[data-screen="howto"] .screen-art .screen-art-pellets {
  position: absolute;
  inset: 0;
  width: 100%;
  height: auto;
  pointer-events: none;
}

/* [q#47] — the SAME face, at TWICE its linear size. Every clamp component below is exactly double
   the Stage 5J.10 rule's own (34px -> 68px, 5vmin -> 10vmin, 64px -> 128px), and doubling all three
   components of a `clamp` doubles whatever it resolves to at EVERY window, so a reader meets a face
   whose box is 2x tall and, because `width` stays `auto`, 2x wide: that is 2x the LINEAR dimensions
   (4x the area), not a remembered bigger box. The ratio, the manifest's own cell, the crisp
   artwork and the row's wrap are untouched: nothing here stretches a face, names a character, or
   grows the panel's own reading measure — the row wraps and the DOCUMENT scrolls instead. The
   selector still belongs to the guide alone, so the Settings page's portraits, the menu's art box
   and the gameplay cast keep their own sizes. */
.screen[data-screen="howto"] .screen-art .screen-art-face {
  display: block;
  flex: none;                            /* a face keeps its own size; the row wraps instead */
  height: clamp(68px, 10vmin, 128px);    /* [q#47]: 2x each of the predecessor's 34px / 5vmin / 64px */
  width: auto;                           /* the manifest's own declared cell ratio decides the width */
  max-width: 100%;
  pointer-events: none;
}

.screen[data-screen="howto"] .screen-body p {
  font-size: var(--frame-line-size);
  line-height: 1.55;
}

.screen[data-screen="howto"] .menu-back {
  font-size: var(--frame-line-size);   /* the way back reads at the copy's scale */
}

@media (max-width: 760px) {
  .screen-body { max-height: min(34vh, 288px); }   /* HIGH SCORES only; SETTINGS grew out (Stage 5S.5) */
}

/* A short window is the tight one: the one page that still caps a reading window is HIGH SCORES —
   its row count is fixed, so its copy fits and the rest scrolls inside the box (there is no maze to
   keep room for on a dedicated page, but the Back control still has to sit on the band). HOW TO PLAY
   grew out of the cap at Stage 5D.4a and SETTINGS did at Stage 5S.5: both grow with their content and
   let the DOCUMENT scroll, because what a player has to REACH on those two pages is copy and controls,
   not a maze. */
@media (max-height: 560px) {
  .screen-body { max-height: min(32vh, 124px); }   /* HIGH SCORES only; see Stage 5D.4a and 5S.5 */
}

/* Stage 5S.5 — the SETTINGS page's own layout, and nothing else's. The page now carries what a
   player has to reach: the cast-settings copy and FIVE labelled picker groups (the player's own and
   the roster's four), each with its own options. A capped box with an inner scroller would clip
   those controls, and a clipped control is a control a thumb cannot see, so this page takes the
   treatment the guide already took: the panel grows with its content, the DOCUMENT scrolls to reach
   the rest (never sideways), and every control keeps its own thumb-sized box inside the panel.

   The picker group is a `role="group"` of its own with its own `aria-label`, so a screen reader
   steps picker by picker rather than through one long list; its caption names what the slot stands on
   now, its options wrap so a narrow window stacks them, and the group's `Use default` control ends
   each block. Every control is a real `<button>` (focus order is DOM order: the copy, then the pickers
   in roster order, then the one `Back to menu`), which is what makes Tab + Enter, a pointer and a
   thumb all land exactly once and keeps the way back the last thing a keyboard can reach. */
.screen[data-screen="settings"] {
  gap: clamp(10px, 2vmin, 22px);          /* heading -> copy -> pickers -> sound -> Back, each breathing apart */
}

/* [q#49] reads this page's title like the guide's: the same arcade title scale and tracking, so
   “Settings” and “How to Play” are one heading system rather than two near-misses. The size stays a
   clamp (it never needs a breakpoint), and the page’s own reading width is untouched below. */
.screen[data-screen="settings"] h2 {
  font-size: clamp(22px, 3.4vmin, 34px);
  letter-spacing: 0.16em;
}

.screen[data-screen="settings"] .screen-body {
  width: min(calc(100% - (var(--frame-content) * 2)), 880px);   /* nearly full width, inside the shared
     frame’s content area; a readable measure on a wide window */
  height: auto;
  max-height: none;                      /* the content decides; the page scrolls, the panel does not */
  overflow: visible;
  overscroll-behavior: auto;
  gap: clamp(6px, 1.4vmin, 14px);
  padding: 10px 14px;
}

.screen[data-screen="settings"] .screen-body p {
  font-size: var(--frame-line-size);
  line-height: 1.55;
}

/* Use How to Play's reading scale for Settings copy, labels and controls. */
.screen[data-screen="settings"] {
  font-size: var(--frame-line-size);
}

.screen[data-screen="settings"] :is(p, label, select, output, .menu-back,
    .picker-limit, .picker-preview-status, .audio-option, .audio-step, .audio-track-value) {
  font-size: var(--frame-line-size);
}

.screen[data-screen="settings"] p {
  line-height: 1.55;
}

.screen[data-screen="settings"] .leaderboard-reset {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: min(calc(100% - (var(--frame-content) * 2)), 880px);
  text-align: center;
  margin-bottom: clamp(24px, 4vmin, 40px);
}

.screen[data-screen="settings"] .leaderboard-reset p:empty {
  display: none;
}

/* Settings: concise introduction, three sections, compact sound rows and persistent navigation. */
.screen[data-screen="settings"] {
  padding-bottom: calc(144px + env(safe-area-inset-bottom, 0px));
  scroll-padding-bottom: 144px;
}

.screen[data-screen="settings"] .screen-body {
  padding: 0;
  border: 0;
  background: none;
  text-align: center;
}

.settings-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: min(calc(100% - (var(--frame-content) * 2)), 880px);
  min-width: 0;
}

.settings-section-title {
  margin: 0;
  color: var(--accent);
  font-size: var(--frame-section-title);
  line-height: 1.2;
}

.settings-section-note { margin: 0; }

.settings-section :is(.picker-grid, .audio-settings, .audio-tracks) {
  width: 100%;
  margin: 0;
}

.settings-section .audio-settings {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 10px;
}

.settings-section .audio-settings .audio-line { flex-basis: 100%; }
.settings-section .audio-tracks { gap: 12px; }
.settings-section .audio-group-heading { font-size: var(--frame-line-size); }

.settings-section .settings-effects { display: block; }
.settings-effects > summary { cursor: pointer; padding: 12px 4px; min-height: 44px; }
.settings-effects > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.settings-effects[open] > summary { margin-bottom: 12px; }
.settings-effects .audio-track + .audio-track { margin-top: 10px; }

.screen[data-screen="settings"] .settings-footer,
.page-footer {
  position: fixed;
  z-index: 20;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  padding: 12px 16px calc(24px + env(safe-area-inset-bottom, 0px));
  background: rgba(5, 7, 15, 0.96);
  border-top: 1px solid rgba(120, 150, 255, 0.3);
}

.screen[data-screen="settings"] .settings-footer .menu-back,
.page-footer .menu-back {
  max-width: 100%;
  margin: 0;
}

.screen[data-screen="settings"] :is(button, select, input, summary) {
  scroll-margin-block: 20px 144px;
}

/* [q#49] — the one status paragraph the page still prints. It used to wear the cabinet’s accent
   because it used to be the record’s own read-out: five sentences of green narration, one per slot,
   changing with the face that slot stood on. That narration is gone (a face merely still arriving
   and a slot left on its safe shape are said by that picker’s own live preview status), and what
   remains — a record that could not be read, a face that cannot dress a slot, a store this device
   cannot write — reads as copy, in ink, so the accent on this page names only labels. The line is
   still a paragraph of its own and still says the outcome, so the diagnostic is not erased. */
.screen[data-screen="settings"] .picker-limit {
  color: var(--ink);
  font-size: clamp(12px, 1.7vmin, 17px);
}

.picker {
  display: flex;
  flex-direction: column;
  flex: none;
  gap: clamp(4px, 1vmin, 10px);
  margin: auto;                          /* centred inside the page, never flush to a window edge */
  width: min(calc(100% - (var(--frame-content) * 2)), 880px);
  padding: 10px 14px;
  border: 1px solid rgba(120, 150, 255, 0.22);
  border-radius: 12px;
  background: rgba(8, 12, 26, 0.5);
}

.picker-line {
  margin: 0;
  font-size: clamp(12px, 1.7vmin, 17px);
  line-height: 1.45;
  color: var(--ink);
}

/* Stage 5J.10 — the face each picker stands on now, between that group's own caption and its own
   options. It is decoration, not a control and not a substitute for the words beside it: `aria-hidden`
   and an empty `alt` on the element (written by `js/menu.js`), `pointer-events: none` here, so a tap
   passes through to whatever sits behind it and a reader never meets it. Its handle travels on `data-
   face-handle`, which is the SAME stable ID the group's `data-current` option control carries, so the
   picture and the selected state are one fact rather than two. The box follows the cell that
   character's manifest declares (`height` decides it, `width: auto` follows the declared ratio), so a
   face never distorts; a slot on its safe shape, or one the page could not honour, simply gets no
   picture, and the caption is then the whole of what that slot says about itself. */
.picker .picker-portrait {
  display: block;
  height: clamp(32px, 4.4vmin, 56px);
  width: auto;
  max-width: 100%;
  margin: auto;                          /* centred inside its own group */
  pointer-events: none;
}

.picker-option, .picker-default {
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
  display: inline-flex;
  align-items: center;
  flex: 1 1 0;
  min-height: clamp(44px, 6.4vmin, 76px);  /* a thumb target, not a label to aim at */
  padding: 8px 12px;
  border: 1px solid rgba(120, 150, 255, 0.3);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink);
  font-family: inherit;
  font-size: clamp(12px, 1.9vmin, 19px);
  line-height: 1.2;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.picker-option[data-current] {
  border: 2px solid var(--accent);
  background: rgba(46, 62, 132, 0.9);    /* the option the cast stands on now, without relying on colour */
  color: var(--ink);
  font-weight: 600;
}

.picker-option:focus-visible, .picker-default:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Stage 5E.4 — the ONE sound block, after the pickers and before the way back. It is the same
   treatment as a picker group, for the same reasons: a `role="group"` with its own `aria-label` so a
   screen reader steps it after the cast rather than through one long list; a caption that names what
   this device stands on (the mute state, and the volume as a percentage) so the state is a WORD and
   never only a colour; real `<button>`s at the same thumb-sized boxes, so Tab focus, Enter/Space,
   a pointer and a thumb all land exactly once and the `Back to menu` stays the last thing a keyboard
   reaches. `data-audio-current` marks which control matches this device's record, drawn the same way
   `data-current` marks a cast option — a border and a weight, so the state does not depend on hue.
   Nothing here is a slider, a drag or a hover-only affordance: a phone, a keyboard and a screen reader
   all reach the same four changes. */
.audio-settings {
  display: flex;
  flex-direction: column;
  flex: none;
  gap: clamp(4px, 1vmin, 10px);
  margin: auto;                          /* centred inside the page, never flush to a window edge */
  width: min(calc(100% - (var(--frame-content) * 2)), 880px);
  padding: 10px 14px;
  border: 1px solid rgba(120, 150, 255, 0.22);
  border-radius: 12px;
  background: rgba(8, 12, 26, 0.5);
}

.audio-line {
  margin: 0;
  font-size: clamp(12px, 1.7vmin, 17px);
  line-height: 1.45;
  color: var(--ink);
}

.audio-option, .audio-step {
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
  display: inline-flex;
  align-items: center;
  flex: 1 1 0;
  min-height: clamp(44px, 6.4vmin, 76px);  /* a thumb target, not a label to aim at */
  padding: 8px 12px;
  border: 1px solid rgba(120, 150, 255, 0.3);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink);
  font-family: inherit;
  font-size: clamp(12px, 1.9vmin, 19px);
  line-height: 1.2;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.audio-option[data-current] {
  border: 2px solid var(--accent);
  background: rgba(46, 62, 132, 0.9);    /* the state this device's record stands on, without colour alone */
  color: var(--ink);
  font-weight: 600;
}

.audio-option:focus-visible, .audio-step:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Stage 5E.15 ([q#66]) — the per-sound sliders, in TWO blocks (Music, then Sound Effects) after the
   master sound block and before the way back. Same treatment as the master's group, for the same
   reasons: a `role="group"` with its own `aria-label`, a heading that says what the block is, and a
   thumb-sized box for every control so Tab focus, an arrow key, Home/End, a pointer drag and a thumb
   all reach the same value. A native `<input type="range">` carries its own role, value and range for
   an assistive reader; the percentage beside it is TEXT, so the state is never only a thumb position
   or a colour. The track's own box is a grid row (label, slider, value) that collapses to a stacked
   row on a narrow window rather than shrinking the slider below a thumb. Nothing here is a custom
   drag, a hover-only affordance or a second volume control for the same sound. */
.audio-tracks {
  display: flex;
  flex-direction: column;
  flex: none;
  gap: clamp(4px, 1vmin, 10px);
  margin: auto;
  width: min(calc(100% - (var(--frame-content) * 2)), 880px);
  padding: 10px 14px;
  border: 1px solid rgba(120, 150, 255, 0.22);
  border-radius: 12px;
  background: rgba(8, 12, 26, 0.5);
}

.audio-group-heading {
  margin: 0;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: clamp(12px, 1.6vmin, 17px);
  line-height: 1.4;
}

.audio-track {
  display: grid;
  grid-template-columns: minmax(9ch, 1fr) minmax(0, 2.2fr) minmax(4ch, auto);
  align-items: center;
  gap: 8px 10px;
  min-height: clamp(44px, 6.4vmin, 76px);   /* the whole row is a thumb target, not a label to aim at */
}

.audio-track-label {
  font-size: clamp(12px, 1.7vmin, 17px);
  line-height: 1.35;
  color: var(--ink);
}

.audio-track-value {
  font-size: clamp(12px, 1.7vmin, 17px);
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  text-align: right;
}

.audio-track-note {
  margin: 0;
  font-size: clamp(11px, 1.5vmin, 15px);
  line-height: 1.4;
  color: var(--ink);
}

.audio-track-slider {
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
  width: 100%;
  min-width: 0;
  height: clamp(44px, 6.4vmin, 76px);       /* the slider ITSELF is the thumb target */
  padding: 0 2px;
  border-radius: 10px;
  background:
    linear-gradient(to right, rgba(120, 150, 255, 0.55), rgba(120, 150, 255, 0.55))
      no-repeat center / 100% 4px,
    rgba(8, 12, 26, 0.55);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.audio-track-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: clamp(22px, 4vmin, 34px);
  height: clamp(22px, 4vmin, 34px);
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: var(--panel);
}

.audio-track-slider::-moz-range-thumb {
  width: clamp(22px, 4vmin, 34px);
  height: clamp(22px, 4vmin, 34px);
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: var(--panel);
}

.audio-track-slider::-moz-range-track {
  height: 4px;
  background: rgba(120, 150, 255, 0.55);
  border-radius: 2px;
}

.audio-track-slider:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* A narrow window stacks a track's own row (name, then slider full width, then its percentage) so
   the slider never becomes a thumb-sized strip a phone cannot hit, and nothing overflows sideways. */
@media (max-width: 600px) {
  .audio-track {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "name value"
      "slider slider";
    row-gap: 2px;
  }
  .audio-track-label { grid-area: name; }
  .audio-track-value { grid-area: value; }
  .audio-track-slider { grid-area: slider; }
}

/* The way back on this page reads at the copy's scale, and is the LAST thing a keyboard reaches, so
   a player who is done with the pickers can leave without hunting for the exit. */
.screen[data-screen="settings"] .menu-back {
  font-size: clamp(14px, 2.2vmin, 21px);
}

/* The way back — generous, like the menu's controls, because a phone reaches it with the same thumb
   and it is the only control a secondary page has. */
.menu-back {
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
  min-height: clamp(52px, 7vmin, 92px);
  padding: 12px 28px;
  border: 1px solid rgba(120, 150, 255, 0.35);
  border-radius: 12px;
  background: var(--panel);
  color: var(--ink);
  font-family: inherit;
  font-size: clamp(14px, 2.8vmin, 26px);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

/* The high-score page (a separate change set, not Stage 4D), as the one presentation of the top ten:
   heading, rows, and the way back. Stage 5D.2 retired the small board beneath the maze (its panel,
   its rows and its own way-out control are gone from the markup, and `js/hud.js` no longer presents
   a board at all), so the `.board` class list now belongs to a single element — `#score-view`, the
   canonical High Scores page — and everything in this block styles that page's parts.

   The class list is kept for the reason Stage 5B.1c asked for it: one presentation of the rows,
   written by `js/view.js`, that a menu look and a finished game's display share rather than restyle.
   `js/layout.js` measures the page itself, and a hidden one costs the maze nothing. */
.board {
  width: 100%;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid rgba(120, 150, 255, 0.25);
  border-radius: 10px;
  background: var(--panel);
}

.board[hidden] {
  display: none;
}

/* Stage 5D.2: THE PAGE. `#score-view` is the canonical High Scores page on both routes — the menu's
   `High Scores` option opens it (a read-only look) and a finished game's display answers through the
   same element — so it takes the treatment the other dedicated full-screen pages take: it fills the
   cabinet's content box, keeps the page gradient, and stacks its heading, its rows, its note and its
   way back centred, at page scale rather than at HUD scale. It is a cabinet block of its own, outside
   the `#game-area` wrapper, so the maze is never behind it: `js/menu.js` keeps the game unit hidden
   on the menu's look and `js/view.js` hides the HUD and the playfield on a finished game's display.
   Nothing here is a remembered pixel width, and `hidden` (hence `display: none` above) still takes
   the whole subtree out of the layout, out of focus order and out of reach of a pointer or a key. */
#score-view:not([hidden]) {
  position: relative;              /* the shared frame’s containing block (Stage 5J.8) */
  width: 100%;
  margin: 0;
  /* Stage 5J.8: the page adopts the shared cabinet frame, so its heading, its rows, its own
     notes and its way back keep at least the contract’s content area from the page’s own box.
     The predecessor’s own clamp still decides the size, but the band adds to it on every side,
     so a long note or a row of letters can never come out from under the band. */
  padding: max(clamp(12px, 3vmin, 32px), var(--frame-content));
  border: none;
  border-radius: 0;
  flex-grow: 1;                  /* takes the cabinet's content box: a full-screen page */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--frame-page-gap);
  background: linear-gradient(168deg, #0b1030 0%, #1a2150 52%, #2b2d63 100%);

  /* Stage 5J.9: the table's OWN geometry, named once here — its four column tracks, the gap between
     them, the box they sit in and the size they read at. The column headings (`js/view.js` keeps
     them inside this table, ahead of the rows) and every row compose the SAME names, so a label can
     never drift off its own column, and the compact short-window scale below only moves the names
     the rest already reads. Nothing here is a remembered pixel width: the table is a share of the
     page's own box, and the band it keeps clear is #33's and #36's `--frame-content`, not a px. */
  --board-col-rank: minmax(2.4em, 0.8fr);
  --board-col-initials: minmax(5.2em, 1.4fr);
  --board-col-score: minmax(3.2em, 1.4fr);
  --board-col-level: minmax(4.4em, 1.6fr);
  --board-cols: var(--board-col-rank) var(--board-col-initials) var(--board-col-score) var(--board-col-level);
  --board-gap: clamp(4px, 1.2vmin, 14px);
  --board-row-gap: clamp(3px, 0.9vmin, 11px);
  --board-table: min(94%, 720px);
  --board-pad: clamp(6px, 1.2vmin, 14px) clamp(10px, 2.2vmin, 22px);
  --board-size: clamp(14px, 2.9vmin, 27px);
  --board-slot: 1.6em;
}

/* The heading reads at page scale, in the same accent the other dedicated pages’ headings take. */
#score-view .board-heading {
  font-size: var(--frame-title-size);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

/* The line the page says about itself per route (`js/view.js` writes it and its `hidden`): on the
   menu's look it names the page as read-only. Secondary to the heading, primary over the rows —
   Stage 5J.9 puts it between the title and the table, since what it says is how the table below is
   being used. */
#score-view .board-mode {
  margin: 0;
  font-size: clamp(12px, 1.9vmin, 17px);
  line-height: 1.45;
  color: var(--muted);
  text-align: center;
}

#score-view .board-mode[hidden] {
  display: none;
}

.board .board-heading {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.board-rows {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
}

/* Stage 5J.9: one row grid, shared by the table's own column headings and every row under them —
   the same four tracks (`--board-cols`, declared once on the page above), the same column gap, the
   same reading size, so a heading can never sit beside the wrong column. The older base rules stay
   as the class list's fallback for a panel that has no page to compose the names from. */
.board-rows li {
  display: grid;
  grid-template-columns: var(--board-cols);
  column-gap: var(--board-gap);
  align-items: baseline;
  font-size: clamp(11px, 2vmin, 13px);
  font-variant-numeric: tabular-nums;   /* stable digits, so "100" and "900" keep the same column */
}

/* The rank column is a fixed width in `em`, so a two-digit rank ("10.") still fits and every
   score lines up under it at any font size the cabinet gives it. */
.board-rows .board-rank {
  justify-self: end;
  color: var(--muted);
}

/* The score is the number a player is chasing, so it carries the accent; how far the run got
   is secondary and stays muted. */
.board-rows output,
.board-rows .board-level {
  justify-self: end;
}

.board-rows output {
  color: var(--accent);
}

.board-rows .board-level {
  color: var(--muted);
}

/* Stage 5E.1: the way out of a finished game, and it belongs to the panel that shows the finished
   game's board — `js/view.js` keeps `#score-view` hidden until the round machine has advanced into
   the finished game's display, so this control is out of the page, out of focus order and
   unreachable by pointer or key for as long as a round is in play, and `js/menu.js` refuses its
   name until the same beat. It keeps the treatment the touch panels give their buttons (a real
   `<button>`, a thumb-sized box: `CONFIG.TOUCH.MIN_BUTTON_PX` is 44 and so is this) because the
   finger that has just read the board is the finger that taps out of a finished game, and a
   keyboard reaches the same control through Tab + Enter, which is why the page needs no key of
   its own. */
.board .board-back {
  appearance: none;
  -webkit-appearance: none;
  margin: 8px 0 0;
  min-width: 44px;
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid rgba(120, 150, 255, 0.35);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink);
  font-family: inherit;
  font-size: clamp(13px, 2.4vmin, 18px);
  letter-spacing: 0.08em;
  display: grid;
  place-content: center;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.board .board-back[hidden] {
  display: none;
}

/* The same pressed feedback the arcade controls already give, so a tap reads as a press even where
   `:active` would have given up. Nothing writes this: it is a pointer state, not a game state. */
.board .board-back:active,
.board .board-back:focus-visible {
  background: var(--accent);
  color: var(--bg);
}

/* Stage 5E.3: what an EMPTY finished board says about itself, in the panel that owns a finished
   game's page (`js/view.js` writes the text and the `hidden`). Secondary like the heading it sits
   under and like the level column, and one sentence rather than a row: it never imitates a score.
   It claims the height it needs and nothing else — the panel keeps claiming height, never width,
   which is what keeps the maze whole and the page unscrolled. */
.board .board-empty {
  margin: 6px 0 0;
  font-size: clamp(11px, 2vmin, 13px);
  color: var(--muted);
  text-align: center;
}

/* Absent, it claims nothing at all — the same rule every other block in this panel keeps, and the
   reason `js/view.js` asks the layout to re-plan when the note starts or stops being shown. */
.board .board-empty[hidden] {
  display: none;
}

/* Stage 5E.2: the initials an entry may carry, in the row presentation both board panels share.
   Secondary to the score (the number is what a player is chasing) and dimmer than it, and an entry
   that carries none shows an em dash rather than a hole — which is the shape every score earned
   before this stage has, and the shape a player gets when they chose `No initials`. */
.board .board-initials {
  color: var(--muted);
}

#score-view .board-rows .board-initials {
  color: #cbd4e6;          /* the silver column: the letters sit in the track this table always
                              reserved for them, and the score still owns the accent */
}

#score-view .board-rows li[data-placeholder] .board-initials {
  opacity: 0.55;           /* an empty position dims its value spans, not its rank */
}

/* Stage 5J.9: the pad is ONE group BELOW the leaderboard — the line that says what the controls do,
   the alphabet, the three ways out — centred under the row it fills, and never beside it. `js/initials.js`
   keeps the whole block `hidden` unless an entry is actually waiting for letters, so a nonqualifying
   game over never shows one, a read-only look from the menu never offers one, and a round in play can
   never reach one (the panel itself is `hidden` for as long as a round is playing, which takes this
   whole subtree out of the layout, out of focus order and out of reach of a pointer or a key).

   The keys keep the treatment the touch panels give their buttons: a thumb-sized box (at or above
   `CONFIG.TOUCH.MIN_BUTTON_PX`, 44), no tap highlight, no selection, one press of feedback — the
   finger that has just read the board is the finger typing three letters. The alphabet wraps over as
   many lines as the page's own width has, and a stack taller than the band is the document's own
   vertical scroll, which a thumb and a keyboard both reach; nothing here grows sideways. */
#score-view .initials {
  margin: 0;
  width: min(var(--board-table), 100%);
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 6px 8px;
  border: 1px solid rgba(120, 150, 255, 0.25);
  border-radius: 10px;
  background: rgba(8, 12, 26, 0.55);
}

/* An absent pad claims nothing at all, and its absence is the layout's truth: the block starting or
   stopping to claim height inside the board panel is why `js/initials.js` asks the layout to re-plan. */
#score-view .initials[hidden] {
  display: none;
}

/* The line above the letters, in the words a player and a check can read: it names the three controls
   below the alphabet, which is the half a tap cannot show. Secondary type, still a readable size —
   it is an instruction, not a caption to be squinted at. */
#score-view .initial-hint {
  font-size: clamp(12px, 2vmin, 17px);
  line-height: 1.4;
  color: var(--muted);
  text-align: center;
}

/* The alphabet, as one group that wraps into as many lines as the page's own width has. */
#score-view .initial-keys {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-content: start;
  gap: 4px;
}

/* Stage 5J.9: the three slots a player reads are the provisional row's own cells, INLINE in that row's
   Initials column (written by `js/view.js` from `js/initials.js`'s model), so the keyboard under the
   board has a row to type into rather than a strip of dashes above a disconnected keyboard. The column
   is a three-cell grid of the column's own width, so the slots keep their places whatever the row is
   showing. */
#score-view .board-rows .board-initials[data-editing] {
  display: inline-grid;
  grid-template-columns: var(--board-slot) var(--board-slot) var(--board-slot);
  gap: 0.14em;
  justify-items: center;
  align-items: baseline;
  font-size: var(--board-size);
  letter-spacing: 0.08em;
  color: var(--ink);
}

#score-view .board-rows .initial-slot {
  justify-self: center;
  min-height: 1.35em;
  text-align: center;
  color: var(--muted);
  position: relative;        /* the caret is placed against the slot it belongs to */
}

#score-view .board-rows .initial-slot[data-filled="true"] {
  color: #cbd4e6;            /* the letters a player has actually entered, beside the score's accent */
}

/* The slot still waiting for a letter, and the caret in it. The slot says so itself (`data-active="true"`,
   which a check and any assistive technology can read without waiting for a blink), and the caret is a
   pseudo-element with no content of its own — an empty string announces nothing while it flashes. */
#score-view .board-rows .initial-slot[data-active="true"]::after {
  content: '';
  position: absolute;
  top: 8%;
  right: -0.16em;
  width: 0.14em;
  height: 84%;
  background: var(--accent);
  pointer-events: none;      /* decoration: it takes no tap and holds no focus */
}

/* The blink is restrained: one on/off pair per 1.6s (0.6 flashes a second, well under the 3 a second
   an arcade cabinet would otherwise put a player's eye through), with hard cuts rather than a fade. */
@keyframes initial-caret {
  0%, 49.9% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

@media (prefers-reduced-motion: no-preference) {
  #score-view .board-rows .initial-slot[data-active="true"]::after {
    animation: initial-caret 1.6s linear infinite;
  }
}

/* Under prefers-reduced-motion the caret stays put and the slot is dressed as a SELECTED field instead:
   a solid box around the one slot that is waiting, which reads as a place to type rather than as a
   something-is-here pulse. Nothing animates, and the same information is still on the page. */
@media (prefers-reduced-motion: reduce) {
  #score-view .board-rows .initial-slot[data-active="true"] {
    animation-name: none;
    animation-duration: 0s;
    box-shadow: inset 0 0 0 0.1em var(--accent);
    border-radius: 3px;
    background: rgba(86, 225, 255, 0.14);
  }
  #score-view .board-rows .initial-slot[data-active="true"]::after {
    animation-name: none;
    opacity: 1;
  }
}

#score-view .initial-key {
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
  min-width: 46px;
  min-height: 46px;
  padding: 4px 6px;
  border: 1px solid rgba(120, 150, 255, 0.35);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font-family: inherit;
  font-size: clamp(13px, 2.6vmin, 18px);
  display: grid;
  place-content: center;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#score-view .initial-key:active,
#score-view .initial-key:focus-visible {
  background: var(--accent);
  color: var(--bg);
}

/* The two ways to resolve an entry, on a line of their own: `Submit` records the finished game with
   the letters typed, `No initials` records it in the shape the board has always stored. A finished
   game's name is never mandatory, and a third outcome (leaving the page by `Back to menu` without resolving) records
   nothing at all — see `js/initials.js` and `js/game.js` for why. */
#score-view .initial-actions {
  width: 100%;
  display: flex;
  gap: 6px;
  justify-content: center;
}

#score-view .initial-submit,
#score-view .initial-skip,
#score-view .initial-clear {
  appearance: none;
  -webkit-appearance: none;
  min-height: 46px;
  padding: 10px 16px;
  border: 1px solid rgba(120, 150, 255, 0.35);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink);
  font-family: inherit;
  font-size: clamp(11px, 2vmin, 13px);
  letter-spacing: 0.08em;
  display: grid;
  place-content: center;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#score-view .initial-submit:active,
#score-view .initial-submit:focus-visible,
#score-view .initial-skip:active,
#score-view .initial-skip:focus-visible,
#score-view .initial-clear:active,
#score-view .initial-clear:focus-visible {
  background: var(--accent);
  color: var(--bg);
}

/* Stage 5J.9 retires the side-by-side arrangement this media query used to give a wide window: the
   alphabet, the editing control and the two ways out belong BELOW the leaderboard on every window
   (the row a player is typing into is in the board, so the keys that fill it read under it), and
   `Back to menu` sits beneath the content. One centred column therefore costs the maze nothing new
   on the routes that hide the game unit, and a window shorter than the stack scrolls vertically
   rather than shrinking the board to fit it. The page still composes #36's `--frame-content`, so
   nothing in the stack can come out from under the band, and nothing here grows sideways. */

/* Stage 5D.4 / Stage 5J.9: the High Scores screen's OWN arcade table — always the board's capacity
   of positions (the filled ones written by `view.js`'s row writer). Large arcade rows: rank, initials,
   score (cyan, the number a player is chasing), level — in the SAME order the page's own headings are
   written in and the same order a screen reader reads them. The four tracks, the gap, the box and the
   type scale are the names the page declares above, so a heading can never sit over the wrong column
   and nothing here is a remembered px. Nothing here stores or writes names: a row either carries the
   letters `js/initials.js` validated, or it has none at all and its column reads as a dash. Gold/silver/
   bronze tint the top three POSITIONS (counted with `nth-of-type`: the table's own headings are a child
   of this box and are not a position). */
#score-view .board-rows {
  list-style: none;
  margin: auto;
  padding: var(--board-pad);
  width: var(--board-table);
  display: grid;
  gap: var(--board-row-gap);
  background: rgba(8, 12, 26, 0.62);
  border: 1px solid rgba(120, 150, 255, 0.25);
  border-radius: 12px;
}

/* The table's own headings: the same four tracks, the same column gap and the same size as every row,
   so each label sits over its column. They are not a row — no rank, no score, no level — and they are
   markup, never written by a module. */
#score-view .board-columns {
  display: grid;
  grid-template-columns: var(--board-cols);
  column-gap: var(--board-gap);
  align-items: baseline;
  font-size: var(--board-size);
  letter-spacing: 0.06em;
  color: var(--muted);
}

#score-view .board-rows li {
  display: grid;
  grid-template-columns: var(--board-cols);
  column-gap: var(--board-gap);
  align-items: baseline;
  font-size: var(--board-size);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;    /* the same digits at the same width, where the face has them */
}

#score-view .board-rows .board-rank {
  color: var(--muted);
}

#score-view .board-rows output {
  color: #56e1ff;
}

#score-view .board-rows .board-level {
  color: var(--muted);
}

/* The numbers read to their right edge, so a two-digit score still lines up under a one-digit one,
   and the label of a column sits the same way over it. The Initials column is centred: its three
   slots (or its three letters, or its dash) are one block of their own. */
#score-view .board-columns .board-column,
#score-view .board-rows .board-rank,
#score-view .board-rows output,
#score-view .board-rows .board-level {
  justify-self: end;
}

#score-view .board-columns [data-column="initials"],
#score-view .board-rows .board-initials {
  justify-self: center;
}

/* The top three positions carry the medal accents, filled or not. `nth-of-type` rather than `nth-child`
   since Stage 5J.9 put the table's own headings inside the same box: the headings are not a position. */
#score-view .board-rows li:nth-of-type(1) .board-rank { color: #ffd479; }
#score-view .board-rows li:nth-of-type(2) .board-rank { color: #cbd4e6; }
#score-view .board-rows li:nth-of-type(3) .board-rank { color: #c88a55; }

/* Stage 5J.9: the row the finished game is still ASKING about reads as the row it will become, and
   it is told apart by SHAPE as well as by colour — a tinted line plus a 2px accent bar down its
   reading edge — so a player looking for their own row is not asked to tell two colours apart. The
   bar is a pseudo-element with no content of its own: it says nothing to a screen reader, it takes
   no tap, and it is never the focused element. */
#score-view .board-rows li[data-provisional] {
  position: relative;
  background: rgba(86, 225, 255, 0.1);
  border-radius: 6px;
}

#score-view .board-rows li[data-provisional]::before {
  content: '';
  position: absolute;
  inset: 0;
  border-left: 2px solid var(--accent);
  border-radius: 6px;
  pointer-events: none;
}

/* Stage 5D.4 kept the empty positions of the legacy board dimmer than a filled one; the writer that
   marks them was retired with that panel, so the rule stays for any caller that still asks for an
   empty position and nothing else dims a row. A provisional row is never one of those. */
#score-view .board-rows li[data-placeholder] output,
#score-view .board-rows li[data-placeholder] .board-level {
  opacity: 0.55;
}

/* A short band reads the table at its own compact scale: the SAME names the wide window reads, at a
   smaller share of it. The rows keep their four aligned columns and their readable digits at every
   window; what a short window gives up is the page's own vertical room, and a stack taller than the
   band is the document's own vertical scroll, never a sideways one and never a shrunken table. */
@media (max-height: 560px) {
  /* The SAME selector the page composes its geometry with, so this is an override of those names and
     not a lower-specificity rule the page above would win. */
  #score-view:not([hidden]) {
    --board-table: min(96%, 620px);
    --board-pad: clamp(2px, 0.7vmin, 10px) clamp(8px, 2vmin, 18px);
    /* Keep the regular readable row size; short screens scroll instead of shrinking text. */
    --board-gap: clamp(3px, 0.9vmin, 10px);
    --board-row-gap: clamp(1px, 0.5vmin, 8px);
    gap: clamp(2px, 0.6vmin, 8px);
  }
  #score-view .board-mode { font-size: var(--board-size); }
  #score-view .board-back { margin: 0; }
  #score-view .board-rows { max-height: none; }
}

/* Stage 5D.4b: the gameplay instruction footer is gone from the page and from this stylesheet —
   its element, its three instruction lines, and every rule that used to size or fold them. The
   instructions live on the dedicated How to Play page (the `.screen` blocks below, Stage 5D.2's
   guide), so the playing page carries no instruction prose at all and the maze gets the room those
   lines used to cost. js/layout.js measures the blocks that are actually in the page, so with the
   footer absent the unit it measures is one block shorter and the maze grows; that is the whole
   layout consequence of the removal, and nothing here needed a replacement. */

/* Stage 5B.1a asked for the short window's gap to be measured rather than remembered: the room
   between the cabinet's blocks is pure vertical cost on a window the maze is height-limited by,
   and at 844x390 the maze had 275 px of height to spend while 11 tiles is 253 px of them, so a
   whole tile was stranded in the gaps. Stage 5B.1b found the same answer at EVERY window — a
   desktop maze is height-limited too — so the figure now lives once at the root (`--gap`) and
   this override is gone: one number, read off the resolved page by js/layout.js, cannot
   disagree with the page that paints it. The margins stay at 10px, because those are the outer
   breathing room a thumb and a screen edge need; the safe-area inset is added to them by
   `.cabinet` and still costs the maze whatever the device reports. Stage 5D.4b then took the one
   block this note used to weigh against, the instruction footer, out of the page: the cabinet's
   flex children around the playfield are now the HUD row and whichever boards are in the page,
   and `--gap` is still the measured gap between each pair of them. */
@media (max-width: 760px), (max-height: 560px) {
  .hud .title { display: none; }
}

/* Stage 5D.4b: the row now carries five read-outs across a maze that is only 13-17 px per tile on
   a phone, so the spacing and the letter-spacing shrink where a desktop's do not — that is what
   keeps `HIGH SCORE` and the three life icons clear of each other and the row on one line at 390
   wide and at 844x390 sideways. The fonts stay where Stage 5B put them (9-11px of label, 13-18px
   of read-out); the icons step down 2px here only, which is "approximately their current size"
   rather than enlargement, and they are the one thing in the row whose width is set by pixels. */
@media (max-width: 760px), (max-height: 560px) {
  .stats { gap: clamp(4px, 1.1vmin, 12px); padding: 3px clamp(5px, 1.4vmin, 14px); }
  .stat span { letter-spacing: 0.06em; }
  .stat.lives output { gap: 3px; }
  .life-icon { width: 14px; height: 14px; }
}

/* Debug inspector. Off during normal play (`hidden`), so the normal presentation stays
   clean; debug UI never feeds back into the simulation. */
.inspector {
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid rgba(120, 150, 255, 0.25);
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.45;
}

.inspector[hidden] {
  display: none;
}

.inspector h2 {
  margin: 0 0 8px;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

/* The read-out is two columns of lines, and the tracks are percentages, not `max-content`:
   a `max-content` track is as wide as the widest line, so one long read-out line grew the
   panel past the column the playfield gave it — which is what put the panel over the stage
   and off the window at 900px. Percentages keep the panel in its column and let a long
   value wrap onto a second line inside it instead. */
.inspector-global {
  display: grid;
  grid-template-columns: 46% 50%;
  gap: 3px 10px;
  margin-bottom: 10px;
}

/* The label and the value are separate elements with no text between them, so the gap is
   what keeps "player speed" and "4.70 tiles/s" from reading as one word. */
/* The label and the value are separate elements with no text between them, so the gap is
   what keeps "player speed" and "4.70 tiles/s" from reading as one word. */
.inspector-line span {
  color: var(--muted);
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.1em;
  margin-right: 6px;
}

.inspector-line output {
  color: var(--ink);
}

.inspector-enemies {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.inspector-enemies li {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.inspector-enemies .tag {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border-radius: 5px;
  background: rgba(120, 150, 255, 0.18);
  color: var(--ink);
  font-size: 11px;
}

.inspector-enemies .inspector-shy {
  color: var(--accent);
}

/* An activation reversal waiting for its decision point. The class is emitted by
   js/inspector.js, so it needs a rule of its own rather than inheriting the row colour. */
.inspector-enemies .inspector-reversal {
  color: var(--accent);
  font-size: 11px;
  margin-top: 2px;
}

/* --------------------------------------------------------- stage 5A: the D-pad */

/* The pad is in the page only while js/touch.js says the device has a coarse pointer:
   index.html starts the panel `hidden` and touch.js clears that attribute on a phone or
   tablet. A keyboard player therefore never sees it — `display: none` takes the whole
   panel out of the playfield grid, so nothing about the desktop layout or its centring
   moves. The buttons themselves are built by js/touch.js, which is why the controls are
   styled here by the data they carry (`data-control`, `data-kind`) rather than by class
   names a reader would have to guess. */
.dpad {
  display: grid;
  grid-template-columns: repeat(3, var(--pad-button));
  grid-template-rows: repeat(3, var(--pad-button));
  gap: var(--pad-gap);
  justify-self: center;
  align-self: start;
  touch-action: none;
}

/* Declared after `display: grid` and on a more specific selector, so the `hidden` attribute
   the page starts with — and that touch.js re-sets on a desktop pointer — always wins. */
.dpad[hidden] {
  display: none;
}

/* The cross: four arms, one per direction, around an empty centre. The centre and the
   gaps are the dead zone js/touch.js reads as "no control", which is what keeps a thumb
   resting between two arms from picking one at random. The cross is three rows tall on its
   own now (Stage 5A.1a): the two actions live in their own panel, so a landscape window can
   put the cross to the LEFT of the maze and the actions to the RIGHT of it. In portrait that
   panel is simply the next block below the maze, under the cross, where the fourth row used
   to be. */
.dpad [data-control="up"] { grid-area: 1 / 2 / 2 / 3; }
.dpad [data-control="left"] { grid-area: 2 / 1 / 3 / 2; }
.dpad [data-control="right"] { grid-area: 2 / 3 / 3 / 4; }
.dpad [data-control="down"] { grid-area: 3 / 2 / 4 / 3; }

/* The actions panel: PAUSE and RESTART side by side, the same thumb-sized boxes as the
   cross, and nothing else — the dead centre of the cross stays a dead centre here too,
   which is why the two are separated by a whole button width in portrait (the columns
   below) rather than nudged together. Stage 5B.1a takes that dead centre back in LANDSCAPE
   (see the media block below): the panel is a measured column there, so a dead one is a
   column the maze cannot use, and the two buttons only need their own two. */
.actions {
  display: grid;
  grid-template-columns: repeat(3, var(--pad-button));
  grid-template-rows: var(--pad-button);
  gap: var(--pad-gap);
  justify-self: center;
  align-self: start;
  touch-action: none;
}

/* Declared after `display: grid` and on a more specific selector, so the `hidden` attribute
   the page starts with — and that touch.js re-sets on a desktop pointer — always wins. */
.actions[hidden] {
  display: none;
}

.actions [data-control="pause"] { grid-area: 1 / 1 / 2 / 2; }
.actions [data-control="reset"] { grid-area: 1 / 3 / 2 / 4; }

/* One button treatment for both panels: they are the same control, only held apart. */
.dpad button, .actions button {
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
  padding: 0;
  border: 1px solid rgba(120, 150, 255, 0.35);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink);
  font-family: inherit;
  display: grid;
  place-content: center;
  transition: background 90ms linear, color 90ms linear, transform 90ms linear;
}

.dpad [data-kind="direction"] {
  font-size: clamp(18px, 4vmin, 26px);
}

/* The actions say what they do in words, because a glyph like "II" or "↻" is a guess for
   a family audience; the aria-label on each button carries the same words for a reader. */
.dpad [data-kind="action"], .actions [data-kind="action"] {
  font-size: clamp(9px, 2vmin, 12px);
  letter-spacing: 0.08em;
}

/* Pressed-state feedback. js/touch.js writes `data-pressed` on the arm the finger is on,
   rather than trusting `:active`, which a touch browser holds only briefly: this is the
   state that stays visibly lit for as long as the hold does, which is the whole point of
   press-and-hold. */
.dpad [data-pressed], .actions [data-pressed] {
  background: var(--accent);
  color: var(--bg);
  transform: scale(0.96);
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.55), 0 0 12px rgba(93, 232, 200, 0.35);
}

/* No browser gesture anywhere near the game. `touch-action: none` is what stops a swipe
   on the maze or a pad arm from panning the page or pinch-zooming the stage; `user-select:
   none` stops a long press from selecting the buttons' own labels; the tap highlight is
   switched off so a press shows the pressed state above rather than a grey box over it. */
.stage, canvas, .dpad, .dpad button, .actions, .actions button {
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.dpad button:focus-visible, .actions button:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

/* ------------------------------------------------- where the touch controls belong

   Stage 5A.1a makes the landscape arrangement read left to right:

     [D-PAD]  [MAZE + HUD]  [PAUSE / RESTART]

   The cross goes to the LEFT of the maze and the two actions to the RIGHT of it, which is
   the way a landscape phone is actually held: the left thumb reaches the cross, the right
   thumb reaches PAUSE and RESTART, and neither has to cross the maze. Nothing else moves:
   the HUD stays directly above the maze, the maze keeps its column, and the debug inspector
   keeps its own column at the same widths as before.

   In portrait — and in any landscape window too narrow to hold a cross column, a maze
   column and an actions column — the two panels stack under the maze instead, which is
   where they already sat, and the inspector goes below them. js/layout.js measures both
   panels (and the cabinet padding, which carries the `env(safe-area-inset-*)` allowance)
   into the tile it chooses, so the maze fits between the controls rather than under them:
   nothing is cropped, distorted or pushed off the edge, and normal play does not scroll.
   The two control columns also stay inside that padding, so a notch, a punch-hole camera
   or the browser's own edge is never a target a thumb has to reach into.

   The 560 px mirrors CONFIG.TOUCH.PAD_BREAKPOINT_PX — the same figure js/touch.js writes
   into `data-layout`, so the claim and the geometry cannot drift apart unnoticed. The
   second block is the debug case, where the inspector already claims a column: at 860 px
   and above it takes its own column to the right of the actions rather than pushing the
   maze off screen. A track only gets width from an item that is actually in the page, so
   `:has()` still keeps the wide debug column out of normal play. */
.playfield:has(.dpad:not([hidden])) .stage { grid-area: 1 / 1; }
.playfield:has(.dpad:not([hidden])) .dpad { grid-area: 2 / 1; }
.playfield:has(.dpad:not([hidden])) .actions { grid-area: 3 / 1; }
.playfield:has(.dpad:not([hidden])) .inspector { grid-area: 4 / 1; }

@media (orientation: landscape) and (min-width: 560px) {
  .playfield:has(.dpad:not([hidden])) {
    width: 100%;
    grid-template-columns: minmax(0, auto) minmax(0, 1fr) minmax(0, auto);
  }
  /* Stage 5B.1a: two buttons, two columns. In portrait the actions panel keeps the cross's
     three columns so the pair stays under the arms it always sat under; in landscape the panel
     is a column measured against the maze, so the cross's dead centre would be a column of
     nothing the maze cannot use. The same two thumb-sized boxes, on the maze's right, one
     button width closer to each other — the arrangement, and the maze's aspect ratio, unchanged.

     Stage 5D.4b keeps those two boxes and gives the PANEL the cross's own column width. The two
     control panels are not the same width (the cross is three buttons plus two gaps, the pair is
     two plus one), and an asymmetric pair of auto columns leaves the maze column off the middle of
     the page — 27 px at 844x390 — which is exactly what a HUD row as wide as the maze would be
     misread against. Making the two side columns equal puts the maze column dead centre on the
     cabinet, and the HUD row (centred, and built from the maze's own rendered width) then lines up
     with it at every window and after every flip; nothing in either is a remembered pixel width.
     The extra room is dead space INSIDE the actions panel with the two buttons centred in it, and
     js/touch.js maps a press by each button's own box, so the buttons stay thumb-sized and a thumb
     resting in that dead space still rests. js/layout.js measures the panel's box, so the maze
     pays for the column it is actually given — and at every landscape window the suite measures the
     maze is height-limited, so the tile it chooses does not move. */
  .playfield:has(.dpad:not([hidden])) .actions {
    grid-template-columns: repeat(2, var(--pad-button));
    justify-content: center;
    min-width: calc(3 * var(--pad-button) + 2 * var(--pad-gap));
  }
  .playfield:has(.dpad:not([hidden])) .actions [data-control="pause"] { grid-area: 1 / 1 / 2 / 2; }
  .playfield:has(.dpad:not([hidden])) .actions [data-control="reset"] { grid-area: 1 / 2 / 2 / 3; }
  /* Centred on the maze's row rather than pinned to its top: that is where a thumb resting
     on the side of a landscape phone actually is, and what keeps PAUSE/RESTART out of a
     screen corner. */
  .playfield:has(.dpad:not([hidden])) .dpad { grid-area: 1 / 1; align-self: center; }
  .playfield:has(.dpad:not([hidden])) .stage { grid-area: 1 / 2; }
  .playfield:has(.dpad:not([hidden])) .actions { grid-area: 1 / 3; align-self: center; }
  /* Debug below the maze here: the window has a maze column and two control columns, but
     no room for a fourth read-out column. */
  .playfield:has(.dpad:not([hidden])) .inspector { grid-area: 4 / 1; }
}

@media (orientation: landscape) and (min-width: 860px) {
  .playfield:has(.dpad:not([hidden])):has(.inspector:not([hidden])) {
    width: 100%;
    grid-template-columns: minmax(0, auto) minmax(0, 1fr) minmax(0, auto) minmax(240px, 300px);
  }
  .playfield:has(.dpad:not([hidden])):has(.inspector:not([hidden])) .inspector { grid-area: 1 / 4; }
}

/* The existing wide debug layout must remain one column in touch portrait. */
@media (orientation: portrait) {
  .playfield:has(.dpad:not([hidden])) { width: 100%; grid-template-columns: minmax(0, 1fr); }
}

/* Stage 5D.4b: the phone's footer rules are gone with the footer. A phone still gets its words
   where its controls already are — the pad's own PAUSE / RESTART labels and the maze's READY /
   PAUSED / GAME OVER — and the rest on the How to Play page, which the menu opens on the same
   tap that opened any other page. */

/* Task48: compact rows preserve the existing Settings reading width. */
.picker-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: min(calc(100% - (var(--frame-content) * 2)), 880px);
  margin: auto;
}
.picker-grid .picker { width: 100%; min-width: 0; margin: 0; padding: 8px 12px; gap: 6px; }
.picker-grid .picker[data-picker-role="player"] { grid-column: 1 / -1; }
/* [q#49] splits #48’s heading into its two tones inside the ONE <label for=…> the group already
   carries: the slot’s identity (its own name plus the roster’s own personality word) wears the
   treatment every other arcade label on this cabinet wears — the accent, bold, letterspaced,
   uppercase, the same system as `.screen h2`, `.screen-heading` and the menu’s controls — while the
   words beside it that say what the slot *does* stay sentence-case ink, because that clause is copy
   and the task asked that no decorative treatment be pushed onto prose. No new font, no new colour:
   both tones are tokens the page already answers with, and the accent on this panel reads about
   12:1, the ink about 15:1.
   The geometry only moves by the heading’s own line box: the group stays inside the shared band,
   the reading width below is unchanged, and the focus ring on the control is untouched. */
.picker-heading { font-size: clamp(12px, 1.6vmin, 17px); line-height: 1.4; }
.picker-heading .picker-heading-label {
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.picker-heading .picker-heading-note {
  color: var(--ink);
  letter-spacing: 0;
}
.picker-control { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 10px; align-items: center; }
.picker-preview { display: grid; place-items: center; min-height: 56px; min-width: 0; }
.picker-preview-status { font-size: clamp(11px, 1.5vmin, 15px); line-height: 1.25; text-align: center; color: var(--ink); }
.picker-preview-status[hidden], .picker-preview img[hidden] { display: none; }
.picker .picker-select {
  width: 100%; min-width: 0; min-height: 44px; padding: 8px; border-radius: 8px;
  color: var(--ink); background: #101830; border: 1px solid #788ab8; font: inherit;
}
.picker-select:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
@media (max-width: 600px) { .picker-grid { grid-template-columns: minmax(0, 1fr); } }

/* Fit previews within their column without changing the canonical art ratio. */
.picker-preview .picker-portrait { height: auto; width: auto; max-width: 100%; max-height: clamp(32px, 4.4vmin, 56px); }

/* Keep the guide, score rows and initials controls clear of their persistent Back footer. */
.screen[data-screen="howto"],
#score-view:not([hidden]) {
  padding-bottom: calc(144px + env(safe-area-inset-bottom, 0px));
}

.screen[data-screen="howto"] :is(button, a),
#score-view :is(button, a) {
  scroll-margin-block: 20px 144px;
}

#score-view .page-footer .board-back {
  margin: 0;
  min-height: clamp(52px, 7vmin, 92px);
  max-width: 100%;
  padding: 12px 28px;
  border-radius: 12px;
  font-size: var(--frame-line-size);
  letter-spacing: 0.08em;
}

/* Release label stays in the safe bottom-left corner and never intercepts game input. */
.version-stamp {
  position: fixed;
  z-index: 21;
  left: max(10px, env(safe-area-inset-left, 0px));
  bottom: max(4px, env(safe-area-inset-bottom, 0px));
  padding: 0 4px;
  border-radius: 3px;
  background: rgba(5, 7, 15, 0.85);
  color: var(--muted);
  font-size: 11px;
  line-height: 16px;
  letter-spacing: 0.06em;
  pointer-events: none;
  user-select: none;
}

#score-view #shared-score-status { max-width: 70ch; text-align: center; color: var(--muted); font-size: var(--frame-line-size); }
