/* ============================================================
   Scrabble — design tokens, board, rack, panels.

   No external fonts, no frameworks, no build step. Vanilla CSS only.
   Everything is driven by the tokens at the top: the light and the
   dark theme are the same layout with a different set of values.
   ============================================================ */

:root {
  /* Surfaces. Bright and cool: near-white paper, cool grey cards. */
  --bg:           #f3f5f9;
  --surface:      #ffffff;
  --surface-2:   #e7ecf3;
  --ink:          #12161d;
  /* Secondary text. Dark enough to clear WCAG AA (4.5:1) on every
     surface it lands on: the page, the cards, and the player cards,
     which are tinted with the player colours. */
  --muted:        #59616f;

  /* Tiles. Still warm — a Scrabble tile is cream — but clean, so they
     lift off the cool board instead of blending into it. */
  --tile:         #fbf6ec;
  --tile-hi:      #fffdf8;
  --tile-border:  #d7cdb8;
  --tile-ink:     #171a20;

  /* Accent. The fill colour: white sits on it well above 4.5:1. */
  --accent:       #1c6e51;
  --accent-ink:   #ffffff;
  /* The accent as TEXT, which has to be darker than the fill to clear
     AA on a light background. */
  --accent-text:  #14513c;
  --ok-text:      #14513c;
  --err-text:    #a3271b;

  /* Premium squares (light mode) — the board's colour-coded multipliers */
  --premium-tl:   #2f6fb5;   /* triple letter  — deep blue   */
  --premium-dl:   #bcd8f2;   /* double letter  — pale blue   */
  --premium-tw:   #d23a35;   /* triple word   — red         */
  --premium-dw:   #f7bdb5;   /* double word   — pink        */
  --centre:       #f6c445;   /* centre square — gold star   */
  --danger:       #a3271b;

  /* Ink for the multiplier labels, one per square so contrast holds */
  --ink-tl:       #ffffff;
  --ink-dl:       #0f3459;
  --ink-tw:       #ffffff;
  --ink-dw:       #6b1712;
  --ink-centre:   #513700;

  /* Board surface — white squares, and the hairline grid they sit in */
  --board-frame:  #dde3ec;
  --board-felt:   #ffffff;
  /* The ring that marks the square a tile would land on. It sits on the
     felt, so it has to be dark to be seen against it, and it is a hue
     no premium square uses. */
  --drop-ring:    #0d2a1f;
  /* The warm tint that marks the squares a word runs through. */
  --word-tint:    #ffd978;

  /* Player identity colours */
  --p1:           #e0762f;
  --p2:           #2f6fb5;

  /* Shadows. Cool, never pure black: a hairline for the edge, and a
     soft lift for the object. */
  --shadow-card:  0 1px 2px rgba(15, 23, 42, 0.05),
                  0 10px 30px -18px rgba(15, 23, 42, 0.35);
  --shadow-board: 0 2px 4px rgba(15, 23, 42, 0.07),
                  0 26px 50px -26px rgba(15, 23, 42, 0.45);
  --shadow-tile:  0 1px 1px rgba(15, 23, 42, 0.10),
                  0 5px 12px -5px rgba(15, 23, 42, 0.45);

  /* Geometry */
  --radius:       10px;
  --gap:          4px;
  --tile-size:    clamp(44px, 10vw, 52px);
  --rack-h:       104px;
  --tile-font:    ui-serif, Georgia, "Times New Roman", serif;
  --ui-font:      system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* ------------------------------------------------------------
   Dark theme — the same board, lit from the other side.
   ------------------------------------------------------------ */
@media (prefers-color-scheme: dark) {
  :root {
    --bg:           #0d1015;
    --surface:      #161b23;
    --surface-2:    #212832;
    --ink:          #f1f4f9;
    --muted:        #a2adbd;
    --tile:         #f4ecdd;
    --tile-hi:      #fdf8ee;
    --tile-border:  #b8ac93;
    --tile-ink:     #14171c;
    --accent:       #37a37a;
    --accent-ink:   #05140e;
    --accent-text:  #7fd2ae;
    --ok-text:      #7fd2ae;
    --err-text:      #f3a79c;
    --premium-tl:   #3d84cc;
    --premium-dl:   #2b5c8c;
    --premium-tw:   #c4433d;
    --premium-dw:   #8c443c;
    --centre:       #c79a2c;
    --ink-tl:       #ffffff;
    --ink-dl:       #eaf3ff;
    --ink-tw:       #ffffff;
    --ink-dw:       #ffe9e4;
    --ink-centre:   #1d1607;
    --board-frame:  #222b36;
    --board-felt:   #2b323d;
    --drop-ring:    #d8f0e0;
    --word-tint:    #d8a92f;
    --danger:       #d4614f;
    --shadow-card:  0 1px 2px rgba(0, 0, 0, 0.4),
                    0 12px 32px -18px rgba(0, 0, 0, 0.8);
    --shadow-board: 0 2px 4px rgba(0, 0, 0, 0.4),
                    0 30px 60px -26px rgba(0, 0, 0, 0.9);
    --shadow-tile:  0 1px 1px rgba(0, 0, 0, 0.45),
                    0 6px 14px -6px rgba(0, 0, 0, 0.8);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background:
    radial-gradient(120% 70% at 50% -10%,
                    color-mix(in srgb, var(--surface) 88%, transparent) 0%,
                    transparent 62%),
    var(--bg);
  color: var(--ink);
  font-family: var(--ui-font);
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

button {
  font: inherit;
  color: inherit;
}

/* A focus ring that is always visible, on everything focusable. The
   :focus-visible ring is the strong one; a pointer focus still leaves a
   quiet outline, so the focus is never invisible. */
:focus {
  outline: 3px solid var(--accent-text);
  outline-offset: 2px;
}
:focus:not(:focus-visible) {
  outline-color: color-mix(in srgb, var(--accent-text) 55%, var(--bg));
}
:focus-visible {
  outline: 3px solid var(--accent-text);
  outline-offset: 2px;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  min-height: 44px;
  min-width: 44px;
  padding: 0 0.9rem;
  border-radius: var(--radius);
  border: 1px solid var(--tile-border);
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  transition: background 120ms ease, transform 120ms ease;
}
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.btn.primary:hover:not(:disabled) {
  background: color-mix(in srgb, var(--accent) 88%, black);
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn.ghost { background: var(--surface); }

/* The three bars of the menu button. The positions are written the long
   way round, layer by layer: a shorthand with the position in the same
   declaration is easy to get wrong, and one bad layer drops the lot. */
.bars {
  display: inline-block;
  width: 16px;
  height: 10px;
  background-image:
    linear-gradient(currentColor, currentColor),
    linear-gradient(currentColor, currentColor),
    linear-gradient(currentColor, currentColor);
  background-position: left top, left center, left bottom;
  background-size: 100% 2px;
  background-repeat: no-repeat;
}

/* ============================================================
   Landing page
   ============================================================ */
.centered {
  max-width: 34rem;
  margin: 0 auto;
  padding: clamp(2rem, 8vw, 5rem) 1.25rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}
.display {
  margin: 0;
  font-family: var(--tile-font);
  font-size: clamp(2.4rem, 9vw, 3.4rem);
  line-height: 1.05;
}
.lede {
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
}
.new-game {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 1.1rem;
  border-radius: var(--radius);
  border: 1px solid var(--tile-border);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}
.new-game button.primary {
  min-height: 46px;
  padding: 0 1.1rem;
  border-radius: var(--radius);
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  cursor: pointer;
}
.new-game button.primary:hover { background: color-mix(in srgb, var(--accent) 88%, black); }
.bot-label { font-weight: 600; }
.bot-row { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.bot-row select {
  flex: 1 1 12rem;
  min-height: 46px;
  padding: 0 0.6rem;
  border-radius: var(--radius);
  border: 1px solid var(--tile-border);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}
.recent h2 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.recent ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 0.5rem; flex-wrap: wrap; }
.recent a {
  display: inline-block;
  padding: 0.4rem 0.7rem;
  border-radius: var(--radius);
  border: 1px solid var(--tile-border);
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  letter-spacing: 0.05em;
}
.recent .empty { color: var(--muted); margin: 0; }
.footer { color: var(--muted); font-size: 0.9rem; }
.footer p { margin: 0; }
/* The tag that says the opponent is a bot rather than a person. */
.bot-tag {
  display: inline-block;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  vertical-align: 0.12em;
}

/* ============================================================
   Game page
   ============================================================ */
.game {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: clamp(0.6rem, 2vw, 1.25rem);
  /* Leave room for the rack, which is pinned to the foot of the
     screen on a phone. */
  padding-bottom: calc(clamp(0.6rem, 2vw, 1.25rem) + var(--rack-h)
                       + env(safe-area-inset-bottom));
  max-width: 64rem;
  margin: 0 auto;
  min-width: 0;
  /* While a finger drags a tile the board grows past the edge of a
     phone screen. Clipping the page sideways keeps everything else
     where it was, instead of letting the page widen under the
     finger. */
  overflow-x: clip;
}

/* ------------------------------------------------------------
   Top bar — the brand, the two players, whose turn it is, the code
   ------------------------------------------------------------
   One row on a wide screen, two on a phone. Nothing here is allowed
   to grow: the bar sits above the board, and every pixel it takes is
   a pixel the board does not.
   ------------------------------------------------------------ */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.9rem;
  padding: 0.45rem 0.7rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--tile-border);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex: 0 0 auto;
}
/* The mark is a tile, because that is what this is. */
.brand .mark {
  width: 26px;
  height: 26px;
  border-radius: 5px;
  border: 1px solid var(--tile-border);
  background: linear-gradient(160deg, var(--tile-hi),
              color-mix(in srgb, var(--tile) 88%, var(--tile-border)));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55), 0 1px 2px rgba(0, 0, 0, 0.2);
  color: var(--tile-ink);
  font-family: var(--tile-font);
  font-weight: 700;
  font-size: 1.05rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.brand .wordmark {
  font-family: var(--tile-font);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--ink);
  white-space: nowrap;
}

.game-code {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  margin: 0;
  min-width: 0;
}
.game-code .label {
  color: var(--muted);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.game-code .code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  user-select: all;
  -webkit-user-select: all;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: 0 0 auto;
  margin-left: auto;
}
.topbar-actions .btn { font-size: 0.85rem; padding: 0 0.6rem; }

.scores {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: 1 1 auto;
  min-width: 0;
}

.player-card {
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--tile-border);
  background: var(--surface-2);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
  transition: box-shadow 160ms ease;
}
/* Each card wears its own colour, and carries it in --seat so the
   glows, the ring and the pulse all know whose card they are. */
