/*
 * 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;

  --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;
  }
}

*,
*::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 {
  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;
  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;
  }
}
