@import "tokens.css";

/* LEGACY / TRANSITIONAL light theme (pre-brand MVP).
 * These values predate the ratified TactiMage dark-fantasy brand and are kept
 * ONLY so the current MVP keeps rendering. They are scheduled for retirement as
 * components migrate to the semantic brand tokens (see tokens.css) in Steps 2.3
 * (Dashboard) and 2.4 (Training). Do NOT add new light values here; consume the
 * semantic tokens from tokens.css instead. (Step 2.2 = token layer only.) */
:root {
  --bg: #f4efe4;
  --surface: #fffaf0;
  --surface-strong: #f9e8c7;
  --text: #1f2933;
  --muted: #667085;
  --primary: #2c3e5c;
  --primary-soft: #dae3f3;
  --accent: #b7892c;
  --accent-soft: #f4dfb4;
  --success: #247857;
  --danger: #b42318;
  --light-square: #ead6ad;
  --dark-square: #8c6840;
  --last-move: rgba(183, 137, 44, 0.55);
  --target: rgba(36, 120, 87, 0.55);
  --shadow: 0 24px 80px rgba(44, 62, 92, 0.16);
  --radius: 24px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

/* Step 2.3: the global shell adopts the dark-fantasy brand tokens (the
 * Dashboard + canvas migrate now; the training INTERIOR — board, puzzle list,
 * info panel — keeps its legacy light styling on this dark canvas until 2.4). */
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text-primary);
  font-family: var(--font-ui);
  background:
    radial-gradient(circle at top left, rgba(124, 77, 255, 0.16), transparent 38rem),
    radial-gradient(circle at bottom right, rgba(245, 166, 35, 0.08), transparent 42rem),
    var(--bg-canvas);
}

button {
  font: inherit;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2rem;
  align-items: end;
  max-width: 1180px;
  margin: 0 auto;
  padding: 3rem 1.25rem 1.5rem;
}

.eyebrow {
  margin: 0 0 0.5rem;
  color: var(--accent-secondary);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  color: var(--text-primary);
  line-height: 1.05;
}

h1 {
  max-width: 820px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.2rem, 7vw, 5.5rem);
  letter-spacing: -0.06em;
}

h2 {
  font-size: clamp(1.35rem, 3vw, 2rem);
}

.hero-copy {
  max-width: 720px;
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: 1.12rem;
  line-height: 1.7;
}

/* =============================================================================
 * Step 2.4 — Training interior, re-skinned to the dark-fantasy tokens.
 * Every rule below consumes ONLY semantic tokens from tokens.css (no raw hex,
 * except piece-glyph legibility halos which are intentional rgba outlines).
 * Layout geometry is unchanged from the MVP; only appearance + motion hooks are
 * added. No game logic — chess truth comes from the core via the providers.
 * ========================================================================== */
.progress-card,
.panel {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  box-shadow: var(--elev-1);
  color: var(--text-primary);
}

.progress-card {
  min-width: 180px;
  padding: 1.25rem;
  text-align: center;
}

.progress-number {
  display: block;
  color: var(--accent-secondary);
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 900;
}

.progress-label {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 1.5rem;
  max-width: 1180px;
  margin: 0 auto;
  padding: 1rem 1.25rem 3rem;
}

.panel {
  padding: 1rem;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1rem;
}

.trainer-heading {
  align-items: start;
}

/* S17: the trainer heading's control cluster — „Neu starten" + „Überspringen". */
.trainer-heading-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}

.puzzle-list {
  display: grid;
  gap: 0.65rem;
}

.puzzle-button,
.ghost-button,
.secondary-button {
  cursor: pointer;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition:
    transform var(--transition-fast) ease,
    border-color var(--transition-fast) ease,
    background var(--transition-fast) ease;
}

.puzzle-button:hover,
.ghost-button:hover,
.secondary-button:hover {
  transform: translateY(-1px);
}

.puzzle-button:focus-visible,
.ghost-button:focus-visible,
.secondary-button:focus-visible {
  outline: 3px solid var(--accent-primary);
  outline-offset: 2px;
}

.puzzle-button {
  display: grid;
  width: 100%;
  gap: 0.25rem;
  padding: 0.85rem;
  color: var(--text-primary);
  background: var(--bg-surface-raised);
  text-align: left;
}

.puzzle-button.active {
  border-color: var(--accent-primary);
  background: linear-gradient(135deg, var(--accent-primary-deep), var(--bg-surface-raised) 75%);
}

.puzzle-button.solved .puzzle-title::after {
  content: " ✓";
  color: var(--state-success);
}

.puzzle-title {
  font-weight: 800;
}

.puzzle-meta {
  color: var(--text-muted);
  font-size: 0.88rem;
}

.ghost-button,
.secondary-button {
  padding: 0.62rem 0.8rem;
  color: var(--text-primary);
  background: var(--bg-surface-raised);
  font-weight: 700;
}

.secondary-button {
  background: var(--accent-primary);
  color: var(--text-primary);
  border-color: transparent;
}

/* S18: the graduated-hint control reads as a distinct "coaching" affordance —
 * an outline (not filled) secondary, gold-tinted, calm. Disabled = exhausted
 * (Stage 3, "Lösung gezeigt"). No motion. */
.hint-button {
  background: transparent;
  color: var(--accent-secondary);
  border-color: var(--accent-secondary);
}

.hint-button:disabled {
  color: var(--text-muted);
  border-color: var(--border-subtle);
  cursor: default;
}

/* S13 button row: lay control buttons in a wrapping flex row and normalize the
 * primary button's standalone width:100%/margin so it sits inline beside the
 * outline (secondary) actions instead of dominating the row. */
.control-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}
.control-row .primary-button,
.control-row .outline-button,
.control-row .secondary-button {
  width: auto;
  margin: 0;
  flex: 0 1 auto;
}

/* Decorative brand icon inside action buttons (Neues Spiel / Aufgeben). */
.btn-icon {
  height: 1.35em;
  width: auto;
  vertical-align: -0.28em;
  margin-right: 0.45rem;
}

/* Icon-only "Brett drehen" button in the panel heading (compact redesign): a
 * square glyph button instead of the wider text button. */
.flip-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.4rem;
  height: 2.4rem;
  padding: 0;
  font-size: 1.2rem;
  line-height: 1;
  border-radius: 50%;
  flex: 0 0 auto;
}

/* S13 outline (tertiary) button — subdued, bordered, transparent. Used for
 * destructive/secondary actions (Aufgeben / resign / agreed draw) so they read
 * as clearly lower-weight than the primary "Neues Spiel" button. */
.outline-button {
  cursor: pointer;
  padding: 0.62rem 0.8rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-muted);
  font-weight: 700;
  transition:
    transform var(--transition-fast) ease,
    border-color var(--transition-fast) ease,
    color var(--transition-fast) ease;
}
.outline-button:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: var(--state-danger, #d9534f);
  color: var(--text-primary);
}
.outline-button:focus-visible {
  outline: 3px solid var(--accent-primary);
  outline-offset: 2px;
}
.outline-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Adaptive-loop CTA (Step 4.1): "Nächste Aufgabe". A prominent accent button that
 * appears once a puzzle is solved. */
.primary-button {
  cursor: pointer;
  width: 100%;
  margin: 0.4rem 0 0.2rem;
  padding: 0.8rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  color: var(--text-primary);
  background: linear-gradient(135deg, var(--accent-secondary, var(--accent-primary)), var(--accent-primary));
  font-weight: 800;
  transition:
    transform var(--transition-fast) ease,
    filter var(--transition-fast) ease;
}

.primary-button:hover {
  transform: translateY(-1px);
  filter: brightness(1.06);
}

.primary-button:focus-visible {
  outline: 3px solid var(--accent-primary);
  outline-offset: 2px;
}

/* Progress HUD (Step 4.1) — rating / streak / freeze / daily-goal surface that
 * replaces the old curated puzzle-list sidebar. Pure presentation. */
.progress-hud {
  display: grid;
  gap: 1rem;
}

.hud-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.65rem;
  margin: 0;
}

