/* ==========================================================================
   Copia
   A limestone frame around a card table: ivory letter cards on deep felt, held
   in a wooden tray and shoe, under a carved header. The rules that keep it one
   object are in the VISUAL LANGUAGE note above :root.
   ========================================================================== */

/* the wordmark's face, self-hosted (SIL OFL, src/fonts/OFL-Fraunces.txt): one
   variable file carries every axis the lockup uses, so no network dependency
   and no FOIT — swap keeps the header from reflowing on a cold load */
@font-face {
  font-family: "Fraunces";
  src: url("./fonts/fraunces-latin-var.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ==========================================================================
   VISUAL LANGUAGE — stone frames, the table plays, ink and gold decorate.
   Every surface is one of three materials, and takes its colours from that
   material's ramp only:
     STONE  the header, the shelf, the lid, the menu, the toast — carved, so its
            words are set in Fraunces and its figures are cut, not printed
     TABLE  the felt and the wooden tray/shoe the cards sit in
     CARD   every letter, bonus and brick — ivory, printed, set in the sans
   Colour has three jobs and three only: --accent (terracotta) is the ACTION
   (send, the primary button, a cost), --gold is the REWARD (bonuses, milestones,
   a selected letter, a cleared row), and the rarity tiers have one colour each,
   used identically on the plate, the wall and the lid.
   Alpha colours are written rgb(var(--c-*) / a), so a shadow or highlight is
   always one of five lights, never a fresh rgba.
   ========================================================================== */
:root {
  --bg: #d6e0da;

  /* ---- light and shade, as channels ---- */
  --c-light: 255 253 246;      /* every highlight: warm ivory, never pure white */
  --c-umber: 96 72 38;         /* the stone's own shadow, grooves, hairlines */
  --c-umber-deep: 44 30 12;    /* deep shadow: under ledges, cast by rows */
  --c-shade: 20 20 12;         /* neutral drop shadow on the page */
  --c-felt-shade: 8 20 16;     /* shadow cast onto the felt */
  --c-accent: 200 69 31;
  --c-gold: 232 193 105;
  --c-good: 28 122 82;

  /* ---- ink ---- */
  --ink: #1f1b12;
  --ink-2: #5d5339;            /* 6.0:1 on --stone-1, 4.7:1 on --stone-3 */
  --ink-3: #6d6146;
  --light: #fffdf6;
  --line: #e3d8c2;
  --line-strong: #cdbd9e;

  /* ---- stone (limestone ramp, light to dark) ---- */
  --stone-0: #fbf6ea;
  --stone-1: #efe4ca;
  --stone-2: #e8dab9;
  --stone-3: #dac9a5;
  --stone-4: #c9b28a;
  --stone-5: #b79d74;
  --stone-foot: #d8cdb6;
  --stone-key: #806a44;        /* the meander, at full strength */
  --bronze: #4a3c24;           /* turned-stone controls */
  --bronze-deep: #2f2616;

  /* ---- card (ivory) ---- */
  --card-hi: #fffdf7;
  --tile: #fbf7ec;
  --tile-line: #ddd2bb;
  --tile-line-2: #c9bda2;
  --card-foot: #ded3bc;
  --card-fill: linear-gradient(180deg, var(--card-hi) 0%, var(--tile) 100%);
  --card-shadow: inset 0 1px 0 rgb(var(--c-light) / 0.8), 0 2px 0 var(--card-foot);

  /* ---- table ---- */
  --felt: #16463a;
  /* the rack is the one wooden thing on the table */
  --rack-hi: #f4ecdb;
  --rack: #e7d9be;
  --rack-lo: #d5c3a2;
  --rack-line: #c3ad86;

  /* ---- the three jobs colour has ---- */
  --accent: #c8451f;
  --accent-deep: #b03c19;
  --accent-text: #96300f;      /* 5.2:1 on stone: the accent as small text */
  --accent-foot: #8f2f12;
  --accent-ink: #fffdf6;
  --gold: #b8862a;
  --gold-hi: #e8c169;
  --gold-ink: #5a3f0c;
  --good: #1c7a52;

  /* ---- rarity: one colour per tier, everywhere a tier is shown ---- */
  --tier-common: var(--ink-2);
  --tier-familiar: #2f6b4f;    /* verdigris */
  --tier-uncommon: #8a5300;    /* ochre */
  --tier-rare: #3d4a66;        /* lapis */

  /* ---- bonus cards: one deck, earthy marks (see .tile-bonus) ---- */
  --bonus-clearRow: #b5532c;   /* terracotta */
  --bonus-clearCol: #3f5a7a;   /* lapis */
  --bonus-shuffle: #3f7a5a;    /* verdigris */
  --bonus-double: #8c2f39;     /* oxblood */
  --bonus-fuse: #a87a1e;       /* gold */
  --bonus-extraSlot: #6a4a78;  /* murex */
  --bonus-addColumn: #8a6a2a;  /* bronze */

  /* ---- type ---- */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, "Helvetica Neue", Arial, sans-serif;
  --font-carved: "Fraunces", Georgia, serif;
  /* the scale: five steps. Captions under 8 px are not text, they are texture */
  --fs-micro: 8px;             /* chips, card captions, the smallest carved label */
  --fs-cap: 9.5px;             /* tracked capitals: menu items, kickers, buttons */
  --fs-label: 11px;            /* readable small text: primary buttons, readouts */
  --fs-num: 20px;              /* a figure you read at a glance */
  --fs-hero: clamp(44px, 15cqi, 64px);
  --track-caps: 0.1em;
  --track-wide: 0.14em;
  --track-tight: -0.02em;

  /* ---- shape ---- */
  /* One letter card, one shape: a square. The board tile, the letter in a blank
     and the empty blank it fills all read this token, so a letter always looks
     like the thing that fits a blank. */
  --card-max: 92px;
  --card-radius: 9px;
  --r-chip: 5px;
  --r-control: 7px;
  --r-panel: 10px;
  --r-board: 18px;
  --r-pill: 999px;
  --shadow-sm: 0 1px 2px rgb(var(--c-shade) / 0.06);
  --shadow-md: 0 2px 4px rgb(var(--c-shade) / 0.05), 0 12px 28px rgb(var(--c-shade) / 0.06);

  /* ---- focus: one ring everywhere; a dark surface redefines --focus ---- */
  --focus: var(--ink);
  --focus-ring: 2px solid var(--focus);
  --focus-offset: 3px;

  /* one motion system: quick, eased out, with a little spring for things that
     arrive. Nothing in the game animates for longer than --m-slow except the
     scoring cascade, which is meant to be watched. */
  --m-instant: 90ms;
  --m-fast: 140ms;
  --m-base: 220ms;
  --m-slow: 380ms;
  --e-out: cubic-bezier(0.2, 0.85, 0.25, 1);
  --e-spring: cubic-bezier(0.3, 1.55, 0.6, 1);
  --e-soft: cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

/* ONE focus ring for everything you can reach with a key: the same width, the same
   offset, in --focus. A surface too dark for ink (the felt, the wall's panel) redefines
   --focus rather than inventing a ring of its own. */
:focus-visible { outline: var(--focus-ring); outline-offset: var(--focus-offset); }
#grid { --focus: var(--light); }
.menu-item:focus-visible { outline-offset: -2px; }

/* nothing scrolls the document any more: the camera moves, inside the stage */
html, body { height: 100%; overflow: hidden; }

/* the table, lit from the middle: a light pool under the game and a cooler edge,
   so the play area has a figure to stand on instead of a same-value page */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    /* the shadow is cool slate-violet, not green: a green vignette greys the
       lavender pools out again and puts the page back in the felt's family */
    radial-gradient(118% 96% at 50% 46%, rgba(40, 36, 56, 0) 34%, rgba(40, 36, 56, 0.12) 74%, rgba(40, 36, 56, 0.26) 100%);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  /* no top or bottom padding: the header hangs from the top of the screen and the
     board stands on the bottom of it, so the column is one piece edge to edge rather
     than a card floating on the page. The safe area is padded INSIDE the board's shoe */
  padding: 0 14px;
  height: 100dvh;
  /* the sticky header reaches past the page padding on purpose; on a narrow
     phone that is a 2px sideways scroll, so clip the axis instead */
  overflow-x: clip;
  /* a game, not a document: a long press or a fast double tap must not select tiles */
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

body input { -webkit-user-select: text; user-select: text; }

/* the colour field: a low-res noise map painted by background.js, blurred by CSS */
#bg-field {
  position: fixed;
  left: -8%;
  top: -8%;
  width: 116%;
  height: 116%;
  z-index: 0;
  pointer-events: none;
  display: block;
  /* the function list is identical in every react state on purpose: browsers
     only interpolate filters whose function lists match, otherwise they cut */
  filter: blur(22px) brightness(1) saturate(1.05) hue-rotate(0deg);
  /* every tone change eases in and out; nothing about the field is a cut */
  transition: filter 1.1s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: filter;
}

/* the field answers every action with a short bloom, never a new UI layer */
body[data-react="pick"] #bg-field { filter: blur(22px) brightness(1.02) saturate(1.02) hue-rotate(0deg); }
body[data-react="swap"] #bg-field { filter: blur(22px) brightness(1.03) saturate(1.07) hue-rotate(-3deg); }
body[data-react="bonus"] #bg-field { filter: blur(22px) brightness(1.05) saturate(1.15) hue-rotate(0deg); }
body[data-react="trash"] #bg-field { filter: blur(22px) brightness(0.97) saturate(0.94) hue-rotate(0deg); }
body[data-react="send"] #bg-field { filter: blur(22px) brightness(1.06) saturate(1.12) hue-rotate(0deg); }

#bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  display: block;
}

/* perspective container: the board lies on the table and leans back a touch */
.app {
  position: relative;
  z-index: 1;
  /* how far the stage starts under the slab (see .stack's clip) */
  --hud-gap: 10px;
  /* the game is exactly one viewport: header, then the stage. The wall does not
     live in a document above the board — it is a layer behind it */
  /* On a short, wide screen the board used to be taller than the stage, so its own
     top was clipped and the wall behind it was never visible. The column width is
     now fitted to the height that is actually left after reserving room for a few
     rows of wall — measured in `fitColumn()`, because the board's chrome (plate,
     blanks, shoe) is fixed px and does not scale with the width. */
  width: min(560px, 100%, var(--app-cap, 100%));
  margin: 0 auto;
  height: 100dvh;
  /* clipped top and bottom only. With both axes hidden, every shadow under the header
     (the opening, the lip) was cut off square at the column's sides and read as a grey
     box on the page; sideways the shadows now fade out into the background on their own.
     `clip`, not `hidden`, so the two axes can differ and no scroll box is created */
  overflow-x: visible;
  overflow-y: clip;
  container-type: inline-size;
  container-name: app;
  display: flex;
  flex-direction: column;
  perspective: 1700px;
  perspective-origin: 50% 0;
}

/* the play area is pinned to the bottom of the stage; the wall slides behind it */
.hud { flex: 0 0 auto; }

/* the stage holds two layers: the wall (behind, full height) and the board
   (in front, pinned to the bottom). The camera slides the wall down through it
   while the board sinks away, so you look UP the wall rather than scroll it. */
.stage {
  position: relative;
  /* ALWAYS a stacking context, and always at 3 — above the lip (1), below the soffit (4).
     It must be explicit: `z-index: auto` is not a stacking context, and the thunk is a
     `translate` animation, which CREATES ONE. For the 620 ms of the jolt the whole stage
     — wall included — was then painted as one unit at z 0, i.e. UNDER the lip, the
     soffit and the header, and snapped back to the right depth when the animation ended.
     That is the "pile goes under the top bar for a second after a word lands". */
  z-index: 3;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  /* two layers in one column: the wall behind, the board pinned to the floor */
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.board {
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
  margin-top: auto;
}
.wordcard { flex: 0 0 auto; }
.rackbar { flex: 0 0 auto; }
.board { flex: 0 0 auto; }

/* ---------- HUD: one slab of stone and one ivory plaque ----------
   Three ornaments in 398 px was the problem with the capital: two pilasters, a
   cartouche and the flutes behind both, each defensible and all of them shouting.
   This bar keeps the material and the depth and deletes the argument — a cornice, a
   plain limestone face, a foot line, and ONE raised ivory plaque holding both numbers,
   which is the only thing the eye has to land on. The wordmark stays the game's own
   tiles, so the plaque is the only solid object up here. */
.hud {
  position: sticky;
  top: 0;
  z-index: 12;
  /* sticky to the top of the SCREEN: the body's top padding is gone, so the bar's top
     edge is the viewport's, and only its bottom corners are rounded */
  display: grid;
  /* the bar is a capital: fillet and echinus are drawn as bands, the face carries the
     name, the numbers and the volute. The stats take the flexible cell, so nothing the
     numbers do can push the volute off the end */
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  /* the gap under the slab: `.stack`'s clip is measured against it, so it is one
     number in one place */
  margin: 0 0 var(--hud-gap, 10px);
  /* the slab reaches the top edge; only its CONTENT respects a notch, and the content
     starts below the profile — 5 px of fillet + 9 px of echinus — so the liver of the
     capital is never under a tile */
  padding: calc(20px + env(safe-area-inset-top)) 14px 8px;
  /* the curve belongs to the LIP, not to the slab: the slab's bottom edge is the far
     rim of the hole and has to stay square */
  border-radius: 0;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='hg'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23hg)' opacity='0.16'/%3E%3C/svg%3E"),
    linear-gradient(180deg, var(--stone-1) 0%, var(--stone-2) 66%, var(--stone-3) 100%);
  background-blend-mode: multiply, normal;
  box-shadow: inset 0 1px 0 var(--light);
}

/* ---------- the foot: the plinth, and nothing else on the face ----------
   The key does not live on the face any more. Under the bar hangs the shelf's plinth —
   the same 5 px stone, upside down — and everything below that is the hole: the dark
   behind the wall, and the meander lying in it as the hole's back wall, half lost in
   shadow. What a row passes behind is the plinth above and the surface below; the key
   is what it passes IN FRONT OF. */
.hud::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 5px;
  background: linear-gradient(180deg, var(--stone-5) 0%, var(--stone-4) 55%, var(--stone-5) 100%);
  box-shadow:
    inset 0 1px 0 rgb(var(--c-light) / 0.45),
    inset 0 -1px 0 rgb(var(--c-umber) / 0.4),
    0 2px 3px -1px rgb(var(--c-umber-deep) / 0.4);
}

