/* Quorble component library.
   Shared by components.html and screens.html; loaded after tokens.css and before theme-sketch.css.

   How it works: every component declares its own tokens at its root (--btn-*, --input-*, --word-* ...)
   and then reads only those. The defaults pull from tokens.css where a global token exists, so with no
   theme active this file reproduces the serious look exactly. A theme (see theme-sketch.css) re-declares
   the component tokens under html[data-theme="..."] and never touches tokens.css or the markup.
   Rules that cannot be a token (a selector, a state) stay here; a theme may add overrides for them.

   Order matters inside a component: state rules come after the rest, as they always did. */

/* ===================================================================================================
   Page chrome: fonts, background, headings, notes. Page-scope tokens live on body and the headings.
   =================================================================================================== */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  --page-bg: var(--color-bg);
  --page-bg-image: none;
  --page-bg-size: auto;
  --page-font: var(--font-sans);
  --page-text: var(--text-base);
  --page-leading: var(--leading-normal);
  --page-ink: var(--color-ink);
  --page-ink-2: var(--color-ink-2);  /* lead, notes, links, footer */
  margin: 0; padding: var(--space-5) var(--space-4) var(--space-8); font-family: var(--page-font);
  font-size: var(--page-text); background: var(--page-bg); background-image: var(--page-bg-image); background-size: var(--page-bg-size);
  color: var(--page-ink); line-height: var(--page-leading);
}
main { max-width: 720px; margin: 0 auto; }
h1, h2, h3 {
  --heading-font: var(--font-serif);
  --heading-weight: var(--weight-semibold);
  --heading-ink: inherit;
  --heading-bg: none;
  --heading-pad: 0;
  --heading-width: auto;
  --heading-transform: none;
  font-family: var(--heading-font); font-weight: var(--heading-weight); color: var(--heading-ink); margin: 0;
  background: var(--heading-bg); padding: var(--heading-pad); width: var(--heading-width); transform: var(--heading-transform);
}
h1 { --h1-text: var(--text-3xl); --h1-leading: var(--leading-tight); font-size: var(--h1-text); line-height: var(--h1-leading); }
h2 { --h2-text: var(--text-xl); font-size: var(--h2-text); margin-top: var(--space-8); margin-bottom: var(--space-2); }
h3 { --h3-text: var(--text-base); font-size: var(--h3-text); margin-bottom: var(--space-2); }
p { margin: var(--space-1) 0; }
.lead { color: var(--page-ink-2); margin-top: var(--space-1); }
.note { --note-text: var(--text-sm); color: var(--page-ink-2); font-size: var(--note-text); margin-bottom: var(--space-3); }
a { color: var(--page-ink-2); }
footer { --footer-text: var(--text-xs); margin-top: var(--space-8); color: var(--page-ink-2); font-size: var(--footer-text); }

/* ===================================================================================================
   Game components
   =================================================================================================== */

/* Word row. The matched word is the one emphasised element on a screen. */
.word {
  --word-gap: calc(var(--space-2) + var(--space-half));
  --word-bg: var(--color-surface);
  --word-border: var(--border) solid var(--color-line);
  --word-radius: var(--radius);
  --word-pad: var(--space-3) calc(var(--space-3) + var(--space-half));
  --word-text: var(--text-lg);
  --word-shadow: none;
  --word-match-font: var(--font-serif);
  --word-match-text: var(--text-2xl);
  --word-match-pad: calc(var(--space-3) + var(--space-half));
  --word-match-border: var(--border-strong) solid var(--color-coop);
  --word-match-bg: var(--word-bg);
  --word-fail-ink: var(--color-danger);
  --word-fail-text: var(--text-base);
  display: flex; align-items: center; gap: var(--word-gap);
  background: var(--word-bg); border: var(--word-border); border-radius: var(--word-radius); box-shadow: var(--word-shadow);
  padding: var(--word-pad); font-size: var(--word-text);
}
/* Up to 12 dots: they wrap onto a second line, right-aligned, rather than squeeze the word (half the row at most). */
.word .dots { margin-left: auto; display: flex; flex-wrap: wrap; justify-content: flex-end; max-width: 50%; gap: var(--space-1); }
.word.match { font-family: var(--word-match-font); font-size: var(--word-match-text); padding: var(--word-match-pad);
              border: var(--word-match-border); background: var(--word-match-bg); }
.word.fail { color: var(--word-fail-ink); border-color: var(--word-fail-ink); font-size: var(--word-fail-text); }
/* Spoiled!: the row for a spoiler that succeeded. Spoiler blue is text only (README), so the hairline stays grey; the word
   everyone else played sits under it as a plain row, not outlined, since nobody matched. */
.word.spoiled { --word-spoiled-ink: var(--color-spoiler); --word-spoiled-weight: var(--weight-semibold);
                color: var(--word-spoiled-ink); font-weight: var(--word-spoiled-weight); font-size: var(--word-fail-text); }

/* Player dot: a 10px circle on a word row, or a 52px lettered circle beside a name. */
.dot { width: var(--dot); height: var(--dot); border-radius: 50%; display: block; flex: none; background: var(--player-bg); }
.player { --player-text: var(--text-md); --player-letter-font: inherit; --player-letter-weight: var(--weight-bold); --player-ring: none;
          display: flex; align-items: center; gap: var(--space-2); font-size: var(--player-text); }