.player-card.p1 { --seat: var(--p1); border-left: 3px solid var(--p1); }
.player-card.p2 { --seat: var(--p2); border-left: 3px solid var(--p2); }
.player-card {
  box-shadow: 0 10px 26px -18px color-mix(in srgb, var(--seat) 85%, transparent);
}

/* The player on turn breathes, in their own colour. */
@keyframes turn-breathe {
  0%, 100% {
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--seat) 40%, transparent),
                0 12px 28px -18px color-mix(in srgb, var(--seat) 90%, transparent);
  }
  50% {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--seat) 62%, transparent),
                0 14px 32px -16px color-mix(in srgb, var(--seat) 90%, transparent);
  }
}
.player-card.turn {
  animation: turn-breathe 2.8s ease-in-out infinite;
  background: color-mix(in srgb, var(--seat) 9%, var(--surface-2));
}

/* The word that just landed lifts its player's card. */
@keyframes card-land {
  0%   { transform: scale(1); }
  28%  { transform: scale(1.05); }
  100% { transform: scale(1); }
}
.player-card.landed {
  animation: card-land 620ms cubic-bezier(0.22, 1.18, 0.36, 1);
}
/* Both at once: the card breathes in its colour while it lifts. */
.player-card.turn.landed {
  animation: turn-breathe 2.8s ease-in-out infinite,
             card-land 620ms cubic-bezier(0.22, 1.18, 0.36, 1);
}
.player-card .name {
  font-weight: 600;
  font-size: 0.88rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.player-card .name small { color: var(--muted); font-weight: 500; }
.player-card .emoji { font-size: 1rem; line-height: 1; }
.player-card .rack-count {
  font-size: 0.72rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.player-card .score {
  font-family: var(--ui-font);
  font-size: 1.25rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
}

.turn-line {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  flex: 0 0 auto;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: var(--surface-2);
}
.turn-line strong { color: var(--ink); }
.turn-line .move-count { flex: 0 0 auto; font-size: 0.78rem; }

/* On a phone the bar has to fit on one row: the label of the code and
   the word on the menu button go, and the code and the icon say it
   all. */
@media (max-width: 899px) {
  .game-code .label { display: none; }
  .icon-only .label { display: none; }
  .wide-only { display: none; }
  /* Three short rows instead of four: the brand and the code and the
     buttons, then the players, then whose turn it is. */
  .brand { order: 1; }
  .topbar-actions { order: 2; }
  .scores { order: 3; }
  .turn-line { order: 4; }

  /* The brand keeps its name on a phone. It is the one thing on the
     page that says what this is, and there is room for it now that
     the two player cards share the row below. */
  .brand { gap: 0.4rem; }
  .brand .mark { width: 30px; height: 30px; font-size: 1.15rem; }
  .brand .wordmark { font-size: 0.95rem; letter-spacing: 0.05em; }

  /* The two player cards take the whole width, one half each, so they
     sit square under the bar instead of huddling at the left. */
  .scores { width: 100%; gap: 0.4rem; }
  .scores .player-card { flex: 1 1 0; min-width: 0; }

  /* The turn panel reads as one block: the note and the buttons are
     both centred, and the buttons sit together rather than spreading
     to the edges. */
  .turn-panel { flex-direction: column; align-items: center; }
  .playbar-main { align-items: center; text-align: center; }
  .playbar-actions { justify-content: center; flex-wrap: wrap; }
}

/* ------------------------------------------------------------
   Board
   ------------------------------------------------------------ */
.board-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  /* The banner over the board is placed against this. */
  position: relative;
}

.board {
  display: grid;
  grid-template-columns: repeat(15, 1fr);
  grid-template-rows: repeat(15, 1fr);
  gap: clamp(1px, 0.55cqw, var(--gap));
  aspect-ratio: 1;
  /* The board fits the smaller of: 720px wide, the width of the page,
     or the height of the window less everything stacked around it. The
     floor keeps the squares legible when the window is short — below it
     the page scrolls instead of crushing the board. */
  width: min(100%, 720px, max(300px, calc(100vh - 340px)));
  height: auto;
  background-color: var(--board-frame);
  background-image: linear-gradient(150deg,
      color-mix(in srgb, var(--board-frame) 82%, #ffffff 18%),
      var(--board-frame) 45%,
      color-mix(in srgb, var(--board-frame) 78%, #000000 22%));
  padding: clamp(4px, 1.4cqw, 11px);
  border-radius: 12px;
  box-shadow:
    var(--shadow-board),
    inset 0 0 0 1px rgba(15, 23, 42, 0.08);
  user-select: none;
  -webkit-user-select: none;
  contain: strict;
  /* Query container so the cell typography scales with the board's own
     width rather than the viewport. */
  container-type: inline-size;
  /* While a finger drags a tile the board grows around it; the origin
     is the top left so the squares keep their place in the layout
     while they are drawn larger. */
  transform-origin: 0 0;
}
/* The change of size is a movement rather than a jump. It is only
   eased while the board grows or settles: while the finger moves, the
   board has to keep up with it exactly. */
.board.zooming { transition: transform 200ms ease-out; }

.cell {
  position: relative;
  background: var(--board-felt);
  color: var(--tile-ink);
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--tile-font);
  font-weight: 700;
  font-size: clamp(12px, 5.5cqw, 38px);
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  cursor: pointer;
  transition: filter 90ms ease;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.05);
}
.cell:hover { filter: brightness(1.06); }

/* The multiplier is printed on the board, in the corner, so it stays
   readable under a tile that has been laid on it. */
.cell-badge {
  position: absolute;
  top: 1px;
  left: 2px;
  font-family: var(--ui-font);
  font-size: clamp(5px, 1.9cqw, 11px);
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1;
  pointer-events: none;
}

/* The colour-coded multiplier squares. */
.cell.tw    { background: var(--premium-tw); color: var(--ink-tw); }
.cell.dw    { background: var(--premium-dw); color: var(--ink-dw); }
.cell.tl    { background: var(--premium-tl); color: var(--ink-tl); }
.cell.dl    { background: var(--premium-dl); color: var(--ink-dl); }
.cell.centre {
  background: var(--centre);
  color: var(--ink-centre);
}
.cell.centre .cell-badge { font-size: clamp(8px, 3cqw, 17px); }

/* A tile that has been played. */
.cell.filled {
  background: var(--tile);
  color: var(--tile-ink);
  box-shadow:
    inset 0 0 0 1px rgba(15, 23, 42, 0.10),
    var(--shadow-tile);
}
/* Under a played tile the multiplier is a footnote, so it shrinks into
   the corner instead of sitting on the letter. */
.cell.filled .cell-badge {
  top: 0;
  left: 1px;
  font-size: clamp(4px, 1.3cqw, 8px);
}
.cell.centre.filled .cell-badge { font-size: clamp(5px, 1.8cqw, 11px); }

/* The letter, with its point value tucked into the corner of the tile.
   A sans-serif at this size sits squarely in the square; the serif face
   it replaced had wide, uneven shoulders that crowded the cell. */
.cell-face {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--ui-font);
  font-size: 0.86em;
  transform: translate(-7%, -9%);
}
.cell-val {
  position: absolute;
  right: 2px;
  bottom: 0;
  font-family: var(--ui-font);
  font-size: clamp(6px, 1.8cqw, 12px);
  font-weight: 600;
  color: var(--tile-ink);
  opacity: 0.72;
  letter-spacing: 0;
  line-height: 1;
  pointer-events: none;
}

/* A tile this turn has put down but not yet played: the same tile, with
   a ring that says "not committed yet". */
.cell.preview-letter,
.cell.preview-blank {
  background: var(--tile);
  color: var(--tile-ink);
  box-shadow:
    inset 0 0 0 2px var(--accent-text),
    0 2px 6px rgba(0, 0, 0, 0.25);
}
.cell.preview-blank .cell-face { font-style: italic; color: var(--muted); }

/* The squares a word runs through, so the word being built is visible
   without counting letters. */
.cell.in-word:not(.preview-letter):not(.preview-blank) {
  background: color-mix(in srgb, var(--word-tint) 34%, var(--board-felt));
}

/* The word that was played last keeps the colour of the player who
   played it: a whisper of it on the tile, and a ring around the square.
   The tile is still a tile - the letter and its value are unchanged. */
.cell.played.p1 { --seat: var(--p1); }
.cell.played.p2 { --seat: var(--p2); }
.cell.filled.played {
  background: color-mix(in srgb, var(--seat) 14%, var(--tile));
  box-shadow:
    inset 0 0 0 2px color-mix(in srgb, var(--seat) 34%, transparent),
    var(--shadow-tile);
}

/* And it brightens as it lands, then settles into the tint. */
@keyframes word-land {
  0% {
    box-shadow:
      inset 0 0 0 3px color-mix(in srgb, var(--seat) 95%, transparent),
      0 0 22px -2px color-mix(in srgb, var(--seat) 85%, transparent);
  }
  100% {
    box-shadow:
      inset 0 0 0 2px color-mix(in srgb, var(--seat) 34%, transparent),
      var(--shadow-tile);
  }
}
.cell.played.just-played { animation: word-land 760ms cubic-bezier(0.22, 1, 0.36, 1); }

/* The square a tile would land on. */
.cell.aim {
  box-shadow: inset 0 0 0 3px var(--drop-ring);
  filter: brightness(1.12);
  z-index: 2;
}
.cell.aim .aim-face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--ui-font);
  font-weight: 700;
  font-size: 0.86em;
  color: var(--tile-ink);
  pointer-events: none;
}
.cell.filled .aim-face { display: none; }