/* ---------- the hole ----------
   Three layers, and the order is the whole of it:
     1. the interior of the opening, BEHIND the wall — dark, unornamented;
     2. the overhanging soffit, IN FRONT of the wall — the slab's own meander course
        in shadow, hanging over the opening;
     3. the near surface below, BEHIND the wall.
   The wall passes IN FRONT of the depth and of the surface, but UNDER the soffit: a
   row that reaches the ceiling has its top cut by the soffit's edge, never painted
   across the dark. That cut is what makes the foot of the bar a hole rather than a
   stripe the words stand over. */
.ceiling-recess {
  position: absolute;
  left: 0;
  right: 0;
  /* two pixels of overlap close the hairline the header's integer height leaves */
  top: calc(var(--hud-h, 88px) - 2px);
  height: 31px;
  /* the opening follows the surface's curve */
  border-radius: 0 0 18px 18px;
  z-index: 1;
  pointer-events: none;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='mf'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23mf)' opacity='0.22'/%3E%3C/svg%3E"),
    /* the far side of the opening, then the depth under it */
    linear-gradient(180deg,
      #7b6a4a 0 15px,
      #2a2010 15px 62%,
      #4c3d24 100%);
  background-blend-mode: multiply, normal;
  box-shadow:
    inset 0 3px 4px -2px rgba(0, 0, 0, 0.55),
    0 3px 0 var(--stone-foot),
    0 12px 26px rgb(var(--c-shade) / 0.14);
}

/* ---------- the soffit: the dark bar, in FRONT of the wall ----------
   The 15 px course hangs over the opening at half strength on dark stone — the slab's
   ornament seen in its own shadow. Anything rising into the ceiling goes UNDER it, so
   the bar is unbroken wherever a row crosses it. Its bottom edge is the cut line, and
   it lands exactly on the surface's top edge, so a row's top is hidden behind stone
   and reappears on the stone. */
.ceiling-soffit {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(var(--hud-h, 88px) - 2px);
  height: 15px;
  /* above the wall (3) and above its info panels (? inside the wall's own context),
     below the header (12): the one layer in this stack that occludes the rows */
  z-index: 4;
  pointer-events: none;
  background:
    /* the key, drawn at half strength for stone in shadow */
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='30' height='14'%3E%3Cg fill='none' stroke='%239a8258' stroke-width='2.2' opacity='0.6'%3E%3Cpath d='M4 12V4h13v6H10v3h12V6'/%3E%3C/g%3E%3C/svg%3E") 0 50% / 30px 12px repeat-x,
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='sf2'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23sf2)' opacity='0.22'/%3E%3C/svg%3E"),
    linear-gradient(180deg, #80704f 0%, #6f5e40 58%, #56472b 100%);
  background-blend-mode: normal, multiply, normal;
  box-shadow:
    /* the shadow the header casts into its own soffit */
    inset 0 3px 4px -2px rgba(0, 0, 0, 0.55),
    /* and the soffit's own shadow onto the rows passing under it */
    inset 0 -1px 0 rgb(var(--c-light) / 0.09),
    0 5px 7px -3px rgb(var(--c-umber-deep) / 0.5);
}

/* ---------- the surface: the shelf's top face, seen from under it ----------
   The last band of the ceiling is the shelf's surface mirrored: the same 15 px plane,
   the same stone gradient reversed (dark where it runs away upward into the bar, lit at
   the front edge nearest the table), the same rounded front lip — and it sits UNDER the
   tower, behind the wall: the rows pass in front of it, so what you see is the tower
   coming out of the socket with the stone receding behind it.

   NOTE the depth is set on `.stage` (z-index: 3), not here. A row used to come out
   BEHIND this lip with the top of its cards sliced off, for about a second after a word
   landed — the depth was not lost by this layer but by the wall's ANCESTOR: `.stage` had
   `z-index: auto`, and the jolt (`is-thunk`) is a `translate` animation, which creates a
   stacking context. For the 620 ms of the jolt the whole stage — wall included — was
   painted at z 0, i.e. under this lip, under the soffit and under the header, and
   snapped back to 3 when the animation ended. Measured on one frozen row whose top sat
   4 px inside this band: the first card pixel was at y 86 with the jolt running and y 77
   without it; with `.stage { z-index: 3 }` it is 77 in both. */