.player .dot-lg { position: relative; width: var(--dot-lg); height: var(--dot-lg); border-radius: 50%; display: grid; place-items: center; flex: none;
                  font-family: var(--player-letter-font); font-weight: var(--player-letter-weight); font-size: var(--text-xl);
                  background: var(--player-bg); color: var(--player-ink); box-shadow: var(--player-ring); }
.player small { display: block; color: var(--color-ink-2); font-size: var(--text-xs); line-height: var(--leading-snug); }
.players { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-3) var(--space-2); }
@media (min-width: 560px) { .players { grid-template-columns: repeat(4, 1fr); } }
.p1  { --player-bg: var(--player-1);  --player-ink: var(--player-1-ink); }
.p2  { --player-bg: var(--player-2);  --player-ink: var(--player-2-ink); }
.p3  { --player-bg: var(--player-3);  --player-ink: var(--player-3-ink); }
.p4  { --player-bg: var(--player-4);  --player-ink: var(--player-4-ink); }
.p5  { --player-bg: var(--player-5);  --player-ink: var(--player-5-ink); }
.p6  { --player-bg: var(--player-6);  --player-ink: var(--player-6-ink); }
.p7  { --player-bg: var(--player-7);  --player-ink: var(--player-7-ink); }
.p8  { --player-bg: var(--player-8);  --player-ink: var(--player-8-ink); }
.p9  { --player-bg: var(--player-9);  --player-ink: var(--player-9-ink); }
.p10 { --player-bg: var(--player-10); --player-ink: var(--player-10-ink); }
.p11 { --player-bg: var(--player-11); --player-ink: var(--player-11-ink); }
.p12 { --player-bg: var(--player-12); --player-ink: var(--player-12-ink); }

/* Edit badge: a small pencil on the lower edge of the viewer's own dot, inside the 52px footprint, like an avatar edit mark.
   White surface, hairline, ink pencil (inline SVG); 20px across, which is --space-5 used as a size. It is a button with the
   aria-label "Edit your look", the one icon-only control the README's button rule allows. */
.edit { --edit-size: var(--space-5); --edit-icon: var(--space-3); --edit-bg: var(--color-surface); --edit-border: var(--border) solid var(--color-line);
        --edit-ink: var(--color-ink); --edit-shadow: none;
        --edit-focus-outline: var(--border-focus) solid var(--color-focus); --edit-focus-offset: calc(-1 * var(--border-focus));
        position: absolute; right: 0; bottom: 0; width: var(--edit-size); height: var(--edit-size); border-radius: 50%; padding: 0;
        display: grid; place-items: center; cursor: pointer; background: var(--edit-bg); border: var(--edit-border); color: var(--edit-ink); box-shadow: var(--edit-shadow); }
.edit svg { width: var(--edit-icon); height: var(--edit-icon); display: block; }
.edit:focus-visible { outline: var(--edit-focus-outline); outline-offset: var(--edit-focus-offset); }

/* Grey line: one plain line of secondary text on a screen (a label over the code, the room settings, a waiting message).
   Same size and colour as a field label, so every quiet line on a screen reads the same. */
.line { --line-text: var(--text-md); --line-ink: var(--color-ink-2); margin: 0; font-size: var(--line-text); color: var(--line-ink); }

/* Room code: the grey label and, under it, the code as the screen's heading at the page-title size, serif because it is a
   heading. Normal tracking, no mono, no box: it is read out across the table, so it is simply the largest text on the screen. */
.code { --code-gap: var(--space-1); --code-text: var(--text-3xl); --code-leading: var(--leading-tight);
        display: flex; flex-direction: column; gap: var(--code-gap); }
.frame .code h1 { font-size: var(--code-text); line-height: var(--code-leading); }

/* Timer: bar plus seconds. Colour changes by stage; the figure goes red only at urgent. */
.timer-row { --timer-text: var(--text-sm); --timer-ink: var(--color-ink-2); --timer-urgent-ink: var(--color-danger);
             display: flex; align-items: center; gap: calc(var(--space-2) + var(--space-half)); font-size: var(--timer-text); color: var(--timer-ink); }
.timer { --timer-bg: var(--color-surface); --timer-border: var(--border) solid var(--color-line); --timer-radius: var(--radius);
         flex: 1; height: var(--bar); border-radius: var(--timer-radius); background: var(--timer-bg); overflow: hidden; border: var(--timer-border); }
.timer i { display: block; height: 100%; width: var(--fill); background: var(--timer-calm); }
.timer-row.calm   { --fill: 62%; }
.timer-row.warn   { --fill: 30%; } .timer-row.warn .timer i   { background: var(--timer-warn); }
.timer-row.urgent { --fill: 10%; } .timer-row.urgent .timer i { background: var(--timer-urgent); }
.timer-row.urgent span { color: var(--timer-urgent-ink); }

/* Points line: the bottom of a Competitive reveal, the points and the spoiler link. A Co-op reveal has no bottom line. */
.bottom { --bottom-text: var(--text-md); --bottom-ink: var(--color-ink-2); --bottom-strong: var(--color-ink); --bottom-line: var(--border) solid var(--color-line);
          display: flex; justify-content: space-between; align-items: baseline; font-size: var(--bottom-text); color: var(--bottom-ink);
          border-top: var(--bottom-line); padding-top: calc(var(--space-2) + var(--space-half)); }
.bottom b, .top b { color: var(--bottom-strong, var(--color-ink)); font-weight: var(--weight-semibold); }
.neg { color: var(--color-danger); }