/* The keyboard cursor. */
.cell.cursor {
  outline: 3px solid var(--accent-text);
  outline-offset: -3px;
  z-index: 3;
}

/* The opening move: the centre square is the square the first word has
   to cross. */
.cell.centre-target {
  box-shadow: inset 0 0 0 3px var(--centre);
  animation: centre-pulse 2s ease-in-out infinite;
}
@keyframes centre-pulse {
  0%, 100% { box-shadow: inset 0 0 0 3px var(--centre); }
  50%      { box-shadow: inset 0 0 0 3px var(--word-tint); }
}

/* A square that was refused flashes red, then settles. */
.cell.invalid-flash { animation: invalid-flash 0.7s ease-out; }
@keyframes invalid-flash {
  0%   { box-shadow: inset 0 0 0 3px var(--danger); }
  100% { box-shadow: inset 0 0 0 3px transparent; }
}

/* What is under the pointer, in words. */
.board-status {
  margin: 0;
  min-height: 1.2em;
  font-size: 0.82rem;
  color: var(--muted);
  text-align: center;
  /* Above the board, which grows over it while a finger drags; the
     page colour behind it keeps the words readable. */
  position: relative;
  z-index: 1;
  padding: 0 0.4rem;
  border-radius: 6px;
  background: var(--bg);
}
/* Nothing to say, nothing to draw. */
.board-status:empty { padding: 0; background: none; }
.board-status.err { color: var(--err-text); }