.ceiling-lip {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(var(--hud-h, 88px) + 13px);
  height: 15px;
  /* BEHIND the wall (3), above the opening's own dark: the surface is the far side of
     the socket, so the tower passes in front of it — which is what makes the tower read
     as coming out of the hole rather than sliding past a lip */
  z-index: 1;
  pointer-events: none;
  border-radius: 0 0 18px 18px;
  background:
    /* the ends curl away, exactly as the shelf's plane does */
    linear-gradient(90deg, rgb(var(--c-umber) / 0.3) 0 5px, transparent 14px),
    linear-gradient(270deg, rgb(var(--c-umber) / 0.3) 0 5px, transparent 14px),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='sf'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.7' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23sf)' opacity='0.18'/%3E%3C/svg%3E"),
    linear-gradient(180deg, #b7a985 0%, #cdbf9c 34%, #e5dabd 72%, #f3ebd7 100%);
  background-blend-mode: normal, normal, multiply, normal;
  box-shadow:
    inset 0 2px 3px -1px rgb(var(--c-umber-deep) / 0.45),
    inset 0 -1px 0 rgb(var(--c-light) / 0.7),
    0 3px 0 var(--stone-foot),
    0 12px 26px rgb(var(--c-shade) / 0.12);
}

/* No scrim over the wall. A row inside the opening is lit normally and simply stands in
   front of the dark — the dark is a BACKDROP, not a veil across the words. The only
   thing allowed to cut a row is the border above it. */

/* the cornice: one light band and the hard seam under it. That single step is what
   stops the slab reading as a plain rectangle */
.hud::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 5px;
  background: linear-gradient(180deg, var(--stone-0) 0%, #f2e7cf 100%);
  box-shadow:
    inset 0 1px 0 var(--card-hi),
    0 1px 0 rgb(var(--c-umber) / 0.45),
    0 3px 5px -2px rgb(var(--c-umber) / 0.35);
}

/* the wordmark is the name, built out of the game's own pieces: C O P I A across
   five cards, with the last pair still off the baseline and falling, and the caption
   under the row saying what the game is. Every measurement is in em of the heading,
   so the lockup scales as one object */
.brand {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.07em;
  font-family: "Fraunces", Georgia, serif;
  font-size: clamp(21px, 4.2vw, 26px);
  font-weight: 900;
  font-variation-settings: "opsz" 144, "SOFT" 30, "WONK" 1;
  line-height: 1;
  margin: 0;
  letter-spacing: -0.038em;
  text-transform: uppercase;
  color: var(--ink);
  /* the header clips at the app's edge and the label's negative tracking pulls its
     first glyph past it, so the logotype starts a few px inside */
  padding-left: 5px;
  padding-bottom: 0.1em;
}

/* COPIA reads across the tiles; the caption sits under them, indented so it starts
   under the word rather than hanging off its left edge. The caption used to complete a
   two-word name (STACK under WORD), so it was always narrower than the row; as a
   subtitle it is the widest thing in the lockup, which is why it is measured (see
   below) rather than assumed to fit */
.brand-row {
  display: inline-flex;
  align-items: flex-start;
  gap: 0.085em;
}

/* board-tile material, not a logo swatch: square, sans 700, inset highlight and a
   2px cream edge for the thickness */
.brand-card {
  position: relative;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 0.8em;
  height: 0.8em;
  border: 1px solid var(--tile-line);
  border-radius: 0.17em;
  background: var(--tile);
  color: var(--ink);
  font-family: var(--font);
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0;
  box-shadow: inset 0 1px 0 rgb(var(--c-light) / 0.8), 0 2px 0 var(--card-foot), 0 3px 6px rgb(var(--c-umber) / 0.28);
}

.brand-card i {
  font-style: normal;
  font-size: 0.54em;
  transform: translateY(-0.02em);
}

/* the last two letters are still settling: nudged off the baseline and tilted, so
   the row reads COPIA while the pair looks like it has just landed */
.brand-card--settle-a,
.brand-card--settle-b {
  box-shadow: inset 0 1px 0 rgb(var(--c-light) / 0.8), 0 2px 0 var(--card-foot), 0 4px 6px rgb(var(--c-felt-shade) / 0.18);
}

.brand-card--settle-a { transform: rotate(6deg) translateY(0.1em); }
.brand-card--settle-b { transform: rotate(-7deg) translateY(0.16em); }

/* the label under the pieces, with the thickness of a stacked tile.
   The caption used to complete a two-word name and was always narrower than the row;
   as a subtitle it is the widest thing in the lockup, so it is measured. At the phone
   size (19 px tiles) the row is 82.4 px: A WORD GAME at 10 px/0.16em was 92.4 px, a
   10 px flag off the last tile, and WORD GAME at 0.10em is 74.6 px — the article is
   dropped (a caption is a label, not a sentence) and the tracking comes down from
   0.16em, which is also what stops it overhanging at 26 px. Re-measure both sizes
   before changing this string. */
.brand-word {
  margin-top: 0.12em;
  padding-left: 0.3em;
  font-size: max(0.52em, 11px);
  line-height: 1;
  /* the caption leans on tracking, never on a drop shadow: at 11-13 px a 1 px offset
     merges S and T into one red smear, and the word stops being readable */
  letter-spacing: 0.1em;
  /* measured on the rendered stone: --accent is 3.6:1 and --accent-deep 4.0:1, both
     under AA for 11 px text. This one is 5.2:1 and still reads red */
  /* the brand's one red mark: the accent as text, the only place it is not an action */
  color: var(--accent-text);
  text-shadow: none;
  white-space: nowrap;
}

/* ---------- the volute: the menu, as the spiral at the end of a capital ----------
   The one ornament on the bar that is also a button. A concave ring around a raised
   eye, lit from above: it reads as turned stone at rest and as a control under the
   pointer (the ring brightens and the eye comes up). 44 px of target around a 30 px
   disc, so it is pressable without looking like a web button. */
.menu-wrap {
  position: relative;
  display: grid;
  place-items: center;
  justify-self: end;
  width: 44px;
  height: 44px;
  margin-right: -7px;
}

.hud-volute {
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  display: grid;
  place-items: center;
  color: var(--bronze);
  background:
    radial-gradient(circle at 50% 50%,
      #efe3c8 0 34%,
      var(--stone-3) 35% 54%,
      var(--stone-4) 55% 100%);
  box-shadow:
    inset 0 0 0 1px rgb(var(--c-umber) / 0.42),
    inset 0 2px 0 rgb(var(--c-light) / 0.75),
    inset 0 -2px 3px -1px rgb(var(--c-umber) / 0.35),
    0 2px 0 var(--stone-foot),
    0 3px 6px rgb(var(--c-umber) / 0.24);
  transition: background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.hud-volute:hover {
  background:
    radial-gradient(circle at 50% 50%,
      #fdf5e2 0 36%,
      #e2d1ad 37% 54%,
      #cfb995 55% 100%);
  box-shadow:
    inset 0 0 0 1px rgb(var(--c-umber) / 0.5),
    inset 0 2px 0 var(--light),
    inset 0 -2px 3px -1px rgb(var(--c-umber) / 0.3),
    0 2px 0 var(--stone-foot),
    0 4px 8px rgb(var(--c-umber) / 0.28);
}

.hud-volute:active {
  background:
    radial-gradient(circle at 50% 50%,
      #e4d5b4 0 36%,
      #d3c1a0 37% 54%,
      #c3ab86 55% 100%);
  box-shadow: inset 0 0 0 1px rgb(var(--c-umber) / 0.5), inset 0 2px 4px -1px rgb(var(--c-umber) / 0.4), 0 1px 0 var(--stone-foot);
}


/* screen-reader-only labels: present for assistive tech, absent for the eye */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ---------- the menu: a tablet of the same stone as the bar ----------
   It drops out of the volute as a slab, not a white sticker: the limestone face, a lit
   cornice along its top, the umber edge every carved thing in the header has. Its
   words are carved (Fraunces), its marks are cut into the face, and the two levels are
   grooves with a turned-stone handle — the volute again, at the size of a thumb. */
.menu {
  position: absolute;
  right: 3px;
  top: calc(100% + 4px);
  z-index: 20;
  min-width: 188px;
  padding: 6px;
  border: 1px solid rgb(var(--c-umber) / 0.42);
  border-radius: var(--r-panel);
  background:
    linear-gradient(180deg, var(--stone-1) 0%, var(--stone-2) 70%, var(--stone-3) 100%);
  box-shadow:
    inset 0 1px 0 var(--light),
    inset 0 -2px 3px -1px rgb(var(--c-umber) / 0.22),
    0 3px 0 var(--stone-foot),
    0 14px 30px rgb(var(--c-umber-deep) / 0.28);
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.menu[hidden] { display: none; }

/* the run you are in, cut along the top of the tablet like a dedication */
.menu-code {
  margin: 0 0 3px;
  padding: 5px 8px 8px;
  border-bottom: 1px solid rgb(var(--c-umber) / 0.24);
  box-shadow: 0 1px 0 rgb(var(--c-light) / 0.6);
  font-family: var(--font-carved);
  font-size: var(--fs-label);
  font-weight: 600;
  font-variation-settings: "opsz" 12;
  font-style: italic;
  letter-spacing: 0.01em;
  color: var(--ink-2);
  white-space: nowrap;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 32px;
  padding: 6px 8px;
  border: 0;
  border-radius: var(--r-control);
  background: none;
  color: var(--ink);
  font-family: var(--font-carved);
  font-size: var(--fs-label);
  font-weight: 650;
  font-variation-settings: "opsz" 12;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: left;
  text-decoration: none;
  box-sizing: border-box;
  cursor: pointer;
  transition: background var(--m-fast) var(--e-out), box-shadow var(--m-fast) var(--e-out);
}

/* under the pointer the item is sunk into the face, the way the blanks are cut */
.menu-item:hover:not([disabled]) {
  background: rgb(var(--c-umber) / 0.1);
  box-shadow: inset 0 1px 2px rgb(var(--c-umber) / 0.28), inset 0 -1px 0 rgb(var(--c-light) / 0.5);
}

.menu-item[disabled] { color: var(--ink-3); cursor: default; opacity: 0.6; }

/* the mark: a lozenge cut into the stone — filled for a thing that is on, an outline
   for a thing that is off. Bronze, never a status-light green */
.menu-dot {
  width: 6px;
  height: 6px;
  flex: 0 0 auto;
  transform: rotate(45deg);
  border-radius: 1px;
  background: var(--bronze);
  box-shadow: 0 1px 0 rgb(var(--c-light) / 0.7);
}

.menu-item[aria-pressed="false"] .menu-dot {
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--ink-3), 0 1px 0 rgb(var(--c-light) / 0.7);
}

.menu-code-form {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 8px 8px;
}

.menu-code-form[hidden] { display: none; }

/* the field is a card laid in the stone: ivory, inset, set in the card's own sans */
.menu-code-input {
  flex: 1 1 72px;
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid var(--tile-line);
  border-radius: var(--r-control);
  background: var(--tile);
  box-shadow: inset 0 2px 3px rgb(var(--c-umber) / 0.16);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--fs-label);
  font-weight: 800;
  letter-spacing: var(--track-wide);
  text-transform: uppercase;
}

.menu-code-input::placeholder { color: var(--ink-3); letter-spacing: var(--track-wide); }

.menu-code-hint {
  flex: 1 0 100%;
  font-family: var(--font-carved);
  font-size: var(--fs-cap);
  font-style: italic;
  color: var(--ink-3);
}

/* ---------- the two levels ----------
   A name, its number, and a groove cut into the tablet. The run of the groove that is
   "on" is bronze, and the handle is a turned stone, the volute in miniature. */
.menu-levels {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 3px;
  padding: 9px 8px 6px;
  border-top: 1px solid rgb(var(--c-umber) / 0.24);
  box-shadow: inset 0 1px 0 rgb(var(--c-light) / 0.6);
}

.menu-level { display: flex; flex-direction: column; gap: 3px; }

.menu-level-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.menu-level-name {
  font-family: var(--font-carved);
  font-size: var(--fs-cap);
  font-weight: 650;
  font-variation-settings: "opsz" 10;
  letter-spacing: var(--track-caps);
  text-transform: uppercase;
  color: var(--ink-2);
  cursor: pointer;
}

/* the number is a readout, not a label: it sits right, it never moves, and tabular
   figures keep it from shifting as the slider travels */
.menu-level-value {
  font-size: var(--fs-cap);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.menu-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 18px; /* the whole row is the target, not just the groove */
  margin: 0;
  background: none;
  cursor: pointer;
}

.menu-range::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: 3px;
  /* the fill is written by paintVolumes() as --v: the level has to be legible at a
     glance, and a bare groove at 30 % and at 90 % look identical */
  background:
    linear-gradient(to right, var(--bronze) 0 calc(var(--v, 100) * 1%), rgb(var(--c-umber) / 0.16) calc(var(--v, 100) * 1%) 100%);
  box-shadow: inset 0 1px 2px rgb(var(--c-umber-deep) / 0.4), 0 1px 0 rgb(var(--c-light) / 0.7);
}

.menu-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 15px;
  height: 15px;
  margin-top: -5px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 45%, var(--stone-0) 0 34%, var(--stone-3) 36% 60%, var(--stone-4) 62% 100%);
  box-shadow: inset 0 0 0 1px rgb(var(--c-umber) / 0.5), 0 1px 0 var(--stone-foot), 0 2px 4px rgb(var(--c-umber-deep) / 0.3);
}

.menu-range::-moz-range-track {
  height: 5px;
  border-radius: 3px;
  background:
    linear-gradient(to right, var(--bronze) 0 calc(var(--v, 100) * 1%), rgb(var(--c-umber) / 0.16) calc(var(--v, 100) * 1%) 100%);
  box-shadow: inset 0 1px 2px rgb(var(--c-umber-deep) / 0.4), 0 1px 0 rgb(var(--c-light) / 0.7);
}

.menu-range::-moz-range-thumb {
  width: 15px;
  height: 15px;
  border: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 45%, var(--stone-0) 0 34%, var(--stone-3) 36% 60%, var(--stone-4) 62% 100%);
  box-shadow: inset 0 0 0 1px rgb(var(--c-umber) / 0.5), 0 2px 4px rgb(var(--c-umber-deep) / 0.3);
}

/* the score leads: it is the number the run is about. Moves sit beside it behind a
   hairline, so the bar reads as one instrument instead of two floating figures */
/* the instrument is ONE raised ivory plaque on the stone — the only solid object in
   the bar, so the numbers have a single place to be. It keeps its thickness (the drop
   shadow and the 2 px bed) because that is what makes it read as set ON the slab */
/* ---------- dust ----------
   Above EVERYTHING in the stage — the board (2) and the wall (3). It has to be: the puff
   off a landing word's feet happens in the 15 px of shelf the row stands on, and the row
   itself is painted over this layer at z 3, so dust below the wall was hidden behind the
   very row that made it. Nothing is emitted above a row's feet, so nothing here can cover
   a word. Never interactive, never a hit target. */
