/*
 * Design system for the Memauri Games Active Five home and navigation
 * (Phase 1 Build). Lives in a same-origin stylesheet, never inline, so the
 * document's Content-Security-Policy can forbid inline styles outright
 * (style-src 'self', no 'unsafe-inline' — Security Correction A, SEC-P0-07).
 * The service worker pre-caches this file with the rest of the critical
 * shell, so an offline reload still renders correctly.
 *
 * No web fonts and no images: docs/pm/provenance.md records that no
 * production-ready UI or character art exists yet, so this system is built
 * entirely from system fonts, colour, spacing and inline SVG shapes
 * generated in code (see app/web/src/icons.ts) — nothing here depends on an
 * asset that might later be rejected on licence or quality grounds.
 */

:root {
  color-scheme: light dark;

  --font-body: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-heading: Georgia, 'Iowan Old Style', 'Palatino Linotype', 'Book Antiqua', serif;

  --color-bg: #fff6e6;
  --color-surface: #fffaf0;
  --color-ink: #2b1b0e;
  --color-ink-muted: #5a4738;
  --color-border: #e7d7bd;
  --color-focus-ring: #1c5fae;

  /* Fixed regardless of colour scheme: game cards keep a light tinted
     background in both light and dark mode (docs decision: legible cards
     over a themed chrome, rather than re-deriving five accessible dark
     palettes with no design-token source to check them against yet). */
  --color-card-ink: #2b1b0e;
  --color-card-ink-muted: #5a4738;

  /* #a8660f measured at 3.92:1 against --color-numpuz-tint below — fails the
     4.5:1 requirement for normal-size text (the card's "Preview" CTA uses
     this colour). Darkened to #975c0d, verified at 4.65:1, same hue. */
  --color-numpuz-accent: #975c0d;
  --color-numpuz-tint: #fbebd3;
  --color-block-accent: #206b41;
  --color-block-tint: #deefe3;
  --color-sudoku-accent: #6a3a9e;
  --color-sudoku-tint: #ede3f7;
  --color-match-accent: #b83a2f;
  --color-match-tint: #fbe2de;
  --color-merge-accent: #146b6d;
  --color-merge-tint: #ddf3f2;

  /* Phase 1 Hardening. The five accents above were chosen and measured
     against the fixed LIGHT card tints, where they carry card text at 4.5:1
     or better in either colour scheme. Two places reuse an accent directly
     on the PAGE background instead — the hero emblem and the game-intro
     icon — and in dark mode that background is #1c140c, where the same
     colours measured 2.35:1 (sudoku) to 3.34:1 (numpuz): visibly muddy, and
     below the 3:1 WCAG 1.4.11 floor for a meaningful non-text graphic.
     These tokens are the on-background variants; in light mode they are the
     accent itself (nothing changes), and the dark-mode block below
     substitutes lightened same-hue values measured at 4.5:1 or better. The
     card tokens above are deliberately NOT redefined: the cards stay light
     in both schemes, so lightening their accent would break the card-text
     contrast the Build correction established. */
  --color-numpuz-accent-on-bg: var(--color-numpuz-accent);
  --color-block-accent-on-bg: var(--color-block-accent);
  --color-sudoku-accent-on-bg: var(--color-sudoku-accent);
  --color-match-accent-on-bg: var(--color-match-accent);
  --color-merge-accent-on-bg: var(--color-merge-accent);

  /* Phase 2 (P04) Numpuz board tokens. Every value below was measured, not
     chosen by eye, and app/web/tests/e2e/numpuz-a11y.spec.ts recomputes the
     ratios from the ACTUALLY RENDERED colours so a later change that
     regresses one fails CI rather than review:
       tile number on tile          15.95:1 (needs 4.5:1, WCAG 1.4.3)
       tile border on board surface  4.31:1 (needs 3:1, WCAG 1.4.11)
       blank outline on board        3.95:1 (needs 3:1)
       board border on page          5.08:1 (needs 3:1)
       focus ring on board surface   5.04:1 (needs 3:1)
     Nothing on the board is carried by colour alone: a tile's identity is its
     printed number, and the blank is identified by having none, by a dashed
     recess, and by its accessible name. */
  --numpuz-board-bg: #f3e3c6;
  --numpuz-tile-bg: #fffaf0;
  --numpuz-tile-ink: #2b1b0e;
  --numpuz-tile-border: #975c0d;
  --numpuz-blank-outline: #8a6a3a;
  --numpuz-gap: 6px;

  /* Phase 3 (P05) Block board tokens. Every value below was MEASURED, not
     chosen by eye, and app/web/tests/e2e/block-a11y.spec.ts recomputes the
     ratios from the ACTUALLY RENDERED colours so a later change that regresses
     one fails CI rather than review. Against the light board surface #e4efe8:
       piece 1 teal      5.11:1     piece 4 purple   6.90:1
       piece 2 rust      5.54:1     piece 5 ochre    4.97:1
       piece 3 green     5.14:1     piece 6 magenta  6.19:1
       empty-cell border 3.43:1     ghost outline    6.77:1
       invalid outline   7.63:1     board border on page 6.03:1
     All are non-text graphics needing 3:1 (WCAG 1.4.11).

     NOTHING ON THIS BOARD IS CARRIED BY COLOUR ALONE. A filled cell has a
     border and an accessible name; the valid ghost carries a solid outline and
     a live-region announcement; the invalid ghost carries a DASHED outline and
     its own announcement; an unplaceable tray piece carries a glyph and an
     accessible-name suffix. Every one is legible in greyscale, and no RULE
     anywhere reads a palette index. */
  --block-board-bg: #e4efe8;
  --block-cell-bg: #f4faf6;
  --block-cell-border: #6b8478;
  --block-ghost-outline: #1a5c38;
  --block-ghost-invalid: #8a2318;
  --block-piece-1: #1a6b85;
  --block-piece-2: #9c4221;
  --block-piece-3: #2f6f3e;
  --block-piece-4: #5f3d94;
  --block-piece-5: #7a6212;
  --block-piece-6: #9c2a55;
  --block-gap: 4px;

  /* Phase 4 (P06) Sudoku board tokens. Every value below was MEASURED, not
     chosen by eye, and app/web/tests/e2e/sudoku-a11y.spec.ts recomputes the
     ratios from the ACTUALLY RENDERED colours so a later change that regresses
     one fails CI rather than review.

     MEASURED, against the light board surface #efe7f7 and cell #fffdff:
       given digit on its cell    11.37:1 (needs 4.5:1, WCAG 1.4.3)
       player digit on its cell    8.08:1 (needs 4.5:1)
       a pencil mark on its cell   7.80:1 (needs 4.5:1)
       empty-cell border on board  4.74:1 (needs 3:1, WCAG 1.4.11)
       box rule on board           7.02:1 (needs 3:1)
       conflict outline on cell    8.89:1 (needs 3:1)
       check mark on cell          6.72:1 (needs 3:1)
       board border on page        7.22:1 (needs 3:1)

     THE CELL BORDER WAS CORRECTED DURING THIS BUILD, in both schemes. It was
     first written as #8a7a9c light / #6f6084 dark with a comment claiming
     3.21:1 and 3.26:1 — and the dark pair actually measures 2.84:1, BELOW the
     3:1 floor, which TB-S-29 caught on its first run. The light pair passed at
     3.26:1, which is not margin. Both are now lightened to clear the floor
     with room, and the numbers above are the ones the test recomputes rather
     than the ones this comment used to assert. A comment stating a measurement
     that was never taken is the SEC-P1-01 defect class, and it is recorded
     here rather than quietly fixed.

     NOTHING ON THIS BOARD IS CARRIED BY COLOUR ALONE. A given carries bold
     weight, its own background AND "given" in its accessible name; a conflict
     carries a 2px outline, a triangular glyph AND a sentence in its name; a
     cell the player asked to have marked after an explicit check carries a
     cross glyph and its own name suffix; a note is identified by its POSITION
     in a fixed 3x3 sub-grid; an exhausted pad digit carries a tick glyph,
     reduced opacity and its accessible name. Every one is legible in
     greyscale, and no RULE anywhere reads a colour.

     THE GAP IS 2px, WITH 2px BOX RULES, and that is arithmetic rather than
     taste (Inspection section 7.1). A 9x9 board cannot reach 44px per cell at
     a 320px viewport — solving cell >= 44 at V = 320 needs N <= 5 — so the
     question is how much margin there is above the WCAG 2.2 AA 24px floor
     (SC 2.5.8). At a 6px gap the prediction was 24.9px, which is 0.9px of
     margin and not margin at all; at 2px it is 28.9px. The Build MEASURES it
     with getBoundingClientRect and reports the figure, and if any supported
     viewport puts a cell below 24px the LAYOUT CHANGES — the floor is not
     waived. */
  --sudoku-board-bg: #efe7f7;
  --sudoku-cell-bg: #fffdff;
  --sudoku-given-bg: #e2d6f0;
  --sudoku-cell-border: #776788;
  --sudoku-rule: #5a3f85;
  --sudoku-ink: #2b1b3e;
  --sudoku-entry-ink: #1d4f8f;
  --sudoku-note-ink: #5b4a70;
  --sudoku-conflict: #8a2318;
  --sudoku-check: #8a4b00;
  --sudoku-hint-unit: #f3ecfb;
  --sudoku-hint-support: #d9c6f0;
  --sudoku-hint-target: #b9e2c5;
  --sudoku-hint-target-edge: #1f6b3c;
  --sudoku-gap: 2px;
  --sudoku-rule-width: 3px;

  --radius-md: 14px;
  --radius-lg: 22px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 16px;
  --space-4: 24px;
  --space-5: 40px;

  --motion-fast: 150ms;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #1c140c;
    --color-surface: #241b11;
    --color-ink: #f6ead9;
    --color-ink-muted: #cbb79c;
    --color-border: #3a2c1c;

    /* Phase 1 Hardening: the light-mode ring #1c5fae measured 2.86:1
       against the dark page background — below the 3:1 WCAG 1.4.11 minimum
       for a focus indicator, and every focus ring in this design lands on
       the page background because outline-offset places it outside the
       element. Lightened to the same hue family at 8.46:1. Light mode is
       unchanged and measures 5.94:1. Both are asserted by
       tests/e2e/contrast.spec.ts against the actually-rendered colours. */
    --color-focus-ring: #7fb5f0;

    /* Same-hue, lightened accents for the two on-background uses (see the
       :root block). Measured against #1c140c: numpuz 4.56:1, block 4.53:1,
       sudoku 4.57:1, match 4.54:1, merge 4.55:1 — all comfortably above the
       3:1 floor, and still visibly one accent per game. */
    --color-numpuz-accent-on-bg: #b66f10;
    --color-block-accent-on-bg: #2b9058;
    --color-sudoku-accent-on-bg: #986bc9;
    --color-match-accent-on-bg: #d2584d;
    --color-merge-accent-on-bg: #1a8d8f;

    /* Phase 2 (P04): the dark counterparts of the board tokens in :root,
       measured the same way. Against the dark board surface #241b11: tile
       number on tile 8.94:1, tile border 4.25:1, blank outline 4.85:1, focus
       ring 7.88:1; board border against the dark page background 4.56:1. */
    --numpuz-board-bg: #241b11;
    --numpuz-tile-bg: #563a16;
    --numpuz-tile-ink: #f8ecd9;
    --numpuz-tile-border: #b66f10;
    --numpuz-blank-outline: #a8834a;

    /* Phase 3 (P05): the dark counterparts, measured the same way against the
       dark board surface #212c26: piece 1 7.06:1, piece 2 6.11:1, piece 3
       6.93:1, piece 4 5.66:1, piece 5 7.16:1, piece 6 5.82:1, empty-cell
       border 3.09:1, ghost outline 8.43:1, invalid outline 6.07:1; the board
       border against the dark page background 4.53:1. */
    --block-board-bg: #212c26;
    --block-cell-bg: #2c3a33;
    --block-cell-border: #63796d;
    --block-ghost-outline: #7fd8a2;
    --block-ghost-invalid: #f08d7f;
    --block-piece-1: #79bfd8;
    --block-piece-2: #e0977a;
    --block-piece-3: #78c48c;
    --block-piece-4: #b294e2;
    --block-piece-5: #cdb567;
    --block-piece-6: #e28aab;

    /* Phase 4 (P06): the dark counterparts, MEASURED the same way against the
       dark board surface #261c33 and cell #302341:
         given digit on its cell    10.86:1
         player digit on its cell    7.94:1
         a pencil mark on its cell   7.49:1
         empty-cell border on board  4.03:1  (was 2.84:1 — see :root)
         box rule on board           5.26:1
         conflict outline on cell    6.12:1
         check mark on cell          7.51:1
         board border on page        4.57:1 */
    --sudoku-board-bg: #261c33;
    --sudoku-cell-bg: #302341;
    --sudoku-given-bg: #3d2c53;
    --sudoku-cell-border: #8778a0;
    --sudoku-rule: #a583d6;
    --sudoku-ink: #f4ecff;
    --sudoku-entry-ink: #93c4f5;
    --sudoku-note-ink: #c4b3da;
    --sudoku-conflict: #f08d7f;
    --sudoku-check: #e3b269;
    --sudoku-hint-unit: #332644;
    --sudoku-hint-support: #4a3765;
    --sudoku-hint-target: #2c4f38;
    --sudoku-hint-target-edge: #7fd8a2;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* The `hidden` attribute must actually hide.
   The UA stylesheet's `[hidden] { display: none }` is a single-attribute
   selector, so ANY class rule that sets `display` outranks it — which is how
   the Numpuz completion surface first shipped with the paused/size controls
   still on screen underneath it, despite the code setting `.hidden = true`.
   Declaring it here, once, means a component can be hidden by attribute
   without every future display rule having to remember this. */
[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-ink);
  font-family: var(--font-body);
  line-height: 1.5;
  /* Phase 1 Hardening: a long unbroken word — a compound translated heading,
     a long game name — used to push the document wider than the viewport
     (measured at 320px: scrollWidth 569 against clientWidth 320, i.e. the
     whole page scrolled sideways). overflow-wrap is inherited, so declaring
     it here covers every current and future view. */
  overflow-wrap: break-word;
}

