/* ============================================================
 ARCADE CHASSIS — one machined frame, every board wears it.

 The single source of truth for everything outside a playfield: the
 frame and its screws, the HUD and the status word, the strip, the
 gamepad in both schemas, the selector dialog, the hint line and the
 consent footer. A board contributes its rules and its painting; it
 does not contribute a chassis.

 Loaded by every page under /games/ with a plain <link>. No build
 step, no bundler, no dependency — R-MINIMAL as amended 2026-09-23.
 Change a button here and every board wears the change at once.
 ============================================================ */

:root {
  --room:    #0B0C0E;
  --frame-a: #2C2E33;
  --frame-b: #101114;
  --board:   #17181B;
  --glyph:   #F1EEE4;
  --amber:   #FFB531;
  --meta:    #8D9096;
  /* One key of the gamepad. The owner asked for bigger than the 54px it was;
     it is one token because two columns and five buttons have to agree. */
  --padKey:  64px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { height: 100%; }
::selection { background: var(--amber); color: #14100A; }
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  ::view-transition-old(root), ::view-transition-new(root) { animation-duration: .2s; }
}
body {
  min-height: 100%;
  background: var(--room);
  color: var(--glyph);
  font-family: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: max(14px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right))
           max(14px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  touch-action: manipulation;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: radial-gradient(120% 90% at 50% 8%, #16181C 0%, var(--room) 55%, #050607 100%);
}
a { color: inherit; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; }

#board {
  position: relative;
  background: linear-gradient(180deg, var(--frame-a), var(--frame-b));
  border-radius: 18px;
  padding: clamp(16px, 3vw, 26px);
  box-shadow:
    0 40px 80px rgba(0,0,0,.65),
    0 6px 18px rgba(0,0,0,.5),
    inset 0 1px 0 rgba(255,255,255,.07);
}
#board::before {
  content: "";
  position: absolute; inset: 10px;
  background: var(--board);
  border-radius: 12px;
  box-shadow: inset 0 2px 10px rgba(0,0,0,.7);
}
.screw { position: absolute; width: 9px; height: 9px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #55585F, #26282C 70%);
  box-shadow: inset 0 -1px 1px rgba(0,0,0,.7); }
.screw::after { content: ""; position: absolute; left: 1.5px; right: 1.5px; top: 3.7px;
  height: 1.4px; background: #0F1012; transform: rotate(38deg); }
.screw.tl { top: 9px; left: 10px; }  .screw.tr { top: 9px; right: 10px; transform: rotate(70deg); }
.screw.bl { bottom: 9px; left: 10px; transform: rotate(15deg); } .screw.br { bottom: 9px; right: 10px; transform: rotate(50deg); }

#inner { position: relative; display: flex; flex-direction: column; gap: 12px; }

#hud {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 14px;
  font-size: clamp(10px, 1.6vw, 12px);
  font-weight: 600;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--meta);
  padding: 0 2px;
}
#hud b { color: var(--amber); letter-spacing: inherit; font-variant-numeric: tabular-nums; }
#statusWord { color: var(--glyph); }
#statusWord.alarm { animation: blink 1s steps(2, start) infinite; }
@keyframes blink { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { #statusWord.alarm { animation: none; } }

canvas {
  display: block;
  border-radius: 8px;
  background: #131417;
  box-shadow: inset 0 2px 8px rgba(0,0,0,.6);
  cursor: pointer;
  touch-action: none;               /* the drag is the rudder, never a page pan */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}


#strip {
  display: flex;
  justify-content: center;
  align-items: center;
  /* Five items do not fit 320px on one line, and the Games link was breaking
     between its arrow and its word to try. Nothing inside breaks; the strip
     wraps as a whole instead, into two centred rows. */
  flex-wrap: wrap;
  row-gap: 8px;
  gap: 10px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--meta);
  padding: 0 2px;
}
#strip a { text-decoration: none; padding: 8px 4px; margin: -8px 0; white-space: nowrap; }
#strip > * { white-space: nowrap; }
/* the look switch: a word, not an icon - it has to say which look is on */
#skinBtn {
  -webkit-appearance: none; appearance: none; font: inherit; cursor: pointer;
  font-size: 10px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase;
  color: var(--meta); background: none; padding: 6px 8px; margin: -6px 0;
  border: 1px solid rgba(141,144,150,.32); border-radius: 7px;
  touch-action: manipulation;
}
#skinBtn:hover { color: var(--glyph); border-color: rgba(241,238,228,.45); }
/* At the narrowest board the five controls want a little less air each, which
   keeps them on one line instead of orphaning Restart on a second. */