.hud-stat {
  display: grid;
  gap: 0.15rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-surface-raised);
}

.hud-stat dt {
  color: var(--text-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.hud-stat dd {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-primary);
}

.hud-stat .hud-unit {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

.hud-rating {
  border-color: var(--accent-primary);
  background: linear-gradient(135deg, var(--accent-primary-deep), var(--bg-surface-raised) 78%);
}

.hud-goal {
  display: grid;
  gap: 0.35rem;
}

.hud-goal-label {
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.hud-goal-select {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  background: var(--bg-surface-raised);
  font: inherit;
  font-weight: 700;
}

.hud-goal-select:focus-visible {
  outline: 3px solid var(--accent-primary);
  outline-offset: 2px;
}

/* All-puzzles-solved banner (STL-2): shown when selection returns the
 * all-solved band so repeats are never silent. */
.all-solved-note {
  margin: 0;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-md);
  background: var(--accent-primary-deep);
  color: var(--text-primary);
  font-weight: 700;
}

.trainer {
  display: grid;
  grid-template-columns: minmax(320px, 620px) minmax(280px, 1fr);
  gap: 1.5rem;
  align-items: start;
}

/* Single-column layout (S11: the puzzle column was removed — the progress HUD
 * moved into the Lernpfad overlay — so all surfaces use one centered content
 * column). Without this, grid auto-placement would drop `.trainer` into the
 * former fixed 320px puzzle track, collapsing the board to half size. Dropping
 * the puzzle column gives the board+panel group the full centered container. The
 * desktop two-column board+info centering is guarded to >980px so the existing
 * ≤980px stacking rule still applies. */
.layout.single {
  grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 981px) {
  .layout.single .trainer {
    /* Board at trainer size (≤620px); info/controls panel beside it, the whole
     * group centered in the container (justify-content) instead of the panel
     * column stretching to 1fr. */
    grid-template-columns: minmax(320px, 620px) minmax(280px, 360px);
    justify-content: center;
  }
}

.board-wrap {
  width: min(100%, 620px);
  aspect-ratio: 1;
  border-radius: var(--radius-lg);
  transition: box-shadow var(--transition-base) ease;
  /* Positioning context for the 3D overlay canvas (Step 3.4). Inert for the 2D
   * rungs, which append no canvas. */
  position: relative;
}

/* Board-frame reactions: app.js toggles these on #board-root from CORE-derived
 * status (reading, not computing). A solved puzzle gets a gold aura; an in-check
 * position gets an amber ring. Reduced motion keeps the static color, drops the
 * animation (see the reduced-motion block). */
.board-wrap.is-solved {
  box-shadow: var(--glow-gold);
  animation: board-solved var(--aura-pulse-duration) ease-in-out 2;
}

.board-wrap.is-check {
  box-shadow: var(--glow-check);
}

/* Win announcement overlay — shown over the board on checkmate / resignation.
 * Positioned over the board box (first grid cell of .trainer). Presentation only;
 * app.js toggles [hidden] from the core-derived status. */
.trainer { position: relative; }
.win-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: min(100%, 620px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  padding: 1rem;
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--color-obsidian) 70%, transparent);
  z-index: 5;
}
.win-overlay[hidden] { display: none; }

/* --- Under-board control bar (Task 3) ------------------------------------- */
/* The board column: board + win overlay + the bar, stacked. Caps at the board
 * width so the bar tracks the board (not the info panel). Positioning context for
 * the win overlay (absolute, 620px square) → the overlay sits over the board at the
 * top of the stack, never over the bar below it. */
.board-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  position: relative;
  width: min(100%, 620px);
}
/* Transparent click-shield over the board while reviewing (Task 1). Above the
 * board, below the win overlay (z-index 5). Catches the board interaction the
 * disabled review squares would otherwise swallow → opens the review-action dialog. */
.review-shield {
  position: absolute;
  top: 0;
  left: 0;
  width: min(100%, 620px);
  aspect-ratio: 1;
  z-index: 4;
  cursor: pointer;
}
.review-shield[hidden] { display: none; }

.board-controls {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--elev-1);
  overflow: hidden;
}
.board-controls[hidden] { display: none; }
.board-controls__header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
}
.board-controls__title {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}
.board-controls__status {
  margin-left: auto;
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.board-controls__toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: transform var(--transition-fast), color var(--transition-fast);
}
.board-controls__toggle:hover { color: var(--text-primary); }
.board-controls__toggle:focus-visible { outline: 3px solid var(--accent-primary); outline-offset: 2px; }
.board-controls[data-collapsed="true"] .board-controls__toggle { transform: rotate(180deg); }
.board-controls__body {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border-top: 1px solid var(--border-subtle);
}
.board-controls[data-collapsed="true"] .board-controls__body { display: none; }
.board-controls__zone { display: flex; align-items: center; gap: var(--space-3); }
.board-controls__zone--left { justify-self: start; }
.board-controls__zone--center { justify-self: center; }
.board-controls__zone--right { justify-self: end; }
.board-controls__zone .move-nav { margin: 0; }
.board-controls__zone .setup-field { margin: 0; }

/* Mobile: stack the three zones (nav first via source order is center — but on a
 * narrow screen a single centered column reads fine), full-width bar. */
@media (max-width: 720px) {
  .board-controls__body {
    grid-template-columns: 1fr;
    justify-items: center;
  }
  .board-controls__zone {
    justify-self: center;
    flex-wrap: wrap;
    justify-content: center;
  }
  .board-controls__zone--left:empty { display: none; }
}

.win-card {
  position: relative;
  text-align: center;
  background: var(--bg-surface-raised);
  border: 1px solid color-mix(in srgb, var(--accent-secondary) 45%, transparent);
  border-radius: var(--radius-md);
  padding: 1.75rem 2.25rem;
  box-shadow: var(--glow-gold);
  animation: win-pop var(--transition-base) ease-out;
}
.win-trophy { font-size: 2.75rem; line-height: 1; }
.win-title {
  font-size: var(--text-h2);
  font-weight: 700;
  color: var(--accent-secondary);
  margin-top: 0.25rem;
}
.win-sub {
  font-size: var(--text-body);
  color: var(--text-primary);
  margin-top: 0.25rem;
}
.win-dismiss {
  position: absolute;
  top: 0.35rem;
  right: 0.5rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1;
  padding: 0.25rem;
  cursor: pointer;
}
.win-dismiss:hover { color: var(--text-primary); }
@keyframes win-pop {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* --- Resign confirmation modal (replaces native window.confirm) ----------- */
/* Full-screen fixed overlay (unlike .win-overlay, which is scoped to the board);
 * a centered card asks the destructive question with a clear cancel default. */
.confirm-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: color-mix(in srgb, var(--color-obsidian) 72%, transparent);
  z-index: 50;
}
.confirm-overlay[hidden] { display: none; }
.confirm-card {
  position: relative;
  width: min(100%, 24rem);
  text-align: center;
  background: var(--bg-surface-raised);
  border: 1px solid color-mix(in srgb, var(--accent-secondary) 45%, transparent);
  border-radius: var(--radius-md);
  padding: 1.75rem 1.75rem 1.5rem;
  box-shadow: var(--glow-gold);
  animation: win-pop var(--transition-base) ease-out;
}
.confirm-illustration {
  display: block;
  width: 5.5rem;
  height: 5.5rem;
  object-fit: contain;
  margin: 0 auto 0.5rem;
}
.confirm-illustration[hidden] { display: none; }
.confirm-title {
  margin: 0;
  font-size: var(--text-h3, 1.4rem);
  font-weight: 700;
  color: var(--accent-secondary);
}
.confirm-text {
  margin: 0.4rem 0 1.25rem;
  color: var(--text-primary);
  font-size: var(--text-body, 0.95rem);
}
.confirm-actions {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
}
.confirm-actions button { flex: 1 1 0; }
/* Destructive confirm: tint the "Aufgeben" primary button toward a warning hue. */
.confirm-danger {
  background: var(--danger, #b3402f);
  background-image: none;
}
/* Multi-option confirm variants. --stack: vertical list for long labels
 * (review-action: Ab hier weiterspielen / Zum aktuellen Stand / Abbrechen). */
.confirm-actions--stack { flex-direction: column; }
.confirm-actions--stack button { flex: 1 1 auto; width: 100%; }
/* --split: two equal choices on one row, a ghost cancel wrapping full-width below
 * (fast-forward: Springen | Animiert / Abbrechen). */
.confirm-actions--split { flex-wrap: wrap; }
.confirm-actions--split .confirm-choice { flex: 1 1 40%; }
.confirm-actions--split .confirm-action-ghost { flex: 1 1 100%; }
.confirm-action-ghost {
  background: transparent;
  background-image: none;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
}
.confirm-action-ghost:hover { color: var(--text-primary); border-color: var(--accent-primary); }
@media (prefers-reduced-motion: reduce) {
  .confirm-card { animation: none; }
}

.board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: 100%;
  height: 100%;
  overflow: hidden;
  border: 10px solid var(--bg-surface-raised);
  border-radius: var(--radius-lg);
  box-shadow: var(--elev-2);
  background: var(--bg-surface-raised);
  /* Query container for piece sizing: pieces size in `cqi` relative to THIS
   * board's own width, so they scale with the board, not the viewport. */
  container-type: inline-size;
}