/* The tile that follows the pointer. */
.drag-ghost {
  position: fixed;
  z-index: 999;
  pointer-events: none;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--tile-hi);
  color: var(--tile-ink);
  border: 1px solid var(--tile-border);
  border-radius: 6px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
  font-family: var(--ui-font);
  font-weight: 700;
  font-size: 1.3rem;
  /* Parked up and to the left of the pointer, so it never covers the
     square being aimed at. */
  transform: translate(-115%, -115%) rotate(-4deg);
}
/* Under a finger the square being aimed at is drawn above the
   fingertip, so the tile itself waits beside the finger. */
.drag-ghost.touch { transform: translate(-165%, -50%) rotate(-4deg); }
body.dragging { cursor: grabbing; }
body.dragging .rack-tile { cursor: grabbing; }

/* ============================================================
   The play area — the rack, the board, and the turn
   ============================================================
   On a phone they stack: the board, the turn controls, and the rack
   pinned to the foot of the screen. On a wide screen they sit side by
   side — the rack on the left, the board in the middle, the turn on
   the right — so the whole game fits on one screen without scrolling.
   ============================================================ */
.play-area {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 0;
}

@media (min-width: 900px) {
  .game {
    max-width: 84rem;
    padding-bottom: clamp(0.75rem, 2vw, 1.5rem);
  }
  .play-area {
    display: grid;
    /* The board is the centre of the game, so it is the centre of the
       page: the rack sits to one side of it, and the turn and the
       moves stand in a column on the other - the turn on top, the
       moves beneath it. */
    grid-template-columns: 260px minmax(0, 700px) 300px;
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas:
      "rack board turn"
      "rack board history";
    justify-content: center;
    gap: 1rem;
    align-items: center;
  }
  .board-wrap { grid-area: board; }
  .turn-panel { grid-area: turn; }
  /* The moves stand directly under the turn panel, and grow with the
     game until they need scrolling. */
  .history-panel { grid-area: history; align-self: start; }
  .rack-panel { grid-area: rack; }
  /* The header is one row now, so the board can have the height it
     needs without the page ever needing to scroll. */
  .board { width: min(100%, 700px, max(300px, calc(100vh - 160px))); }
}