@media (max-width: 360px) {
  #strip { gap: 7px; }
  #skinBtn { padding: 5px 6px; letter-spacing: .1em; }
  #padOpts { letter-spacing: .1em; }
}
#strip a:hover { color: var(--glyph); }

#hint {
  font-size: 10px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--meta);
  text-align: center;
}
#hint .tp { display: none; }
@media (max-width: 460px), (hover: none) and (pointer: coarse) {
  #hint .kb { display: none; }
  #hint .tp { display: inline; }
}
/* consent + legal footer (R-CONSENT: the settings button must exist) */
#pagefoot {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 6px 14px;
  font-size: 10px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--meta);
  text-align: center;
}
#pagefoot a, #pagefoot .consent-settings {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
#pagefoot a:hover, #pagefoot .consent-settings:hover { color: var(--glyph); border-bottom-color: currentColor; }
#pagefoot .consent-settings {
  font: inherit;
  background: none;
  border: 0;
  padding: 6px 2px;
  cursor: pointer;
}


/* Pause and Restart live in the strip, beside the Games link and inside the frame.
   Restart is deliberately NOT one of the big action circles: a control that ends a
   run has no business sitting under the thumb that is playing. */
#holdBtn, #resetBtn {
  -webkit-appearance: none; appearance: none;
  display: inline-grid; place-items: center;
  width: 30px; height: 30px; padding: 0; margin: -7px 0 -7px 2px;
  color: var(--meta); background: none;
  border: 1px solid rgba(141,144,150,.32); border-radius: 7px;
  cursor: pointer; touch-action: manipulation;
}
#holdBtn svg, #resetBtn svg { width: 12px; height: 12px; fill: currentColor; }
#holdBtn svg[hidden] { display: none; }
#holdBtn:hover, #resetBtn:hover { color: var(--glyph); border-color: rgba(241,238,228,.45); }
#holdBtn[aria-pressed="true"] { color: var(--amber); border-color: var(--amber); }
#resetBtn:active { color: var(--amber); border-color: var(--amber); }
#resetBtn svg { width: 13px; height: 13px; }

/* ---- gamepad: one column either side of the board -------------------- */
/* The cross used to be a single cluster on the left. It is now two columns,
   one per thumb (owner, 2026-09-23):
       left column   .  / left / down
       right column  up / right / centre
   Both columns are three fixed rows tall whatever a board leaves out, which is
   what keeps left and right on one level on every board - Breaker has no up or
   down and still lines up. */
#stage { display: flex; align-items: center; justify-content: center; gap: clamp(10px, 2vw, 22px); }
.pad {
  display: grid; gap: 10px;
  grid-template-columns: auto;
  grid-template-rows: repeat(3, var(--padKey));
  align-content: center;
}
#padL { grid-template-areas: "." "left" "down"; }
#padR { grid-template-areas: "up" "right" "centre"; }
/* A board with no arrows has nothing to put in the left column, and an empty
   column would still spend a gap beside the board. */
#stage[data-dirs="none"] #padL { display: none; }
/* Every board now leaves the action circles empty; an empty flex child still
   costs a gap and nudges the board off centre. */