/* Spoiler: a plain text link, no chrome. Failed goes danger red. */
.spoil { --spoil-ink: var(--color-spoiler); --spoil-failed-ink: var(--color-danger); --spoil-decoration: none;
         color: var(--spoil-ink); font-weight: var(--weight-semibold); text-decoration: var(--spoil-decoration); }
.spoil.failed { color: var(--spoil-failed-ink); }
.links { display: flex; gap: var(--space-5); align-items: baseline; font-size: var(--text-md); color: var(--color-ink-2); }

/* ===================================================================================================
   Controls
   =================================================================================================== */

/* Text entry. One hairline box; focus is a 2px ink outline drawn inside the hairline, so nothing moves and nothing glows.
   Error is the hairline gone red plus a plain line of red text under the field. Disabled sinks into the cream. */
input, button { font: inherit; margin: 0; -webkit-appearance: none; appearance: none; }
.field { --field-gap: var(--space-1); --field-label-text: var(--text-md); --field-label-ink: var(--color-ink-2);
         --field-error-ink: var(--color-danger); --field-error-text: var(--text-sm);
         display: flex; flex-direction: column; gap: var(--field-gap); }
.field label { font-size: var(--field-label-text); color: var(--field-label-ink); }
.input {
  --input-height: var(--control);
  --input-pad: var(--space-3);
  --input-font: var(--font-sans);
  --input-text: var(--text-base);
  --input-ink: var(--color-ink);
  --input-bg: var(--color-surface);
  --input-border: var(--border) solid var(--color-line);
  --input-radius: var(--radius);
  --input-shadow: none;
  --input-placeholder: var(--color-ink-2);
  --input-focus-outline: var(--border-focus) solid var(--color-focus);
  --input-focus-offset: calc(-1 * var(--border-focus));
  --input-disabled-bg: var(--color-bg);
  --input-disabled-ink: var(--color-ink-2);
  --input-error: var(--color-danger);
  --input-height-lg: var(--control-lg);   /* .entry, the word box */
  --input-text-lg: var(--text-xl);
  --input-pad-lg: var(--space-4);
  display: block; width: 100%; height: var(--input-height); padding: 0 var(--input-pad); font-family: var(--input-font); font-size: var(--input-text);
  color: var(--input-ink); background: var(--input-bg); border: var(--input-border); border-radius: var(--input-radius); box-shadow: var(--input-shadow);
}
.input::placeholder { color: var(--input-placeholder); opacity: 1; }
.input:focus, .input.is-focus { outline: var(--input-focus-outline); outline-offset: var(--input-focus-offset); }
.input:disabled { background: var(--input-disabled-bg); color: var(--input-disabled-ink); }
.field.error .input { border-color: var(--input-error); }
.field .error-text { color: var(--field-error-ink); font-size: var(--field-error-text); margin: 0; }
.input.entry { height: var(--input-height-lg); font-size: var(--input-text-lg); padding: 0 var(--input-pad-lg); }

/* Buttons. Same height as the inputs. Primary is filled sage with white text, one per screen at most, the same in both modes.
   Secondary is a white hairline box. Text is quiet: no chrome at all. Hover and pressed shade the fill towards ink; disabled is cream and grey. */
.btn {
  --btn-height: var(--control);
  --btn-pad: var(--space-4);
  --btn-font: var(--font-sans);
  --btn-text: var(--text-base);
  --btn-weight: var(--weight-semibold);
  --btn-ink: var(--color-ink);
  --btn-bg: var(--color-surface);
  --btn-border: var(--border) solid var(--color-line);
  --btn-radius: var(--radius);
  --btn-shadow: none;
  --btn-transform: none;
  --btn-focus-outline: var(--border-focus) solid var(--color-focus);
  --btn-focus-offset: calc(-1 * var(--border-focus));
  --btn-height-lg: var(--control-lg);     /* .lg, the Submit beside the word box */
  --btn-pad-lg: var(--space-5);
  --btn-text-lg: var(--text-lg);
  --btn-primary-bg: var(--color-coop);
  --btn-primary-border-color: var(--color-coop);
  --btn-primary-ink: var(--color-surface);
  --btn-primary-hover-bg: color-mix(in srgb, var(--color-coop), var(--color-ink) 10%);
  --btn-primary-active-bg: color-mix(in srgb, var(--color-coop), var(--color-ink) 20%);
  --btn-secondary-hover-bg: var(--color-bg);
  --btn-secondary-active-border-color: var(--color-ink-2);
  --btn-text-pad: var(--space-2);
  --btn-text-hover-ink: var(--color-ink-2);
  --btn-text-active-bg: var(--color-line);
  --btn-disabled-bg: var(--color-bg);
  --btn-disabled-border-color: var(--color-line);
  --btn-disabled-ink: var(--color-ink-2);
  display: inline-flex; align-items: center; justify-content: center; height: var(--btn-height); padding: 0 var(--btn-pad); flex: none;
  font-family: var(--btn-font); font-size: var(--btn-text); font-weight: var(--btn-weight); line-height: 1; text-decoration: none;
  border: var(--btn-border); border-radius: var(--btn-radius); background: var(--btn-bg); color: var(--btn-ink); cursor: pointer;
  box-shadow: var(--btn-shadow); transform: var(--btn-transform);
}
.btn:focus-visible { outline: var(--btn-focus-outline); outline-offset: var(--btn-focus-offset); }
.btn.lg { height: var(--btn-height-lg); padding: 0 var(--btn-pad-lg); font-size: var(--btn-text-lg); }
.btn.primary { background: var(--btn-primary-bg); border-color: var(--btn-primary-border-color); color: var(--btn-primary-ink); }
.btn.primary:hover, .btn.primary.is-hover   { background: var(--btn-primary-hover-bg); border-color: var(--btn-primary-hover-bg); }
.btn.primary:active, .btn.primary.is-active { background: var(--btn-primary-active-bg); border-color: var(--btn-primary-active-bg); }
.btn.secondary:hover, .btn.secondary.is-hover   { background: var(--btn-secondary-hover-bg); }
.btn.secondary:active, .btn.secondary.is-active { background: var(--btn-secondary-hover-bg); border-color: var(--btn-secondary-active-border-color); }
.btn.text { background: none; border-color: transparent; padding: 0 var(--btn-text-pad); }
.btn.text:hover, .btn.text.is-hover   { color: var(--btn-text-hover-ink); }
.btn.text:active, .btn.text.is-active { background: var(--btn-text-active-bg); }
.btn:disabled, .btn.is-disabled { background: var(--btn-disabled-bg); border-color: var(--btn-disabled-border-color); color: var(--btn-disabled-ink); cursor: default; }
.btn.text:disabled, .btn.text.is-disabled { background: none; border-color: transparent; }