/* Between a phone and a big screen the side columns give a little of
   their width back to the board. */
@media (min-width: 900px) and (max-width: 1200px) {
  .play-area { grid-template-columns: 200px minmax(0, 700px) 250px; gap: 1rem; }
}

/* ============================================================
   Motion
   ------------------------------------------------------------
   The tiles have weight. A tile lands with a spring, a word that
   was just played arrives with a flourish, and the score counts
   itself up. Nothing here blocks the game: the moves are already
   in the page, this only shows how they arrived.
   ============================================================ */

@keyframes tile-land {
  0%   { transform: scale(1.18) translateY(-5%); }
  52%  { transform: scale(0.95) translateY(2%); }
  76%  { transform: scale(1.03); }
  100% { transform: scale(1); }
}

/* A tile that has just been put down. */
.cell.landed,
.cell.preview-letter.landed {
  animation: tile-land 420ms cubic-bezier(0.22, 1.18, 0.36, 1);
}

@keyframes rack-lift {
  0%   { transform: translateY(0) scale(1); }
  45%  { transform: translateY(-7px) scale(1.05); }
  100% { transform: translateY(0) scale(1); }
}
.rack-tile.selected { animation: rack-lift 300ms cubic-bezier(0.22, 1.18, 0.36, 1); }

@keyframes word-banner-in {
  0%   { opacity: 0; transform: translateX(-50%) translateY(16px) scale(0.9); }
  100% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

/* The word that was just played, over the board. */
.word-banner {
  position: absolute;
  left: 50%;
  top: 0.4rem;
  z-index: 5;
  display: inline-flex;
  align-items: baseline;
  gap: 0.55rem;
  padding: 0.4rem 0.95rem;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
  white-space: nowrap;
  box-shadow: var(--shadow-card);
  animation: word-banner-in 420ms cubic-bezier(0.22, 1.18, 0.36, 1);
}
.word-banner .pts { color: color-mix(in srgb, var(--bg) 70%, transparent); }
.word-banner[hidden] { display: none; }

/* ============================================================
   The turn being built
   ============================================================ */
.turn-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius);
  border: 1px solid var(--tile-border);
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.playbar-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.word-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.word-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--surface));
  font-size: 0.85rem;
}
.word-chip .word {
  font-family: var(--ui-font);
  font-weight: 700;
  letter-spacing: 0.08em;
}
.word-chip .points {
  color: var(--accent-text);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.playbar-note {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}
.playbar-note.err { color: var(--err-text); font-weight: 600; }
.playbar-note.ok { color: var(--ok-text); }

/* The Play button, when the turn in front of it is a legal one, wears a
   sheen that sweeps across it. It says "go" without saying go, and it
   stops as soon as the turn stops being legal.

   The sheen is a layer of the button's own background rather than a
   shape laid over it, so it passes behind the word and the label stays
   legible all the way across. */
.btn.primary.ready,
.btn.primary.ready:hover:not(:disabled) {
  background-image: linear-gradient(100deg,
      transparent 32%, rgba(255, 255, 255, 0.42) 50%, transparent 68%);
  background-size: 250% 100%;
  background-repeat: no-repeat;
  animation: play-sheen 1.9s ease-in-out infinite;
}
@keyframes play-sheen {
  0%   { background-position: 160% 0; }
  100% { background-position: -60% 0; }
}
.playbar-actions {
  display: flex;
  gap: 0.4rem;
  flex: 0 0 auto;
}

/* On a phone the turn controls have to stay on one row, so the buttons
   get tighter rather than the bar wrapping into a second line. */
@media (max-width: 899px) {
  .turn-panel { padding: 0.5rem 0.55rem; gap: 0.4rem; }
  .playbar-actions { gap: 0.3rem; }
  .playbar-actions .btn { padding: 0 0.6rem; font-size: 0.9rem; }
}

/* On a wide screen the turn panel is a column, and the buttons fill it. */
@media (min-width: 900px) {
  .turn-panel {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 0.7rem;
  }
  .playbar-actions .btn { flex: 1 1 0; }
}

/* A hint — the squares the suggestion would fill, and the tiles to
   fill them with. */
.cell.hinted {
  box-shadow: inset 0 0 0 3px var(--word-tint);
  animation: hint-pulse 1.4s ease-in-out infinite;
}
@keyframes hint-pulse {
  0%, 100% { box-shadow: inset 0 0 0 3px var(--word-tint); }
  50%      { box-shadow: inset 0 0 0 3px var(--centre); }
}
.rack-tile.hinted {
  outline: 3px solid var(--word-tint);
  outline-offset: 2px;
}

/* The result of a finished game, in the place the turn controls were. */
.turn-panel.result {
  animation: tile-land 460ms cubic-bezier(0.22, 1.18, 0.36, 1);
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}
.result-title {
  font-family: var(--ui-font);
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}
.final-scores {
  font-family: var(--ui-font);
  margin: 0.25rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.1rem;
  font-size: 0.88rem;
  color: var(--muted);
}
.final-scores b {
  color: var(--ink);
  font-family: var(--tile-font);
  font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   The rack
   ============================================================
   On a phone it is pinned to the foot of the screen, within reach of
   a thumb. On a wide screen it stands to the left of the board.
   ============================================================ */
.rack-panel {
  padding: 0.6rem 0.7rem;
  border-radius: var(--radius);
  border: 1px solid var(--tile-border);
  background: var(--surface);
  min-width: 0;
  /* Above the board, which grows over it while a finger drags. */
  position: relative;
  z-index: 1;
}
.rack-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}
.rack-panel h3 {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}
.rack-count {
  font-size: 0.78rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
/* The rack count and the bag count sit together at the end of the head. */
.rack-counts {
  display: inline-flex;
  align-items: baseline;
  gap: 0.6rem;
}
/* A pass is armed and waiting for the second tap. */
.btn.armed {
  border-color: var(--danger);
  color: var(--danger);
}

.rack-tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.rack-tile {
  width: var(--tile-size);
  height: var(--tile-size);
  padding: 0;
  border-radius: 6px;
  border: 1px solid var(--tile-border);
  background: linear-gradient(160deg, var(--tile-hi),
              color-mix(in srgb, var(--tile) 88%, var(--tile-border)));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.75),
    var(--shadow-tile);
  color: var(--tile-ink);
  font-family: var(--ui-font);
  font-weight: 700;
  font-size: calc(var(--tile-size) * 0.44);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: grab;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
.rack-tile:active { cursor: grabbing; }
.rack-tile.blank { color: var(--muted); }
.rack-tile-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transform: translate(-8%, -12%);
}
.rack-tile-label {
  position: absolute;
  bottom: 2px;
  right: 4px;
  pointer-events: none;
  font-family: var(--ui-font);
  font-size: calc(var(--tile-size) * 0.22);
  font-weight: 600;
  color: var(--tile-ink);
  opacity: 0.7;
  line-height: 1;
}
.rack-tile.used {
  opacity: 0.4;
  cursor: not-allowed;
}
.rack-tile.used::after {
  content: "";
  position: absolute;
  inset: 18%;
  background: linear-gradient(45deg, transparent 45%,
              var(--tile-ink) 45%, var(--tile-ink) 55%, transparent 55%);
  opacity: 0.55;
}
.rack-tile.selected {
  outline: 3px solid var(--accent-text);
  outline-offset: 2px;
}
.rack-tile input[type="checkbox"] {
  width: calc(var(--tile-size) * 0.4);
  height: calc(var(--tile-size) * 0.4);
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}
/* In the exchange list the checkbox takes the right side, so the point
   value moves to the left-hand corner. */
.rack-tile.has-check .rack-tile-label { right: auto; left: 4px; }

/* The rack is pinned to the foot of the screen, within reach of a
   thumb. */
.rack-panel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  padding: 0.5rem clamp(0.6rem, 2vw, 1.25rem);
  padding-bottom: calc(0.5rem + env(safe-area-inset-bottom));
  border-radius: var(--radius) var(--radius) 0 0;
  border: 1px solid var(--accent);
  border-bottom: 0;
  background: var(--surface);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.12);
}
.rack-panel .rack-tiles { justify-content: center; }
.rack-panel.p1 { border-color: var(--p1); }
.rack-panel.p2 { border-color: var(--p2); }