h1,
h2,
h3 {
  font-family: var(--font-heading);
  margin: 0 0 var(--space-2);
}

p {
  margin: 0 0 var(--space-3);
}

a {
  color: inherit;
}

button {
  font-family: inherit;
}

/* Reduced motion: a global safety net in addition to the opt-in-only hero
   animation below, so any future transition/animation is covered too. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* Phase 1 Hardening. These controls are inline-flex, so their text forms an
   anonymous flex item whose default min-width is auto (its min-content
   width) — a long unbreakable label therefore overflowed the control's own
   box even with max-width: 100%, and scrolled the page sideways by a
   measured 231px at 320px wide. `anywhere`, unlike `break-word`, also
   reduces the min-content contribution, which is what lets the anonymous
   item shrink and the label wrap inside the control. */
.footer-link,
.back-link,
.primary-button,
.game-card__status,
.game-card__cta {
  overflow-wrap: anywhere;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--color-ink);
  color: var(--color-bg);
  padding: var(--space-2) var(--space-3);
  border-radius: 0 0 var(--radius-md) 0;
  z-index: 10;
  text-decoration: none;
  font-weight: 600;
}

.skip-link:focus {
  left: 0;
}

:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 3px;
  border-radius: 4px;
}

/* The <main> landmark is focused programmatically on every route change
   (main.ts focusMainLandmark) purely so assistive technology announces the
   surface the player just opened — it carries tabindex="-1" and is not an
   interactive control.

   Phase 2 Hardening (H2-01). `main { outline: none }` has specificity 0,0,1
   and was outranked by the bare `:focus-visible` rule above (0,1,0), so every
   navigation drew a 3px ring around the entire page. Measured at the Phase 2
   Build head on #/, #/game/block, #/game/sudoku, #/diagnostics, #/nope and
   the Numpuz play route; introduced by b759ab6 (Phase 1 Hardening).

   The reset is now scoped by id (1,1,0) so it wins outright, and it is
   scoped to the landmark ELEMENT alone: `#main:focus-visible` matches the
   container and nothing inside it, so every link, button, tile and form
   control keeps the ring above, in both colour schemes. Asserted by
   measurement in tests/e2e/focus-scroll.spec.ts rather than by reading the
   specificity off the page. */
#main:focus,
#main:focus-visible {
  outline: none;
}

.view {
  max-width: 1100px;
  margin: 0 auto;
  padding: var(--space-4) var(--space-3) var(--space-5);
}

.view--game-intro,
.view--diagnostics,
.view--not-found,
.view--update-ready,
.view--chunk-error {
  max-width: 640px;
}

/* Hero */
.hero {
  text-align: center;
  padding-top: var(--space-4);
  padding-bottom: var(--space-4);
}

.hero__emblem {
  width: 96px;
  height: 96px;
  margin: 0 auto var(--space-2);
  color: var(--color-numpuz-accent-on-bg);
}

@media (prefers-reduced-motion: no-preference) {
  .hero__emblem {
    animation: hero-float 4s ease-in-out infinite;
  }
}

@keyframes hero-float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-6px);
  }
}

.hero-emblem__svg {
  width: 100%;
  height: 100%;
}

.hero__host-name {
  margin: 0;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.75rem;
  color: var(--color-ink-muted);
}

.hero__title {
  font-size: clamp(1.75rem, 5vw, 2.75rem);
  margin: var(--space-1) 0;
}

.hero__tagline {
  font-size: clamp(1rem, 2.5vw, 1.25rem);
  font-weight: 600;
  color: var(--color-ink-muted);
  margin-bottom: var(--space-1);
}

.hero__lead {
  color: var(--color-ink-muted);
  margin-bottom: 0;
}

/* Catalog */
.catalog__heading {
  text-align: center;
  font-size: clamp(1.25rem, 3vw, 1.75rem);
  margin-bottom: var(--space-4);
}

.game-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-3);
}

.game-grid__item {
  display: flex;
  /* Phase 1 Hardening. A `1fr` track's automatic minimum size is the item's
     min-content width, so one long unbreakable word (a compound translated
     game name) grew the track and pushed the whole page wider than the
     viewport — overflow-wrap alone cannot prevent that, because it does not
     reduce min-content. Allowing the item to shrink below its content lets
     the track stay within the viewport, and the wrapping rules below then
     break the word inside it. */
  min-width: 0;
}

.game-card {
  --card-accent: var(--color-numpuz-accent);
  --card-tint: var(--color-numpuz-tint);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  width: 100%;
  text-decoration: none;
  color: var(--color-card-ink);
  background: var(--card-tint);
  border: 2px solid transparent;
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  min-height: 220px;
  transition:
    transform var(--motion-fast) ease,
    box-shadow var(--motion-fast) ease,
    border-color var(--motion-fast) ease;
}

.game-card:hover,
.game-card:focus-visible {
  transform: translateY(-3px);
  border-color: var(--card-accent);
  box-shadow: 0 10px 24px -12px rgba(0, 0, 0, 0.35);
}

.game-card--numpuz {
  --card-accent: var(--color-numpuz-accent);
  --card-tint: var(--color-numpuz-tint);
}
.game-card--block {
  --card-accent: var(--color-block-accent);
  --card-tint: var(--color-block-tint);
}
.game-card--sudoku {
  --card-accent: var(--color-sudoku-accent);
  --card-tint: var(--color-sudoku-tint);
}
.game-card--match {
  --card-accent: var(--color-match-accent);
  --card-tint: var(--color-match-tint);
}
.game-card--merge {
  --card-accent: var(--color-merge-accent);
  --card-tint: var(--color-merge-tint);
}

.game-card__icon {
  color: var(--card-accent);
  width: 44px;
  height: 44px;
}

.icon-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.game-card__title {
  font-size: 1.25rem;
  margin: 0;
  color: var(--color-card-ink);
}

.game-card__description {
  margin: 0;
  color: var(--color-card-ink-muted);
  font-size: 0.9rem;
  flex-grow: 1;
}

.game-card__status {
  display: inline-flex;
  align-items: center;
  /* Wrap rather than widen: a long translated availability string
     ("Demnächst verfügbar…") must fall onto a second line beside its dot,
     not stretch the card. */
  flex-wrap: wrap;
  max-width: 100%;
  gap: var(--space-1);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-card-ink-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--card-accent);
  flex-shrink: 0;
}

/* align-self: flex-start makes this shrink-to-fit, so it needs an explicit
   ceiling or a long call-to-action escapes the card (Phase 1 Hardening). */