#stage[data-acts="0"] #padAct { display: none; }
#padAct { display: grid; gap: 10px; grid-template-columns: repeat(2, auto); }
.pad [data-act="up"] { grid-area: up; }
.pad [data-act="left"] { grid-area: left; }
.pad [data-act="centre"] { grid-area: centre; }
.pad [data-act="right"] { grid-area: right; }
.pad [data-act="down"] { grid-area: down; }
.pad .dir, #padAct .bb {
  -webkit-appearance: none; appearance: none;
  width: var(--padKey); height: var(--padKey); padding: 0; cursor: pointer;
  display: grid; place-items: center;
  -webkit-user-select: none; user-select: none; touch-action: manipulation;
}
.pad .dir {
  color: var(--glyph); background: rgba(241,238,228,.05);
  border: 1px solid rgba(141,144,150,.32); border-radius: 12px;
}
.pad .dir svg { width: 26px; height: 26px; fill: currentColor; }
.pad .dir:active { background: var(--amber); color: #14100A; border-color: var(--amber); }
#padAct .bb { border-radius: 50%; border: 1px solid rgba(0,0,0,.45); color: #14100A; }
#padAct .bb span { font-size: 8px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
#padAct .b1 { background: #C4442F; }
#padAct .b2 { background: #3F9B54; }
#padAct .b3 { background: #3C6FB5; }
#padAct .b4 { background: #E0A81E; }
#padAct .bb:active { filter: brightness(1.35); }
.pad .dir[hidden], #padAct .bb[hidden] { display: none; }

/* the phone puts the controls under the screen */
@media (max-width: 860px) {
  /* Scoped to the stage on purpose. A bare `#board { order: 1 }` also reaches
     the section page at /games/, where #board is a sibling of #pagefoot rather
     than a child of #stage — and an order of 1 there throws the footer above
     the content on every screen under 860px. */
  /* The two columns stay two columns on a phone; the board moves above them
     and the free middle track pushes each one under its own thumb. */
  #stage { display: grid; grid-template-columns: auto 1fr auto;
    grid-template-areas: "board board board" "padL padAct padR";
    justify-items: center; row-gap: clamp(10px, 3vw, 18px); }
  #stage > #board { grid-area: board; }
  #padL { grid-area: padL; justify-self: start; }
  #padR { grid-area: padR; justify-self: end; }
  #padAct { grid-area: padAct; grid-template-columns: repeat(4, auto); align-self: end; }
}

/* the second schema: one block under the screen, four coloured buttons at its corners */
/* The flexible outer tracks swallow the board's width, so the pad stays a tight
   cluster under the middle of the screen instead of being flung to its edges. */
#stage[data-schema="grid"] { display: grid; justify-items: center;
  grid-template-columns: 1fr auto auto auto 1fr;
  grid-template-areas: "board board board board board"
                       ".     b1   up     b2    ."
                       ".     left centre right ."
                       ".     b3   down   b4    .";
  gap: 8px; }
#stage[data-schema="grid"] #board { grid-area: board; margin-bottom: 6px; }
#stage[data-schema="grid"] .pad,
#stage[data-schema="grid"] #padAct { display: contents; }
#stage[data-schema="grid"] [data-act="b1"] { grid-area: b1; }
#stage[data-schema="grid"] [data-act="b2"] { grid-area: b2; }
#stage[data-schema="grid"] [data-act="b3"] { grid-area: b3; }
#stage[data-schema="grid"] [data-act="b4"] { grid-area: b4; }

/* The schema switch sits in the strip with Pause and Restart, inside the frame:
   it is a setting, not something you play with. Compact enough that the strip
   still fits one row at 320px with four things on it. */
#padOpts {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 8px 2px; margin: -8px 0;
  cursor: pointer; white-space: nowrap;
}
#padOpts input {
  accent-color: var(--amber);
  width: 13px; height: 13px; margin: 0; cursor: pointer;
}
#padOpts span { color: inherit; }
#padOpts:hover { color: var(--glyph); }
#padOpts:has(input:checked) { color: var(--amber); }

/* The selector is a popup shown before the run starts, not a row under the board */
#chooser {
  /* `* { margin: 0 }` above kills the UA's auto margins, which are what centre a
     modal dialog - so the box has to ask for them back by name. */
  margin: auto;
  width: min(340px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px); overflow: auto;
  padding: 22px 20px 20px; border: 1px solid rgba(141,144,150,.32); border-radius: 14px;
  background: #16171A; color: var(--glyph);
  box-shadow: 0 24px 60px rgba(0,0,0,.6);
}
#chooser::backdrop { background: rgba(6,7,9,.78); }
#chooser form { margin: 0; display: grid; gap: 14px; }
.ch-head { text-align: center; display: grid; gap: 5px; }
.ch-title { margin: 0; font-size: 19px; font-weight: 600; letter-spacing: .04em; }
.ch-sub { margin: 0; font-size: 10px; font-weight: 600; letter-spacing: .16em;
          text-transform: uppercase; color: var(--meta); }
.ch-opts { display: grid; gap: 8px; }