@media (min-width: 900px) {
  .rack-panel {
    position: static;
    border-radius: var(--radius);
    border: 1px solid var(--tile-border);
    background: var(--surface);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    padding: 0.6rem 0.7rem;
  }
  .rack-panel .rack-tiles { justify-content: flex-start; }
}

/* ============================================================
   Drawer — identity / exchange / pass
   ============================================================ */
.drawer-scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 20;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}
.drawer-scrim.open {
  opacity: 1;
  pointer-events: auto;
}

.drawer {
  position: fixed;
  z-index: 30;
  background: var(--bg);
  border: 1px solid var(--tile-border);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  overflow-y: auto;
  transition: transform 220ms ease;
  /* Mobile: bottom sheet, full width, most of the viewport. */
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 80vh;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 1rem 1rem max(env(safe-area-inset-bottom), 1rem);
}
.drawer:not(.open) { transform: translateY(100%); }
.drawer.open { transform: translate(0, 0); }

@media (min-width: 720px) {
  .drawer {
    top: 0;
    bottom: 0;
    left: auto;
    right: 0;
    width: min(360px, 90vw);
    max-height: none;
    border-radius: var(--radius) 0 0 var(--radius);
    padding: 1.25rem;
  }
  .drawer:not(.open) { transform: translateX(100%); }
}