.dust {
  position: absolute;
  inset: 0;
  z-index: 4;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ---------- the echinus: the bar is a capital seen from below ----------
   A capital is not a rectangle with a plinth; between the fillet and the face there is
   an echinus — a shallow convex moulding that leans out of the abacus. Nine pixels of
   it are enough to lose the hard edge and make the top of the bar read as a profile
   instead of a cut. It is drawn as a band, so it costs no layout: the header's padding
   clears it (the fillet's 5 px plus these 9). */
.hud-echinus {
  position: absolute;
  left: 0;
  right: 0;
  top: 5px;
  height: 9px;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(180deg, #e9dbbe 0%, #e3d3b2 58%, var(--stone-3) 100%);
  box-shadow:
    /* the lit lip of the fillet above it, and the shadow it throws down the face */
    inset 0 1px 0 rgb(var(--c-light) / 0.9),
    inset 0 -2px 3px -1px rgb(var(--c-umber) / 0.3);
}

/* ---------- the numbers, cut into the stone ----------
   No plate: the figures are engraved, so the light comes off a bevel instead of a card.
   A dark line above each glyph and a light one below is what a chisel leaves — that,
   and one weight heavier than a printed numeral would be, is the whole trick. */
.hud-stats {
  /* two rows shared by both figures, so the captions sit on ONE line and the numerals
     sit on ONE baseline even though the score is set larger than the moves. Centring
     two stacked blocks of different heights — what this used to do — put every caption
     and every numeral at a slightly different height, which is the first thing that
     makes a HUD look improvised. */
  display: grid;
  grid-template-columns: auto auto auto;
  grid-template-rows: auto auto;
  align-items: baseline;
  column-gap: 16px;
  /* one number: the caption sits as close to its figure as a carved line allows. The
     gap used to be a 4 px margin plus a 3 px row gap, and it read as a stack of two
     separate things rather than one reading. */
  row-gap: 2px;
  justify-content: end;
  min-width: 0;
}

.hud-rule {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  width: 1px;
  height: 30px;
  background: linear-gradient(180deg, transparent, rgb(var(--c-umber) / 0.45), transparent);
}

.stat {
  /* the block spans both rows and borrows them from the parent, so its caption and its
     figure land in the SHARED rows instead of in rows of its own */
  grid-row: 1 / span 2;
  display: grid;
  grid-template-rows: subgrid;
  align-items: baseline;
  justify-items: end;
  flex: 0 0 auto;
  line-height: 1;
}

.stat-label {
  font-family: var(--font-carved);
  font-variation-settings: "opsz" 9;
  font-size: var(--fs-micro);
  letter-spacing: 0.13em;
  text-transform: uppercase;
  white-space: nowrap;
  /* measured against the THREE stones of the face at 8 px — the label sits high, but a
     carved caption must hold wherever the gradient puts it: var(--ink-2) is 6.0:1 on
     var(--stone-1), 5.5:1 on var(--stone-2), 4.7:1 on the darkest var(--stone-3) */
  color: var(--ink-2);
  font-weight: 700;
}

.stat-value {
  font-family: var(--font-carved);
  font-variation-settings: "opsz" 48;
  font-size: 23px;
  font-weight: 700;
  letter-spacing: var(--track-tight);
  font-variant-numeric: lining-nums tabular-nums;
  color: var(--ink);
  display: inline-block;
  /* the chisel: shadow above, light below */
  text-shadow:
    0 1px 0 rgb(var(--c-light) / 0.95),
    0 -1px 1px rgb(var(--c-umber) / 0.45),
    0 -2px 1px rgb(var(--c-umber) / 0.16);
}

.stat-moves {
  position: relative;
  min-width: 0;
}

/* a move spent is read on the counter itself, once, without a toast */
.stat-delta {
  position: absolute;
  right: -3px;
  top: 15px;
  font-size: var(--fs-label);
  font-weight: 800;
  letter-spacing: 0;
  color: var(--accent-text);
  font-variant-numeric: tabular-nums;
  opacity: 0;
  pointer-events: none;
}

.stat-moves.is-spending .stat-delta { animation: moveOut 0.62s var(--e-out) both; }
.stat-moves.is-spending .stat-value { animation: moveDip 0.5s var(--e-out) both; }

@keyframes moveOut {
  0% { opacity: 0; transform: translateY(3px); }
  22% { opacity: 1; transform: translateY(-5px); }
  70% { opacity: 1; transform: translateY(-10px); }
  100% { opacity: 0; transform: translateY(-15px); }
}

@keyframes moveDip {
  0%, 100% { transform: none; }
  38% { transform: translateY(1px) scale(0.9); }
}

/* ---------- Rack ---------- */

/* The tray is the board's top rail, not a separate object: it bleeds to the
   card's own edges and rounds the top corners, exactly as the shoe does at the
   bottom. It inherits the board's tilt, so the whole thing is one plane. */
/* ---------- the wall's floor: a cornice, in perspective ----------
   The shelf is not a stripe, it is an object with a surface. Read bottom to top:
   the plinth and its shadow, the frieze with its meander, and then a real TOP
   SURFACE — a plane rotated back into the scene with its own perspective, so it
   foreshortens and narrows toward the back. The wall stands at that surface's far
   edge, which puts the near edge in front of the cards' feet: that is what makes
   the pile read as placed ON the shelf instead of floating over a line. */
.ledge {
  position: relative;
  z-index: 3;
  flex: 0 0 auto;
  height: 32px;
  margin: -9px -9px 0;
  border-radius: 17px 17px 0 0;
  /* the front face: warm limestone with a grain multiplied into it */
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23g)' opacity='0.2'/%3E%3C/svg%3E"),
    linear-gradient(180deg, #efe3ca 0%, #dccca8 52%, #c3ac82 100%);
  background-blend-mode: multiply, normal;
  box-shadow:
    inset 0 1px 0 rgb(var(--c-light) / 0.85),
    0 5px 12px rgb(var(--c-umber-deep) / 0.2);
}

/* ---------- the top surface ----------
   A plane seen from above: `rotateX(74deg)` about its front edge turns a 34px band
   into the 10px of stone you would actually see, narrowing toward the back because
   it carries its own perspective. The clipping box is what keeps the board's
   rounded top corners — a rotated rectangle has square ones and they poked out. */
.ledge-face {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  /* the box is exactly as tall as the plane projects (44 × cos74° ≈ 12), so the
     whole visible band is stone — no empty strip above it */
  height: 15px;
  overflow: hidden;
  border-radius: 17px 17px 0 0;
}

.ledge-face i {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 44px;
  transform-origin: 50% 100%;
  /* a short focal length: the far edge narrows enough that the band reads as a
     surface receding into the scene rather than a painted stripe */
  transform: perspective(170px) rotateX(70deg);
  background:
    /* only the ambient darkening at the back of the surface: the cards' own
       drop-shadow is what marks where they meet the stone, so a baked-in contact
       band here would sit in the wrong place the moment the pile moved */
    linear-gradient(180deg, rgb(var(--c-umber-deep) / 0.3) 0, rgb(var(--c-umber-deep) / 0.12) 16px, transparent 32px),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='g2'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.7' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23g2)' opacity='0.18'/%3E%3C/svg%3E"),
    /* the stone itself: lit toward the front edge, darker where it runs away from
       the light at the back — no white, or it reads as a second highlight line */
    linear-gradient(180deg, #b49a72 0%, #cdb78e 34%, #e6d8b8 72%, #f4ecda 100%);
  background-blend-mode: normal, multiply, normal;
}

/* ---------- the front face: the meander ----------
   A Greek key cut into the frieze, at 30 px pitch so it still resolves on a phone —
   the narrower 22 px key turns into hatchwork below ~400 px. The band is a mid tone
   on purpose: a cream frieze beside a cream tray has no weight, and the shelf has to
   frame the tray the way stone frames a lighter panel. Light falls from the cornice
   above it and the key sits in the stone, so the frieze has a body to be carved from. */
.ledge-channel {
  position: absolute;
  left: 0;
  right: 0;
  top: 15px;
  bottom: 5px;
  background:
    /* the key: a 4 px return, a 13 px run, a 6 px well — one turn per 30 px */
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='30' height='14'%3E%3Cg fill='none' stroke='%23806a44' stroke-width='2.2' opacity='0.7'%3E%3Cpath d='M4 12V4h13v6H10v3h12V6'/%3E%3C/g%3E%3C/svg%3E") 0 50% / 30px 12px repeat-x,
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='fz'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23fz)' opacity='0.22'/%3E%3C/svg%3E"),
    linear-gradient(180deg, #e6dcc0 0%, #cdbf9c 55%, #b4a37c 100%);
  background-blend-mode: multiply, multiply, normal;
  box-shadow:
    /* the cornice above: the shadow it throws down the frieze, and the lit foot */
    inset 0 6px 7px -4px rgb(var(--c-umber-deep) / 0.55),
    inset 0 -2px 0 rgb(var(--c-light) / 0.22);
}

/* the plinth: the shelf's footing, and the shadow it throws on the tray */
.ledge::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 5px;
  border-radius: 0 0 2px 2px;
  background: linear-gradient(180deg, var(--stone-4) 0%, var(--stone-5) 100%);
  box-shadow:
    inset 0 1px 0 rgb(var(--c-light) / 0.55),
    0 2px 0 rgb(var(--c-umber) / 0.45),
    0 9px 18px rgb(var(--c-umber-deep) / 0.34);
}

.rackbar {
  position: relative;
  margin: 0 -9px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  align-items: stretch;
  padding: 9px 10px 9px;
  border: 0;
  border-radius: 0;
  background:
    linear-gradient(180deg, var(--rack-hi) 0%, var(--rack) 58%, var(--rack-lo) 100%);
  box-shadow:
    inset 0 1px 0 rgb(var(--c-light) / 0.75),
    inset 0 -2px 6px rgb(var(--c-umber) / 0.16);
}

/* (the rack's delete key is gone: tapping a letter selects it and the plate turns
   into the delete, and Backspace/Delete work from the keyboard — the blanks get
   that width instead) */

.rack-row {
  display: flex;
  gap: 12px;
  align-items: stretch;
  position: relative;
  z-index: 3;
}

.rack {
  position: relative;
  flex: 1;
  display: grid;
  grid-template-columns: repeat(var(--slots, 6), minmax(0, 1fr));
  /* the blanks sit closer together than the board's cards: with the delete key
     gone and the plate holding the delete, this band is about one thing — the
     letters you are holding — so the gaps give way to the cards */
  gap: clamp(3px, 0.6vw, 5px);
  align-items: end;
  min-width: 0;
}

.slot {
  position: relative;
  min-width: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  /* the slot IS the card's square plus the lip it stands on: the content box is
     one square, so an empty and a filled blank are the same box at every gap and
     a landing card can never move the board. content-box because the square is
     the card's footprint, not the lip's. */
  box-sizing: content-box;
  aspect-ratio: 1;
  height: auto;
  padding: 0 0 8px;
  border: 0;
  background: none;
  font-family: inherit;
  color: inherit;
  cursor: pointer;
  transition: transform var(--m-fast) var(--e-spring);
}

/* empty blank: a quiet inset well, cut to exactly the card's footprint */
.slot::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 8px;
  /* a groove, not a tile: it has to sit inside the rack face */
  width: min(100%, var(--card-max));
  height: auto;
  aspect-ratio: 1;
  transform: translateX(-50%);
  border: 1px solid rgb(var(--c-umber) / 0.3);
  border-radius: var(--card-radius);
  background: linear-gradient(180deg, rgb(var(--c-umber) / 0.2), rgb(var(--c-umber) / 0.1));
  box-shadow:
    inset 0 3px 5px rgb(var(--c-umber) / 0.3),
    inset 0 -1px 0 rgb(var(--c-light) / 0.4);
  transition: background var(--m-fast) var(--e-out), border-color var(--m-fast) var(--e-out);
}

.slot[data-filled="1"]::after { opacity: 0; }

.slot:focus-visible { outline: none; }
.slot:focus-visible .slot-letter { outline: var(--focus-ring); outline-offset: var(--focus-offset); }

.slot-letter {
  position: relative;
  display: grid;
  place-items: center;
  /* the letter is sized by the CARD, not by the viewport: 5vw in a narrow column
     on a wide screen made a 32px glyph in a 38px card, so the value in the corner
     collided with the letter itself */
  /* the card itself: the same square, radius and type scale as a board tile */
  width: min(100%, var(--card-max));
  aspect-ratio: 1;
  border-radius: var(--card-radius);
  border: 1px solid var(--tile-line);
  background: var(--card-fill);
  box-shadow: var(--card-shadow), 0 4px 8px rgb(var(--c-shade) / 0.1);
  font-size: clamp(18px, 74cqi, 40px);
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
  color: var(--ink);
}

/* the slot is the measuring stick for the letter above */
.slot { container-type: inline-size; }

/* "next word scores double" rings the whole rack, also as its own layer */
.rack::before {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: var(--r-panel);
  border: 2px solid var(--gold-hi);
  opacity: 0;
  pointer-events: none;
  will-change: opacity, transform;
}

.rack.is-firing::before { animation: rackFire 1.45s var(--e-out) both; }

@keyframes rackFire {
  0% { opacity: 0.9; transform: scale(0.996); }
  100% { opacity: 0; transform: scale(1.012); }
}

/* a word that is a word: the plate turns terracotta (the action), and the letters
   only warm to gold — one red thing on the tray, not seven */
.rack.is-valid .slot-letter {
  border-color: var(--gold);
  box-shadow: var(--card-shadow), 0 0 0 1.5px rgb(var(--c-gold) / 0.7);
}

/* a selected letter is picked up, not painted: it lifts and takes a gold rim, and the
   plate beside it becomes the delete key (the action, in terracotta) */
.slot[data-selected="1"] .slot-letter {
  border-color: var(--gold);
  box-shadow: var(--card-shadow), 0 0 0 2.5px var(--gold-hi), 0 8px 14px rgb(var(--c-umber-deep) / 0.25);
  transform: translateY(-4px);
}
.slot[data-filled="1"]:hover { transform: translateY(-2px); }

body:not(.is-scoring) .slot[data-filled="1"]:hover .slot-letter { transform: translateY(-1px); }

.slot.drop-target::after {
  opacity: 1;
  border-color: var(--gold);
  background: rgb(var(--c-gold) / 0.25);
}

/* ---------- Word block ----------
   The bar above the blanks is the action key: it shows only the numbers (the
   word itself is in the rack), and the whole row is what you press. */

.wordcard {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0;
  padding: 3px 8px;
  /* an ivory plate set into the tray's back rail, not a card resting on it:
     the wood shows on all four sides, and the groove is cut by the shadow */
  border: 1px solid rgb(var(--c-umber) / 0.42);
  border-radius: 7px;
  /* ivory, not paper: a plate cut into the rail, so the router's shadow falls
     into its top edge and the wood sits proud of it */
  background: linear-gradient(180deg, var(--card-hi) 0%, #fdf9f0 100%);
  box-shadow:
    inset 0 2px 4px rgb(var(--c-umber) / 0.16),
    inset 0 -1px 0 rgb(var(--c-light) / 0.75),
    0 1px 0 rgb(var(--c-light) / 0.5);
  /* the plate is the smallest band in the tray: the blanks are what you look at,
     the plate is what you press */
  min-height: 32px;
  transition: transform var(--m-base) var(--e-spring), box-shadow var(--m-base) var(--e-out),
    border-color var(--m-base) var(--e-out);
}

/* the plate is set into the rail, so its ring is drawn inside it */
.wordcard:focus-visible { outline-offset: -3px; }

/* a word is a word: the bar goes red so the next move is obvious at a glance */
.wordcard[data-state="valid"] {
  border-color: var(--accent);
  background: linear-gradient(180deg, #fff4ef 0%, #fbdfd4 100%);
  box-shadow:
    inset 0 2px 4px rgb(var(--c-umber) / 0.14),
    inset 0 0 0 1.5px rgb(var(--c-accent) / 0.6),
    0 0 0 3px rgb(var(--c-accent) / 0.18),
    0 6px 16px rgb(var(--c-accent) / 0.16);
}

.wordcard[data-state="valid"] .wc-status { color: var(--accent-deep); }
.wordcard[data-state="valid"] .wc-math { color: var(--ink-2); }

/* the ring breathes: a word sitting ready should catch the eye without shouting.
   It is a layer that only changes opacity and scale — an animated box-shadow is
   repainted whole on every frame and Chrome counts it against layout stability. */
.wordcard::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: 9px;
  border: 2px solid var(--accent);
  opacity: 0;
  pointer-events: none;
  will-change: opacity, transform;
}

.wordcard[data-state="valid"]::after { animation: wcReady 2.6s var(--e-soft) infinite; }

@keyframes wcReady {
  0%, 100% { opacity: 0.32; transform: scale(1); }
  50% { opacity: 0.85; transform: scale(1.008); }
}

.wordcard[data-state="valid"] .wc-total { color: var(--accent-deep); }

/* not a word is quiet, not loud: red is reserved for a word you can send */
.wordcard[data-state="invalid"] {
  border-color: var(--line-strong);
  border-style: dashed;
}

/* the whole bar is the button */
.wordcard.is-actionable { cursor: pointer; }
.wordcard.is-actionable:hover { transform: translateY(-1px); border-color: var(--ink-2); }
.wordcard.is-actionable:active { transform: translateY(1px); }
.wordcard.is-actionable .wc-arrow { background: var(--accent); color: var(--accent-ink); }
.wordcard.is-delete .wc-arrow { background: var(--accent-deep); color: var(--accent-ink); }
.wordcard.is-actionable .wc-total { color: var(--accent-deep); }

.wordcard[data-swiping="1"] {
  transform: translateY(-5px);
  box-shadow: 0 10px 22px rgb(var(--c-shade) / 0.12);
}

.wordcard.is-dragging { opacity: 0.55; }

.wc-word {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  /* the status is the exception, not the subject: it takes its own width and no
     more, so the line of reasoning starts at the left edge of the plate */
  flex: 0 1 auto;
  overflow: hidden;
}

/* nothing to say most of the time, so the cell takes no room at all */
.wc-word:empty,
.wc-status:empty { display: none; }

.wc-status {
  margin: 0;
  font-size: var(--fs-cap);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wordcard[data-state="invalid"] .wc-status { color: var(--ink-3); }

/* the total and the key never move: the chips give up their width first, or a
   plate full of chips pushes the number out of the plate entirely */
.wc-points {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
}

/* the working: a row of chips, one per reason. Every chip is the same chip — a small
   ivory slip pressed into the plate — and only its NUMBER carries meaning: the accent is
   what the word cost you, gold is what it earned beyond its letters, and a rarity chip
   is printed in that tier's colour (the same colour the wall and the lid use). When the
   chips do not fit they wrap to a second line rather than being sliced off: a number
   the player cannot read is worse than a plate that grows by one line. */
.wc-math {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px;
  flex: 1 1 auto;
  min-width: 0;
}

.wc-chip {
  flex: 0 0 auto;
  padding: 2px 5px;
  border-radius: var(--r-chip);
  background: rgb(var(--c-umber) / 0.1);
  box-shadow: inset 0 0 0 1px rgb(var(--c-umber) / 0.12);
  color: var(--ink-2);
  font-size: var(--fs-micro);
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.wc-chip b { color: var(--ink); font-weight: 800; font-variant-numeric: tabular-nums; }

.wc-chip[data-k="cost"] { background: rgb(var(--c-accent) / 0.1); box-shadow: inset 0 0 0 1px rgb(var(--c-accent) / 0.2); color: var(--accent-text); }
.wc-chip[data-k="cost"] b { color: var(--accent-text); }
.wc-chip[data-k="new"] b,
.wc-chip[data-k="alphabet"] b,
.wc-chip[data-k="double"] b,
.wc-chip[data-k="fuse"] b { color: var(--gold-ink); }
.wc-chip[data-k="tier-familiar"] b { color: var(--tier-familiar); }
.wc-chip[data-k="tier-uncommon"] b { color: var(--tier-uncommon); }
.wc-chip[data-k="tier-rare"] b { color: var(--tier-rare); }

/* the arrow is the cue, not the target: it lights up when the bar is pressable */
.wc-arrow {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: rgb(var(--c-umber) / 0.12);
  color: var(--ink-3);
  font-size: 15px;
  font-weight: 800;
  line-height: 1;
  transition: background var(--m-fast) var(--e-out), color var(--m-fast) var(--e-out),
    transform var(--m-fast) var(--e-spring);
}

/* the arrow that turns the reasoning into a result: it appears only when there is
   reasoning to read, so an idle plate is just the em dash and the key */
.wc-sep {
  flex: 0 0 auto;
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 800;
}

.wordcard[data-state="valid"] .wc-sep { color: rgb(var(--c-accent) / 0.75); }

.wordcard[data-has-deltas="0"] .wc-sep { display: none; }

.wc-total {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 2px;
  min-width: 40px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
}

.wordcard[data-bump="1"] .wc-total b { animation: wcBump 0.42s var(--e-spring); display: inline-block; }

@keyframes wcBump {
  0% { transform: scale(1); }
  45% { transform: scale(1.28); }
  100% { transform: scale(1); }
}

/* ---------- Board ---------- */

.board {
  position: relative;
  /* the felt's own inset, shared with the rail so the wells sit exactly on the
     board's column centres (a 9px offset made a dealt card drift sideways) */
  --felt-pad: clamp(7px, 1.4vw, 10px);
  padding: 9px;
  border: 1px solid var(--line-strong);
  /* the board stands on the bottom of the screen: no bottom edge, no bottom curve —
     only the top corners are rounded, mirroring the header, whose top is the screen's */
  border-bottom: 0;
  border-radius: var(--r-board) var(--r-board) 0 0;
  /* the board's own body: the wood the tray, the felt and the shoe are set into */
  background: var(--rack);
  box-shadow: 0 20px 44px rgb(var(--c-shade) / 0.11);
  /* the board does not scroll and it does not fade or tilt away: it slides down
     out of the stage at exactly the speed the wall's foot does, so the wall stays
     welded to its shelf the whole way up. Nothing else is applied to it — a fade
     made it look like it was evaporating and the extra tilt broke it off the wall */
  transform: translateY(calc(var(--sink, 0) * 1px)) rotateX(6deg);
  transform-origin: 50% 100%;
}

.grid {
  display: grid;
  grid-template-columns: repeat(var(--cols, 6), minmax(0, 1fr));
  gap: clamp(6px, 1.4vw, 10px);
}

#grid {
  /* the felt runs the full width of the card between the two wooden rails: with
     side insets the white card showed as two strips and the board split in three */
  margin: 0 -9px;
  padding: var(--felt-pad, clamp(7px, 1.4vw, 10px));
  border-radius: 0;
  /* tiles refill a column by sliding up from below it: without a clip they draw
     over the board's white edge and the page, and the felt stops being a surface.
     The margin keeps their own shadows and the hover lift inside the felt. */
  overflow: clip;
  overflow-clip-margin: 16px;
  background:
    radial-gradient(120% 100% at 50% 0%, rgb(var(--c-light) / 0.05), rgba(0, 0, 0, 0.18)),
    var(--felt);
  box-shadow: inset 0 1px 0 rgb(var(--c-light) / 0.06);
}

/* while a card is dealing out of the shoe it has to cross the seam, so the felt
   stops clipping for the length of that one flight */
#grid.is-dealing { overflow: visible; }

/* and it has to paint over the rail, or the next card waiting in its well is drawn
   on top of it and the flight looks like a ghost */
.tile.is-flying { z-index: 5; }

/* ---------- Tiles ---------- */

.tile {
  position: relative;
  aspect-ratio: 1;
  width: 100%;
  max-width: var(--card-max);
  justify-self: center;
  border: 1px solid var(--tile-line);
  border-radius: var(--card-radius);
  background: var(--card-fill);
  color: var(--ink);
  font-family: var(--font);
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
  display: grid;
  place-items: center;
  cursor: grab;
  /* the card is the measuring stick for everything printed on it: the letter is half
     the card at every size. It used to be 5vw, which made a 20 px letter on a 74 px
     phone tile and a 32 px letter on a 64 px desktop one — the phone, where most runs
     are played, got the weakest board. No padding: a button's default inline padding
     would come out of the container and shrink every letter by a fifth */
  container-type: inline-size;
  padding: 0;
  box-shadow: var(--card-shadow), 0 5px 10px rgb(var(--c-felt-shade) / 0.3);
  transition: transform var(--m-fast) var(--e-spring), box-shadow var(--m-base) var(--e-out),
    border-color var(--m-fast) var(--e-out);
  will-change: transform;
}

.tile-face { display: grid; place-items: center; line-height: 1; font-size: 50cqi; transform: translateY(-1px); }

.tile-val {
  position: absolute;
  right: 9cqi;
  bottom: 5cqi;
  font-size: clamp(8px, 17cqi, 13px);
  font-weight: 600;
  letter-spacing: 0;
  color: var(--ink-3);
  text-transform: none;
}

.tile:hover {
  z-index: 2;
  transform: translateY(-2px);
  border-color: var(--tile-line-2);
  box-shadow:
    inset 0 1px 0 rgb(var(--c-light) / 0.8),
    0 3px 0 var(--card-foot),
    0 12px 20px rgb(var(--c-felt-shade) / 0.34);
}

.tile:active { transform: translateY(1px) scale(0.97); cursor: grabbing; transition-duration: var(--m-instant); }

/* ---------- bonus cards: one deck ----------
   A bonus is a card from the same deck as the letters, not a sticker from another
   game: the same ivory, the same edge and thickness, washed with its kind's earthy mark
   (--bonus-<kind> in :root) and with the glyph and caption printed in that mark. The
   kinds stay told apart by hue; the deck stays one deck because every wash is mixed
   from the same ivory. */
.tile-bonus,
.deck .face[data-kind] {
  --mark: var(--ink-2);
  background:
    linear-gradient(180deg, rgb(var(--c-light) / 0.55), transparent 60%),
    color-mix(in srgb, var(--tile) 74%, var(--mark));
  border-color: color-mix(in srgb, var(--tile-line) 60%, var(--mark));
  color: color-mix(in srgb, var(--mark) 82%, var(--ink));
}

[data-kind="clearRow"] { --mark: var(--bonus-clearRow); }
[data-kind="clearCol"] { --mark: var(--bonus-clearCol); }
[data-kind="shuffle"] { --mark: var(--bonus-shuffle); }
[data-kind="double"] { --mark: var(--bonus-double); }
[data-kind="fuse"] { --mark: var(--bonus-fuse); }
[data-kind="extraSlot"] { --mark: var(--bonus-extraSlot); }
[data-kind="addColumn"] { --mark: var(--bonus-addColumn); }

.tile-bonus { cursor: pointer; }

.tile-bonus:hover { border-color: color-mix(in srgb, var(--tile-line-2) 50%, var(--mark)); }

.tile-bonus:active { cursor: pointer; }
.tile-bonus .glyph { font-size: 38cqi; }

/* the glyph is a symbol, so the card spells itself out underneath: no tooltip to
   discover, nothing to press and hold while your thumb is already dragging */
.tile-bonus .tile-face { transform: translateY(-4px); }

.tile-bonus .tile-cap {
  position: absolute;
  left: 3px;
  right: 3px;
  bottom: 7cqi;
  font-size: clamp(6px, 11cqi, 9px);
  font-weight: 800;
  letter-spacing: 0.05em;
  line-height: 1;
  text-align: center;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  color: color-mix(in srgb, var(--mark) 70%, var(--ink));
  pointer-events: none;
}

/* A fired row or column glows through a ring layer of its own: opacity + scale
   only, so the four tiles that pop never repaint their shadows. */
.tile::before {
  content: "";
  position: absolute;
  inset: -5px;
  border-radius: 12px;
  border: 2px solid rgb(var(--c-gold) / 0.9);
  opacity: 0;
  pointer-events: none;
  will-change: opacity, transform;
}

.tile.is-popping::before { animation: tilePop 0.78s var(--e-out) both; }

@keyframes tilePop {
  0% { opacity: 0.95; transform: scale(0.88); }
  100% { opacity: 0; transform: scale(1.1); }
}

/* Milestone cards wear gold: the reward colour, as a rim of its own outside the card's
   edge. It used to be an accent ring (read as "selected"), then an accent corner flag
   (read as "warning"); gold is the one colour that means "you earned this". */
.tile-milestone {
  box-shadow:
    var(--card-shadow),
    0 0 0 2px var(--gold-hi),
    0 0 0 3px rgb(var(--c-umber-deep) / 0.25),
    0 5px 10px rgb(var(--c-felt-shade) / 0.3);
}

.tile-milestone:hover {
  box-shadow:
    var(--card-shadow),
    0 0 0 2px var(--gold-hi),
    0 0 0 3px rgb(var(--c-umber-deep) / 0.25),
    0 12px 20px rgb(var(--c-felt-shade) / 0.34);
}

.tile.is-gone { opacity: 0; }

/* ---------- Baseline + queue ---------- */

.baseline {
  position: relative;
  height: 1px;
  border-top: 1px solid var(--line-strong);
  margin: 8px 2px;
}

.baseline i {
  position: absolute;
  top: -3px;
  width: 1px;
  height: 6px;
  background: var(--line-strong);
}

.baseline i:first-child { left: 0; }
.baseline i:last-child { right: 0; }

/* ---------- The shoe: one bay of queued cards per column ----------
   The board carries its own deck. Each bay is a routed well in the wood — the same
   language as the rack's empty blanks — holding that column's real queue: the front
   card legible, the two behind it as card edges. */

.board .seam-top { margin: 0; }
.board .baseline { margin: 0; }

.board .rail {
  margin: 0 -9px -9px;
  /* the felt sits 9px (board padding) + --felt-pad into the card; the rail has to
     use the same inline inset and gap or its wells land off the column centres */
  /* the foot is a wooden rim the toast plate sits on, plus the home-indicator area */
  padding: 3px calc(9px + var(--felt-pad, 10px)) calc(22px + env(safe-area-inset-bottom));
  border-top: 1px solid rgb(var(--c-umber) / 0.35);
  border-radius: 0;
  background: linear-gradient(180deg, var(--rack-hi) 0%, var(--rack) 58%, var(--rack-lo) 100%);
  box-shadow:
    inset 0 1px 0 rgb(var(--c-light) / 0.6),
    inset 0 -2px 6px rgb(var(--c-umber) / 0.16);
}

.grid.preview {
  grid-template-columns: repeat(var(--cols, 6), minmax(0, 1fr));
  gap: clamp(6px, 1.4vw, 10px);
  padding: 0;
}

.bay {
  position: relative;
  /* one slot per column, not a long tray: the wood between them is the rail */
  justify-self: center;
  width: min(88px, 97%);
  /* the well is cut to the card's own footprint plus the lip the queue stands
     in — the groove the rack's blanks are cut with, at the size of a card. No
     fixed height: the well grows with the card instead of cropping it. */
  border-radius: var(--card-radius);
  border: 1px solid rgb(var(--c-umber) / 0.3);
  background: linear-gradient(180deg, rgb(var(--c-umber) / 0.24), rgb(var(--c-umber) / 0.13));
  box-shadow: inset 0 4px 6px rgb(var(--c-umber) / 0.32), inset 0 -1px 0 rgb(var(--c-light) / 0.35);
  display: grid;
  place-items: start center;
  padding: 2px 4px 9px;
  /* the queue leans back INTO the well: one local vanishing point, so the top of
     a card recedes while its foot comes at you */
  perspective: 220px;
  perspective-origin: 50% 35%;
}

/* the deck: the card that drops in next lies on top of the pile and the two after
   it wait underneath, each shifted down 42% of a card so its own bottom band shows
   below the card above it. Not `.stack` — that name belongs to the word pile, and
   sharing it shrank the pile to 60px. The well's own perspective tilts the queue
   into its groove, which is also why a dealt card leaves the well already tilted
   instead of snapping flat. */
.deck {
  position: relative;
  width: min(100%, var(--card-max));
  /* the pile stands 1.84 cards tall: the spacer carries the extra 0.84 so the well
     grows to fit the stack without the card ever needing a fixed size */
  container-type: inline-size;
  transform: rotateX(12deg);
  transform-origin: 50% 0;
}

.deck::before { content: ""; display: block; padding-top: 184%; }

.deck .face {
  position: absolute;
  top: 0;
  left: 0;
  /* the card itself: the same square, radius and value corner as a card on the
     board or in a blank, and the same type ratio: the letter is half the card. */
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--card-radius);
  border: 1px solid var(--tile-line);
  background: var(--card-fill);
  display: grid;
  place-items: center;
  font-size: 50cqw;
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
  color: var(--ink);
  box-shadow: var(--card-shadow), 0 3px 6px rgb(var(--c-shade) / 0.2);
}

/* the next card is the one you read in full */
.deck .face:nth-child(1) { z-index: 3; }

/* the two under it: only their bottom band shows, so the letter sits in that band
   instead of the middle of a card nobody can see. A percentage margin is measured
   against the card's width, which is exactly the step down the pile. */
.deck .face:nth-child(2),
.deck .face:nth-child(3) {
  margin-top: 42%;
  z-index: 2;
  place-items: end center;
  padding-bottom: 4cqw;
  /* the band is 58 % of a card tall: the letter takes 40 % of the width, and never
     more than 80 % of the board's glyph, so the two peeks stay under the top card */
  font-size: 40cqw;
}
.deck .face:nth-child(3) { margin-top: 84%; z-index: 1; }

.deck .face b {
  position: absolute;
  right: 6px;
  bottom: 3px;
  font-size: clamp(7px, 17cqw, 12px);
  font-weight: 600;
  color: var(--ink-3);
}

/* the band under a card is short: its point value has to shrink with it, or the
   value reads as a second letter. It stays a step under the top card's value at
   every size, so the three cards read as one card and two peeks. */
.deck .face:nth-child(2) b,
.deck .face:nth-child(3) b {
  right: 3px;
  bottom: 2px;
  font-size: clamp(6px, 13cqw, 10px);
}

.board[data-swap="1"] .tile:not(.tile-bonus) {
  outline: 2px dashed rgb(var(--c-gold) / 0.85);
  outline-offset: -3px;
}

.tile.drop-target {
  transform: translateY(-2px);
  border-color: var(--gold);
  box-shadow: 0 6px 10px rgb(var(--c-felt-shade) / 0.26), 0 0 0 3px var(--gold-hi);
  z-index: 2;
}

/* ---------- the toast: a small plaque on the table's front edge ----------
   Not a system notification: a short label cut into a stone plate, fixed to the foot of
   the board like the name plate on a cabinet. It sits on the board's bottom rim rather
   than over the wells, so the queue it would cover stays readable, and it speaks in the
   carved face, at a size that can actually be read. */
.msg {
  position: fixed;
  bottom: calc(1px + env(safe-area-inset-bottom));
  left: 50%;
  z-index: 14;
  margin: 0;
  padding: 3px 12px 4px;
  border: 1px solid rgb(var(--c-umber) / 0.45);
  border-radius: var(--r-control);
  background: linear-gradient(180deg, var(--stone-1) 0%, var(--stone-3) 100%);
  box-shadow:
    inset 0 1px 0 var(--light),
    0 2px 0 var(--stone-foot),
    0 6px 14px rgb(var(--c-umber-deep) / 0.3);
  color: var(--ink);
  font-family: var(--font-carved);
  font-size: var(--fs-label);
  font-weight: 650;
  font-variation-settings: "opsz" 12;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 4px);
  transition: opacity var(--m-fast) var(--e-out), transform var(--m-fast) var(--e-out);
}

.msg.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- The wall ----------
   Words are not rows in a list, they are courses of clay bricks laid on the table:
   bevelled slabs with a contact shadow, staggered like a running bond, inscribed
   rather than typeset. A new word is pushed in *under* the pile, right above the
   board, so the wall rises. */

.stack {
  position: absolute;
  /* the wall runs well further up than the stage does, so a row can be caught half in
     and half out of the ceiling: the header is opaque, and the soffit under it paints
     in front of this layer, which is what turns the bar's foot into a hole the words
     pass through. The extension is deliberately larger than any header is tall, so the
     wall's own clip line always falls inside the stone and can never be seen */
  inset: -120px 0 0;
  
  /* ABOVE the board. The newest row has to lie in front of the shelf — its feet
     overlap the stone the way a card does when it is stood on a ledge, and the
     shelf has to read as being under it, not in front of it. Nothing below the
     pile's foot is ever painted here, so raising this layer cannot cover the tray. */
  z-index: 3;
  /* the layer is above the board, so it must be INERT — otherwise it swallows every
     pointerdown on the table and the board can no longer be touched at all. Only the
     rows themselves opt back in, and they are what the pan guard already excludes */
  pointer-events: none;
  overflow: hidden;
  /* AND a hard cut at the opening's near edge. A clip belongs to the layer itself,
     so it is applied to promoted child layers too — which is what keeps a row that is
     moving under a transform animation from painting over the header. At rest it is
     invisible: the soffit already covers every pixel above that line.
     Geometry, all of it in this file: the wall starts 120 px above the stage, the
     stage starts --hud-gap under the slab, and the soffit ends 13 px under it — so the
     cut falls (120 + 13 − gap) px into the wall's own box, and it follows the header's
     height for free because --hud-h cancels out */
  clip-path: inset(calc(120px + 13px - var(--hud-gap, 10px)) 0 0 0);
  /* the wall is FLAT and climbs straight up: no perspective, no tilt. The pile is a
     plane parallel to the screen, so a course slides vertically by exactly what the
     camera asks for — one number in, one number of pixels out — and the rows never
     foreshorten or change angle as they go under the soffit */
  /* no mask any more: the wall used to dissolve into the paper over 46 px, which
     made the words look like fog. It now runs into the ceiling and is cut by it — the
     header is opaque and sits above this layer, and the soffit (z 4) is the stone in
     front of the rows, so the pile disappears INTO the stone the way it disappears into
     the shelf at the other end */
}

/* the pile is anchored where its newest brick sits — just above the board — and
   the camera slides it down from there */
.log-list {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(var(--wall-anchor, 0) * 1px);
  display: flex;
  flex-direction: column;
  /* the rows are the cards themselves, and their own shadow is what separates
     them: the items stay flush so the pile still reads as one object */
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  /* the wall's own width is the budget every row is measured against: a card is
     a square, so a row of n cards may not be wider than the column (see --cs) */
  container-type: inline-size;
  container-name: wall;
  transform-origin: 50% 100%;
  /* a pure vertical slide. Nothing about the pile is a 3-D move any more, so `rise`
     is pixels of climb, 1:1, and the rows stack at their own real height */
  transform: translateY(calc(var(--rise, 0) * 1px));
  will-change: transform;
}

/* ---------- a row of cards ----------
   There is no block: the row IS the letter cards — the same cards the board deals —
   laid one after another. They touch and share a seam, and the row is exactly as
   wide as its word. Points, bonuses and the tier are in the panel; the wall is read
   as words, not as a table. */
.log-chip {
  position: relative;
  /* every row bends about its own bottom edge, so the wave SHEARS the stack (rows
     rocking on each other) instead of sliding one past another */
  transform-origin: 50% 100%;
  display: flex;
  align-items: stretch;
  width: fit-content;
  max-width: 100%;
  margin-inline: auto;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  color: var(--brick-ink, var(--ink));
  cursor: help;
}

.log-chip:focus-visible { border-radius: var(--r-chip); }

/* a row is the one thing in this layer you can point at: hover opens its numbers,
   tapping opens them on a phone, and the pan guard leaves it alone */
.log-chip { pointer-events: auto; }

/* the letters: the game's own tiles, edge to edge */
.lc-cards {
  display: flex;
  align-items: stretch;
  max-width: 100%;
  /* the row casts onto what is behind it. The bottom row overlaps the shelf, so
     this shadow is what makes it land on the stone instead of floating in front
     of it — soft, downward, and never a resize (filter only) */
  filter: drop-shadow(0 2px 2px rgb(var(--c-umber-deep) / 0.3)) drop-shadow(0 5px 7px rgb(var(--c-umber-deep) / 0.18));
}

.lc-card {
  display: grid;
  place-items: center;
  /* THE SAME PIECE AS THE BOARD'S: a square. `--n` is how many letters the row has
     (written on the chip by renderLog), and a card is as big as the column allows —
     a maximum of 53 px, shrinking only when a long word would not fit, exactly as
     the board's tiles shrink with the column. --cs drives the size, the letter and
     the curve together, so a small square is a small square, not a cropped one. */
  /* --cs drives the size, the letter and the curve together, so a small square is
     a small square, not a cropped one. `--cs-in` lets the flying copy of a row pin
     the exact size it left with: it is appended to `body`, where there is no wall
     container to measure */
  --cs: var(--cs-in, clamp(24px, calc((100cqi - 16px) / var(--n, 5)), 53px));
  flex: 0 0 auto;
  width: var(--cs);
  height: var(--cs);
  padding: 0;
  margin-left: -1px;
  border: 1px solid var(--tile-line);
  border-radius: calc(var(--cs) * 0.13);
  background: var(--brick-fill, var(--card-fill));
  color: var(--brick-ink, var(--ink));
  font-style: normal;
  font-size: calc(var(--cs) * 0.5);
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0;
  text-shadow: 0 1px 0 rgb(var(--c-light) / 0.9);
  box-shadow: inset 0 1px 0 rgb(var(--c-light) / 0.95);
}

.lc-card:first-child { margin-left: 0; }

/* ---------- the numbers live behind the pointer ----------
   A wall is read at a glance: the letters are the row. What paid for it opens on
   hover, on focus (keyboard) or on tap, in one panel anchored above. */
.lc-info {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  z-index: 8;
  display: none;
  align-items: baseline;
  gap: 9px;
  padding: 6px 10px;
  border-radius: 6px;
  background: var(--bronze-deep);
  color: var(--stone-1);
  white-space: nowrap;
  text-shadow: none;
  box-shadow: 0 8px 18px rgb(var(--c-umber-deep) / 0.32);
  transform: translateX(-50%);
  pointer-events: none;
}

.log-chip:hover .lc-info,
.log-chip:focus-visible .lc-info,
.log-chip.is-open .lc-info { display: flex; }

/* the top rows have no room above them, so their panel opens downward */
.log-chip:first-child .lc-info { bottom: auto; top: calc(100% + 8px); }

.lc-word { font-family: var(--font-carved); font-size: var(--fs-label); font-weight: 700; letter-spacing: var(--track-caps); color: var(--light); }

.lc-chips { font-size: var(--fs-micro); font-weight: 600; letter-spacing: 0.05em; color: rgb(var(--c-light) / 0.8); }

.lc-chips i { margin: 0 4px; font-style: normal; color: rgb(var(--c-light) / 0.4); }

.lc-chips [data-b] { color: var(--gold-hi); font-weight: 800; }

.lc-total { font-family: var(--font-carved); font-size: 13px; font-weight: 800; font-variant-numeric: lining-nums tabular-nums; color: var(--light); }

/* ---------- the tier is the tint of the cards ----------
   A brick is the same ivory card as the board's, washed very lightly with its tier's
   colour — the SAME --tier-* colour the plate's chip and the lid's ledger print. Common
   stays plain ivory. The panel spells the tier out, so the tint is never the only cue. */
.log-chip[data-tier="familiar"] { --brick-tint: var(--tier-familiar); }
.log-chip[data-tier="uncommon"] { --brick-tint: var(--tier-uncommon); }
.log-chip[data-tier="rare"] { --brick-tint: var(--tier-rare); }

.log-chip[data-tier]:not([data-tier="common"]) {
  --brick-ink: color-mix(in srgb, var(--brick-tint) 35%, var(--ink));
  --brick-fill: linear-gradient(180deg,
    color-mix(in srgb, var(--card-hi) 90%, var(--brick-tint)) 0%,
    color-mix(in srgb, var(--tile) 82%, var(--brick-tint)) 52%,
    color-mix(in srgb, var(--tile) 70%, var(--brick-tint)) 100%);
}

/* ---------- the wall's physics ----------
   Three motions, all on the individual `translate` / `rotate` / `scale` properties
   so they compose with the camera's `transform` instead of fighting it. Nothing
   ever leaves the stack: every one is return-to-rest. */
.log-list.is-swaying .log-chip {
  animation: brickSway var(--sway-dur, 9s) ease-in-out infinite alternate;
  animation-delay: calc(var(--i, 0) * -0.42s);
}

@keyframes brickSway {
  from { rotate: calc(var(--bsway, 0.2deg) * -1); }
  to { rotate: var(--bsway, 0.2deg); }
}

/* the settle: the courses above a new brick lift by their own weight and come
   back down, staggered by height. The brick itself is not animated here — it flies
   in from the board (see flyWordToLog), and this is what the pile does when it
   lands */
.log-list.is-impact .log-chip:not(.is-new) {
  animation: brickSettle 0.72s cubic-bezier(0.22, 0.9, 0.24, 1) both;
  animation-delay: calc(var(--i, 0) * 18ms);
}

@keyframes brickSettle {
  0% { translate: 0 0; }
  22% { translate: 0 calc(var(--amp, 2px) * -1); }
  54% { translate: 0 calc(var(--amp, 2px) * 0.34); }
  78% { translate: 0 calc(var(--amp, 2px) * -0.12); }
  100% { translate: 0 0; }
}

/* ---------- the brick that has been sent but has not arrived ----------
   It stands exactly where its row will be — absolutely positioned at the foot, so
   the courses above it do not move while the word is still in the air — and it is
   invisible until its first flight frame is in place. No dimmed copy, no waiting
   row: the pile is not missing a brick, it simply has not received it yet. */
.log-chip.is-holding {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  opacity: 0;
}

/* the hit travels into the table: the stage takes a sideways jolt, so the shelf
   and the board are shoved with the pile instead of the pile jolting on its own */
.stage.is-thunk { animation: wallThunk 0.62s cubic-bezier(0.2, 0.9, 0.25, 1) both; }

@keyframes wallThunk {
  0% { translate: 0 0; }
  16% { translate: var(--thunk, 1.5px) 0; }
  40% { translate: calc(var(--thunk, 1.5px) * -0.62) 0; }
  64% { translate: calc(var(--thunk, 1.5px) * 0.28) 0; }
  84% { translate: calc(var(--thunk, 1.5px) * -0.1) 0; }
  100% { translate: 0 0; }
}

.log-empty {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(var(--wall-anchor, 0) * 1px + 6px);
  margin: 0;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}

/* three blanks waiting on the shelf: the footprint of the first word, drawn the way the
   rack's empty blanks are — a groove, not a card */
.le-cards { display: flex; gap: 0; }

.le-cards i {
  width: 46px;
  height: 46px;
  margin-left: -1px;
  border: 1.5px dashed rgb(var(--c-umber) / 0.45);
  border-radius: calc(46px * 0.13);
  background: rgb(var(--c-light) / 0.22);
}

/* a short screen has no wall to speak of: the board fills the stage, and a placeholder
   would only peek out from under the soffit as a stray strip of dashes */
@media (max-height: 720px) {
  .log-empty { display: none; }
}

.le-text {
  font-family: var(--font-carved);
  font-size: 15px;
  font-style: italic;
  font-weight: 500;
  font-variation-settings: "opsz" 18;
  color: var(--ink-2);
  text-shadow: 0 1px 0 rgb(var(--c-light) / 0.6);
}

/* ---------- End of game: the table closes ----------
   A run does not end in a popup from another game. The board is a lid: a stone slab
   that rises off the bottom edge of the stage, covers the tray, the felt and the shoe
   — everything below the shelf — and carries the run's numbers carved into it. It
   lives INSIDE .board, so the camera takes it down with the board when you climb the
   wall: the pile stays readable over a closed table, which is the whole point. */
.closed {
  position: absolute;
  /* from under the shelf down: the shelf is the wall's floor and stays open */
  left: 0;
  right: 0;
  top: 32px;
  bottom: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  /* the board's own shape, because it IS the board, closed: square at the foot, where
     the board meets the screen's edge */
  border-radius: 0;
  /* its buttons stay clear of the home indicator now the slab reaches the screen's foot */
  padding-bottom: env(safe-area-inset-bottom);
  overflow: hidden;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='lid'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23lid)' opacity='0.16'/%3E%3C/svg%3E"),
    linear-gradient(180deg, var(--stone-1) 0%, var(--stone-2) 58%, var(--stone-3) 100%);
  background-blend-mode: multiply, normal;
  box-shadow:
    /* the leading edge of a slab that has just come up: a lit fillet */
    inset 0 1px 0 var(--light),
    inset 0 6px 0 -1px rgb(var(--c-light) / 0.5),
    inset 0 -1px 0 rgb(var(--c-umber) / 0.3),
    0 3px 0 var(--stone-foot),
    0 12px 26px rgb(var(--c-shade) / 0.16);
  animation: lidRise 0.52s cubic-bezier(0.2, 0.88, 0.28, 1) both;
}

.closed[hidden] { display: none; }

/* it comes up, it does not fade in: a lid has mass */
@keyframes lidRise {
  0% { transform: translateY(101%); }
  72% { transform: translateY(-1.5px); }
  100% { transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .closed { animation: none; }
}

.closed-in {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* the block is centred in the closed board: with the ledger gone there is a lot less
     to say, and a group pinned to the top of a tall slab reads as a page that ran out
     of content. `safe center` keeps the top of it reachable on a window too short to
     hold it — a plain centre clips both ends of an overflowing flex column */
  justify-content: safe center;
  overflow-y: auto;
  gap: 0;
  padding: 20px 18px 18px;
  text-align: center;
}

.closed-kicker {
  margin: 0;
  font-family: var(--font-carved);
  font-variation-settings: "opsz" 10;
  font-size: var(--fs-cap);
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  /* carved into stone, same ink rules as the header's captions */
  color: var(--ink-2);
}

.closed-score {
  margin: 6px 0 0;
  font-family: var(--font-carved);
  font-variation-settings: "opsz" 144;
  font-size: var(--fs-hero);
  line-height: 1;
  font-weight: 800;
  letter-spacing: -0.03em;
  font-variant-numeric: lining-nums tabular-nums;
  color: var(--ink);
  /* the same chisel as the header's figures, at four times the size */
  text-shadow:
    0 2px 0 rgb(var(--c-light) / 0.95),
    0 -1px 1px rgb(var(--c-umber) / 0.45),
    0 -3px 2px rgb(var(--c-umber) / 0.14);
}

/* the rating is earned, so it is gilded, not painted in the action colour */
.closed-rating {
  margin: 4px 0 0;
  font-family: var(--font-carved);
  font-variation-settings: "opsz" 12;
  font-size: var(--fs-label);
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold-ink);
}

.closed-run {
  margin: 6px 0 0;
  font-family: var(--font-carved);
  font-variation-settings: "opsz" 9;
  font-size: var(--fs-micro);
  font-weight: 700;
  letter-spacing: var(--track-caps);
  text-transform: uppercase;
  color: var(--ink-3);
}

.closed-run:empty { display: none; }

/* the run, by rarity: four rows, one per tier, always all four. The number that
   matters is the total at the top; these say what made it, and a run with no rare word
   says so in place instead of staying silent about it */
.closed-tiers {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  width: 100%;
  flex: 0 0 auto;
  text-align: left;
  /* a hairline above the table, so it reads as a ledger cut into the slab */
  border-top: 1px solid rgb(var(--c-umber) / 0.28);
  box-shadow: inset 0 3px 5px -4px rgb(var(--c-umber) / 0.45);
}

.closed-tiers li {
  display: grid;
  /* tier · how many · how much: the two right-hand columns line up down the rows */
  grid-template-columns: 1fr auto 3.2em;
  align-items: center;
  gap: 12px;
  padding: 7px 2px;
  border-bottom: 1px solid rgb(var(--c-umber) / 0.16);
}

/* the tier is the colour of the row, the same four colours the wall uses */
.closed-tiers li b {
  font-family: var(--font-carved);
  font-variation-settings: "opsz" 10;
  font-size: var(--fs-cap);
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--tier-common);
}