.ch-opt {
  -webkit-appearance: none; appearance: none;
  font: inherit; text-align: left; display: grid; gap: 3px;
  padding: 12px 14px; min-height: 56px; cursor: pointer;
  color: var(--glyph); background: rgba(241,238,228,.04);
  border: 1px solid rgba(141,144,150,.3); border-radius: 10px;
  touch-action: manipulation;
}
.ch-opt b { font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; }
.ch-opt span { font-size: 11px; color: var(--meta); letter-spacing: .02em; }
.ch-opt:hover { border-color: rgba(241,238,228,.45); background: rgba(241,238,228,.07); }
.ch-opt[aria-pressed="true"] { border-color: var(--amber); }
.ch-opt[aria-pressed="true"] b { color: var(--amber); }
/* amber already means "this is the one on"; focus says something else, so it
   borrows the porcelain instead of doubling the amber. */
.ch-opt:focus-visible { outline: 2px solid rgba(241,238,228,.7); outline-offset: 2px; }

/* ---- generic widgets a board may ask the chassis for ---- */

/* a row of auxiliary controls under the playfield (Minesweeper's flag mode) */
#tools { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; }
.tool {
  font: inherit; font-size: 10px; font-weight: 600;
  letter-spacing: .16em; text-transform: uppercase;
  color: var(--meta); background: none;
  border: 1px solid rgba(141,144,150,.3); border-radius: 6px;
  padding: 9px 14px; cursor: pointer; min-height: 36px;
  touch-action: manipulation;
}
.tool:hover { color: var(--glyph); border-color: rgba(241,238,228,.45); }
.tool.on { color: #14100A; background: var(--amber); border-color: var(--amber); }

/* a row of pips in the HUD, for lives, rounds, anything countable */
.pips { display: inline-flex; gap: 5px; vertical-align: baseline; }
.pips i {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 8px rgba(255,181,49,.5);
}
.pips i.out { background: #33363C; box-shadow: none; }

/* an action button a board has turned off, rather than one that fails silently */
#padAct .bb.off { opacity: .3; }

/* A HUD of more than three slots wraps on a narrow screen. ONE breakpoint for every
   board: the four the pages used to carry (420/440/460/470px) differed by accident
   rather than by design, and one chassis means one look. */
@media (max-width: 470px) {
  #hud { flex-wrap: wrap; gap: 8px 12px; justify-content: center; }
}

/* Beside the screen, the action circles stack in one column unless there are four
   of them, which make a square. Three in a two-column grid read as a lopsided 2+1 —
   and three is now the common case, Restart having moved into the strip. Under the
   screen they stay a single row, which the phone rule above sets. */
@media (min-width: 861px) {
  #stage[data-schema="sides"] #padAct { grid-template-columns: auto; }
  #stage[data-schema="sides"][data-acts="4"] #padAct { grid-template-columns: repeat(2, auto); }
}

/* A board that drives its playfield directly asks for no direction cross, and a
   two-item row would push it off-centre. Three columns keep it centred. The shell
   sets data-dirs, so this is a property of the configuration, not of one game. */
@media (min-width: 861px) {
  #stage[data-dirs="none"][data-schema="sides"] {
    display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; }
  /* One row, named explicitly. Both clusters sit in column 3, and without a row
     the empty one would take row 1 and push the board down to row 2. */
  #stage[data-dirs="none"][data-schema="sides"] #board { grid-column: 2; grid-row: 1; }
  #stage[data-dirs="none"][data-schema="sides"] #padAct,
  #stage[data-dirs="none"][data-schema="sides"] #padDir {
    grid-column: 3; grid-row: 1; justify-self: start;
    margin-left: clamp(10px, 2vw, 22px); margin-right: 0; }
}


/* ---- the touch engine (owner, 2026-09-24) ---------------------------------
   Snake, Dropings and Breaker: no pad, no Grid switch. The playfield is the
   controller and a drag area sits under the frame, exactly as wide as it. */
#stage[data-schema="touch"] {
  display: grid; grid-template-columns: max-content; justify-content: center;
  /* The phone rule names three columns of areas for the two-column pad. Left in
     place here they open implicit columns, and the drag area lands BESIDE the
     board instead of under it - which is what the first render showed. */
  grid-template-areas: none;
  justify-items: stretch;       /* the phone rule centres items; the drag area must span the frame */
  row-gap: 16px;
}
/* The phone rule above names a grid area for the board; on the touch grid there
   is no such area, and an unknown name would open an implicit track beside it. */