.control-card {
  padding: 0.9rem;
  border-radius: var(--radius);
  border: 1px solid var(--tile-border);
  background: var(--surface);
}
.control-card h2 {
  margin: 0 0 0.5rem;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 0.6rem;
}
.field label {
  font-size: 0.82rem;
  color: var(--muted);
}
.field input[type="text"] {
  min-height: 44px;
  padding: 0 0.7rem;
  border-radius: var(--radius);
  border: 1px solid var(--tile-border);
  background: var(--bg);
  color: var(--ink);
  font-size: 1rem;
  width: 100%;
}
.message {
  min-height: 1.4em;
  margin: 0.5rem 0 0;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
}
.message.ok { background: color-mix(in srgb, var(--ok-text) 18%, var(--surface)); color: var(--ok-text); }
.message.err { background: color-mix(in srgb, var(--err-text) 18%, var(--surface)); color: var(--err-text); }

.identity {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: flex-end;
}
.identity .field { flex: 1 1 8rem; margin-bottom: 0; }

.emoji-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.emoji-picker button {
  font-size: 1.2rem;
  padding: 0;
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  border: 1px solid var(--tile-border);
  background: var(--bg);
  cursor: pointer;
}
.emoji-picker button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

/* The blank picker: the alphabet, in the same grid as the avatars. */
.emoji-picker.letters button {
  font-family: var(--tile-font);
  font-size: 1rem;
  font-weight: 600;
}
.join-veil[hidden] { display: none; }