/* Choice: a row of secondary buttons where exactly one is chosen. Unchosen ones are grey text; the chosen one is ink text
   with the same 2px inset ink outline a focused control gets. No fill, no new colour: it is the focus style used as a mark.
   Mode and the timers all use it; there is no mode class. */
.choice { --choice-gap: var(--space-2); --choice-pad: var(--space-2);
          --choice-off-ink: var(--color-ink-2); --choice-off-weight: var(--weight-regular);
          --choice-on-ink: var(--color-ink); --choice-on-weight: var(--weight-semibold);
          --choice-on-outline: var(--border-focus) solid var(--color-focus); --choice-on-offset: calc(-1 * var(--border-focus));
          --choice-on-disabled-ink: var(--color-ink-2);
          display: flex; gap: var(--choice-gap); }
.choice .btn { flex: 1 1 0; min-width: 0; padding: 0 var(--choice-pad); color: var(--choice-off-ink); font-weight: var(--choice-off-weight); }
.choice .btn[aria-pressed="true"] { color: var(--choice-on-ink); font-weight: var(--choice-on-weight);
                                    outline: var(--choice-on-outline); outline-offset: var(--choice-on-offset); }
.choice .btn[aria-pressed="true"]:disabled { outline-color: var(--choice-on-disabled-ink); color: var(--choice-on-disabled-ink); }
.choice .btn[aria-pressed="true"]:focus-visible { outline-width: var(--border-focus); }
/* A choice with more options than fit one row (a match-target vote in a big game): three to a row. */
.choice.wrap { flex-wrap: wrap; }
.choice.wrap .btn { flex: 0 0 calc((100% - 2 * var(--choice-gap)) / 3); }

/* Stepper: a plain input showing the number, with a square secondary button either side. All three are --control tall,
   the same hairline and radius; the host can type or step. Below the minimum the input is empty and its placeholder reads Off,
   and the minus is disabled: that is the whole "off" state, no toggle. */
.step { --step-gap: var(--space-2); --step-btn-width: var(--control); --step-btn-weight: var(--weight-regular); --step-btn-text: var(--text-xl);
        display: flex; gap: var(--step-gap); }
.step .input { flex: 1 1 0; min-width: 0; text-align: center; }
.step .btn { width: var(--step-btn-width); padding: 0; font-weight: var(--step-btn-weight); font-size: var(--step-btn-text); }

/* Your look: the editor that opens under the player list when the pencil badge is tapped. Flat, in the page flow, no sheet
   or overlay. A grey title (.line), the colour control, the label field (.input.entry with a grey hint), a secondary Done.
   Start stays the only primary. */
.look { --look-gap: var(--space-3); display: flex; flex-direction: column; gap: var(--look-gap); }
.look .btn { align-self: flex-start; }

/* Colour: a native colour input dressed as the plain 48px hairline box, with "Any colour" in grey beside it (.any), then the
   12 token colours as 52px dot buttons for quick picks (.swatches), six across, four on a narrow phone. The input's inner swatch
   is the one piece of chrome tokens cannot reach; the vendor rules only strip its border and round it to sit inside the radius.
   The chosen dot carries the 2px inset ink outline (the .choice mark). A colour another player has is refused with the field's
   error pattern: red hairline on the box, one red line under the control. Tokens are --picker-* because --color-* is taken. */
.any { --any-gap: var(--space-3); display: flex; align-items: center; gap: var(--any-gap); }
.color { --picker-size: var(--control); --picker-pad: var(--space-1); --picker-bg: var(--color-surface);
         --picker-border: var(--border) solid var(--color-line); --picker-radius: var(--radius);
         --picker-swatch-radius: calc(var(--radius) - var(--space-1)); --picker-shadow: none; --picker-error: var(--color-danger);
         width: var(--picker-size); height: var(--picker-size); padding: var(--picker-pad); background: var(--picker-bg);
         border: var(--picker-border); border-radius: var(--picker-radius); box-shadow: var(--picker-shadow); cursor: pointer; }