.game-card__cta {
  align-self: flex-start;
  max-width: 100%;
  margin-top: var(--space-1);
  font-weight: 700;
  color: var(--card-accent);
}

.game-card__cta::after {
  content: ' \2192';
}

/* Footer */
.site-footer {
  text-align: center;
  margin-top: var(--space-5);
}

.footer-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  min-height: 44px;
  padding: 0 var(--space-3);
  font-size: 0.85rem;
  color: var(--color-ink-muted);
  text-decoration: underline;
}

/* Back link / primary button (shared by game-intro, diagnostics, not-found) */
.back-link {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 44px;
  padding: var(--space-1) 0;
  font-weight: 600;
  text-decoration: none;
  color: var(--color-ink);
}

/* Shrink-to-fit like the links above: an explicit ceiling keeps a long
   translated label inside the surface instead of widening the page. */
.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  min-height: 48px;
  padding: 0 var(--space-4);
  margin-top: var(--space-4);
  background: var(--color-ink);
  color: var(--color-bg);
  border-radius: 999px;
  /* The same explicit family and rem size `.secondary-button` and
     `.sudoku-button` already carry, and for the reason Phase 3 Hardening
     measured on `.block-button`: the global `button` reset sets the family but
     not the size, so a <button> carrying this class keeps the UA default while
     every other piece of text grows with the browser's text-size setting.
     Until Phase 4 Hardening this class was only ever used on an <a>, which
     inherits both, so nothing had exposed it. Found by LOOKING at the 320x568
     / 200 %-text capture of the new recovery surface, where the button's label
     stayed small beside a secondary control that had scaled. A no-op for every
     existing anchor: body is 1rem and already the inherited family. */
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  text-decoration: none;
}

/* Game intro */
.game-intro--numpuz {
  --card-accent-on-bg: var(--color-numpuz-accent-on-bg);
}
.game-intro--block {
  --card-accent-on-bg: var(--color-block-accent-on-bg);
}
.game-intro--sudoku {
  --card-accent-on-bg: var(--color-sudoku-accent-on-bg);
}
.game-intro--match {
  --card-accent-on-bg: var(--color-match-accent-on-bg);
}
.game-intro--merge {
  --card-accent-on-bg: var(--color-merge-accent-on-bg);
}

/* This icon sits directly on the page background, not on a card tint, so it
   takes the on-background accent (see the :root block). */
.game-intro__icon {
  width: 72px;
  height: 72px;
  margin: var(--space-3) 0 var(--space-2);
  color: var(--card-accent-on-bg, var(--color-numpuz-accent-on-bg));
}

.game-intro__title {
  font-size: clamp(1.5rem, 4vw, 2.25rem);
}

.game-intro__description {
  font-size: 1.05rem;
  color: var(--color-ink-muted);
}

.status-banner {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  margin-top: var(--space-3);
}

.status-banner p {
  margin: 0;
  /* A flex item's default min-width is auto (its min-content), which a long
     unbreakable word would push past the banner's own width. */
  min-width: 0;
}

.status-banner__icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.status-banner--unavailable {
  border-color: var(--color-ink-muted);
}

.status-banner--unavailable .status-banner__icon {
  color: var(--color-ink-muted);
}

.status-banner--available {
  border-color: var(--color-block-accent);
}

.status-banner--available .status-banner__icon {
  color: var(--color-block-accent);
}

/* Not found */
.not-found__title {
  font-size: clamp(1.4rem, 4vw, 2rem);
}

/* Diagnostics: deliberately plain and utilitarian — this must never be
   styled to look like, or be mistaken for, a consumer-facing surface. */
.view--diagnostics {
  font-family: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  font-size: 0.85rem;
}

.view--diagnostics h1,
.view--diagnostics h2 {
  font-family: inherit;
}

.diagnostics__title {
  font-size: 1.1rem;
}

.view--diagnostics ul {
  padding-left: var(--space-4);
}

.view--diagnostics li {
  margin-bottom: var(--space-1);
}

.diagnostics__buttons button {
  font-size: 0.85rem;
  min-height: 40px;
  padding: var(--space-1) var(--space-2);
  margin: 2px 4px 2px 0;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-surface);
  color: var(--color-ink);
  cursor: pointer;
}

.diagnostics__buttons button:hover {
  border-color: var(--color-ink-muted);
}

#log {
  white-space: pre-wrap;
  font-size: 0.75rem;
  border-top: 1px solid var(--color-border);
  padding-top: var(--space-2);
  margin-top: var(--space-3);
  max-height: 180px;
  overflow: auto;
}

/* ---------------------------------------------------------------------
   Phase 2 (P04): Numpuz play and completion surfaces.

   Board geometry comes from one PREDECLARED CLASS PER DECLARED SIZE
   (.numpuz-board--3/--4/--5, REC-17). No inline style attribute is ever set:
   app/web/src/dom.ts routes every non-class attribute through setAttribute,
   so a computed `style` would be a literal inline style governed by
   style-src 'self' — predeclaring the three sizes makes the question moot
   instead of relying on an engine-dependent CSP corner.
   --------------------------------------------------------------------- */

.view--numpuz-play {
  max-width: 820px;
}

.numpuz-title {
  font-size: clamp(1.5rem, 4vw, 2.25rem);
}

.numpuz-notice {
  border: 2px solid var(--color-border);
  border-left-width: 6px;
  border-left-color: var(--color-numpuz-accent-on-bg);
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  margin-bottom: var(--space-3);
  color: var(--color-ink);
  min-width: 0;
}

.numpuz-layout {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  align-items: stretch;
}

.numpuz-board-area {
  min-width: 0;
}

/* The board is a two-level grid because its rows are real role="row"
   elements: the board lays out rows, each row lays out its cells. */
.numpuz-board {
  display: grid;
  gap: var(--numpuz-gap);
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  aspect-ratio: 1;
  padding: var(--numpuz-gap);
  background: var(--numpuz-board-bg);
  border: 2px solid var(--color-numpuz-accent-on-bg);
  border-radius: var(--radius-lg);
}

.numpuz-row {
  display: grid;
  gap: var(--numpuz-gap);
  min-width: 0;
}

.numpuz-board--3 {
  grid-template-rows: repeat(3, 1fr);
}
.numpuz-board--3 .numpuz-row {
  grid-template-columns: repeat(3, 1fr);
}
.numpuz-board--4 {
  grid-template-rows: repeat(4, 1fr);
}
.numpuz-board--4 .numpuz-row {
  grid-template-columns: repeat(4, 1fr);
}
.numpuz-board--5 {
  grid-template-rows: repeat(5, 1fr);
}
.numpuz-board--5 .numpuz-row {
  grid-template-columns: repeat(5, 1fr);
}

.numpuz-tile {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 0;
  border: 2px solid var(--numpuz-tile-border);
  border-radius: var(--radius-md);
  background: var(--numpuz-tile-bg);
  color: var(--numpuz-tile-ink);
  font-family: var(--font-heading);
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  /* Only the settle animation moves; there is no transition on layout, so a
     rapid sequence of taps can never queue up visual work behind the model. */
  animation-fill-mode: none;
}

/* One size step per declared board size. rem-based so the numbers still grow
   with the browser's text size; the values are chosen so that even at a 200%
   root size the widest label (two digits at 5x5) fits its cell at 320px —
   asserted by measurement in tests/e2e/numpuz-a11y.spec.ts, not by eye. */
.numpuz-board--3 .numpuz-tile {
  font-size: 1.75rem;
}
.numpuz-board--4 .numpuz-tile {
  font-size: 1.4rem;
}
.numpuz-board--5 .numpuz-tile {
  font-size: 1.05rem;
}

/* The blank is a recess, not a tile: no fill, no number, a dashed inset
   outline, and an accessible name that says it is empty. Three independent
   signals, none of which is colour. */
.numpuz-tile--blank {
  background: transparent;
  border-style: dashed;
  border-color: var(--numpuz-blank-outline);
  cursor: default;
}

.numpuz-tile:disabled {
  cursor: default;
}

@media (prefers-reduced-motion: no-preference) {
  .numpuz-tile--settled {
    animation: numpuz-settle 180ms ease-out;
  }
}

@keyframes numpuz-settle {
  from {
    transform: scale(0.88);
  }
  to {
    transform: scale(1);
  }
}

/* The paused board is dimmed, not hidden. The dim is deliberately mild: at
   opacity 0.55 the tile numbers composited to 3.93:1 in light mode and 4.11:1
   in dark (measured), below the 4.5:1 text floor. Disabled controls are
   formally exempt from that floor, but a paused puzzle is something a player
   sits and looks at, so the state is signalled by the "Paused" line, the
   Resume control and the inert cells, and only gently by the dim. The
   composited ratio is asserted in tests/e2e/numpuz-a11y.spec.ts. */
.numpuz-board--paused .numpuz-tile {
  opacity: 0.78;
}

.numpuz-paused {
  text-align: center;
  margin: var(--space-3) 0 0;
  font-weight: 600;
  color: var(--color-ink-muted);
}

/* Side panel */
.numpuz-side {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.numpuz-stats {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-4);
  margin: 0;
  align-items: baseline;
}

.numpuz-stat__label {
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-ink-muted);
}

.numpuz-stat__value {
  margin: 0 var(--space-3) 0 0;
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 700;
}

.numpuz-controls,
.numpuz-sizes,
.numpuz-confirm__actions,
.numpuz-complete__actions,
.game-intro__confirm-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}

.numpuz-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  min-height: 44px;
  padding: 0 var(--space-3);
  border: 2px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-surface);
  color: var(--color-ink);
  font-weight: 600;
  font-family: inherit;
  font-size: 1rem;
  text-decoration: none;
  cursor: pointer;
  overflow-wrap: anywhere;
}

.numpuz-button:hover,
.secondary-button:hover {
  border-color: var(--color-ink-muted);
}

.numpuz-button--primary {
  background: var(--color-ink);
  color: var(--color-bg);
  border-color: var(--color-ink);
}

.numpuz-size-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  min-width: 64px;
  padding: 0 var(--space-3);
  border: 2px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-surface);
  color: var(--color-ink);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  overflow-wrap: anywhere;
}

/* The pressed size is marked by a filled swatch AND by aria-pressed, so the
   current choice is never conveyed by colour alone. */