.closed-tiers li[data-tier="familiar"] b { color: var(--tier-familiar); }
.closed-tiers li[data-tier="uncommon"] b { color: var(--tier-uncommon); }
.closed-tiers li[data-tier="rare"] b { color: var(--tier-rare); }

.closed-tiers .ft-count {
  font-family: var(--font-carved);
  font-style: italic;
  font-size: var(--fs-label);
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ink-2);
  white-space: nowrap;
}

.closed-tiers .ft-points {
  font-family: var(--font-carved);
  font-size: 14px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--ink);
}

/* a tier that paid nothing is still a row, but it is not a claim: the label loses its
   colour and the two figures go quiet, so the eye counts the rows you earned */
.closed-tiers li[data-empty] b,
.closed-tiers li[data-empty] .ft-count,
.closed-tiers li[data-empty] .ft-points { color: var(--ink-3); }

.closed-tiers li[data-empty] .ft-points { font-weight: 700; }

.closed-actions {
  flex: 0 0 auto;
  width: 100%;
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.closed .btn {
  width: 100%;
  min-height: 44px;
  padding: 0 20px;
  font-size: var(--fs-label);
}

.closed .btn-submit {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 3px 0 var(--accent-foot), 0 8px 18px rgb(var(--c-accent) / 0.22);
}

/* one primary, the rest quiet: a board you can retry and a daily you can go back to
   should not shout over "play again" */
.closed .btn-small {
  min-height: 38px;
  font-size: var(--fs-cap);
  letter-spacing: var(--track-caps);
  background: rgb(var(--c-light) / 0.55);
  color: var(--bronze);
  border: 1px solid rgb(var(--c-umber) / 0.34);
  box-shadow: inset 0 1px 0 rgb(var(--c-light) / 0.7), 0 1px 0 rgb(var(--c-umber) / 0.18);
}

.closed .btn-small:hover {
  background: var(--light);
  border-color: rgb(var(--c-umber) / 0.5);
  color: var(--bronze-deep);
}

.closed .btn-small[hidden] { display: none; }

/* the last word: you ran out of moves holding a word, so the lid offers it once. Not a
   second primary — two red buttons side by side say nothing — so it is an offer: the
   accent as an outline, and the accent as the word itself */
.closed .closed-last {
  min-height: 44px;
  padding: 0 20px;
  font-size: var(--fs-label);
  background: rgb(var(--c-light) / 0.6);
  border: 1px solid var(--accent);
  color: var(--accent-deep);
  box-shadow: inset 0 1px 0 rgb(var(--c-light) / 0.8);
}

.closed .closed-last:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 3px 0 var(--accent-foot);
}