.square {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.square.light {
  background: var(--board-light);
}

.square.dark {
  background: var(--board-dark);
}

.square.selected {
  outline: 4px solid var(--accent-primary);
  outline-offset: -4px;
  box-shadow: var(--glow-select);
  animation: square-pulse var(--aura-pulse-duration) ease-in-out infinite;
}

/* S2 accessibility: visible keyboard-focus indicator for board squares.
 * `--accent-primary` (#7C4DFF) clears ≥3:1 on the light square (3.54:1) but
 * NOT the dark square (2.04:1) — the same "no single colour on both squares"
 * constraint DESIGN_SYSTEM §7 hit for coordinates. So we reuse that verified
 * opposite-square split (dark-on-light / light-on-dark → 7.21:1 on BOTH).
 * Dashed + inset + high z-index keeps it distinct from the solid `.selected`
 * glow and the `.legal-target` dot. Static (no animation) → motion-safe. */
.square:focus-visible {
  outline: 3px dashed var(--board-coord-on-light);
  outline-offset: -3px;
  z-index: 3;
}

.square.dark:focus-visible {
  outline-color: var(--board-coord-on-dark);
}

.square.last-move::before,
.square.legal-target::after {
  position: absolute;
  content: "";
  inset: 0;
  pointer-events: none;
}

.square.last-move::before {
  background: var(--board-last-move);
}

.square.legal-target::after {
  inset: 34%;
  border-radius: var(--radius-pill);
  background: var(--board-legal-hint);
  animation: dot-in var(--transition-base) ease-out both;
}

/* S18 graduated-hint markers — presentation-only highlight of the KNOWN
   solution's from/to squares (board.js paints them; no legality). Static rings
   (no keyframe) so they are reduced-motion-safe by construction: gold = "this
   piece" (Stage 1), blue coaching cue = "go here" (Stage 2). */
.square.hint-from {
  box-shadow: inset 0 0 0 3px var(--accent-secondary);
}

.square.hint-to {
  box-shadow: inset 0 0 0 4px var(--state-info);
}

/* B-7: the engine best-move readout line (vs-computer / free-play). Reuses the
 * .feedback base; a left accent border ties it to the from/to markers. Renderer-
 * independent (shown in 2D and 3D, where the board markers don't render). */
.hint-line {
  border-left: 3px solid var(--accent-secondary);
  padding-left: 0.6rem;
}

/* B-7 follow-up: the 2D best-move hint arrow. board.js appends an <svg> child of
 * `.board` (viewBox 0 0 100 100, non-uniform scale) spanning the 8×8 grid; the
 * shaft + head are drawn in 0–100% board space so the arrow follows board flip
 * automatically (the helper mirrors the coordinates). pointer-events:none so it
 * never blocks a square click; the square markers stay underneath. Uses the hint
 * accent (the same `--state-info` the `.hint-to` marker uses). Static — no
 * animation — so it is reduced-motion-safe by construction. */
.hint-arrow {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 4;
  overflow: visible;
}
.hint-arrow-shaft {
  stroke: var(--state-info);
  stroke-width: 1.7;
  stroke-linecap: round;
  opacity: 0.92;
}
.hint-arrow-head {
  fill: var(--state-info);
  opacity: 0.92;
}

/* "Schach" cue: the checked king's square glows red (board.js sets .in-check from
 * the core's check fact — the view computes no legality). Box-shadow only so it
 * never collides with the ::before/::after overlays; static = reduced-motion-safe. */
.square.in-check {
  box-shadow: inset 0 0 0 4px rgba(224, 50, 46, 0.95), inset 0 0 22px 5px rgba(224, 50, 46, 0.55);
  z-index: 2;
}

/* S26 "Schach-Bedrohung": the attack path (the threatening piece + the squares
 * between it and the king) gets a SOFTER red than the king's own square, so the
 * checked king (.in-check) stays the dominant cue while the player can still trace
 * which piece delivers the check. board.js sets .check-path from the CORE-supplied
 * checkThreatSquares (no UI legality). Box-shadow only (overlay-safe, static =
 * reduced-motion-safe). */
.square.check-path {
  box-shadow: inset 0 0 0 3px rgba(224, 50, 46, 0.5), inset 0 0 16px 3px rgba(224, 50, 46, 0.28);
  z-index: 1;
}

/* The 'check-threat' setting (default ON). When the user turns it OFF the body
 * gains .check-threat-hidden and the whole threat tint — king square and path —
 * is suppressed (the 3D markers are gated separately via the showCheck flag). */
body.check-threat-hidden .square.in-check,
body.check-threat-hidden .square.check-path {
  box-shadow: none;
  z-index: auto;
}

.piece {
  /* Centre the piece independently of the square. The `.square` is a native
   * <button>, and Chromium does NOT honour grid/flex centre-alignment for a
   * button's children (they pin to the top-left of the button content box), so
   * we centre the piece ourselves over the position:relative square. */
  position: absolute;
  top: 50%;
  left: 50%;
  /* Centre the piece over its position:relative square. The committed-move
   * slide is driven by the CSS adapter via the Web Animations API, animating
   * this `transform` from the origin offset back to centre over
   * --piece-move-duration (the Settings-tunable pace). WAAPI is used instead of
   * a CSS `transition`, because Chromium does NOT fire a transform transition
   * when only an unregistered var() the transform references changes. */
  transform: translate(-50%, -50%);
  z-index: 2;
  /* Board-relative sizing via container-query units: one cell ≈ 12.5cqi, so
   * 11cqi leaves a small margin and the glyph/image never overflows the cell —
   * on any viewport. (Was `clamp(2rem, 7vw, 4.8rem)`, keyed to the viewport,
   * which overflowed the 59px cell on wide screens.) */
  /* S13: scaled by --piece-scale so pieces read calmer against coordinates and
   * markers; the PNG `img { width/height: 1em }` chain inherits this size. */
  font-size: calc(11cqi * var(--piece-scale));
  line-height: 1;
  /* Clicks always land on the square button, never an overflowing glyph edge. */
  pointer-events: none;
}

/* PNG piece images: size to match the glyph baseline so the board layout is
 * unaffected by the active piece-set (S5 reviewer note). object-fit: contain
 * keeps the image inside the cell without clipping. */
.piece img,
img.piece {
  width: 1em;
  height: 1em;
  object-fit: contain;
  display: block;
}

/* Legibility halos: white glyphs get a dark rim, black glyphs a light rim, so
 * both read on either square color (ANIMATION_CONTRACT legibility-first). */
.piece.w {
  color: var(--color-warm-ivory);
  text-shadow:
    0 1px 2px rgba(0, 0, 0, 0.55),
    0 0 3px rgba(0, 0, 0, 0.45);
}

.piece.b {
  color: var(--color-obsidian);
  text-shadow:
    0 1px 1px rgba(0, 0, 0, 0.4),
    0 0 3px rgba(242, 233, 208, 0.55);
}

/* The just-moved piece settles into place (slide handled by the keyframe). */
.square.last-move .piece {
  animation: piece-settle var(--transition-base) ease-out both;
}

/* Step 3.2/3.3 CSS-adapter per-piece FX (transient classes the adapter adds, then
 * removes on settle). Motion-only: they never obscure piece identity. Durations are
 * dedicated --fx-* tokens (Step 3.3) so reduced-motion zeroes them independently;
 * glows use drop-shadow (follows the silhouette, never a box). */
.piece.check-react {
  animation: piece-check-react var(--fx-react-duration) ease-in-out 2;
}

.piece.capture-fx {
  animation: piece-capture-fx var(--fx-react-duration) ease-out both;
}

.piece.promote-fx {
  animation: piece-promote-fx var(--fx-resolution-duration) ease-out both;
}

/* Step 3.3: victim dissipation (played on a transient ghost overlay clone) +
 * king-resolution FX for mate (victory winner / defeat loser). */
.piece.captured-fx {
  animation: piece-captured-fx var(--fx-dissolve-duration) ease-in both;
  pointer-events: none;
}

.piece.victory-fx {
  animation: piece-victory-fx var(--fx-resolution-duration) ease-out both;
}

.piece.defeat-fx {
  animation: piece-defeat-fx var(--fx-resolution-duration) ease-in both;
}

/* Step 3.3: piece-level selected pulse, riding the existing .square.selected
 * highlight (board.js owns selection — no JS change). Arcane-purple silhouette
 * glow; reads --aura-pulse-duration (zeroed under reduced motion → static glow). */
.square.selected .piece {
  animation: piece-selected-pulse var(--aura-pulse-duration) ease-in-out infinite;
}

@keyframes piece-selected-pulse {
  0%, 100% { filter: drop-shadow(0 0 3px var(--color-arcane-purple)); }
  50%      { filter: drop-shadow(0 0 8px var(--color-arcane-purple)); }
}

/* check_react: amber (--state-check-warning) aura + small shake (Step 3.3 fixes the
 * prior fire-gold colour, which collided with the gold victory cue). */
@keyframes piece-check-react {
  0%, 100% { transform: translate(-50%, -50%);            filter: none; }
  25%      { transform: translate(calc(-50% - 2px), -50%); filter: drop-shadow(0 0 8px var(--state-check-warning)); }
  75%      { transform: translate(calc(-50% + 2px), -50%); filter: drop-shadow(0 0 8px var(--state-check-warning)); }
}

@keyframes piece-capture-fx {
  0% { transform: translate(-50%, -50%) scale(1.18); }
  100% { transform: translate(-50%, -50%) scale(1); }
}

@keyframes piece-promote-fx {
  0%   { transform: translate(-50%, -50%) scale(0.5); opacity: 0.3; filter: drop-shadow(0 0 0 var(--color-fire-gold)); }
  60%  { filter: drop-shadow(0 0 10px var(--color-fire-gold)); }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; filter: drop-shadow(0 0 0 var(--color-fire-gold)); }
}