.hint {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0.4rem 0 0;
}

/* The moves log — what has been played, and what it was worth. */
/* ------------------------------------------------------------
   The moves so far. A column under the turn on a wide screen, and
   a panel at the foot of the page on a phone - there, it stays
   closed until you want to read it.
   ------------------------------------------------------------ */
.history-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: min(46vh, 460px);
  padding: 0.55rem 0.7rem 0.2rem;
  border-radius: var(--radius);
  border: 1px solid var(--tile-border);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}
.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.history-head h2 {
  margin: 0;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.history-toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 44px;
  padding: 0 0.5rem;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}
.history-toggle .chevron {
  width: 0.5rem;
  height: 0.5rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translate(-2px, -2px);
  transition: transform 160ms ease;
}
.history-panel.open .history-toggle .chevron {
  transform: rotate(-135deg) translate(-2px, -2px);
}
.history-empty { margin: 0.2rem 0 0.5rem; }

.move-log {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
}
.move-log li {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  font-size: 0.85rem;
  padding: 0.3rem 0 0.3rem 0.45rem;
  border-bottom: 1px solid var(--surface-2);
  border-left: 3px solid transparent;
}
.move-log li:last-child { border-bottom: 0; }
.move-log li.p1 { border-left-color: var(--p1); }
.move-log li.p2 { border-left-color: var(--p2); }
.move-log .who { font-weight: 600; flex: 0 0 auto; }
.move-log .what {
  color: var(--muted);
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.move-log .pts {
  font-family: var(--tile-font);
  font-weight: 700;
  color: var(--accent-text);
  font-variant-numeric: tabular-nums;
}

/* On a phone the panel is closed to begin with: the moves are there
   for when you want them, not in the way of the board. */
@media (max-width: 899px) {
  .history-panel {
    max-height: none;
    padding: 0.35rem 0.6rem;
  }
  .history-panel:not(.open) .move-log,
  .history-panel:not(.open) .history-empty { display: none; }
  .history-panel.open .move-log { max-height: 55vh; }
  .history-toggle { flex: 1 1 auto; justify-content: flex-end; }
}

/* On a wide screen it is always open, and the button has nothing to
   say. */
@media (min-width: 900px) {
  .history-toggle { display: none; }
  .history-panel .move-log { max-height: none; }
}

/* ------------------------------------------------------------
   Join overlay — the name and avatar a visitor picks
   ------------------------------------------------------------ */
.join-veil {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(3px);
}
.join-card {
  width: min(28rem, 100%);
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.4rem;
  border-radius: var(--radius);
  border: 1px solid var(--tile-border);
  background: var(--surface);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.3);
}
.join-card h2 {
  margin: 0 0 0.35rem;
  font-size: 1.3rem;
}
.join-card .field { margin-top: 1rem; }
.join-card .field input[type="text"] {
  width: 100%;
  min-height: 44px;
  padding: 0 0.7rem;
  border-radius: var(--radius);
  border: 1px solid var(--tile-border);
  background: var(--bg);
  color: var(--ink);
  font-size: 1rem;
}
.join-card button.primary { width: 100%; min-height: 46px; }

/* ------------------------------------------------------------
   Share panel — the link the player sends to their opponent
   ------------------------------------------------------------ */
.share-row {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.6rem;
}
.share-link {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 44px;
  padding: 0 0.6rem;
  border-radius: var(--radius);
  border: 1px solid var(--tile-border);
  background: var(--bg);
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
}

/* Notice banner — invalid invite link, seat already taken, etc. */
.notice {
  margin: 0;
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius);
  border: 1px solid var(--err-text);
  background: var(--surface);
  color: var(--err-text);
  font-size: 0.9rem;
}

/* Seat switcher — shown when one browser holds both seats. */
.seat-switch {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.seat-switch a {
  display: inline-block;
  padding: 0.45rem 0.7rem;
  border-radius: var(--radius);
  border: 1px solid var(--tile-border);
  background: var(--bg);
  color: var(--ink);
  text-decoration: none;
  font-size: 0.85rem;
}
.seat-switch a.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

/* ------------------------------------------------------------
   Toast — the result of a play, exchange or pass
   ------------------------------------------------------------ */
.toast {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%);
  z-index: 40;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--tile-border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  font-weight: 600;
  max-width: min(90vw, 28rem);
  text-align: center;
}
.toast.ok {
  border-color: var(--accent-text);
  color: var(--accent-text);
  animation: toast-pop 260ms cubic-bezier(0.2, 1.4, 0.4, 1);
}
@keyframes toast-pop {
  from { transform: translateX(-50%) translateY(10px) scale(0.94); opacity: 0; }
  to   { transform: translateX(-50%) translateY(0) scale(1); opacity: 1; }
}
.toast.err { border-color: var(--err-text); color: var(--err-text); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  .cell.centre-target {
    animation: none;
    box-shadow: inset 0 0 0 3px var(--centre);
  }
}
