/* ============================================================
   console.css, the console shell every child page sits in (owner 08/11/26, v0.6)
   ============================================================
   One fixed 16:9 screen box holds ALL child-facing content, laid out against a fixed logical size (640x360,
   js/arcade/console.js) and scaled as a unit. The page never scrolls. Laptop and desktop landscape only: one layout,
   no portrait branch. The screen sits in the middle; the Joy-Con rails flank it, each rail --side wide:
   left = D-pad (W A S D) with Capture (C) below, right = the X Y A B diamond with Home (N) below. Below 1024 px wide,
   below 480 px tall, in portrait or on a touch-only device the gate (js/arcade/console-gate.js) covers it all.
   The first-paint screen width below is the exact fit; js/arcade/console.js overrides --sw/--sh with pickScale().
   Load AFTER the page's own css. Page-level links ("Back to start", staff links) sit outside the screen as a small strip. */

html.console-page { font-size: 16px; height: 100%; overflow: hidden; }
html.console-page body { margin: 0; height: 100%; min-height: 0; overflow: hidden; display: grid; place-items: center; background: #0e1a14; }

html.console-page .console.console {
  --cu: 44px;            /* the control unit: one D-pad key */
  --pm: 12px;            /* body padding */
  --gap: 12px;
  --rs: 26px;            /* a strip kept clear at the foot of the viewport for page-level links */
  --side: 160px;         /* one Joy-Con rail */
  --sw: max(320px, min(100vw - 2 * (var(--side) + var(--gap) + var(--pm)), (100dvh - var(--rs) - 2 * var(--pm)) * 16 / 9));
  --sh: calc(var(--sw) * 9 / 16);
  box-sizing: border-box;
  overflow: hidden;
  display: grid;
  grid-template-columns: var(--side) var(--sw) var(--side);
  grid-template-rows: 1fr auto auto 1fr;   /* two spacers centre each rail's two controls beside the screen */
  column-gap: var(--gap); row-gap: 0;
  align-items: center;
  width: calc(var(--sw) + 2 * var(--side) + 2 * var(--gap) + 2 * var(--pm));
  height: calc(var(--sh) + 2 * var(--pm));
  max-width: none; min-height: 0; margin: 0; padding: var(--pm);
  background: #25223f;
  border-radius: 14px 44px 14px 14px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.12) inset, 0 -3px 0 #14122b inset, 0 14px 34px rgba(0, 0, 0, 0.5);
  touch-action: manipulation;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ---- the screen ---- */
.console__screen {
  position: relative;
  grid-column: 2; grid-row: 1 / -1;
  width: var(--sw); height: var(--sh);
  overflow: hidden;
  background: #0b1710;
  border-radius: 6px;
  box-shadow: 0 0 0 5px #0c0b1f, 0 0 0 7px #3a3670;
  --k: 1;
}
.console__content {
  position: absolute; left: 0; top: 0;
  width: 640px; height: 360px;
  transform: scale(var(--k)); transform-origin: 0 0;
  overflow: hidden;
  font-size: 16px;
}
/* the demo's shrink-to-fit wrapper: width and height grow as the scale shrinks, so the layout reflows to use the room */
.console__fit {
  box-sizing: border-box;
  width: calc(100% / var(--z, 1)); height: calc(100% / var(--z, 1));
  transform: scale(var(--z, 1)); transform-origin: 0 0;
  display: flex; flex-direction: column; gap: 0.375rem;
  padding: 0.375rem 0.75rem 0.5rem;
  overflow: hidden;
}
.console__fit.is-scroll { overflow-y: auto; scrollbar-width: thin; }
/* menus and overlays mounted into the content are positioned against the screen, never the window */
.console__content .arcade-menu, .console__content .arcade-overlay { position: absolute; }

/* ---- the controls: the existing pad components become grid items of the console ---- */
.console__pad, .console .arcade-touchpad, .console .arcade-padrow, .console .pad { display: contents; }
.console .arcade-dpad, .console .dpad { grid-column: 1; grid-row: 2; justify-self: center; align-self: center; }
.console .arcade-cap, .console .pad__cap { grid-column: 1; grid-row: 3; justify-self: center; align-self: start; margin-top: 16px; }
.console .arcade-ab, .console .actions { grid-column: 3; grid-row: 2; justify-self: center; align-self: center; }
.console .arcade-home, .console .pad__home { grid-column: 3; grid-row: 3; justify-self: center; align-self: start; margin-top: 16px; }
.console__pad[hidden] { display: contents; visibility: hidden; }

/* grid-template-areas plus separate tracks: the one-line grid-template shorthand with var() tracks computed invalid and stacked all four keys in one cell */
.console .arcade-dpad { display: grid; grid-template-areas: ". u ." "l . r" ". d ."; grid-template-columns: var(--cu) var(--cu) var(--cu); grid-template-rows: var(--cu) var(--cu) var(--cu); gap: 0; }
.console .arcade-tbtn { box-sizing: border-box; min-width: var(--cu); min-height: var(--cu); font-size: 18px; }
.console .arcade-tbtn-up, .console .arcade-tbtn-down { justify-self: stretch; }
.console .arcade-tbtn-left, .console .arcade-tbtn-right { justify-self: stretch; }
/* the diamond: X top, Y left, A right, B bottom, each cell 46px so the four sit close and read as one cluster */
.console .arcade-ab { display: grid; grid-template-areas: ". x ." "y . a" ". b ."; grid-template-columns: repeat(3, 46px); grid-template-rows: repeat(3, 46px); gap: 0; margin: 0; }
.console .arcade-ab .arcade-tbtn { min-width: 0; min-height: 0; width: 46px; height: 46px; margin: 0; padding: 0; font-size: 17px; }
.console .arcade-cap .arcade-tbtn, .console .arcade-home .arcade-tbtn { min-width: 4.4rem; min-height: 1.5rem; font-size: 10px; }
.console .dpad { grid-template-columns: repeat(3, var(--cu)); grid-template-rows: repeat(3, var(--cu)); }
.console .actions__btn { width: 46px; height: 46px; }
.console .pad__pill { min-width: 4.4rem; height: 24px; }

/* ---- page-level links outside the screen: a small fixed strip, never a reason to scroll ---- */
html.console-page .console-links { position: fixed; left: 0; right: 0; bottom: 0; height: var(--rs, 26px); display: flex; align-items: center; justify-content: center; gap: 0.75rem; margin: 0; padding: 0; font-size: 12px; color: #9bd8a0; overflow: hidden; white-space: nowrap; }
html.console-page .console-links a { color: inherit; }

/* the Captain Lim and Sprite arrival picture: a fixed band, so it never grows with the width and pushes the Sprite's line off the screen */
.console .demo-arrival-wrap { aspect-ratio: auto; height: 11.5rem; flex: 0 0 auto; }
/* a hidden console (the game before a child is chosen, the start screen once the game opens) is gone, not a grid */
html.console-page .console.console[hidden] { display: none !important; }

/* the mini-game's intro card and 3, 2, 1 sit inside the screen (js/minigames/host-dom.js mounts them in .console__content), sized by the logical screen, never the window */
.console__content .mg-ov { position: absolute; inset: 0; z-index: 50; padding: 8px; overflow: hidden; }
.console__content .mg-intro-head { font-size: 26px; margin-bottom: 4px; padding: 4px 14px; }
.console__content .mg-intro-name { font-size: 20px; margin: 4px 0 6px; }
.console__content .mg-intro-lines { font-size: 15px; margin-bottom: 8px; }
.console__content .mg-intro-lines li { margin: 3px 0; }
.console__content .mg-keys { margin-bottom: 8px; }
.console__content .mg-key { min-width: 34px; height: 34px; font-size: 18px; }
.console__content .mg-ready { min-height: 44px; font-size: 24px; padding: 4px 12px; }
.console__content .mg-intro-rest { margin-top: 6px; font-size: 12px; }
.console__content .mg-count b { font-size: 240px; }

/* a picture's SVG text sits under two nested scales (the screen's --k and the fit's --z): without geometricPrecision Chromium lays the glyphs out at one scale and paints them at another, so clock numerals drifted off the face and the lower ones vanished (Q-i1zk) */
.console svg text { text-rendering: geometricPrecision; }

/* ---- the laptop-only gate (js/arcade/console-gate.js): covers the console under 1024 wide, under 480 tall, in portrait or on a touch-only device ---- */
#console-gate[hidden] { display: none; }
html.console-gated #console-gate { position: fixed; inset: 0; z-index: 2147483000; display: grid; align-content: center; justify-items: center; gap: 10px; box-sizing: border-box; padding: 24px; background: #0e1a14; color: #e8f5e8; text-align: center; font-family: system-ui, sans-serif; }
html.console-gated body > :not(#console-gate) { display: none !important; }
.console-gate__title { margin: 0; font-size: 26px; font-weight: 700; line-height: 1.25; }
.console-gate__line { margin: 0; font-size: 16px; color: #9bd8a0; }

/* U5 + fullscreen (owner 09/11/26): the mini-game fills the screen. The .mg shell is the largest 4:3 box of the 640x360 screen (480x360, height-limited),
   centred; the title and time row and the footer sit INSIDE it and the canvas takes every row left over (about 314 of 360 logical px tall, 87 percent).
   js/minigames/host-dom.js then snaps the canvas to a whole device-pixel multiple of 160x120 when that costs under 10 percent. Logical px only. */
.console__content .mg { position: absolute; inset: 0; margin: auto; box-sizing: border-box; width: 640px; height: 360px; max-width: 100%; max-height: 100%; padding: 3px 8px 4px; display: flex; flex-direction: column; }
/* the end card keeps the 480 wide shell it was drawn for; while playing (owner 12/11/26) the 4:3 field is centred between a 92px left rail (game, mode, song) and a 92px right rail (score and time on top, multiplier and streak at the bottom), its thin timer bar glued to its top; there is no header bar */
.console__content .mg[data-phase=done] { width: 480px; }
.console__content .mg-stage { flex: 1 1 0; min-height: 0; }
.console__content .mg-field { align-items: center; justify-content: flex-end; }
.console__content .mg canvas { flex: 0 0 auto; width: auto; height: auto; max-width: 100%; aspect-ratio: 4 / 3; }
.console__content .mg-foot { margin-top: 2px; flex: 0 0 auto; }
.console__content .mg-hint { min-width: 0; font-size: 12px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* the end card covers the whole shell and is bigger type than the old small field */
.console__content .mg-end b { font-size: 30px; }
.console__content .mg-end .mg-sum { font-size: 17px; }
.console__content .mg-endscore { font-size: 60px; }
.console__content .mg.has-board .mg-end { padding: 12px 16px 8px; }
.console__content .mg.has-board .mg-end b, .console__content .mg.has-board .mg-hi { font-size: 22px; }
.console__content .mg.has-board .mg-end .mg-sum { font-size: 17px; }
.console__content .mg.has-board .mg-end .mg-unlock { font-size: 13px; }
.console__content .mg-board { font-size: 15px; }
.console__content .mg-board li { height: 25px; }
.console__content .mg-boardhead { font-size: 14px; }
.console__content .mg.has-board .mg-end .mg-back { font-size: 14px; }
/* the hut's question layer keeps its padding for menus; a running round takes the whole layer */
/* border-radius 0: the layer's own 12px radius would otherwise show the town canvas (cream) as a wedge at each screen corner (corners2 09/11/26); the screen clips its own 6px corners */
#q-layer:has(> div > .mg) { padding: 0; overflow: hidden; background: #0b1710; border-radius: 0; }
/* the intro card: two columns (title and rules left; keys, Ready and the rest line right) inside the screen */
.console__content .mg-intro { display: grid; grid-template-columns: minmax(0, 1fr) 264px; column-gap: 12px; align-items: center; width: min(612px, 100%); padding: 14px 16px; border-radius: 14px; }
.console__content .mg-intro-l, .console__content .mg-intro-r { min-width: 0; }
.console__content .mg-intro-lines { margin-bottom: 0; }
.console__content .mg-intro-r .mg-keys { margin: 0 0 10px; flex-wrap: wrap; }
.console__content .mg-intro-r .mg-ready { margin: 0; }
/* Q-bawx 11/11/26: Normal, Hard and Extreme with their two arrows were wider than the right column and ran into the rules and past the card edge at 1024x480 */
.console__content .mg-modes-wrap { gap: 3px; max-width: 100%; }
.console__content .mg-modes-wrap .mg-mode { min-width: 0; padding: 4px 6px; font-size: 14px; }
.console__content .mg-modes-wrap .mg-song-arrow { min-width: 28px; padding: 0 2px; }

/* HUD legibility and hit areas (hudfix 09/11/26, row Q-be6n follow-up). Rendered sizes at the 1024x480 minimum:
   the place-value labels are question content (12px floor), key letters 10px floor, and the small pills / Back link
   keep their look but get a 44px tall invisible hit area (a pseudo-element, so the visual size is unchanged). */
.console__content .demo-story-part, .console .demo .demo-story-part, .console .demo-story .demo-story-part { font-size: 13px; line-height: 1.15; }
.console .arcade-cap .arcade-tbtn::after, .console .arcade-home .arcade-tbtn::after,
.console .demo-top .demo-exit::after {
  content: ''; position: absolute; left: -6px; right: -6px; top: 50%; height: 44px; transform: translateY(-50%);
}
.console .demo-top .demo-exit { position: relative; display: inline-block; }

/* Floating key chips (owner 10/11/26): the console widget is the ONLY place a keyboard key is shown. Each button gets a small
   keycap-style chip floating on its OWN outer side (up: above, down: below, left: to its left, right: to its right, X above, B below,
   Y to its left, A to its right; Capture to the left of its pill, Home to the right of its), never in a gap between two buttons.
   One shared style: dark ink on the light chip for every button, whatever colour the button's own text is. Everywhere else the game
   speaks in console buttons (js/arcade/keymap.js BUTTON_GLYPHS). */
.console .arcade-tbtn > .arcade-keycap,
.console .dpad__btn::before,
.console .actions__btn::after,
.console .pad__pill::after {
  content: attr(data-key);
  position: absolute; left: 50%; right: auto; top: auto; bottom: calc(100% + 3px); transform: translateX(-50%);
  margin: 0; padding: 2px 5px; min-width: 14px; box-sizing: border-box; text-align: center;
  font: 700 11px/1 var(--arcade-font, system-ui, sans-serif); letter-spacing: 0; opacity: 1; box-shadow: 0 1px 0 #8f8878;
  color: #2a2433; background: #f6f1e4; border: 1px solid #b9b2a0; border-radius: 5px;
  pointer-events: none; z-index: 3; white-space: nowrap;
}
.console .dpad__btn, .console .actions__btn, .console .arcade-tbtn { position: relative; }
/* below: the chip hangs under the button */
.console .arcade-tbtn-down > .arcade-keycap, .console .arcade-tbtn-b > .arcade-keycap,
.console .dpad__btn--down::before, .console .actions__btn[data-btn="b"]::after { bottom: auto; top: calc(100% + 3px); }
/* left: the chip sits left of the button, centred on its height */
.console .arcade-tbtn-left > .arcade-keycap, .console .arcade-tbtn-y > .arcade-keycap,
.console .dpad__btn--left::before, .console .actions__btn[data-btn="y"]::after,
.console .arcade-cap .arcade-tbtn > .arcade-keycap, .console .pad__cap .pad__pill::after { left: auto; right: calc(100% + 3px); bottom: auto; top: 50%; transform: translateY(-50%); }
/* right */
.console .arcade-tbtn-right > .arcade-keycap, .console .arcade-tbtn-a > .arcade-keycap,
.console .dpad__btn--right::before, .console .actions__btn[data-btn="a"]::after,
.console .arcade-home .arcade-tbtn > .arcade-keycap, .console .pad__home .pad__pill::after { left: calc(100% + 3px); right: auto; bottom: auto; top: 50%; transform: translateY(-50%); }
/* Capture and Home drop a little lower so the chips under Down and B have their own room above the pills */
.console .arcade-cap, .console .pad__cap, .console .arcade-home, .console .pad__home { margin-top: 30px; }