.color::-webkit-color-swatch-wrapper { padding: 0; }
.color::-webkit-color-swatch { border: none; border-radius: var(--picker-swatch-radius); }
.color::-moz-color-swatch { border: none; border-radius: var(--picker-swatch-radius); }
.field.error .color { border-color: var(--picker-error); }
.swatches { --swatches-gap: var(--space-2); display: grid; grid-template-columns: repeat(6, 1fr); gap: var(--swatches-gap); justify-items: center; }
@media (max-width: 420px) { .swatches { grid-template-columns: repeat(4, 1fr); } } /* six 52px dots do not fit 343px; three rows of four do */
.swatch { --swatch-size: var(--dot-lg); --swatch-border: var(--border) solid var(--player-bg); --swatch-shadow: none;
          --swatch-on-outline: var(--border-focus) solid var(--color-focus); --swatch-on-offset: calc(-1 * var(--border-focus));
          --swatch-disabled-bg: var(--color-bg); --swatch-disabled-border: var(--border) solid var(--color-line);
          width: var(--swatch-size); height: var(--swatch-size); border-radius: 50%; padding: 0; cursor: pointer;
          border: var(--swatch-border); background: var(--player-bg); box-shadow: var(--swatch-shadow); }
.swatch[aria-pressed="true"] { outline: var(--swatch-on-outline); outline-offset: var(--swatch-on-offset); }
.swatch:disabled { background: var(--swatch-disabled-bg); border: var(--swatch-disabled-border); cursor: default; } /* cream and grey like every disabled control; no frame uses it yet, a taken colour is refused with the error line instead */

/* Word entry row: the box plus Submit on one line, both the large control height (components.html). On the turn screen the
   row is stacked (.stack): the box full width on its own line, Submit full width under it and, in Competitive, the Spoil
   button (see .btn.spoil) full width under that. The box carries enterkeyhint="send", so the keyboard's return key submits
   and the buttons may sit under the keyboard while typing. */
.entry-row { --entry-gap: var(--space-2); display: flex; gap: var(--entry-gap); }
.entry-row .input { flex: 1; min-width: 0; }
.entry-row.stack { flex-direction: column; }
.entry-row.stack > * { width: 100%; flex: none; }

/* Played: the box once your play is in. The disabled box shows your word and carries the sent mark (.sent) inside its right
   edge, under the same padding the text has; the box pads itself so the word never runs under the mark. */
.played { --played-pad: var(--space-4); --played-gap: var(--space-2); --played-mark: var(--space-5); /* the sent mark's size, --sent-size */
          position: relative; flex: 1; min-width: 0; }
.played .input { width: 100%; padding-right: calc(var(--played-pad) + var(--played-mark) + var(--played-gap)); }
.played .sent { position: absolute; right: var(--played-pad); top: 50%; transform: translateY(-50%); }

/* Sent mark: a small ink check (inline SVG) that says your play has gone in. Not a control: role="img" with the label "Sent"
   for assistive tech. Sits inside the played box and at the end of the spoiling line. 20px is --space-5 used as a size. */
.sent { --sent-size: var(--space-5); --sent-ink: var(--color-ink);
        width: var(--sent-size); height: var(--sent-size); display: block; flex: none; color: var(--sent-ink); }

/* Last turn: the previous reveal on the turn screen, open by default, from the second turn of a round. A grey line label,
   then the reveal's rows in the reveal's order, cut to the most popular three (every row tied with the first is kept, so a
   tie for first is never half shown), then, only when there were more, the Show all / Show fewer link (.more, aria-expanded).
   The rows are the reveal's rows with 8px instead of 12px of vertical padding and 6px between, so three rows plus the entry
   row fit the top half of a 375 by 667 phone; nothing is hidden to make room.
   The block is a scrolling region of its own: at most --last-max tall (180px: the 333px keyboard line less the top line, the
   timer, the box and the 12px gaps), overflow-y auto, a hairline along its bottom edge, so however many rows a reveal or the
   earlier turns add, the rows scroll inside it and the top line, timer, box and Submit never move. Three rows fit exactly;
   anything more shows as a row cut off at the hairline, which is the scroll hint, without hover. */
.last { --last-gap: calc(var(--space-1) + var(--space-half)); --last-row-pad: var(--space-2) calc(var(--space-3) + var(--space-half));
        --last-max: 180px; --last-edge: var(--border) solid var(--color-line);
        --more-text: var(--text-md); --more-ink: var(--color-ink-2); --more-weight: var(--weight-semibold); --more-pad: calc(var(--space-1) + var(--space-half)) 0;
        --more-hover-ink: var(--color-ink); --more-active-bg: var(--color-line);
        display: flex; flex-direction: column; gap: var(--last-gap); flex: none;
        max-height: var(--last-max); overflow-y: auto; border-bottom: var(--last-edge); }
.last .words { flex: none; margin-top: 0; gap: var(--last-gap); }
.last .word { --word-pad: var(--last-row-pad); }
.last .word.match { padding: var(--last-row-pad); }
.more { align-self: flex-start; padding: var(--more-pad); border: 0; background: none; cursor: pointer;
        font-size: var(--more-text); font-weight: var(--more-weight); color: var(--more-ink); text-decoration: none; line-height: var(--leading-normal); }
.more:hover, .more.is-hover { color: var(--more-hover-ink); }
.more:active, .more.is-active { background: var(--more-active-bg); }
.more:focus-visible { outline: var(--border-focus) solid var(--color-focus); outline-offset: 0; }