.closed .closed-last[hidden] { display: none; }

/* ---------- Scoring ghosts ---------- */

.score-layer {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

.score-ghost {
  position: absolute;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 8px;
}

/* the ghost of a scored letter rises off the card it was on, so it is that card */
.score-glyph {
  display: grid;
  place-items: center;
  width: min(100%, var(--card-max));
  aspect-ratio: 1;
  border-radius: var(--card-radius);
  border: 1px solid var(--tile-line);
  background: var(--card-fill);
  color: var(--ink);
  font-weight: 700;
  font-size: clamp(17px, calc(50vw / var(--slots, 6)), 32px);
  line-height: 1;
  text-transform: uppercase;
  box-shadow: 0 1px 2px rgb(var(--c-felt-shade) / 0.3), 0 0 0 2px var(--gold-hi);
}

.drag-ghost[data-state="send"] .dg-hint { background: var(--accent); }
.drag-ghost[data-state="send"] .dg-tile { border-color: var(--accent); }

body.is-panning { cursor: grabbing; user-select: none; }
body.is-panning * { cursor: grabbing !important; }

body.dragging-letter { cursor: grabbing; }
body.dragging-letter .rack .slot-letter { cursor: grabbing; }

.slot.is-dragging { opacity: 0.3; }

/* floating copy of the dragged letter */
.drag-ghost {
  position: fixed;
  top: 0;
  left: 0;
  /* fixed width: the hint pill changes text while dragging (swap / move /
     cancel / drop to trash), and a shrink-to-fit box would shift the tile
     sideways under the cursor every time the label changed */
  width: 104px;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  pointer-events: none;
  will-change: transform;
}

.dg-tile {
  position: relative;
  display: grid;
  place-items: center;
  width: 46px;
  aspect-ratio: 1;
  border-radius: var(--card-radius);
  border: 1px solid var(--tile-line);
  background: var(--card-fill);
  color: var(--ink);
  font-size: 25px;
  font-weight: 700;
  line-height: 1;
  box-shadow: var(--card-shadow), var(--shadow-md);
  transition: background var(--m-instant) var(--e-out), color var(--m-instant) var(--e-out), transform var(--m-instant) var(--e-spring), border-color var(--m-instant) var(--e-out);
}

/* a dragged word is wider than a single tile */
.drag-ghost.is-word { width: auto; min-width: 104px; }

.dg-word {
  width: auto;
  min-width: 46px;
  padding: 0 10px;
  font-size: 17px;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.dg-tile b {
  position: absolute;
  right: 5px;
  bottom: 3px;
  font-size: var(--fs-micro);
  font-weight: 600;
  color: var(--ink-3);
}

.dg-hint {
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--light);
  font-size: var(--fs-micro);
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  white-space: nowrap;
  transition: background var(--m-instant) var(--e-out), color var(--m-instant) var(--e-out);
}

.drag-ghost[data-state="swap"] .dg-hint { background: var(--gold); }
.drag-ghost[data-state="move"] .dg-hint { background: var(--ink-2); }
.drag-ghost[data-state="cancel"] .dg-tile { opacity: 0.7; }
.drag-ghost[data-state="cancel"] .dg-hint { background: var(--ink-3); }

.drag-ghost[data-state="trash"] .dg-tile {
  color: var(--accent-ink);
  background: var(--accent-deep);
  border-color: var(--accent-foot);
  transform: scale(0.9) rotate(-7deg);
}

.drag-ghost[data-state="trash"] .dg-tile b { color: rgb(var(--c-light) / 0.7); }
.drag-ghost[data-state="trash"] .dg-hint { background: var(--accent-deep); }

/* ---------- Interaction juice ---------- */

/* ---------- Responsive ---------- */

@media (max-width: 560px) {
  /* the header is the top of the screen on a phone too: only the sides and the foot
     get padding, and the app takes the height back */
  body { padding: 0 12px 16px; }

  .brand { font-size: 23px; }
  /* the word block stacks on a phone: letters above, maths under them */
  /* the plate stays one row even on a phone: it is the smallest band in the tray,
     and a stacked plate is taller than the blanks it sits under */
  .wordcard {
    gap: 8px;
    padding: 4px 8px;
  }

  .wc-word { flex-wrap: nowrap; overflow: hidden; }
  .wc-status { font-size: var(--fs-micro); }
  .wc-points { justify-content: space-between; }
  .wc-math { justify-content: flex-start; }
  .wc-total { font-size: 19px; min-width: 0; }

  /* the header keeps the column's width on a phone too: it caps the column the way
     the shelf does at its foot, instead of bleeding past it — one edge rule everywhere */
  .hud { gap: 8px; }
  .hud-stats { column-gap: 13px; }
  .stat-value { font-size: 19px; }
  /* a two-line lockup is narrow, so it can carry a bigger type size on a phone
     than the old one-line wordmark did */
  .brand { font-size: 24px; }
}

/* ---------- Buttons + action key ----------
   Restored: the interrupted refactor dropped these, which left every button
   rendering as a raw browser control. */

.btn {
  font-family: inherit;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--ink);
  color: var(--light);
  cursor: pointer;
  transition: transform var(--m-fast) var(--e-spring), background var(--m-fast) var(--e-out),
    color var(--m-fast) var(--e-out), opacity var(--m-fast) var(--e-out);
}