/* captured: magical dissipation — shrink + fade + arcane puff. The ghost clone is
 * fixed-positioned at the victim's former centre, so translate(-50%,-50%) centres it. */
@keyframes piece-captured-fx {
  0%   { opacity: 1; transform: translate(-50%, -50%) scale(1);    filter: none; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(0.55); filter: drop-shadow(0 0 8px var(--color-arcane-purple)) blur(1px); }
}

@keyframes piece-victory-fx {
  0%   { transform: translate(-50%, -50%) scale(1);    filter: drop-shadow(0 0 0 var(--color-fire-gold)); }
  40%  { transform: translate(-50%, -50%) scale(1.12); filter: drop-shadow(0 0 12px var(--color-fire-gold)); }
  100% { transform: translate(-50%, -50%) scale(1);    filter: drop-shadow(0 0 6px var(--color-fire-gold)); }
}

@keyframes piece-defeat-fx {
  0%   { transform: translate(-50%, -50%) rotate(0deg);  filter: none;                          opacity: 1; }
  100% { transform: translate(-50%, -50%) rotate(-8deg); filter: grayscale(0.7) brightness(0.6); opacity: 0.85; }
}

.coord {
  position: absolute;
  top: 0.22rem;
  left: 0.28rem;
  z-index: 2;
  font-size: 0.68rem;
  font-weight: 800;
}

/* Coordinate color uses the OPPOSITE square color so each clears AA (tokens). */
.square.light .coord {
  color: var(--board-coord-on-light);
}

.square.dark .coord {
  color: var(--board-coord-on-dark);
}

/* S13 edge-coordinate label nodes (rendered by board.js on the display-bottom
 * rank / left file). Inert by default — the Aus/Rand/Voll mode gating
 * (body[data-coords]) decides visibility. Baseline = hidden so the full
 * per-square `.coord` remains the active appearance until a mode is set. */
.coord-file,
.coord-rank {
  display: none;
}

/* Coach bubble: the trainer feedback string, re-skinned. Neutral by default;
 * the success variant marks a solved/correct beat. Color is never the only
 * signal — the text carries the verdict. */
.feedback {
  margin: 0 0 1rem;
  padding: 1rem;
  border-radius: var(--radius-md);
  border-left: 4px solid var(--accent-primary);
  background: var(--bg-surface-raised);
  color: var(--text-primary);
  line-height: 1.55;
}

.feedback.success {
  border-left-color: var(--state-success);
  background: linear-gradient(135deg, rgba(63, 185, 112, 0.18), var(--bg-surface-raised) 70%);
}

/* S7: computer-opponent surface. The "denkt …" line uses the accent; the error
 * line uses the danger color. The pulsing dots are motion-stripped under
 * prefers-reduced-motion (the global reduce block zeroes animation durations). */
.feedback.computer-thinking {
  border-left-color: var(--accent-secondary, var(--accent-primary));
  color: var(--text-muted);
}
.feedback.computer-thinking::after {
  content: ' ';
  animation: computer-thinking-dots 1.2s steps(4, end) infinite;
}
@keyframes computer-thinking-dots {
  0% { content: ''; }
  25% { content: '.'; }
  50% { content: '..'; }
  75% { content: '...'; }
}
.feedback.error {
  border-left-color: var(--state-danger, #d9534f);
}
.link-button {
  background: none;
  border: none;
  color: var(--accent-primary);
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
  font: inherit;
}

/* S7 setup controls (color + strength pickers). */
.computer-setup {
  gap: 1rem;
  flex-wrap: wrap;
}
.setup-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.setup-field select {
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-sm, 6px);
  background: var(--bg-surface-raised);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.12));
}

/* B-4: three-dot difficulty selector — replaces the strength dropdown. Each dot
 * is a real button (keyboard + screen-reader reachable); fill conveys the tier
 * via shape + aria-pressed, not hue alone. */