.numpuz-size-button[aria-pressed='true'] {
  background: var(--numpuz-tile-bg);
  border-color: var(--color-numpuz-accent-on-bg);
  border-width: 3px;
  color: var(--numpuz-tile-ink);
}

.numpuz-save-note,
.numpuz-live {
  margin: 0;
  font-size: 0.85rem;
  color: var(--color-ink-muted);
  min-width: 0;
}

/* Phase 2 Hardening (H2-08): the live region is announced, not displayed.
   The Build left it visible, which was honest but made the completion surface
   repeat itself — the captured completion shows "Solved. 3 x 3 board, 25
   moves, 1 minute 23 seconds." printed underneath a labelled summary already
   saying Board / Moves / Time. Printing the same three facts twice does not
   make them truer, and the visible copy is the one nobody asked for.

   The standard clipped-not-hidden technique: `display: none`, `visibility:
   hidden`, `hidden` and zero width/height all remove a node from the
   accessibility tree, and a live region removed from that tree announces
   NOTHING, which would silently delete the feature rather than tidy it. A 1px
   clipped box stays in the tree and keeps announcing.

   Asserted by measurement in tests/e2e/numpuz-hardening.spec.ts: the region
   still exists, still carries role="status", still receives its messages, and
   contributes no visible text. */
.numpuz-live {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Confirmation */
.numpuz-confirm,
.game-intro__confirm {
  border: 2px solid var(--color-numpuz-accent-on-bg);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  padding: var(--space-3);
  min-width: 0;
}

.numpuz-confirm__title {
  font-size: 1.1rem;
  margin-top: 0;
}

.numpuz-confirm__title:focus-visible,
.numpuz-complete__title:focus-visible,
.game-intro__confirm-title:focus-visible,
.game-intro__delete-failed:focus-visible,
.numpuz-title:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 3px;
}

.game-intro__play {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  align-items: flex-start;
  margin-top: var(--space-4);
}

.game-intro__play .primary-button {
  margin-top: 0;
}

.game-intro__confirm-title {
  margin-bottom: var(--space-2);
  font-weight: 600;
}

/* Phase 2 Hardening (H2-03). Shown only when the saved game could NOT be
   deleted. It uses the notice treatment already established on the play
   surface rather than a new one, because it is the same kind of statement:
   the device would not do something, and the product says so plainly instead
   of pretending it worked. */
.game-intro__delete-failed {
  margin: 0;
  border: 2px solid var(--color-numpuz-accent-on-bg);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  padding: var(--space-2) var(--space-3);
  color: var(--color-ink);
  font-weight: 600;
  min-width: 0;
}

/* Phase 2 Hardening (H2-05). The bounded recovery surface an event-handler
   failure degrades to. Deliberately plain: it has one job, which is to say
   what happened and give the player two working ways out. */
.numpuz-recovery__lead {
  margin-bottom: var(--space-4);
  max-width: 48ch;
}

.numpuz-recovery__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
}

.numpuz-recovery__actions .primary-button {
  margin-top: 0;
}

/* Completion */
.numpuz-complete {
  text-align: center;
  border: 3px solid var(--color-numpuz-accent-on-bg);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  padding: var(--space-4) var(--space-3);
  margin-bottom: var(--space-4);
  min-width: 0;
}

.numpuz-celebration {
  width: 88px;
  height: 88px;
  margin: 0 auto var(--space-2);
  color: var(--color-numpuz-accent-on-bg);
}

.numpuz-celebration__svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* The shapes are drawn in their final state and the animation only travels TO
   it, so when the reduced-motion rule above collapses every duration to
   0.001ms the burst is complete and static rather than absent. */
@media (prefers-reduced-motion: no-preference) {
  .numpuz-celebration__svg {
    animation: numpuz-burst 420ms ease-out;
  }
  /* Opacity only. A `transform-origin` here would NOT be inert: each ray
     already carries its own `transform="rotate(a 24 24)"` attribute, which
     modern engines expose as the CSS transform property, so declaring an
     origin re-anchors that rotation and scatters the rays off the burst —
     visible in the first Phase 2 capture as a disc with three stray marks
     beside it, while the reduced-motion capture (where this whole block does
     not apply) drew the sunburst correctly. */
  .numpuz-celebration__ray {
    animation: numpuz-ray 520ms ease-out;
  }
  .numpuz-complete {
    animation: numpuz-rise 320ms ease-out;
  }
}

@keyframes numpuz-burst {
  from {
    transform: scale(0.55) rotate(-12deg);
  }
  to {
    transform: scale(1) rotate(0deg);
  }
}

@keyframes numpuz-ray {
  from {
    opacity: 0.2;
  }
  to {
    opacity: 1;
  }
}

@keyframes numpuz-rise {
  from {
    transform: translateY(10px);
  }
  to {
    transform: translateY(0);
  }
}

.numpuz-complete__title {
  font-size: clamp(1.6rem, 6vw, 2.4rem);
  margin-bottom: var(--space-1);
}

.numpuz-complete__lead {
  color: var(--color-ink-muted);
  margin-bottom: var(--space-3);
}

.numpuz-summary {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2) var(--space-4);
  margin: 0 0 var(--space-3);
}

.numpuz-summary__row {
  min-width: 0;
}

.numpuz-summary dt {
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-ink-muted);
  font-weight: 600;
}

.numpuz-summary dd {
  margin: 0;
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
}

.numpuz-complete__actions {
  justify-content: center;
}

.numpuz-complete__actions .primary-button {
  margin-top: 0;
}

/* Two columns once there is width for them, so the board and its controls sit
   side by side rather than pushing the controls far below the fold. */
@media (min-width: 720px) {
  .numpuz-layout {
    flex-direction: row;
    align-items: flex-start;
  }
  .numpuz-board-area {
    flex: 0 0 420px;
  }
  .numpuz-side {
    flex: 1 1 0;
  }
}

/* Short landscape (the 844x390 case in the evidence matrix). Here the board
   is HEIGHT-constrained, not width-constrained, so it is sized against the
   viewport height and the controls move beside it.

   Phase 2 Hardening (H2-02). This was a flat `69vh`, which spends a FIXED
   FRACTION of the viewport on the board and therefore wastes an increasing
   share of it as the viewport shrinks: at 390px high the board ended 43px
   short of the bottom edge, at 320px it ended 21px short, while its 5x5 tiles
   had already fallen to 36px. The chrome above the board is a constant
   number of pixels, not a fraction, so the honest formula subtracts it:

     board = min(420px, viewport height - chrome - breathing room)

   --numpuz-landscape-chrome carries that constant, measured rather than
   guessed (view padding 8 + back link 36 + title 30 + gap 4 = 78, plus 12px
   so the board is not flush against the bottom edge). Measured effect on a
   5x5 board, the tightest declared case:

     viewport   before -> after      tiles before -> after
     844x390    269 -> 300           46 -> 51
     740x370    255 -> 280           43 -> 48
     700x360    248 -> 270           42 -> 46
     640x340    235 -> 265*          39 -> 45     (*tier 2 below)

   100dvh is preferred where it is supported, because on a real phone the
   URL bar makes vh and the actual visible height disagree; the 100vh
   declaration above it is the fallback for an engine that does not support
   dvh, which drops the whole calc() rather than mis-computing it. Both are
   asserted by measurement in tests/e2e/numpuz-a11y.spec.ts, not by eye.

   Below roughly 330px of viewport height a 5x5 board's tiles still fall under
   44px, because the back link alone is 36px tall and dropping it further to
   buy board height would move the touch-target problem onto a real control.
   That limit is recorded rather than hidden — see the Hardening evidence. */
@media (orientation: landscape) and (max-height: 520px) {
  .numpuz-layout {
    --numpuz-landscape-chrome: 90px;
    flex-direction: row;
    align-items: flex-start;
  }
  /* A notice sits ABOVE the layout, so in short landscape its height comes
     straight off the board's. The Build budgeted for this by trimming the
     notice's own type and padding; that was not enough, and the reason is
     that a notice is not one fixed height. Measured cost (height + margin) at
     the narrowest landscape width this rule covers:

       "Your saved game is back..."      1 line   42px
       "We couldn't read your last..."   1 line   42px
       "This device isn't letting..."    2 lines  63px
       ...plus the stale-save clause     3 lines  85px

     At the Build head a 3-line notice put the board's lower edge at 410px of
     a 390px viewport — off screen, on the surface a player meets after a
     failed save. The budget is therefore keyed to the notice the code is
     actually showing, through the data-notice attribute it already sets, and
     every combination is measured in tests/e2e/numpuz-a11y.spec.ts rather
     than trusted to these numbers staying true. */
  .numpuz-notice:not([hidden]) + .numpuz-layout {
    --numpuz-landscape-chrome: 132px;
  }
  .numpuz-notice[data-notice^='save-failed']:not([hidden]) + .numpuz-layout {
    --numpuz-landscape-chrome: 175px;
  }
  .view--numpuz-play {
    padding-top: var(--space-2);
    padding-bottom: var(--space-2);
  }
  .view--numpuz-play .back-link {
    min-height: 36px;
  }
  .numpuz-title {
    font-size: 1.25rem;
    margin-bottom: var(--space-1);
  }
  /* The flex basis, not just the board's max-width: with a content-sized
     basis the board's `width: 100%` resolves against a shrink-to-fit box and
     collapses (measured at 144px before this line existed, giving 21px
     tiles). */
  /* No lower floor, deliberately. A floor of 260px (the smallest board whose
     5x5 tiles still measure 44px) was measured and rejected: it kept the
     touch target but pushed the board's lower edge past the viewport in most
     short-landscape-plus-notice combinations, including 568x320 with no
     notice at all. The Build already weighed that same trade and chose a
     board that fits on screen over one that meets the 44px floor, recording
     it as a known limitation; reversing an accepted trade is not Hardening's
     to do quietly. What Hardening fixes is the DEFECT — a board pushed off
     screen by a notice — and it takes the free improvement the height-aware
     formula gives everywhere else. Horizontal scrolling is never traded away
     at any size. */
  .numpuz-board-area {
    flex: 0 0 min(420px, calc(100vh - var(--numpuz-landscape-chrome)));
    flex-basis: min(420px, calc(100dvh - var(--numpuz-landscape-chrome)));
  }
  .numpuz-board {
    max-width: min(420px, calc(100vh - var(--numpuz-landscape-chrome)));
    max-width: min(420px, calc(100dvh - var(--numpuz-landscape-chrome)));
  }
  .numpuz-side {
    flex: 1 1 0;
  }
  /* A notice sits above the layout, so in short landscape its own height comes
     straight off the board's. At full size it pushed the board's lower edge to
     418px of a 390px viewport (measured); trimmed, the board stays on screen
     with a notice showing, which is the case a player meets after every
     restore. */
  .numpuz-notice {
    font-size: 0.9rem;
    padding: var(--space-1) var(--space-2);
    margin-bottom: var(--space-2);
  }
}