.btn:active { transform: translateY(1px); }

.btn[disabled] { opacity: 0.35; cursor: not-allowed; }

.btn-small {
  font-size: var(--fs-cap);
  padding: 9px 14px;
  background: var(--tile);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  box-shadow: none;
}

.btn-small:hover { border-color: var(--ink); }

/* the column is narrow whenever the screen is short: the header has to fit in
   one line there, or it eats the space the board needs */
/* the plate only stacks when it really has to: a stacked plate is ~23px taller,
   and on a short screen those 23px are a whole row of wall */
/* A short screen fits the column to the wall, which can leave it narrow enough that
   the wordmark and the stats fight. The score and the moves matter; the logo does not,
   so below 290 px it goes and the numbers close up (last rule in this block). Above
   that it shrinks and keeps its place: the lockup scales down, the stats lose their
   pinch, nothing wraps. */
@container app (max-width: 460px) {
  .hud-stats { column-gap: 13px; }
}

@container app (max-width: 380px) {
  /* a narrow column shrinks the instrument, it does not empty it: the lockup scales
     down, the plaque loses its padding, nothing wraps and nothing is hidden */
  .hud {
    gap: 8px;
    /* the content still clears fillet + echinus (5 + 9), or the labels sit under the
       moulding */
    padding: calc(19px + env(safe-area-inset-top)) 12px 7px;
  }
  .brand { padding-left: 2px; font-size: 19px; }
  .brand-word { font-size: 10px; }
  .hud-stats { column-gap: 12px; }
  .hud-rule { height: 26px; }
  .stat-label { letter-spacing: 0.11em; }
  .stat-value { font-size: 19px; }
  .hud-volute { width: 28px; height: 28px; }
  .menu-wrap { width: 40px; height: 40px; margin-right: -4px; }
}