.difficulty-dots {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.2rem 0;
}
.difficulty-dot {
  width: 1.05rem;
  height: 1.05rem;
  padding: 0;
  border-radius: 50%;
  cursor: pointer;
  background: transparent;
  border: 2px solid var(--accent-primary, var(--accent, #b7892c));
  transition: background-color 0.15s ease, transform 0.1s ease;
}
.difficulty-dot.is-filled {
  background: var(--accent-primary, var(--accent, #b7892c));
}
.difficulty-dot:hover {
  transform: scale(1.12);
}
.difficulty-dot:focus-visible {
  outline: 3px solid var(--accent-primary, var(--accent, #b7892c));
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  .difficulty-dot {
    transition: none;
  }
  .difficulty-dot:hover {
    transform: none;
  }
}

/* B-8: 2D↔3D toggle switch — lives on the play surfaces (next to the difficulty
 * dots in Computer). A real role="switch" button; state shows via the sliding
 * thumb + aria-checked, not hue alone (WCAG 1.4.1). The visible "3D" text labels
 * what it switches on. */
.renderer-toggle-field {
  justify-content: flex-end;
}
.renderer-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.45rem;
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.12));
  border-radius: var(--radius-sm, 6px);
  background: var(--bg-surface-raised);
  color: var(--text-primary);
  cursor: pointer;
  font: inherit;
  font-size: 0.85rem;
}
.renderer-toggle-track {
  position: relative;
  width: 2.1rem;
  height: 1.1rem;
  border-radius: 999px;
  background: var(--border-subtle, rgba(255, 255, 255, 0.18));
  transition: background-color 0.15s ease;
}
.renderer-toggle-thumb {
  position: absolute;
  top: 50%;
  left: 0.12rem;
  width: 0.86rem;
  height: 0.86rem;
  border-radius: 50%;
  background: var(--text-muted);
  transform: translateY(-50%);
  transition: transform 0.15s ease, background-color 0.15s ease;
}
.renderer-toggle.is-on .renderer-toggle-track {
  background: var(--accent-primary, var(--accent, #b7892c));
}
.renderer-toggle.is-on .renderer-toggle-thumb {
  background: #fff;
  transform: translate(1rem, -50%);
}
.renderer-toggle-text {
  font-weight: 600;
  letter-spacing: 0.02em;
}
.renderer-toggle:hover {
  border-color: var(--accent-primary, var(--accent, #b7892c));
}
.renderer-toggle:focus-visible {
  outline: 3px solid var(--accent-primary, var(--accent, #b7892c));
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  .renderer-toggle-track,
  .renderer-toggle-thumb {
    transition: none;
  }
}

/* Event-driven reaction line: the latest committed-fact from session.events,
 * rendered under the feedback (consumes the event stream; invents no chess). */
.coach-reaction {
  margin: 0 0 1rem;
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-style: italic;
}

.coach-reaction[hidden] {
  display: none;
}

/* Step 5.1 — deterministic motif coach explanation (trainer panel). A calm,
   teaching line set off by the accent edge; text-only, no motion dependency. */
.coach-explanation {
  margin: 0 0 1rem;
  padding: 0.6rem 0.85rem;
  border-left: 3px solid var(--color-fire-gold, #b9892f);
  border-radius: var(--radius-sm, 6px);
  background: rgba(185, 137, 47, 0.1);
  color: var(--text-primary, inherit);
  font-size: var(--text-sm);
  line-height: 1.45;
}

.coach-explanation[hidden] {
  display: none;
}

/* S13 compact status line — replaces the former .stats-grid cards + large
 * neutral status box. One dense line: side-to-move indicator dot, status text,
 * and dezente inline meta counts. */
.status-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem 0.9rem;
  margin: 0 0 1rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-md);
  border-left: 4px solid var(--accent-primary);
  background: var(--bg-surface-raised);
  line-height: 1.4;
}

.status-main {
  display: inline-flex;
  align-items: baseline;
  gap: 0.45rem;
  min-width: 0;
}

/* Side-to-move indicator: a filled disc tinted by the colour on move. Sourced
 * from the core session's `turn`; decorative (aria-hidden) — the text carries
 * the meaning so colour is never the only signal. */
.turn-indicator {
  align-self: center;
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 50%;
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.35));
  flex: 0 0 auto;
}
.turn-indicator.w {
  background: #f4f1ea;
}
.turn-indicator.b {
  background: #14110f;
  border-color: rgba(255, 255, 255, 0.45);
}

.status-turn {
  font-weight: 800;
  color: var(--text-primary);
}

/* Non-neutral state (check / mate / draw / agreed / terminal): prominent. */
.status-strong {
  font-weight: 900;
  color: var(--text-primary);
}

/* Dezente inline metadata (Züge / Legale Züge / Fehler / Du spielst). */
.meta-row {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.2rem 0.9rem;
  color: var(--text-primary);
  font-weight: 800;
  font-size: 0.9rem;
}
.meta-label {
  color: var(--text-muted);
  font-weight: 800;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

/* S14 — Move list (read-only). A compact, scrollable two-column SAN list. Pure
 * presentation: the SAN strings are built in src/ui/move-list.js from committed
 * move events; this block only lays them out. Each row is number + white + black;
 * the most recently played half-move carries .move-current. */
/* Collapsible move list (compact redesign): a default-closed <details> so the
 * list never pushes the controls below the fold. The summary is a slim toggle. */
.move-list-details {
  margin: var(--space-3) 0;
}
.move-list-summary {
  cursor: pointer;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.55rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  user-select: none;
}
.move-list-summary::-webkit-details-marker {
  display: none;
}
.move-list-summary::before {
  content: '▸';
  font-size: 0.7rem;
  transition: transform var(--transition-fast) ease;
}
.move-list-details[open] .move-list-summary::before {
  transform: rotate(90deg);
}
.move-list-summary:hover {
  border-color: var(--accent-primary);
  color: var(--text-primary);
}
.move-list-summary:focus-visible {
  outline: 3px solid var(--accent-primary);
  outline-offset: 2px;
}
.move-list-count {
  color: var(--text-muted);
  font-weight: 700;
}
/* Review navigation (|◀ ◀ ▶ ▶| + status) under the move list. Read-only history
 * scrubbing; compact, centred row. */
.move-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  margin: var(--space-2) 0 0;
}
.move-nav-btn {
  cursor: pointer;
  min-width: 2rem;
  padding: 0.25rem 0.45rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 0.85rem;
  line-height: 1;
}
.move-nav-btn:hover:not(:disabled) {
  border-color: var(--accent-primary);
  background: var(--bg-surface-raised);
}
.move-nav-btn:disabled {
  opacity: 0.4;
  cursor: default;
}
.move-nav-btn:focus-visible {
  outline: 3px solid var(--accent-primary);
  outline-offset: 2px;
}
.move-nav-status {
  min-width: 5.5em;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.move-list {
  display: grid;
  grid-template-columns: 2.2em 1fr 1fr;
  gap: 0.05rem 0.4rem;
  align-content: start;
  max-height: 12.5rem;
  overflow-y: auto;
  margin: var(--space-2) 0 0;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-surface, var(--surface));
  font-variant-numeric: tabular-nums;
  font-size: 0.92rem;
}
.move-list:empty {
  display: none;
}
.move-entry {
  display: contents;
}
.move-num {
  color: var(--text-muted);
  font-weight: 700;
  text-align: right;
  font-size: 0.82rem;
}
.move-white,
.move-black {
  color: var(--text-primary);
  font-weight: 700;
  padding: 0.04rem 0.3rem;
  border-radius: var(--radius-sm);
}
.move-current {
  background: var(--accent-soft, var(--accent-secondary-soft));
  color: var(--text-primary);
  box-shadow: inset 0 0 0 1px var(--accent-secondary, var(--accent-primary));
}

dt {
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

dd {
  margin: 0.22rem 0 0;
  color: var(--text-primary);
  font-weight: 900;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tag {
  padding: 0.35rem 0.58rem;
  border-radius: var(--radius-pill);
  background: var(--bg-surface-raised);
  color: var(--accent-secondary);
  font-size: 0.82rem;
  font-weight: 800;
}

.details {
  margin-top: 1rem;
}

.details summary {
  cursor: pointer;
  color: var(--text-muted);
  font-weight: 800;
}

pre {
  overflow: auto;
  max-height: 260px;
  padding: 1rem;
  border-radius: var(--radius-md);
  background: var(--bg-canvas);
  color: var(--text-primary);
  font-size: 0.78rem;
}

/* =============================================================================
 * Step 2.3 — Dark-fantasy shell: Dashboard, top bar, mode switch.
 * All rules below consume ONLY the semantic tokens from tokens.css (no raw
 * hex). They are additive; the legacy light interior styles above are intact.
 * ========================================================================== */

/* The router toggles `hidden` on these regions. They set an explicit
 * `display` (grid/flex), which would otherwise override the UA
 * `[hidden] { display: none }` — so re-assert it at higher specificity. */
.topbar[hidden],
.layout[hidden] {
  display: none;
}

/* --- In-screen top bar (shown on the play surfaces) --------------------- */
.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--space-4);
  max-width: 1180px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-4) 0;
}

/* Right cluster (Lernpfad + music + gear), pinned to the bar's right edge so the
 * mode group can sit centered in the middle grid column. */
.topbar-right {
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
}

/* --- Brand mark (replaces the former "← Übersicht" home button, S11) ----- */
.topbar-brand {
  display: inline-flex;
  align-items: center;
  color: var(--accent-secondary);
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: 0.06em;
}

/* --- Play-mode picker: bordered group with a centered "Modus" legend ------ */
/* A thin ring encircles the player-symbol pills; the "Modus" caption sits on the
 * top border (fieldset-style), reading as a label for the symbols below it. */
.mode-group {
  position: relative;
  justify-self: center;
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.65rem 0.3rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}
.mode-group-legend {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 0 0.4rem;
  background: var(--bg-canvas);
  color: var(--text-muted);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  white-space: nowrap;
}

.mode-select {
  cursor: pointer;
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  background: var(--bg-surface);
  color: var(--text-primary);
  font: inherit;
  font-weight: 700;
  transition:
    background var(--transition-fast) ease,
    border-color var(--transition-fast) ease;
}

.mode-select:hover {
  background: var(--bg-surface-raised);
  border-color: var(--accent-primary);
}

.mode-select:focus-visible {
  outline: 3px solid var(--accent-primary);
  outline-offset: 2px;
}

/* --- B-9: mode as player-symbol picker (replaces the dropdown) ------------ */
/* A radiogroup of player compositions (🧑 vs 💻 etc.). Selection is conveyed by
 * the active pill (border + fill), not hue alone; each button carries an aria-label
 * so a screen reader announces the composition. */
.mode-picker {
  display: inline-flex;
  gap: var(--space-2);
  align-items: center;
}
.mode-comp {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  background: var(--bg-surface);
  color: var(--text-muted);
  transition:
    background var(--transition-fast) ease,
    border-color var(--transition-fast) ease,
    color var(--transition-fast) ease;
}
.mode-comp-icons {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}
.mode-comp-vs {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  opacity: 0.7;
}
.player-icon {
  display: block;
}
.mode-comp:hover {
  background: var(--bg-surface-raised);
  border-color: var(--accent-primary);
  color: var(--text-primary);
}
.mode-comp.is-active {
  border-color: var(--accent-primary);
  background: var(--bg-surface-raised);
  color: var(--text-primary);
  box-shadow: inset 0 0 0 1px var(--accent-primary);
}
.mode-comp:focus-visible {
  outline: 3px solid var(--accent-primary);
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  .mode-comp {
    transition: none;
  }
}

/* --- Lernpfad menu (button → popover with progress HUD + CTA, S11) -------- */
.lernpfad-menu {
  position: relative;
  display: inline-flex;
}

.lernpfad-button {
  cursor: pointer;
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  background: var(--bg-surface);
  color: var(--text-primary);
  font: inherit;
  font-weight: 700;
  transition:
    background var(--transition-fast) ease,
    border-color var(--transition-fast) ease;
}

.lernpfad-button:hover {
  background: var(--bg-surface-raised);
  border-color: var(--accent-primary);
}

.lernpfad-button:focus-visible {
  outline: 3px solid var(--accent-primary);
  outline-offset: 2px;
}

.lernpfad-panel {
  position: absolute;
  top: calc(100% + var(--space-2));
  right: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  width: 22rem;
  max-width: calc(100vw - 2 * var(--space-4));
  padding: var(--space-6);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-surface-raised);
  box-shadow: var(--elev-2);
}

.lernpfad-panel[hidden] {
  display: none;
}

.lernpfad-eyebrow {
  margin: 0 0 var(--space-1);
  color: var(--accent-secondary);
  font-size: var(--text-xs);
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.lernpfad-lede {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--text-sm);
  line-height: var(--leading-body);
}

.lernpfad-cta {
  align-self: stretch;
}

/* --- Piece-set switcher button (S5) --------------------------------------- */
.piece-set-button {
  cursor: pointer;
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  background: var(--bg-surface);
  color: var(--text-primary);
  font: inherit;
  font-weight: 700;
  transition:
    background var(--transition-fast) ease,
    border-color var(--transition-fast) ease;
}

.piece-set-button:hover {
  background: var(--bg-surface-raised);
  border-color: var(--accent-primary);
}

.piece-set-button:focus-visible {
  outline: 3px solid var(--accent-primary);
  outline-offset: 2px;
}

/* --- Settings menu (gear button → popover panel; Stage 1) ----------------- */
.settings-menu {
  position: relative;
  display: inline-flex;
}

.settings-button {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.4rem;
  height: 2.4rem;
  padding: 0;
  border: 1px solid var(--border-subtle);
  border-radius: 50%;
  background: var(--bg-surface);
  color: var(--text-primary);
  font: inherit;
  font-size: 1.15rem;
  line-height: 1;
  transition:
    background var(--transition-fast) ease,
    border-color var(--transition-fast) ease;
}

.settings-button:hover {
  background: var(--bg-surface-raised);
  border-color: var(--accent-primary);
}

.settings-button:focus-visible {
  outline: 3px solid var(--accent-primary);
  outline-offset: 2px;
}

/* --- Music note toggle (S9): always-visible on/off in the top bar --------- */
.music-note-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  cursor: pointer;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  background: var(--bg-surface);
  color: var(--text-muted);
  font-size: 1.15rem;
  line-height: 1;
  transition:
    background var(--transition-fast) ease,
    border-color var(--transition-fast) ease,
    color var(--transition-fast) ease;
}

.music-note-toggle:hover {
  background: var(--bg-surface-raised);
  border-color: var(--accent-primary);
}

.music-note-toggle:focus-visible {
  outline: 3px solid var(--accent-primary);
  outline-offset: 2px;
}

/* "On" state: the glyph lights up with the brand accent so the toggle reads at
   a glance without opening the settings panel. */
.music-note-toggle.is-on {
  color: var(--accent-secondary);
  border-color: var(--accent-secondary);
  background: var(--bg-surface-raised);
}

.settings-panel {
  position: absolute;
  top: calc(100% + var(--space-2));
  right: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-width: 16rem;
  padding: var(--space-4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-surface-raised);
  box-shadow: var(--elev-2);
}

.settings-panel[hidden] {
  display: none;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.setting-label {
  color: var(--text-primary);
  font-weight: 700;
}

.setting-block {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  width: 100%;
}

.setting-value {
  color: var(--text-primary);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.setting-slider {
  width: 100%;
  accent-color: var(--accent-primary);
  cursor: pointer;
}

.setting-slider:focus-visible {
  outline: 3px solid var(--accent-primary);
  outline-offset: 4px;
}

.setting-scale {
  display: flex;
  justify-content: space-between;
  color: var(--text-muted);
  font-size: var(--text-small, 0.8rem);
}

/* S8 settings-registry controls — reuse the panel's .setting-* layout. */
.setting-checkbox {
  width: 1.2rem;
  height: 1.2rem;
  accent-color: var(--accent-primary);
  cursor: pointer;
}

.setting-checkbox:focus-visible,
.setting-select:focus-visible {
  outline: 3px solid var(--accent-primary);
  outline-offset: 2px;
}

.setting-select {
  color: var(--text-primary);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.18));
  border-radius: var(--radius-sm, 6px);
  padding: 0.25rem 0.5rem;
  font: inherit;
  cursor: pointer;
}

/* S9 audio settings — a sub-group inside the panel (SFX/music toggles + volume
 * sliders + sound-pack select), set off by a subtle divider. Controls reuse the
 * existing .setting-* / .motion-toggle-button styles; this only adds spacing. */
#audio-settings {
  padding-top: var(--space-2);
  border-top: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.18));
}