/* Phase 2 Hardening (H2-02), tier two: the shortest landscape viewports, where
   the constant chrome above the board is the binding constraint rather than
   the fraction of viewport the board is allowed. Only the chrome is trimmed —
   the heading is smaller and the paddings tighter — and the back link keeps
   its 36px so no real control is pushed further below the touch-target floor
   to buy board height. Measured at 640x340: chrome 78 -> 62, board 235 -> 266,
   5x5 tiles 39px -> 45px, whole board still on screen. */
@media (orientation: landscape) and (max-height: 400px) {
  .numpuz-layout {
    --numpuz-landscape-chrome: 74px;
  }
  .numpuz-notice:not([hidden]) + .numpuz-layout {
    --numpuz-landscape-chrome: 116px;
  }
  .numpuz-notice[data-notice^='save-failed']:not([hidden]) + .numpuz-layout {
    --numpuz-landscape-chrome: 159px;
  }
  .view--numpuz-play {
    padding-top: var(--space-1);
  }
  /* Phase 2 Hardening (H2-09). The completion panel keeps its full celebration
     in portrait, where there is height for it. In short landscape the same
     panel pushed "Play again" — the primary action — onto the fold at
     844x390 (measured: the button spanned y 360-396 of a 390px viewport), so
     the panel's own vertical spend is trimmed rather than the player being
     asked to scroll for the one control the surface exists to offer. The
     celebration is smaller, not absent: it is still drawn, still complete,
     and still carries the moment. */
  .numpuz-complete {
    padding-top: var(--space-2);
    padding-bottom: var(--space-2);
    margin-bottom: var(--space-2);
  }
  .numpuz-celebration {
    width: 48px;
    height: 48px;
    margin-bottom: var(--space-1);
  }
  .numpuz-complete__title {
    font-size: 1.4rem;
  }
  .numpuz-complete__lead {
    margin-bottom: var(--space-2);
  }
  .numpuz-title {
    font-size: 1.05rem;
    margin-bottom: 0;
  }
}

/* ---------------------------------------------------------------------
   Phase 3 (P05): Block play and game-over surfaces.

   Board geometry comes from ONE PREDECLARED CLASS PER SHAPE FOOTPRINT, in
   two independent families (--w1..--w5 for columns, --h1..--h5 for rows),
   which covers every shape in the catalogue and every shape a future one
   could add within the declared maxima. No inline style attribute is ever
   set: app/web/src/dom.ts routes every non-class attribute through
   setAttribute, so a computed `style` would be a literal inline style
   governed by style-src 'self'. Predeclaring makes the question moot rather
   than relying on an engine-dependent CSP corner.

   THE GHOST NEEDS NO POSITIONING AT ALL. It is rendered by toggling classes
   on the board's own cell elements, so there is nothing to position and
   nothing for style-src to consider — strictly simpler than Phase 2's
   answer to the same problem.
   --------------------------------------------------------------------- */

.view--block-play {
  max-width: 820px;
}

.block-title {
  font-size: clamp(1.5rem, 4vw, 2.25rem);
}

.block-notice {
  border: 2px solid var(--color-border);
  border-left-width: 6px;
  border-left-color: var(--color-block-accent-on-bg);
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  margin-bottom: var(--space-3);
  color: var(--color-ink);
  min-width: 0;
}

.block-layout {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  align-items: stretch;
}

/* Two-level grid, because the rows are real role="row" elements: the board
   lays out rows, each row lays out its cells. */
.block-board {
  display: grid;
  grid-template-rows: repeat(8, 1fr);
  gap: var(--block-gap);
  width: 100%;
  min-width: 0;
  /* 480px rather than Numpuz's 420px. A comfort change, stated as one rather
     than dressed up as compliance: on a phone neither cap is reached, so this
     changes nothing where the touch-target problem actually is. */
  max-width: 480px;
  margin: 0 auto;
  aspect-ratio: 1;
  padding: var(--block-gap);
  background: var(--block-board-bg);
  border: 2px solid var(--color-block-accent-on-bg);
  border-radius: var(--radius-lg);
}

.block-row {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: var(--block-gap);
  min-width: 0;
}

.block-cell {
  display: block;
  min-width: 0;
  padding: 0;
  border: 2px solid var(--block-cell-border);
  border-radius: 6px;
  background: var(--block-cell-bg);
  cursor: pointer;
  /* Nothing transitions on layout, so a rapid sequence of taps can never queue
     visual work up behind the model. */
  animation-fill-mode: none;
}

.block-cell--filled {
  border-color: transparent;
}

.block-cell--p1 { background: var(--block-piece-1); }
.block-cell--p2 { background: var(--block-piece-2); }
.block-cell--p3 { background: var(--block-piece-3); }
.block-cell--p4 { background: var(--block-piece-4); }
.block-cell--p5 { background: var(--block-piece-5); }
.block-cell--p6 { background: var(--block-piece-6); }

/* THE GHOST. Valid: the piece's colour at reduced opacity plus a SOLID accent
   outline. Invalid: a DASHED outline and no fill. The outline STYLE and the
   live-region announcement both carry the state, so neither is legible by
   colour alone and both survive greyscale. */
.block-cell--ghost-valid {
  outline: 3px solid var(--block-ghost-outline);
  outline-offset: -3px;
  /* Well below a placed cell's solid fill. At 0.62 the preview was close
     enough to a placed piece to be mistaken for one — another observation from
     looking at the captures. The outline carries the state regardless (it is
     solid here and dashed when the piece does not fit), so this is legibility
     rather than the signal itself. */
  opacity: 0.4;
}

.block-cell--ghost-invalid {
  outline: 3px dashed var(--block-ghost-invalid);
  outline-offset: -3px;
  /* NO background override. It used to repaint the cell as empty, which ERASED
     the filled cells the piece was colliding with — so the preview said "this
     does not fit" while hiding the only thing that explained why. Found by
     looking at the capture. The dashed outline sits on top of whatever the cell
     really is, and the cell keeps saying whether it is filled. */
}

.block-cell:disabled {
  cursor: default;
}

/* The tray. A piece is a real control and stays at or above 44px in both
   dimensions; the BOARD CELL is the small target, and nothing else is. */
.block-tray {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: flex-end;
  justify-content: center;
  margin: 0;
  padding: var(--space-2);
  min-height: 76px;
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
}

.block-piece {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  min-width: 44px;
  min-height: 44px;
  padding: var(--space-1) var(--space-2);
  background: transparent;
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  cursor: grab;
  color: var(--color-ink);
  touch-action: none;
}

.block-piece[aria-pressed='true'] {
  border-color: var(--color-block-accent-on-bg);
  background: var(--color-block-tint);
}

/* The selected state is an outline, a background AND the word "Selected" in
   the accessible name — never colour alone. */
.block-piece__selected {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-block-accent-on-bg);
}

/* An unplaceable piece carries a GLYPH and an accessible-name suffix. A
   computed fact from the rules, not a hint and not a difficulty claim. */
.block-piece--unplaceable {
  opacity: 0.55;
  cursor: default;
}

.block-piece__marker {
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1;
  color: var(--block-ghost-invalid);
}

.block-piece__grid {
  display: grid;
  gap: 2px;
}

/* 14px per piece cell, not 10px. At 10px a tray piece read as a speck beside a
   ~40px board cell and a player could not judge what would fit where — found by
   looking at the Build's own captures, not by a failing assertion. The widest
   shape is five cells: 5 x 14 + 4 x 2 = 78px, so three of them plus the gaps
   still fit the 288px content width at the 320px viewport without wrapping. */

.block-piece__grid--w1 { grid-template-columns: repeat(1, 14px); }
.block-piece__grid--w2 { grid-template-columns: repeat(2, 14px); }
.block-piece__grid--w3 { grid-template-columns: repeat(3, 14px); }
.block-piece__grid--w4 { grid-template-columns: repeat(4, 14px); }
.block-piece__grid--w5 { grid-template-columns: repeat(5, 14px); }
.block-piece__grid--h1 { grid-template-rows: repeat(1, 14px); }
.block-piece__grid--h2 { grid-template-rows: repeat(2, 14px); }
.block-piece__grid--h3 { grid-template-rows: repeat(3, 14px); }
.block-piece__grid--h4 { grid-template-rows: repeat(4, 14px); }
.block-piece__grid--h5 { grid-template-rows: repeat(5, 14px); }

.block-piece__cell {
  border-radius: 2px;
  background: transparent;
}

.block-piece__cell--filled {
  border: 1px solid rgba(0, 0, 0, 0.18);
}

.block-piece__cell--p1 { background: var(--block-piece-1); }
.block-piece__cell--p2 { background: var(--block-piece-2); }
.block-piece__cell--p3 { background: var(--block-piece-3); }
.block-piece__cell--p4 { background: var(--block-piece-4); }
.block-piece__cell--p5 { background: var(--block-piece-5); }
.block-piece__cell--p6 { background: var(--block-piece-6); }

/* Side panel */
.block-side {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.block-stats {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-4);
  margin: 0;
  align-items: baseline;
}

.block-stat__label {
  font-weight: 600;
  color: var(--color-ink-muted);
}

.block-stat__value {
  margin: 0;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.15rem;
}

.block-controls {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.block-button {
  /* The global `button` reset sets the family but not the size, so a button
     label stays at the UA default (about 13px) while every other piece of text
     grows with the browser's text-size setting. Found by looking at the 200%
     capture: the page text was twice its size and "Start over" was not.

     Phase 3 Hardening MEASURED the rest of the sentence that used to stand
     here — "the same gap exists on the shell's buttons" — and it does not.
     Every text node on all seven routes was compared at a 16px and a 32px root
     font size in isolated browser contexts and every one of them scales,
     because `.numpuz-button`, `.secondary-button`, `.primary-button` and
     `.diagnostics__buttons button` each carry an explicit `rem` size already.
     The generalisation was never measured; the deferral it created is closed
     by measurement rather than by a change. */
  font-size: 1rem;
  min-height: 44px;
  min-width: 44px;
  padding: var(--space-2) var(--space-3);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-ink);
  font-weight: 600;
  cursor: pointer;
}