#stage[data-schema="touch"] > #board { grid-area: auto; }
/* Shrunk to the canvas: #inner is as wide as the HUD, and on a tall board
   (Dropings) that is wider than the playfield - a stretched field lit zones
   past the playfield's edge, which the first render showed. */
#field { position: relative; align-self: center; width: max-content; }
#zones { position: absolute; inset: 0; pointer-events: none; border-radius: 8px; overflow: hidden; }
#zones i {
  position: absolute; inset: 0;
  background: rgba(255,181,49,.13);
  opacity: 0; transition: opacity .12s linear;
}
@media (prefers-reduced-motion: reduce) { #zones i { transition: none; } }
#zones i.on { opacity: 1; }
#zones i:not([data-zone]) { display: none; }
/* the shapes follow the classification in arcade.js wireTouch() exactly */
#zones[data-shape="cross"] [data-zone="up"]     { clip-path: polygon(0 0, 100% 0, 66.667% 33.333%, 33.333% 33.333%); }
#zones[data-shape="cross"] [data-zone="down"]   { clip-path: polygon(0 100%, 100% 100%, 66.667% 66.667%, 33.333% 66.667%); }
#zones[data-shape="cross"] [data-zone="left"]   { clip-path: polygon(0 0, 33.333% 33.333%, 33.333% 66.667%, 0 100%); }
#zones[data-shape="cross"] [data-zone="right"]  { clip-path: polygon(100% 0, 66.667% 33.333%, 66.667% 66.667%, 100% 100%); }
#zones[data-shape="cross"] [data-zone="centre"] { clip-path: inset(33.333%); }
#zones[data-shape="x"] [data-zone="up"]     { clip-path: polygon(0 0, 100% 0, 50% 50%); }
#zones[data-shape="x"] [data-zone="down"]   { clip-path: polygon(0 100%, 100% 100%, 50% 50%); }
#zones[data-shape="x"] [data-zone="left"]   { clip-path: polygon(0 0, 50% 50%, 0 100%); }
#zones[data-shape="x"] [data-zone="right"]  { clip-path: polygon(100% 0, 50% 50%, 100% 100%); }
#zones[data-shape="x"] [data-zone="centre"] { display: none; }
#zones[data-shape="cols"] [data-zone="left"]   { clip-path: inset(0 66.667% 0 0); }
#zones[data-shape="cols"] [data-zone="centre"] { clip-path: inset(0 33.333%); }
#zones[data-shape="cols"] [data-zone="right"]  { clip-path: inset(0 0 0 66.667%); }
#zones[data-shape="cols"] [data-zone="up"],
#zones[data-shape="cols"] [data-zone="down"]   { display: none; }

#dragPad {
  position: relative;
  height: 108px; min-width: 0;
  display: grid; place-items: center; align-content: center; gap: 6px;
  border-radius: 14px;
  background: linear-gradient(180deg, #17181B, #111215);
  border: 1px solid rgba(141,144,150,.22);
  box-shadow: inset 0 2px 10px rgba(0,0,0,.6);
  color: rgba(141,144,150,.55);
  cursor: grab;
  touch-action: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
#dragPad:active { cursor: grabbing; border-color: rgba(255,181,49,.4); }
#dragPad svg { width: 30px; height: 30px; fill: currentColor; }
#dragPad .dp-label {
  font-size: 9px; font-weight: 600; letter-spacing: .2em; text-transform: uppercase;
  white-space: nowrap;
}
@media (max-width: 860px) { #dragPad { height: 92px; } }

/* pause at the top, beside the word it changes */
.hud-mid { display: inline-flex; align-items: center; gap: 8px; }
#hud #holdBtn { margin: -8px 0; width: 28px; height: 28px; }
/* Pause in the HUD costs 36px. At the narrowest widths Breaker's Armed and Turret
   HUD - five slots with Ammo showing - then pushed the frame 14px past a 320px
   screen. Less air between the slots and in the letters buys it back. */
@media (max-width: 360px) {
  #stage[data-schema="touch"] #hud { gap: 6px; letter-spacing: .1em; }
  #stage[data-schema="touch"] .hud-mid { gap: 5px; }
  #hud #holdBtn { width: 26px; height: 26px; }
}