/* Earlier turns: under Last turn, from a round's third turn, the round's earlier reveals as collapsed one-line rows, latest
   first: a full-width secondary button whose left half says what it holds ("Turn 2: 5 words, no match") and whose right half,
   in grey, says what tapping does (Show / Hide, aria-expanded). Open, that turn's rows sit under its row in place, in the
   compact cut Last turn uses. Each collapsed row is a control's height, so two of them push the box under the keyboard. */
/* The block is set off from Last turn by a hairline and space above it, and has its own grey label (Earlier turns), so
   the last turn's words never run into the earlier ones. */
.earlier { --earlier-gap: calc(var(--space-1) + var(--space-half)); --earlier-action-ink: var(--color-ink-2); --earlier-action-weight: var(--weight-regular);
           --earlier-edge: var(--border) solid var(--color-line); --earlier-space: var(--space-3);
           display: flex; flex-direction: column; gap: var(--earlier-gap);
           margin-top: var(--earlier-space); padding-top: var(--earlier-space); border-top: var(--earlier-edge); }
.earlier > .line { margin: 0; }
.earlier .btn { width: 100%; justify-content: space-between; }
.earlier .btn span:last-child { color: var(--earlier-action-ink); font-weight: var(--earlier-action-weight); }

/* Spoil: the spoiler as a proper control on the Competitive turn screen, a full-width line of the stacked entry row under
   Submit, at the same height. A secondary button (white hairline, never filled: only the primary is) reading Spoil this turn
   in the spoiler blue, so it reads as the spoiler without competing with Submit. It is there only while a spoiler is
   available to you this round. */
.btn.spoil { --btn-ink: var(--spoil-ink); --btn-text-lg: var(--text-lg); text-decoration: none; }
.btn.spoil:disabled, .btn.spoil.is-disabled { color: var(--btn-disabled-ink); }

/* Spoiling: what replaces the entry row once Spoil is tapped (Competitive). One line in the spoiler blue, the same height
   as the entry box so nothing moves, with the sent mark at its end and a grey hint under it in a .field. The spoiler is a
   play, so it is final once tapped. */
.spoiling { --spoiling-height: var(--control-lg); --spoiling-font: var(--font-sans); --spoiling-text: var(--text-lg); --spoiling-weight: var(--weight-semibold); --spoiling-ink: var(--color-spoiler);
            --spoiling-pad: var(--space-4);
            display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); min-height: var(--spoiling-height); margin: 0; padding: 0 var(--spoiling-pad);
            font-family: var(--spoiling-font); font-size: var(--spoiling-text); font-weight: var(--spoiling-weight); color: var(--spoiling-ink); }

/* Result rows: the word rows on the round-over screen (the matched word, or the spoiler's row and the word the others said).
   On a reveal the rows stretch to push the score line to the bottom; here they keep their height so the standings sit right
   under them and the free space falls before the buttons. */
.words.result { flex: none; }

/* Outcome: the round-over screen's heading, how the round ended in two words (Match!, Spoiled!, Turn limit, Not enough
   players). An ordinary frame h1; the spoiled one is in the spoiler blue, text only as that colour always is. */
.outcome { --outcome-ink: inherit; --outcome-spoiled-ink: var(--color-spoiler); color: var(--outcome-ink); }
.outcome.spoiled { color: var(--outcome-spoiled-ink); }

/* Scores: the Competitive standings as a ranked list, winner first, on the round-over and game-over screens. Each row is
   the player's 10px dot, the name (You, semibold, for the viewer), the change this round in grey (+1, +2) or in red when
   it is a loss (a failed spoiler, the turn-limit penalty: red is for danger only), and the total on the right. A total below
   zero is red too, as it is on the reveal's points line. Rows sit on the page with a hairline between them, no box: a list,
   not a stack of cards. An optional grey rank figure leads the row on the game-over screen; tied players share one, and a
   player who left or was kicked has an empty one, with left or kicked in the small grey text after the name. */
.scores { --scores-text: var(--text-base); --scores-ink: var(--color-ink); --scores-ink-2: var(--color-ink-2); --scores-neg-ink: var(--color-danger);
          --scores-line: var(--border) solid var(--color-line); --scores-pad: var(--space-2) 0; --scores-gap: calc(var(--space-2) + var(--space-half));
          --scores-delta-text: var(--text-sm); --scores-total-weight: var(--weight-semibold); --scores-you-weight: var(--weight-semibold); --scores-rank-width: var(--space-4);
          display: flex; flex-direction: column; font-size: var(--scores-text); color: var(--scores-ink); }
.score { display: flex; align-items: center; gap: var(--scores-gap); padding: var(--scores-pad); border-top: var(--scores-line); }
.score:first-child { border-top: 0; }
.score .rank { flex: none; width: var(--scores-rank-width); color: var(--scores-ink-2); font-variant-numeric: tabular-nums; }
.score .name { flex: 1; min-width: 0; }
.score.you .name { font-weight: var(--scores-you-weight); }
.score small { color: var(--scores-ink-2); font-size: var(--scores-delta-text); font-variant-numeric: tabular-nums; }
.score b { font-weight: var(--scores-total-weight); min-width: 2ch; text-align: right; font-variant-numeric: tabular-nums; }
.score .neg { color: var(--scores-neg-ink); }

/* Final: the game-over screen's one big figure under a grey label, the shape of the room code: the winner's name in
   Competitive, the rounds matched in Co-op. Serif at the page-title size because it is the heading of the result. */