/* Step 3.4 — 2D↔3D renderer switch + adapter-local tilt sub-group. Same panel
 * divider treatment as the audio group; controls reuse the .setting-* styles.
 * The block itself is hidden via [hidden] on mobile (desktop-only v1); the tilt
 * row is hidden via [hidden] unless the active adapter advertises a camera. */
#render-settings {
  padding-top: var(--space-2);
  border-top: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.18));
}

.setting-loading {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--text-small, 0.8rem);
}

/* The 3D canvas is a visual overlay: it fills #board-root on top of the DOM board,
 * which stays the input + a11y surface beneath it (no renderer-owned input). The
 * canvas must not eat clicks, so they fall through to the buttons underneath. */
#board-root canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: var(--radius-lg);
  pointer-events: none;
}

/* In 3D, the WebGL canvas is the visual piece layer, so the 2D glyph pieces are
 * hidden — but only visually: the .square buttons beneath stay clickable + in the
 * a11y tree, so input and screen-reader output are unchanged. app.js toggles
 * .is-3d on #board-root from the active adapter's camera capability. */
.board-wrap.is-3d .piece {
  visibility: hidden;
}

/* In 3D, mouse picking is owned by the WebGL canvas (raycast → square under the
 * cursor in app.js), because the flat DOM grid does not line up with the tilted
 * perspective board. So the square buttons are made pointer-inert: a mouse click
 * falls through to #board-root, which raycasts the real scene. Keyboard focus +
 * activation are unaffected (pointer-events does not gate keyboard), so the board
 * stays fully operable by keyboard and in the a11y tree. */
