/* Structural styling only: layout, sizes, states. The visual design comes later. */
/* ==== base ==== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; overscroll-behavior-x: none; }
body {
  margin: 0 auto; max-width: 480px; min-height: 100dvh; padding: 8px var(--wh-gutter) max(16px, env(safe-area-inset-bottom));
  font: 15px/1.3 var(--wh-font-body);
  background: var(--wh-ground); color: var(--wh-text);
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }

/* ==== scale (E1) ==== */
/* One layout, scaled to the screen. The page column on a game screen is exactly as wide as the machine, and the machine is as
   large as fits: width-limited on a phone held upright, height-limited on a tablet, a desktop or a phone on its side. The
   declared chrome (header, gear band, bottom margin; on the result screen the score block) is subtracted from the height, so
   the stacking screen never scrolls. --wh-aspect is the view's width / height (main.js and link.js set it from CONFIG.view;
   the value here is the same number for a page that has not run yet). --wh-u is the text unit: 1 px on a 390 px column,
   growing with the column, at most 1.35 px, so sizes are written calc(N * var(--wh-u)). Nothing here runs per frame. */
/* the layout variables (--wh-aspect, --wh-head-h, --wh-bar-h, --wh-score-h, --wh-fit, --wh-w, --wh-u ...) are defined in tokens.css */
body[data-phase="pick"] { --wh-fit: 560px; }
body[data-phase="place"], body[data-phase="released"] {
  --wh-fit: max(120px, calc((var(--wh-vh) - var(--wh-head-h) - var(--wh-bar-h) - var(--wh-notice-h) - var(--wh-pad-b)) * var(--wh-aspect)));
}
/* the stacking screen has a slimmer header and a thinner bottom margin: the machine is the screen (Task E2) */
body[data-phase="place"], body[data-phase="released"] { --wh-head-h: 24px; --wh-pad-b: max(4px, env(safe-area-inset-bottom)); padding-bottom: var(--wh-pad-b); }
body[data-phase] .wh-header { z-index: 3; }   /* the header stays over the screen that pans up under it (release pan, Task E3) */
body[data-phase="place"] .wh-header, body[data-phase="released"] .wh-header { height: var(--wh-head-h); min-height: var(--wh-head-h); padding-block: 2px; }
body[data-phase="place"] .wh-header h1, body[data-phase="released"] .wh-header h1 { font-size: 14px; }
body[data-phase="place"] .wh-header .pill, body[data-phase="released"] .wh-header .pill { font-size: 12px; line-height: 1; padding: 1px 8px; border-width: 1px; }
body[data-phase="place"]:has(#build-notice:not([hidden])), body[data-phase="released"]:has(#round-status:not([hidden])) { --wh-notice-h: 36px; }
@media (max-width: 430px) { :root { --wh-toolbar: 44px; } }
/* result: the machine, the score and the buttons share the first screen; the details scroll below them */
body[data-phase="done"], body[data-view] {
  --wh-fit: max(240px, calc((var(--wh-vh) - var(--wh-head-h) - var(--wh-score-h) - var(--wh-toolbar) - env(safe-area-inset-bottom)) * var(--wh-aspect)));
}
/* the replay page (result link, Task E3): no timer, no Release, so the machine takes the phone's width; the result scrolls below it.
   Fitted to the screen's height less the header, as the stacking screen is. The unavailable and missing views are text: a 560 px column. */
body[data-view] { --wh-fit: max(240px, calc((var(--wh-vh) - var(--wh-head-h) - env(safe-area-inset-bottom)) * var(--wh-aspect))); }
body[data-view="unavailable"], body[data-view="missing"] { --wh-fit: 560px; }
/* the compact result view (Task E4): the column is sized from the view's aspect AS DRAWN NOW (--wh-aspect-now, written by
   scene.compact) on a phone, where the shorter machine can take the full width; on a wider screen from the full view's aspect, so
   the machine gets shorter instead of wider. */
@media (max-width: 430px) {
  body[data-phase="done"] { --wh-fit: max(240px, calc((var(--wh-vh) - var(--wh-head-h) - var(--wh-score-h) - var(--wh-toolbar) - env(safe-area-inset-bottom)) * var(--wh-aspect-now))); }
  body[data-view]:not([data-view="unavailable"]):not([data-view="missing"]) { --wh-fit: max(240px, calc((var(--wh-vh) - var(--wh-head-h) - env(safe-area-inset-bottom)) * var(--wh-aspect-now))); }
}
body[data-phase], body[data-view] { width: min(100%, var(--wh-fit)); max-width: none; }
body[data-phase]:not([data-phase="pick"]), body[data-view] { padding-inline: 0; }
body[data-phase] .wh-header h1, body[data-view] .wh-header h1 { font-size: calc(18 * var(--wh-u)); }
body[data-phase] .wh-header .pill, body[data-view] .wh-header .pill { font-size: calc(15 * var(--wh-u)); }
body[data-phase]:not([data-phase="pick"]) .wh-header, body[data-view] .wh-header { margin-inline: 0; padding-inline: var(--wh-gutter); }

.top { display: flex; justify-content: space-between; align-items: center; min-height: 40px; }
.top h1 { font-size: 18px; margin: 0; }
.pill { background: #23302b; color: #f6f1e7; border-radius: 99px; padding: 2px 10px; font-weight: 700; font-size: 14px; }
.pill:empty { display: none; }

/* ==== pick (C1) ==== */
/* The pick screen is a row of slotted iron rails: a chip is a brass slider carrying an enamel name plate.
   CSS and text only (no svg, no canvas inside #pick). Plain token rules; C2's .wh-* kit may replace them. */
#pick { display: flex; flex-direction: column; font-family: var(--wh-font-body); }
#pick :focus-visible, #app-notice:focus-visible { outline: 3px solid var(--wh-focus); outline-offset: 2px; }
#theme {
  margin: 4px 0 6px; padding: 5px 10px; font: 700 calc(15 * var(--wh-u))/1.15 var(--wh-font-plate); letter-spacing: .04em; overflow-wrap: anywhere;
  background: var(--wh-brass); color: var(--wh-ink); border-radius: var(--wh-r-plate); box-shadow: inset 0 0 0 2px var(--wh-ink), inset 0 3px 0 var(--wh-brass-lt);
}
#pick-help { margin: 2px 0 8px; font-size: calc(13 * var(--wh-u)); color: var(--wh-mute); }
.pick-heads { display: flex; justify-content: space-between; padding: 0 0 5px; }
.pick-heads span {
  min-height: 26px; padding: 3px 10px 2px; font: 700 calc(15 * var(--wh-u))/1.2 var(--wh-font-plate); letter-spacing: .08em;
  background: var(--wh-iron); border-radius: var(--wh-r-plate);
}
.head-left { color: var(--wh-left-ink); box-shadow: inset 0 0 0 2px var(--wh-ink), inset 0 -3px 0 var(--wh-left); }
.pick-heads [data-over="true"] { color: #fff; background: var(--wh-danger); box-shadow: inset 0 0 0 2px var(--wh-ink); }
.head-right { color: var(--wh-right); box-shadow: inset 0 0 0 2px var(--wh-ink), inset 0 -3px 0 var(--wh-right); }
#lanes { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }

/* A lane: an iron rail with a dark slot. The ends are the two sides; the middle (not used) is hatched. */
.lane {
  position: relative; height: calc(46 * var(--wh-u)); border-radius: var(--wh-r-plate);
  background:
    linear-gradient(var(--wh-ink), var(--wh-ink)) center / 100% 8px no-repeat,
    linear-gradient(90deg, color-mix(in srgb, var(--wh-left) 16%, var(--wh-wall)) 0 26%, transparent 26% 74%, color-mix(in srgb, var(--wh-right) 16%, var(--wh-wall)) 74%),
    repeating-linear-gradient(135deg, var(--wh-seam) 0 2px, var(--wh-wall) 2px 7px);
  box-shadow: inset 0 0 0 2px var(--wh-ink), 0 0 0 1px var(--wh-seam);
}
/* the end stops: orange on the left, blue on the right; the chip slides over the one it reaches */
.lane::before, .lane::after { content: ""; position: absolute; top: 0; bottom: 0; width: 5px; pointer-events: none; }
.lane::before { left: 0; background: var(--wh-left); border-radius: var(--wh-r-plate) 0 0 var(--wh-r-plate); }
.lane::after { right: 0; background: var(--wh-right); border-radius: 0 var(--wh-r-plate) var(--wh-r-plate) 0; }

/* The button is the whole coloured zone: 26 % of the lane wide, the lane's full height. The iron knob is its ::before
   (44px, outer side), so the knob keeps its look while the hit area is the zone. The glyph stays centred in the knob
   by padding out the inner side. */
.lane-left, .lane-right {
  position: absolute; top: 0; width: 26%; height: 100%; margin: 0; border: 0; border-radius: var(--wh-r-plate);
  background: transparent; isolation: isolate; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  font: 700 28px/1 var(--wh-font-plate); color: var(--wh-brass-lt);
}
.lane-left { left: 0; padding: 0 calc(26% - 44px) 2px 0; }
.lane-right { right: 0; padding: 0 0 2px calc(26% - 44px); }
.lane-left::before, .lane-right::before {
  content: ""; position: absolute; top: 0; width: 44px; height: 100%; z-index: -1; border-radius: var(--wh-r-plate);
  background:
    radial-gradient(circle at 8px 8px, var(--wh-edge) 0 1.5px, var(--wh-ink) 1.5px 2.5px, transparent 2.5px),
    radial-gradient(circle at 8px calc(100% - 8px), var(--wh-edge) 0 1.5px, var(--wh-ink) 1.5px 2.5px, transparent 2.5px),
    var(--wh-iron);
  box-shadow: inset 0 0 0 2px var(--wh-ink), inset 0 4px 0 var(--wh-iron-lt);
}
.lane-left::before { left: 0; }
.lane-right::before {
  right: 0;
  background:
    radial-gradient(circle at calc(100% - 8px) 8px, var(--wh-edge) 0 1.5px, var(--wh-ink) 1.5px 2.5px, transparent 2.5px),
    radial-gradient(circle at calc(100% - 8px) calc(100% - 8px), var(--wh-edge) 0 1.5px, var(--wh-ink) 1.5px 2.5px, transparent 2.5px),
    var(--wh-iron);
}
.lane-left:active, .lane-right:active { background: #0000001a; }
.lane-left:active::before, .lane-right:active::before { background-color: var(--wh-iron-lt); }
.lane-left:focus-visible, .lane-right:focus-visible { outline: 3px solid var(--wh-focus); outline-offset: -3px; }
.lane-left:disabled, .lane-right:disabled { visibility: hidden; }

/* The chip is 48 % of the lane; left / middle / right put it at 0 / 26 % / 52 %, so one step is
   wider than the 25 % drag threshold and the chip on a side covers that side's (useless) button. */
.chip {
  position: absolute; top: 1px; height: calc(44 * var(--wh-u)); width: 48%; left: 26%; z-index: 1;
  display: flex; align-items: center; gap: 5px; padding: 0 6px;
  border: 3px solid var(--wh-brass); border-radius: 5px; background: var(--wh-enamel); color: var(--wh-enamel-ink);
  box-shadow: inset 0 0 0 1px var(--wh-ink), 0 2px 0 var(--wh-ink);
  font: 700 calc(16 * var(--wh-u))/1.05 var(--wh-font-plate); letter-spacing: .02em;
  cursor: grab; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  touch-action: pan-y;    /* horizontal moves come to us; vertical ones still scroll the page */
  transition: left .18s ease-out, background-color .18s, border-color .18s;
}
.chip .flag { font-size: 20px; flex: none; line-height: 1; }
.chip .name { overflow-wrap: anywhere; min-width: 0; }
.chip[data-len="l"] { font-size: calc(15 * var(--wh-u)); }
.chip[data-len="xl"] { font-size: calc(13 * var(--wh-u)); line-height: 1; }
.chip[data-len="xl"] .flag { font-size: 16px; }
.lane[data-side="-1"] .chip { left: 0; background: var(--wh-left); color: var(--wh-ink); }
.lane[data-side="1"] .chip { left: 52%; background: var(--wh-right); color: var(--wh-ink); }
.lane.dragging .chip { transition: none; cursor: grabbing; }
.lane:focus-visible { outline: 3px solid var(--wh-focus); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .chip { transition: none; } }

#pick-count { margin: 12px 0 10px; padding: 7px 10px; min-height: 38px; text-align: center; font: 700 calc(17 * var(--wh-u))/1.2 var(--wh-font-plate); letter-spacing: .04em; }
#btn-start { width: 100%; min-height: calc(52 * var(--wh-u)); font-size: calc(21 * var(--wh-u)); letter-spacing: .08em; margin-bottom: 4px; }
#rules-note { margin: 10px 0 0; font-size: calc(13 * var(--wh-u)); text-align: center; color: var(--wh-mute); }

/* ==== stack: house (B1) ==== */
/* The page header (the runway girder the crab rides, scene.metrics().topY) is the shared .wh-header in parts.css. */

/* ---- place (and the frozen pile once released) ---- */
/* The section fills the viewport below the header: field on top, one bar with the countdown and
   Release below. The field takes what is left; the viewBox keeps the world's aspect ("meet").
   It is the house's interior: the rear wall runs across the whole page column (into the gutters,
   where the front columns stand) and up to the runway girder. */
body[data-phase="place"], body[data-phase="released"] { overscroll-behavior: none; background: var(--wh-ground); color: var(--wh-text); }
/* Spare height (a tall phone) goes above the field, so the field, the box and Release sit together near the thumb. */
/* The page column is exactly the machine's width (see scale (E1)), so the field is the column's full width and its
   height follows from the view's aspect; the gear band sits under it, inside the declared chrome. */
#place { display: flex; flex-direction: column; min-height: 0; }
body[data-phase="place"] #place, body[data-phase="released"] #place { background: var(--wh-wall); }
/* overflow visible: the house (#wh-house, beside the view) is drawn into the gutter and the spare
   height above the field; the world itself stays clipped to CONFIG.view (scene.js) */
#field {
  display: block; flex: none; min-height: 0; width: 100%; height: auto; overflow: visible;
  touch-action: none;                                  /* no scroll, zoom or pull-to-refresh while dragging */
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
/* the rear wall in the field (house.js): --wh-wall above the beam, falling away to --wh-field at view.minY */
#field .wh-wall-top { stop-color: var(--wh-wall); }
#field .wh-wall-low { stop-color: var(--wh-field); }
#field .wh-wall, #field .wh-house-wall { fill: var(--wh-wall); }
#field .wh-wall-seams { fill: none; stroke: var(--wh-seam); stroke-width: 1; vector-effect: non-scaling-stroke; }
/* the front columns beside the view, their base and cap plates, and the left column's channel slots;
   no stroke on the faces (half of it would be painted inside the view): the flange lines are inset */
#field .wh-column { fill: var(--wh-iron); }
#field .wh-column-base, #field .wh-column-cap { fill: var(--wh-iron-lt); }
#field .wh-column-flange { fill: none; stroke: var(--wh-edge); stroke-width: 1; vector-effect: non-scaling-stroke; }
#field .wh-channel-slot { fill: var(--wh-ink); stroke: var(--wh-seam); stroke-width: 1; vector-effect: non-scaling-stroke; }

/* ==== stack: hopper (B2) ==== */
/* The box on top and its four doors (scene.js; drawn behind the countries). At the box-gone step the
   hopper is hauled out sideways on its rail (Task B1): translateX(NUM.hopper.outM), set on #field as
   --wh-hopper-out in SVG user units; the slide time comes from CONFIG.release.boxOutMs (set inline).
   Under reduced motion it jumps. */
svg[data-box="gone"] #box { transform: translateX(var(--wh-hopper-out)); }
@media (prefers-reduced-motion: reduce) { #box { transition: none !important; } }
/* The hopper (hopper.js): iron on a flat rear plate. The inside stays a calm flat ground (no seams, no
   rivets) so both side colours read on it; the dressing is the rim, the end posts, the partition, the
   near end frame's tie and latch boxes. Fills and lines are flat; strokes keep their width at any scale. */
#box .box-frame { fill: none; stroke: var(--wh-seam); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
#box .box-wall { fill: none; stroke: var(--wh-ink); stroke-width: 1; vector-effect: non-scaling-stroke; }
#box .wh-hopper-inside { fill: var(--wh-wall); }
#box .wh-end-post, #box .wh-partition-plate { fill: var(--wh-iron); stroke: var(--wh-ink); stroke-width: 1; vector-effect: non-scaling-stroke; }
#box .wh-hatch-lines { fill: none; stroke: var(--wh-edge); }
#box .wh-hinge-lug, #box .wh-latch-box { fill: var(--wh-iron-lt); stroke: var(--wh-ink); stroke-width: 1; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
#box .wh-hopper-rim { fill: var(--wh-iron-lt); stroke: var(--wh-ink); stroke-width: 1; vector-effect: non-scaling-stroke; }
#box .wh-end-tie { fill: var(--wh-iron); stroke: var(--wh-ink); stroke-width: 1; vector-effect: non-scaling-stroke; }
#box .wh-rim-rivets, #box .wh-tie-rivets { fill: none; stroke: var(--wh-edge); stroke-linecap: round; }
#box #wh-roller-window { fill: none; stroke: var(--wh-edge); stroke-width: 1; vector-effect: non-scaling-stroke; }
/* the doors: the simulated body (iron) with its dress over it, and the knuckle at the hinge end */
#box .door .wh-door-body { fill: var(--wh-iron); stroke: var(--wh-ink); stroke-width: 1; vector-effect: non-scaling-stroke; }
#box .wh-door-dress, .wh-dress { pointer-events: none; }
.wh-dress .wh-dress-plate { fill: var(--wh-iron); stroke: var(--wh-ink); stroke-width: 1; vector-effect: non-scaling-stroke; }
.wh-dress .wh-dress-edge { fill: none; stroke: var(--wh-edge); stroke-width: 1; vector-effect: non-scaling-stroke; }
.wh-dress .wh-dress-rivets { fill: none; stroke: var(--wh-edge); stroke-linecap: round; }
/* the LEFT / RIGHT plates in the hopper: enamel, ink lettering, a stripe in the side's colour; they leave
   with the hopper. */
#box .side-heads .wh-head-plate { fill: var(--wh-enamel); stroke: var(--wh-ink); stroke-width: 1; vector-effect: non-scaling-stroke; }
#box .side-heads .wh-head-stripe[data-side="-1"] { fill: var(--wh-left); }
#box .side-heads .wh-head-stripe[data-side="1"] { fill: var(--wh-right); }
#box .side-heads g text { font-family: var(--wh-font-plate); font-size: 0.4px; font-weight: 700; fill: var(--wh-enamel-ink); }
/* waiting in the hopper: translucent, so overlaps read, with a full-opacity outline in the side's colour */
svg .country[data-state="box"] path { fill-opacity: .55; stroke-opacity: 1; stroke-width: 1.5; }
svg .country[data-state="box"][data-side="-1"] path { stroke: var(--wh-left); }
svg .country[data-state="box"][data-side="1"] path { stroke: var(--wh-right); }

/* ==== stack: crane and countries (B3) ==== */
/* A country that is gone is not shown (the tally plate names it). */
g.country[data-state="gone"] { display: none; }
.country { cursor: grab; }
/* Flat fills, an ink outline: both sides stay apart on the dark ground by hue, luminance and position. */
.country path { stroke: var(--wh-ink); stroke-width: 1; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.country[data-side="-1"] path { fill: var(--wh-left); }
.country[data-side="1"] path { fill: var(--wh-right); }
.country[data-state="held"] { cursor: grabbing; }
.country[data-state="held"] path { stroke-width: 2; }
/* The grab dot is the hook's eye ring: a dark eye in a brass ring, where the hook takes the country. */
.grab-dot { fill: var(--wh-ink); stroke: var(--wh-brass-lt); stroke-width: 2; vector-effect: non-scaling-stroke; }
/* Fallen countries stay where they landed, faded, so a collapse can be read. The dashes are edge-grey:
   an ink dash would vanish on the dark ground. */
.country[data-state="off"] path { fill-opacity: .45; stroke: var(--wh-edge); stroke-dasharray: 4 3; }
#field.pile-hidden .country { visibility: hidden; }
body[data-phase="released"] .country, body[data-phase="done"] .country { cursor: default; }
/* The crane (crane.js): never takes a press. The chain is two falls in one path: a 2 px steel dashed
   stroke over a solid 3.5 px ink underlay (a second path with the same d), so the gaps read as links. */
#wh-crane, #wh-crane * { pointer-events: none; }
#wh-chain-set { fill: none; stroke: var(--wh-steel); stroke-width: 2px; stroke-dasharray: 5 2; vector-effect: non-scaling-stroke; }
#wh-chain-set path { vector-effect: non-scaling-stroke; }
#wh-chain-set .wh-chain-under { stroke: var(--wh-ink); stroke-width: 3.5px; stroke-dasharray: none; }
#wh-crab .wh-crab-body { fill: var(--wh-iron-lt); stroke: var(--wh-ink); stroke-width: 1; vector-effect: non-scaling-stroke; }
#wh-crab .wh-crab-cap { fill: var(--wh-iron); stroke: var(--wh-ink); stroke-width: 1; vector-effect: non-scaling-stroke; }
#wh-crab .wh-crab-wheel { fill: var(--wh-steel); stroke: var(--wh-ink); stroke-width: 1; vector-effect: non-scaling-stroke; }
#wh-crab .wh-crab-drum { fill: var(--wh-iron); stroke: var(--wh-ink); stroke-width: 1; vector-effect: non-scaling-stroke; }
#wh-crab .wh-crab-drum-grooves { fill: none; stroke: var(--wh-edge); stroke-width: 1; vector-effect: non-scaling-stroke; }
#wh-hook-block .wh-block-body { fill: var(--wh-iron-lt); stroke: var(--wh-ink); stroke-width: 1; vector-effect: non-scaling-stroke; }
#wh-hook-block .wh-block-sheave { fill: var(--wh-ink); }
#wh-hook-block .wh-swivel { fill: var(--wh-brass); stroke: var(--wh-ink); stroke-width: 1; vector-effect: non-scaling-stroke; }
#field .deco, #field text { pointer-events: none; }

/* ==== stack: girder and dial (B4) ==== */
/* The dial (needle and scale) is hidden while the box is still there. */
#needle[data-shown="false"], #tilt-scale[data-shown="false"], #peak-pointers[data-shown="false"] { opacity: 0; }
/* No fade: the hauled-out hopper uncovers them (Task B1). */
/* The girder (girder.js): the simulated #beam is left transparent, its dress (deck plate, web, knife edge) is
   drawn in #wh-girder under it with the same transform. Outlines stay one pixel at any scale. */
#field #beam { fill: transparent; }
#field .wh-web { fill: var(--wh-web); stroke: var(--wh-ink); stroke-width: 1; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
#field .wh-flange { fill: none; stroke: var(--wh-edge); stroke-width: 1; vector-effect: non-scaling-stroke; }
#field .wh-stiffeners { fill: none; stroke: var(--wh-iron-lt); stroke-width: 1.6; vector-effect: non-scaling-stroke; }
#field .wh-holes { fill: var(--wh-wall); stroke: var(--wh-ink); stroke-width: 1; vector-effect: non-scaling-stroke; }
#field .wh-deck { fill: var(--wh-iron); stroke: var(--wh-ink); stroke-width: 1.2; vector-effect: non-scaling-stroke; }
#field .wh-deck-edge { fill: none; stroke: var(--wh-edge); stroke-width: 1; vector-effect: non-scaling-stroke; }
#field .wh-deck-ticks { fill: none; stroke: var(--wh-brass-lt); stroke-width: 1; vector-effect: non-scaling-stroke; }
#field .wh-knife { fill: var(--wh-steel); stroke: var(--wh-ink); stroke-width: 1; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
/* The standard (the sim's fulcrum silhouette), its head, base plate, brackets and pads, the lock bolt, the case behind. */
#field .fulcrum { fill: var(--wh-iron); stroke: var(--wh-ink); stroke-width: 1.2; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
#field .wh-flank { fill: none; stroke: var(--wh-edge); stroke-width: 1; vector-effect: non-scaling-stroke; }
#field .wh-head { fill: var(--wh-iron-lt); stroke: var(--wh-ink); stroke-width: 1; vector-effect: non-scaling-stroke; }
#field .wh-agate { fill: var(--wh-steel); stroke: var(--wh-ink); stroke-width: 1; vector-effect: non-scaling-stroke; }
#field .wh-base-plate { fill: var(--wh-iron-lt); stroke: var(--wh-ink); stroke-width: 1.2; vector-effect: non-scaling-stroke; }
#field .wh-base-bolts { fill: var(--wh-edge); stroke: var(--wh-ink); stroke-width: 1; vector-effect: non-scaling-stroke; }
#field .wh-bracket { fill: var(--wh-iron); stroke: none; }
#field .wh-bracket-edge { fill: none; stroke: var(--wh-ink); stroke-width: 1; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
#field .wh-pad { fill: var(--wh-rubber); stroke: var(--wh-edge); stroke-width: 1; vector-effect: non-scaling-stroke; }
#field .wh-bolt-collar { fill: var(--wh-iron-lt); stroke: var(--wh-ink); stroke-width: 1; vector-effect: non-scaling-stroke; }
#field .wh-bolt-bore { fill: var(--wh-ink); }
#field .wh-bolt-nose { fill: var(--wh-brass-lt); stroke: var(--wh-ink); stroke-width: 1; vector-effect: non-scaling-stroke; }
#field .wh-case { fill: var(--wh-wall); stroke: var(--wh-ink); stroke-width: 1; vector-effect: non-scaling-stroke; }
#field .wh-case-door { fill: none; stroke: var(--wh-seam); stroke-width: 1; vector-effect: non-scaling-stroke; }
#field .wh-case-screws { fill: var(--wh-edge); }
#field .side-left { fill: color-mix(in srgb, var(--wh-left) 7%, transparent); }
#field .side-right { fill: color-mix(in srgb, var(--wh-right) 7%, transparent); }
#pivot-line { stroke: var(--wh-brass); stroke-width: 1.5; stroke-dasharray: 6 5; vector-effect: non-scaling-stroke; }
/* The dial band on the rear wall behind the scale: an iron band, a brass rail on its inner edge. */
#field .wh-dial-iron { fill: var(--wh-iron); stroke: var(--wh-ink); stroke-width: 1.2; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
#field .wh-dial-brass { fill: none; stroke: var(--wh-brass); }
#field .wh-dial-rails { fill: none; stroke: var(--wh-iron-lt); vector-effect: non-scaling-stroke; }
/* The tilt needle and its scale (scene.js): decoration only, never a press target. The tip reads against the
   iron band; the tapered index and its rib are quieter, so a long index (the result screen) does not dominate. */
#needle, #tilt-scale { pointer-events: none; }
#needle .wh-index { fill: var(--wh-brass); fill-opacity: .45; stroke: none; }
#needle .needle-line { stroke: var(--wh-brass-lt); stroke-opacity: .4; stroke-width: 1.5; stroke-linecap: round; vector-effect: non-scaling-stroke; }
#needle .needle-tip { fill: var(--wh-brass-lt); stroke: var(--wh-ink); stroke-width: 1; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
#needle .needle-hub { fill: var(--wh-brass-lt); }
/* The peak drag pointers (T10): two thin brass telltales on the band, flat fill, an ink edge; the needle paints over them. */
#peak-pointers { pointer-events: none; }
#peak-pointers .peak-pointer polygon { fill: var(--wh-brass); stroke: var(--wh-ink); stroke-width: .75; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
#tilt-scale .arc { fill: none; stroke: var(--wh-brass-lt); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
#tilt-scale .tick { stroke: var(--wh-brass-lt); stroke-width: 1; vector-effect: non-scaling-stroke; }
#tilt-scale .tick.major { stroke-width: 1.5; }
#tilt-scale .tick.centre { stroke: var(--wh-text); stroke-width: 2.5; }
#tilt-scale .level-zone { fill: none; stroke: var(--wh-level); stroke-width: 7; stroke-linecap: butt; vector-effect: non-scaling-stroke; }
#tilt-scale text { fill: var(--wh-brass-lt); font-family: var(--wh-font-plate); font-weight: 700; }

/* ==== stack: gear band (B5) ==== */
/* The gear band: three cells in one row, the pressure gauge with the enamel time plate, the brass tally
 * plate of fallen countries, and the Release lever (a real button on the dump cock). One row, so the field
 * keeps its height. */
.place-bar {
  flex: none; display: grid; grid-template-columns: calc((100% + 16px) * 0.4) minmax(0, 1fr) auto; align-items: center; gap: 4px; padding: 2px 8px 0;
  background: var(--wh-web); border-bottom: 2px solid var(--wh-iron-lt);   /* Task E3: the control bar is the machine's runway girder; the crane's crab rides its lower edge */
}   /* Release (left, over the pull rod's column) keeps 40 % of the band's whole width (the 8 px side padding is added back) */
.place-bar[hidden] { display: none; }
.wh-gear-time { display: flex; align-items: center; gap: 2px; min-width: 0; }
.wh-gauge { flex: none; display: block; }   /* its size is the svg's width and height attributes (NUM.gaugeFace.view) */
.wh-gauge-case { fill: var(--wh-iron); stroke: var(--wh-ink); stroke-width: 1.5; }
.wh-gauge-face { fill: var(--wh-enamel); stroke: var(--wh-edge); stroke-width: 1; }
.wh-gauge-trip { fill: var(--wh-danger); }
.wh-gauge-ticks { fill: none; stroke: var(--wh-enamel-ink); stroke-linecap: butt; }
.wh-gauge-ticks-long { stroke-width: 1.5; }
.wh-gauge-ticks-short { stroke-width: 1; }
.wh-gauge-tripmark { fill: none; stroke: var(--wh-ink); stroke-width: 1.5; }
.wh-gauge-needle-blade { fill: var(--wh-enamel-ink); }
.wh-gauge-hub { fill: var(--wh-brass); stroke: var(--wh-ink); stroke-width: 1; }
.wh-gauge-needle { transform: rotate(-135deg); }
.wh-gauge-pipe { fill: var(--wh-steel); }
.wh-trip-cyl { fill: var(--wh-iron-lt); stroke: var(--wh-ink); stroke-width: 1; }
.wh-trip-piston { fill: var(--wh-steel); }
/* The enamel time plate: the exact digits, in the plate face, tabular. A fixed width that holds the widest text ("1:15": three equal digits and a colon, under 3.7 digit widths in the plate font and in both fallbacks), so the bar never shifts while the clock runs. */
#timer { flex: none; box-sizing: border-box; width: calc(3.7ch + 10px); padding: 2px 5px; text-align: center; white-space: nowrap;
  font-family: var(--wh-font-plate); font-size: 22px; line-height: 1.15; font-weight: 700; font-variant-numeric: tabular-nums; }
#timer[hidden] { display: none; }
/* The tally plate: a brass board with five slots; a fallen country's slot is struck (its shutter has dropped),
 * and the flag stays on the plate to say which one. With one or two entries the name is on the plate, too. */
.wh-tally { position: relative; box-sizing: border-box; min-width: 0; height: 56px; padding: 2px 4px 2px; overflow: hidden;
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: 11px 1fr; column-gap: 4px; align-content: start;
  background-color: var(--wh-brass); color: var(--wh-ink);
  border: var(--wh-line-2) solid var(--wh-ink); border-radius: var(--wh-r-plate); box-shadow: inset 0 var(--wh-line-1) 0 var(--wh-brass-lt); }
.wh-tally-title { font: 700 10px/11px var(--wh-font-plate); letter-spacing: .08em; text-transform: uppercase; }
.wh-tally-slots { display: flex; gap: 2px; align-items: center; justify-self: end; }
.wh-slot { display: block; width: 7px; height: 8px; background: var(--wh-iron); border: 1px solid var(--wh-ink); box-sizing: border-box; }
.wh-tally:has(.gone-flag:nth-child(1)) .wh-slot:nth-child(1), .wh-tally:has(.gone-flag:nth-child(2)) .wh-slot:nth-child(2),
.wh-tally:has(.gone-flag:nth-child(3)) .wh-slot:nth-child(3), .wh-tally:has(.gone-flag:nth-child(4)) .wh-slot:nth-child(4),
.wh-tally:has(.gone-flag:nth-child(5)) .wh-slot:nth-child(5) { background: var(--wh-danger); }
#gone-list { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 0 2px; min-width: 0; overflow: hidden; }
.gone-flag { position: relative; display: inline-flex; align-items: center; gap: 3px; min-width: 0; max-width: 100%; font-size: 17px; line-height: 20px; }
.gone-emoji { position: relative; flex: none; }
.gone-emoji::after { content: ""; position: absolute; left: -1px; right: -1px; top: 50%; border-top: 2px solid var(--wh-danger); transform: rotate(-20deg); }
.gone-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 700 11px/20px var(--wh-font-plate); letter-spacing: .02em; text-decoration: line-through var(--wh-danger) 2px; }
#gone-list:has(.gone-flag:nth-child(3)) .gone-name { display: none; }
#gone-list:has(.gone-flag:nth-child(3)) .gone-flag { font-size: 19px; }
/* Narrow screens: the plate is about 60 px wide. The decorative title gives way; the five slots take the first row. */
@media (max-width: 400px) {
  .wh-tally { column-gap: 0; padding-inline: 1px; }   /* the c3 machine is narrower: the plate is about 37 px at 360 wide */
  .wh-slot { width: 5px; }
  .wh-tally-slots { gap: 1px; }
  .wh-tally-title { display: none; }
  .wh-tally-slots { grid-column: 1 / -1; justify-self: start; }
  .gone-name { font-size: 10px; letter-spacing: 0; }
  /* one struck country: its name under the flag, the plate's whole width; two or more: flags only */
  .gone-flag { flex-direction: column; align-items: flex-start; gap: 0; }
  .gone-flag .gone-name { max-width: 100%; line-height: 12px; }
  #gone-list:has(.gone-flag:nth-child(2)) .gone-name { display: none; }
  /* wh-final #6: nothing struck yet: the plate says what it is for ("Fallen") instead of showing a blank slab under its five slots */
  .wh-tally:not(:has(.gone-flag)) .wh-tally-title { display: block; grid-column: 1 / -1; grid-row: 2; align-self: center; justify-self: center; letter-spacing: .04em; opacity: .75; }
}
#build-notice { flex: none; margin: 6px 8px 0; text-align: center; font-size: 14px; }
/* The Release lever: an iron plate with a brass label and a knob; the real button. Thrown (pressed in, or
 * Released) it sits 3 px lower. */
#btn-release.wh-lever {
  position: relative; box-sizing: border-box; min-height: 52px; width: 100%; padding: 4px 44px 4px 10px; text-align: left; white-space: nowrap; overflow: hidden;
  display: flex; align-items: center; font: 700 20px/1 var(--wh-font-plate); letter-spacing: .08em; text-transform: uppercase; cursor: pointer;
  background-color: var(--wh-iron); color: var(--wh-brass-lt); border: var(--wh-line-2) solid var(--wh-brass); border-radius: var(--wh-r-btn);
  box-shadow: inset 0 var(--wh-line-1) 0 var(--wh-iron-lt), 0 var(--wh-line-3) 0 var(--wh-ink);
}
#btn-release.wh-lever::before { content: ""; position: absolute; right: 22px; top: 50%; width: 13px; height: 6px; margin-top: -3px; background: var(--wh-steel); border: 1px solid var(--wh-ink); }
#btn-release.wh-lever::after { content: ""; position: absolute; right: 6px; top: 50%; width: 18px; height: 18px; margin-top: -9px; border-radius: 50%; border: 2px solid var(--wh-ink);
  background: radial-gradient(circle at 35% 35%, var(--wh-brass-lt) 0 28%, var(--wh-brass) 30% 100%); }
#btn-release.wh-lever:disabled { transform: translateY(3px); color: var(--wh-mute); border-color: var(--wh-edge); box-shadow: inset 0 var(--wh-line-1) 0 var(--wh-iron-lt); cursor: default; opacity: 1; }
#btn-release.wh-lever:disabled::after { background: var(--wh-iron-lt); }
#round-status { flex: none; margin: 6px 8px 0; text-align: center; font-size: 18px; font-weight: 700; min-height: 1.3em; }

/* ==== release pan (E3) ==== */
/* At the haul-out (pan.js) the whole screen section moves up by --wh-pan px: the control bar and the box's crown leave the top
   (behind the header), the dial and the pile stay in view. It is one compositor transform over the haul-out's time (--wh-pan-ms;
   0 under reduced motion). The result screen hides the bar instead and draws the field the crown higher: the same picture. */
#place[data-pan] { transform: translateY(calc(-1 * var(--wh-pan, 0px))); transition: transform var(--wh-pan-ms, 0ms) ease-in; }
@media (prefers-reduced-motion: reduce) { #place[data-pan] { transition: none !important; } }
body[data-phase="done"] #place[data-pan] { transform: none; transition: none; }
body[data-phase="done"] #field { margin-top: calc(-100% * var(--wh-crown, 0)); }   /* a percentage margin is of the column's width = the machine's width */

/* ==== stack: linkage (B6) ==== */
/* the lock chain (E3, linkage.js): iron chain on an ink underlay, sheaves at its corners; widths are in world units */
/* wh-final #9: the compact view cuts the machine off above the dial; the column slots (the pull rod's channel) stand above the cut and read as unexplained tick marks */
#field[data-compact="true"] .wh-channel-slot, #field[data-compact="true"] .wh-channel-joint { display: none !important; }
#field .wh-lever-casing { fill: var(--wh-iron-lt); stroke: var(--wh-ink); stroke-width: 1; vector-effect: non-scaling-stroke; }
#field .wh-chain-under { stroke: var(--wh-ink); }
#field .wh-chain-links { stroke: var(--wh-steel); }
#field .wh-sheave { fill: var(--wh-iron-lt); stroke: var(--wh-ink); stroke-width: 1; vector-effect: non-scaling-stroke; }
#field .wh-sheave-hub { fill: var(--wh-ink); }
/* The release linkage (linkage.js): pull rod and its sleeves in the column's windows, the column lever on its bracket, the hopper
   crank's roller in the hopper, the release weight in its cover window in the gear band (gauge.js). The rear rail and the hopper's
   wheels (house.js, hopper.js) are here, too: the rail is static, the wheels turn with the haul-out (--wh-wheel-out, hopper.js,
   same time and easing as #box) and stand still under reduced motion like the hopper's slide. Flat fills, no filters. */
#field .wh-channel-joint { fill: var(--wh-ink); stroke: var(--wh-seam); stroke-width: 1; vector-effect: non-scaling-stroke; }
#field .wh-rod { fill: var(--wh-steel); }
#field .wh-rod-sleeves { fill: var(--wh-iron-lt); stroke: var(--wh-ink); stroke-width: 1; vector-effect: non-scaling-stroke; }
#field .wh-lever-bracket { fill: var(--wh-iron-lt); stroke: var(--wh-ink); stroke-width: 1; vector-effect: non-scaling-stroke; }
#field .wh-lever-bar { fill: var(--wh-steel); stroke: var(--wh-ink); stroke-width: 1; vector-effect: non-scaling-stroke; }
#field .wh-lever-boss { fill: var(--wh-brass); stroke: var(--wh-ink); stroke-width: 1; vector-effect: non-scaling-stroke; }
#field .wh-lever-pin { fill: var(--wh-ink); }
#box .wh-roller-body { fill: var(--wh-steel); stroke: var(--wh-ink); stroke-width: 1; vector-effect: non-scaling-stroke; }
#field .wh-rail-foot, #field .wh-rail-head { fill: var(--wh-iron-lt); }
#field .wh-rail-web { fill: var(--wh-iron); }
#box .wh-wheel-tyre { fill: var(--wh-iron); stroke: var(--wh-edge); stroke-width: 1; vector-effect: non-scaling-stroke; }
#box .wh-wheel-spokes { fill: none; stroke: var(--wh-edge); }
#box .wh-wheel-cap { fill: var(--wh-brass); stroke: var(--wh-ink); stroke-width: 1; vector-effect: non-scaling-stroke; }
svg[data-box="gone"] .wh-wheel-spin { transform: rotate(var(--wh-wheel-out)); }
@media (prefers-reduced-motion: reduce) { .wh-wheel-spin { transition: none !important; } }
.wh-weight-window { fill: var(--wh-ink); stroke: var(--wh-edge); stroke-width: 1; }
.wh-weight-hanger { fill: var(--wh-steel); }
.wh-weight-body { fill: var(--wh-iron-lt); stroke: var(--wh-ink); stroke-width: 1; }
.wh-weight-cover { fill: var(--wh-brass); }

/* ==== result (C2) ==== */
body[data-phase="released"] .top .pill, body[data-phase="done"] .top .pill { background: var(--wh-brass); color: var(--wh-ink); }

/* Done: the page scrolls normally; the field is capped so the result fits below it. */
body[data-phase="done"] #place { height: auto; justify-content: flex-start; }
/* The field sits in a framed opening in the wall; the scene is dressed for the dark wall (Task B4). */
body[data-phase="done"] #field {
  touch-action: pan-y;
  border: var(--wh-line-3) solid var(--wh-ink); border-inline-width: 0; border-radius: 0;
  box-shadow: 0 0 0 var(--wh-line-2) var(--wh-iron-lt), 0 var(--wh-line-3) 0 var(--wh-line-2) var(--wh-ink);
}
#result { flex: none; padding: 8px var(--wh-gutter) 0; display: flex; flex-direction: column; gap: 8px; }
#result > * { margin: 0; }

/* The total on its wheels, the maximum engraved beside it. */
.result-total { display: flex; justify-content: center; align-items: baseline; gap: 12px; padding: 6px 16px; overflow: hidden; }
#score-total, .result-total .score-spacer.wh-wheels { font-size: 40px; }
#score-max, .result-total .score-max { font-family: var(--wh-font-plate); font-weight: 700; font-size: 17px; letter-spacing: .08em; text-transform: uppercase; color: var(--wh-brass-lt); }
#result:not([hidden]) #score-total { animation: wh-roll 300ms cubic-bezier(.2, .8, .3, 1) 1 both; }
@media (prefers-reduced-motion: reduce) { #result:not([hidden]) #score-total { animation: none; } }

/* The settle panel (weighing): while a release settles, the space under the compact machine holds the result's first screen in
   its final place and size (result.js mountWeighing): the score plate says "Weighing…" over a hidden spacer in the score's own
   font (the plate keeps its height), and the three buttons wait, disabled. It shows with the compact view (before the cut the
   machine fills the screen), and the section's layout gives back the pan (--wh-pan), so the panned screen does not scroll.
   From the pan on, the header is the result screen's (40 px): the machine and the panel stand where the result puts them, so
   nothing moves when the score arrives. Presentation only: the score's timing is release.js's. */
body[data-phase="released"] #field:not([data-compact="true"]) ~ #result { display: none; }
body[data-phase="released"] #result { background: var(--wh-ground); }
body[data-phase="released"] #place[data-pan] { margin-bottom: calc(-1 * var(--wh-pan, 0px)); }
body[data-phase="released"]:has(#place[data-pan]) .wh-header { height: 40px; min-height: 40px; padding-block: 4px 5px; }
body[data-phase="released"]:has(#place[data-pan]) .wh-header h1 { font-size: calc(18 * var(--wh-u)); }
body[data-phase="released"]:has(#place[data-pan]) .wh-header .pill { font-size: calc(15 * var(--wh-u)); line-height: 1.2; padding: 2px 10px; border-width: var(--wh-line-2); }
.result-weighing { position: relative; }
.result-weighing .score-spacer { visibility: hidden; }
.weighing-line { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-family: var(--wh-font-plate); font-weight: 700; font-size: 22px; letter-spacing: .14em; text-transform: uppercase; color: var(--wh-brass-lt); }
@media (prefers-reduced-motion: no-preference) { .weighing-line { animation: wh-weighing 1.6s ease-in-out infinite alternate; } }
@keyframes wh-weighing { from { opacity: 1; } to { opacity: .55; } }
.wh-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

.result-part { padding: 10px 18px 12px; }
.result-part h2 { margin: 0 0 4px; font-family: var(--wh-font-plate); font-weight: 700; font-size: 16px; letter-spacing: .14em; text-transform: uppercase; }
#stacking h2 { color: var(--wh-brass-lt); }
.part-note { margin: 0 0 6px; font-size: calc(13 * var(--wh-u)); }

/* Selection: an enamel inspection tag. Shown, not scored: no points column, no brass, no rivets. */
#selection .part-note { color: var(--wh-enamel-mute); padding-right: 22px; }
.sel-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-family: var(--wh-font-plate); font-weight: 700; font-size: calc(20 * var(--wh-u)); letter-spacing: .04em; }
.sel-row .sel-left { color: var(--wh-left-on-enamel); }
.sel-row .sel-right { color: var(--wh-right-on-enamel); }
#sel-balance { font-size: 16px; color: var(--wh-enamel-ink); text-transform: uppercase; }

/* Stacking: three engraved rows; points in brass, the part maximum quiet beside them. */
.part-row { display: grid; grid-template-columns: 1fr auto 6.5em; gap: 8px; align-items: baseline; padding: 5px 0; font-size: calc(15 * var(--wh-u)); border-top: var(--wh-line-1) solid var(--wh-seam); }
.part-row:first-of-type { border-top: 0; }
.part-what { font-family: var(--wh-font-plate); font-weight: 700; font-size: calc(16 * var(--wh-u)); letter-spacing: .08em; text-transform: uppercase; color: var(--wh-mute); }
.part-value { font-family: var(--wh-font-plate); font-weight: 700; font-size: calc(20 * var(--wh-u)); letter-spacing: .04em; font-variant-numeric: tabular-nums; }
/* The peak tilt beside the final one (T10): quiet and smaller, tucked under the final tilt so the row keeps its width
   (on the narrowest machine it may break after "peak", as the other values do). */
.part-values { display: inline-flex; flex-direction: column; align-items: flex-end; }
.part-peak { font-variant-numeric: tabular-nums; font-size: calc(13 * var(--wh-u)); line-height: 1.15; text-align: right; color: var(--wh-mute); }
.part-peak[hidden] { display: none; }
.part-pts { text-align: right; font-variant-numeric: tabular-nums; color: var(--wh-mute); }
.part-pts b { color: var(--wh-brass-lt); font-family: var(--wh-font-plate); font-size: calc(20 * var(--wh-u)); }

.result-actions { display: flex; gap: 8px; }
.result-actions .wh-btn { flex: 1; min-width: 0; min-height: 48px; padding: 4px 6px; font-size: clamp(15px, calc(18 * var(--wh-u)), 22px); text-align: center; }
#card-note, #send-note, #result-notice { font-size: 14px; }
#send-note[hidden], #send-text[hidden] { display: none; }
#send-text { display: block; width: 100%; box-sizing: border-box; font: inherit; font-size: 14px; background: var(--wh-iron); color: var(--wh-text); border: var(--wh-line-3) solid var(--wh-iron-lt); border-radius: var(--wh-r-plate); padding: 6px 8px; }

/* The rank on a brass strip; pending says so with static stripes. */
/* Status text, not a control: a flat notice plate (dark, brass bar on the left), left-aligned, no bevel, no brass face. */
#rank-line { padding: 8px 12px; font: 700 19px/1.25 var(--wh-font-plate); letter-spacing: .04em; color: var(--wh-text); }
#rank-line[data-pending="true"] { color: var(--wh-mute); border-left-style: dotted; }
#rank-line:empty { display: none; }
.result-next { text-align: center; font-size: 14px; color: var(--wh-mute); }
#result #from-link { color: var(--wh-brass-lt); font-weight: 700; text-align: center; }

/* Test host only: Play again (test). An iron plate with a dashed edge, so it never reads as part of the game. */
.test-again { margin: 4px 0 0; padding: 10px; border: var(--wh-line-2) dashed var(--wh-edge); border-radius: var(--wh-r-btn); text-align: center; }
#btn-again { width: 100%; }
#again-note { margin: 8px 0 0; font-size: 13px; color: var(--wh-mute); }

/* Released, before the result: the status line ("…", or the engine could not start; the text says to reload). */
#round-status.wh-notice { text-align: center; font-family: var(--wh-font-plate); font-size: 20px; letter-spacing: .04em; padding: 8px 12px; }

/* ==== card chooser (C4) ==== */
/* "Picture" opens a small plate under the buttons with the two pictures to choose from. In the flow, not over it:
   it never covers the score. No motion. */
#btn-card[aria-expanded="true"] { background-color: var(--wh-brass-lt); }
#picture-chooser { margin: 0; padding: 10px 12px 12px; border-color: var(--wh-brass); }
#picture-chooser[hidden] { display: none; }
.wh-chooser-head { display: block; margin-bottom: 8px; font: 700 18px/1.1 var(--wh-font-plate); letter-spacing: .12em; text-transform: uppercase; color: var(--wh-brass-lt); }
.wh-tiles { display: flex; gap: 10px; }
.wh-tile {
  flex: 1; min-width: 0; min-height: 48px; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 6px; cursor: pointer;
  background-color: var(--wh-wall); color: var(--wh-text); border: var(--wh-line-2) solid var(--wh-brass); border-radius: var(--wh-r-btn);
}
.wh-tile b { font: 700 20px/1.1 var(--wh-font-plate); letter-spacing: .06em; text-transform: uppercase; color: var(--wh-brass-lt); }
.wh-tile small { font: 13px/1.2 var(--wh-font-body); color: var(--wh-mute); text-align: center; }
.wh-tile-img { display: block; width: 104px; height: 130px; background: var(--wh-ground); border: var(--wh-line-2) solid var(--wh-ink); border-radius: 4px; }
.wh-tile-img[hidden] { display: block; visibility: hidden; }
.wh-tile:disabled { cursor: default; border-color: var(--wh-edge); }
.wh-tile:disabled b { color: var(--wh-mute); }
.wh-tile[aria-busy="true"] { cursor: progress; }

/* ==== link (C3) ==== */
#link { display: flex; flex-direction: column; gap: 6px; padding-top: 0; }
#link > :not(#field) { margin-inline: var(--wh-gutter); }
/* The field in its framed opening, as on the result screen. */
#link #field {
  touch-action: pan-y; width: 100%; height: auto;
  border: var(--wh-line-3) solid var(--wh-ink); border-inline-width: 0; border-radius: 0;
  box-shadow: 0 0 0 var(--wh-line-2) var(--wh-iron-lt), 0 var(--wh-line-3) 0 var(--wh-line-2) var(--wh-ink);
}
#link-notice { margin: 4px 0; font-weight: 600; }
.link-result { flex: none; }
/* The invitation: a full-width brass push plate (an iron one once the pile is shown). */
#btn-play { flex: 1; min-height: 52px; font-size: 22px; }
body[data-view="open"] #btn-play { background-color: var(--wh-iron); color: var(--wh-brass-lt); border-color: var(--wh-brass); box-shadow: inset 0 var(--wh-line-1) 0 var(--wh-iron-lt), 0 var(--wh-line-3) 0 var(--wh-ink); }
body[data-view="locked"] .result-actions { margin-top: 4px; }
/* Locked: the total is the whole page, so it is larger (72 px) on its wheels. */
body[data-view="locked"] #score-total { font-size: 72px; }
body[data-view="locked"] .result-total { flex-wrap: wrap; row-gap: 0; }
body[data-view="loading"] #result, body[data-view="loading"] .result-actions { visibility: hidden; }
#from-link { display: block; margin: 8px 0 0; text-align: center; font-weight: 700; color: var(--wh-brass-lt); }

/* ==== states (C1/C2/C3) ==== */
/* Loading: before main.js sets body[data-phase], the pick page shows one centred plate, from CSS alone.
   If the module graph never starts (a core module failing to load runs no script at all), the same CSS
   swaps the plate for a plain failure line after a few seconds: no script involved. */
body:not([data-phase]) main:has(> #pick) { display: grid; place-items: center; min-height: 55dvh; }
body:not([data-phase]) main:has(> #pick)::before,
body:not([data-phase]) main:has(> #pick)::after {
  grid-area: 1 / 1; max-width: 100%; padding: 14px 22px; text-align: center;
  font: 700 22px/1.2 var(--wh-font-plate); letter-spacing: .06em;
  background: var(--wh-enamel); color: var(--wh-enamel-ink); border-radius: var(--wh-r-plate); box-shadow: inset 0 0 0 2px var(--wh-ink), 0 0 0 3px var(--wh-brass);
}
body:not([data-phase]) main:has(> #pick)::before { content: "Raising steam…"; animation: wh-loading-late 0s linear 5s forwards; }
body:not([data-phase]) main:has(> #pick)::after {
  content: "Taking longer than it should. Reload the page to try again."; visibility: hidden; font-size: 18px;
  animation: wh-loading-failed 0s linear 5s forwards;
}
@keyframes wh-loading-late { to { visibility: hidden; } }
@keyframes wh-loading-failed { to { visibility: visible; } }
body:not([data-phase]) noscript p { text-align: center; color: var(--wh-text); }

/* Every #app-notice is a status plate (the kit's .wh-notice on enamel). */
#app-notice { margin: 24px 3px; text-align: center; font: 700 18px/1.25 var(--wh-font-plate); letter-spacing: .03em; }
body[data-error="boot"] #app-notice { border-left-color: var(--wh-danger); }

/* ==== board (leaderboard L1) ==== */
/* The board page: the same column as the game's machine (scale E1: as wide as the machine on this screen,
   text in --wh-u). One enamel scoreboard plate under a row of tab plates; plain, readable, no effects. */
/* A text page: the pick screen's column (scale E1: the whole width on a phone, 560 px at most). */
body[data-page="board"] { --wh-fit: 560px; width: min(100%, var(--wh-fit)); max-width: none; padding-inline: 0; }
body[data-page="board"] .wh-header { margin-inline: 0; padding-inline: var(--wh-gutter); }
body[data-page="board"] .wh-header h1 { font-size: calc(18 * var(--wh-u)); }
body[data-page="board"] .wh-header .pill { font-size: calc(15 * var(--wh-u)); }
#board { display: flex; flex-direction: column; gap: 10px; padding: 10px var(--wh-gutter) 0; }
#board > * { margin: 0; }

/* Tabs: iron plates with engraved brass letters; the chosen one is the brass face. */
/* Tabs wrap onto a second row on a narrow screen rather than break a word. */
.board-tabs { display: flex; flex-wrap: wrap; gap: 4px; }
.board-tabs [role="tab"] { flex: 1 1 auto; }
.board-tabs [role="tab"], .board-sub button {
  min-height: 44px; min-width: 0; padding: 4px 8px; cursor: pointer; white-space: nowrap;
  font: 700 calc(15 * var(--wh-u))/1.05 var(--wh-font-plate); letter-spacing: .04em; text-transform: uppercase;
  background-color: var(--wh-iron); color: var(--wh-brass-lt);
  border: var(--wh-line-2) solid var(--wh-ink); border-radius: var(--wh-r-btn);
  box-shadow: inset 0 var(--wh-line-1) 0 var(--wh-iron-lt), 0 var(--wh-line-2) 0 var(--wh-ink);
}
.board-tabs [role="tab"][aria-selected="true"], .board-sub button[aria-pressed="true"] {
  background-color: var(--wh-brass); color: var(--wh-ink); box-shadow: inset 0 var(--wh-line-2) 0 var(--wh-brass-lt);
}
.board-sub { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.board-sub[hidden] { display: none; }

/* The scoreboard plate. */
.board-plate { padding: 10px 12px 12px; min-width: 0; }
.board-plate h2 { margin: 0; font: 700 calc(20 * var(--wh-u))/1.15 var(--wh-font-plate); letter-spacing: .1em; text-transform: uppercase; color: var(--wh-enamel-ink); }
.board-note { margin: 2px 0 8px; font-size: calc(14 * var(--wh-u)); color: var(--wh-enamel-mute); }
.board-note:empty { display: none; }
.board-rows { list-style: none; margin: 0; padding: 0; }
.board-row {
  position: relative; min-height: 44px;
  display: grid; grid-template-columns: 1.8em minmax(0, 1fr) auto auto; column-gap: 8px; align-items: baseline;
  padding: 7px 4px; border-top: var(--wh-line-1) dashed var(--wh-enamel-mute); font-size: calc(16 * var(--wh-u));
}
.board-row:first-child { border-top: 0; }
.board-rank { font: 700 calc(18 * var(--wh-u))/1 var(--wh-font-plate); font-variant-numeric: tabular-nums; text-align: right; color: var(--wh-enamel-mute); }
.board-name { min-width: 0; overflow-wrap: anywhere; color: var(--wh-enamel-ink); font-weight: 600; }
a.board-name { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--wh-enamel-mute); }
/* the whole row is the link's target (at least 44 px tall) */
a.board-name::after { content: ""; position: absolute; inset: 0; }
.board-marks { grid-column: 3; display: inline-flex; gap: 4px; }
.board-marks:empty { display: none; }
#board-notice:empty, #like-note:empty { display: none; }
.board-value { grid-column: 4; text-align: right; white-space: nowrap; font: 700 calc(19 * var(--wh-u))/1 var(--wh-font-plate); font-variant-numeric: tabular-nums; color: var(--wh-enamel-ink); }
.board-value small { font: 400 calc(13 * var(--wh-u)) var(--wh-font-body); color: var(--wh-enamel-mute); }
.board-you, .board-old { font: 700 calc(12 * var(--wh-u))/1.2 var(--wh-font-plate); letter-spacing: .08em; text-transform: uppercase; padding: 1px 5px; border-radius: 3px; }
.board-you { background-color: var(--wh-brass); color: var(--wh-ink); border: var(--wh-line-1) solid var(--wh-ink); }
.board-old { color: var(--wh-enamel-mute); border: var(--wh-line-1) dashed var(--wh-enamel-mute); }
.board-row.is-me { background-color: color-mix(in srgb, var(--wh-brass) 22%, var(--wh-enamel)); }
.board-around-head { margin: 10px 0 2px; padding-top: 6px; border-top: var(--wh-line-2) solid var(--wh-ink); font: 700 calc(14 * var(--wh-u))/1 var(--wh-font-plate); letter-spacing: .12em; text-transform: uppercase; color: var(--wh-enamel-mute); }
#board-plate[aria-busy="true"] .board-rows { opacity: .55; }
#board-play, #board-back, #board-more { width: 100%; }
#board-back { margin-bottom: 4px; }

/* ==== likes (leaderboard L2) ==== */
/* The like control: a brass push plate whose count sits on counter wheels; pressed, it is the lighter brass.
   The own result shows the count on a small iron plate instead (no button). */
.like-slot:empty, .like-slot[hidden] { display: none; }
.like-slot { display: flex; flex-direction: column; gap: 6px; }
.like-btn { gap: 12px; width: 100%; }
.like-btn.is-on { background-color: var(--wh-brass-lt); }
.like-count { font-size: calc(20 * var(--wh-u)); min-width: 2ch; text-align: center; }
.like-own { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 0; padding: 8px 16px;
  font: 700 calc(16 * var(--wh-u))/1.1 var(--wh-font-plate); letter-spacing: .08em; text-transform: uppercase; color: var(--wh-brass-lt); }
#like-note { margin: 0; font-size: 14px; }
/* The way to the boards from the result screen and a replay. */
#board-link { text-align: center; }

/* ==== a11y and fit (D1) ==== */
/* A phone on its side: the machine is about 160 px wide, playable but small. The page says to turn the phone
   upright, on a strip over the header (touch screens only: a short desktop window gets no strip). It never
   blocks: a round in progress keeps its clock, so the player can finish it sideways; the strip takes no
   pointer events and the machine below stays usable. */
#turn-notice { display: none; }
/* min-width, not orientation: an upright phone with the soft keyboard open is also wider than tall, but never 560 px wide. */
@media (min-width: 560px) and (max-height: 500px) and (pointer: coarse) {
  #turn-notice {
    display: block; position: fixed; top: env(safe-area-inset-top, 0px); left: 50%; transform: translateX(-50%); z-index: 50; pointer-events: none;
    width: min(96vw, 520px); margin: 0; padding: 6px 12px; text-align: center;
    font: 700 16px/1.2 var(--wh-font-plate); letter-spacing: .04em;
  }
}
/* The title stays on one line in a narrow column (a short desktop window): it is cut, never wrapped over the girder. */
body[data-phase] .wh-header h1, body[data-view] .wh-header h1 { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* The Release label fits its cell on the narrowest machine: its size follows the stacking band's width (the
   cell is ~39 % of it, minus the knob and padding), at most the kit's 20 px. */
.place-bar { container-type: inline-size; }
#btn-release.wh-lever { font-size: clamp(12px, calc((39cqi - 54px) * 0.27), 20px); }

/* The result's Stacking rows: the label column may shrink and wrap, the points keep one line, so the plate
   never overflows with a wider fallback font on the narrowest phone. */
#stacking .part-row { grid-template-columns: minmax(0, 1fr) auto minmax(6.5em, auto); }   /* the points column keeps its 6.5em alignment */
#stacking .part-what { overflow-wrap: break-word; }
#stacking .part-pts { white-space: nowrap; }
/* The three result buttons on the narrowest phone: a little less inner padding and spacing, so a fallback font
   (Firefox renders the shrunk fallback a few px wider) keeps "Picture" inside its plate. */
.result-actions .wh-btn { padding-inline: 3px; letter-spacing: .04em; }
/* wh-final #7: at 360 the longest label (Send result) filled its plate edge to edge; a smaller face keeps a margin on both sides */
@media (max-width: 380px) { .result-actions .wh-btn { font-size: clamp(13px, calc(15.5 * var(--wh-u)), 22px); } }
/* The title link (privacy and other text pages) is a 44 px target without moving the header: padding out,
   margin back in. */
.wh-header h1 a { display: inline-block; padding: 13px 0; margin: -13px 0; }
/* The counter wheels' drums are a gradient from ink; ink is also their background colour, so the digits' contrast
   is defined (and measured) against the drum, not against the plate around it. No visual change. */
.wh-wheels { background-color: var(--wh-ink); }

/* ==== header menu ==== */
/* A brass plate with three ink bars beside the day oval (js/ui/menu.js). The button is a 44 px target; only the 30 px plate
   in its middle is drawn, so it sits inside the 40 px girder (the transparent rim hangs 2 px over it; the header keeps its
   fixed height). The title takes the free space, so the oval and the button stand together on the right. */
.wh-header > h1 { margin-right: auto; }
.wh-menu { flex: none; margin-left: 6px; margin-right: -7px; display: flex; align-items: center; }
.wh-menu-btn {
  width: 44px; height: 44px; margin: -2px 0; padding: 0; border: 0; background: none; cursor: pointer;
  display: grid; place-items: center; border-radius: var(--wh-r-btn); -webkit-tap-highlight-color: transparent;
}
.wh-menu-plate {
  width: 30px; height: 30px; display: grid; place-items: center;
  background-color: var(--wh-brass); color: var(--wh-ink);
  border: var(--wh-line-2) solid var(--wh-ink); border-radius: var(--wh-r-plate);
  box-shadow: inset 0 var(--wh-line-1) 0 var(--wh-brass-lt);
}
.wh-menu-btn:active .wh-menu-plate, .wh-menu-btn[aria-expanded="true"] .wh-menu-plate { background-color: var(--wh-brass-lt); }
.wh-menu-list {
  position: absolute; z-index: 20; top: calc(100% + 4px); right: var(--wh-gutter);
  min-width: 13rem; margin: 0; padding: 8px 6px; list-style: none;
  box-shadow: inset 0 var(--wh-line-1) 0 var(--wh-iron-lt), 0 var(--wh-line-3) 0 var(--wh-ink);
  animation: wh-menu-in 120ms ease-out;
}
.wh-menu-list a {
  display: flex; align-items: center; min-height: 44px; padding: 0 14px; border-radius: var(--wh-r-plate);
  color: var(--wh-brass-lt); text-decoration: none; text-transform: uppercase;
  font: 700 18px/1.1 var(--wh-font-plate); letter-spacing: .08em;
}
.wh-menu-list a:hover { background-color: var(--wh-iron-lt); color: var(--wh-text); }
.wh-menu-list li:not([hidden]) ~ li:not([hidden]) { border-top: var(--wh-line-1) solid var(--wh-seam); }
@keyframes wh-menu-in { from { opacity: 0; transform: translateY(-4px); } }
@media (prefers-reduced-motion: reduce) { .wh-menu-list { animation: none; } }
/* Stacking and the release: no menu. The header keeps the exact layout it had (24 px, title and oval) and nothing in
   it can be hit by mistake over the control bar right under it. It comes back on the result screen. */
body[data-phase="place"] .wh-menu, body[data-phase="released"] .wh-menu { display: none; }

/* ==== how to play (first-visit card and /how) ==== */
/* The first-visit card (ui/howcard.js): a riveted iron plate over the pick screen, a modal <dialog>. */
.how-card {
  position: fixed; inset: 0; z-index: 60;   /* .wh-plate is relative; a dialog stays fixed (and on top without showModal) */
  width: min(calc(100vw - 2 * var(--wh-gutter)), 400px); height: fit-content; max-height: calc(100dvh - 32px); overflow-y: auto;
  margin: auto; padding: 18px 18px 16px; color: var(--wh-text); font: 16px/1.4 var(--wh-font-body);
}
.how-card::backdrop { background: rgb(8 9 10 / 0.78); }
.how-card h2 {
  margin: 0 0 12px; padding: 0 0 6px; border-bottom: var(--wh-line-2) solid var(--wh-seam);
  font: 700 22px/1.15 var(--wh-font-plate); letter-spacing: .1em; text-transform: uppercase; color: var(--wh-brass-lt);
}
.how-card-steps { list-style: none; margin: 0; padding: 0; counter-reset: how; display: grid; gap: 10px; }
.how-card-steps li { position: relative; padding-left: 38px; counter-increment: how; min-height: 28px; }
.how-card-steps li::before {
  content: counter(how); position: absolute; left: 0; top: 0; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; font: 700 17px/1 var(--wh-font-plate);
  background: var(--wh-brass); color: var(--wh-ink); box-shadow: inset 0 0 0 2px var(--wh-ink), inset 0 3px 0 var(--wh-brass-lt);
}
.how-card-steps strong { font-family: var(--wh-font-plate); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--wh-brass-lt); }
.how-card-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; }
.how-card-more { display: inline-flex; align-items: center; min-height: 44px; color: var(--wh-brass-lt); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: var(--wh-line-2); }
.how-card #how-card-ok { min-width: 120px; }
@media (prefers-reduced-motion: no-preference) {
  .how-card[open] { animation: wh-how-in .22s ease-out; }
  .how-card[open]::backdrop { animation: wh-how-fade .22s ease-out; }
}
@keyframes wh-how-in { from { opacity: 0; transform: translateY(-14px); } to { opacity: 1; transform: none; } }
@keyframes wh-how-fade { from { opacity: 0; } to { opacity: 1; } }

/* The /how page: the doc column, with numbered step headings, a small drawing, the score table and a play button. */
.how-doc h2 .how-num {
  display: inline-grid; place-items: center; width: 1.45em; height: 1.45em; margin-right: 8px; border-radius: 50%;
  background: var(--wh-brass); color: var(--wh-ink); letter-spacing: 0; box-shadow: inset 0 0 0 2px var(--wh-ink);
}
.how-doc .how-lead { font-size: 17px; }
.how-doc figure { margin: 12px 0; }
.how-doc figure svg { display: block; width: 100%; height: auto; max-width: 420px; margin: 0 auto; }
.how-doc .how-score td:nth-child(2), .how-doc .how-score th:nth-child(2) { width: 22%; text-align: right; white-space: nowrap; }
.how-doc .how-score th:first-child, .how-doc .how-score td:first-child { width: 30%; }
.how-doc .how-score tfoot td { font-weight: 700; color: var(--wh-brass-lt); border-top: var(--wh-line-2) solid var(--wh-seam); }
.how-doc .how-play { margin: 24px 0 8px; }
.how-doc .how-play .wh-btn { width: 100%; min-height: 52px; font-size: 22px; color: var(--wh-ink); text-decoration: none; }