.final { --final-gap: var(--space-1); --final-font: var(--font-serif); --final-text: var(--text-3xl); --final-leading: var(--leading-tight); --final-weight: var(--weight-semibold);
         display: flex; flex-direction: column; gap: var(--final-gap); }
.final b { display: block; font-family: var(--final-font); font-size: var(--final-text); line-height: var(--final-leading); font-weight: var(--final-weight); }

/* Actions: the host's buttons at the bottom of the round-over screen, full width, stacked, the quiet Options (Competitive)
   above the primary so Next round is the lowest thing on the screen and in thumb reach. There is no End game: a game ends
   by itself. Takes .cta inside a frame to be pushed to the bottom. */
.actions { --actions-gap: var(--space-2); display: flex; flex-direction: column; gap: var(--actions-gap); }
.actions .btn { width: 100%; }

/* Who: a short grey label and then players as 10px dots: Still to play on the spectator's turn screen, Voted and Waiting
   for on a vote in progress. Colour is the dots' only signal, as on a word row: nobody has to act on it, it only says how far
   along the turn or the vote is. Dots wrap when a full room will not fit a line. */
.who { --who-gap: calc(var(--space-2) + var(--space-half)); --who-dot-gap: var(--space-1); --who-text: var(--text-md); --who-ink: var(--color-ink-2);
       display: flex; align-items: center; gap: var(--who-gap); font-size: var(--who-text); color: var(--who-ink); }
.who .dots { display: flex; flex-wrap: wrap; gap: var(--who-dot-gap); }

/* Tally: a vote's result as a list of .who rows, the winning option first: the option in ink, the dots of those who chose
   it, and the count in semibold on the right. Hairlines between rows, no box, the shape of the standings. Nothing is
   outlined: the matched word is the one outlined element, and the big figure above the list already says what won. */
.tally { --tally-text: var(--text-base); --tally-ink: var(--color-ink); --tally-line: var(--border) solid var(--color-line); --tally-pad: var(--space-2) 0;
         --tally-count-weight: var(--weight-semibold);
         display: flex; flex-direction: column; }
.tally .who { --who-text: var(--tally-text); --who-ink: var(--tally-ink); padding: var(--tally-pad); border-top: var(--tally-line); }
.tally .who:first-child { border-top: 0; }
.tally .who b { margin-left: auto; min-width: 2ch; text-align: right; font-weight: var(--tally-count-weight); font-variant-numeric: tabular-nums; }

/* Watching: the spectator's turn screen has no entry box; in its place one line of ink at the box's height, You are
   watching this game, with a grey hint under it in a .field saying they can ready up for the next game. No chrome and no
   colour: it is a statement, not a control, so it must not look like one. */
.watching { --watching-height: var(--control-lg); --watching-font: var(--font-sans); --watching-text: var(--text-lg); --watching-weight: var(--weight-semibold);
            --watching-ink: var(--color-ink);
            display: flex; align-items: center; min-height: var(--watching-height); margin: 0;
            font-family: var(--watching-font); font-size: var(--watching-text); font-weight: var(--watching-weight); color: var(--watching-ink); }

/* Option: a between-rounds setting the Competitive host can change or put to a vote. A field whose control (the match target
   stepper, the Allow spoilers choice) is followed by a secondary Put to a vote that hugs its text, with 8px between instead of
   the field's 4px so the button reads as the field's action and not as part of the control. */
.field.option { --option-gap: var(--space-2); --field-gap: var(--option-gap); }
.option > .btn { align-self: flex-start; }

/* Room bar: across the top of every in-room screen. Left, where you are as an eyebrow ("Competitive lobby", "Round 2 of 5 ·
   Turn 3", "Round over": small grey semibold, sentence case) over the room code (semibold); right, your name over your score (Competitive only), then the settings gear, whose menu holds Leave. One
   hairline under it, on the page colour, no card. Long names are cut with an ellipsis so the bar stays one block at 375px. */
.roombar { --roombar-bg: var(--color-bg); --roombar-line: var(--border) solid var(--color-line); --roombar-ink: var(--color-ink);
           --roombar-ink-2: var(--color-ink-2); --roombar-text: var(--text-sm); --roombar-strong: var(--text-md);
           --roombar-pad: var(--space-2) var(--space-4); --roombar-shadow: none;
           --roombar-eyebrow: var(--text-xs); --roombar-eyebrow-weight: var(--weight-semibold);
           display: flex; align-items: center; gap: var(--space-3); padding: var(--roombar-pad);
           background: var(--roombar-bg); border-bottom: var(--roombar-line); box-shadow: var(--roombar-shadow);
           font-size: var(--roombar-text); color: var(--roombar-ink-2); line-height: var(--leading-tight); }
.roombar .where, .roombar .me { display: flex; flex-direction: column; gap: var(--space-half); min-width: 0; }
.roombar .where { flex: 1; }
.roombar .me { text-align: right; max-width: 40%; }
.roombar b { color: var(--roombar-ink); font-size: var(--roombar-strong); font-weight: var(--weight-semibold); }
.roombar .eyebrow { font-size: var(--roombar-eyebrow); font-weight: var(--roombar-eyebrow-weight); color: var(--roombar-ink-2); }
.roombar .where span, .roombar .me > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.roombar .btn.leave { flex: none; height: var(--space-7); padding: 0 var(--space-2); }

/* Leave confirm: opens under the room bar when Leave (in the settings menu) is tapped during a game. The question, one grey line on what leaving
   costs, then Stay and Leave side by side. On the page, a hairline under it, no card and no overlay. */