#board-root.is-3d .square {
  pointer-events: none;
}

/* In 3D the check threat is shown by reddening the actual board TILES (the renderer
 * tints them — S26); the flat 2D box-shadow tint on the DOM squares would otherwise
 * "ghost" through behind the WebGL canvas, so suppress it here. The squares stay in
 * the a11y tree; only the visual tint is dropped (the 3D tiles carry the cue). */
#board-root.is-3d .square.in-check,
#board-root.is-3d .square.check-path {
  box-shadow: none;
  z-index: auto; /* never let the flat 2D square stack above the WebGL canvas */
}

/* In 3D the best-move hint is drawn IN-SCENE by the renderer (the red dotted trail
 * + arrowhead — B-7 parity). The flat 2D SVG arrow (z-index 4) and the from/to
 * box-shadow rings would otherwise "ghost" through over the WebGL canvas, so
 * suppress them here. The squares stay in the a11y tree; only the visual overlay is
 * dropped (the 3D trail carries the cue). */
#board-root.is-3d .hint-arrow {
  display: none;
}
#board-root.is-3d .square.hint-from,
#board-root.is-3d .square.hint-to {
  box-shadow: none;
}

/* S13 coordinates mode (Aus / Rand / Voll) — board.js always renders both the
 * per-square `.coord` labels and the single-char `.coord-file` / `.coord-rank`
 * edge labels; this gates which are visible off body[data-coords]. The default
 * is `edge` (Rand) — set by app.js applying the setting on init; a board with no
 * attribute yet shows nothing extra (edge labels are baseline-hidden), so there
 * is no flash of full coordinates before the setting applies. */
body[data-coords="full"] .coord {
  display: block;
}
body[data-coords="edge"] .coord,
body[data-coords="off"] .coord {
  display: none;
}
body[data-coords="edge"] .coord-file,
body[data-coords="edge"] .coord-rank {
  display: block;
}

/* Edge-label placement: file letters centred on the bottom edge of the
 * bottom-rank squares, rank numbers centred on the left edge of the left-file
 * squares. Positioned over each square's position:relative box; pointer-events
 * stay off the square button (labels are aria-hidden, decorative). */
.coord-file,
.coord-rank {
  position: absolute;
  z-index: 2;
  font-size: 0.62rem;
  font-weight: 800;
  pointer-events: none;
}
.coord-file {
  bottom: 0.12rem;
  left: 0;
  right: 0;
  text-align: center;
}
.coord-rank {
  top: 0.12rem;
  left: 0.18rem;
}
/* Edge labels reuse the opposite-colour contrast rule of the full coords. */
.square.light .coord-file,
.square.light .coord-rank {
  color: var(--board-coord-on-light);
}
.square.dark .coord-file,
.square.dark .coord-rank {
  color: var(--board-coord-on-dark);
}

/* S8 highlight-last-move toggle — gate the last-move square tint. Default shows
 * it; the setting adds `last-move-hidden` when OFF. The one-time settle
 * animation on the piece is motion, not a persistent highlight, so it is left
 * untouched. */
body.last-move-hidden .square.last-move::before {
  display: none;
}

/* S10 legal-move-hints toggle — gate the legal-destination hint dots the board
 * shows on selection. Default shows them; the setting adds `legal-hints-hidden`
 * when OFF. The dots come from CORE-supplied legal targets; this only hides
 * them (no legality change). */
body.legal-hints-hidden .square.legal-target::after {
  display: none;
}

/* S8 board-theme select — palettes override the board square colours via
 * data-board-theme on <body>. 'classic' = the default tokens.css palette (no
 * override needed). */
body[data-board-theme="slate"] {
  --board-light: #C9D1D9;
  --board-dark: #3B4252;
  --board-coord-on-light: #3B4252;
  --board-coord-on-dark: #C9D1D9;
}

body[data-board-theme="forest"] {
  --board-light: #E9EBC9;
  --board-dark: #3A5A40;
  --board-coord-on-light: #3A5A40;
  --board-coord-on-dark: #E9EBC9;
}

@media (max-width: 720px) {
  /* Narrow: stack the three zones so the centered mode group doesn't squeeze the
   * brand and the right cluster. */
  .topbar {
    grid-template-columns: 1fr;
    justify-items: center;
    row-gap: var(--space-3);
  }
  .topbar-right {
    justify-self: center;
  }
}

@media (max-width: 980px) {
  .hero,
  .layout,
  .trainer {
    grid-template-columns: 1fr;
  }

  .progress-card {
    text-align: left;
  }
}

@media (max-width: 560px) {
  .hero {
    padding-top: 1.5rem;
  }

  .layout {
    padding-inline: 0.75rem;
  }

  .panel-heading,
  .trainer-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .board {
    border-width: 6px;
  }

  .coord {
    display: none;
  }
}

/* =============================================================================
 * Step 2.4 — Promotion picker (modal) + motion keyframes + reduced-motion.
 * The modal is presentation scaffolding (ANIMATION_CONTRACT "Show UI state");
 * it commits nothing until the player chooses. Tokens only (no raw hex).
 * ========================================================================== */
.promotion-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  background: rgba(14, 11, 20, 0.72);
  border-radius: var(--radius-lg);
  animation: overlay-in var(--transition-fast) ease-out both;
}

.promotion-dialog {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  width: min(86%, 360px);
  padding: var(--space-6);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  box-shadow: var(--elev-3);
  text-align: center;
  animation: dialog-in var(--transition-base) ease-out both;
}

.promotion-heading {
  margin: 0;
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: var(--text-h3);
}

.promotion-choices {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-2);
}

.promotion-choice {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-3) var(--space-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-surface-raised);
  color: var(--text-primary);
  cursor: pointer;
  transition:
    transform var(--transition-fast) ease,
    border-color var(--transition-fast) ease,
    box-shadow var(--transition-fast) ease;
}

.promotion-choice:hover {
  transform: translateY(-2px);
  border-color: var(--accent-primary);
  box-shadow: var(--glow-select);
}

.promotion-choice:focus-visible {
  outline: 3px solid var(--accent-primary);
  outline-offset: 2px;
}

.promotion-glyph {
  font-size: 2.4rem;
  line-height: 1;
}

.promotion-choice.w .promotion-glyph {
  color: var(--color-warm-ivory);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
}

.promotion-choice.b .promotion-glyph {
  color: var(--color-obsidian);
  text-shadow: 0 0 3px rgba(242, 233, 208, 0.6);
}

.promotion-label {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text-muted);
}