.block-button--primary {
  border-color: var(--color-block-accent-on-bg);
  background: var(--color-block-accent-on-bg);
  color: var(--color-surface);
}

.block-save-note,
.block-help {
  margin: 0;
  font-size: 0.9rem;
  color: var(--color-ink-muted);
}

/* Visually hidden, audibly unchanged. Phase 2 H2-08 found that a VISIBLE live
   region printed the completion facts twice on the same surface. */
.block-live {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.block-confirm,
.block-complete,
.block-recovery__lead {
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  padding: var(--space-3);
}

.block-confirm__title,
.block-complete__title {
  margin-top: 0;
  font-size: 1.25rem;
}

.block-confirm__actions,
.block-complete__actions,
.block-recovery__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.block-summary {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.block-summary__row {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  border-bottom: 1px solid var(--color-border);
  padding-bottom: var(--space-1);
}

.block-summary__row dt {
  font-weight: 600;
  color: var(--color-ink-muted);
}

.block-summary__row dd {
  margin: 0;
  font-family: var(--font-heading);
  font-weight: 700;
}

@media (prefers-reduced-motion: no-preference) {
  .block-cell--cleared {
    animation: block-clear 180ms ease-out;
  }
}

@keyframes block-clear {
  from {
    opacity: 0.85;
    transform: scale(0.94);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@media (min-width: 720px) {
  .block-layout {
    flex-direction: row;
    align-items: flex-start;
  }
  .block-board {
    flex: 0 0 480px;
  }
  .block-side {
    flex: 1 1 0;
  }
}

/* SHORT LANDSCAPE. R-22 handled in advance, and handled WITHOUT a table of
   measured chrome constants.

   Phase 2 sized its landscape board from `100dvh` minus a constant for the
   chrome above it, with a separate constant per notice state. That works until
   a notice is one line longer than the constant assumed — which is exactly the
   defect R-22 records, and which Block reproduced on its first measurement
   (the board's lower edge landed at 411px of a 390px viewport with a restore
   notice showing).

   The board is sized by the LAYOUT here instead. The view is a full-height
   column, the layout row takes whatever height is left after the back link,
   the heading and any notice, and the board is as tall as that row and square.
   Nothing has to know how tall a notice is, so no notice of any length can push
   the board off screen, and the tray sits BESIDE the board rather than above
   it. The side panel scrolls within its own column if its content is taller
   than the row, so the board is never the thing that gives way. */
@media (orientation: landscape) and (max-height: 520px) {
  .view--block-play {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    padding-top: var(--space-2);
    padding-bottom: var(--space-2);
    overflow: hidden;
  }
  .view--block-play .back-link {
    min-height: 36px;
    flex: 0 0 auto;
  }
  .block-title {
    font-size: 1.25rem;
    margin-bottom: var(--space-1);
    flex: 0 0 auto;
  }
  .block-notice {
    font-size: 0.9rem;
    padding: var(--space-1) var(--space-2);
    margin-bottom: var(--space-2);
    flex: 0 0 auto;
  }
  .block-layout {
    flex: 1 1 auto;
    min-height: 0;
    flex-direction: row;
    align-items: stretch;
    gap: var(--space-3);
  }
  /* The board takes its height from the layout row and its width from its own
     `aspect-ratio`, AS THE FLEX ITEM ITSELF. It used to sit inside a
     `.block-board-area` wrapper that was the flex item, and WebKit sized that
     wrapper from the board's intrinsic content width (250px) rather than from
     the square the board then rendered at (311.6px) — a percentage height is
     not definite while a flex line's main size is being resolved, so the
     aspect ratio had nothing to transfer. The board overflowed its own
     wrapper and the tray beside it started 14px inside the board's right
     edge. Chromium and Firefox transferred the height and hid the fault.
     With the wrapper gone the board's height resolves against
     `.block-layout`, whose height the OUTER column has already settled, and
     a flex item cannot overlap its sibling whatever an engine makes of the
     transfer. */
  .block-board {
    flex: 0 0 auto;
    min-height: 0;
    height: 100%;
    width: auto;
    max-width: none;
    max-height: 480px;
    margin: 0;
  }
  .block-side {
    flex: 1 1 0;
    min-width: 0;
    min-height: 0;
    overflow-y: auto;
    gap: var(--space-1);
  }
  /* `flex: 0 0 auto`, not a zeroed min-height alone. The tray is a flex item in
     the side column, so the default `flex-shrink: 1` squeezed the BOX while its
     pieces kept their own size and spilled out over the stats beneath it —
     visible in the short-landscape capture and invisible to every assertion,
     because the board itself was still square and on screen. */
  .block-tray {
    flex: 0 0 auto;
    min-height: 0;
    padding: var(--space-1);
    align-items: center;
  }
  .block-stats,
  .block-controls {
    flex: 0 0 auto;
  }
  /* THE TWO INFORMATIONAL PARAGRAPHS LEAVE THE FLOW, AND STAY IN THE
     ACCESSIBLE TREE.

     Phase 3 Build gave `.block-help` `display: none` here with the comment
     "It stays in the accessible tree — every instruction it carries is also in
     the tray pieces' own accessible names." Phase 3 Hardening found both
     halves of that false: `display: none` removes an element from the
     accessibility tree as surely as it removes it from the page, and a tray
     piece's accessible name gives its shape, its size in squares, whether it
     is selected and whether it can be placed — never how to operate the game.
     In short landscape the only operating instructions disappeared for
     everyone, sighted or not.

     The standing save-note was the other half of the Build's own deferral, and
     it was measured rather than assumed: at 568 x 320 it was clipped by 42px
     on a fresh board and 48px restored, and at 640 x 340 by 16px fresh, 28px
     restored and 42px after a discarded save. It is a disclosure, so it is not
     dropped — it is taken out of the column's flow and left where a screen
     reader still reaches it, exactly like the help.

     Visually hidden rather than hidden: absolutely positioned, so neither
     paragraph contributes a pixel to the column that has to hold the board's
     controls, and both remain in the accessible tree. This is the same recipe
     `.block-live` already uses on this surface. */
  .block-help,
  .block-save-note {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    border: 0;
  }
  /* And the interactive remainder is tightened so it fits the row rather than
     relying on the column's scroll. Measured at 568 x 320 with the four-line
     storage-failure notice, the tallest notice this surface has: tray, stats
     and controls came to 189px against a 178px row before the column gap above
     was narrowed and these two rules were added. */
  .block-stats {
    gap: 2px var(--space-3);
  }
  .block-stat__value {
    font-size: 1rem;
  }
}

@media (orientation: landscape) and (max-height: 400px) {
  .view--block-play {
    padding-top: var(--space-1);
  }
  .block-title {
    font-size: 1.1rem;
  }
}

/* ---------------------------------------------------------------------
   Phase 4 (P06): Sudoku — the tier chooser, play and completion surfaces.

   THE BOX SEPARATORS ARE BORDERS ON THE CELLS, not extra elements. A 9x9
   Sudoku needs eight internal gridlines per axis, two of which must read as
   box boundaries; drawing those two as thicker borders on the cells that sit
   against them costs no DOM at all and, crucially, no inline style — every
   non-class attribute in this application goes through setAttribute (see
   app/web/src/dom.ts), so a computed `style` would be a literal inline style
   governed by style-src 'self'. Predeclaring the geometry in classes makes
   the question moot rather than relying on an engine-dependent CSP corner,
   exactly as Phase 3 did for Block's shape footprints.

   NO DRAG, NO POINTER CAPTURE, NO GHOST. A cell tap only ever SELECTS, so
   there is nothing to position and nothing to preview. The entire class of
   defects that dominated Phase 3 — seven drag endings, the compatibility
   click, the hover that moved a held ghost — does not apply to this surface,
   and that is a genuine reduction in risk rather than an accident.
   --------------------------------------------------------------------- */

.view--sudoku-play {
  max-width: 880px;
}

.sudoku-title {
  font-size: clamp(1.5rem, 4vw, 2.25rem);
}

.sudoku-notice {
  border: 2px solid var(--color-border);
  border-left-width: 6px;
  border-left-color: var(--color-sudoku-accent-on-bg);
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  margin-bottom: var(--space-3);
  color: var(--color-ink);
  min-width: 0;
}

/* --- the tier chooser ------------------------------------------------
   Every label is a MEASUREMENT: the tiers are named for the solving
   techniques their puzzles require, certified in both directions for all 60.
   There is no easy, no medium, no hard, no expert, no star rating and no
   difficulty anywhere on this surface. */

.sudoku-chooser__title {
  margin-top: 0;
  font-size: 1.25rem;
}

.sudoku-chooser__lead {
  color: var(--color-ink-muted);
  margin-top: 0;
}

.sudoku-chooser__options {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.sudoku-tier {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  align-items: flex-start;
  text-align: left;
  /* Comfortably past the 44px floor: this is a reading-and-choosing control,
     not a dense grid, so there is no reason for it to be tight. */
  min-height: 64px;
  padding: var(--space-3);
  border: 2px solid var(--color-border);
  border-left-width: 6px;
  border-left-color: var(--color-sudoku-accent-on-bg);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-ink);
  cursor: pointer;
  font-size: 1rem;
  width: 100%;
}

.sudoku-tier__name {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.15rem;
}

.sudoku-tier__sentence {
  color: var(--color-ink-muted);
  font-size: 0.95rem;
}

/* --- the board ------------------------------------------------------- */

.sudoku-layout {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  align-items: stretch;
}

/* Two-level grid, because the rows are real role="row" elements: the board
   lays out rows, each row lays out its cells. */
.sudoku-board {
  display: grid;
  grid-template-rows: repeat(9, 1fr);
  gap: var(--sudoku-gap);
  width: 100%;
  min-width: 0;
  max-width: 480px;
  margin: 0 auto;
  aspect-ratio: 1;
  padding: var(--sudoku-gap);
  background: var(--sudoku-board-bg);
  border: 2px solid var(--color-sudoku-accent-on-bg);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-sizing: border-box;
  isolation: isolate;
  box-shadow: 0 8px 26px rgba(70, 43, 16, 0.10);
}

.sudoku-row {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: var(--sudoku-gap);
  min-width: 0;
}

.sudoku-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 0;
  border: 1px solid var(--sudoku-cell-border);
  border-radius: 3px;
  background: var(--sudoku-cell-bg);
  color: var(--sudoku-entry-ink);
  font-family: var(--font-heading);
  /* Scales with the CELL rather than with the root font size, so a digit
     always fills its square at every viewport. The cell is a fixed fraction
     of the board and the board is a square that fits the viewport, so cqw
     would need a container; vw against the board's own max-width is the
     simplest thing that is correct at both ends. */
  font-size: clamp(0.85rem, 3.6vw, 1.6rem);
  font-weight: 600;
  cursor: pointer;
  /* Nothing transitions on layout, so a rapid sequence of taps can never
     queue visual work up behind the model. */
  animation-fill-mode: none;
}

/* THE BOX RULES, DRAWN FROM BOTH SIDES OF EACH BOUNDARY.
   ===================================================================
   FOUND BY LOOKING AT THE CAPTURES, NOT BY AN ASSERTION. The first version
   drew a single 2px border on the leading edge of the cell that starts each
   box — columns 3 and 6, rows 3 and 6 — and every assertion passed: the
   geometry was right, the contrast was right, nothing was carried by colour
   alone. And the board was UNREADABLE AS A SUDOKU. Across a 2px inter-cell
   gap, a 2px border on one side is indistinguishable from the cell's own 1px
   outline, so the nine boxes simply did not appear: the capture showed a flat
   9x9 grid.

   That is not a cosmetic complaint. The box is one of the three constraints a
   player reasons about, it is half of what tier 2 is NAMED for ("Lines and
   boxes"), and a hint that says "in box 5" is unfollowable on a board with no
   visible boxes.

   The boundary is now drawn from BOTH sides: the trailing edge of columns 2
   and 5 and rows 2 and 5, and the leading edge of columns 3 and 6 and rows 3
   and 6. That gives 3px + the 2px gap + 3px = 8px of rule colour at each box
   boundary against 2px of board background elsewhere — a four-fold difference
   that reads immediately. Borders are inside `box-sizing: border-box`, so the
   cells keep their outer size and the geometry measurements are unchanged;
   the digit's centring shifts by about 1px, which is below the threshold of
   noticing at any supported width.

   THREE OF PHASE 2'S FOUR PRODUCT DEFECTS AND FIVE OF PHASE 3 BUILD'S came
   from looking at images rather than from a failing assertion. This is the
   first of Phase 4's. */
.sudoku-cell[data-col='3'],
.sudoku-cell[data-col='6'] {
  border-left: var(--sudoku-rule-width) solid var(--sudoku-rule);
}

.sudoku-cell[data-col='2'],
.sudoku-cell[data-col='5'] {
  border-right: var(--sudoku-rule-width) solid var(--sudoku-rule);
}

.sudoku-cell[data-row='3'],
.sudoku-cell[data-row='6'] {
  border-top: var(--sudoku-rule-width) solid var(--sudoku-rule);
}

.sudoku-cell[data-row='2'],
.sudoku-cell[data-row='5'] {
  border-bottom: var(--sudoku-rule-width) solid var(--sudoku-rule);
}

/* A GIVEN: bold weight AND its own background AND "given" in its accessible
   name. Three carriers, none of them colour alone. */
.sudoku-cell--given {
  background: var(--sudoku-given-bg);
  color: var(--sudoku-ink);
  font-weight: 800;
}

/* Preserve the established given/entry backgrounds and their proven
   contrast ratios. Selection context is conveyed by inset rules, not
   by replacing cell backgrounds with blended colours. */
.sudoku-cell--box {
  box-shadow: inset 0 0 0 1px var(--color-sudoku-accent-on-bg);
}
.sudoku-cell--peer {
  box-shadow: inset 0 0 0 2px var(--color-sudoku-accent-on-bg);
}
.sudoku-cell--matching {
  box-shadow: inset 0 0 0 2px var(--color-sudoku-accent-on-bg);
  font-weight: 800;
}
.sudoku-cell__note--matching {
  background: var(--color-sudoku-accent-on-bg);
  color: #fff;
  border-radius: 3px;
}
.sudoku-cell--selected {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: -3px;
}

/* A CONFLICT: a 2px outline AND a triangular glyph AND a sentence in the
   accessible name. The glyph sits in the corner so it never covers the digit
   it is about. */
.sudoku-cell--conflict {
  outline: 2px solid var(--sudoku-conflict);
  outline-offset: -2px;
  color: var(--sudoku-conflict);
}

.sudoku-cell--disagrees {
  outline: 2px dashed var(--sudoku-check);
  outline-offset: -2px;
}

.sudoku-cell__flag {
  position: absolute;
  top: 0;
  right: 1px;
  font-size: 0.55em;
  line-height: 1;
  color: var(--sudoku-conflict);
}

.sudoku-cell__flag--check {
  color: var(--sudoku-check);
  right: auto;
  left: 1px;
}

.sudoku-cell__digit {
  line-height: 1;
}

/* NOTES SCALE WITH THE CELL, NOT WITH THE ROOT FONT SIZE (Codex PM OQ-S-05),
   and the honest consequence is that at 200% text they are small relative to
   the rest of the page. The mitigation is structural rather than visual: a
   note's POSITION identifies it — 1 is always top-left, 9 always
   bottom-right — and the cell's accessible name states every note it holds,
   so a player who cannot read the marks loses nothing a screen reader would
   not tell them. */
.sudoku-cell__notes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  width: 100%;
  height: 100%;
  font-family: var(--font-body);
  /* 0.38em, not the 0.34em first written: at 0.34 the pencil marks were
     legible only on a large screen, and the whole point of scaling them with
     the CELL rather than the root font size is that they stay proportionate to
     the square they live in. Found by looking at sudoku-play-notes.png. */
  font-size: 0.38em;
  font-weight: 600;
  color: var(--sudoku-note-ink);
  line-height: 1;
}

.sudoku-cell__note {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* The hint highlight. The unit is a wash, the supporting cells are the
   evidence and the target is the conclusion — three distinct treatments,
   because a hint that highlighted everything the same way would not be
   explaining anything.
   ===================================================================
   THE TARGET GAINED AN OUTLINE AFTER LOOKING AT sudoku-hint.png. A tint alone
   was the whole treatment, and on an EMPTY cell — which a placement hint's
   target always is — a light wash on a near-white background was invisible at
   a phone's scale. The hint said "only 2 can go there" and pointed at nothing
   a reader could find. TB-S-09 passed throughout, because it asserts the
   `data-hint` attribute rather than whether a person can see the result; the
   attribute was correct all along.

   The outline also makes the highlight legible without colour, which the tint
   alone was not — so this is an accessibility improvement as much as a visual
   one. */
.sudoku-cell--hint-unit {
  background: var(--sudoku-hint-unit);
}

.sudoku-cell--hint-support {
  background: var(--sudoku-hint-support);
  outline: 2px dashed var(--sudoku-rule);
  outline-offset: -2px;
}

.sudoku-cell--hint-target {
  background: var(--sudoku-hint-target);
  outline: 3px solid var(--sudoku-hint-target-edge);
  outline-offset: -3px;
}

.sudoku-cell--given.sudoku-cell--hint-unit,
.sudoku-cell--given.sudoku-cell--hint-support {
  /* A given keeps its own weight and ink; only the wash changes. */
  color: var(--sudoku-ink);
}

/* --- the number pad --------------------------------------------------
   EVERY COMMIT PATH IS HERE, and every button is at or above 44 x 44px. A
   single row of nine 44px buttons needs 396px and does not fit at 320px; a
   3 x 3 pad does, with room for Notes and Erase beside it. */

.sudoku-pad {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: flex-start;
}

.sudoku-pad__digits {
  display: grid;
  grid-template-columns: repeat(3, minmax(44px, 1fr));
  gap: var(--space-2);
  flex: 1 1 160px;
  max-width: 240px;
}

.sudoku-digit {
  position: relative;
  min-height: 48px;
  min-width: 44px;
  padding: var(--space-1);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-ink);
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  cursor: pointer;
}

/* AN EXHAUSTED DIGIT: a tick glyph AND reduced opacity AND the accessible
   name. It stays OPERABLE and refuses with an announcement, because disabling
   a control a player is mid-way through reaching for is worse than refusing
   it. */
.sudoku-digit--exhausted {
  opacity: 0.55;
}

.sudoku-digit__mark {
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 0.7rem;
  line-height: 1;
}

.sudoku-pad__actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  flex: 0 0 auto;
}

/* --- the side column ------------------------------------------------- */

.sudoku-side {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

/* A TWO-COLUMN GRID, not a wrapping flex row.
   Found by looking at sudoku-hint.png: with the tier name "Pairs" in the first
   value, the flex row fitted "Puzzle Pairs Squares still empty" on one line and
   pushed the bare number "59" onto the next, so the second label and its value
   were separated and the row read as one run-on sentence. Block's version works
   because its values are one or two digits; a technique name is not.
   A grid keeps every label with its own value whatever either one says. */
/* THE TWO-COLUMN STATS ROW, AND THE MINIMUM IT MUST NOT CARRY.

   `auto 1fr` reads as "label takes what it needs, value takes the rest", and
   that is what it does until the text grows. Both tracks carry an AUTOMATIC
   MINIMUM: a non-`fr` `auto` track is at least its items' min-content, and
   `1fr` is `minmax(auto, 1fr)`, so the value track is at least the widest
   unbreakable word its values contain. Once those two minima together exceed
   the column the grid sits in, the grid cannot shrink — nothing in the track
   sizing is permitted to — so it pushes the whole page sideways instead.

   MEASURED, NOT REASONED ABOUT. The grid's own min-content requirement at
   320px was 133px at 100% text, 192px at 150% and 251px at 200%, against a
   288px container. Chromium fitted at every size and reported no overflow at
   all, which is exactly why this shipped. Gecko and WebKit, whose fallback
   metrics for the heading font are wider, needed about 323px at 200% — a 19px
   horizontal page scroll on four of the six browser projects, with
   `sudoku-tier-name` and `sudoku-empty` both reported at right=339.

   The correction is two changes and no compromises:

     * `fit-content(180px)` on the label track. `fit-content(X)` is
       min(max-content, X), so the labels still size to their own content
       exactly as before wherever that fits inside 180px — which at 100% text
       it does, at every supported width, so the default layout is unchanged to
       the pixel. Past that the label stops growing and the value keeps a
       usable share instead of being squeezed to nothing. 180px is not
       arbitrary: the widest label renders at 175.25px at 100% text, so the cap
       clears it and binds only when the text is larger than the design assumed.

     * `minmax(0, 1fr)` on the value track, plus `min-width: 0` on the cells,
       removes the content-derived floor. The grid's minimum is now its gap —
       16px at every text size, down from 251px — so it fits its container in
       any engine, whatever that engine thinks the heading font measures.

   `overflow-wrap: break-word` is the backstop for a single word wider than its
   cell. Nothing is hidden, truncated, scaled down or scrolled: every label and
   every value is rendered in full and simply wraps a line sooner. The values
   stay right-aligned against the same right edge they always had, so nothing
   moves for the reader. TB-S-31 asserts the minimum directly, and NC-S-34
   removes it. */
.sudoku-stats {
  display: grid;
  grid-template-columns: fit-content(180px) minmax(0, 1fr);
  gap: var(--space-1) var(--space-3);
  margin: 0;
  align-items: baseline;
}

.sudoku-stats > dt,
.sudoku-stats > dd {
  min-width: 0;
  overflow-wrap: break-word;
}

.sudoku-stats dd {
  text-align: right;
}

.sudoku-stat__label {
  font-weight: 600;
  color: var(--color-ink-muted);
}

.sudoku-stat__value {
  margin: 0;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.15rem;
}

.sudoku-controls {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.sudoku-button {
  /* An explicit rem size, for the reason Phase 3 Hardening measured on
     `.block-button`: the global `button` reset sets the family but not the
     size, so a button label would stay at the UA default while every other
     piece of text grew with the browser's text-size setting. */
  font-size: 1rem;
  min-height: 44px;
  min-width: 44px;
  padding: var(--space-2) var(--space-3);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-ink);
  font-weight: 600;
  cursor: pointer;
}

.sudoku-button--primary {
  border-color: var(--color-sudoku-accent-on-bg);
  background: var(--color-sudoku-accent-on-bg);
  color: var(--color-surface);
}

/* Notes mode is an EXPLICIT toggle with aria-pressed, and its on-state is
   carried by the border and the background as well as by the attribute. */
.sudoku-button--on {
  border-color: var(--color-sudoku-accent-on-bg);
  border-width: 3px;
}

.sudoku-button:disabled {
  opacity: 0.5;
  cursor: default;
}

.sudoku-assist {
  border: 2px solid var(--color-border);
  border-left-width: 6px;
  border-left-color: var(--color-sudoku-accent-on-bg);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.sudoku-assist__title {
  margin: 0;
  font-size: 1.1rem;
}

.sudoku-assist p {
  margin: 0;
}

.sudoku-assist__technique {
  font-family: var(--font-heading);
  font-weight: 700;
}

.sudoku-assist__count {
  color: var(--color-ink-muted);
  font-size: 0.9rem;
}

.sudoku-save-note,
.sudoku-help {
  margin: 0;
  font-size: 0.9rem;
  color: var(--color-ink-muted);
}

/* Two disclosures in a row ran together into one block on the completion
   surface — "These numbers are on this screen only…" and "Your finished puzzle
   has been removed from this device." read as a single paragraph. Found by
   looking at sudoku-complete.png. */
.sudoku-complete > p + p,
.sudoku-complete > .sudoku-notice {
  margin-top: var(--space-2);
}

/* Visually hidden, audibly unchanged — the H2-08 lesson: a VISIBLE live
   region printed the completion facts twice on the same surface. */
.sudoku-live {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.sudoku-confirm,
.sudoku-complete,
.sudoku-recovery__lead {
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  padding: var(--space-3);
}

.sudoku-confirm__title,
.sudoku-complete__title {
  margin-top: 0;
  font-size: 1.25rem;
}

.sudoku-confirm__actions,
.sudoku-complete__actions,
.sudoku-recovery__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.sudoku-summary {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.sudoku-summary__row {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  border-bottom: 1px solid var(--color-border);
  padding-bottom: var(--space-1);
}

.sudoku-summary__row dt {
  font-weight: 600;
  color: var(--color-ink-muted);
}

.sudoku-summary__row dd {
  margin: 0;
  font-family: var(--font-heading);
  font-weight: 700;
}

/* A CODE-NATIVE CELEBRATION: three rays of the game's own accent, drawn in
   CSS, animated only where motion is welcome. No trophy, no badge, no rank,
   no star, no new art asset — and nothing that claims anything about the
   player beyond the fact that the puzzle is solved. */
.sudoku-complete__burst {
  display: flex;
  justify-content: center;
  gap: var(--space-2);
  height: 12px;
  margin-bottom: var(--space-2);
}

.sudoku-complete__ray {
  display: block;
  width: 26px;
  height: 6px;
  border-radius: 3px;
  background: var(--color-sudoku-accent-on-bg);
  transform-origin: center;
}

@media (prefers-reduced-motion: no-preference) {
  .sudoku-complete__ray {
    animation: sudoku-ray 420ms ease-out;
  }
  .sudoku-complete__ray:nth-child(2) {
    animation-delay: 60ms;
  }
  .sudoku-complete__ray:nth-child(3) {
    animation-delay: 120ms;
  }
}

@keyframes sudoku-ray {
  from {
    opacity: 0;
    transform: scaleX(0.2);
  }
  to {
    opacity: 1;
    transform: scaleX(1);
  }
}

@media (min-width: 720px) {
  .sudoku-layout {
    flex-direction: row;
    align-items: flex-start;
  }
  .sudoku-board {
    flex: 0 0 480px;
  }
  .sudoku-side {
    flex: 1 1 0;
  }
}

/* SHORT LANDSCAPE, handled the way Phase 3 established rather than with a
   table of measured chrome constants.

   The view is a full-height column, the layout row takes whatever height is
   left after the back link, the heading and any notice, and the board is as
   tall as that row and square. Nothing has to know how tall a notice is, so
   no notice of any length can push the board off screen, and the pad sits
   BESIDE the board rather than above it. The side column scrolls within its
   own column if its content is taller than the row, so the board is never the
   thing that gives way. */
@media (orientation: landscape) and (max-height: 520px) {
  .view--sudoku-play {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    padding-top: var(--space-2);
    padding-bottom: var(--space-2);
    overflow: hidden;
  }
  .view--sudoku-play .back-link {
    min-height: 36px;
    flex: 0 0 auto;
  }
  /* THE COMPRESSION ABOVE BUYS VERTICAL ROOM FOR A SQUARE BOARD that has to fit
     in 320px of height. The pack-failure surface has no board, so it pays that
     cost for nothing and drops a real control under AS-08's 44px floor —
     measured at 36px on that surface at both 568x320 and 640x340 (Phase 4
     Hardening, HS-16). `data-pack-failure` is already on that root, so telling
     the two apart needs nothing new. */
  .view--sudoku-play[data-pack-failure] .back-link {
    min-height: 44px;
  }
  .sudoku-title {
    font-size: 1.25rem;
    margin-bottom: var(--space-1);
    flex: 0 0 auto;
  }
  .sudoku-notice {
    font-size: 0.9rem;
    padding: var(--space-1) var(--space-2);
    margin-bottom: var(--space-2);
    flex: 0 0 auto;
  }
  .sudoku-chooser {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
  }
  .sudoku-layout {
    flex: 1 1 auto;
    min-height: 0;
    flex-direction: row;
    align-items: stretch;
    gap: var(--space-3);
  }
  /* The board takes its height from the layout row and its width from its own
     aspect-ratio, AS THE FLEX ITEM ITSELF — no wrapper between it and the
     layout row. Phase 3 measured what a wrapper costs here: WebKit sized it
     from the board's intrinsic width rather than from the square the board
     rendered at, and the board overflowed the box reserved for it. */
  .sudoku-board {
    flex: 0 0 auto;
    min-height: 0;
    height: 100%;
    width: auto;
    max-width: none;
    max-height: 480px;
    margin: 0;
  }
  .sudoku-side {
    flex: 1 1 0;
    min-width: 0;
    min-height: 0;
    overflow-y: auto;
    gap: var(--space-1);
  }
  .sudoku-pad {
    flex: 0 0 auto;
    min-height: 0;
  }
  .sudoku-pad__digits {
    max-width: 200px;
  }
  .sudoku-stats,
  .sudoku-controls {
    flex: 0 0 auto;
  }
  .sudoku-stats {
    gap: 2px var(--space-3);
  }
  .sudoku-stat__value {
    font-size: 1rem;
  }
  /* THE TWO INFORMATIONAL PARAGRAPHS LEAVE THE FLOW AND STAY IN THE
     ACCESSIBLE TREE — Phase 3 Hardening's correction, applied here in
     advance. `display: none` would remove them from the accessibility tree as
     surely as from the page, and the operating instructions and the storage
     disclosure are exactly the two things a player who cannot see the layout
     most needs. Visually hidden instead, the same recipe `.sudoku-live` uses,
     so neither contributes a pixel to the column that has to hold the board's
     controls. */
  .sudoku-help,
  .sudoku-save-note {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    border: 0;
  }
}

@media (orientation: landscape) and (max-height: 400px) {
  .view--sudoku-play {
    padding-top: var(--space-1);
  }
  .sudoku-title {
    font-size: 1.1rem;
  }
}

/* Sudoku UX-001A: tactile assistance controls, accessible on narrow screens. */
.sudoku-assistance {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  width: 100%;
}
.sudoku-assistance__title {
  flex-basis: 100%;
  font-weight: 700;
  font-family: var(--font-heading);
  color: var(--color-ink);
}
.sudoku-assistance .sudoku-option {
  min-height: 44px;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-md);
}
.sudoku-assistance .sudoku-option[aria-pressed='true'] {
  border-color: var(--color-sudoku-accent-on-bg);
  box-shadow: inset 0 0 0 1px var(--color-sudoku-accent-on-bg);
}
.sudoku-assistance .sudoku-option[aria-pressed='true']::before {
  content: '✓ ';
  font-weight: 800;
}
@media (max-width: 440px) {
  .sudoku-assistance .sudoku-option {
    flex: 1 1 calc(50% - var(--space-2));
  }
}