.confirm { --confirm-bg: var(--color-bg); --confirm-line: var(--border) solid var(--color-line); --confirm-ink: var(--color-ink);
           --confirm-text: var(--text-lg); --confirm-shadow: none;
           display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-3) var(--space-4) var(--space-4);
           background: var(--confirm-bg); border-bottom: var(--confirm-line); box-shadow: var(--confirm-shadow); }
.confirm .q { margin: 0; font-size: var(--confirm-text); color: var(--confirm-ink); font-weight: var(--weight-semibold); }
.confirm .actions { flex-direction: row; margin-top: var(--space-1); }
.confirm .actions .btn { flex: 1; }

/* The next line: the left of a play screen's top line, saying what happens next for you ("Your turn: play a word",
   "Waiting on 2 players", "Waiting for Ann to start the next turn"). Ink, so it reads before the grey target beside it. */
.top .next { color: var(--color-ink); }

/* ===================================================================================================
   Phone frames
   =================================================================================================== */

/* The reveal mock: a 300 by 480 phone frame built from the parts above (components.html). */
.mock { --frame-bg: var(--color-bg); --frame-bg-image: none; --frame-bg-size: auto; --frame-border: var(--border) solid var(--color-line);
        --frame-radius: var(--radius); --frame-shadow: none;
        width: 300px; height: 480px; background: var(--frame-bg); background-image: var(--frame-bg-image); background-size: var(--frame-bg-size);
        border: var(--frame-border); border-radius: var(--frame-radius); box-shadow: var(--frame-shadow);
        padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-3); }
.mock.short { height: auto; }
.top { display: flex; justify-content: space-between; font-size: var(--text-md); color: var(--color-ink-2); }
.words { display: flex; flex-direction: column; gap: var(--space-2); flex: 1; margin-top: calc(var(--space-1) + var(--space-half)); }

/* Wireframe frame: the 480px measure, shrinking to the viewport on a phone (343px inside 16px margins at 375px).
   Tall enough that the primary button sits in thumb reach at the bottom, as it would on a real screen (screens.html). */
.frame { --frame-bg: var(--color-bg); --frame-bg-image: none; --frame-bg-size: auto; --frame-border: var(--border) solid var(--color-line);
         --frame-radius: var(--radius); --frame-shadow: none; --frame-h1-text: var(--text-2xl); --frame-gap: var(--space-5);
         width: min(var(--measure), 100%); min-height: 600px; background: var(--frame-bg); background-image: var(--frame-bg-image); background-size: var(--frame-bg-size);
         border: var(--frame-border); border-radius: var(--frame-radius); box-shadow: var(--frame-shadow);
         padding: var(--space-5) var(--space-4) var(--space-4); display: flex; flex-direction: column; gap: var(--frame-gap); }
/* The turn screen: a tighter rhythm, 12px between the top line, the timer, Last turn and the entry row instead of the 20px every
   other screen has, so three last-turn rows and the entry row fit the top half of a 375 by 667 phone with the keyboard up. */
.frame.turn { --frame-gap: var(--space-3); }
.frame h1 { font-size: var(--frame-h1-text); }
.frame form { display: contents; }
.frame .cta { margin-top: auto; width: 100%; }
/* Players inside a frame: three columns at the 480px measure, so a full room of 12 lettered dots is four rows and fits above
   the Start button without scrolling. Two columns on a narrow phone, where the frame grows instead; the page scrolls anyway. */
.frame .players { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 420px) { .frame .players { grid-template-columns: repeat(2, 1fr); } }
/* Waiting line and Start: the grey line takes the cta slot (pushed to the bottom, centred) and the full-width button sits under it,
   so the button is in thumb reach as on every other screen. Without a button, the line alone closes the screen. */
.frame .line.cta { text-align: center; }
.frame .btn.full { width: 100%; }
/* Play screens inside a frame (Turn, Reveal): the entry row stays a row even though it is a form (frames flatten forms),
   the word rows take the frame's own gap, and the points line sits at the bottom whether or not rows fill the middle. */
.frame .entry-row { display: flex; }
.frame .words { margin-top: 0; }
.frame .bottom { margin-top: auto; }

/* ===================================================================================================
   Design pages only: the Serious / Sketch switch. Not a game component.
   =================================================================================================== */
.theme-switch { --switch-bg: var(--color-surface); --switch-border: var(--border) solid var(--color-line); --switch-radius: var(--radius);
                --switch-font: var(--font-sans); --switch-text: var(--text-sm); --switch-ink: var(--color-ink-2);
                --switch-on-bg: var(--color-ink); --switch-on-ink: var(--color-surface); --switch-shadow: none;
                position: fixed; right: var(--space-3); bottom: var(--space-3); z-index: 1; display: flex; overflow: hidden;
                background: var(--switch-bg); border: var(--switch-border); border-radius: var(--switch-radius); box-shadow: var(--switch-shadow);
                font-family: var(--switch-font); font-size: var(--switch-text); }
.theme-switch button { height: 32px; padding: 0 var(--space-3); border: 0; background: none; color: var(--switch-ink); cursor: pointer; }
.theme-switch button[aria-pressed="true"] { background: var(--switch-on-bg); color: var(--switch-on-ink); }
.theme-switch button:focus-visible { outline: var(--border-focus) solid var(--color-focus); outline-offset: calc(-1 * var(--border-focus)); }