.promotion-cancel {
  align-self: center;
  padding: var(--space-2) var(--space-6);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.promotion-cancel:focus-visible {
  outline: 3px solid var(--accent-primary);
  outline-offset: 2px;
}

/* --- Motion keyframes (gentle; collapsed under reduced motion below) ------ */
@keyframes square-pulse {
  0%, 100% { box-shadow: var(--glow-select); }
  50% { box-shadow: 0 0 6px rgba(124, 77, 255, 0.5); }
}

@keyframes dot-in {
  from { transform: scale(0.2); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* Keeps the centring `translate(-50%, -50%)` (see `.piece`) while adding the
 * settle motion, so the just-moved piece stays centred after it settles. */
@keyframes piece-settle {
  from { transform: translate(-50%, -50%) translateY(-8%) scale(1.06); }
  to { transform: translate(-50%, -50%) scale(1); }
}

@keyframes board-solved {
  0%, 100% { box-shadow: var(--glow-gold); }
  50% { box-shadow: 0 0 24px rgba(245, 166, 35, 0.95), 0 0 48px rgba(245, 166, 35, 0.5); }
}

@keyframes overlay-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes dialog-in {
  from { transform: translateY(10px) scale(0.96); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

/* Reduced motion: the loop is fully playable with motion stripped. Outcome and
 * feedback are unchanged — only the animation is removed (ANIMATION_CONTRACT
 * "Accessibility & Disableability"). The token-level reduced-motion block in
 * tokens.css already zeroes the durations; here we also disable the keyframe
 * animations and hover lifts so nothing pulses or slides. */
@media (prefers-reduced-motion: reduce) {
  .square.selected,
  .square.legal-target::after,
  .square.last-move .piece,
  .board-wrap.is-solved,
  .promotion-overlay,
  .promotion-dialog,
  /* Step 3.2/3.3: neutralize the per-piece motion under reduced motion. */
  .piece.check-react,
  .piece.capture-fx,
  .piece.promote-fx,
  .piece.captured-fx,
  .piece.victory-fx,
  .piece.defeat-fx,
  .win-card,
  .square.selected .piece {
    animation: none;
  }

  /* The FLIP slide is a transform transition, not a keyframe — kill it too so a
   * committed move snaps to its final square (ANIMATION_CONTRACT §Accessibility). */
  .piece {
    transition: none;
  }

  .puzzle-button:hover,
  .ghost-button:hover,
  .secondary-button:hover,
  .promotion-choice:hover {
    transform: none;
  }
}

/* Step 3.2 declarative kill switch: the user "Animation: aus" toggle sets
 * body.motion-off, which snaps the slide + FX independently of the JS motion
 * profile (belt-and-suspenders; the board stays fully playable, instant). */
body.motion-off .piece {
  transition: none;
}

body.motion-off .piece.check-react,
body.motion-off .piece.capture-fx,
body.motion-off .piece.promote-fx,
body.motion-off .piece.captured-fx,
body.motion-off .piece.victory-fx,
body.motion-off .piece.defeat-fx,
body.motion-off .square.selected .piece,
body.motion-off .square.last-move .piece {
  animation: none;
}

/* S15 — Legal pages (Impressum + Datenschutz scaffold) + site footer.
 * Pure presentation, no motion dependency. Reachable from every surface so the
 * Impressum stays "ständig verfügbar" (§5 DDG). Contrast follows the body text
 * token (--text-primary, 16.1:1 on the dark theme). */
.site-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 1.5rem;
  padding: 0.9rem 1rem;
  border-top: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 0.85rem;
}

.footer-brand {
  font-weight: 700;
  letter-spacing: 0.02em;
}

.footer-nav {
  display: flex;
  gap: 1rem;
}

.footer-link {
  cursor: pointer;
  padding: 0.2rem 0.1rem;
  border: none;
  background: none;
  color: var(--text-muted);
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.footer-link:hover {
  color: var(--text-primary);
}

.footer-link:focus-visible {
  outline: 3px solid var(--accent-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm, 4px);
}

.legal-view {
  display: block;
}

.legal-page {
  max-width: 46rem;
  margin: 0 auto;
  padding: 1rem 0.5rem 0.5rem;
  color: var(--text-primary);
  line-height: 1.6;
}

.legal-page h2 {
  margin: 0.2rem 0 0.6rem;
}

.legal-page h3 {
  margin: 1.2rem 0 0.3rem;
  font-size: 1rem;
  color: var(--accent-secondary);
}

.legal-note {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0 0 0.8rem;
}

.legal-address {
  font-style: normal;
}

.legal-contact {
  list-style: none;
  margin: 0.2rem 0;
  padding: 0;
}

.legal-contact a {
  color: var(--accent-secondary);
}

/* Datenschutz: Betroffenenrechte-Liste + Querverweis aus dem Impressum. */
.legal-list {
  margin: 0.2rem 0 0.6rem;
  padding-left: 1.2rem;
}

.legal-list li {
  margin: 0.15rem 0;
}

.legal-crosslink {
  margin-top: 1rem;
}

/* In-page legal cross-link (rendered as a button so it routes through goToView,
 * but reads as a link). */
.legal-link {
  cursor: pointer;
  padding: 0;
  border: none;
  background: none;
  color: var(--accent-secondary);
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.legal-link:hover {
  color: var(--text-primary);
}

.legal-link:focus-visible {
  outline: 3px solid var(--accent-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm, 4px);
}

.legal-back {
  cursor: pointer;
  margin-bottom: 0.8rem;
  padding: 0.45rem 0.8rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-primary);
  font: inherit;
}

.legal-back:hover {
  background: var(--bg-surface-raised);
}

.legal-back:focus-visible {
  outline: 3px solid var(--accent-primary);
  outline-offset: 2px;
}

/* S16 — Accessibility follow-ups (OQ-S2-1 + OQ-S2-2).
 * `.sr-only`: visually hidden but available to assistive tech — used by the
 * live announcer (#a11y-announcer) and any screen-reader-only label. Motion-free.
 * `.skip-link`: off-screen until focused, then revealed top-left so a keyboard
 * user can jump straight to the main content without tabbing the whole topbar. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: 0.5rem;
  top: -3rem;
  z-index: 1000;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-md);
  background: var(--bg-surface-raised);
  color: var(--text-primary);
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  /* No transition/keyframe — reveal is an instant position change (motion-safe). */
}

.skip-link:focus,
.skip-link:focus-visible {
  top: 0.5rem;
  outline: 3px solid var(--accent-primary);
  outline-offset: 2px;
}

/* --- S17: Souvenir cards + collection gallery ---------------------------- *
 * Presentation-only keepsake of solved puzzles. The reward card (in the
 * trainer panel) and the gallery (in the Lernpfad overlay) share the card
 * look. Colours come from existing design tokens only — no new contrast
 * pairing. The reward reveal is motion-safe (zeroed under reduced motion). */
.souvenir-gallery {
  margin-top: 1rem;
}

.souvenir-gallery-inner {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.souvenir-gallery-heading {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.souvenir-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
  padding: 0.05rem 0.4rem;
  border-radius: var(--radius-pill);
  background: var(--accent-primary);
  color: #fff;
  font-size: 0.78rem;
}

.souvenir-empty {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.souvenir-card-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 16rem;
  overflow-y: auto;
}

.souvenir-card {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--border-subtle);
  border-left: 4px solid var(--accent-secondary, var(--accent-primary));
  border-radius: var(--radius-md);
  background: var(--bg-surface-raised);
}

/* The just-earned card in the trainer panel — accent emphasis + a soft reveal. */
.souvenir-card--reward {
  border-left-color: var(--accent-primary);
  background: linear-gradient(135deg, var(--accent-primary-deep), var(--bg-surface-raised) 78%);
  margin: 0.75rem 0;
  animation: souvenir-reward-in var(--transition-base, 240ms) ease-out both;
}

@keyframes souvenir-reward-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.souvenir-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.souvenir-rating {
  font-weight: 800;
  color: var(--text-primary);
}

.souvenir-date {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.souvenir-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.souvenir-tag {
  padding: 0.2rem 0.45rem;
  border-radius: var(--radius-pill);
  background: var(--bg-surface);
  color: var(--accent-secondary);
  font-size: 0.74rem;
  font-weight: 700;
}

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