/* The header needs 273 px for the five-card mark, the plaque and the menu at the 19 px
   size (measured: 84.4 + 134.9 + 30 + 3 × 8 gap). The fifth card made the wordmark
   17 px wider than the four-card one it replaced, which is what pushed a 1280×720
   window (275 px column) 10 px over and a 1024×700 one (262 px) 16 px over. When the
   column is that narrow the mark is the thing that goes, per the comment above.
   Measured overflow after this rule: 0 at both. */
@container app (max-width: 290px) {
  .brand { display: none; }
}

@container app (max-width: 400px) {
  .wordcard { flex-wrap: wrap; gap: 4px 8px; }
  .wc-math { gap: 3px; }
}

/* this block used to do device work with a CONTAINER query, and the column is never
   wider than ~406 px — so every rule in it applied to every screen. The worst of them
   shrank the menu button to 26 px on a desktop that had room for 30. Labels still
   need their line kept, so that one moved into the base rule. */

/* respect the system switch everywhere, including the JS-driven animations
   (they check the same query before they run) */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- the fuse ----------
   Every blank carries its own trace: a channel cut round the card, with a gold run in
   it whose LENGTH is the time left and a burning head at its end. The ring is the only
   wall clock in the game, so it is drawn as part of the blank's own card instead of
   taking a band of its own. Sealed = the blank was won (the ×3 is banked on the letter);
   ash = the trace closed before a letter landed there, and the blank still works. */
.fuse {
  position: absolute;
  left: -4px;
  top: -4px;
  width: calc(100% + 8px);
  aspect-ratio: 1;
  pointer-events: none;
}

.fuse svg { display: block; width: 100%; height: 100%; overflow: visible; }

/* the channel is cut into the rack floor, so the gold has somewhere to sit */
.fuse-groove {
  fill: none;
  stroke: rgb(var(--c-umber-deep) / 0.3);
  stroke-width: 4;
  vector-effect: non-scaling-stroke;
}

.fuse-trace {
  fill: none;
  stroke: #c9931b;
  stroke-width: 2.4;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 0 2px rgb(var(--c-gold) / 0.8));
}

.fuse-head {
  position: absolute;
  width: 6px;
  height: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 34%, #fff7e0 0%, #ffc76a 60%, #e8a63a 100%);
  box-shadow: 0 0 8px rgb(var(--c-gold) / 0.95);
}

/* sealed: a letter made it. The rim closes and stops counting. */
.fuse[data-sealed="1"] .fuse-trace {
  stroke: #b8862a;
  stroke-width: 2.6;
  filter: drop-shadow(0 0 3px rgb(var(--c-gold) / 0.55));
}

.fuse[data-sealed="1"] .fuse-head { display: none; }

/* ash: the trace closed first. Nothing is drawn but the empty channel. */
.fuse[data-dead="1"] .fuse-trace,
.fuse[data-dead="1"] .fuse-head { display: none; }

.fuse[data-dead="1"] .fuse-groove {
  stroke: rgb(var(--c-umber-deep) / 0.2);
  stroke-dasharray: 1.5 2.5;
}

/* the receipt: a letter that was banked carries its multiplier on the card */
.fuse-x3 {
  position: absolute;
  right: -4px;
  bottom: -4px;
  padding: 0 2px;
  border: 1px solid #c08c2a;
  border-radius: 3px;
  font-size: 7px;
  font-weight: 800;
  line-height: 1.5;
  letter-spacing: 0.02em;
  color: #4a3208;
  background: linear-gradient(180deg, #ffe9b4, #e8c169);
  box-shadow: 0 1px 2px rgb(var(--c-umber-deep) / 0.3);
}


/* the trace is information, the ember is decoration */
@media (prefers-reduced-motion: reduce) {
  .fuse-head { display: none; }
}
