/* Copyright (c) 2025 Gambit Consulting Ltd. All Rights Reserved. */
:root {
  --bg: #fef9f0;
  --card: #fff;
  --primary: #e85d75;
  --primary-hover: #d94a62;
  --secondary: #5cb8b2;
  --accent: #ffc857;
  --text: #2d3142;
  --text-muted: #6b7280;
  --success: #4ade80;
  --wrong: #f87171;
  --shadow: 0 4px 20px rgba(45, 49, 66, 0.08);
  --radius: 20px;
  --font: 'Lexend', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-ui: var(--font);
  /* Monospace IDs: distinct I, l, 1 (SPL-LNLN) */
  --font-user-id: 'IBM Plex Mono', ui-monospace, 'Cascadia Mono', 'Segoe UI Mono', 'Roboto Mono', Menlo, Consolas, monospace;
}

/* Lexend (variable, default app font) — html[data-ui-font="lexend"]. Self-hosted under fonts/. */
@font-face {
  font-family: 'Lexend';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/lexend/lexend-latin-wght-normal.woff2') format('woff2');
}

/* OpenDyslexic — loaded when admin defaultUiFont is opendyslexic. Self-hosted under fonts/. */
@font-face {
  font-family: 'OpenDyslexic';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/opendyslexic/opendyslexic-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'OpenDyslexic';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/opendyslexic/opendyslexic-latin-700-normal.woff2') format('woff2');
}

html[data-ui-font='lexend'] {
  --font: 'Lexend', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-ui: var(--font);
}

html[data-ui-font='opendyslexic'] {
  --font: 'OpenDyslexic', 'Lexend', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-ui: var(--font);
}

/* Andika — built for beginning readers; single-storey a and g match handwriting instruction. Self-hosted under fonts/. */
@font-face {
  font-family: 'Andika';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/andika/andika-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Andika';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/andika/andika-latin-700-normal.woff2') format('woff2');
}

/* Atkinson Hyperlegible — maximally distinguishable glyphs; targets b/d/p/q and I/l/1 confusions. Self-hosted under fonts/. */
@font-face {
  font-family: 'Atkinson Hyperlegible';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/atkinson/atkinson-hyperlegible-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Atkinson Hyperlegible';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/atkinson/atkinson-hyperlegible-latin-700-normal.woff2') format('woff2');
}

html[data-ui-font='andika'] {
  --font: 'Andika', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-ui: var(--font);
}

html[data-ui-font='atkinson'] {
  --font: 'Atkinson Hyperlegible', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-ui: var(--font);
}

/* App font weight (admin Config → defaultUiFontWeight). */
html[data-ui-font-weight='100'] {
  font-weight: 100;
}
html[data-ui-font-weight='200'] {
  font-weight: 200;
}
html[data-ui-font-weight='300'] {
  font-weight: 300;
}
html[data-ui-font-weight='400'] {
  font-weight: 400;
}
html[data-ui-font-weight='500'] {
  font-weight: 500;
}
html[data-ui-font-weight='600'] {
  font-weight: 600;
}
html[data-ui-font-weight='700'] {
  font-weight: 700;
}
html[data-ui-font-weight='800'] {
  font-weight: 800;
}
html[data-ui-font-weight='900'] {
  font-weight: 900;
}

/* App-wide text scale (admin Config → defaultUiFontScale). */
html[data-ui-font-scale='90'] {
  font-size: 90%;
}
html[data-ui-font-scale='110'] {
  font-size: 110%;
}
html[data-ui-font-scale='125'] {
  font-size: 125%;
}

/* ---- Reading-comfort variables (Dyslexia/ND). Applied by applyReadingComfortSettings() in app.js. ---- */
:root {
  --read-font: var(--font);
  --read-font-weight: 400;
  --read-base-size: 1.125rem;
  --read-user-scale: 1;
  --read-font-scale: 1;
  --read-font-size: calc(var(--read-base-size) * var(--read-user-scale) * var(--read-font-scale));
  --read-letter-spacing: 0em;
  --read-word-spacing: 0em;
  --read-line-height: 1.6;
}

body[data-reading-font='lexend']       { --read-font: 'Lexend', system-ui, sans-serif;                    --read-font-scale: 1.00; }
body[data-reading-font='andika']       { --read-font: 'Andika', system-ui, sans-serif;                    --read-font-scale: 1.00; }
body[data-reading-font='atkinson']     { --read-font: 'Atkinson Hyperlegible', system-ui, sans-serif;     --read-font-scale: 1.05; }
body[data-reading-font='opendyslexic'] { --read-font: 'OpenDyslexic', system-ui, sans-serif;              --read-font-scale: 0.95; }

* {
  box-sizing: border-box;
}

/* Splash overlay: image fills screen; welcome + stars drawn over it */
/* Login gate: full-screen overlay until user is authenticated */
.login-gate-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  box-sizing: border-box;
}
.login-gate-overlay.hidden {
  display: none !important;
}
.login-gate-overlay.login-gate-overlay--splash-bg .login-gate-backdrop {
  background: rgba(254, 249, 240, 0.55);
}
.login-gate-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}
.login-gate-box {
  position: relative;
  z-index: 1;
  background: #fff;
  border-radius: 12px;
  padding: 1.5rem 2rem;
  max-width: 60rem;
  transition: max-width 0.2s ease;
  width: 100%;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}
.login-gate-box--signin {
  max-width: 30rem;
}
.login-gate-title {
  margin: 0 0 0.5rem;
  font-size: 1.35rem;
}
.login-gate-hint {
  margin: 0 0 1rem;
  color: #555;
  font-size: 0.95rem;
}
.login-gate-form .login-gate-row {
  margin-bottom: 1rem;
}
.login-gate-form .login-gate-row label {
  display: block;
  margin-bottom: 0.35rem;
  font-weight: 500;
}
.login-gate-form .login-gate-row input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  box-sizing: border-box;
}
.login-gate-error {
  margin: 0 0 0.75rem;
  color: #c00;
  font-size: 0.9rem;
}
.login-gate-error.hidden {
  display: none !important;
}
.login-gate-tabs {
  display: flex;
  gap: 0;
  margin: 0 0 1rem;
  border-bottom: 2px solid #e0e0e0;
}
.login-gate-tab {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  font-weight: 500;
  color: #888;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.login-gate-tab:hover {
  color: #444;
}
.login-gate-tab.active {
  color: #e85d75;
  border-bottom-color: #e85d75;
}
.login-gate-panel.hidden {
  display: none !important;
}
.login-gate-success {
  margin: 0.75rem 0 0;
  padding: 0.5rem 0.75rem;
  background: #e8f5e9;
  border-radius: 6px;
  color: #2e7d32;
  font-size: 0.9rem;
}
.login-gate-success.hidden {
  display: none !important;
}
.login-gate-forgot-btn {
  display: block;
  margin: 0.85rem auto 0;
  background: none;
  border: none;
  color: #3a6ea5;
  font-size: 0.875rem;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.login-gate-forgot-btn:hover { color: #1a4a85; }
.login-gate-forgot-panel {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #e0e0e0;
}
.login-gate-forgot-panel.hidden { display: none !important; }
.login-gate-privacy-hint {
  margin: 0.75rem 0 0;
  font-size: 0.8rem;
  color: #888;
  text-align: center;
}
.login-gate-privacy-hint a { color: inherit; text-decoration: underline; }
/* User ID and subscription code (gate, settings, footer): monospace for legible I vs 1 */
.login-gate-user-id,
#login-gate-user-id,
#login-gate-code,
#login-user-id,
#login-school-code,
#login-user-id-display,
.user-id-footer-line {
  font-family: var(--font-user-id);
  font-weight: 500;
  letter-spacing: 0.06em;
  font-variant-numeric: slashed-zero;
}
#login-gate-user-id,
#login-gate-code,
#login-user-id,
#login-school-code {
  text-transform: uppercase;
}
.login-gate-user-id,
.user-id-saved-popup-body .login-gate-user-id {
  font-weight: 600;
}
.login-gate-success .login-gate-user-id {
  letter-spacing: 0.06em;
}
.login-gate-user-id-row {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  vertical-align: middle;
  flex-wrap: wrap;
}
.login-gate-copy-user-id {
  font-family: var(--font-ui, inherit);
  letter-spacing: normal;
  font-variant-numeric: normal;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem;
  min-width: 2rem;
  min-height: 2rem;
  line-height: 0;
  flex-shrink: 0;
  color: var(--text-secondary, #64748b);
  background: transparent;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
}
.login-gate-copy-user-id:hover {
  color: var(--text, #1e293b);
  border-color: #94a3b8;
  background: #f8fafc;
}
.login-gate-copy-user-id.is-copied {
  color: #2e7d32;
  border-color: #81c784;
  background: #e8f5e9;
}
.login-gate-copy-user-id-icon {
  display: block;
}
.user-id-saved-popup-body .login-gate-user-id-row {
  margin: 0 0.1rem;
}

/* Learn mini-quiz overlay: type missing parts before next word */
.learn-mini-quiz-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  pointer-events: none;
  overflow: hidden;
}
.learn-mini-quiz-overlay.hidden {
  display: none !important;
}
/* Avoid scroll-into-view on Tab shifting the scrollable overlay (layout jitter). */
.learn-mini-quiz-overlay .learn-mini-quiz-box,
.learn-mini-quiz-overlay .learn-mini-quiz-actions button,
.learn-mini-quiz-overlay .learn-mini-quiz-delete,
.learn-mini-quiz-overlay .learn-mini-quiz-hear,
.learn-mini-quiz-overlay .learn-mini-quiz-close,
.learn-mini-quiz-overlay .learn-mini-quiz-need-help {
  scroll-margin: 0;
}
.learn-mini-quiz-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  pointer-events: auto;
}
/* Extra support: keep the learn card visible and reachable under the draggable popup. */
.learn-mini-quiz-overlay.learn-mini-quiz-overlay--extra-support .learn-mini-quiz-backdrop {
  background: transparent;
  pointer-events: none;
}
/* "I need help": keep popup frame (semi-transparent); hide quiz controls inside. */
.learn-mini-quiz-overlay.learn-mini-quiz-overlay--peek-help .learn-mini-quiz-backdrop {
  background: transparent;
  pointer-events: none;
}
.learn-mini-quiz-overlay.learn-mini-quiz-overlay--peek-help .learn-mini-quiz-close,
.learn-mini-quiz-overlay.learn-mini-quiz-overlay--peek-help .learn-mini-quiz-drag-handle,
.learn-mini-quiz-overlay.learn-mini-quiz-overlay--peek-help .learn-mini-quiz-peek-fade {
  display: none !important;
}
/* Invisible placeholders keep "I need help" in the same slot between Back and Next. */
.learn-mini-quiz-overlay.learn-mini-quiz-overlay--peek-help .learn-mini-quiz-back,
.learn-mini-quiz-overlay.learn-mini-quiz-overlay--peek-help #learn-mini-quiz-ok {
  visibility: hidden !important;
  pointer-events: none !important;
}
.learn-mini-quiz-overlay.learn-mini-quiz-overlay--peek-help .learn-mini-quiz-box {
  display: flex !important;
  flex-direction: column !important;
  background: rgba(255, 255, 255, 0.38);
  background: color-mix(in srgb, var(--card) 38%, transparent);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  box-shadow: 0 2px 12px rgba(45, 49, 66, 0.08);
  pointer-events: auto;
  overflow: hidden;
  /* Keep spell-locked width/height from JS — do not collapse the frame. */
}
.learn-mini-quiz-overlay.learn-mini-quiz-overlay--peek-help .learn-mini-quiz-box:not([style*="height"]) {
  min-height: 10rem;
  min-width: min(
    calc(var(--learn-main-pane-width, 860px) * 0.75),
    calc(100vw - 2rem)
  );
  padding: 1.25rem 1.5rem !important;
}
.learn-mini-quiz-overlay.learn-mini-quiz-overlay--peek-help .learn-mini-quiz-actions {
  flex: 0 0 auto;
  margin-top: auto !important;
  padding-top: 0.25rem !important;
  display: flex !important;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  pointer-events: auto;
}
.learn-mini-quiz-overlay.learn-mini-quiz-overlay--peek-help .learn-mini-quiz-need-help {
  pointer-events: auto;
  visibility: visible;
  opacity: 1;
}

/* Wrong-answer feedback: solid card (no peek-help frost glass). */
.learn-mini-quiz-overlay.learn-mini-quiz-overlay--wrong-answer .learn-mini-quiz-backdrop {
  background: rgba(0, 0, 0, 0.5);
  pointer-events: auto;
}
.learn-mini-quiz-overlay.learn-mini-quiz-overlay--wrong-answer .learn-mini-quiz-box {
  background: var(--card) !important;
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
  box-shadow: var(--shadow);
}
.learn-mini-quiz-overlay.learn-mini-quiz-overlay--wrong-answer.learn-mini-quiz-overlay--peek-help .learn-mini-quiz-box {
  background: var(--card) !important;
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
}
.learn-mini-quiz-overlay.learn-mini-quiz-overlay--wrong-answer .learn-mini-quiz-error-panel,
.learn-mini-quiz-overlay.learn-mini-quiz-overlay--wrong-answer .learn-mini-quiz-error-panel .learn-word-spell-wrap,
.learn-mini-quiz-overlay.learn-mini-quiz-overlay--wrong-answer .learn-mini-quiz-error-panel .learn-word,
.learn-mini-quiz-overlay.learn-mini-quiz-overlay--wrong-answer .learn-mini-quiz-error-panel .learn-spell-wrap,
.learn-mini-quiz-overlay.learn-mini-quiz-overlay--wrong-answer .learn-mini-quiz-error-panel .learn-spell-part {
  opacity: 1 !important;
  filter: none !important;
}

.learn-mini-quiz-need-help {
  box-sizing: border-box;
  width: 11.5rem;
  min-width: 11.5rem;
  max-width: 11.5rem;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
  text-align: center;
  white-space: nowrap;
  flex-shrink: 0;
}
.learn-mini-quiz-need-help[aria-pressed="true"] {
  font-weight: 600;
}
.learn-mini-quiz-box {
  position: fixed;
  left: 50%;
  z-index: 1;
  /* Top inset set in px via JS (--learn-mini-quiz-pad-top ≈ 10% page height at open). */
  top: max(var(--learn-mini-quiz-pad-top, 0px), env(safe-area-inset-top, 0px));
  transform: translate(calc(-50% + var(--mq-drag-x, 0px)), var(--mq-drag-y, 0px));
  pointer-events: auto;
  background: var(--card);
  border-radius: var(--radius);
  padding: 0.75rem 2rem 1.5rem;
  /* At least 75% of #main-pane (--learn-main-pane-width set when overlay opens). */
  max-width: min(calc(100vw - 2rem), var(--learn-main-pane-width, 860px));
  width: min(
    calc(var(--learn-main-pane-width, 860px) * 0.75),
    calc(100vw - 2rem)
  );
  min-width: min(
    calc(var(--learn-main-pane-width, 860px) * 0.75),
    calc(100vw - 2rem)
  );
  max-height: min(85vh, calc(100vh - var(--learn-mini-quiz-pad-top, 0px) - 1rem));
  overflow-y: auto;
  overflow-anchor: none;
  overscroll-behavior: contain;
  box-shadow: var(--shadow);
  box-sizing: border-box;
}
.learn-mini-quiz-box.learn-mini-quiz-box--dragging {
  box-shadow: 0 6px 28px rgba(45, 49, 66, 0.14);
}
/* Spell-the-slots popup: lock size after first paint so the inline hint does not resize the panel. */
.learn-mini-quiz-box.learn-mini-quiz-box--spell {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-sizing: border-box;
  contain: layout;
}

/* Screen-position lock (JS): inline top/left/width override centering + 100vw. */
.learn-mini-quiz-box.learn-mini-quiz-box--spell[data-mq-screen-pos-locked="1"] {
  right: auto;
  bottom: auto;
  margin: 0;
}
.learn-mini-quiz-box.learn-mini-quiz-box--spell .learn-mini-quiz-actions {
  flex-shrink: 0;
  margin-top: auto;
  padding-top: 0.25rem;
}
/* Hover/active scale on .btn shifts layout inside the fixed-height spell sheet. */
.learn-mini-quiz-actions .btn:hover:not(:disabled),
.learn-mini-quiz-actions .btn:active:not(:disabled) {
  transform: none;
}

/* Hear is .btn — Alt+Tab clears :hover while the pointer stays over it, which shrinks the row. */
.learn-mini-quiz-box.learn-mini-quiz-box--spell .learn-mini-quiz-hear.btn {
  position: static;
  z-index: auto;
  transform: none;
  transition: background 0.2s, box-shadow 0.2s, opacity 0.2s;
}
.learn-mini-quiz-box.learn-mini-quiz-box--spell .learn-mini-quiz-hear.btn:hover:not(:disabled),
.learn-mini-quiz-box.learn-mini-quiz-box--spell .learn-mini-quiz-hear.btn:active:not(:disabled) {
  transform: none;
}
.learn-mini-quiz-box.learn-mini-quiz-box--spell .learn-mini-quiz-hear.btn:focus,
.learn-mini-quiz-box.learn-mini-quiz-box--spell .learn-mini-quiz-hear.btn:focus-visible {
  outline: none !important;
  box-shadow: none !important;
  position: static !important;
  z-index: auto !important;
  transform: none !important;
}

.learn-mini-quiz-box.learn-mini-quiz-box--spell .learn-mini-quiz-delete {
  position: static;
  z-index: auto;
}

.learn-mini-quiz-box.learn-mini-quiz-box--spell.learn-mini-quiz-window-blurred .learn-mini-quiz-action-focus {
  outline: none !important;
  box-shadow: none !important;
}

.learn-mini-quiz-box.learn-mini-quiz-box--spell.learn-mini-quiz-window-blurred,
.learn-mini-quiz-box.learn-mini-quiz-box--spell.learn-mini-quiz-window-blurred * {
  transition: none !important;
}

.learn-mini-quiz-box.learn-mini-quiz-box--spell.learn-mini-quiz-window-blurred .learn-mini-quiz-close:hover,
.learn-mini-quiz-box.learn-mini-quiz-box--spell.learn-mini-quiz-window-blurred .learn-mini-quiz-delete:hover,
.learn-mini-quiz-box.learn-mini-quiz-box--spell.learn-mini-quiz-window-blurred .learn-mini-quiz-hear.btn:hover:not(:disabled) {
  transform: none;
  box-shadow: inherit;
}

.learn-mini-quiz-box.learn-mini-quiz-box--spell .learn-mini-quiz-close:focus-visible {
  outline: none !important;
  box-shadow: 0 2px 8px rgba(45, 49, 66, 0.14) !important;
  position: absolute !important;
  z-index: 3 !important;
  transform: none !important;
}

/* Spell popup: roving Tab highlight — native :focus-visible on Close/Delete shifts the sheet. */
.learn-mini-quiz-box.learn-mini-quiz-box--spell .learn-mini-quiz-close:focus,
.learn-mini-quiz-box.learn-mini-quiz-box--spell .learn-mini-quiz-close:focus-visible {
  outline: none !important;
  transform: none !important;
}

.learn-mini-quiz-box.learn-mini-quiz-box--spell .learn-mini-quiz-delete:focus,
.learn-mini-quiz-box.learn-mini-quiz-box--spell .learn-mini-quiz-delete:focus-visible,
.learn-mini-quiz-box.learn-mini-quiz-box--spell .learn-mini-quiz-hear:focus,
.learn-mini-quiz-box.learn-mini-quiz-box--spell .learn-mini-quiz-hear:focus-visible,
.learn-mini-quiz-box.learn-mini-quiz-box--spell .learn-mini-quiz-actions .btn:focus,
.learn-mini-quiz-box.learn-mini-quiz-box--spell .learn-mini-quiz-actions .btn:focus-visible {
  outline: none !important;
  box-shadow: none !important;
  position: static !important;
  z-index: auto !important;
  transform: none !important;
}

.learn-mini-quiz-box.learn-mini-quiz-box--spell .learn-mini-quiz-close.learn-mini-quiz-action-focus {
  outline: 2px solid var(--accent, #5b8def);
  outline-offset: 2px;
}

.learn-mini-quiz-box.learn-mini-quiz-box--spell .learn-mini-quiz-delete.learn-mini-quiz-action-focus,
.learn-mini-quiz-box.learn-mini-quiz-box--spell .learn-mini-quiz-hear.learn-mini-quiz-action-focus,
.learn-mini-quiz-box.learn-mini-quiz-box--spell .learn-mini-quiz-actions .btn.learn-mini-quiz-action-focus:not(#learn-mini-quiz-ok) {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
  box-shadow: none;
}

/* Next: inset indigo ring — outer outline/glow is clipped by overflow:hidden on the spell sheet. */
.learn-mini-quiz-box.learn-mini-quiz-box--spell .learn-mini-quiz-actions #learn-mini-quiz-ok:focus,
.learn-mini-quiz-box.learn-mini-quiz-box--spell .learn-mini-quiz-actions #learn-mini-quiz-ok:focus-visible,
.learn-mini-quiz-box.learn-mini-quiz-box--spell .learn-mini-quiz-actions #learn-mini-quiz-ok.learn-mini-quiz-action-focus {
  outline: none !important;
  box-shadow: inset 0 0 0 2px var(--focus-ring, #4f46e5) !important;
  position: relative !important;
  z-index: 2 !important;
  transform: none !important;
}

.learn-mini-quiz-close {
  position: absolute;
  top: 0.45rem;
  right: 0.45rem;
  z-index: 3;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 50%;
  background: rgba(226, 232, 240, 0.95);
  color: #2e333d;
  font-family: var(--font);
  font-size: 1.85rem;
  font-weight: 400;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(45, 49, 66, 0.14);
  touch-action: manipulation;
}
.learn-mini-quiz-close span {
  display: block;
  margin-top: -0.08em;
}
.learn-mini-quiz-close:hover {
  background: #e2e8f0;
}
.learn-mini-quiz-close:focus-visible {
  outline: 2px solid var(--accent, #5b8def);
  outline-offset: 2px;
}
.learn-mini-quiz-title {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
  color: var(--text);
}
.learn-mini-quiz-word-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin: 0 0 0.75rem;
  flex-wrap: wrap;
}
.learn-mini-quiz-hear {
  font-size: 0.95rem;
  padding: 0.3rem 0.55rem;
  border-radius: 10px;
}
.learn-mini-quiz-prompt {
  margin: 0 0 1rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}
.learn-mini-quiz-mask {
  margin: 0 0 1rem;
  font-size: 1.5rem;
  font-family: var(--font);
  letter-spacing: 0.05em;
  text-transform: lowercase;
  color: var(--text);
}
.learn-mini-quiz-mask:empty {
  display: none;
  margin: 0;
}
.learn-mini-quiz-slots-row {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  width: 100%;
  position: relative;
}
.learn-mini-quiz-slots {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: center;
  gap: 0.2rem;
  text-transform: lowercase;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
.learn-mini-quiz-char,
.learn-mini-quiz-slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  min-width: 1.1rem;
  width: auto;
  height: 1.6rem;
  min-height: 1.6rem;
  max-height: 1.6rem;
  font-size: 1.2rem;
  line-height: 1;
  font-family: var(--font);
  text-transform: lowercase;
  vertical-align: bottom;
}
.learn-mini-quiz-char {
  box-shadow: inset 0 -2px 0 transparent;
}
.learn-mini-quiz-slot {
  box-shadow: inset 0 -2px 0 #e5e7eb;
}
.learn-mini-quiz-slot-current {
  background: rgba(232, 93, 117, 0.12);
  box-shadow: inset 0 -2px 0 var(--primary);
}
.learn-mini-quiz-slot:active {
  background: rgba(232, 93, 117, 0.12);
}
.learn-mini-quiz-slot.learn-mini-quiz-slot-correct,
.learn-mini-quiz-char.learn-mini-quiz-char-correct {
  box-shadow: inset 0 -2px 0 var(--success);
  background: rgba(74, 222, 128, 0.2);
  color: var(--text);
}
.learn-mini-quiz-slots.learn-mini-quiz-slots-correct .learn-mini-quiz-slot-current {
  background: rgba(74, 222, 128, 0.2);
  box-shadow: inset 0 -2px 0 var(--success);
}
.learn-mini-quiz-delete {
  border: none;
  background: #e5e7eb;
  border-radius: 999px;
  padding: 0.25rem 0.6rem;
  cursor: pointer;
  font-size: 1rem;
}
.learn-mini-quiz-delete:hover {
  background: #d1d5db;
}
.learn-mini-quiz-input {
  position: absolute;
  left: 0;
  top: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.learn-mini-quiz-box.learn-mini-quiz-box--spell .learn-mini-quiz-input:focus,
.learn-mini-quiz-box.learn-mini-quiz-box--spell .learn-mini-quiz-input:focus-visible {
  outline: none !important;
  box-shadow: none !important;
}
.learn-mini-quiz-error {
  margin: 0 0 0.75rem;
  color: var(--wrong);
  font-size: 0.9rem;
}
.learn-mini-quiz-hint {
  margin: 0 0 0.75rem;
  min-height: 1.5rem;
  line-height: 1.5rem;
  font-size: 1.1rem;
  font-weight: 600;
  text-align: center;
  color: #f3b8c8;
  opacity: 0;
  transition: opacity 0.12s ease-out;
}
.learn-mini-quiz-hint.is-visible {
  opacity: 1;
  color: #e8a0b4;
}
.learn-mini-quiz-error.hidden {
  display: none !important;
}
.learn-mini-quiz-error-panel.hidden {
  display: none !important;
}
.learn-mini-quiz-error-panel {
  text-align: center;
  margin-bottom: 0.5rem;
}
.learn-mini-quiz-error-label {
  margin: 0 0 0.65rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
}
.learn-mini-quiz-error-word-spell {
  margin: 0 auto 0.75rem;
}
.learn-mini-quiz-error-word-spell .learn-word {
  animation: none;
}
.learn-mini-quiz-error-word-spell .learn-spell-wrap {
  margin-top: 0.5rem;
  margin-bottom: 0;
}
.learn-mini-quiz-box.learn-mini-quiz-box--wrong-answer .learn-mini-quiz-title,
.learn-mini-quiz-box.learn-mini-quiz-box--wrong-answer .learn-mini-quiz-word-row,
.learn-mini-quiz-box.learn-mini-quiz-box--wrong-answer .learn-mini-quiz-prompt,
.learn-mini-quiz-box.learn-mini-quiz-box--wrong-answer .learn-mini-quiz-mask,
.learn-mini-quiz-box.learn-mini-quiz-box--wrong-answer .learn-mini-quiz-slots-row,
.learn-mini-quiz-box.learn-mini-quiz-box--wrong-answer .learn-mini-quiz-hint,
.learn-mini-quiz-box.learn-mini-quiz-box--wrong-answer .learn-mini-quiz-back,
.learn-mini-quiz-box.learn-mini-quiz-box--wrong-answer .learn-mini-quiz-need-help,
.learn-mini-quiz-box.learn-mini-quiz-box--answer-correct .learn-mini-quiz-back,
.learn-mini-quiz-box.learn-mini-quiz-box--answer-correct .learn-mini-quiz-need-help {
  display: none !important;
}
.learn-mini-quiz-delete:disabled,
.learn-mini-quiz-hear:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
#learn-mini-quiz-ok.learn-mini-quiz-ok--inactive {
  opacity: 0.55;
  cursor: not-allowed;
}
#learn-mini-quiz-ok.learn-mini-quiz-ok--inactive:focus,
#learn-mini-quiz-ok.learn-mini-quiz-ok--inactive:focus-visible,
#learn-mini-quiz-ok.learn-mini-quiz-ok--inactive.learn-mini-quiz-action-focus {
  outline: none !important;
  box-shadow: none !important;
}
@keyframes learn-mini-quiz-slot-flash {
  0%,
  100% {
    background: rgba(232, 93, 117, 0.1);
    box-shadow: inset 0 -2px 0 #e5e7eb;
  }
  50% {
    background: rgba(232, 93, 117, 0.38);
    box-shadow: inset 0 -2px 0 var(--primary);
  }
}
.learn-mini-quiz-slot.learn-mini-quiz-slot-missing-flash {
  animation: learn-mini-quiz-slot-flash 0.45s ease-in-out 2;
}
.learn-mini-quiz-actions {
  margin-top: 1rem;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.learn-drill-hide {
  display: none !important;
}

/* Spell mini-quiz recall: scaffolding visibility from quest rules (recallScaffold matrix). */
#phase-learn.learn-recall-scaffold--dimmed .learn-image-wrap,
#phase-learn.learn-recall-scaffold--dimmed .learn-word-spell-wrap,
#phase-learn.learn-recall-scaffold--dimmed .learn-meaning {
  opacity: 0.42;
  filter: blur(2.5px);
  pointer-events: none;
  transition: opacity 0.2s ease, filter 0.2s ease;
}
#phase-learn.learn-recall-scaffold--dimmed .learn-image {
  filter: blur(2.5px);
}

/* Mini-quiz overlay (incl. wrong-answer word/breakdown) must not inherit recall dim/blur. */
#phase-learn.learn-recall-scaffold--dimmed .learn-mini-quiz-overlay .learn-image-wrap,
#phase-learn.learn-recall-scaffold--dimmed .learn-mini-quiz-overlay .learn-word-spell-wrap,
#phase-learn.learn-recall-scaffold--dimmed .learn-mini-quiz-overlay .learn-meaning,
#phase-learn.learn-recall-scaffold--dimmed .learn-mini-quiz-overlay .learn-word,
#phase-learn.learn-recall-scaffold--dimmed .learn-mini-quiz-overlay .learn-spell-wrap,
#phase-learn.learn-recall-scaffold--dimmed .learn-mini-quiz-overlay .learn-spell-part,
#phase-learn.learn-recall-scaffold--dimmed .learn-mini-quiz-overlay .learn-image {
  opacity: 1 !important;
  filter: none !important;
  pointer-events: auto;
}

/* "I need help" peek: show learn page at full clarity under the popup. */
#phase-learn.learn-recall-scaffold--peek-unobscured.learn-recall-scaffold--dimmed .learn-image-wrap,
#phase-learn.learn-recall-scaffold--peek-unobscured.learn-recall-scaffold--dimmed .learn-word-spell-wrap,
#phase-learn.learn-recall-scaffold--peek-unobscured.learn-recall-scaffold--dimmed .learn-meaning,
#phase-learn.learn-recall-scaffold--peek-unobscured .learn-image-wrap,
#phase-learn.learn-recall-scaffold--peek-unobscured .learn-word-spell-wrap,
#phase-learn.learn-recall-scaffold--peek-unobscured .learn-meaning {
  opacity: 1 !important;
  filter: none !important;
  pointer-events: auto;
}
#phase-learn.learn-recall-scaffold--peek-unobscured .learn-image {
  filter: none !important;
}

.splash-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: linear-gradient(135deg, #ffeef8 0%, #e0f7fa 50%, #fff9e6 100%);
  opacity: 1;
  transition: opacity 0.5s ease-out;
  pointer-events: auto;
  cursor: default;
  overflow: hidden;
  font-family: var(--font);
}

.splash-overlay.hidden {
  display: none !important;
}

.splash-overlay.fade-out {
  opacity: 0;
}

/* Behind login gate: show art only; Child/Adult choice comes after sign-in */
.splash-overlay.splash-overlay--background {
  pointer-events: none;
}
.splash-overlay.splash-overlay--background .splash-choices {
  display: none !important;
}

/* After sign-in: continue as Adult only (Child choice not offered on splash) */
.splash-overlay.splash-overlay--adult-only #splash-btn-child {
  display: none !important;
}

.splash-inner {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  box-sizing: border-box;
  overflow: hidden;
}

/* Duplicate splash art: fills viewport area with cover; ~85% transparent (~15% opaque) */
.splash-back-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  opacity: 0.15;
  pointer-events: none;
  z-index: 0;
}

.splash-image {
  position: relative;
  z-index: 1;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.splash-stars {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.splash-star {
  position: absolute;
  left: var(--x, 50%);
  top: var(--y, 50%);
  transform: translate(-50%, -50%) scale(0);
  font-size: clamp(1.5rem, 4vw, 3rem);
  animation: splash-star-explode 1.8s ease-in-out var(--d, 0s) infinite;
  opacity: 0;
  filter: drop-shadow(0 0 4px rgba(255, 235, 59, 0.9));
}

.splash-star:nth-child(odd) {
  color: #ffeb3b;
}
.splash-star:nth-child(3n) {
  color: #ff9800;
}
.splash-star:nth-child(3n + 1) {
  color: #fff176;
}
.splash-star:nth-child(3n + 2) {
  color: #ffd54f;
}

.splash-star::before {
  content: '★';
}

@keyframes splash-star-explode {
  0%, 100% {
    transform: translate(-50%, -50%) scale(0);
    opacity: 0;
  }
  45% {
    transform: translate(-50%, -50%) scale(1.4);
    opacity: 0.9;
  }
  55% {
    transform: translate(-50%, -50%) scale(1.4);
    opacity: 0.9;
  }
}

.splash-choices {
  position: absolute;
  bottom: clamp(2rem, 8vh, 4rem);
  left: 0;
  right: 0;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
  padding: 0 1rem;
  pointer-events: auto;
}
.splash-choice-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-width: 8rem;
  padding-top: 0.05rem;
  padding-bottom: 0.05rem;
  line-height: 1.2;
  cursor: grab;
  font-family: var(--font);
  position: relative;
  overflow: hidden;
}
#splash-btn-adult::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  height: 5px;
  width: 0;
  background: var(--primary, #e85d75);
  border-radius: 0 2px 2px 0;
  opacity: 0;
  pointer-events: none;
}
#splash-btn-adult.splash-btn-adult-holding::after {
  opacity: 1;
  width: 100%;
  transition: width 2s linear;
}
#wizard-howto-adult-test {
  position: relative;
  overflow: hidden;
  cursor: pointer;
}
#wizard-howto-adult-test::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  height: 5px;
  width: 0;
  background: var(--primary, #e85d75);
  border-radius: 0 2px 2px 0;
  opacity: 0;
  pointer-events: none;
}
#wizard-howto-adult-test.wizard-howto-holding::after {
  opacity: 1;
  width: 100%;
  transition: width 2s linear;
}
.wizard-howto-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin: 1rem 0;
  flex-wrap: wrap;
}
.wizard-howto-child-preview {
  opacity: 0.5;
  cursor: default;
  pointer-events: none;
}
.wizard-howto-audio {
  margin: 1.25rem 0 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: flex-start;
}
.wizard-howto-confirm-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1rem;
  cursor: pointer;
}
.wizard-howto-success {
  color: var(--success, #2a8c4a);
  font-weight: 600;
}
.wizard-howto-ready {
  font-weight: 600;
  color: var(--primary, #e85d75);
  margin: 0.5rem 0 0.25rem;
}
.wizard-group-parent-custom-hint {
  color: var(--text-secondary, #666);
  font-size: 0.9em;
  margin-top: 0.35rem;
}
.splash-choice-emoji {
  font-size: 1.8em;
  line-height: 1;
  display: inline-block;
  vertical-align: middle;
  font-family: var(--font);
}
.splash-choice-label {
  font-size: clamp(1.22rem, 3.2vw, 1.5rem);
  font-weight: 800;
  letter-spacing: 0.02em;
  font-family: var(--font);
}

.splash-welcome {
  position: absolute;
  top: clamp(1.5rem, 5vh, 3rem);
  left: 0;
  right: 0;
  z-index: 2;
  margin: 0 1rem;
  font-family: var(--font);
  font-size: clamp(1.5rem, 5vw, 2.5rem);
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  color: #d84315;
  -webkit-text-stroke: 0.02em rgba(255, 255, 255, 0.9);
  text-shadow:
    0 0 0.08em #fff,
    0 0 0.2em #ffeb3b,
    0 0 0.4em #ff9800,
    0 2px 6px rgba(0, 0, 0, 0.2);
}

/* Mode switch (Child/Parent): top left of page */
.mode-switch-wrap {
  position: fixed;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 100;
}
.mode-switch-badge {
  font-family: var(--font);
  font-size: 1.08rem;
  font-weight: 500;
  color: var(--text-secondary, #64748b);
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.35rem;
  padding: 0.22rem 0.45rem;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
  background: #f1f5f9;
  cursor: pointer;
  margin: 0;
  line-height: 1.25;
  min-width: 14rem;
  box-sizing: border-box;
  text-align: left;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
  transition:
    min-width 0.45s ease-in-out,
    gap 0.45s ease-in-out,
    padding 0.45s ease-in-out,
    background 0.2s ease,
    color 0.2s ease,
    box-shadow 0.45s ease-in-out,
    transform 0.2s ease;
}
/* Press-and-hold affordance for the child->adult gate (01 §5.5): a subtle
   bar fills left-to-right over the 2s hold so a grown-up sees the press
   registering. A child's quick tap shows almost nothing and never completes. */
.mode-switch-badge::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: 0;
  background: var(--primary, #e85d75);
  border-radius: 0 2px 2px 0;
  opacity: 0;
  pointer-events: none;
}
.mode-switch-badge.mode-switch-holding::after {
  opacity: 1;
  width: 100%;
  transition: width 2s linear;
}
.mode-switch-badge .mode-switch-emoji {
  font-size: 1.72rem;
  line-height: 1;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font);
}
.mode-switch-badge .mode-switch-text {
  font-size: 1.08rem;
  font-weight: inherit;
  line-height: 1.25;
  font-family: var(--font);
  transition: max-width 0.45s ease-in-out, opacity 0.4s ease-in-out, margin 0.45s ease-in-out;
}
/* After leaving the front page (Learn / Quest / Play): emoji only until hover or keyboard focus. */
.mode-switch-badge.mode-switch-compact {
  min-width: 0;
  width: auto;
  gap: 0;
  padding: 0.22rem 0.4rem;
  justify-content: flex-start;
}
.mode-switch-badge.mode-switch-compact .mode-switch-text {
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  margin: 0;
  padding: 0;
  pointer-events: none;
}
.mode-switch-badge.mode-switch-compact:hover,
.mode-switch-badge.mode-switch-compact:focus-visible {
  min-width: 14rem;
  gap: 0.35rem;
  padding: 0.22rem 0.45rem;
  justify-content: flex-start;
}
.mode-switch-badge.mode-switch-compact:hover .mode-switch-text,
.mode-switch-badge.mode-switch-compact:focus-visible .mode-switch-text {
  max-width: 14rem;
  opacity: 1;
  margin: 0;
  pointer-events: auto;
}
.mode-switch-badge.mode-switch-compact.mode-switch-emphasized {
  min-width: 0;
}
.mode-switch-badge.mode-switch-compact.mode-switch-emphasized:hover,
.mode-switch-badge.mode-switch-compact.mode-switch-emphasized:focus-visible {
  min-width: 14rem;
}
.mode-switch-badge:hover {
  background: #e2e8f0;
  color: var(--text, #1e293b);
}

/* Parent/adult mode: draw attention to switching to child view — same dimensions as child-mode label */
.mode-switch-badge.mode-switch-emphasized {
  font-size: 1.08rem;
  font-weight: 700;
  padding: 0.22rem 0.45rem;
  min-width: 14rem;
  color: #fff;
  background: linear-gradient(135deg, #e85d75 0%, #c94c62 100%);
  box-shadow: 0 2px 8px rgba(232, 93, 117, 0.5), 0 0 0 2px rgba(255, 255, 255, 0.8);
  border-radius: 8px;
}
.mode-switch-badge.mode-switch-emphasized:hover {
  background: linear-gradient(135deg, #ef7a8f 0%, #e85d75 100%);
  box-shadow: 0 3px 12px rgba(232, 93, 117, 0.6), 0 0 0 2px #fff;
  transform: scale(1.02);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  font-family: var(--font);
  background: linear-gradient(135deg, #ffeef8 0%, #e0f7fa 50%, #fff9e6 100%);
  background-attachment: fixed;
  color: var(--text);
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  --page-pad-top: 0.2rem;
  --page-pad-x: 0.75rem;
  --page-pad-bottom: 0.75rem;
  padding: max(var(--page-pad-top), env(safe-area-inset-top))
    max(var(--page-pad-x), env(safe-area-inset-right))
    max(var(--page-pad-bottom), env(safe-area-inset-bottom))
    max(var(--page-pad-x), env(safe-area-inset-left));
  position: relative;
  overflow-x: hidden;
  overflow-y: auto;
  box-sizing: border-box;
}

/* Non-front pages: only a few pixels at top and bottom; hide empty header. */
body:not(.is-frontpage) {
  --page-pad-top: 4px;
  --page-pad-bottom: 4px;
}

body:not(.is-frontpage) .header {
  display: none;
}

/* ── Home screen height containment (mirrors body:has(#phase-settings) pattern)
   Outer flex chain fills the viewport; the input-card-grid scrolls internally;
   action buttons are a flex-shrink:0 sibling of the grid, always visible.
   ────────────────────────────────────────────────────────────────────────── */
body:has(#phase-input.active) .app-wrap { align-items: stretch; }
body:has(#phase-input.active) .app-center-wrap { flex: 0 0 min(860px, 100%); }
body:has(#phase-input.active) .app     { flex: 1 1 0; min-height: 0; max-width: 860px; }
body:has(#phase-input.active) .main-pane { flex: 1 1 0; min-height: 0; }

#phase-input.active {
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
}

/* Card becomes a flex column so the grid can scroll and the action row is pinned.
   flex: 0 0 auto  → sizes to content (no forced full-height stretch).
   max-height: 100% → caps at the available phase height so it never overlaps the status line. */
.input-card {
  flex: 0 0 auto;
  max-height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.input-card > #pane-profile-row,
.input-card > #home-notice {
  flex-shrink: 0;
}

/* Scrollable content panel — same role as .settings-panel in the Adults screen.
   flex-basis: auto → natural content height when card is short (no collapse);
   flex-shrink: 1 + min-height: 0 → shrinks to fit when card hits max-height, enabling the scrollbar. */
.input-card > .input-card-grid {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Action buttons pinned at bottom — same role as .actions-row in settings-card */
.input-card > .input-count-actions-row {
  flex-shrink: 0;
  padding-top: 0.4rem;
}

/* Quest / learn / assess: no phantom body scroll (scrollbar thumb jitter on hover). */
body.exercise-phase-active {
  overflow-y: clip;
  overscroll-behavior: none;
  scrollbar-gutter: stable;
}

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: 
    radial-gradient(circle at 20% 30%, rgba(255, 200, 87, 0.15) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(232, 93, 117, 0.15) 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, rgba(92, 184, 178, 0.1) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* Splash image as a very faint background on all pages (set by JS when splash loads) */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  background-image: var(--splash-bg-image, url('/img/splash.jpg'));
  background-size: cover;
  background-position: center;
  opacity: 0.07;
  pointer-events: none;
}

/* T1–T5: current theme test image (0–4) instead of splash */
body.exercise-test-bg-active::after {
  background-image: var(--exercise-test-bg-image);
}

/* Frontpage intro: glow highlight on input and buttons during spoken guide */
.intro-glow {
  animation: intro-glow-pulse 1.2s ease-in-out infinite;
  box-shadow: 0 0 0 3px rgba(255, 200, 87, 0.5), 0 0 20px rgba(255, 200, 87, 0.35);
}

@keyframes intro-glow-pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(255, 200, 87, 0.5), 0 0 20px rgba(255, 200, 87, 0.35); }
  50% { box-shadow: 0 0 0 4px rgba(255, 200, 87, 0.7), 0 0 28px rgba(255, 200, 87, 0.5); }
}

.app-wrap {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
  flex: 1 1 0;
  min-height: 0;
  position: relative;
  z-index: 1;
  overflow: visible;
}

/* When Lists pane is open, stretch so .app can fill height and list pane extends to bottom */
body:has(#phase-load-list.active) .app-wrap {
  align-items: stretch;
}

body:has(#phase-achievements.active) .app-wrap {
  align-items: stretch;
}

/* Main app (quiz/map) and expertise ladder sit together; fixed width so pane does not shrink (e.g. in T2) */
.app-center-wrap {
  flex: 0 0 580px;
  max-width: 100%;
  display: flex;
  flex-direction: row;
}

.app {
  max-width: 580px;
  width: 100%;
  flex: 0 0 auto;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}

body:has(#phase-load-list.active) .app {
  flex: 1 1 0;
  min-height: 0;
}


.header {
  flex-shrink: 0;
  margin-bottom: 0.4rem;
}

.main-pane {
  flex: 0 0 auto;
  min-height: auto;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: visible;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

body:has(#phase-load-list.active) .main-pane {
  flex: 1 1 0;
  min-height: 0;
}

body:has(#phase-achievements.active) .app {
  flex: 1 1 0;
  min-height: 0;
}

body:has(#phase-achievements.active) .main-pane {
  flex: 1 1 0;
  min-height: 0;
}

#phase-achievements.active {
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
  width: 100%;
  max-width: 100%;
}


.header-nickname {
  font-family: var(--font);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  max-width: 8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-nickname.hidden {
  display: none;
}

.btn-home {
  flex-shrink: 0;
  align-self: center;
  box-sizing: border-box;
  padding: 0.7rem 0.95rem;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
  font-size: 1.15rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.15s;
}

.btn-home:hover {
  background: #fff;
  transform: scale(1.05);
}

.btn-home.hidden {
  display: none !important;
}

/* Quest treasure tiers (Bronze / Silver / Gold / Master) — card buttons only, never floating 🏠 */
body:has(#phase-school-story.active) #home-btn,
body:has(#phase-school-cover.active) #home-btn,
body:has(#phase-school-video.active) #home-btn,
#phase-school-story.active .actions #home-btn,
#phase-school-cover.active .actions #home-btn,
#phase-school-video.active .actions #home-btn {
  display: none !important;
  pointer-events: none !important;
}

.header-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* Difficulty and complexity badges: child = bottom-left stack; adult = full-width status line */
.difficulty-badge-wrap {
  position: fixed;
  bottom: max(0.5rem, env(safe-area-inset-bottom));
  left: max(0.5rem, env(safe-area-inset-left));
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
}

/* Adult view: one horizontal status line along the bottom of the viewport */
body:not(.app-child-mode):not(.profile-setup-incomplete) {
  --system-status-bar-height: 2.35rem;
  --page-pad-bottom: max(2.85rem, calc(env(safe-area-inset-bottom) + 2.35rem));
}

body:not(.app-child-mode):not(.profile-setup-incomplete) .difficulty-badge-wrap.system-status-bar {
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 100%;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-start;
  gap: 0;
  padding: 0.35rem max(0.75rem, env(safe-area-inset-right)) max(0.35rem, env(safe-area-inset-bottom)) max(0.75rem, env(safe-area-inset-left));
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid #e2e8f0;
  box-shadow: 0 -2px 10px rgba(15, 23, 42, 0.06);
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

body:not(.app-child-mode):not(.profile-setup-incomplete) .difficulty-badge-wrap.system-status-bar > * {
  flex-shrink: 0;
  margin: 0;
  padding-top: 0;
  padding-bottom: 0;
}

body:not(.app-child-mode):not(.profile-setup-incomplete) .difficulty-badge-wrap.system-status-bar > * + * {
  margin-left: 0.7rem;
  padding-left: 0.7rem;
  border-left: 1px solid #cbd5e1;
}

body:not(.app-child-mode):not(.profile-setup-incomplete) .difficulty-badge-wrap .difficulty-badge,
body:not(.app-child-mode):not(.profile-setup-incomplete) .difficulty-badge-wrap .difficulty-mode-badge,
body:not(.app-child-mode):not(.profile-setup-incomplete) .difficulty-badge-wrap .complexity-badge {
  font-size: 0.72rem;
  padding: 0.2rem 0.45rem;
}

body:not(.app-child-mode):not(.profile-setup-incomplete) .difficulty-badge-wrap .list-type-footer-line,
body:not(.app-child-mode):not(.profile-setup-incomplete) .difficulty-badge-wrap .user-id-footer-line {
  max-width: none;
  font-size: 0.72rem;
  padding: 0;
  line-height: 1.3;
  white-space: nowrap;
}

/* Adult mode: position panel just above the bottom status bar */
body:not(.app-child-mode):not(.profile-setup-incomplete) .floating-keyboard-panel {
  bottom: calc(env(safe-area-inset-bottom, 0px) + var(--system-status-bar-height, 2.35rem) + 8px);
}

/* Child view: no status bar — base pill styling only (fixed bottom-left corner, no bar chrome) */
body.app-child-mode {
  --system-status-bar-height: 0rem;
  --page-pad-bottom: env(safe-area-inset-bottom, 0px);
}

body.app-child-mode .difficulty-badge-wrap .difficulty-badge {
  font-size: 0.72rem;
  padding: 0.2rem 0.45rem;
  cursor: default;
}

/* Feedback button — adult: rightmost item in the status bar; child: fixed bottom-right pill */
body:not(.app-child-mode):not(.profile-setup-incomplete) .difficulty-badge-wrap.system-status-bar .status-feedback-btn {
  margin-left: auto;
  font-size: 0.72rem;
  font-weight: 500;
  color: #64748b;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.2rem 0.45rem;
  line-height: 1.3;
  white-space: nowrap;
}
body:not(.app-child-mode):not(.profile-setup-incomplete) .difficulty-badge-wrap.system-status-bar .status-feedback-btn:hover {
  color: #1e293b;
  text-decoration: underline;
  text-underline-offset: 2px;
}
body.app-child-mode .status-feedback-btn {
  position: fixed;
  bottom: max(0.5rem, env(safe-area-inset-bottom));
  right: max(0.5rem, env(safe-area-inset-right));
  z-index: 100;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.1);
  color: #475569;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
body.app-child-mode .status-feedback-btn:hover {
  background: #f1f5f9;
  color: #1e293b;
}

/* Incomplete registration (signed in, avatar not saved): hide global chrome. */
body.profile-setup-incomplete #app-mode-switch-wrap,
body.profile-setup-incomplete #difficulty-complexity-wrap {
  display: none !important;
}

/* Hide the mode-switch badge while on the Adults/settings page. */
body.phase-settings #app-mode-switch-wrap {
  display: none !important;
}

/* Child view: no Adult-view switch on hero/profile pick (Select your hero). */
body.app-child-mode.phase-profile #app-mode-switch-wrap {
  display: none !important;
}

/* Hide format (i) tooltip in Simple/Advanced adult modes — only relevant when typing words (Full control). */
body.adult-mode-default #hint-info-wrap,
body.adult-mode-extra #hint-info-wrap,
/* Child view: bottom-left strip shows only the day pill (no complexity, list type, or user id). */
body.app-child-mode #hint-info-wrap,
body.app-child-mode #word-input,
body.app-child-mode #add-word,
body.app-child-mode #copy-words-btn,
body.app-child-mode #phase-input .input-row,
body.app-child-mode .input-main,
body.app-child-mode .input-buttons-column,
body.app-child-mode #difficulty-mode-badge,
body.app-child-mode #complexity-badge,
body.app-child-mode #list-type-footer-line,
body.app-child-mode #user-id-footer-line {
  display: none !important;
}
.input-words-panel {
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px;
  padding: 0.75rem;
  margin: 0 0 0.75rem 0;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
.input-words-panel legend,
.input-words-panel-legend {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
  padding: 0 0.3rem;
}
.input-words-panel .word-list-wrap {
  margin: 0;
}
body.app-child-mode .difficulty-badge {
  cursor: default;
}

/* Adult auto-list active (Simple/Advanced mode with a resolved school list):
   hide the input controls — only the word list and action buttons remain. */
body.adult-auto-list-active:not(.app-child-mode) .input-main,
body.adult-auto-list-active:not(.app-child-mode) .input-buttons-column {
  display: none !important;
}
.difficulty-badge {
  font-family: var(--font);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  box-shadow: var(--shadow);
  cursor: help;
}
.difficulty-badge.difficulty-easy {
  background: rgba(34, 197, 94, 0.25);
  color: #166534;
}
.difficulty-badge.difficulty-medium {
  background: rgba(234, 179, 8, 0.3);
  color: #854d0e;
}
.difficulty-badge.difficulty-difficult {
  background: rgba(239, 68, 68, 0.25);
  color: #991b1b;
}
@keyframes difficulty-badge-flash {
  0%, 100% { opacity: 1; transform: scale(1); font-size: 0.75rem; }
  50% { opacity: 0.4; transform: scale(1.08); font-size: 2.25rem; }
}
.difficulty-badge.difficulty-badge-flash {
  animation: difficulty-badge-flash 0.8s ease-in-out 3;
}
.difficulty-mode-badge {
  font-family: var(--font);
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-secondary, #64748b);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  cursor: help;
}
.difficulty-mode-badge.hidden {
  display: none !important;
}
.complexity-badge {
  font-family: var(--font);
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-secondary, #64748b);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  cursor: help;
}

.list-type-footer-line {
  font-family: var(--font);
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--text-secondary, #64748b);
  padding: 0.1rem 0.35rem 0;
  max-width: min(96vw, 22rem);
  line-height: 1.25;
  cursor: help;
}

.list-type-footer-line[hidden] {
  display: none !important;
}

.user-id-footer-line[hidden] {
  display: none !important;
}

/* Plain text user ID below complexity / list type (same corner stack, no pill) */
.user-id-footer-line {
  margin: 0;
  padding: 0.05rem 0.35rem 0;
  max-width: min(96vw, 22rem);
  font-size: 0.68rem;
  line-height: 1.25;
  color: var(--text-secondary, #64748b);
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  background: none;
  border: none;
  border-radius: 0;
  box-shadow: none;
  -webkit-tap-highlight-color: transparent;
}
.user-id-footer-line:hover {
  color: var(--text, #475569);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Achievements button (frontpage profile row) */
.btn-achievements-icon {
  background: none;
  border: none;
  cursor: pointer;
  font-size: clamp(2rem, 5vw, 2.5rem);
  line-height: 1;
  padding: 0.2rem 0.35rem;
  border-radius: 6px;
  opacity: 0.7;
  transition: opacity 0.15s;
  margin-left: 0.3rem;
}
.btn-achievements-icon:hover {
  opacity: 1;
  background: rgba(0,0,0,0.05);
}

.streak-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: #b45309;
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border: 1px solid #f59e0b;
  border-radius: 12px;
  padding: 0.15rem 0.55rem;
  margin: 0;
  white-space: nowrap;
  animation: streakPulse 2s ease-in-out infinite;
}
@keyframes streakPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245,158,11,0.3); }
  50% { box-shadow: 0 0 8px 2px rgba(245,158,11,0.35); }
}

/* Achievements page */
.achievements-card {
  padding: 0;
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 1;
}

.achievements-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-shrink: 0;
  padding: clamp(0.75rem, 2vw, 1rem) clamp(0.85rem, 2.2vw, 1.35rem);
  border-bottom: 2px solid rgba(226, 232, 240, 0.95);
  background: linear-gradient(135deg, #ffffff 0%, #fef9f0 100%);
  position: sticky;
  top: 0;
  z-index: 3;
}

.achievements-header-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  text-align: left;
}

.achievements-header-icon {
  font-size: 1.85rem;
  line-height: 1;
  flex-shrink: 0;
}

.achievements-title {
  font-size: clamp(1.15rem, 3.5vw, 1.4rem);
  text-align: left;
}

.achievements-card .achievements-title {
  margin: 0;
}

.achievements-back-btn {
  flex-shrink: 0;
}

.achievements-scroll {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  padding: clamp(0.85rem, 2.2vw, 1.35rem);
  -webkit-overflow-scrolling: touch;
}

/* ===== Achievements rebuild (10 §6) ===== */
.achievements-points-callout {
  text-align: center;
  font-size: clamp(1.05rem, 3.2vw, 1.35rem);
  font-weight: 600;
  color: var(--text);
  margin: 0 0 1.1rem;
}
.achievements-points-callout strong {
  color: var(--primary, #e85d75);
  font-size: 1.25em;
}
.achievements-section { margin: 0 0 1.6rem; }
.achievements-section-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0 0 0.6rem;
  color: var(--text);
}
.achievements-section-empty {
  color: var(--text-secondary, #64748b);
  font-size: 0.95rem;
  margin: 0.2rem 0 0;
}
.achievements-trophies {
  display: flex;
  gap: 0.7rem;
  overflow-x: auto;
  padding-bottom: 0.3rem;
  -webkit-overflow-scrolling: touch;
}
.achievements-trophy {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  width: 5.5rem;
  padding: 0.6rem 0.4rem;
  background: rgba(255, 200, 87, 0.14);
  border: 2px solid var(--accent, #ffc857);
  border-radius: 12px;
  cursor: pointer;
  text-align: center;
}
.achievements-trophy-icon { font-size: 2rem; line-height: 1; }
.achievements-trophy-name {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.achievements-cycles {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
.achievements-cycle-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.9rem;
  background: var(--card, #fff);
  border: 1px solid rgba(100, 116, 139, 0.22);
  border-radius: 12px;
}
.achievements-cycle-chest { font-size: 1.7rem; line-height: 1; flex: 0 0 auto; }
.achievements-cycle-body { flex: 1 1 auto; min-width: 0; }
.achievements-cycle-list {
  font-weight: 700;
  color: var(--text);
}
.achievements-cycle-meta {
  font-size: 0.85rem;
  color: var(--text-secondary, #64748b);
}
.achievements-cycle-tier {
  font-weight: 700;
  text-transform: capitalize;
}

.achievements-list {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}
.achievements-loading,
.achievements-error {
  text-align: center;
  color: var(--text-secondary, #64748b);
  padding: 2rem 0;
}
.achievements-empty {
  text-align: center;
  color: var(--text-secondary, #64748b);
  padding: 2rem 0;
}
.achievements-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.achievements-group-toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  margin: 0;
  padding: 0 0 0.35rem 0;
  border: none;
  border-bottom: 1px solid var(--border, #e2e8f0);
  background: transparent;
  font: inherit;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text, #2d3142);
  text-align: left;
  cursor: pointer;
  border-radius: 6px;
}
.achievements-group-toggle:hover {
  color: var(--primary, #e85d75);
}
.achievements-group-toggle:focus-visible {
  outline: 2px solid var(--primary, #e85d75);
  outline-offset: 2px;
}
.achievements-group-chevron {
  flex-shrink: 0;
  width: 1.1rem;
  font-size: 0.75rem;
  opacity: 0.85;
}
.achievements-group-label {
  flex: 1;
  min-width: 0;
}
.achievements-group-body {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.achievements-group--collapsed .achievements-group-body {
  display: none;
}
.achievement-card {
  position: relative;
  background: var(--card-bg, #fff);
  border-radius: 10px;
  box-shadow: var(--shadow, 0 1px 3px rgba(0,0,0,0.12));
  overflow: visible;
  transition: transform 0.15s;
}
.achievement-tooltip {
  display: none;
  position: absolute;
  z-index: 8;
  top: 0.4rem;
  right: 0.4rem;
  max-width: min(16rem, calc(100% - 0.8rem));
  max-height: 10rem;
  overflow-y: auto;
  padding: 0.45rem 0.55rem;
  font-size: 0.72rem;
  line-height: 1.4;
  background: var(--card, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.15);
  pointer-events: none;
  text-align: left;
}
.achievement-card:hover .achievement-tooltip {
  display: block;
}
.achievement-tooltip-k {
  font-weight: 600;
}
.achievement-tooltip-correct {
  color: #15803d;
  margin-bottom: 0.35rem;
}
.achievement-tooltip-incorrect {
  color: var(--text, #2d3142);
}
.achievement-tooltip-empty {
  opacity: 0.65;
}
.achievement-card:hover {
  transform: translateY(-1px);
}
.achievement-card-inner {
  display: flex;
  gap: 0.8rem;
  padding: 0.7rem;
  align-items: center;
}
.achievement-video-wrap {
  flex-shrink: 0;
  width: 100px;
  border-radius: 8px;
  overflow: hidden;
  background: #f1f5f9;
}
.achievement-video {
  width: 100%;
  display: block;
  border-radius: 8px;
  cursor: pointer;
}
.achievement-info {
  flex: 1;
  min-width: 0;
}
.achievement-test-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text, #2d3142);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  line-height: 1.35;
}
.achievement-test-area {
  color: var(--text, #2d3142);
}
.achievement-test-pill {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  font-weight: 500;
  font-size: 0.78rem;
  padding: 0.22rem 0.65rem;
  border-radius: 999px;
  border: 1px solid transparent;
  max-width: 100%;
  line-height: 1.35;
}
.achievement-test-pill-strong {
  font-weight: 700;
}
/* Easiest → hardest: flat fills (mint → ice → blue → violet → warm cream) */
.achievement-test-pill--t1 {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #065f46;
}
.achievement-test-pill--t2 {
  background: #ecfeff;
  border-color: #a5f3fc;
  color: #164e63;
}
.achievement-test-pill--t3 {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1e3a8a;
}
.achievement-test-pill--t4 {
  background: #f5f3ff;
  border-color: #ddd6fe;
  color: #4c1d95;
}
.achievement-test-pill--t5 {
  background: #fff7ed;
  border-color: #fed7aa;
  color: #431407;
}
.achievement-hero {
  font-size: 0.82rem;
  color: var(--text-secondary, #64748b);
}
.achievement-meta {
  font-size: 0.78rem;
  color: var(--text-secondary, #64748b);
  margin-top: 0.2rem;
}
.achievement-words {
  font-size: 0.78rem;
  font-weight: 500;
  margin-top: 0.15rem;
}
.achievement-words-stat {
  color: var(--primary, #e85d75);
}
.achievement-words-from {
  color: var(--text, #2d3142);
}

/* Login gate: confirm User ID was saved */
.user-id-saved-popup {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.user-id-saved-popup.hidden {
  display: none !important;
}
.user-id-saved-popup-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
}
.user-id-saved-popup-box {
  position: relative;
  background: var(--card, #fff);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  max-width: min(26rem, calc(100vw - 2rem));
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  border: 1px solid #e5e7eb;
}
.user-id-saved-popup-title {
  margin: 0 0 0.75rem 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text, #1e293b);
}
.user-id-saved-popup-body {
  margin: 0 0 1rem 0;
  font-size: 0.95rem;
  color: var(--text-secondary, #64748b);
  line-height: 1.55;
}
.user-id-saved-popup-body .login-gate-user-id {
  color: var(--text, #1e293b);
}
.user-id-saved-popup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: flex-end;
}
.user-id-saved-popup-actions .btn {
  min-width: 6rem;
}

/* Curriculum word-list amendment (school / national lists with media treasures) */
/* Also used for Adults mode-narrowing warning (.settings-mode-warning-popup) */
.curriculum-amend-popup,
.settings-mode-warning-popup {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.curriculum-amend-popup.hidden,
.settings-mode-warning-popup.hidden {
  display: none !important;
}
.curriculum-amend-popup-backdrop,
.settings-mode-warning-popup-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
}
.curriculum-amend-popup-box,
.settings-mode-warning-popup-box {
  position: relative;
  background: var(--card, #fff);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  max-width: min(26rem, calc(100vw - 2rem));
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  border: 1px solid #e5e7eb;
}
.curriculum-amend-popup-title,
.settings-mode-warning-popup-title {
  margin: 0 0 0.75rem 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text, #1e293b);
}
.curriculum-amend-popup-body,
.settings-mode-warning-popup-body {
  margin: 0 0 1rem 0;
  font-size: 0.95rem;
  color: var(--text-secondary, #64748b);
  line-height: 1.55;
  white-space: pre-line;
}
.curriculum-amend-popup-actions,
.settings-mode-warning-popup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: flex-end;
}
.curriculum-amend-popup-actions .btn,
.settings-mode-warning-popup-actions .btn {
  min-width: 6rem;
}

.difficulty-quest-popup {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.difficulty-quest-popup.hidden {
  display: none !important;
}
.difficulty-quest-popup-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
}
.difficulty-quest-popup-box {
  position: relative;
  background: var(--card, #fff);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  max-width: 22rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  border: 1px solid #e5e7eb;
}
.difficulty-quest-popup-title {
  margin: 0 0 0.75rem 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text, #1e293b);
}
.difficulty-quest-popup-body {
  margin: 0 0 1rem 0;
  font-size: 0.95rem;
  color: var(--text-secondary, #64748b);
  line-height: 1.5;
}
.difficulty-quest-popup-dismiss-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 1rem 0;
  font-size: 0.9rem;
  cursor: pointer;
  color: var(--text, #334155);
}
.difficulty-quest-popup-dismiss-label input {
  margin: 0;
}
.difficulty-quest-popup-start {
  display: block;
  width: 100%;
}

/* Learn break offer (60% words) + Play tip after break */
.learn-break-offer,
.play-learn-break-tip {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.learn-break-offer.hidden,
.play-learn-break-tip.hidden {
  display: none !important;
}
.learn-break-offer-backdrop,
.play-learn-break-tip-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
}
.learn-break-offer-box {
  position: relative;
  z-index: 1;
  background: var(--card, #fff);
  border-radius: 16px;
  padding: 0;
  max-width: 24rem;
  width: 100%;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.3);
  border: 1px solid #e5e7eb;
  overflow: hidden;
}
.learn-break-collage {
  position: relative;
  height: 7.5rem;
  width: 100%;
  background: linear-gradient(145deg, #e0f2fe 0%, #fef3c7 50%, #fce7f3 100%);
  overflow: hidden;
}
.learn-break-collage-item {
  position: absolute;
  font-size: clamp(1.35rem, 4vw, 2.1rem);
  line-height: 1;
  pointer-events: none;
  animation-name: learnBreakCollageDrift;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
  animation-direction: alternate;
  will-change: transform;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}
@keyframes learnBreakCollageDrift {
  0% {
    transform: translate(0, 0) rotate(-12deg) scale(0.72);
    opacity: 0.88;
  }
  100% {
    transform: translate(14px, -12px) rotate(14deg) scale(1.18);
    opacity: 1;
  }
}
.learn-break-offer-title {
  margin: 0;
  padding: 1rem 1.25rem 0.35rem;
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text, #1e293b);
  text-align: center;
}
.learn-break-offer-body {
  margin: 0;
  padding: 0 1.25rem 1rem;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text-secondary, #64748b);
  text-align: center;
}
.learn-break-offer-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0 1.25rem 1.25rem;
}
.learn-break-offer-actions .btn {
  width: 100%;
}

.play-learn-break-tip-box {
  position: relative;
  z-index: 1;
  background: var(--card, #fff);
  border-radius: 14px;
  padding: 1.25rem 1.35rem;
  max-width: 21rem;
  width: 100%;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.28);
  border: 1px solid #e5e7eb;
}
.play-learn-break-tip-title {
  margin: 0 0 0.65rem 0;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text, #1e293b);
}
.play-learn-break-tip-body {
  margin: 0 0 1rem 0;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text-secondary, #64748b);
}
.play-learn-break-tip-actions {
  display: flex;
  flex-direction: row;
  gap: 0.5rem;
}
.play-learn-break-tip-actions .btn {
  flex: 1;
  width: auto;
  min-width: 0;
}
.play-learn-break-tip-box > .btn {
  width: 100%;
}

.play-pick.play-pick-disabled {
  opacity: 0.42;
  filter: grayscale(0.45);
  cursor: not-allowed;
  pointer-events: none;
}

.header-titles {
  text-align: center;
}

.btn-profile-icon {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 2px solid rgba(255, 200, 87, 0.6);
  background: #f8fafc;
  background-size: cover;
  background-position: center;
  cursor: pointer;
  font-size: 1.45rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, box-shadow 0.2s;
  overflow: hidden;
  padding: 0;
}

.btn-profile-icon .profile-icon-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 50%;
}

.btn-profile-icon:hover {
  border-color: var(--secondary);
  box-shadow: 0 2px 8px rgba(92, 184, 178, 0.3);
}

.pane-profile-row {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.45rem;
  flex-wrap: nowrap;
}

.pane-profile-left {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 0.5rem;
  flex-shrink: 0;
  padding-top: 0.1rem;
}

.pane-profile-copy-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
}

.pane-profile-streak-wrap {
  margin: 0;
}
.pane-profile-streak-wrap.hidden {
  display: none !important;
}

.input-card .pane-profile-row {
  margin-bottom: 0.45rem;
}

.input-hint-row {
  margin: 0;
  width: 100%;
  min-width: 0;
}

/* Child mode uses the same row as Adult: avatar + achievements | hint (+ streak); login stays hidden */

.pane-profile-row .pane-profile-login {
  flex-shrink: 0;
  align-self: flex-start;
  margin-left: auto;
}

.pane-nickname-block.hidden {
  display: none;
}

.pane-nickname,
.btn-profile-name {
  font-family: var(--font);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
}

.btn-profile-name {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-align: right;
}

.btn-profile-name:hover {
  color: var(--secondary);
  text-decoration: underline;
}

.header h1 {
  font-size: clamp(1.7rem, 4.2vw, 2.15rem);
  font-weight: 700;
  background: linear-gradient(135deg, #e85d75, #ff6b9d, #ffc857);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 0 0 0.25rem 0;
  text-shadow: none;
  animation: rainbow 3s ease infinite;
  transform: scale(1);
}

@keyframes rainbow {
  0%, 100% { filter: hue-rotate(0deg); }
  50% { filter: hue-rotate(10deg); }
}

.subtitle {
  font-size: clamp(0.9rem, 2.2vw, 1rem);
  color: var(--text-muted);
  margin: 0;
}

.phase {
  display: none;
}

.phase.active {
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  min-height: auto;
  animation: fadeIn 0.3s ease;
  overflow: visible;
}

/* Adventure map: full pane, 5 areas, cover quadrants; same width as card pane on other pages */
.phase-quiz-map.active {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  padding: 0;
  overflow: hidden;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

/* Match main pane content width: same horizontal padding as .card */
.quiz-map-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  position: relative;
  padding: 0.5rem clamp(0.85rem, 2.2vw, 1.35rem);
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.quiz-map-loading {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 2rem;
  background: rgba(255, 255, 255, 0.88);
  border-radius: 12px;
  pointer-events: none;
}
.quiz-map-loading.hidden {
  display: none !important;
}
.quiz-map-container.quiz-map-container--loading > :not(#quiz-map-loading) {
  visibility: hidden;
}

.quiz-map-title {
  font-family: var(--font);
  font-size: clamp(1.1rem, 3vw, 1.4rem);
  margin: 0 0 0.25rem 0;
  text-align: center;
  color: var(--text);
}

.quiz-map-hint {
  font-size: clamp(0.98rem, 2.75vw, 1.2rem);
  text-align: center;
  margin: 0.55rem 0 0;
}

.quiz-map-hint strong {
  font-weight: 700;
  color: var(--text);
}

.treasure-tier-name {
  font-weight: 700;
}
.treasure-tier-name[data-tier="bronze"] { color: #b87333; }
.treasure-tier-name[data-tier="silver"] { color: #888; }
.treasure-tier-name[data-tier="gold"]   { color: #c8890a; }
.treasure-tier-name[data-tier="master"] { color: #a855f7; }

/* ===== Quest hub furniture (01 §5.1) — full-width progress rail below map ===== */
.quiz-map-points-bar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.4rem;
  margin: 0.65rem 0 0;
  width: 100%;
  max-width: 100%;
  flex-shrink: 0;
}
.quiz-map-points-bar.hidden { display: none !important; }
.quiz-map-points-text {
  display: none;
}
.quiz-map-progress-rail {
  width: 100%;
  padding: 0 1.65rem;
  box-sizing: border-box;
}
.quiz-map-points-track {
  position: relative;
  display: block;
  width: 100%;
  height: 14px;
  border-radius: 8px;
  background: rgba(100, 116, 139, 0.2);
  overflow: visible;
}
.quiz-map-day-segments {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: flex;
  border-radius: 8px;
  overflow: hidden;
  pointer-events: none;
}
.quiz-map-day-segment {
  height: 100%;
  transition: opacity 0.3s;
}
.quiz-map-day-segment[data-day="1"] { background: #60a5fa; }
.quiz-map-day-segment[data-day="2"] { background: #34d399; }
.quiz-map-day-segment[data-day="3"] { background: #a78bfa; }
.quiz-map-day-segment.past    { opacity: 0.18; }
.quiz-map-day-segment.current { opacity: 0.40; }
.quiz-map-day-segment.future  { opacity: 0.22; }
.quiz-map-points-fill {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 8px;
  background: linear-gradient(90deg, rgba(255, 210, 77, 0.85), rgba(255, 155, 61, 0.85));
  transition: width 0.5s ease;
  position: relative;
  z-index: 1;
}
/* >> chevron tab at the leading edge — shown only when there is actual progress */
.quiz-map-points-fill.has-progress::after {
  content: '»';
  position: absolute;
  right: -2px;
  top: 50%;
  transform: translate(50%, -50%);
  font-size: 0.82rem;
  font-weight: 900;
  line-height: 1;
  color: #fff;
  background: rgba(210, 110, 15, 0.9);
  padding: 2px 5px 2px 3px;
  border-radius: 0 6px 6px 0;
  box-shadow: 2px 0 5px rgba(150, 70, 5, 0.45);
  pointer-events: none;
  z-index: 5;
}
.quiz-map-day-dividers {
  display: none;
}
.quiz-map-day-divider {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 2px;
  margin-left: -1px;
  background: rgba(255, 255, 255, 0.7);
  box-shadow: 0 0 0 1px rgba(100, 116, 139, 0.25);
}
/* Day labels sit ABOVE the progress bar */
.quiz-map-day-labels {
  position: relative;
  width: 100%;
  height: 18px;
  margin-bottom: 6px;
}
.quiz-map-day-label {
  position: absolute;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  transform: translateX(-50%);
  pointer-events: none;
}
.quiz-map-day-label.past    { color: rgba(100, 116, 139, 0.55); }
.quiz-map-day-label.current { color: rgba(30, 64, 175, 0.85); }
.quiz-map-day-label.future  { color: rgba(100, 116, 139, 0.55); }
.quiz-map-milestones {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}
.quiz-map-milestone {
  position: absolute;
  top: 50%;
  left: 0;
  width: 0;
  height: 0;
}
/* Ticks hidden — pts labels appear on the bar track itself. */
.quiz-map-milestone-tick { display: none; }
/* Pts label: centered on the bar track (vertically and horizontally on the milestone anchor). */
.quiz-map-milestone-pts {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.62rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.82);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
  line-height: 1;
  white-space: nowrap;
  z-index: 4;
  transition: opacity 0.3s;
}
/* Earned milestone: keep pts label visible (fill has moved past it, no chevron clash). */
.quiz-map-milestone.earned .quiz-map-milestone-pts {
  opacity: 0.9;
  color: rgba(255, 255, 255, 0.95);
}
/* Chests sit close to the bar — no gap needed for labels below */
.quiz-map-tier-chests {
  position: relative;
  width: 100%;
  height: 4.25rem;
  margin-top: 0.3rem;
}
@media (max-width: 420px) {
  .quiz-map-progress-rail { padding: 0 1.35rem; }
  .quiz-map-tier-chests { height: 3.85rem; margin-top: 0.25rem; }
  .quiz-map-chest { width: 3.35rem; padding: 0.18rem 0.2rem; }
  .quiz-map-chest .quiz-map-chest-icon { font-size: 1.15rem; }
  .quiz-map-chest .quiz-map-chest-label { font-size: 0.56rem; }
  .quiz-map-chest[data-tier="master"] { width: 3.55rem; }
}
.quiz-map-chest {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.05rem;
  min-width: 0;
  width: 3.75rem;
  padding: 0.22rem 0.3rem;
  border: 2px solid rgba(100, 116, 139, 0.25);
  border-radius: 10px;
  background: rgba(100, 116, 139, 0.08);
  cursor: default;
  transform: translateX(-50%);
  /* Faded until earned. */
  filter: grayscale(1);
  opacity: 0.5;
  transition: opacity 0.3s ease, filter 0.3s ease, transform 0.2s ease, left 0.35s ease;
}
.quiz-map-chest .quiz-map-chest-icon { font-size: 1.35rem; line-height: 1; }
.quiz-map-chest .quiz-map-chest-label {
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
  text-align: center;
  line-height: 1.1;
}
.quiz-map-chest.earned {
  filter: none;
  opacity: 1;
  cursor: pointer;
  border-color: var(--accent, #ffc857);
  background: rgba(255, 200, 87, 0.16);
}
.quiz-map-chest.earned:hover {
  transform: translateX(-50%) scale(1.06);
}
.quiz-map-chest.earned:focus-visible {
  outline: 2px solid var(--accent, #ffc857);
  outline-offset: 2px;
}
.quiz-map-chest.earned .quiz-map-chest-label { color: var(--text); }
.quiz-map-chest.just-earned { animation: chest-pop 0.6s ease; }
/* Master (crown) chest — distinct from bronze/silver/gold medals */
.quiz-map-chest[data-tier="master"] {
  width: 3.9rem;
  border-width: 3px;
  border-style: double;
}
.quiz-map-chest[data-tier="master"]:not(.earned) {
  border-color: rgba(168, 85, 247, 0.35);
  background: rgba(168, 85, 247, 0.07);
}
.quiz-map-chest[data-tier="master"] .quiz-map-chest-icon {
  font-size: 1.65rem;
}
.quiz-map-chest[data-tier="master"].earned {
  border-color: #a855f7;
  background: linear-gradient(145deg, rgba(255, 200, 87, 0.22), rgba(168, 85, 247, 0.14));
  box-shadow: 0 2px 10px rgba(168, 85, 247, 0.28);
}
.quiz-map-chest[data-tier="master"].earned:hover {
  box-shadow: 0 3px 14px rgba(168, 85, 247, 0.38);
}
@keyframes chest-pop {
  0% { transform: translateX(-50%) scale(1); }
  40% { transform: translateX(-50%) scale(1.18); }
  100% { transform: translateX(-50%) scale(1); }
}

/* Per-card point value + status badge. */
.quiz-map-area-points {
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 0.66rem;
  font-weight: 700;
  color: #fff;
  background: rgba(45, 49, 66, 0.62);
  padding: 1px 5px;
  border-radius: 8px;
  pointer-events: none;
}
.quiz-map-area-points:empty { display: none; }
.quiz-map-area-status {
  position: absolute;
  bottom: 4px;
  right: 6px;
  font-size: 0.7rem;
  font-weight: 700;
  pointer-events: none;
}
.quiz-map-area-status:empty { display: none; }
.quiz-map-area-status.status-in-progress { color: var(--accent, #ffc857); }
/* Completion uses the large .quiz-map-area-done badge only — no duplicate small tick. */
.quiz-map-area-status.status-complete {
  display: none;
}

.quiz-map-treasure-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.6rem 0.9rem;
  margin-top: 0.2rem;
}
.quiz-map-treasure-row .quiz-map-hint {
  margin: 0;
}
.quiz-map-all-complete-msg {
  width: 100%;
  text-align: center;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  margin: 0.2rem 0 0;
}
.quiz-map-practice-note {
  width: 100%;
  text-align: center;
  font-size: 0.95rem;
  color: var(--text-muted, #555);
  margin: 0.3rem 0 0;
  font-style: italic;
}

.quiz-map-treasure-btn {
  display: inline-block;
  margin: 0;
  background: linear-gradient(135deg, #ffd24d 0%, #ff9b3d 60%, #ff6b3d 100%);
  color: #3b1f0a;
  border: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
  font-weight: 800;
  letter-spacing: 0.02em;
}
.quiz-map-treasure-btn.hidden,
.quiz-map-treasure-btn[hidden] {
  display: none !important;
}
.quiz-map-treasure-btn:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.quiz-map-day-complete-actions {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem 0.75rem;
}
.quiz-map-day-complete-label {
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--text);
  white-space: nowrap;
}
.quiz-map-start-day2-btn {
  background: linear-gradient(135deg, #7dd3fc 0%, #38bdf8 55%, #0ea5e9 100%);
  color: #0c2d48;
  border: none;
  font-weight: 800;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
}
.quiz-map-start-day2-btn:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
}

/* Quest map: black "treasure" text on pastel letter tiles; shimmer on background/glow when Decorative animations are on
   (Settings → Adults). Off = body.spelling-app-reduced-motion (see grouped rules ~ splash-stars). */
.treasure-shimmer {
  display: inline-flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.12em;
  vertical-align: baseline;
}

.treasure-shimmer .treasure-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: normal;
  color: #000;
  line-height: 1;
  padding: 0.12em 0.2em;
  border-radius: 0.32em;
  border: 1px solid rgba(0, 0, 0, 0.06);
  animation: treasure-letter-shimmer 2.6s ease-in-out infinite;
}

.treasure-shimmer .treasure-letter:nth-child(1) {
  background-color: #f5b8c8;
  --treasure-shine: #f5b8c8;
  animation-delay: 0s;
}
.treasure-shimmer .treasure-letter:nth-child(2) {
  background-color: #f5cdb5;
  --treasure-shine: #f5cdb5;
  animation-delay: 0.12s;
}
.treasure-shimmer .treasure-letter:nth-child(3) {
  background-color: #f5e6b8;
  --treasure-shine: #f5e6b8;
  animation-delay: 0.24s;
}
.treasure-shimmer .treasure-letter:nth-child(4) {
  background-color: #c8eccf;
  --treasure-shine: #c8eccf;
  animation-delay: 0.36s;
}
.treasure-shimmer .treasure-letter:nth-child(5) {
  background-color: #b8eaf0;
  --treasure-shine: #b8eaf0;
  animation-delay: 0.48s;
}
.treasure-shimmer .treasure-letter:nth-child(6) {
  background-color: #c9d8fa;
  --treasure-shine: #c9d8fa;
  animation-delay: 0.6s;
}
.treasure-shimmer .treasure-letter:nth-child(7) {
  background-color: #dfd4fb;
  --treasure-shine: #dfd4fb;
  animation-delay: 0.72s;
}
.treasure-shimmer .treasure-letter:nth-child(8) {
  background-color: #f5c2e4;
  --treasure-shine: #f5c2e4;
  animation-delay: 0.84s;
}

@keyframes treasure-letter-shimmer {
  0%,
  100% {
    filter: brightness(1);
    box-shadow: none;
    transform: translateY(0);
  }
  45% {
    filter: brightness(1.1);
    box-shadow:
      0 0 0.55em color-mix(in srgb, var(--treasure-shine, #ccc) 50%, transparent),
      0 0.06em 0.18em rgba(0, 0, 0, 0.07);
    transform: translateY(-1px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .treasure-shimmer .treasure-letter {
    animation: none !important;
    box-shadow: none !important;
    transform: none !important;
    filter: none !important;
  }
}

.quiz-map-areas {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr auto 1fr;
  gap: 0.5rem;
  flex: 1;
  min-height: 22.05rem;
  width: 100%;
  max-width: 100%;
  /* Clear the Back button / title row so map tiles don’t crowd the header */
  margin: 12px 0 0;
}

.quiz-map-area-number {
  position: absolute;
  top: 0.4rem;
  left: 0.5rem;
  width: 1.5rem;
  height: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 700;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  line-height: 1;
}
.quiz-map-area.quiz-map-area-has-image .quiz-map-area-number {
  background: rgba(0, 0, 0, 0.5);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.quiz-map-area {
  font-family: var(--font);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
  border-radius: 14px;
  border: 3px solid rgba(0,0,0,0.12);
  background: linear-gradient(145deg, #fff 0%, #f5f5f5 100%);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  position: relative;
  min-height: 7.06rem;
}

/* Optional full-bleed artwork for adventure areas; emoji + text still act as fallback if image missing. */
.quiz-map-area.quiz-map-area-has-image {
  background-image: none; /* set inline by JS */
  background-size: cover;
  background-position: 50% 50%;
  background-repeat: no-repeat;
  background-color: #1a1a2e;
  overflow: hidden;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  animation: quiz-map-image-pan-zoom-vertical 68s linear infinite;
}
.quiz-map-area.quiz-map-area-has-image.quiz-map-area-scroll-horizontal {
  animation-name: quiz-map-image-pan-zoom-horizontal;
  background-size: auto 110%; /* match scroll/hold so no black bars when image loads */
}
.quiz-map-area.quiz-map-area-has-image.quiz-map-area-near-fit {
  animation-name: quiz-map-image-pan-zoom-near-fit;
}

/* Vertical scroll (image taller than container): use 105% for scroll/hold/loop so no jump (same value type as zoom, no cover). */
@keyframes quiz-map-image-pan-zoom-vertical {
  /* Scroll along Y: center → top → bottom → center */
  0%, 2% { background-position: 50% 50%; background-size: 105%; }
  6% { background-position: 50% 37.5%; background-size: 105%; }
  10% { background-position: 50% 25%; background-size: 105%; }
  14% { background-position: 50% 12.5%; background-size: 105%; }
  18% { background-position: 50% 0%; background-size: 105%; }
  22% { background-position: 50% 12.5%; background-size: 105%; }
  26% { background-position: 50% 25%; background-size: 105%; }
  30% { background-position: 50% 37.5%; background-size: 105%; }
  34% { background-position: 50% 50%; background-size: 105%; }
  38% { background-position: 50% 62.5%; background-size: 105%; }
  42% { background-position: 50% 75%; background-size: 105%; }
  46% { background-position: 50% 87.5%; background-size: 105%; }
  50% { background-position: 50% 100%; background-size: 105%; }
  54% { background-position: 50% 87.5%; background-size: 105%; }
  58% { background-position: 50% 75%; background-size: 105%; }
  62% { background-position: 50% 62.5%; background-size: 105%; }
  65% { background-position: 50% 50%; background-size: 105%; }
  66%, 70% { background-position: 50% 50%; background-size: 105%; }
  /* Zoom in: same scale as scroll end (105%), then ramp to 120% */
  71% { background-position: 50% 50%; background-size: 105%; }
  72% { background-position: 50% 50%; background-size: 108%; }
  73% { background-position: 50% 50%; background-size: 112%; }
  74% { background-position: 50% 50%; background-size: 116%; }
  75% { background-position: 50% 50%; background-size: 120%; }
  /* Bounce horizontal ~15s: center → right → left → center */
  76% { background-position: 50% 50%; background-size: 120%; }
  78% { background-position: 62.5% 50%; background-size: 120%; }
  80% { background-position: 75% 50%; background-size: 120%; }
  82% { background-position: 87.5% 50%; background-size: 120%; }
  84% { background-position: 100% 50%; background-size: 120%; }
  86% { background-position: 75% 50%; background-size: 120%; }
  88% { background-position: 50% 50%; background-size: 120%; }
  90% { background-position: 25% 50%; background-size: 120%; }
  92% { background-position: 0% 50%; background-size: 120%; }
  94% { background-position: 25% 50%; background-size: 120%; }
  96% { background-position: 50% 50%; background-size: 120%; }
  98% { background-position: 50% 50%; background-size: 120%; }
  /* Zoom out: back to 105% for smooth loop */
  98.5% { background-position: 50% 50%; background-size: 115%; }
  99% { background-position: 50% 50%; background-size: 110%; }
  99.25% { background-position: 50% 50%; background-size: 106%; }
  99.5% { background-position: 50% 50%; background-size: 103%; }
  99.75% { background-position: 50% 50%; background-size: 101%; }
  100% { background-position: 50% 50%; background-size: 105%; }
}

/* Near-fit (image aspect within 5% of container): no initial scroll, keep random zoom and bounce only. */
@keyframes quiz-map-image-pan-zoom-near-fit {
  0%, 70% { background-position: 50% 50%; background-size: cover; }
  71% { background-position: 50% 50%; background-size: 105%; }
  72% { background-position: 50% 50%; background-size: 108%; }
  73% { background-position: 50% 50%; background-size: 112%; }
  74% { background-position: 50% 50%; background-size: 116%; }
  75% { background-position: 50% 50%; background-size: 120%; }
  76% { background-position: 50% 50%; background-size: 120%; }
  78% { background-position: 62.5% 50%; background-size: 120%; }
  80% { background-position: 75% 50%; background-size: 120%; }
  82% { background-position: 87.5% 50%; background-size: 120%; }
  84% { background-position: 100% 50%; background-size: 120%; }
  86% { background-position: 75% 50%; background-size: 120%; }
  88% { background-position: 50% 50%; background-size: 120%; }
  90% { background-position: 25% 50%; background-size: 120%; }
  92% { background-position: 0% 50%; background-size: 120%; }
  94% { background-position: 25% 50%; background-size: 120%; }
  96% { background-position: 50% 50%; background-size: 120%; }
  98% { background-position: 50% 50%; background-size: 120%; }
  98.5% { background-position: 50% 50%; background-size: 115%; }
  99% { background-position: 50% 50%; background-size: 110%; }
  99.25% { background-position: 50% 50%; background-size: 106%; }
  99.5% { background-position: 50% 50%; background-size: 103%; }
  99.75% { background-position: 50% 50%; background-size: 101%; }
  100% { background-position: 50% 50%; background-size: cover; }
}

/* Horizontal scroll (image wider than container): same structure as vertical. Use auto 110% (height 110%) so image fills height, no black top/bottom; zoom starts from same position/scale as scroll end. */
@keyframes quiz-map-image-pan-zoom-horizontal {
  /* Scroll along X: center → right → left → center; same scale so zoom continues from here */
  0%, 2% { background-position: 50% 50%; background-size: auto 110%; }
  6% { background-position: 62.5% 50%; background-size: auto 110%; }
  10% { background-position: 75% 50%; background-size: auto 110%; }
  14% { background-position: 87.5% 50%; background-size: auto 110%; }
  18% { background-position: 100% 50%; background-size: auto 110%; }
  22% { background-position: 87.5% 50%; background-size: auto 110%; }
  26% { background-position: 75% 50%; background-size: auto 110%; }
  30% { background-position: 62.5% 50%; background-size: auto 110%; }
  34% { background-position: 50% 50%; background-size: auto 110%; }
  38% { background-position: 37.5% 50%; background-size: auto 110%; }
  42% { background-position: 25% 50%; background-size: auto 110%; }
  46% { background-position: 12.5% 50%; background-size: auto 110%; }
  50% { background-position: 0% 50%; background-size: auto 110%; }
  54% { background-position: 12.5% 50%; background-size: auto 110%; }
  58% { background-position: 25% 50%; background-size: auto 110%; }
  62% { background-position: 37.5% 50%; background-size: auto 110%; }
  65% { background-position: 50% 50%; background-size: auto 110%; }
  66%, 70% { background-position: 50% 50%; background-size: auto 110%; }
  /* Zoom in: stay in "auto X%" so no jump (same value type throughout) */
  71% { background-position: 50% 50%; background-size: auto 110%; }
  72% { background-position: 50% 50%; background-size: auto 114%; }
  73% { background-position: 50% 50%; background-size: auto 117%; }
  74% { background-position: 50% 50%; background-size: auto 119%; }
  75% { background-position: 50% 50%; background-size: auto 120%; }
  /* Bounce along Y ~15s: center → bottom → top → center */
  76% { background-position: 50% 50%; background-size: auto 120%; }
  78% { background-position: 50% 62.5%; background-size: auto 120%; }
  80% { background-position: 50% 75%; background-size: auto 120%; }
  82% { background-position: 50% 87.5%; background-size: auto 120%; }
  84% { background-position: 50% 100%; background-size: auto 120%; }
  86% { background-position: 50% 75%; background-size: auto 120%; }
  88% { background-position: 50% 50%; background-size: auto 120%; }
  90% { background-position: 50% 25%; background-size: auto 120%; }
  92% { background-position: 50% 0%; background-size: auto 120%; }
  94% { background-position: 50% 25%; background-size: auto 120%; }
  96% { background-position: 50% 50%; background-size: auto 120%; }
  98% { background-position: 50% 50%; background-size: auto 120%; }
  /* Zoom out: stay in "auto X%" so no jump at loop */
  98.5% { background-position: 50% 50%; background-size: auto 116%; }
  99% { background-position: 50% 50%; background-size: auto 113%; }
  99.25% { background-position: 50% 50%; background-size: auto 111%; }
  99.5% { background-position: 50% 50%; background-size: auto 110%; }
  99.75% { background-position: 50% 50%; background-size: auto 110%; }
  100% { background-position: 50% 50%; background-size: auto 110%; }
}

/* Passed tests: heavy uniform dim on artwork only (inset shadow; labels sit above it). */
.quiz-map-area.quiz-map-area-has-image.complete {
  --quiz-map-complete-dim: rgba(0, 0, 0, 0.58);
  --quiz-map-complete-chip: rgba(72, 78, 94, 0.78);
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.1),
    inset 0 0 0 100vmax var(--quiz-map-complete-dim);
}
.quiz-map-area.quiz-map-area-has-image.complete:hover {
  box-shadow:
    0 6px 20px rgba(0, 0, 0, 0.15),
    inset 0 0 0 100vmax var(--quiz-map-complete-dim);
}
.quiz-map-area.quiz-map-area-has-image.complete .quiz-map-area-number,
.quiz-map-area.quiz-map-area-has-image.complete .quiz-map-area-points,
.quiz-map-area.quiz-map-area-has-image.complete .quiz-map-area-name,
.quiz-map-area.quiz-map-area-has-image.complete .quiz-map-area-done {
  background: var(--quiz-map-complete-chip);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}
.quiz-map-area.complete:not(.quiz-map-area-has-image) {
  filter: brightness(0.78) saturate(0.88);
}

.quiz-map-area:hover {
  transform: scale(1.03);
  box-shadow: 0 6px 20px rgba(0,0,0,0.15);
}

.quiz-map-area:active {
  transform: scale(0.98);
}

.quiz-map-area-0 { border-color: #22c55e; background: linear-gradient(145deg, #dcfce7 0%, #bbf7d0 100%); }
.quiz-map-area-1 { border-color: #0ea5e9; background: linear-gradient(145deg, #e0f2fe 0%, #bae6fd 100%); }
.quiz-map-area-2 { border-color: #a855f7; background: linear-gradient(145deg, #f3e8ff 0%, #e9d5ff 100%); }
.quiz-map-area-3 { border-color: #f59e0b; background: linear-gradient(145deg, #fffbeb 0%, #fef3c7 100%); }
.quiz-map-area-4 { border-color: #ef4444; background: linear-gradient(145deg, #fee2e2 0%, #fecaca 100%); }

.quiz-map-area-done {
  position: absolute;
  bottom: 0.35rem;
  right: 0.35rem;
  top: auto;
  font-size: 2.2rem;
  color: #16a34a;
  opacity: 0;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));
  line-height: 1;
}

.quiz-map-area.complete .quiz-map-area-done {
  opacity: 1;
}

.quiz-map-area-icon {
  font-size: 2.4rem;
  margin-bottom: 0.2rem;
}

.quiz-map-area-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

/* Layout tweaks when a map area uses a full-bleed image. Hide the emoji icon and overlay the name on the image. */
.quiz-map-area.quiz-map-area-has-image .quiz-map-area-icon {
  display: none;
}

.quiz-map-area.quiz-map-area-has-image .quiz-map-area-name {
  position: absolute;
  left: 50%;
  bottom: 0.4rem;
  transform: translateX(-50%);
  font-size: 0.9rem;
  font-weight: 800;
  color: #fff;
  text-align: center;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
}

.quiz-map-area.quiz-map-area-has-image .quiz-map-area-done {
  color: #22c55e;
  text-shadow: 0 0 3px rgba(0, 0, 0, 0.9), 0 0 6px rgba(0, 0, 0, 0.7), 0 2px 4px rgba(0, 0, 0, 0.8);
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.9));
  background: rgba(0, 0, 0, 0.35);
  border-radius: 50%;
  padding: 0.15em;
  line-height: 1;
  box-sizing: content-box;
}
.quiz-map-area.quiz-map-area-has-image.complete .quiz-map-area-done {
  border-radius: 50%;
  padding: 0.15em;
  box-sizing: content-box;
}

.quiz-map-area:nth-child(1) { grid-column: 1; grid-row: 1; }
.quiz-map-area:nth-child(2) { grid-column: 2; grid-row: 1; }
.quiz-map-area:nth-child(3) { grid-column: 1 / -1; grid-row: 2; }
.quiz-map-area:nth-child(4) { grid-column: 1; grid-row: 3; }
.quiz-map-area:nth-child(5) { grid-column: 2; grid-row: 3; }

.quiz-map-cover-wrap {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: 12px;
  overflow: hidden;
  margin: 0.5rem;
}

/* No dark overlay on the map – only the revealed quadrant images show */
.quiz-map-cover-bg {
  position: absolute;
  inset: 0;
  background: transparent;
  pointer-events: none;
}

.quiz-map-quadrant {
  position: absolute;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.quiz-map-quadrant.revealed {
  opacity: 1;
}

.quiz-map-tl { top: 0; left: 0; width: 50%; height: 50%; }
.quiz-map-tr { top: 0; right: 0; width: 50%; height: 50%; }
.quiz-map-bl { bottom: 0; left: 0; width: 50%; height: 50%; }
.quiz-map-br { bottom: 0; right: 0; width: 50%; height: 50%; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.card {
  background: linear-gradient(135deg, #ffffff 0%, #fef9f0 100%);
  border-radius: var(--radius);
  padding: clamp(0.85rem, 2.2vw, 1.35rem);
  box-shadow: 0 8px 32px rgba(0,0,0,0.1), 0 0 0 4px rgba(255, 200, 87, 0.2);
  border: 3px solid transparent;
  background-clip: padding-box;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

.card::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255, 200, 87, 0.1) 0%, transparent 70%);
  animation: shimmer 4s ease-in-out infinite;
  pointer-events: none;
}

@keyframes shimmer {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  50% { transform: translate(20px, 20px) rotate(180deg); }
}

.card h2 {
  font-size: 1.5rem;
  margin: 0 0 0.5rem 0;
  color: var(--text);
}

.input-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.input-title-row h2 {
  margin: 0;
}

.input-language-label {
  font-size: 0.9rem;
  color: var(--secondary);
  margin: 0;
  font-weight: 600;
}

/* Profile */
.profile-card .profile-label,
.profile-card .profile-field label {
  display: block;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.35rem;
  font-size: 0.95rem;
}

.profile-avatar-section {
  margin-bottom: 1.25rem;
}

.profile-avatar-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.5rem 0 0.75rem 0;
}

.profile-avatar-option {
  width: 100px;
  height: 100px;
  padding: 0;
  border: 3px solid #e5e7eb;
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.profile-avatar-option:hover {
  border-color: var(--secondary);
}

.profile-avatar-option.selected {
  border-width: 5px;
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.45);
}

.profile-avatar-option.profile-avatar-hero-highlight {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(232, 93, 117, 0.6);
  animation: profile-avatar-highlight-pulse 0.4s ease-out;
}

@keyframes profile-avatar-highlight-pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

.profile-avatar-option img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-avatar-tooltip {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  background: rgba(15, 23, 42, 0.9);
  color: #f9fafb;
  font-size: 0.78rem;
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
  white-space: nowrap;
  box-shadow: 0 4px 8px rgba(15, 23, 42, 0.3);
  transform: translate(10px, -10px);
}

.profile-avatar-custom-cell {
  width: 100px;
  height: 100px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid #e5e7eb;
  border-radius: 12px;
  background: #f8fafc;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.profile-avatar-custom-cell:hover {
  border-color: var(--secondary);
}

.profile-avatar-custom-btn {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  text-align: center;
  cursor: pointer;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--secondary);
  transition: background 0.2s, color 0.2s;
}

.profile-avatar-custom-btn:hover {
  background: rgba(232, 93, 117, 0.1);
  color: var(--primary);
}

.profile-avatar-preview {
  margin-top: 0.5rem;
}

.profile-avatar-preview img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 12px;
  border: 2px solid var(--secondary);
}

.profile-avatar-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.profile-avatar-overlay.hidden {
  display: none;
}
.profile-avatar-overlay img {
  max-width: 90vw;
  max-height: 90vh;
  width: auto;
  height: auto;
  object-fit: contain;
  pointer-events: none;
}

.profile-field {
  margin-bottom: 1rem;
}

.profile-nickname-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: flex-end;
  width: 100%;
}

.profile-field-adventure-name .profile-nickname-row {
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-start;
  gap: 0.35rem;
}

.profile-field-adventure-name .profile-field-label {
  display: inline;
  margin-bottom: 0;
  margin-right: 0;
  flex: 0 0 auto;
  white-space: nowrap;
}

.profile-field-label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--text);
}

.profile-adventure-name {
  display: inline-flex;
  flex: 0 0 auto;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-start;
  gap: 0;
  min-width: 0;
}

.profile-nickname-row #profile-suggest-name {
  flex: 0 0 auto;
  margin-left: auto;
}

.profile-hero-title {
  font-family: var(--font);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
  user-select: text;
  text-align: left;
}

.profile-hero-title:not(:empty)::before {
  content: ", ";
}

.profile-name-part {
  flex: 0 0 auto;
  width: 13ch;
  max-width: 13ch;
  min-width: 13ch;
  box-sizing: border-box;
  font-family: var(--font);
  font-size: 1.1rem;
  font-weight: 700;
  padding: 0.35rem 0.5rem;
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  text-align: left;
}

.profile-name-part:focus {
  outline: none;
  border-color: var(--primary, #e85d75);
  box-shadow: 0 0 0 2px rgba(232, 93, 117, 0.2);
}

.profile-school-list {
  position: relative;
  margin-top: 0.25rem;
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  background: #fff;
  max-height: 200px;
  overflow-y: auto;
  z-index: 10;
}

.profile-school-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.5rem 0.75rem;
  border: none;
  background: none;
  font-family: var(--font);
  font-size: 1rem;
  cursor: pointer;
  color: var(--text);
}

.profile-school-item:hover {
  background: #f0fdfa;
}

.profile-school-code-wrap {
  margin-top: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.profile-school-code-wrap.hidden {
  display: none;
}

.profile-school-code-label {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 500;
}

.profile-school-code {
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.05em;
  padding: 0.25rem 0.5rem;
  background: rgba(232, 93, 117, 0.1);
  border-radius: 8px;
  border: 1px solid rgba(232, 93, 117, 0.25);
  display: inline-block;
  min-width: 2.5rem;
  text-align: center;
}

.profile-card .profile-field input[type="text"]:not(.profile-name-part),
.profile-card select {
  font-family: var(--font);
  font-size: 1rem;
  padding: 0.6rem 0.75rem;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  width: 100%;
  max-width: 20rem;
}

.profile-card .profile-field input.profile-name-part {
  width: 13ch;
  max-width: 13ch;
  min-width: 13ch;
  flex: 0 0 auto;
  font-weight: 700;
}

.hint, .assess-label {
  color: var(--text-muted);
  font-size: 1rem;
  margin: 0 0 1rem 0;
}

/* Learning progress label: pill + faux progress bar (darker fill grows with Word x of y) */
/* Learn progress row: "Word X of Y" pill + segmented bar */
.learn-progress-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  align-self: stretch;
  margin-bottom: 0.6rem;
  flex-shrink: 0;
}

.learn-label {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  padding: 0.28rem 0.9rem;
  border-radius: 999px;
  background: linear-gradient(135deg, #fef3c7, #fde8d8);
  border: 1px solid rgba(180, 100, 80, 0.3);
  color: #2d3142;
  font-weight: 700;
  font-size: 0.88rem;
  letter-spacing: 0.01em;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.08);
  white-space: nowrap;
}

.learn-label-text {
  white-space: nowrap;
}

.learn-progress-track-wrap {
  flex: 1;
  min-width: 0;
  position: relative;
  display: flex;
  align-items: center;
}

/* Room for 🎮 break marker above the bar (.card overflow:hidden clips taller absolutes). */
#learn-progress-wrap {
  min-height: 2.25rem;
}

.learn-break-marker {
  position: absolute;
  top: 0.1rem;
  transform: translateX(-50%);
  font-size: 2.2rem;
  line-height: 1;
  pointer-events: none;
  z-index: 3;
}
.learn-break-marker.hidden { display: none; }

.learn-progress-track-outer {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 4px;
  box-sizing: border-box;
  background: transparent;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.08);
}

.learn-dash {
  flex: 1;
  height: 100%;
  border-radius: 999px;
  background: rgba(200, 160, 145, 0.35);
  transition: background 0.3s ease;
}
.learn-dash--filled {
  background: linear-gradient(135deg, #9b2c2c, #c05050);
}

.learn-label-progress-fill {
  display: none;
}

.learn-card {
  position: relative;
  padding-top: 3px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.learn-card > .actions,
.learn-card > .progress-dots,
.learn-card-body > .learn-meaning,
.learn-card-body > .learn-image-wrap {
  align-self: stretch;
}

.learn-card .learn-image-wrap {
  margin-top: 0;
}

.ask-adult {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: linear-gradient(135deg, rgba(255, 193, 7, 0.25), rgba(255, 152, 0, 0.2));
  color: var(--text-primary, #1a1a1a);
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 152, 0, 0.35);
}

.hint-info-wrap {
  position: relative;
  display: inline;
}

.hint-info-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--secondary);
  font-size: 1rem;
  font-weight: 700;
  margin-left: 0.15rem;
  padding: 0 0.2rem;
  border-radius: 50%;
  background: rgba(92, 184, 178, 0.15);
  border: 1px solid rgba(92, 184, 178, 0.4);
  -webkit-tap-highlight-color: transparent;
}

.hint-info-trigger:hover {
  background: rgba(92, 184, 178, 0.25);
}

.hint-info-tooltip {
  position: fixed;
  z-index: 9999;
  width: 18rem;
  max-width: calc(100vw - 2rem);
  padding: 0.6rem 0.75rem;
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--text);
  background: var(--card);
  border: 2px solid var(--secondary);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s, visibility 0.15s;
}

.hint-info-wrap:hover .hint-info-tooltip,
.hint-info-wrap.show .hint-info-tooltip {
  opacity: 1;
  visibility: visible;
}

.hint-info-tooltip code {
  font-size: 0.85em;
  padding: 0.1rem 0.3rem;
  background: rgba(92, 184, 178, 0.15);
  border-radius: 4px;
}

.home-notice {
  background: #e8f4fd;
  border: 1px solid #b0d4f1;
  border-radius: 8px;
  color: #1a4a72;
  font-size: 0.93rem;
  margin: 0 0 10px;
  padding: 10px 14px;
  text-align: center;
  line-height: 1.4;
}

.input-card-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: start;
  margin-bottom: 0.35rem;
}

.input-card-grid .input-virtual-keyboard,
.input-card-grid .input-words-panel,
.input-card-grid .word-list,
.input-card-grid .word-list-wrap {
  grid-column: 1 / -1;
}

.input-tools-and-count-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  width: 100%;
  gap: 0.5rem;
  min-width: 0;
}

.input-tools-and-count-row .word-count {
  display: none;
  margin: 0;
  grid-column: 1;
}

.input-tools-and-count-row .input-tools-spacer {
  grid-column: 3;
}

.input-count-actions-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  min-width: 0;
}

.input-learn-quest-cell {
  grid-column: 1;
  display: flex;
  justify-content: center;
  align-items: center;
}

.input-count-actions-row .input-adults-cell {
  grid-column: 2;
  display: flex;
  justify-content: center;
  align-items: center;
}

.input-learn-quest-cell .input-card-actions {
  margin-top: 0;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 0.5rem;
  justify-content: center;
  align-items: center;
}

.input-main {
  min-width: 0;
}

.input-row {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 0.55rem;
  align-items: flex-start;
}

.input-row input,
.input-row textarea {
  flex: 1;
  font-family: var(--font);
  font-size: 1.2rem;
  padding: 0.85rem 1rem;
  border: 3px solid #e5e7eb;
  border-radius: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.input-row input:focus,
.input-row textarea:focus {
  border-color: var(--secondary);
}

#word-input {
  min-height: 4.25rem;
  max-height: 6rem;
  font-size: 1.05rem;
  line-height: 1.3;
  padding: 0.55rem 0.75rem;
}

.input-buttons-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  width: max-content;
  max-width: 7.5rem;
  justify-self: center;
  align-self: center;
  min-width: 0;
}

.input-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
  min-width: 0;
}

/* Front-page Add / Lists / Save: slightly tighter horizontal padding. */
.input-buttons #add-word {
  padding-left: 0.9rem;
  padding-right: 0.9rem;
}
.input-buttons #open-load-list,
.input-buttons #open-save-list {
  padding-left: 0.62rem;
  padding-right: 0.62rem;
}

.input-tools-and-count-row .input-tools-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin: 0;
  flex-shrink: 0;
  grid-column: 2;
  justify-self: center;
}

.input-tools-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 0;
  margin-bottom: 0;
}

.btn-dictate {
  font-family: var(--font);
  font-size: 1rem;
  padding: 0.6rem 1rem;
  border: 2px solid #bae6fd;
  border-radius: 12px;
  background: #e0f2fe;
  color: #075985;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.2s, background 0.2s;
}

.btn-dictate:hover:not(:disabled) {
  border-color: #7dd3fc;
  background: #bae6fd;
}

.btn-dictate:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-dictate.listening {
  border-color: var(--primary);
  background: #fff0f3;
  animation: dictatePulse 1.2s ease-in-out infinite;
}

@keyframes dictatePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(232, 93, 117, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(232, 93, 117, 0); }
}

.hidden {
  display: none !important;
}

.public-list-sync-toast {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  max-width: 90vw;
  padding: 0.75rem 1rem;
  background: #1e293b;
  color: #f8fafc;
  border-radius: 12px;
  font-size: 0.9rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  z-index: 10000;
}
.public-list-sync-toast.hidden {
  display: none !important;
}

.global-toast {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  max-width: 90vw;
  padding: 0.75rem 1rem;
  background: #92400e;
  color: #fef3c7;
  border-radius: 12px;
  font-size: 0.9rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  z-index: 10000;
}
.global-toast.hidden {
  display: none !important;
}

.add-words-first-toast {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  max-width: 90vw;
  padding: 0.75rem 1rem;
  background: #1e293b;
  color: #f8fafc;
  border-radius: 12px;
  font-size: 0.9rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  z-index: 10000;
}
.add-words-first-toast.hidden {
  display: none !important;
}

.load-list-truncated-toast {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  max-width: 90vw;
  padding: 0.75rem 1rem;
  background: #1e293b;
  color: #f8fafc;
  border-radius: 12px;
  font-size: 0.9rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  z-index: 10000;
}
.load-list-truncated-toast.hidden {
  display: none !important;
}

.word-list-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.75rem 0;
}

.word-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: contents;
}

.word-list-wrap > li,
.word-list li {
  background: linear-gradient(135deg, #ffc857, #ffb347);
  color: var(--text);
  padding: 0.5rem 0.9rem;
  border-radius: 20px;
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  box-shadow: 0 3px 8px rgba(255, 184, 71, 0.3);
  animation: wordBounce 0.3s ease;
  transform: scale(1);
  transition: transform 0.2s;
}

.word-list-wrap > li:hover,
.word-list li:hover {
  transform: scale(1.05);
}

@keyframes wordBounce {
  0% { transform: scale(0.8); opacity: 0; }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

/* Day 1: words belonging to a later session are greyed/dimmed */
.word-list li.word-future-session {
  background: linear-gradient(135deg, #cbd5e1, #94a3b8);
  box-shadow: 0 3px 8px rgba(148, 163, 184, 0.25);
  opacity: 0.55;
  animation: none;
}
.word-list li.word-future-session:hover {
  transform: none;
}

/* Day 2: words already learned on day 1 shown in lighter yellow */
.word-list li.word-prev-session {
  background: linear-gradient(135deg, #ffe8a3, #ffd57a);
  box-shadow: 0 3px 8px rgba(255, 200, 87, 0.18);
}

.word-list-wrap > li .remove,
.word-list li .remove {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0 0.2rem;
  line-height: 1;
  color: var(--text);
  opacity: 0.8;
}

.word-list-wrap > li .remove:hover,
.word-list li .remove:hover {
  opacity: 1;
}

.copy-words-btn {
  align-self: center;
  background: linear-gradient(135deg, #e2e8f0, #cbd5e1);
  color: var(--text);
  border: none;
  padding: 0.5rem 0.65rem;
  border-radius: 20px;
  font-size: 1.1rem;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s, opacity 0.2s;
}
.copy-words-btn:hover {
  transform: scale(1.05);
}

.copy-words-btn.copy-words-copied {
  background: linear-gradient(135deg, #86efac, #4ade80);
  color: #14532d;
}

.copy-words-btn.hidden {
  display: none;
}

.word-count {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin: 0;
}

.save-settings-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.btn-settings-link {
  font-family: var(--font);
  font-size: 0.95rem;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  border: none;
  background: #e5e7eb;
  color: var(--text);
  cursor: pointer;
}

.btn-settings-link:hover {
  background: #d4d4d8;
}

.btn-save-list {
  font-family: var(--font);
  font-size: 0.95rem;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  border: 2px solid var(--secondary);
  background: rgba(92, 184, 178, 0.15);
  color: var(--text);
  cursor: pointer;
}

.btn-save-list:hover:not(:disabled) {
  background: rgba(92, 184, 178, 0.25);
}

.btn-save-list:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.save-list-card .save-list-field {
  margin-bottom: 1rem;
}

.save-list-card .save-list-field.save-list-type-row-hidden {
  display: none;
}

.save-list-card .save-list-field label,
.save-list-card .profile-label {
  display: block;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.35rem;
  font-size: 0.95rem;
}

.save-list-type-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.save-list-radio {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  font-family: var(--font);
  font-size: 1rem;
  color: var(--text);
}

.save-list-radio input {
  width: 1.1em;
  height: 1.1em;
  accent-color: var(--secondary);
}

.save-list-card .save-list-field input[type="text"] {
  font-family: var(--font);
  font-size: 1rem;
  padding: 0.6rem 0.75rem;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.save-list-cloud-hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0.3rem 0 0 0;
  line-height: 1.35;
}

.save-list-cloud-hint.hidden {
  display: none;
}

/* Load list phase */
.btn-load-list {
  font-family: var(--font);
  font-size: 0.95rem;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  border: 2px solid var(--secondary);
  background: rgba(92, 184, 178, 0.15);
  color: var(--text);
  cursor: pointer;
}

.btn-load-list:hover {
  background: rgba(92, 184, 178, 0.25);
}

/* Available word lists: phase extends to nearly bottom, list area fills and scrolls */
#phase-load-list.active {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 80px);
  height: 100%;
  overflow: hidden;
}

.load-list-card {
  max-width: 100%;
  padding-bottom: 1.5rem;
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.load-list-card h2,
.load-list-card .hint,
.load-list-card .load-list-filter,
.load-list-card .load-list-registration-scope,
.load-list-card .load-list-search-wrap,
.load-list-card .actions {
  flex-shrink: 0;
}

.load-list-card .load-list-empty {
  flex-shrink: 0;
}

/* Scrollable list fills space between header/filter and Cancel button */
.load-list-card .load-list-container {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
}

.load-list-card .hint {
  margin: 0 0 1rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.load-list-registration-scope {
  margin: 0.35rem 0 0.5rem;
  padding: 0.5rem 0.65rem;
  font-size: 0.9rem;
  line-height: 1.35;
  color: var(--text-muted, #5a6570);
  background: var(--surface-subtle, rgba(0, 0, 0, 0.04));
  border-radius: 8px;
  border: 1px solid var(--border-subtle, rgba(0, 0, 0, 0.08));
}

.load-list-registration-scope.hidden {
  display: none;
}

.load-list-scope-pills {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}

.load-list-scope-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  font-size: 0.85rem;
  line-height: 1.25;
  background: var(--pill-bg, rgba(255, 255, 255, 0.75));
  border: 1px solid var(--border-subtle, rgba(0, 0, 0, 0.12));
  color: var(--text, #1a1a1a);
}

.load-list-scope-pill.hidden {
  display: none;
}

.load-list-scope-pill-key {
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.75;
}

.load-list-scope-pill-val {
  font-weight: 600;
}

.load-list-scope-pill-nc {
  gap: 0.4rem;
  padding-right: 0.4rem;
}

#load-list-scope-codes-wrap {
  display: contents;
}

.load-list-nc-year-select {
  margin: 0;
  padding: 0.2rem 1.6rem 0.2rem 0.45rem;
  font: inherit;
  font-weight: 600;
  font-size: 0.85rem;
  border: none;
  border-radius: 999px;
  background: var(--pill-inner-bg, rgba(0, 0, 0, 0.06));
  color: inherit;
  cursor: pointer;
  min-width: 6.5rem;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23555' d='M3 4.5L6 8l3-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.4rem center;
}

.load-list-nc-year-select:focus {
  outline: 2px solid var(--focus-ring, #3b82f6);
  outline-offset: 1px;
}

.load-list-scope-hint {
  margin: 0.4rem 0 0;
  font-size: 0.8rem;
  line-height: 1.35;
  color: var(--text-muted, #5a6570);
}

.load-list-scope-hint:empty {
  display: none;
}

.load-list-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
}

.load-list-radio {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  font-family: var(--font);
  font-size: 1rem;
  color: var(--text);
}

.load-list-radio input {
  width: 1.1em;
  height: 1.1em;
  accent-color: var(--secondary);
}

.load-list-search-wrap {
  position: relative;
  margin-bottom: 1rem;
}

.load-list-search {
  width: 100%;
  box-sizing: border-box;
  font-family: var(--font);
  font-size: 1rem;
  padding: 0.6rem 0.75rem;
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  background: #fff;
  color: var(--text);
}

.load-list-search:focus {
  outline: none;
  border-color: var(--secondary);
}

.load-list-search::placeholder {
  color: var(--text-muted);
}

.load-list-school-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 0.25rem;
  max-height: 12rem;
  overflow-y: auto;
  background: #fff;
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  box-shadow: var(--shadow);
  z-index: 10;
}

.load-list-school-suggestions.hidden {
  display: none;
}

.load-list-school-suggestion {
  padding: 0.5rem 0.75rem;
  font-family: var(--font);
  font-size: 0.95rem;
  color: var(--text);
  cursor: pointer;
  border-bottom: 1px solid #f1f5f9;
}

.load-list-school-suggestion:last-child {
  border-bottom: none;
}

.load-list-school-suggestion:hover,
.load-list-school-suggestion[aria-selected="true"] {
  background: #f1f5f9;
}

.load-list-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  margin-bottom: 1rem;
  padding-right: 0.25rem;
}

.load-list-sentinel {
  height: 1px;
  min-height: 1px;
  visibility: hidden;
  pointer-events: none;
}

.load-list-item {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: #f8fafc;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.load-list-item:hover {
  background: #f1f5f9;
  border-color: var(--secondary);
}

.load-list-item-name {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem;
  font-weight: 600;
  color: var(--text);
  font-size: 1rem;
  white-space: normal;
  word-break: break-word;
  min-width: 0;
}

.load-list-date-pill {
  flex-shrink: 0;
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.25;
}

.load-list-name-rest {
  min-width: 0;
}

.load-list-item-row2 {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  width: 100%;
}

.load-list-query-hit {
  background: rgba(92, 184, 178, 0.45);
  color: inherit;
  padding: 0 0.08em;
  border-radius: 4px;
  font-weight: 700;
}

.load-list-word-hits {
  min-width: 0;
  max-width: min(100%, 14rem);
  font-size: 0.82rem;
  line-height: 1.35;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.22);
  color: var(--text);
  white-space: normal;
  word-break: break-word;
  font-variant-numeric: tabular-nums;
}

.load-list-word-hits .load-list-query-hit {
  background: rgba(92, 184, 178, 0.55);
}

.load-list-item-row2-end {
  margin-left: auto;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  justify-content: flex-end;
  min-width: 0;
  flex: 0 1 auto;
}

.load-list-item-meta {
  font-size: 0.9rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.load-list-badges {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  vertical-align: baseline;
}

.load-list-badge {
  font-size: 0.8rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  font-weight: 600;
}

.load-list-badge-device {
  background: rgba(148, 163, 184, 0.28);
  color: var(--text-muted);
}

.load-list-badge-private {
  background: rgba(107, 114, 128, 0.2);
  color: var(--text-muted);
}

.load-list-badge-public {
  background: rgba(92, 184, 178, 0.25);
  color: var(--secondary);
}

.load-list-badge-school {
  background: rgba(255, 200, 87, 0.3);
  color: #b45309;
}

/* School code / year on each row — slightly darker than the list item fill */
.load-list-badge-meta {
  background: #e8edf3;
  color: #475569;
}

.load-list-item-school-month-a .load-list-badge-meta {
  background: rgba(251, 191, 36, 0.38);
  color: #92400e;
}

.load-list-item-school-month-b .load-list-badge-meta {
  background: rgba(147, 197, 253, 0.42);
  color: #1e40af;
}

/* School list view: whole row tinted by month from YYYYMMDD list name prefix */
.load-list-item.load-list-item-school-month-a {
  background: rgba(255, 251, 235, 0.98);
  border-color: rgba(251, 191, 36, 0.55);
}

.load-list-item.load-list-item-school-month-a:hover {
  background: rgba(254, 243, 199, 0.99);
  border-color: var(--secondary);
}

.load-list-item.load-list-item-school-month-b {
  background: rgba(239, 246, 255, 0.98);
  border-color: rgba(147, 197, 253, 0.65);
}

.load-list-item.load-list-item-school-month-b:hover {
  background: rgba(219, 234, 254, 0.99);
  border-color: var(--secondary);
}

.load-list-badge-cloud {
  background: rgba(99, 152, 236, 0.25);
  color: #2563eb;
}

.load-list-item-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.load-list-item-load.btn-small,
.load-list-item-share.btn-small {
  font-size: 0.9rem;
  padding: 0.35rem 0.75rem;
  flex-shrink: 0;
}

.load-list-item-delete.btn-small {
  font-size: 0.9rem;
  padding: 0.35rem 0.75rem;
  flex-shrink: 0;
  border-color: var(--wrong);
  background: rgba(248, 113, 113, 0.15);
  color: var(--wrong);
}

.load-list-item-delete.btn-small:hover {
  background: rgba(248, 113, 113, 0.25);
}

.load-list-empty {
  margin: 0 0 1rem;
  color: var(--text-muted);
  font-size: 1rem;
  text-align: center;
}

.loading-indicator {
  text-align: center;
  color: var(--text-muted);
  font-size: 1.1rem;
  padding: 2rem 0;
  animation: loading-pulse 1.2s ease-in-out infinite;
}
@keyframes loading-pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

.scan-link-row {
  display: flex;
  justify-content: center;
  margin-top: 0.75rem;
}

.btn-scan {
  font-family: var(--font);
  font-size: 1rem;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  border: 2px solid rgba(167, 139, 250, 0.35);
  background: linear-gradient(135deg, #ddd6fe 0%, #c4b5fd 55%, #bdb4fe 100%);
  color: #5b21b6;
  cursor: pointer;
  font-weight: 600;
}

.btn-scan:hover {
  background: linear-gradient(135deg, #e9e5ff 0%, #ddd6fe 50%, #d4c7fd 100%);
  border-color: rgba(139, 92, 246, 0.45);
  transform: scale(1.02);
}

.btn-help {
  font-family: var(--font);
  font-size: 1.1rem;
  min-width: 2.25rem;
  border-radius: 999px;
  border: 2px solid #e5e7eb;
  background: #f8fafc;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
}

.btn-help:hover {
  border-color: var(--secondary);
  background: #ecfeff;
  transform: scale(1.05);
}

.btn-secondary {
  font-family: var(--font);
  font-size: 1rem;
  padding: 0.6rem 1.2rem;
  border-radius: 999px;
  border: 2px solid #e5e7eb;
  background: #f3f4f6;
  color: var(--text);
  cursor: pointer;
}

.btn-secondary:hover {
  background: #e5e7eb;
}

.scan-card .actions {
  flex-wrap: wrap;
  gap: 0.5rem;
}

.scan-crop-actions {
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.scan-crop-actions-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
}

.scan-step {
  width: 100%;
}

.scan-paste-zone {
  display: block;
  width: 100%;
  min-height: 80px;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  border: 2px dashed #94a3b8;
  border-radius: 12px;
  background: #f8fafc;
  color: var(--text-muted);
  font-size: 1rem;
  text-align: center;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}

.scan-paste-zone:hover,
.scan-paste-zone:focus {
  border-color: var(--secondary);
  background: #f1f5f9;
  color: var(--text);
}

.scan-choose-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

.scan-video-wrap {
  width: 90%;
  max-height: 320px;
  border-radius: 16px;
  overflow: hidden;
  background: #000;
  margin-bottom: 1rem;
}

.scan-video-wrap video {
  width: 100%;
  height: auto;
  display: block;
}

.scan-crop-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

#scan-step-crop .scan-crop-actions-row {
  margin-bottom: 0.75rem;
}

.scan-crop-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
  height: 320px;
  max-height: 320px;
  border-radius: 16px;
  overflow: auto;
  background: #111;
}

.scan-crop-controls {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.scan-crop-controls .scan-crop-btn {
  min-width: 2.5rem;
  padding: 0.5rem 0.6rem;
  font-size: 1.1rem;
}

.scan-crop-inner {
  position: relative;
  width: calc(100% * var(--scan-zoom, 1));
  min-width: 100%;
  height: calc(320px * var(--scan-zoom, 1));
  min-height: 320px;
  transform-origin: 0 0;
}

.scan-crop-inner img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.scan-crop-inner canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

.scan-status {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin: 0 0 1rem 0;
  min-height: 1.25rem;
}

.settings-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.45rem 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.settings-row label {
  white-space: nowrap;
}

.settings-row input[type="number"] {
  width: 70px;
  font-family: var(--font);
  font-size: 0.9rem;
  padding: 0.25rem 0.4rem;
  border-radius: 8px;
  border: 2px solid #e5e7eb;
}

.settings-row select {
  font-family: var(--font);
  font-size: 0.9rem;
  padding: 0.25rem 0.4rem;
  border-radius: 8px;
  border: 2px solid #e5e7eb;
  background: #fff;
}

/* Difficulty tab: select sits immediately after the label (no flex-grow on label — avoids pushing select to the far right). */
.settings-row-definition-complexity label {
  flex: 0 0 auto;
  white-space: nowrap;
}

.settings-row-definition-complexity select {
  flex: 0 0 auto;
}

.settings-row-wrap,
.settings-row-toggle {
  flex-wrap: wrap;
}

/* Stacked variant: explanation on its own line, then label + combobox
   together on the line below (used by Difficulty mode / Cycle length). */
.settings-row-stacked {
  flex-direction: column;
  align-items: flex-start;
}
.settings-row-stacked .settings-field-hint {
  order: -1;          /* hint first regardless of DOM order */
  margin: 0 0 0.35rem 0;
  white-space: normal;
}
.settings-row-stacked .settings-row-control {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.settings-row-toggle label {
  white-space: normal;
}

.settings-row input[type="checkbox"] {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--secondary);
  flex-shrink: 0;
}


.settings-card h2 {
  margin-top: 0;
  margin-bottom: 0.25rem;
  font-size: 1.15rem;
}

.settings-card > .hint {
  margin-bottom: 0.35rem;
  font-size: 0.8rem;
}

.settings-card > .settings-note {
  font-size: 0.8rem;
  margin: 0 0 0.3rem 0;
}

.settings-card .actions-row {
  margin-top: 0.4rem;
}

.settings-card .btn-big {
  font-size: 0.95rem;
  padding: 0.5rem 1rem;
}

.settings-card .btn-secondary {
  font-size: 0.9rem;
  padding: 0.45rem 1rem;
}

/* Learn phase: sticky action buttons, scrollable card body */
body:has(#phase-learn.active) .app-center-wrap {
  align-self: stretch;   /* stretch only the main column; sidebar keeps its own align-self:center */
}
body:has(#phase-learn.active) .app {
  min-height: 0;
}
body:has(#phase-learn.active) .main-pane {
  flex: 1 1 0;
  min-height: 0;
}
#phase-learn.active {
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
}
#phase-learn.active .learn-card {
  flex: 1 1 0;
  min-height: 0;
}
.learn-card-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}
#phase-learn.active .learn-card-body {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  padding-bottom: 0.25rem;
  row-gap: 0;
}
#phase-learn.active .learn-card > .actions,
#phase-learn.active .learn-card > .progress-dots,
#phase-learn.active .learn-card > .learn-progress-row {
  flex-shrink: 0;
}

/* Settings page (⚙️ Adults): wider pane + sticky action buttons, scrollable panel body */
body:has(#phase-settings.active) .app-wrap {
  align-items: stretch;
}
body:has(#phase-settings.active) .app-center-wrap {
  flex: 0 0 min(940px, 100%);
  max-width: 100%;
}
body:has(#phase-settings.active) .app {
  flex: 1 1 0;
  min-height: 0;
  max-width: 940px;
}
body:has(#phase-settings.active) .main-pane {
  flex: 1 1 0;
  min-height: 0;
}
#phase-settings.active {
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
}
.settings-card {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.settings-card h2,
.settings-card .settings-mode-tabs,
.settings-card .settings-mode-desc,
.settings-card .settings-tabs,
.settings-card .actions-row {
  flex-shrink: 0;
}
.settings-card .settings-panel:not([hidden]) {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  margin-bottom: 0;
  padding-bottom: 0.5rem;
}

.settings-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-bottom: 0.75rem;
  border-bottom: 2px solid #e5e7eb;
}

.settings-tab {
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.4rem 0.75rem;
  border: none;
  border-radius: 8px 8px 0 0;
  background: #f1f5f9;
  color: var(--text);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.settings-tab:hover {
  background: #e2e8f0;
}

.settings-tab.active {
  background: #fff;
  color: var(--secondary);
  border: 2px solid #e5e7eb;
  border-bottom-color: #fff;
  margin-bottom: -2px;
}

.settings-panel {
  margin-bottom: 0.5rem;
}

/* Difficulty panel: tip matches row label size (0.85rem), italic */
#settings-panel-difficulty .settings-note {
  font-size: 0.85rem;
  font-style: italic;
}

.settings-panel.active {
  display: block;
}

.tools-btn-row {
  display: flex;
  gap: 0.75rem;
}
/* Foundry status bar on frontpage */
.foundry-status-bar {
  font-size: 0.78rem;
  color: var(--text-secondary, #64748b);
  padding: 0.4rem 0.5rem;
  margin-top: 0.3rem;
  border-top: 1px solid var(--border, #e2e8f0);
  line-height: 1.4;
}
.foundry-status-bar .foundry-spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid var(--border, #e2e8f0);
  border-top-color: var(--primary, #6366f1);
  border-radius: 50%;
  animation: foundry-spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 0.3rem;
}
@keyframes foundry-spin {
  to { transform: rotate(360deg); }
}
.foundry-status-bar .foundry-done {
  color: #16a34a;
}
.foundry-status-bar .foundry-error {
  color: #dc2626;
}

.tools-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  align-items: start;
}
/* Each grid cell stacks its fieldsets vertically (Welcome tour above Teaching
   materials in the left column; Dictation in the right; Report wraps to row 2). */
.tools-col {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}
@media (max-width: 600px) {
  .tools-grid { grid-template-columns: 1fr; }
}
.tools-dictation-fieldset {
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px;
  padding: 0.75rem;
}
.tools-dictation-fieldset legend {
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0 0.3rem;
}
.tools-dictation-options {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

/* ─── Quiz Map + Play menu top row (back + centred title) ─── */
.quiz-map-top-row,
.play-menu-top-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 0.5rem;
  width: 100%;
}

.play-menu-top-row {
  margin-bottom: 0.25rem;
}

.btn-quiz-map-back {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.75rem;
  border: 2px solid var(--accent, #5b8def);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
}

.btn-quiz-map-back:hover {
  background: #fff;
  transform: scale(1.03);
}

.btn-quiz-map-back--compact {
  padding: 0.3rem 0.55rem;
  font-size: 0.82rem;
  gap: 0.28rem;
  flex-shrink: 0;
}

.quiz-map-back-icon {
  flex-shrink: 0;
  display: block;
}

.quiz-map-back-label {
  line-height: 1;
}

.quiz-map-top-row .quiz-map-title,
.play-menu-top-row .play-menu-title {
  justify-self: center;
  grid-column: 2;
  margin: 0;
}

.play-menu-title {
  font-family: var(--font);
  font-size: clamp(1rem, 2.8vw, 1.25rem);
  font-weight: 700;
  text-align: center;
  color: var(--text);
}

.quiz-map-top-spacer {
  grid-column: 3;
  min-width: 0;
  pointer-events: none;
}

/* ─── Puzzles page ─── */
.puzzles-card {
  padding: 1rem 1.25rem;
  max-width: 40rem;
  margin: 0 auto;
}
.puzzles-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  margin: 0.75rem 0;
}
.puzzle-pick {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.75rem 0.5rem;
  border: 2px solid #e5e7eb;
  border-radius: 14px;
  background: #fafbfc;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
  font-family: var(--font);
}
.puzzle-pick:hover {
  border-color: var(--secondary);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(92, 184, 178, 0.15);
}
.puzzle-pick-icon {
  font-size: 2rem;
}
.puzzle-pick-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}
.puzzle-pick-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.puzzles-play-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.puzzles-play-header h3 {
  flex: 1;
  margin: 0;
  font-size: 1.1rem;
  color: var(--primary);
}
.puzzles-score {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--secondary);
}
#puzzles-play-area {
  min-height: 10rem;
}

/* Scramble */
.scramble-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}
.scramble-item {
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  padding: 0.75rem;
  text-align: center;
  transition: border-color 0.3s;
}
.scramble-item.solved {
  border-color: var(--success);
  background: #f0fdf4;
}
.scramble-letters {
  display: flex;
  justify-content: center;
  gap: 0.3rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}
.scramble-tile {
  width: 2.2rem;
  height: 2.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 700;
  border-radius: 6px;
  background: var(--accent);
  color: var(--text);
  cursor: pointer;
  user-select: none;
  transition: transform 0.15s, opacity 0.2s;
}
.scramble-tile.used {
  opacity: 0.3;
  pointer-events: none;
}
.scramble-tile:hover {
  transform: scale(1.1);
}
.scramble-answer {
  display: flex;
  justify-content: center;
  gap: 0.2rem;
  min-height: 2.4rem;
  margin-bottom: 0.4rem;
}
.scramble-answer-slot {
  width: 2.2rem;
  height: 2.4rem;
  border-bottom: 2px solid var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--primary);
  cursor: pointer;
}
.scramble-answer-slot.scramble-hint-slot {
  color: #7c3aed;
  opacity: 0.7;
  cursor: default;
  border-bottom-color: #7c3aed;
}
.scramble-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* Crossword */
.cw-grid {
  display: inline-grid;
  gap: 0;
  margin: 0 auto 0.75rem;
}
.cw-cell {
  width: 2.5rem;
  height: 2.5rem;
  border: 1.5px solid #2d3142;
  text-align: center;
  font-size: 1rem;
  font-weight: 700;
  font-family: var(--font);
  text-transform: uppercase;
  padding: 0.3rem 0 0 0;
  background: #fff;
  position: relative;
  box-sizing: border-box;
}
.cw-cell:focus {
  outline: 2px solid var(--secondary);
  z-index: 1;
}
.cw-cell.cw-correct {
  background: #dcfce7;
  color: var(--success);
}
.cw-cell.cw-hint {
  background: #ede9fe;
  color: #7c3aed;
  font-weight: 700;
}
.cw-cell-blank {
  width: 2.5rem;
  height: 2.5rem;
  border: none;
  background: transparent;
}
.cw-cell-wrap {
  position: relative;
  width: 2.5rem;
  height: 2.5rem;
}
.cw-cell-wrap.cw-border-right {
  border-right: 3px solid #1e293b;
}
.cw-cell-wrap.cw-border-bottom {
  border-bottom: 3px solid #1e293b;
}
.cw-cell-wrap .cw-cell {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.cw-num-label {
  position: absolute;
  top: 1px;
  left: 2px;
  font-size: 1.1rem;
  line-height: 1;
  color: var(--primary);
  font-weight: 600;
  pointer-events: none;
  z-index: 2;
  background: rgba(255,255,255,0.85);
  border-radius: 2px;
  padding: 0 1px;
}
.cw-clues {
  display: flex;
  gap: 1.5rem;
  font-size: 0.85rem;
  margin-top: 0.5rem;
}
.cw-clues h4 {
  margin: 0 0 0.3rem;
  color: var(--secondary);
  font-size: 0.9rem;
}
.cw-clues p {
  margin: 0.15rem 0;
}
.cw-clue-num {
  font-weight: 700;
  color: var(--primary);
}
.cw-clue.cw-clue-solved {
  text-decoration: line-through;
  opacity: 0.5;
}

/* Word Search */
.ws-container {
  text-align: center;
}
.ws-grid {
  display: inline-grid;
  gap: 0;
  user-select: none;
}
.ws-cell {
  width: 1.8rem;
  height: 1.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  border-radius: 3px;
  transition: background 0.15s;
}
.ws-cell:hover {
  background: #fef0f3;
}
.ws-cell.ws-selecting {
  background: #fef0f3;
}
.ws-cell.ws-hint {
  background: #f3e8ff;
  color: #7c3aed;
  border-radius: 50%;
}
.ws-cell.ws-found {
  background: #dcfce7;
  color: var(--success);
  border-radius: 4px;
}
.ws-words {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 0.75rem;
}
.ws-word-tag {
  padding: 0.25rem 0.6rem;
  border: 1.5px solid var(--secondary);
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--secondary);
}
.ws-word-tag.ws-word-found {
  background: #dcfce7;
  border-color: var(--success);
  color: var(--success);
  text-decoration: line-through;
}

/* Missing Letters */
.missing-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.6rem;
}
.missing-item {
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  padding: 0.6rem 0.75rem;
  transition: border-color 0.3s;
}
.missing-item.solved {
  border-color: var(--success);
  background: #f0fdf4;
}
.missing-word-row {
  display: flex;
  justify-content: center;
  gap: 0.15rem;
  margin-bottom: 0.4rem;
  flex-wrap: wrap;
}
.missing-char {
  width: 2rem;
  height: 2.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
}
.missing-input {
  width: 2rem;
  height: 2.2rem;
  border: none;
  border-bottom: 2.5px solid var(--primary);
  background: transparent;
  text-align: center;
  font-size: 1.15rem;
  font-weight: 700;
  font-family: var(--font);
  color: var(--primary);
  padding: 0;
  text-transform: lowercase;
}
.missing-input:focus {
  outline: none;
  border-bottom-color: var(--secondary);
}
.missing-input.correct {
  border-bottom-color: var(--success);
  color: var(--success);
}
.missing-input.wrong {
  border-bottom-color: var(--wrong);
  color: var(--wrong);
}
.missing-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
}

/* Match Up */
.match-container {
  display: flex;
  gap: 1rem;
  justify-content: center;
}
.match-col {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
  max-width: 14rem;
}
.match-col.match-col-hints {
  flex: 2;
  max-width: 28rem;
}
.match-item {
  padding: 0.5rem 0.7rem;
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
  text-align: center;
  user-select: none;
}
.match-item:hover {
  border-color: var(--secondary);
}
.match-item.match-selected {
  border-color: var(--primary);
  background: #fef0f3;
  transform: scale(1.03);
}
.match-item.match-correct {
  border-color: var(--success);
  background: #dcfce7;
  pointer-events: none;
}
.match-item.match-wrong {
  border-color: var(--wrong);
  background: #fef2f2;
  animation: matchShake 0.4s;
}
.match-word {
  font-weight: 700;
}
.match-def {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: left;
  line-height: 1.35;
}
@keyframes matchShake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* Puzzle complete banner */
.puzzle-complete {
  text-align: center;
  padding: 1.5rem 1rem;
  animation: puzzlePop 0.4s ease-out;
}
.puzzle-complete-icon {
  font-size: 3rem;
}
.puzzle-complete-text {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--primary);
  margin: 0.5rem 0;
}
.puzzle-complete-score {
  font-size: 0.95rem;
  color: var(--text-muted);
}
@keyframes puzzlePop {
  0% { transform: scale(0.8); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* ─── Play phase ─── */
.play-card { padding-bottom: 1.5rem; }
.play-learn-break-info {
  margin: 0.5rem 0 0.25rem;
  padding: 0.55rem 0.85rem;
  border-radius: 0.5rem;
  background: color-mix(in srgb, var(--secondary) 15%, transparent);
  border: 1px solid color-mix(in srgb, var(--secondary) 40%, transparent);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text, #1e293b);
}
.play-learn-break-info.hidden { display: none !important; }
.play-category-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--primary);
  margin: 1rem 0 0.3rem;
  padding-bottom: 0.2rem;
  border-bottom: 2px solid var(--secondary);
}
#play-menu .play-category-title:first-of-type {
  margin-top: 0.35rem;
}
.play-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.5rem;
  margin: 0.4rem 0;
}
.play-pick {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  padding: 0.35rem 0.25rem;
  border: 2px solid #e5e7eb;
  border-radius: 14px;
  background: #fafbfc;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
  font-family: var(--font);
}
.play-pick:hover {
  border-color: var(--secondary);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(92, 184, 178, 0.15);
}
.play-pick-icon { font-size: 1.8rem; }
.play-pick-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
  text-align: center;
}
.play-play-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.play-play-header h3 {
  flex: 1;
  margin: 0;
  font-size: 1.1rem;
  color: var(--primary);
}
.play-score {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--secondary);
}
#play-play-area { min-height: 10rem; }

/* Creature bar */
.play-creature-bar {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.4rem 0 0.15rem;
  margin-bottom: 0;
}
.play-creature {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 4.5rem;
  text-align: center;
}
.play-creature-emoji { font-size: 1.6rem; }
.play-creature-name {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text);
}
.play-creature-word {
  font-size: 0.62rem;
  color: var(--secondary);
  max-width: 4.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.play-creature.locked {
  background: linear-gradient(135deg, #e0e0e0 0%, #c8c8c8 100%);
  border-radius: 12px;
  padding: 0.3rem 0.2rem;
  position: relative;
}
.play-creature.locked .play-creature-emoji {
  font-size: 1.8rem;
  filter: none;
  opacity: 1;
}
.play-creature.locked .play-creature-name { color: var(--text-muted); font-style: italic; }
.play-creature.locked .play-creature-word { display: none; }

/* Reveal animation when a creature is unlocked */
.play-creature.creature-reveal {
  animation: creatureReveal 0.8s ease-out;
}
@keyframes creatureReveal {
  0% { transform: scale(0.5) rotate(-10deg); opacity: 0.3; background: #ffe066; }
  40% { transform: scale(1.3) rotate(5deg); opacity: 1; background: #fff9c4; }
  70% { transform: scale(0.95) rotate(-2deg); }
  100% { transform: scale(1) rotate(0); background: transparent; }
}

/* Soft triple pulse when returning to Play after uncovering a creature. */
@keyframes playCreatureTileFlash {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(124, 111, 235, 0);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 0 4px rgba(124, 111, 235, 0.32), 0 0 16px rgba(124, 111, 235, 0.22);
    transform: scale(1.05);
  }
}
.play-creature.play-creature-flash {
  animation: playCreatureTileFlash 1.05s ease-in-out 3;
  position: relative;
  z-index: 2;
}

/* Unlocked creature tiles are clickable — give a soft cursor + hover hint. */
.play-creature:not(.locked) { cursor: pointer; }
.play-creature:not(.locked):hover,
.play-creature:not(.locked):focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(0,0,0,0.12);
  outline: none;
}

/* ── Mystery-creature unlock popup ─────────────────────────────────────── */
.creature-popup-overlay {
  position: fixed; inset: 0; z-index: 2000;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.creature-popup-overlay.hidden { display: none; }
.creature-popup-backdrop {
  position: absolute; inset: 0;
  background: rgba(20, 30, 50, 0.72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.creature-popup-box {
  position: relative;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.35);
  padding: 1.25rem 1.25rem 1.5rem;
  max-width: min(640px, 96vw);
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 0.85rem;
}
.creature-popup-close {
  position: absolute; top: 0.4rem; right: 0.55rem;
  width: 2rem; height: 2rem;
  border: none; background: transparent;
  font-size: 1.7rem; line-height: 1;
  cursor: pointer; color: #555;
  border-radius: 50%;
}
.creature-popup-close:hover,
.creature-popup-close:focus-visible {
  background: rgba(0,0,0,0.06); color: #222; outline: none;
}
/* Congrats banner above the video — celebrates the unlock and quotes the
   creature's pre-allocated well-done phrase under a fixed "You uncovered me"
   line. Two-line layout so the static encouragement and the per-creature
   voice line read as separate beats. */
.creature-popup-congrats {
  text-align: center;
  margin: 0;
  padding: 0.4rem 0.5rem 0;
  display: flex; flex-direction: column; gap: 0.25rem;
}
.creature-popup-congrats-line {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: #2a7a3a;
  line-height: 1.25;
}
.creature-popup-phrase {
  margin: 0;
  font-size: 1.05rem;
  font-style: italic;
  color: #d97706;
  line-height: 1.3;
}
.creature-popup-phrase:empty { display: none; }
/* While /api/creatures is in flight, the phrase + description show
   "Loading…" — render in a muted style so it reads as a placeholder. */
.creature-popup-phrase.is-loading,
.creature-popup-description.is-loading {
  color: #888;
  font-style: italic;
  font-weight: normal;
}
/* And the media box gets a subtle "loading" backdrop with a centred dot
   animation while we don't yet know whether to show video / poster / nothing. */
.creature-popup-media.is-loading::after {
  content: 'Loading…';
  position: absolute;
  inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: #ddd;
  font-size: 1rem;
  letter-spacing: 0.05em;
  background: linear-gradient(135deg, #1a2030 0%, #2a3040 100%);
  pointer-events: none;
}

.creature-popup-media {
  position: relative;
  width: 100%;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  display: flex; align-items: center; justify-content: center;
}
.creature-popup-media[data-orientation="vertical"] {
  aspect-ratio: 9 / 16;
  max-height: 70vh;
  margin: 0 auto;
}
.creature-popup-video,
.creature-popup-poster {
  width: 100%; height: 100%;
  object-fit: contain;
  background: #000;
  display: block;
}
.creature-popup-poster.hidden,
.creature-popup-video.hidden { display: none; }
.creature-popup-controls {
  position: absolute;
  left: 50%; bottom: 0.6rem;
  transform: translateX(-50%);
  display: flex; gap: 0.6rem;
  background: rgba(0,0,0,0.45);
  border-radius: 999px;
  padding: 0.3rem 0.55rem;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
/* In fullscreen the custom controls overlay the video itself. */
.creature-popup-video:fullscreen + .creature-popup-poster + .creature-popup-controls,
.creature-popup-media:fullscreen .creature-popup-controls {
  bottom: 1.5rem;
}
.creature-popup-ctrl {
  width: 2.5rem; height: 2.5rem;
  border: none; background: transparent; color: #fff;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  padding: 0;
}
.creature-popup-ctrl:hover,
.creature-popup-ctrl:focus-visible {
  background: rgba(255,255,255,0.18);
  outline: none;
}
.creature-popup-icon { display: block; }
.creature-popup-icon.hidden { display: none; }
.creature-popup-title {
  margin: 0;
  font-size: 1.3rem;
  text-align: center;
}
.creature-popup-description {
  margin: 0;
  text-align: center;
  color: var(--text-muted, #555);
  line-height: 1.45;
}
/* List-specific descriptions weave in the learner's words; we mark them
   with this wrapper and render each word using the existing breakdown
   spans (.learn-spell-word .learn-spell-part) so the syllables are visible. */
.creature-popup-word-highlight {
  display: inline-block;
  padding: 0 0.15rem;
  border-radius: 4px;
  background: #fff7d6;
  box-shadow: inset 0 -2px 0 rgba(217, 119, 6, 0.4);
}
.creature-popup-word-highlight .learn-spell-word { display: inline; }
.creature-popup-actions {
  display: flex; justify-content: center;
  margin-top: 0.25rem;
}
.creature-popup-close-btn {
  min-width: 8rem;
}
/* Hide native controls on browsers that don't honour our `controls` removal
   (we never set the `controls` attribute, but defensive: also hide the
   webkit overlay-play button on iOS so only our custom buttons drive UX). */
.creature-popup-video::-webkit-media-controls-start-playback-button { display: none !important; -webkit-appearance: none; }
.creature-popup-video::-webkit-media-controls-overlay-play-button { display: none !important; }
.creature-popup-video::-webkit-media-controls { display: none !important; }

/* Trophy popup */
.trophy-popup-overlay {
  position: fixed; inset: 0; z-index: 2000;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.trophy-popup-overlay.hidden { display: none; }
.trophy-popup-box { text-align: center; }
.trophy-popup-hero {
  display: flex; justify-content: center; align-items: center;
  padding: 0.5rem 0 0.25rem;
}
.trophy-popup-emoji { font-size: 4rem; line-height: 1; }
.trophy-popup-title {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent, #ffc857);
  text-align: center;
}
.trophy-popup-media {
  aspect-ratio: 9 / 16;
  max-height: 40vh;
  width: auto;
  margin: 0 auto;
}
.trophy-popup-media[data-orientation="horizontal"] { aspect-ratio: 16 / 9; max-height: none; }
.trophy-popup-quest {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-muted, #555);
  text-align: center;
  font-style: italic;
}
.trophy-popup-quest.hidden { display: none; }
.achievements-trophy:focus-visible {
  outline: 2px solid var(--accent, #ffc857);
  outline-offset: 2px;
}

/* Mini-game: Spell It */
.mini-spell-wrap { text-align: center; padding: 1rem 0; }
.mini-spell-speaker {
  font-size: 3rem;
  cursor: pointer;
  user-select: none;
  display: inline-block;
  transition: transform 0.15s;
}
.mini-spell-speaker:hover { transform: scale(1.15); }
.mini-spell-hint { font-size: 0.85rem; color: var(--text-muted); margin: 0.5rem 0; }
.mini-spell-input {
  font-size: 1.3rem;
  padding: 0.5rem 0.75rem;
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  text-align: center;
  width: 80%;
  max-width: 300px;
  font-family: var(--font);
}
.mini-spell-input:focus { border-color: var(--secondary); outline: none; }
.mini-spell-check {
  margin-top: 0.5rem;
}

/* Mini-game: Unscramble */
.mini-unscramble-wrap { text-align: center; padding: 0.5rem 0; }
.mini-unscramble-slots {
  display: flex;
  justify-content: center;
  gap: 0.3rem;
  margin: 0.75rem 0;
  min-height: 2.5rem;
  flex-wrap: wrap;
}
.mini-slot {
  width: 2rem;
  height: 2.2rem;
  border: 2px dashed #ccc;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.2s;
}
.mini-slot.filled {
  border-style: solid;
  border-color: var(--secondary);
  background: #e8f5f3;
}
.mini-slot.mini-hint-slot {
  border-color: #7c3aed;
  background: #ede9fe;
  color: #7c3aed;
  opacity: 0.7;
  cursor: default;
}
.mini-letter-tiles {
  display: flex;
  justify-content: center;
  gap: 0.3rem;
  flex-wrap: wrap;
  margin: 0.5rem 0;
}
.mini-letter-tile {
  width: 2rem;
  height: 2.2rem;
  border: 2px solid var(--secondary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  background: #fff;
  transition: transform 0.15s, opacity 0.15s;
}
.mini-letter-tile:hover { transform: scale(1.1); }
.mini-letter-tile.used { opacity: 0.3; pointer-events: none; }

/* Mini-game: Fill the Gap */
.mini-fill-wrap { text-align: center; padding: 0.5rem 0; }
.mini-fill-row {
  display: flex;
  justify-content: center;
  gap: 0.15rem;
  margin: 0.75rem 0;
  flex-wrap: wrap;
}
.mini-fill-char {
  width: 2rem;
  height: 2.2rem;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
  background: #f0f0f0;
}
.mini-fill-input {
  width: 2rem;
  height: 2.2rem;
  border: 2px dashed #ccc;
  border-radius: 8px;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 700;
  font-family: var(--font);
  padding: 0;
  text-transform: lowercase;
}
.mini-fill-input:focus { border-color: var(--secondary); outline: none; }
.mini-fill-input.correct { border-color: #22c55e; background: #dcfce7; }
.mini-fill-input.wrong { border-color: #ef4444; background: #fee2e2; }

/* Mini-game: Build It */
.mini-build-wrap { text-align: center; padding: 0.5rem 0; }
.mini-build-target {
  display: flex;
  justify-content: center;
  gap: 0.3rem;
  margin: 0.75rem 0;
  min-height: 2.5rem;
  flex-wrap: wrap;
}
.mini-build-slot {
  padding: 0.35rem 0.6rem;
  border: 2px dashed #ccc;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 700;
  min-width: 6rem;
  min-height: 2.5rem;
  cursor: pointer;
  transition: border-color 0.2s;
}
.mini-build-slot.filled {
  border-style: solid;
  border-color: var(--secondary);
  background: #e8f5f3;
}
.mini-build-pills {
  display: flex;
  justify-content: center;
  gap: 0.3rem;
  flex-wrap: wrap;
  margin: 0.5rem 0;
}
.mini-build-pill {
  padding: 0.35rem 0.7rem;
  border: 2px solid var(--secondary);
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  background: #fff;
  transition: transform 0.15s, opacity 0.15s;
}
.mini-build-pill:hover { transform: scale(1.05); }
.mini-build-pill.used { opacity: 0.3; pointer-events: none; }

/* Mini-game shared feedback */
.mini-word-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}
.mini-progress {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}
.mini-feedback {
  font-size: 1rem;
  font-weight: 700;
  min-height: 1.5rem;
  margin: 0.3rem 0;
}
.mini-feedback.correct { color: #22c55e; }
.mini-feedback.wrong { color: #ef4444; }

/* Star burst celebration (falling stars on correct word) */
.star-burst-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  overflow: hidden;
}
.star-burst-p {
  position: absolute;
  top: -20px;
  opacity: 0;
  animation: starBurstFall ease-in forwards;
}
@keyframes starBurstFall {
  0% { transform: translateY(0) rotate(0deg) scale(0.5); opacity: 1; }
  80% { opacity: 0.8; }
  100% { transform: translateY(100vh) rotate(720deg) scale(1); opacity: 0; }
}

@keyframes miniShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}
.mini-shake { animation: miniShake 0.4s ease-out; }

@media (max-width: 500px) {
  .play-grid { grid-template-columns: 1fr 1fr; }
}

.settings-panel[hidden] {
  display: none !important;
}

/* Breakdown comparison table */
.bdcmp-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.bdcmp-table {
  border-collapse: collapse;
  font-size: 0.8rem;
  min-width: 100%;
  white-space: nowrap;
}
.bdcmp-table th,
.bdcmp-table td {
  border: 1px solid #e5e7eb;
  padding: 0.3rem 0.5rem;
  text-align: left;
}
.bdcmp-table thead th {
  background: #f3f4f6;
  font-weight: 600;
  color: #374151;
  position: sticky;
  top: 0;
}
.bdcmp-table td.bdcmp-word {
  font-weight: 600;
  color: #111827;
  background: #f9fafb;
}
.bdcmp-table tbody tr:hover td {
  background: #eff6ff;
}
.bdcmp-p0 {
  background: #dbeafe;
  border-radius: 3px;
  padding: 0 2px;
}
.bdcmp-p1 {
  background: #fce4ec;
  border-radius: 3px;
  padding: 0 2px;
}
.bdcmp-dot {
  color: #9ca3af;
  font-size: 0.75em;
  margin: 0 1px;
}

.settings-sources-group {
  border: 1.5px solid #e5e7eb;
  border-radius: 10px;
  padding: 0.35rem 0.6rem 0.2rem;
  margin-bottom: 0.4rem;
}

.settings-source-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  margin-bottom: 0.3rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.settings-source-row label {
  white-space: normal;
  line-height: 1.3;
}

.settings-source-row select {
  font-family: var(--font);
  font-size: 0.82rem;
  padding: 0.2rem 0.35rem;
  border-radius: 7px;
  border: 2px solid #e5e7eb;
  background: #fff;
  width: max-content;
  max-width: 100%;
  min-width: 8rem;
}

.settings-source-row select:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.settings-linked-row {
  flex-direction: row;
  align-items: center;
  gap: 0.4rem;
  border-top: 1px dashed #e5e7eb;
  padding-top: 0.25rem;
}

.settings-linked-row label {
  flex: 0 0 auto;
}

.settings-linked-row input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--secondary);
  flex-shrink: 0;
}

.settings-subrow {
  padding-left: 0.85rem;
}

.settings-source-note {
  font-size: 0.75rem;
  font-style: italic;
  margin-top: 0;
  margin-bottom: 0.15rem;
}

.settings-field-hint {
  margin-top: 0.25rem;
  flex-basis: 100%;
}

/* Decorative animations note: match checkbox row label size (0.85rem), italic */
.settings-animations-hint {
  font-size: 0.85rem;
  font-style: italic;
}

.settings-note {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin: 0 0 1rem 0;
}

.actions {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.85rem;
}

.input-card > .actions,
.input-card-actions {
  gap: 0.5rem;
}

.input-card-actions {
  margin-top: 0.35rem;
}

/* Small gap between buttons in T1–T5 phases */
.learn-card .actions {
  margin-top: 0.4rem;
}
/* Learn phase: green Spell action */
.learn-spell-btn {
  background: radial-gradient(circle at 20% 20%, #86efac, #22c55e);
  color: #fff;
  font-weight: 600;
  border: none;
}
.learn-spell-btn:hover:not(:disabled) {
  background: radial-gradient(circle at 20% 20%, #4ade80, #16a34a);
}

.learn-next-wrap {
  position: relative;
  display: inline-block;
  flex-shrink: 0;
}
.learn-next-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  cursor: not-allowed;
}
.learn-next-overlay:not(.hidden) {
  pointer-events: auto;
}
.learn-card .actions,
.learn-story-card .actions,
.school-cover-card .actions,
.school-video-card .actions,
.learn-fill-card .actions,
.quiz-t3-card .actions,
.learn-summary-card .actions,
.assess-card .actions,
.results-card .actions {
  gap: 0.5rem;
}
.results-four-complete-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
}
.results-four-complete-actions.hidden {
  display: none !important;
}

.actions-row {
  flex-wrap: wrap;
  gap: 0.45rem;
  justify-content: center;
}

.btn {
  font-family: var(--font);
  font-size: clamp(0.95rem, 2.2vw, 1.05rem);
  font-weight: 600;
  padding: 0.58rem 1.15rem;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  transition: transform 0.15s, box-shadow 0.15s, background 0.2s;
}

.btn:hover:not(:disabled) {
  transform: scale(1.02);
  box-shadow: 0 6px 16px rgba(0,0,0,0.14);
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
  box-shadow: 0 3px 10px rgba(0,0,0,0.12);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: radial-gradient(circle at 20% 20%, #6ee7b7, #22c1c3);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: radial-gradient(circle at 20% 20%, #4ade80, #1ba7ab);
}

.btn-primary.at-max-words {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary.at-max-words:hover {
  cursor: not-allowed;
}

.btn-big {
  background: radial-gradient(circle at 20% 20%, #ff9a9e, #e85d75);
  color: white;
  font-size: clamp(1rem, 2.5vw, 1.12rem);
  padding: 0.7rem 1.2rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  position: relative;
  overflow: hidden;
}

/* Buttons with a .btn-emoji inside: flex-centre all items */
button:has(.btn-emoji) {
  display: inline-flex !important;
  align-items: center;
}
.btn-emoji {
  font-size: 2em;
  flex-shrink: 0;
  line-height: 1;
}

/* Per-button vertical-padding reductions to absorb the taller 2em emoji */
.input-card-actions .btn-big        { padding: 0.38rem 0.65rem; }
.learn-card .actions .btn-big       { padding: 0.5rem 1.0rem; }
.learn-summary-card .actions .btn-big { padding: 0.5rem 1.0rem; }
#learn-prev                   { padding: 0.5rem 1.0rem; }
#learn-spell-btn              { padding: 0.45rem 1.0rem; }
#learn-summary-hear-btn       { padding: 0.5rem 1.2rem; }
#quiz-map-treasure-btn        { padding: 0.5rem 1.0rem; }
#quiz-map-start-day2-btn      { padding: 0.5rem 1.0rem; }
#home-btn                     { padding: 0.35rem 0.95rem; }
/* Prevent ➡️ being clipped: overflow clipping must not hide end emoji */
#learn-next                   { overflow: visible; }

.btn-big::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.btn-big:hover::before {
  width: 300px;
  height: 300px;
}

.btn-big:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-big.no-words {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-big.no-words:hover:not(:focus) {
  background: radial-gradient(circle at 20% 20%, #ff9a9e, #e85d75);
}

/* Learning phase */
.learn-image-wrap {
  text-align: center;
  margin: 0 0 0.6rem 0;
  min-height: 120px;
}

.learn-image {
  max-width: 80%;
  max-height: 180px;
  width: auto;
  height: auto;
  border-radius: 16px;
  object-fit: contain;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

.learn-image-placeholder {
  width: 120px;
  height: 120px;
  margin: 0 auto;
  border-radius: 16px;
  background: linear-gradient(135deg, #e5e7eb 0%, #f3f4f6 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  color: #9ca3af;
}

.learn-word-spell-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: fit-content;
  max-width: 100%;
  margin: 0.4rem auto 0.35rem auto;
}

.learn-word {
  font-size: clamp(1.25rem, 6vw + 1rem, 3.5rem);
  font-weight: 400;
  text-transform: lowercase;
  text-align: center;
  margin: 0;
  letter-spacing: 0.06em;
  text-shadow: none;
  animation: wordPulse 2s ease-in-out 2;
  transform: scale(1);
  display: block;
  max-width: 100%;
  box-sizing: border-box;
  overflow-wrap: break-word;
  word-break: break-word;
  background: #FFE06E;
  color: #2E333D;
  padding: 0.02em 1.12em 0.07em 1.12em;
  line-height: 1.05;
  border-radius: 16px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

@keyframes wordPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.definition-line .def-highlight {
  background: linear-gradient(135deg, #fef08a 0%, #fde047 100%);
  border-radius: 0.35em;
  padding: 0.08em 0.3em;
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.definition-example .def-highlight {
  background: linear-gradient(135deg, #fef08a 0%, #fde047 100%);
  border-radius: 0.35em;
  padding: 0.08em 0.3em;
  font-weight: inherit;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.learn-meaning {
  background: #f8fafc;
  border-radius: 14px;
  padding: 0.5rem 1.25rem;
  margin: 0 0 1rem 0;
}

.learn-meaning-heading {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
  flex-wrap: wrap;
}

.learn-meaning-label {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--secondary);
  margin: 0;
}

.learn-definition {
  font-size: 1.05rem;
  line-height: 1.5;
  color: var(--text);
  flex: 1 1 12rem;
  min-width: 0;
}

.learn-definition.loading {
  color: var(--text-muted);
  font-style: italic;
}
.learn-def-source {
  font-size: 0.78rem;
  color: var(--text-secondary, #64748b);
  font-style: italic;
}

.definition-item {
  margin-bottom: 0.5rem;
}

.definition-item:last-child {
  margin-bottom: 0;
}

.definition-line {
  margin: 0;
}

.definition-example {
  margin: 0.15rem 0 0 0.5rem;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.learn-examples .definition-example {
  margin: 0.15rem 0 0 0;
  font-size: inherit;
  line-height: inherit;
  letter-spacing: inherit;
  word-spacing: inherit;
  color: inherit;
  font-weight: inherit;
  font-style: normal;
}

.learn-example-label {
  font-weight: 600;
  color: var(--text);
}

.learn-examples:empty {
  display: none;
}

.learn-spell-wrap {
  margin-top: 0.5rem;
  margin-bottom: 0.2rem;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  box-sizing: border-box;
}

.learn-spell-word {
  --part-letter-space: 0.03em;
  --part-inner-pad: 0.03em; /* half of letter space */
  text-transform: lowercase;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-family: var(--font);
  font-size: clamp(1.25rem, 6vw + 1rem, 3.5rem);
  font-weight: 400;
  color: #2E333D;
  letter-spacing: var(--part-letter-space);
}

.learn-spell-dot {
  font-size: 1em;
  color: #2E333D;
  line-height: 1;
  user-select: none;
  display: flex;
  align-items: center;
  padding: 0 0.08em;
}

.learn-spell-hyphen {
  font-family: "Arial Narrow", "Roboto Condensed", "Helvetica Neue Condensed", "Condensed", "Franklin Gothic Condensed", Arial, sans-serif;
  font-stretch: ultra-condensed;
  user-select: none;
  padding: 0;
  margin: 0;
  letter-spacing: -0.08em;
  color: #2E333D;
  display: inline;
  line-height: 1;
  vertical-align: middle;
}

.learn-spell-part {
  transition: background 0.25s ease, color 0.2s ease;
  padding: 0.02em var(--part-inner-pad) 0.07em var(--part-inner-pad);
  border-radius: 14px;
  font-weight: 400;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
  letter-spacing: var(--part-letter-space);
}

/* First part: align text to the right; left padding expanded so total row width = word pill */
.learn-spell-part:nth-of-type(1) {
  padding-left: calc(var(--part-inner-pad) + var(--extra-side-padding, 0));
  padding-right: var(--part-inner-pad);
  justify-content: flex-end;
}

/* Last part: align text to the left; right padding expanded so total row width = word pill */
.learn-spell-part:last-of-type {
  padding-left: var(--part-inner-pad);
  padding-right: calc(var(--part-inner-pad) + var(--extra-side-padding, 0));
  justify-content: flex-start;
}

/* Single part: extra padding both sides so pill width = word pill width */
.learn-spell-part:only-of-type {
  padding-left: calc(var(--part-inner-pad) + var(--extra-side-padding, 0));
  padding-right: calc(var(--part-inner-pad) + var(--extra-side-padding, 0));
}

/* Part colors: odd parts (1st, 3rd, 5th, …) soft pink, even parts (2nd, 4th, 6th, …) soft blue */
.learn-spell-part { background: #FFE7E8; color: #2E333D; }
.learn-spell-part-even { background: #E0EDF3 !important; color: #2E333D; }

/* Highlighted (active/spoken) state */
.learn-spell-part.learn-spell-highlight { background: #f48fb1; color: #2E333D; }
.learn-spell-part-even.learn-spell-highlight { background: #94a3b8 !important; color: #2E333D; }

.btn-hear-explanation {
  flex-shrink: 0;
  font-family: var(--font);
  font-size: 1.1rem;
  font-weight: 600;
  padding: 0.4rem 0.65rem;
  background: var(--secondary);
  color: white;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.2s;
}

.btn-hear-explanation:hover {
  opacity: 0.95;
  transform: scale(1.02);
}

/* Learn summary – all words and parts */
.learn-summary-card {
  max-width: 100%;
  display: flex;
  flex-direction: column;
  min-height: min(72dvh, 780px);
}

.learn-summary-title {
  margin: 0 0 0.25rem 0;
  font-size: 1.35rem;
}

.learn-summary-hint {
  margin: 0 0 1rem 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.learn-summary-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  flex: 1 1 auto;
  min-height: 0;
  align-content: start;
  max-height: none;
  overflow-y: auto;
  margin-bottom: 1rem;
  padding-right: 0.25rem;
}

.learn-summary-finish-msg {
  margin: 0 0 1rem 0;
  font-size: 1rem;
  color: var(--text-muted);
  text-align: center;
}

.learn-summary-row {
  display: grid;
  grid-template-columns: 2fr 3fr auto;
  gap: 0.5rem 1rem;
  align-items: center;
  padding: 0.6rem 0.75rem;
  background: #f8fafc;
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  font-size: 1rem;
}

.learn-summary-word-hear {
  padding: 0.35rem 0.5rem;
  font-size: 0.95rem;
  line-height: 1;
}

.learn-summary-word-hear-playing {
  animation: learn-summary-speaker-glow 2.5s ease-out;
}

@keyframes learn-summary-speaker-glow {
  0%, 100% {
    box-shadow: 0 0 0 0 transparent;
  }
  15% {
    box-shadow: 0 0 12px 3px rgba(59, 130, 246, 0.6);
  }
  50% {
    box-shadow: 0 0 14px 4px rgba(59, 130, 246, 0.5);
  }
  85% {
    box-shadow: 0 0 10px 2px rgba(59, 130, 246, 0.4);
  }
}

.learn-summary-word {
  font-weight: 700;
  color: var(--text);
  text-transform: lowercase;
}

.learn-summary-parts {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 0.16em;
  row-gap: 0.08em;
  font-weight: 600;
  color: var(--secondary);
  letter-spacing: 0.02em;
  text-transform: lowercase;
}

.learn-summary-hyphen {
  font-family: "Arial Narrow", "Roboto Condensed", "Helvetica Neue Condensed", "Condensed", "Franklin Gothic Condensed", Arial, sans-serif;
  font-stretch: ultra-condensed;
  user-select: none;
  padding: 0 0.04em;
  margin: 0;
  letter-spacing: 0;
  color: var(--text-muted, #64748b);
  font-weight: 700;
  opacity: 0.92;
  display: inline;
  line-height: 1;
  vertical-align: middle;
}

/* Learn story – AI-generated story + image at end of learning */
.learn-story-card {
  max-width: 100%;
}

.learn-story-title {
  margin: 0 0 1rem 0;
  font-size: 1.35rem;
}

.learn-story-loading {
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 1.1rem;
}

/* Quiz map: nodes locked for a future session (not scheduled today) */
.quiz-map-area-future {
  opacity: 0.38;
  filter: grayscale(0.9);
  cursor: not-allowed;
}
.quiz-map-area-future .quiz-map-area-done {
  opacity: 0;
}
.quiz-map-area-future:hover {
  transform: none;
  box-shadow: none;
}

/* Quiz map: disabled areas (no definitions/examples) */
.quiz-map-area-disabled-def,
.quiz-map-area-disabled-ex {
  opacity: 0.45;
  filter: grayscale(0.9);
  cursor: not-allowed;
}

.quiz-map-area-disabled-def .quiz-map-area-done,
.quiz-map-area-disabled-ex .quiz-map-area-done {
  opacity: 0.6;
}

/* Practice button hint text — same total height as siblings:
   padding 0.08rem top + ~2em emoji row + 0.68rem bottom = same as 0.38+2+0.38 */
#start-practice {
  padding-top: 0.08rem;
  padding-bottom: 0.68rem;
  margin-left: 1.8rem;
}

.btn-practice-label {
  display: inline-flex;
  align-items: center;
}

.btn-practice-hint {
  position: absolute;
  bottom: 0.06rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.62em;
  line-height: 1;
  font-weight: 400;
  opacity: 0.7;
  letter-spacing: 0;
  white-space: nowrap;
}

/* Remind phase (warm-up before Quest on D2/D3) */
.remind-card {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}
.remind-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.remind-progress {
  font-size: 0.85rem;
  color: var(--text-muted, #666);
  font-weight: 600;
}
.remind-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted, #555);
  text-align: center;
  margin: 0;
}
.remind-word-area {
  min-height: 6rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 0.7rem;
}
.remind-cue {
  font-size: 1rem;
  text-align: center;
  color: var(--text, #222);
  max-width: 28rem;
}
.remind-word-reveal {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
}
.remind-meaning {
  font-size: 0.95rem;
  color: var(--text-muted, #555);
  text-align: center;
  font-style: italic;
  margin: 0;
  max-width: 28rem;
}
.remind-reveal-word {
  display: block;
  text-align: center;
}
#phase-remind .learn-image-wrap {
  min-height: 80px;
  margin-bottom: 0.4rem;
}
#phase-remind .learn-image {
  max-height: 140px;
  display: block;
  margin: 0 auto;
}
#phase-remind .learn-word-spell-wrap {
  margin: 0 auto;
}
#phase-remind .learn-word,
#phase-remind .learn-spell-word,
#phase-remind .learn-spell-part {
  font-family: var(--read-font, inherit);
  font-weight: 400;
  font-size: clamp(1.25rem, 5vw + 0.75rem, 3rem);
  word-spacing: normal;
}
#phase-remind .learn-word {
  letter-spacing: calc(0.06em + var(--read-letter-spacing, 0em));
  line-height: 1.05;
  animation: none;
  transform: none;
}
.remind-done-text {
  text-align: center;
  font-weight: 600;
  font-size: 1.05rem;
  margin: 0.5rem 0 0;
}
#remind-action-area {
  gap: 0.75rem;
}
#remind-reveal-btn:focus,
#remind-next-btn:focus {
  outline: 3px solid #4f46e5;
  outline-offset: 3px;
  box-shadow: 0 0 0 6px rgba(79, 70, 229, 0.18);
}

.learn-story-content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.learn-story-image-wrap {
  text-align: center;
  margin-bottom: 0.5rem;
  min-height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.learn-story-image-wrap img {
  max-width: 100%;
  max-height: 40vh;
  width: auto;
  height: auto;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.learn-story-image-failed {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin: 0.5rem 0;
}

.learn-story-image-placeholder {
  width: min(520px, 100%);
  min-height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed #cbd5e1;
  border-radius: 12px;
  background: #f8fafc;
  color: #475569;
  font-size: 1rem;
  padding: 1rem;
  text-align: center;
}

.learn-story-text {
  font-size: 1.1rem;
  line-height: 1.6;
  color: var(--text);
  margin: 0;
  padding: 1rem;
  background: #f8fafc;
  border-radius: 12px;
  border: 2px solid #e5e7eb;
}

/* Reading-comfort overrides: font, spacing on reading text containers only.
   Not applied to T4 slot widgets, learn mini-quiz popup, breakdown widgets, or manuscript display. */
.learn-definition,
.learn-examples,
.learn-fill-row,
.learn-story-text,
.nd-preview-text,
.assess-hint-example,
.fill-word-chip,
.remind-cue,
.btn.quiz-t3-option {
  font-family: var(--read-font);
  font-weight: var(--read-font-weight);
  font-size: var(--read-font-size);
  line-height: var(--read-line-height);
  letter-spacing: var(--read-letter-spacing);
  word-spacing: var(--read-word-spacing);
  font-style: normal;
  text-align: left;
}

/* Learn word pill + syllable breakdown: ND font face + letter spacing only.
   Do not use the full reading-comfort stack (size/weight/line/word spacing) — layout
   padding and pill metrics stay on fixed design tokens. See docs/reading-comfort.md. */
#phase-learn .learn-word,
#phase-learn .learn-spell-word,
#phase-learn .learn-spell-part {
  font-family: var(--read-font);
  font-weight: 400;
  font-size: clamp(1.25rem, 6vw + 1rem, 3.5rem);
  word-spacing: normal;
}

#phase-learn .learn-image-wrap {
  margin-bottom: 0.75rem;
  padding-bottom: 0;
}

#phase-learn .learn-image {
  display: block;
  margin: 0 auto;
}

#phase-learn .learn-word-spell-wrap {
  margin: 0 auto 0.25rem auto;
  padding-top: 0;
}

#phase-learn .learn-spell-wrap {
  margin-top: 0.35rem;
  margin-bottom: 0.1rem;
}

#phase-learn .learn-meaning {
  margin-top: 0;
}

#phase-learn .learn-word {
  letter-spacing: calc(0.06em + var(--read-letter-spacing, 0em));
  line-height: 1.05;
  transform-origin: top center;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.08);
  animation: none;
  transform: none;
}

#phase-learn .learn-spell-word {
  --part-letter-space: calc(0.03em + var(--read-letter-spacing, 0em));
  line-height: 1;
}

#phase-learn .learn-spell-part {
  line-height: normal;
}

.nd-preview-box {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 0.85rem 1rem;
  background: #fef9f0;
  color: #2d3142;
  margin: 0.25rem 0 0.75rem;
}

.nd-preview-text {
  margin: 0;
}

/* Highlight current list words in story text on both "Your story" pages */
.learn-story-text .learn-story-word-highlight,
#school-story-text .learn-story-word-highlight {
  background: rgba(34, 197, 94, 0.3) !important;
  font-weight: 700 !important;
  color: #166534 !important;
  padding: 0 2px;
  border-radius: 4px;
}

.school-story-hear-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 0.75rem 0 0.25rem;
}

#school-story-hear-btn {
  width: auto;
}

.school-story-reward-message {
  font-size: 1rem;
  font-weight: 600;
  color: #1a7f37;
  margin: 0 0 1rem 0;
  line-height: 1.4;
}

.school-story-video-teaser {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin: 1rem 0 0 0;
}

/* ===== Manuscript reveal (Bronze treasure: 16-sector cursor-following reveal) ===== */
.school-story-manuscript-wrap {
  margin: 0 auto 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
}
.school-story-manuscript-wrap.hidden {
  display: none !important;
}
.school-story-manuscript-stage {
  position: relative;
  width: 540px;
  height: 360px;
  max-width: 100%;
  border-radius: 6px;
  box-shadow: 0 10px 30px rgba(45, 49, 66, 0.25);
  background: #1a1208;
  overflow: hidden;
  touch-action: none;
  cursor: crosshair;
}
.school-story-cover-image {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: brightness(0.92) saturate(1.05);
}
.school-story-paper {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(ellipse at 30% 25%, rgba(120, 80, 30, 0.18) 0%, transparent 55%),
    radial-gradient(ellipse at 75% 80%, rgba(110, 70, 25, 0.22) 0%, transparent 60%),
    radial-gradient(ellipse at 50% 50%, #f5e8c4 0%, #e8d59a 60%, #c9ad6b 100%);
  border-radius: 4px;
  box-shadow:
    inset 0 0 60px rgba(120, 80, 30, 0.35),
    inset 0 0 12px rgba(80, 50, 15, 0.25);
  overflow: hidden;
  /* simulate aged paper edges with frayed look */
  filter: contrast(1.02);
  /* sector reveal: JS updates clip-path; no transition so it snaps instantly */
  clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
  pointer-events: none;
}
.school-story-paper::before {
  /* fibrous texture overlay */
  content: "";
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(115deg,
      rgba(120, 80, 30, 0.04) 0 2px,
      transparent 2px 5px),
    repeating-linear-gradient(25deg,
      rgba(80, 50, 15, 0.03) 0 1px,
      transparent 1px 4px);
  pointer-events: none;
  opacity: 0.85;
}
.school-story-paper::after {
  /* darker stains around edges and a few spots */
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 12% 18%, rgba(90, 55, 15, 0.22) 0 18px, transparent 22px),
    radial-gradient(circle at 88% 75%, rgba(90, 55, 15, 0.18) 0 16px, transparent 22px),
    radial-gradient(circle at 70% 12%, rgba(90, 55, 15, 0.14) 0 8px, transparent 14px),
    radial-gradient(circle at 25% 82%, rgba(90, 55, 15, 0.16) 0 10px, transparent 16px);
  pointer-events: none;
}
.school-story-text-manuscript {
  position: absolute;
  inset: 0;
  padding: 36px 44px;
  margin: 0;
  font-family: 'Georgia', 'Times New Roman', serif;
  font-style: italic;
  font-size: 1.05rem;
  line-height: 1.55;
  color: #3b2a14;
  text-shadow: 0 1px 0 rgba(255, 240, 200, 0.4);
  overflow: hidden;
  text-align: justify;
  letter-spacing: 0.01em;
  z-index: 2;
  pointer-events: none;
}
.school-story-text-manuscript .learn-story-word-highlight {
  background: rgba(140, 90, 30, 0.18) !important;
  color: #5a3712 !important;
  font-weight: 700 !important;
  padding: 0 2px;
  border-radius: 3px;
}

.school-story-manuscript-hint {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
}

@media (max-width: 580px) {
  .school-story-manuscript-stage {
    width: 100%;
    height: auto;
    aspect-ratio: 3 / 2;
  }
  .school-story-text-manuscript {
    padding: 22px 26px;
    font-size: 0.95rem;
  }
}

.school-cover-card {
  max-width: 42rem;
}
.school-cover-title {
  margin: 0 0 1rem 0;
  font-size: 1.25rem;
}
.school-cover-card .school-cover-title.learn-story-title {
  margin: 0 0 0.75rem 0;
}
.school-cover-wrap {
  margin: 0 0 1rem 0;
  border-radius: 12px;
  overflow: hidden;
  background: #111;
}
.school-cover-image {
  display: block;
  width: 100%;
  max-height: 50vh;
  object-fit: contain;
}
.school-cover-message {
  margin: 0 0 1rem 0;
  font-size: 1rem;
  line-height: 1.4;
}
.school-cover-message.school-cover-reward-message {
  font-size: 1rem;
  font-weight: 600;
  color: #1a7f37;
}
.school-cover-hear-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 0.75rem 0 0.25rem;
}
#school-cover-hear-btn {
  width: auto;
}

.school-video-card {
  max-width: 42rem;
}
.school-video-title {
  margin: 0 0 1rem 0;
  font-size: 1.25rem;
}
.school-video-card .school-video-title.learn-story-title {
  margin: 0 0 0.75rem 0;
}
.school-video-message {
  margin: 0 0 1rem 0;
  font-size: 1rem;
  line-height: 1.4;
}
.school-video-message.school-video-reward-message {
  font-size: 1rem;
  font-weight: 600;
  color: #1a7f37;
}
.school-video-wrap {
  margin: 0 0 1rem 0;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}
.school-video-video {
  display: block;
  width: 100%;
  max-height: 50vh;
}

/* School list: progressive cover reveal overlay (1s after T1–T4 pass) */
.cover-reveal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  pointer-events: none;
}
.cover-reveal-overlay.hidden {
  display: none !important;
}

/* Ensure full-screen cover overlay never lingers on top of the adventure map */
body:has(.phase-quiz-map.active) #cover-reveal-overlay {
  display: none !important;
}
.cover-reveal-container {
  position: relative;
  width: min(70vw, 70vh * 16 / 9);
  height: min(70vh, 70vw * 9 / 16);
  overflow: hidden;
  background: transparent;
}
.cover-reveal-quadrant {
  position: absolute;
  width: 50%;
  height: 50%;
  background-size: 200% 200%;
  background-repeat: no-repeat;
  background-color: transparent;
}
.cover-reveal-quadrant.hidden {
  display: none;
  background-color: transparent;
}
/* Overlap by 1px to avoid vertical/horizontal seam from sub-pixel cropping */
.cover-reveal-tl { top: 0; left: 0; background-position: 0 0; }
.cover-reveal-tr { top: 0; left: 50%; width: calc(50% + 1px); background-position: 100% 0; margin-left: -1px; }
.cover-reveal-bl { top: 50%; left: 0; height: calc(50% + 1px); background-position: 0 100%; margin-top: -1px; }
.cover-reveal-br { top: 50%; left: 50%; width: calc(50% + 1px); height: calc(50% + 1px); background-position: 100% 100%; margin-left: -1px; margin-top: -1px; }

.learn-story-error {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0.5rem 0;
}

/* Small challenge image in top-right of test cards (T1–T5) */
.challenge-image-wrap {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 6rem;
  height: 6rem;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}
.challenge-image-wrap.hidden {
  display: none;
}
.challenge-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Learn fill – sentences with blanks, drag words */
.learn-fill-card {
  max-width: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

/* Quest T1–T5: Word X of Y bar as on Learn; stop before land image (top-right). */
.quest-test-progress-row {
  width: 100%;
  box-sizing: border-box;
  margin-top: 0.15rem;
}
.learn-fill-card:not(:has(.challenge-image-wrap.hidden)) .quest-test-progress-row,
.quiz-t3-card:not(:has(.challenge-image-wrap.hidden)) .quest-test-progress-row,
.assess-card:not(:has(.challenge-image-wrap.hidden)) .quest-test-progress-row {
  padding-right: calc(6rem + 0.85rem);
}

.learn-fill-title {
  margin: 0 0 0.25rem 0;
  font-size: 1.35rem;
}

.learn-fill-page-label {
  margin: 0 0 0.35rem 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

#learn-fill-next-btn.fill-next-awaiting-answer:disabled,
#quiz-t3-next-btn.fill-next-awaiting-answer:disabled {
  cursor: not-allowed;
}

.learn-fill-hint {
  margin: 0 0 1rem 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.learn-fill-sentences {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
  max-height: 40vh;
  overflow-y: auto;
}

.learn-fill-row {
  padding: 0.6rem 0.75rem;
  background: #f8fafc;
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  min-height: 2.5rem;
}

.fill-blank {
  display: inline-block;
  min-width: 4em;
  padding: 0.15em 0.4em;
  margin: 0 0.15em;
  border: 2px dashed #94a3b8;
  border-radius: 6px;
  background: #fff;
  color: var(--text-muted);
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.fill-blank.fill-correct {
  border-style: solid;
  border-color: var(--success);
  background: rgba(74, 222, 128, 0.2);
  color: var(--text);
}

.fill-blank.fill-incorrect {
  border-style: solid;
  border-color: var(--wrong);
  background: rgba(248, 113, 113, 0.2);
  color: var(--text);
}

/* T1 correct drop: ~1s star burst */
.t1-celebration-wrap {
  position: fixed;
  width: 0;
  height: 0;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 100;
}

.t1-celebration-star {
  position: absolute;
  left: 0;
  top: 0;
  font-size: 2rem;
  color: #fbbf24;
  text-shadow: 0 0 10px rgba(251, 191, 36, 0.9);
  opacity: 1;
  animation: t1-celebration-burst 2s ease-out forwards;
}

@keyframes t1-celebration-burst {
  0% {
    transform: translate(0, 0) scale(0.8);
    opacity: 1;
  }
  100% {
    transform: translate(var(--burst-dx, 0), var(--burst-dy, 0)) scale(1.3);
    opacity: 0;
  }
}

/* ===== Point pop-up (01 §5.2) ===== */
.point-pop {
  position: fixed;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 110;
  font-weight: 800;
  font-family: var(--font);
  white-space: nowrap;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  will-change: transform, opacity;
}
/* Correct: green, floats up. Size cue conveys magnitude (small/medium/large). */
.point-pop-correct { color: #16a34a; }
.point-pop-already-counted {
  font-size: 1.35rem;
  white-space: nowrap;
}
.point-pop-correct.pop-large.point-pop-already-counted { font-size: 1.65rem; }
.point-pop-correct.pop-medium.point-pop-already-counted { font-size: 1.35rem; }
.point-pop-correct.pop-small.point-pop-already-counted { font-size: 1.1rem; }
.point-pop-correct.pop-large { font-size: 2.4rem; }
.point-pop-correct.pop-medium { font-size: 1.8rem; }
.point-pop-correct.pop-small { font-size: 1.3rem; }
/* Wrong (extra_support / standard): warm orange, NOT red — validates effort.
   Same font size as the correct first-attempt pop (.pop-large) so the two
   feedback states feel equally weighted (per spec: validates effort without
   minimising it). */
.point-pop-tryagain {
  color: #f97316;
  font-size: 2.4rem;
}
/* Wrong (challenge): quiet neutral marker, minimal motion. */
.point-pop-quiet {
  color: var(--text-muted, #6b7280);
  font-size: 1.6rem;
  text-shadow: none;
}
.point-pop-float-strong { animation: point-pop-float-strong 3.2s ease-out forwards; }
.point-pop-float-soft { animation: point-pop-float-soft 1.4s ease-out forwards; }
.point-pop-float-gentle { animation: point-pop-float-gentle 1.5s ease-in-out forwards; }
.point-pop-quiet-fade { animation: point-pop-quiet-fade 1s ease-out forwards; }
/* Try-again ("+0 — let's try again!") is a sentence — it needs reading time.
   Two stages:
   1. Rise FAST (0%→18%) from the anchor up well above it so the red "correct
      answer" word underneath is not covered while the user is reading the pop.
   2. Dwell HIGH (18%→78%) at the reading height with full opacity, then fade.
   Overrides float-soft when both classes are paired
   (.point-pop-tryagain ships with .point-pop-float-soft from the helper). */
.point-pop-tryagain.point-pop-float-soft {
  animation: point-pop-float-tryagain 3.2s ease-out forwards;
}
@keyframes point-pop-float-tryagain {
  0%   { transform: translate(-50%, -50%) scale(0.7); opacity: 0; }
  18%  { transform: translate(-50%, -200%) scale(1.05); opacity: 1; }
  78%  { transform: translate(-50%, -220%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -250%) scale(1); opacity: 0; }
}

@keyframes point-pop-float-strong {
  0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
  18% { transform: translate(-50%, -60%) scale(1.15); opacity: 1; }
  70% { opacity: 1; }
  100% { transform: translate(-50%, -250%) scale(1); opacity: 0; }
}
@keyframes point-pop-float-soft {
  0% { transform: translate(-50%, -50%) scale(0.7); opacity: 0; }
  22% { transform: translate(-50%, -60%) scale(1.05); opacity: 1; }
  70% { opacity: 1; }
  100% { transform: translate(-50%, -130%) scale(1); opacity: 0; }
}
@keyframes point-pop-float-gentle {
  0% { transform: translate(-50%, -50%) scale(0.9); opacity: 0; }
  35% { opacity: 1; }
  75% { opacity: 1; }
  100% { transform: translate(-50%, -115%) scale(1); opacity: 0; }
}
@keyframes point-pop-quiet-fade {
  0% { transform: translate(-50%, -50%) scale(0.9); opacity: 0; }
  30% { opacity: 0.85; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 0; }
}

.learn-fill-words-label {
  margin: 0 0 0.35rem 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.learn-fill-word-bank {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.fill-word-chip {
  display: inline-block;
  padding: 0.4rem 0.75rem;
  background: #f1f5f9;
  color: #334155;
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
}

.fill-word-chip:active {
  cursor: pointer;
}

.progress-dots {
  display: none;
}

.progress-dots .dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #e5e7eb;
  transition: background 0.2s;
}

.progress-dots .dot.done {
  background: var(--secondary);
}

.progress-dots .dot.current {
  background: var(--primary);
  transform: scale(1.2);
}

/* Assessment phase */
.assess-prompt {
  font-size: 1.2rem;
  font-weight: 600;
  text-align: center;
  margin: 1rem 0;
  color: var(--text);
}

.btn-hear {
  font-family: var(--font);
  font-size: 1rem;
  padding: 0.4rem 0.75rem;
  margin-left: 0.5rem;
  background: var(--secondary);
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
}

.btn-hear:hover {
  opacity: 0.9;
}

.assess-hint {
  font-size: 0.95rem;
  color: var(--text-muted);
  text-align: center;
  margin: 0 0 0.5rem 0;
}

.assess-hint-main {
  display: block;
}

.assess-hint-example {
  display: block;
  margin-top: 0.35rem;
  font-weight: var(--read-font-weight);
  font-style: normal;
  color: var(--text);
}

.assess-hint-main + .assess-hint-example {
  margin-top: 0.45rem;
}

.assess-card--t5 .assess-hint {
  margin-bottom: 1rem;
}

.assess-card--t5 .assess-hint-main {
  text-align: left;
}

.assess-card--t5 .assess-hint-example {
  text-align: center;
}

.assess-card--t5 .assess-hint-main + .assess-hint-example {
  margin-top: 0.9rem;
}

.assess-card--t5 .assess-letter-hint {
  margin: 0.5rem 0 1rem;
}

.assess-card--t5 .assess-letter-hint + .assess-hint {
  margin-top: 0.5rem;
}

.assess-input {
  margin-bottom: 0.5rem;
  justify-content: center;
}

.assess-card--t4-slots .assess-hint {
  margin-bottom: 0.75rem;
  text-align: left;
}

.assess-card--t4-slots .assess-hint-main {
  text-align: left;
}

.assess-card--t4-slots .assess-hint-example {
  text-align: center;
}

.assess-card--t4-slots .assess-hint-main + .assess-hint-example {
  margin-top: 0.5rem;
}

.assess-card--t4-slots .assess-input {
  margin-top: 2.5rem;
  margin-bottom: 0;
}

.assess-card--t4-slots .assess-slot-wrap {
  margin-bottom: 0.5rem;
  position: relative;
}

.assess-card--t4-slots .assess-slot-hint:not(.is-visible) {
  min-height: 0;
  margin: 0;
  line-height: 0;
  overflow: hidden;
}

.assess-card--t4-slots .assess-top-nav {
  flex-shrink: 0;
}

.assess-card--t4-slots .btn-quiz-map-back:focus,
.assess-card--t4-slots .btn-quiz-map-back:focus-visible {
  outline: none !important;
  box-shadow: var(--shadow) !important;
  transform: none !important;
  position: static !important;
  z-index: auto !important;
}

.assess-card--t4-slots .assess-actions {
  flex-shrink: 0;
  margin-top: 0 !important;
  min-height: 3.5rem;
  height: 3.5rem;
  max-height: 3.5rem;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  contain: layout;
}

/* T4 action row: no hover/active scale — Alt+Tab clears :hover while the mouse stays over
   the row (side-by-side), which used to shrink buttons and jump the layout. */
.assess-card--t4-slots .assess-actions .btn,
.assess-card--t4-slots .assess-actions #home-btn,
.assess-card--t4-slots .assess-actions .btn-home {
  position: static;
  z-index: auto;
  transform: none;
  transition: background 0.2s, box-shadow 0.2s, opacity 0.2s;
}

.assess-card--t4-slots .assess-actions .btn:hover:not(:disabled),
.assess-card--t4-slots .assess-actions .btn:active:not(:disabled),
.assess-card--t4-slots .assess-actions .btn-big:hover:not(:disabled),
.assess-card--t4-slots .assess-actions .btn-big:active:not(:disabled),
.assess-card--t4-slots .assess-actions #home-btn:hover,
.assess-card--t4-slots .assess-actions .btn-home:hover {
  transform: none;
}

.assess-card--t4-slots .assess-actions .btn:focus,
.assess-card--t4-slots .assess-actions .btn:focus-visible,
.assess-card--t4-slots .assess-actions #home-btn:focus,
.assess-card--t4-slots .assess-actions #home-btn:focus-visible,
.assess-card--t4-slots .assess-actions .btn-home:focus,
.assess-card--t4-slots .assess-actions .btn-home:focus-visible {
  outline: none !important;
  box-shadow: none !important;
  position: static !important;
  z-index: auto !important;
  transform: none !important;
}

.assess-card--t4-slots .assess-slot-delete {
  position: static;
  z-index: auto;
}

.assess-card--t4-slots .assess-slot-delete:focus,
.assess-card--t4-slots .assess-slot-delete:focus-visible {
  outline: none !important;
  box-shadow: none !important;
  position: static !important;
  z-index: auto !important;
}

.assess-card--t4-slots {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.assess-card--t4-slots .assess-t4-challenge {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  min-height: 11.5rem;
}

.assess-card--t4-slots .assess-actions .btn.assess-t4-action-focus,
.assess-card--t4-slots .assess-actions #home-btn.assess-t4-action-focus,
.assess-card--t4-slots .assess-actions .btn-home.assess-t4-action-focus {
  outline: none !important;
}

.assess-card--t4-slots .assess-actions #home-btn.assess-t4-action-focus,
.assess-card--t4-slots .assess-actions .btn-home.assess-t4-action-focus {
  box-shadow: var(--shadow), inset 0 0 0 2px var(--focus-ring) !important;
}

.assess-card--t4-slots .assess-actions .btn-secondary.assess-t4-action-focus,
.assess-card--t4-slots .assess-actions .assess-need-help-btn.assess-t4-action-focus {
  box-shadow: inset 0 0 0 2px var(--focus-ring) !important;
}

.assess-card--t4-slots .assess-actions .btn-big.assess-t4-action-focus:not(#assess-check),
.assess-card--t4-slots .assess-actions #assess-check.assess-t4-action-focus {
  box-shadow: inset 0 0 0 2px var(--focus-ring) !important;
}

/* Check Answer: inset ring for roving highlight and programmatic :focus (row is not clipped). */
.assess-card--t4-slots .assess-actions #assess-check:focus,
.assess-card--t4-slots .assess-actions #assess-check:focus-visible {
  outline: none !important;
  box-shadow: inset 0 0 0 2px var(--focus-ring, #4f46e5) !important;
  transform: none !important;
  position: relative !important;
  z-index: 2 !important;
}

/* Alt+Tab away: no roving ring repaint while another app owns focus. */
.assess-card--t4-slots.assess-t4-window-blurred .assess-t4-action-focus {
  outline: none !important;
  box-shadow: none !important;
}


.assess-input input {
  font-size: 1.35rem;
  text-align: center;
}

.assess-input input.hidden {
  display: none;
}

.assess-slot-wrap {
  flex: 0 1 auto;
  width: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 3.6rem;
}

.assess-slot-wrap.hidden {
  display: none;
}

.assess-slot-wrap--locked {
  pointer-events: none;
  opacity: 0.85;
}

.assess-slots-row {
  display: inline-flex;
  align-items: flex-end;
  justify-content: center;
  gap: 0.35rem;
  max-width: 100%;
}

.assess-slots {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: center;
  gap: 0.2rem;
  text-transform: lowercase;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  flex: 0 1 auto;
  max-width: 100%;
}

.assess-slots .learn-mini-quiz-char,
.assess-slots .learn-mini-quiz-slot {
  font-size: 1.35rem;
  min-width: 1.2rem;
  height: 1.85rem;
  min-height: 1.85rem;
  max-height: 1.85rem;
}

.assess-slot-delete {
  flex-shrink: 0;
  align-self: flex-end;
  border: none;
  background: #e5e7eb;
  border-radius: 999px;
  padding: 0.3rem 0.65rem;
  cursor: pointer;
  font-size: 1.1rem;
}

.assess-slot-delete:hover {
  background: #d1d5db;
}

.assess-slot-input {
  position: absolute;
  left: 0;
  top: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.assess-card--t4-slots .assess-slot-input:focus,
.assess-card--t4-slots .assess-slot-input:focus-visible {
  outline: none !important;
  box-shadow: none !important;
  /* Global :focus-visible sets position:relative — reflows slot row and drops action buttons. */
  position: absolute !important;
  left: 0 !important;
  top: 0 !important;
  z-index: auto !important;
  transform: none !important;
}

.assess-card--t4-slots.assess-t4-window-blurred::before {
  animation-play-state: paused;
}

.assess-slot-hint {
  margin: 0.35rem 0 0;
  min-height: 1.5rem;
  line-height: 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  text-align: center;
  color: #e8a0b4;
  opacity: 0;
  transition: opacity 0.12s ease-out;
}

.assess-slot-hint.is-visible {
  opacity: 1;
}

.assess-feedback {
  min-height: 1.5rem;
  font-size: 1.1rem;
  font-weight: 600;
  text-align: center;
  margin: 0.5rem 0 0 0;
}

.assess-card--t4-slots .assess-feedback:empty {
  min-height: 0;
  margin: 0;
  padding: 0;
}

/* After Check: keep feedback area from collapsing the challenge block (slots stay locked above). */
.assess-card--t4-slots .assess-slot-wrap--locked + .assess-feedback {
  min-height: 1.5rem;
  margin: 0.5rem 0 0 0;
}

.assess-feedback.incorrect {
  text-align: center;
  color: var(--wrong);
  animation: shake 0.5s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
}

.assess-incorrect-intro {
  text-align: center;
  font-weight: 600;
  line-height: 1.35;
  margin: 0;
  padding: 0 0.25rem;
}

.assess-incorrect-word-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.65rem 0.85rem;
  width: 100%;
}

.assess-feedback-ok-btn {
  flex-shrink: 0;
  font-weight: 700;
  min-width: 4rem;
}

.assess-feedback.correct {
  color: var(--success);
  font-size: 1.3rem;
  animation: celebrate 0.6s ease;
}

.assess-correct-spelling {
  display: inline-block;
  background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
  color: #065f46;
  font-size: clamp(1.25rem, 6vw + 1rem, 3.5rem);
  font-weight: 400;
  letter-spacing: 0.06em;
  padding: 0.15em 0.5em 0.15em 0.5em;
  border-radius: 8px;
  margin: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Floating virtual keyboard — top-right badge, mirrors mode-switch-wrap on the left */
/* Above learn mini-quiz overlay (10000) so ⌨️ stays usable while “Spell the missing letters” is open */
.floating-keyboard-fab-wrap {
  position: fixed;
  top: 0.5rem;
  right: max(0.5rem, env(safe-area-inset-right));
  z-index: 10050;
}

.floating-keyboard-fab {
  font-family: var(--font);
  font-size: 1.08rem;
  font-weight: 500;
  color: var(--text-secondary, #64748b);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.22rem 0.45rem;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
  background: #f1f5f9;
  cursor: pointer;
  margin: 0;
  line-height: 1.25;
  min-width: 12rem;
  box-sizing: border-box;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(45, 49, 66, 0.12);
  transition:
    min-width 0.45s ease-in-out,
    gap 0.45s ease-in-out,
    padding 0.45s ease-in-out,
    background 0.2s ease,
    color 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.2s ease;
}

.kbd-fab-emoji {
  font-size: 1.75rem;
  line-height: 1;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  margin-top: -0.2em;
  margin-bottom: -0.2em;
}

.kbd-fab-text {
  font-size: 1.08rem;
  font-weight: inherit;
  line-height: 1.25;
  font-family: var(--font);
  transition: max-width 0.45s ease-in-out, opacity 0.4s ease-in-out, margin 0.45s ease-in-out;
}

.floating-keyboard-fab:hover {
  background: #e2e8f0;
  color: var(--text, #1e293b);
}

.floating-keyboard-fab:active {
  transform: scale(0.97);
}

/* Keyboard hidden */
.floating-keyboard-fab[aria-pressed=”false”] {
  background: #f1f5f9;
  color: var(--text-secondary, #64748b);
}

/* Keyboard visible — teal fill */
.floating-keyboard-fab[aria-pressed=”true”] {
  background: linear-gradient(160deg, rgb(92, 184, 178) 0%, rgb(62, 158, 152) 100%);
  color: #fff;
  border-color: transparent;
  box-shadow:
    inset 0 2px 5px rgba(0, 0, 0, 0.12),
    0 2px 8px rgba(45, 49, 66, 0.2);
}

.floating-keyboard-fab[aria-pressed=”true”]:hover {
  background: linear-gradient(160deg, rgb(102, 194, 188) 0%, rgb(72, 168, 162) 100%);
  box-shadow:
    inset 0 2px 5px rgba(0, 0, 0, 0.1),
    0 3px 12px rgba(45, 49, 66, 0.25);
}

/* Compact: icon only, expand on hover (all pages except front page) */
.floating-keyboard-fab.kbd-fab-compact {
  min-width: 0;
  width: auto;
  gap: 0;
  padding: 0.22rem 0.4rem;
  justify-content: center;
}

.floating-keyboard-fab.kbd-fab-compact .kbd-fab-text {
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  margin: 0;
  padding: 0;
  pointer-events: none;
}

.floating-keyboard-fab.kbd-fab-compact:hover,
.floating-keyboard-fab.kbd-fab-compact:focus-visible {
  min-width: 12rem;
  gap: 0.35rem;
  padding: 0.22rem 0.45rem;
  justify-content: center;
}

.floating-keyboard-fab.kbd-fab-compact:hover .kbd-fab-text,
.floating-keyboard-fab.kbd-fab-compact:focus-visible .kbd-fab-text {
  max-width: 12rem;
  opacity: 1;
  pointer-events: auto;
}

/* "Keyboard is open — click to hide" badge: small × in the top-right corner of the button */
.floating-keyboard-fab[aria-pressed="true"]::after {
  content: "×";
  position: absolute;
  top: 3px;
  right: 4px;
  font-size: 0.7rem;
  font-weight: 900;
  line-height: 14px;
  width: 14px;
  height: 14px;
  text-align: center;
  background: rgba(255, 255, 255, 0.88);
  color: #1e293b;
  border-radius: 50%;
  pointer-events: none;
}

.floating-keyboard-panel {
  position: fixed;
  left: 50%;
  /* Child mode default: a few px above the viewport bottom edge */
  bottom: max(8px, env(safe-area-inset-bottom, 0px));
  z-index: 10049;
  max-width: min(100vw - 24px, 720px);
  width: calc(100vw - 24px);
  padding: 10px 12px 12px;
  border-radius: var(--radius);
  /* ~70% transparent (30% opaque) */
  background: rgba(254, 249, 240, 0.3);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: 0 4px 24px rgba(45, 49, 66, 0.06);
  border: 1px solid rgba(203, 213, 225, 0.35);
  /* Pass clicks/hover through gaps so the cursor matches controls underneath (I‑beam, not‑allowed, etc.) */
  pointer-events: none;
  transform: translate(calc(-50% + var(--vk-drag-x, 0px)), var(--vk-drag-y, 0px));
}

/* First learn mini-quiz open this load: sit flush on the viewport bottom (respect safe area). */
.floating-keyboard-panel.floating-keyboard-panel--dock-bottom-flush {
  bottom: env(safe-area-inset-bottom, 0px);
}

.floating-keyboard-panel.floating-keyboard-panel--dragging {
  box-shadow: 0 6px 28px rgba(45, 49, 66, 0.1);
}

.floating-keyboard-drag-handle,
.learn-mini-quiz-drag-handle {
  height: 14px;
  margin: -4px 0 8px;
  border-radius: 6px;
  background: rgba(203, 213, 225, 0.3);
  cursor: grab;
  pointer-events: auto;
  touch-action: none;
}
.learn-mini-quiz-drag-handle {
  /* Stop short of the top-right close button (2.75rem + inset). */
  margin: 0 3.5rem 0.75rem 0;
  background: rgba(203, 213, 225, 0.55);
}

.floating-keyboard-mount-inner {
  pointer-events: none;
}

.floating-keyboard-panel.floating-keyboard-panel--dragging .floating-keyboard-drag-handle,
.learn-mini-quiz-box.learn-mini-quiz-box--dragging .learn-mini-quiz-drag-handle {
  cursor: grabbing;
}

.floating-keyboard-panel .virtual-keyboard-key {
  pointer-events: auto;
  touch-action: manipulation;
  /* 👆 as cursor image (fallback: pointer) */
  cursor: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Ctext x='16' y='22' font-size='20' text-anchor='middle'%3E%F0%9F%91%86%3C/text%3E%3C/svg%3E") 16 10, pointer;
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(203, 213, 225, 0.38);
  box-shadow: 0 1px 2px rgba(45, 49, 66, 0.06);
  color: var(--text);
  text-shadow: 0 0 4px rgba(255, 255, 255, 0.95), 0 1px 3px rgba(45, 49, 66, 0.35);
}

.floating-keyboard-panel .virtual-keyboard-key:hover {
  background: var(--card);
  border-color: rgba(92, 184, 178, 0.55);
  box-shadow: 0 2px 10px rgba(45, 49, 66, 0.12);
}

.floating-keyboard-panel .floating-keyboard-mount-inner .virtual-keyboard-key.virtual-keyboard-shift-active:hover {
  background: rgb(92, 184, 178);
  border-color: var(--secondary);
  box-shadow: inset 0 2px 8px rgba(45, 49, 66, 0.2);
}

.floating-keyboard-panel .virtual-keyboard-key:active {
  cursor: grabbing;
  background: var(--card);
  border-color: rgba(92, 184, 178, 0.65);
}

.floating-keyboard-panel .floating-keyboard-mount-inner .virtual-keyboard-key.virtual-keyboard-shift-active:active {
  background: rgb(78, 168, 162);
  border-color: var(--secondary);
}

.floating-keyboard-panel .floating-keyboard-mount-inner {
  width: 100%;
  box-sizing: border-box;
  /* Row 1 column count set in JS so rows 2–3 keys match row 1 cell width */
  --floating-vk-gap: 0.88rem;
  --floating-vk-cols: 13;
  --floating-vk-key-w: calc((100% - (var(--floating-vk-cols) - 1) * var(--floating-vk-gap)) / var(--floating-vk-cols));
}

.floating-keyboard-panel .floating-keyboard-mount-inner .virtual-keyboard-row:not(.virtual-keyboard-row-bottom) {
  width: 100%;
  box-sizing: border-box;
  gap: var(--floating-vk-gap);
  justify-content: center;
  flex-wrap: nowrap;
}

/* Row 3 (⇧ + letters + punctuation): left-align so ⇧ sits under row-1 col 1, letters match row-1 columns (e.g. Z under W on QWERTY). */
.floating-keyboard-panel .floating-keyboard-mount-inner .virtual-keyboard-row.floating-keyboard-row--align-row1 {
  justify-content: flex-start;
}

.floating-keyboard-panel .floating-keyboard-mount-inner .virtual-keyboard-key {
  min-height: 2.65rem;
  padding: 0 0.06rem;
  font-size: 1rem;
}

.floating-keyboard-panel .floating-keyboard-mount-inner .virtual-keyboard-row:not(.virtual-keyboard-row-bottom) .virtual-keyboard-key {
  flex: 0 0 var(--floating-vk-key-w);
  min-width: 0;
  max-width: var(--floating-vk-key-w);
}

.floating-keyboard-panel .floating-keyboard-mount-inner .virtual-keyboard-key.virtual-keyboard-key-empty {
  pointer-events: none;
  cursor: default;
  visibility: visible;
  opacity: 0.35;
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(203, 213, 225, 0.2);
  box-shadow: none;
  color: transparent;
  text-shadow: none;
}

.floating-keyboard-panel .floating-keyboard-mount-inner .virtual-keyboard-key.virtual-keyboard-key-empty:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(203, 213, 225, 0.2);
}

/* Quest matrix: keyboard letter highlights for letters in the target word (T4/T5). */
.floating-keyboard-panel .virtual-keyboard-key.virtual-keyboard-key--word-letter-bright {
  background: rgba(255, 236, 140, 0.92);
  border-color: rgba(234, 179, 8, 0.75);
  box-shadow: 0 0 0 2px rgba(250, 204, 21, 0.45), 0 2px 8px rgba(45, 49, 66, 0.12);
  color: #422006;
  font-weight: 700;
}

.floating-keyboard-panel .virtual-keyboard-key.virtual-keyboard-key--word-letter-soft {
  background: rgba(255, 248, 210, 0.72);
  border-color: rgba(234, 179, 8, 0.42);
  box-shadow: 0 1px 4px rgba(45, 49, 66, 0.08);
  color: var(--text);
  font-weight: 600;
}

.floating-keyboard-panel .virtual-keyboard-key.virtual-keyboard-key--word-letter-faint {
  background: rgba(255, 255, 255, 0.48);
  border-color: rgba(250, 204, 21, 0.28);
  box-shadow: none;
  color: var(--text);
}

.floating-keyboard-panel .virtual-keyboard-key.virtual-keyboard-key--word-letter-bright:hover,
.floating-keyboard-panel .virtual-keyboard-key.virtual-keyboard-key--word-letter-soft:hover,
.floating-keyboard-panel .virtual-keyboard-key.virtual-keyboard-key--word-letter-faint:hover {
  border-color: rgba(234, 179, 8, 0.65);
}

.floating-keyboard-panel .floating-keyboard-mount-inner .virtual-keyboard-key.virtual-keyboard-shift {
  flex: 0 0 var(--floating-vk-key-w);
  max-width: var(--floating-vk-key-w);
  min-width: 0;
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  cursor: pointer;
}

.floating-keyboard-panel .floating-keyboard-mount-inner .virtual-keyboard-key.virtual-keyboard-shift-active {
  background: rgba(92, 184, 178, 0.42);
  border-color: var(--secondary);
  box-shadow: inset 0 2px 8px rgba(45, 49, 66, 0.22);
}

.floating-keyboard-panel .floating-keyboard-mount-inner .virtual-keyboard-key.virtual-keyboard-shift:active {
  cursor: pointer;
}

.floating-keyboard-panel .floating-keyboard-mount-inner .virtual-keyboard-row-bottom {
  width: 100%;
  gap: var(--floating-vk-gap);
}

.floating-keyboard-panel .floating-keyboard-mount-inner .virtual-keyboard-row-bottom .virtual-keyboard-space {
  flex: 5 1 0;
  max-width: none;
}

.floating-keyboard-panel .floating-keyboard-mount-inner .virtual-keyboard-row-bottom .virtual-keyboard-backspace {
  flex: 1.45 1 0;
  min-width: 3rem;
}

.virtual-keyboard-row {
  display: flex;
  justify-content: center;
  gap: 0.25rem;
  margin-bottom: 0.35rem;
}

.virtual-keyboard-row:last-child {
  margin-bottom: 0;
}

.virtual-keyboard-key {
  font-family: var(--font);
  font-size: 1rem;
  min-width: 2rem;
  height: 2.5rem;
  padding: 0 0.35rem;
  border: 2px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  transition: background 0.15s, border-color 0.15s;
}

.virtual-keyboard-key:hover {
  background: #e0f2fe;
  border-color: var(--secondary);
}

.virtual-keyboard-key:active {
  background: #bae6fd;
}

.virtual-keyboard-space {
  flex: 1;
  max-width: 10rem;
  min-width: 4rem;
}

.virtual-keyboard-backspace {
  min-width: 3rem;
}

@keyframes celebrate {
  0% { transform: scale(0.8) rotate(-5deg); }
  50% { transform: scale(1.2) rotate(5deg); }
  100% { transform: scale(1) rotate(0deg); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-10px); }
  75% { transform: translateX(10px); }
}

/* Results */
.results-card {
  position: relative;
  overflow: hidden;
}
.results-card h2 {
  text-align: center;
  margin-bottom: 0.5rem;
}

.score-circle {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--secondary), var(--accent), #ffc857);
  margin: 1.5rem auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 12px 32px rgba(92, 184, 178, 0.4), 0 0 0 8px rgba(255, 200, 87, 0.2);
  animation: scoreSpin 0.8s ease;
  position: relative;
}

.score-circle::before {
  content: '⭐';
  position: absolute;
  top: -20px;
  right: -20px;
  font-size: 2rem;
  animation: starFloat 2s ease-in-out infinite;
}

.score-circle::after {
  content: '✨';
  position: absolute;
  bottom: -20px;
  left: -20px;
  font-size: 1.5rem;
  animation: starFloat 2s ease-in-out infinite 0.5s;
}

@keyframes scoreSpin {
  0% { transform: scale(0) rotate(0deg); }
  50% { transform: scale(1.1) rotate(180deg); }
  100% { transform: scale(1) rotate(360deg); }
}

@keyframes starFloat {
  0% { 
    transform: translateY(0) translateX(0) rotate(0deg) scale(1);
    opacity: 1;
  }
  100% { 
    transform: translateY(-100px) translateX(20px) rotate(360deg) scale(0);
    opacity: 0;
  }
}

#score-text {
  font-size: 3rem;
  font-weight: 700;
  line-height: 1;
}

.score-of {
  font-size: 1.1rem;
  opacity: 0.95;
}

.results-success-image-wrap {
  position: relative;
  margin: 1rem auto;
  padding: 0.5rem;
  width: fit-content;
  border-radius: 16px;
  background: #f8fafc;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.results-success-video-overlay {
  position: absolute;
  /* inset/position + size are set in JS to match #results-success-image (wrap has padding; image is inset) */
  inset: 0;
  padding: 0;
  box-sizing: border-box;
  border-radius: 12px;
  overflow: hidden;
  z-index: 1;
  opacity: 0;
  pointer-events: none;
  transform: scale(1);
  transform-origin: center center;
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: center;
}
.results-success-video-overlay-visible {
  opacity: 1;
  pointer-events: auto;
}
.results-success-video-overlay video {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 12px;
}

/* End-of-play shrink into the still (transform driven from JS after transition reset) */
.results-success-video-overlay.results-success-video-shrinking {
  pointer-events: none;
}

.results-success-image-wrap.hidden {
  display: none;
}

.results-success-image {
  display: block;
  width: auto;
  height: auto;
  border-radius: 12px;
  vertical-align: middle;
}

.results-success-image.results-success-image-replay-available {
  cursor: pointer;
}

.results-message {
  text-align: center;
  font-size: 1.15rem;
  color: var(--text);
  margin: 0 0 1rem 0;
}

.results-cover-hint {
  display: block;
  font-size: 0.95rem;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 0.5rem;
}

.results-cover-progress-bar {
  display: block;
  height: 0.5rem;
  margin-top: 0.6rem;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
}

.results-cover-progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--secondary) 0%, var(--accent) 50%, var(--primary) 100%);
  transition: width 0.4s ease;
}

.results-breakdown {
  background: #f3f4f6;
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

.results-breakdown:empty {
  display: none;
}

.results-breakdown .item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0;
}

.results-breakdown .item.correct {
  color: var(--success);
}

.results-breakdown .item.incorrect {
  color: var(--wrong);
}

.results-not-attempted {
  font-size: 0.9em;
  color: var(--text-muted);
  font-style: italic;
}

.results-breakdown .item span:first-child {
  font-weight: 600;
  min-width: 1.5rem;
}

.results-breakdown .item.incorrect .results-retry-inline {
  color: var(--text);
  font-style: italic;
  font-weight: normal;
}

/* ========== Responsive: fit viewport, portrait/landscape, mobile/tablet/PC ========== */

/* Small phones (portrait) */
@media (max-width: 380px) {
  body {
    padding: max(0.5rem, env(safe-area-inset-top)) max(0.5rem, env(safe-area-inset-right)) max(0.5rem, env(safe-area-inset-bottom)) max(0.5rem, env(safe-area-inset-left));
  }
  .header h1 {
    font-size: 1.45rem;
  }
  .subtitle {
    font-size: 0.95rem;
  }
  .header {
    margin-bottom: 0.5rem;
  }
}

/* Short viewport (landscape phone or small height): compact header */
@media (max-height: 500px) {
  .header h1 {
    font-size: 1.3rem;
  }
  .subtitle {
    display: none;
  }
  .header {
    margin-bottom: 0.5rem;
  }
  .card {
    padding: 0.7rem 0.9rem;
  }
  .quiz-map-container {
    padding: 0.5rem 0.9rem;
  }
}

/* Tablet: use more width */
@media (min-width: 600px) {
  .app-center-wrap {
    flex: 0 0 640px;
  }
  .app {
    max-width: 640px;
  }
  body {
    --page-pad-x: 1rem;
    --page-pad-bottom: 1rem;
  }
  body.is-frontpage {
    --page-pad-top: 1rem;
  }
}

/* Desktop / large tablet */
@media (min-width: 900px) {
  .app-center-wrap {
    flex: 0 0 720px;
  }
  .app {
    max-width: 720px;
  }
  body {
    --page-pad-x: 1.5rem;
    --page-pad-bottom: 1.5rem;
  }
  body.is-frontpage {
    --page-pad-top: 1.5rem;
  }
}

/* Learn / Quest / Play / Practice / exercise phases: wider 860px pane (overrides responsive defaults above) */
body.exercise-phase-active .app-center-wrap,
body:has(#phase-play.active) .app-center-wrap,
body:has(#phase-puzzles.active) .app-center-wrap {
  flex: 0 0 min(860px, 100%);
  max-width: 100%;
}
body.exercise-phase-active .app,
body:has(#phase-play.active) .app,
body:has(#phase-puzzles.active) .app {
  flex: 1 1 0;
  min-height: 0;
  max-width: 860px;
}

/* ============================================================
   T4 – Letter hint boxes
   ============================================================ */

.assess-letter-hint {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin: 0.25rem 0 0.5rem;
}

.assess-letter-hint-label {
  font-style: italic;
  color: var(--text-muted);
  margin-right: 0.35rem;
  line-height: 1.3;
}

.assess-letter-hint.hidden {
  display: none;
}

.letter-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2.4rem;
  border: 2px solid #cbd5e1;
  border-radius: 6px;
  font-size: 1.1rem;
  font-weight: 700;
  background: #f8fafc;
  color: #64748b;
  letter-spacing: 0;
}

.letter-box.filled {
  background: linear-gradient(135deg, #e0f2fe, #bfdbfe);
  border-color: #60a5fa;
  color: #1e40af;
}

.assess-help-scaffold {
  margin: 0.5rem 0 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 14px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}
.assess-help-scaffold.hidden {
  display: none;
}
.assess-help-scaffold .learn-image-wrap {
  margin-bottom: 0.5rem;
}
.assess-help-scaffold .learn-spell-wrap {
  margin-bottom: 0.5rem;
}
.assess-help-word-spell {
  margin-bottom: 0.35rem;
}

/* T4/T5 "I need help" — peek: title + word card + Hide help (no layout jump). */
body.assess-peek-help-active #home-btn {
  display: none !important;
}
.assess-card--peek-help {
  display: flex;
  flex-direction: column;
  overflow: visible;
}
.assess-card--peek-help .assess-top-nav,
.assess-card--peek-help .challenge-image-wrap,
.assess-card--peek-help .assess-prompt,
.assess-card--peek-help .assess-hint,
.assess-card--peek-help .assess-letter-hint,
.assess-card--peek-help .assess-input,
.assess-card--peek-help .assess-feedback,
.assess-card--peek-help #assess-check,
.assess-card--peek-help .assess-dots {
  display: none !important;
}
.assess-card--peek-help .assess-t4-title,
.assess-card--peek-help .assess-t5-title {
  flex: 0 0 auto;
  margin-bottom: 0.35rem;
}
.assess-card--peek-help .assess-t4-title.hidden,
.assess-card--peek-help .assess-t5-title.hidden {
  display: none !important;
}
.assess-card--peek-help .assess-help-scaffold {
  display: block !important;
  flex: 0 1 auto;
  min-height: 0;
  max-height: none;
  overflow: visible;
  margin: 0 0 0.5rem;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
}
.assess-card--peek-help .assess-help-word-spell {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}
.assess-card--peek-help .assess-help-scaffold .learn-image-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 0.5rem;
}
.assess-card--peek-help .assess-help-scaffold .learn-spell-wrap {
  display: flex;
  justify-content: center;
  width: 100%;
  margin-bottom: 0.35rem;
}
.assess-card--peek-help .assess-help-scaffold.hidden {
  display: none !important;
}
.assess-card--peek-help .assess-actions {
  flex: 0 0 auto;
  margin-top: 0;
  padding: 0.75rem 0 0;
  justify-content: center;
  background: transparent;
  border-radius: 0;
  box-shadow: none;
}
.assess-card--peek-help .assess-need-help-btn {
  box-sizing: border-box;
  width: 9.25rem;
  min-width: 9.25rem;
  max-width: 9.25rem;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
  text-align: center;
  white-space: nowrap;
  flex-shrink: 0;
  font-weight: 600;
}
.assess-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: center;
}
.assess-need-help-btn {
  flex: 0 1 auto;
}

/* ============================================================
   T3 – Guess the word (multiple choice)
   ============================================================ */

.quiz-t3-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.75rem;
}

.quiz-t3-title {
  font-size: 1.3rem;
  margin: 0;
}

.quiz-t3-progress {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0;
}

.quiz-t3-hint {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin: 0;
}

.quiz-t3-hear-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

#quiz-t3-hear-btn {
  width: auto;
}

.quiz-t3-hint-pill {
  padding: 0.4rem 0.85rem;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: 999px;
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border: 2px solid #f59e0b;
  color: #92400e;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.quiz-t3-hint-pill:hover {
  background: linear-gradient(135deg, #fde68a 0%, #fcd34d 100%);
  transform: translateY(-1px);
}

.quiz-t3-hint-pill.hidden {
  display: none;
}

.quiz-t3-def-tooltip {
  margin: 0.5rem 0 0;
  padding: 0.6rem 0.9rem;
  font-size: 0.95rem;
  line-height: 1.4;
  color: var(--text);
  background: linear-gradient(135deg, #e0f2fe 0%, #fef9c3 100%);
  border: 2px solid #7dd3fc;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transition: opacity 0.2s ease;
}

.quiz-t3-def-tooltip.hidden {
  display: none;
}

.quiz-t3-image-flash {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: rgba(0, 0, 0, 0.75);
  border-radius: inherit;
  pointer-events: none;
}

.quiz-t3-image-flash.hidden {
  display: none;
}

.quiz-t3-image-flash-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.quiz-t3-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.quiz-t3-option {
  flex: 0 0 auto;
  min-width: 0;
  display: inline-block;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  border: none;
  background: #f1f5f9;
  color: #334155;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
}

.quiz-t3-option:hover:not(:disabled) {
  background: #e2e8f0;
  color: #1e293b;
  transform: translateY(-1px);
}

.quiz-t3-option.correct {
  background: #22c55e;
  color: white;
}

.quiz-t3-option.incorrect {
  background: #ef4444;
  color: white;
}

.quiz-t3-option:disabled {
  cursor: default;
  opacity: 0.85;
}

.quiz-t3-feedback {
  font-size: 1rem;
  font-weight: 600;
  min-height: 1.4em;
  margin: 0;
}

.quiz-t3-feedback.correct {
  color: #16a34a;
}

.quiz-t3-feedback.incorrect {
  color: #dc2626;
}

.quiz-t3-feedback .quiz-t3-correct-word {
  display: inline-block;
  background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
  color: #065f46;
  font-size: clamp(1.25rem, 6vw + 1rem, 3.5rem);
  font-weight: 400;
  letter-spacing: 0.06em;
  padding: 0.15em 0.5em 0.15em 0.5em;
  border-radius: 8px;
  margin: 0 0.1em;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* ============================================================
   Adventure Path Sidebar
   ============================================================ */

.adventure-sidebar {
  display: none;
  flex-shrink: 0;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  position: relative;
  align-self: flex-start;
  overflow: visible;
  pointer-events: none;
  user-select: none;
}

.adventure-sidebar.visible {
  display: flex;
  pointer-events: auto;
  /* Consistent top position across all phases — matches quest page centering in its ~580px column */
  margin-top: 4.5625rem;
}

.adv-week-label {
  flex-shrink: 0;
  order: -2;
  margin: 0 0 0.1rem;
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.2;
  letter-spacing: 0.02em;
}

/* Home screen: app-center-wrap starts 20px lower than on exercise phases (header/spacing above),
   so reduce margin-top by the same amount to keep the ladder at the same absolute top position. */
body.is-frontpage .adventure-sidebar.visible {
  margin-top: 3.3125rem;
}

.adv-score-counter {
  flex-shrink: 0;
  order: -1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  min-width: 4.5rem;
  padding: 0.35rem 0.65rem;
  margin: 0 0 0.15rem;
  border-radius: 999px;
  background: linear-gradient(180deg, #fff9e6 0%, #ffe8a3 100%);
  border: 2px solid #f5c542;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.28);
  font-family: var(--font);
  font-weight: 800;
  font-size: 1.15rem;
  color: #92400e;
  line-height: 1.1;
  transform-origin: center center;
}

.adv-score-star {
  font-size: 1.05rem;
  line-height: 1;
}

.adv-score-value {
  font-variant-numeric: tabular-nums;
  min-width: 1.5ch;
  text-align: center;
}

.adv-score-counter.quest-score-bump {
  animation: adv-score-bump 0.45s cubic-bezier(0.34, 1.45, 0.64, 1);
}

@keyframes adv-score-bump {
  0% { transform: scale(1); }
  40% { transform: scale(1.22); }
  100% { transform: scale(1); }
}

.quest-score-float {
  position: fixed;
  left: var(--qs-from-x, 50%);
  top: var(--qs-from-y, 50%);
  transform: translate(-50%, -50%) scale(0.85);
  z-index: 115;
  pointer-events: none;
  font-family: var(--font);
  font-weight: 800;
  font-size: 1.35rem;
  color: #16a34a;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  white-space: nowrap;
  animation: quest-score-float-to-counter 0.75s cubic-bezier(0.22, 0.85, 0.32, 1) forwards;
}
.quest-score-float.quest-score-float-already-counted {
  font-size: 1.05rem;
  max-width: min(92vw, 18rem);
  text-align: center;
  line-height: 1.15;
}

@keyframes quest-score-float-to-counter {
  0% {
    left: var(--qs-from-x);
    top: var(--qs-from-y);
    transform: translate(-50%, -50%) scale(0.7);
    opacity: 0;
  }
  15% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.05);
  }
  100% {
    left: var(--qs-to-x);
    top: var(--qs-to-y);
    transform: translate(-50%, -50%) scale(0.55);
    opacity: 0;
  }
}

.adventure-sidebar.visible .adv-path,
.adventure-sidebar.visible .adv-node {
  pointer-events: auto;
}

/* Hide on narrow viewports where there's no room */
@media (max-width: 700px) {
  .adventure-sidebar {
    display: none !important;
  }
}

.adv-path {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  position: relative;
}

.adv-path-segment {
  width: 4px;
  height: 18px;
  background: #dde3ee;
  border-radius: 2px;
  transition: background 0.4s;
}

.adv-path-segment.reached {
  background: linear-gradient(to bottom, #ffc107, #ff9800);
}

.adv-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  position: relative;
}

.adv-node-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #dde3ee;
  border: 3px solid #c5cfe0;
  transition: background 0.4s, border-color 0.4s, transform 0.3s;
}

.adv-node.reached .adv-node-dot {
  background: #ffc107;
  border-color: #ff9800;
}

.adv-node.current .adv-node-dot {
  background: #e85d75;
  border-color: #c62828;
  transform: scale(1.35);
  box-shadow: 0 0 0 4px rgba(232, 93, 117, 0.25);
}

.adv-label {
  font-size: 0.6rem;
  font-weight: 600;
  color: #94a3b8;
  white-space: nowrap;
  letter-spacing: 0.02em;
  transition: color 0.3s;
}

.adv-node.reached .adv-label {
  color: #b45309;
}

.adv-node.current .adv-label {
  color: #e85d75;
  font-weight: 700;
}

.adv-character-wrap {
  position: absolute;
  /* SVG character to the right of the path, clear of the node dots */
  right: -56px;
  transition: top 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}

.adventure-sidebar.visible .adv-character-wrap {
  pointer-events: auto;
  cursor: grab;
}

.adventure-sidebar.visible .adv-character-wrap:active {
  cursor: grabbing;
}

.adv-character {
  width: 52px;
  height: auto;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

/* Level-up flash animation on the node dot */
@keyframes advLevelUp {
  0%   { transform: scale(1.35); box-shadow: 0 0 0 4px rgba(232, 93, 117, 0.25); }
  40%  { transform: scale(1.8);  box-shadow: 0 0 0 10px rgba(255, 193, 7, 0.4); }
  70%  { transform: scale(1.5);  box-shadow: 0 0 0 6px rgba(255, 193, 7, 0.2); }
  100% { transform: scale(1.35); box-shadow: 0 0 0 4px rgba(232, 93, 117, 0.25); }
}

.adv-node.level-up .adv-node-dot {
  animation: advLevelUp 0.6s ease forwards;
}

/* Landscape on small screens: reduce vertical space usage */
@media (orientation: landscape) and (max-height: 450px) {
  .header h1 {
    font-size: 1.2rem;
  }
  .subtitle {
    display: none;
  }
  .header {
    margin-bottom: 0.35rem;
  }
  .card {
    padding: 0.6rem 0.95rem;
  }
  .quiz-map-container {
    padding: 0.5rem 0.95rem;
  }
  .card h2 {
    font-size: 1.05rem;
  }
}

/* Scrollable lists/areas: cap by viewport so content fits when possible (load-list uses flex to fill pane, so no cap) */
@media (max-height: 600px) {
  .learn-summary-card {
    min-height: min(78dvh, 620px);
  }
  .learn-fill-sentences {
    max-height: min(35vh, 140px);
  }
  .learn-story-image-wrap img,
  .learn-story-image-placeholder {
    max-height: min(30vh, 120px);
    min-height: 80px;
  }
}

@media (max-height: 700px) {
  .learn-story-image-wrap img {
    max-height: 28vh;
  }
  .learn-story-text,
  .learn-fill-sentences {
    max-height: 38vh;
  }
}

/* Settings → Configuration: decorative animations off (see body class toggled in app.js) */
body.spelling-app-reduced-motion .splash-stars {
  visibility: hidden;
}

body.spelling-app-reduced-motion .treasure-shimmer .treasure-letter {
  animation: none !important;
  box-shadow: none !important;
  transform: none !important;
  filter: none !important;
}

body.spelling-app-reduced-motion .quiz-map-area.quiz-map-area-has-image,
body.spelling-app-reduced-motion .quiz-map-area.quiz-map-area-has-image.quiz-map-area-scroll-horizontal,
body.spelling-app-reduced-motion .quiz-map-area.quiz-map-area-has-image.quiz-map-area-near-fit {
  animation: none !important;
}

body.spelling-app-reduced-motion .score-circle {
  animation: none !important;
}

body.spelling-app-reduced-motion .score-circle::before,
body.spelling-app-reduced-motion .score-circle::after {
  animation: none !important;
}

body.spelling-app-reduced-motion .assess-feedback.incorrect,
body.spelling-app-reduced-motion .assess-feedback.correct {
  animation: none !important;
}

body.spelling-app-reduced-motion .difficulty-badge {
  animation: none !important;
}

body.spelling-app-reduced-motion .learn-break-collage-item {
  animation: none !important;
}

body.spelling-app-reduced-motion .t1-celebration-star {
  animation: none !important;
}

body.spelling-app-reduced-motion .star-burst-p {
  animation: none !important;
}

body.spelling-app-reduced-motion .adv-score-counter.quest-score-bump,
body.spelling-app-reduced-motion .quest-score-float {
  animation: none !important;
}

body.spelling-app-reduced-motion .learn-summary-word-hear-playing {
  animation: none !important;
}

/* ============================================================
   First-time onboarding tutorial — modal overlay shown once per
   device after Adult mode is chosen at the splash; re-openable via
   Settings. Designed to match the app's pastel/Lexie-Readable style.
   ============================================================ */
.onboarding-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.onboarding-overlay.hidden { display: none !important; }
.onboarding-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(45, 49, 66, 0.55);
}
.onboarding-card {
  position: relative;
  z-index: 1;
  background: var(--card, #fff);
  border-radius: var(--radius, 20px);
  box-shadow: 0 20px 60px rgba(45, 49, 66, 0.25);
  padding: 1.5rem 1.75rem;
  width: 100%;
  max-width: 760px;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  color: var(--text, #2d3142);
  font-family: var(--font);
}
.onboarding-close {
  position: absolute;
  top: 0.5rem;
  right: 0.65rem;
  background: transparent;
  border: none;
  color: var(--text-muted, #6b7280);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.2rem 0.5rem;
  border-radius: 8px;
}
.onboarding-close:hover { color: var(--text); background: rgba(0, 0, 0, 0.04); }

.onboarding-title {
  margin: 0 0 0.5rem;
  color: var(--primary, #e85d75);
  font-size: 1.45rem;
  line-height: 1.25;
}
.onboarding-subtitle {
  margin: 1rem 0 0.4rem;
  color: var(--secondary, #5cb8b2);
  font-size: 1.1rem;
}
.onboarding-lede {
  margin: 0 0 1rem;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text);
}

/* 3-day rhythm strip — three side-by-side cards on desktop, stacked on phones. */
.onboarding-rhythm {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.65rem;
  margin: 0.75rem 0;
}
.onboarding-day {
  background: #fff7ed;
  border: 2px solid #fed7aa;
  border-radius: 14px;
  padding: 0.75rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  text-align: center;
}
.onboarding-day-num {
  font-weight: 700;
  color: var(--primary);
  font-size: 0.85rem;
  letter-spacing: 0.04em;
}
.onboarding-day-label {
  font-weight: 700;
  font-size: 1.05rem;
}
.onboarding-day-detail {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.35;
}
.onboarding-rhythm-note {
  margin: 0.5rem 0 0;
  font-size: 0.88rem;
  color: var(--text-muted);
  font-style: italic;
  line-height: 1.4;
}

.onboarding-benefits {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.onboarding-benefits li {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  font-size: 0.92rem;
  line-height: 1.45;
}
.onboarding-bullet {
  font-size: 1.25rem;
  line-height: 1;
  flex-shrink: 0;
  width: 1.8rem;
  text-align: center;
  margin-top: 0.05rem;
}
.onboarding-benefits strong { color: var(--text); }

.onboarding-treasures p { margin: 0 0 0.5rem; font-size: 0.95rem; line-height: 1.5; }
.onboarding-getstarted { margin: 0 0 0.6rem; font-size: 0.95rem; line-height: 1.45; }
.onboarding-tip {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  background: #f3f4f6;
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
}

.onboarding-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1.25rem;
  padding-top: 0.85rem;
  border-top: 1px solid #f1f5f9;
}
.onboarding-controls .btn { padding: 0.5rem 1rem; }
.onboarding-dots {
  flex: 1;
  display: flex;
  gap: 0.45rem;
  justify-content: center;
}
.onboarding-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #e5e7eb;
  transition: background 0.2s;
}
.onboarding-dot.active { background: var(--primary); }

.onboarding-show-again-label {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  max-width: min(11rem, 100%);
}
.onboarding-show-again-label input {
  margin: 0;
  flex-shrink: 0;
  accent-color: var(--secondary);
}

@media (max-width: 540px) {
  .onboarding-card { padding: 1.2rem 1rem 1rem; }
  .onboarding-title { font-size: 1.2rem; }
  .onboarding-rhythm { grid-template-columns: 1fr; }
  .onboarding-controls { flex-wrap: wrap; }
  .onboarding-controls .btn { flex: 1 1 30%; }
  .onboarding-dots { order: -1; flex: 1 1 100%; margin-bottom: 0.25rem; }
}

body.spelling-app-reduced-motion .onboarding-dot { transition: none !important; }

/* ============================================================
   Accessibility: visible focus indicator for keyboard / switch users.
   Uses :focus-visible so the ring shows on Tab navigation, switch
   access, and screen-reader focus — but NOT on plain mouse clicks
   (which would be visually noisy for sighted pointer users).

   Appended last so these rules win over earlier `:focus { outline: none }`
   declarations when a keyboard focus is active. The `:focus { outline: none }`
   rules still fire for pure-mouse clicks where they were originally intended.
   ============================================================ */
:root {
  --focus-ring: #4f46e5;        /* indigo — high contrast on cream and on dark surfaces */
  --focus-ring-glow: rgba(79, 70, 229, 0.28);
}

button:focus-visible,
[role="button"]:focus-visible,
.btn:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
label.profile-avatar-custom-btn:focus-visible,
[tabindex]:not([tabindex="-1"]):focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
  box-shadow: 0 0 0 5px var(--focus-ring-glow);
  /* Prevent the glow being clipped on tightly-laid-out buttons. */
  z-index: 2;
  position: relative;
}

/* Inside a hover-active button (where a transform may be applied), the focus
   ring should still be visible: don't let parent transforms clip the box-shadow. */
.btn-big:focus-visible,
.btn-primary:focus-visible,
.btn-secondary:focus-visible {
  transform: none;
  outline: 3px solid var(--focus-ring, #4f46e5);
  outline-offset: 3px;
}

/* Programmatic focus (child-mode auto-focus) does not trigger :focus-visible —
   use :focus so the ring shows regardless of how focus was set. */
#start-learning:focus {
  outline: 3px solid var(--focus-ring, #4f46e5);
  outline-offset: 3px;
}

#quest-intro-btn:focus {
  outline: 3px solid var(--focus-ring, #4f46e5);
  outline-offset: 3px;
}

/* "Hide help" retains mouse-click focus — :focus-visible never fires on a click */
#assess-need-help-btn:focus,
#learn-mini-quiz-need-help:focus {
  outline: 3px solid var(--focus-ring, #4f46e5);
  outline-offset: 3px;
  box-shadow: 0 0 0 5px var(--focus-ring-glow, rgba(79, 70, 229, 0.28));
  z-index: 2;
  position: relative;
}

#learn-summary-quiz-btn:focus {
  outline: 3px solid var(--focus-ring, #4f46e5);
  outline-offset: 3px;
  box-shadow: 0 0 0 5px var(--focus-ring-glow, rgba(79, 70, 229, 0.28));
  transform: none;
  z-index: 2;
  position: relative;
}

.learn-break-offer-actions .btn:focus,
.learn-break-offer-actions .btn:focus-visible {
  outline: 3px solid var(--focus-ring, #4f46e5);
  outline-offset: 3px;
  box-shadow: 0 0 0 5px var(--focus-ring-glow, rgba(79, 70, 229, 0.28));
  transform: none;
  z-index: 2;
  position: relative;
}

#phase-quiz-map button:focus {
  outline: 3px solid var(--focus-ring, #4f46e5);
  outline-offset: 3px;
}

#phase-learn button:focus,
#phase-learn-story button:focus,
#phase-learn-summary button:focus {
  outline: 3px solid var(--focus-ring, #4f46e5);
  outline-offset: 3px;
}

/* Some inputs explicitly suppress the default outline (textarea, scan paste zone,
   load list search, mini-spell, etc). They typically signal focus via
   `border-color`; layer the focus ring on top so keyboard users still see it. */
.input-row input:focus-visible,
.input-row textarea:focus-visible,
#word-input:focus-visible,
.scan-paste-zone:focus-visible,
.load-list-search:focus-visible,
.missing-input:focus-visible,
.mini-spell-input:focus-visible,
.mini-fill-input:focus-visible,
#profile-name-part:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
  box-shadow: 0 0 0 5px var(--focus-ring-glow);
}

/* ── Settings mode tabs (top-level navigation: Simple / With extras / Full control) ── */
.settings-mode-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0;
  flex-wrap: wrap;
}
.settings-mode-tab {
  flex: 1;
  min-width: 90px;
  padding: 0.6rem 0.75rem;
  border: 2px solid var(--border, #e0d6c8);
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted, #666);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  text-align: center;
}
.settings-mode-tab::before {
  content: '( ) ';
  font-family: monospace;
  font-weight: 400;
  letter-spacing: -0.05em;
}
.settings-mode-tab.active::before {
  content: '(◉) ';
}
.settings-mode-tab:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.settings-mode-tab.active {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 10%, transparent);
  color: var(--primary);
}
.settings-mode-desc {
  margin: 0.5rem 0 0;
  font-size: 0.88rem;
  color: var(--text-muted, #666);
  min-height: 1.2em;
}

/* ── Settings sub-tab gating by mode (view-mode on .settings-card) ────────── */
/* Simple: only Tools + Schedule */
.settings-card[data-view-mode="default"] #settings-tab-difficulty,
.settings-card[data-view-mode="default"] #settings-tab-dictionary,
.settings-card[data-view-mode="default"] #settings-tab-breakdown,
.settings-card[data-view-mode="default"] #settings-tab-configuration,
.settings-card[data-view-mode="default"] #settings-panel-difficulty,
.settings-card[data-view-mode="default"] #settings-panel-dictionary,
.settings-card[data-view-mode="default"] #settings-panel-breakdown,
.settings-card[data-view-mode="default"] #settings-panel-configuration {
  display: none;
}
/* Advanced: Tools + Schedule + Levels — hide dictionary, breakdown, configuration */
.settings-card[data-view-mode="extra"] #settings-tab-dictionary,
.settings-card[data-view-mode="extra"] #settings-tab-breakdown,
.settings-card[data-view-mode="extra"] #settings-tab-configuration,
.settings-card[data-view-mode="extra"] #settings-panel-dictionary,
.settings-card[data-view-mode="extra"] #settings-panel-breakdown,
.settings-card[data-view-mode="extra"] #settings-panel-configuration {
  display: none;
}
/* Full: all tabs visible — no hiding rules needed */
/* In Simple and Advanced modes the auto-list checkbox is locked on */
.settings-card[data-view-mode="default"] #auto-list-selection,
.settings-card[data-view-mode="extra"] #auto-list-selection {
  pointer-events: none;
  opacity: 0.5;
}

.tools-materials-options {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.tools-materials-opt {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.tools-materials-opt input[type="checkbox"] {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--secondary);
  flex-shrink: 0;
}

/* ── Setup Wizard phase ───────────────────────────────────────────────────── */
.setup-wizard-card {
  max-width: 760px;
  margin: 0 auto;
  padding: 1.75rem 1.5rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.setup-wizard-card h2 {
  margin: 0 0 0.25rem;
  font-size: 1.3rem;
  color: var(--text);
}
.wizard-step.hidden { display: none; }

.wizard-context-display {
  background: var(--bg);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border, #e0d6c8);
}
.wizard-context-line {
  margin: 0;
  font-weight: 600;
  color: var(--text);
}
.wizard-context-year {
  font-weight: 400;
  color: var(--text-muted, #666);
  font-size: 0.9em;
  margin-top: 0.2rem;
}

.wizard-year-selector {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.wizard-year-selector.hidden { display: none; }
.wizard-year-label { font-weight: 600; white-space: nowrap; }
.wizard-year-select { flex: 1; }

.wizard-group-fieldset {
  border: 1px solid var(--border, #e0d6c8);
  border-radius: 10px;
  padding: 0.75rem 1rem;
}
.wizard-group-fieldset legend {
  font-weight: 700;
  padding: 0 0.25rem;
}
.wizard-group-options {
  display: flex;
  gap: 0.75rem;
}
.wizard-group-option {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  border: 2px solid var(--border, #e0d6c8);
  border-radius: 10px;
  cursor: pointer;
  font-size: 1rem;
  transition: border-color 0.15s, background 0.15s;
}
.wizard-group-option input[type="radio"] { display: none; }
.wizard-group-option--selected,
.wizard-group-option:has(input:checked) {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 8%, transparent);
}
.wizard-group-label-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
}
.wizard-group-hint {
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--text-muted, #888);
}
.wizard-custom-code-notice {
  margin: 0.5rem 0 0;
  padding: 0.6rem 0.9rem;
  border-radius: 8px;
  background: color-mix(in srgb, var(--primary) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent);
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.45;
}
.wizard-custom-code-notice.hidden { display: none; }

/* Mode cards — shared by wizard and compact Setup mode fieldset */
.wizard-mode-options {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.wizard-mode-options--compact .wizard-mode-card-desc {
  font-size: 0.82rem;
}
.wizard-mode-card {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border: 2px solid var(--border, #e0d6c8);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.wizard-mode-card input[type="radio"] { display: none; }
.wizard-mode-card--selected,
.wizard-mode-card:has(input:checked) {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 8%, transparent);
}
.wizard-mode-card-body { flex: 1; }
.wizard-mode-card-title {
  font-weight: 700;
  margin-bottom: 0.15rem;
}
.wizard-mode-card-desc {
  font-size: 0.88rem;
  color: var(--text-muted, #666);
  line-height: 1.4;
}

/* Setup mode fieldset inside Tools tab */
.setup-mode-fieldset {
  margin-top: 0.5rem;
}

/* ── Schedule tab ─────────────────────────────────────────────────────────── */
.schedule-header {
  margin-bottom: 0.75rem;
}
.schedule-header-row {
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
}
.schedule-group-wrap {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-left: auto;
}
.schedule-group-label {
  font-size: 0.9rem;
  white-space: nowrap;
}
.schedule-group-select {
  font-size: 0.9rem;
  padding: 0.2rem 0.4rem;
  border: 1px solid var(--border, #e0d6c8);
  border-radius: 6px;
  background: var(--surface, #fff);
  cursor: pointer;
  min-width: 3.5rem;
}
.schedule-auto-hint {
  margin: 0.25rem 0 0;
  color: var(--text-muted, #666);
}
.schedule-grid-wrap { margin-top: 0.5rem; }
.schedule-grid-wrap.hidden { display: none; }
.schedule-week-start {
  flex-wrap: wrap;
  gap: 0.5rem 0.65rem;
  margin-bottom: 0.35rem;
}
.schedule-week-start-day,
.schedule-week-start-time {
  min-width: 7rem;
}
.schedule-week-start-time-label {
  margin: 0;
  font-weight: 600;
  color: var(--text);
}
.schedule-week-start-hint {
  margin: 0 0 0.75rem;
}
.schedule-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.schedule-row {
  display: grid;
  grid-template-columns: 9rem 1fr auto auto;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.25rem;
  border-bottom: 1px solid var(--border, #e0d6c8);
}
.schedule-row:last-child { border-bottom: none; }
.schedule-row-active {
  background: #f0fdf4;
}
.schedule-week-active-badge {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #166534;
  background: #bbf7d0;
  vertical-align: middle;
}
.schedule-row-label {
  font-size: 0.85rem;
  line-height: 1.3;
}
.schedule-week-id {
  font-weight: 600;
  display: block;
}
.schedule-week-dates {
  color: var(--text-muted, #666);
  font-size: 0.78rem;
}
.schedule-row-assigned {
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.schedule-row-assigned-empty {
  color: var(--text-muted, #888);
  font-style: italic;
}
.schedule-row-choose {
  font-size: 0.8rem;
  padding: 0.2rem 0.5rem;
  white-space: nowrap;
}
.schedule-row-clear {
  font-size: 0.8rem;
  padding: 0.2rem 0.5rem;
  white-space: nowrap;
}
.schedule-assign-banner {
  background: color-mix(in srgb, var(--primary, #e85d75) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--primary, #e85d75) 30%, transparent);
  border-radius: 8px;
  color: var(--primary, #e85d75);
  font-size: 0.88rem;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.75rem;
}
.schedule-save-status {
  margin-top: 0.5rem;
  min-height: 1.2em;
  font-size: 0.85rem;
}

/* ── Splash Child-button disabled state ──────────────────────────────────── */
.splash-child-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
}
.splash-child-blocked {
  font-size: 0.78rem;
  color: var(--text-muted, #aaa);
  text-align: center;
  max-width: 160px;
  line-height: 1.3;
  margin: 0;
}
.splash-child-blocked.hidden { display: none; }
.splash-overlay--child-disabled #splash-btn-child {
  opacity: 0.45;
  pointer-events: none;
  cursor: default;
}
.splash-overlay--child-disabled #splash-btn-child[aria-disabled="true"] {
  filter: grayscale(0.5);
}

/* Honour user preference for high contrast (Windows / iOS / GNOME): make the
   ring even thicker and use the system selection colour where available. */
@media (prefers-contrast: more) {
  :root { --focus-ring: Highlight; }
  button:focus-visible,
  [role="button"]:focus-visible,
  .btn:focus-visible,
  a:focus-visible,
  input:focus-visible,
  select:focus-visible,
  textarea:focus-visible {
    outline-width: 4px;
    outline-offset: 3px;
  }
}
/* ── Quest intro overlay (T1–T5 character welcome / retry) ─────────────── */
/* === Quest welcome overlay — 5 portrait panels side-by-side === */
.quest-welcome-overlay {
  position: fixed;
  inset: 0;
  z-index: 9989;
  background: rgba(15, 23, 42, 0.72);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.quest-welcome-overlay.hidden { display: none !important; }
.quest-welcome-card {
  background: #fff;
  border-radius: 18px;
  padding: 1rem 1rem 1.5rem;
  max-width: calc(100vw - 2rem);
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
  box-shadow: 0 20px 48px rgba(15, 23, 42, 0.28);
}
.quest-welcome-stage {
  display: flex;
  gap: 0;
  align-items: stretch;
  width: 100%;
  border-radius: 10px;
  overflow: hidden;
}
.qw-panel {
  position: relative;
  flex: 1 1 0;
  aspect-ratio: 9 / 16;
  min-width: 0;
  overflow: hidden;
  border-radius: 0;
  background: #f8fafc;
}
.qw-img,
.qw-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 0;
}
.quest-welcome-btn {
  min-width: 9rem;
  flex-shrink: 0;
  border: 2px solid var(--focus-ring, #4f46e5);
  color: var(--focus-ring, #4f46e5);
  background: #fff;
}
/* === Quest intro overlay (per-challenge T1–T5) === */
.quest-intro-overlay {
  position: fixed;
  inset: 0;
  z-index: 9990;
  background: rgba(15, 23, 42, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.quest-intro-overlay.hidden { display: none !important; }
.quest-intro-card {
  background: #fff;
  border-radius: 18px;
  padding: 1.25rem 1.5rem 1.5rem;
  max-width: min(1440px, calc(100vw - 2rem));
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
  box-shadow: 0 20px 48px rgba(15, 23, 42, 0.28);
}
.quest-intro-video {
  width: 100%;
  border-radius: 10px;
  max-height: min(810px, calc(100vh - 12rem));
  object-fit: cover;
  background: #fff;
  display: block;
}
.quest-intro-video.quest-intro-video--pending {
  opacity: 0;
}
.quest-intro-fallback-img {
  width: min(450px, calc(100vw - 4rem));
  height: min(450px, calc(100vw - 4rem));
  object-fit: contain;
}
.quest-intro-land {
  font-size: 1.25rem;
  font-weight: 700;
  text-align: center;
  color: #1e293b;
  margin: 0;
}
.quest-intro-phrase {
  text-align: center;
  font-size: 1rem;
  color: #374151;
  margin: 0;
  line-height: 1.5;
}
.quest-intro-btn {
  margin-top: 0.25rem;
  min-width: 9rem;
}

/* === Account page === */
.account-card {
  max-width: 680px;
  margin: 0 auto;
  padding: 1.5rem;
}
.account-section-title {
  font-size: 1rem;
  font-weight: 700;
  margin: 1.25rem 0 0.5rem;
  color: #1e293b;
}
.account-details-block { margin-bottom: 1rem; }
.account-detail-list {
  display: grid;
  grid-template-columns: 7rem 1fr;
  gap: 0.25rem 0.75rem;
  margin: 0;
  font-size: 0.95rem;
}
.account-detail-list dt { font-weight: 600; color: #475569; }
.account-detail-list dd { margin: 0; word-break: break-all; }
.account-reports-list { display: flex; flex-direction: column; gap: 0.75rem; margin-top: 0.5rem; }
.account-report-item {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 0.75rem 1rem;
}
.account-report-item.account-report-status-replied { border-left: 4px solid #22c55e; }
.account-report-item.account-report-status-triaged { border-left: 4px solid #f59e0b; }
.account-report-meta { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; margin-bottom: 0.35rem; font-size: 0.8rem; }
.account-report-cat { font-weight: 600; background: #e0e7ff; color: #3730a3; padding: 0.1rem 0.45rem; border-radius: 4px; }
.account-report-status-badge { padding: 0.1rem 0.45rem; border-radius: 4px; background: #f1f5f9; color: #64748b; }
.account-report-date { color: #94a3b8; margin-left: auto; }
.account-report-message { margin: 0 0 0.35rem; font-size: 0.9rem; color: #374151; }
.account-user-id-hint { margin: 0.75rem 0 0; }
.account-actions { margin-top: 1.25rem; }

/* Account panel — spec 10+11 sections */
.account-section {
  padding: 0.9rem 0;
  border-bottom: 1px solid #e2e8f0;
}
.account-section:last-child { border-bottom: none; }
.account-section:first-child { padding-top: 0; }

.account-parent-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}
.account-parent-email { font-weight: 600; word-break: break-all; }
.account-link-btn {
  background: none;
  border: none;
  color: var(--secondary, #6366f1);
  cursor: pointer;
  font-size: 0.875rem;
  padding: 0.1rem 0.25rem;
  text-decoration: underline;
  text-underline-offset: 2px;
  font-family: inherit;
}
.account-link-btn:hover { opacity: 0.8; }

/* Child cards */
.account-child-card {
  display: block;
  min-width: 0;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 0.9rem 1rem;
  margin-bottom: 0.75rem;
}
.account-child-card legend {
  font-weight: 700;
  font-size: 0.8rem;
  padding: 0 0.35rem;
  color: #64748b;
  font-family: ui-monospace, monospace;
  letter-spacing: 0.04em;
}
.account-child-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}
.account-child-avatar-name { font-weight: 700; }
.account-child-edit-row {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  margin-bottom: 0.75rem;
}
.account-child-edit-label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.875rem;
  font-weight: 600;
}
.account-child-edit-label input,
.account-child-edit-label select {
  padding: 0.35rem 0.5rem;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  font-size: 0.9rem;
  font-family: inherit;
  min-height: 36px;
}
.account-child-details {
  display: grid;
  grid-template-columns: 7.5rem 1fr;
  gap: 0.25rem 0.75rem;
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
}
.account-child-details dt { font-weight: 600; color: #475569; }
.account-child-details dd { margin: 0; word-break: break-word; }
.account-child-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.2rem 0.5rem;
  font-size: 0.85rem;
  margin: 0 0 0.75rem;
}
.account-child-stats dt { color: #64748b; font-size: 0.78rem; }
.account-child-stats dd { margin: 0; font-weight: 700; }
.account-danger-outline-btn {
  background: none;
  border: 1.5px solid #ef4444;
  color: #ef4444;
  font-size: 0.82rem;
  padding: 0.3rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  min-height: 36px;
  font-family: inherit;
}
.account-danger-outline-btn:hover { background: #fef2f2; }

/* Marketing row */
.account-marketing-row {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 0.4rem 0 0.6rem;
}
.account-marketing-text { flex: 1; min-width: 0; }
.account-marketing-text strong { display: block; }

/* Danger zone */
.account-danger-zone {
  border: 1.5px solid #fca5a5;
  border-radius: 10px;
  padding: 0.9rem 1rem;
  margin-top: 0.5rem;
}
.account-danger-btn {
  background: #ef4444;
  color: #fff;
  border: none;
  padding: 0.5rem 1.25rem;
  border-radius: 7px;
  cursor: pointer;
  font-size: 0.9rem;
  min-height: 44px;
  font-family: inherit;
}
.account-danger-btn:hover { background: #dc2626; }
.account-danger-btn:disabled { background: #f87171; cursor: not-allowed; }

/* Account modals */
.account-modal {
  position: fixed;
  inset: 0;
  z-index: 2100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.account-modal.hidden { display: none; }
.account-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}
.account-modal-box {
  position: relative;
  background: #fff;
  border-radius: 12px;
  padding: 1.5rem;
  max-width: min(480px, calc(100vw - 2rem));
  width: 100%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  z-index: 1;
}
.account-modal-box h3 { margin: 0 0 0.75rem; font-size: 1.05rem; }
.account-modal-box p { font-size: 0.9rem; margin: 0 0 0.5rem; }
.account-modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}
.account-modal input[type="email"],
.account-modal input[type="text"] {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1.5px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.95rem;
  font-family: inherit;
  box-sizing: border-box;
  margin-top: 0.35rem;
  min-height: 44px;
}
.account-modal-error { color: #ef4444; font-size: 0.875rem; margin: 0.35rem 0 0; }
.account-modal-sent  { color: #16a34a; font-size: 0.875rem; margin: 0.35rem 0 0; }
.account-modal-user-id-line { font-size: 0.8rem; color: #64748b; margin: 0 0 0.5rem; }
.account-modal-user-id-line code { font-family: ui-monospace, monospace; font-size: 0.8rem; letter-spacing: 0.04em; }

/* === Report popup === */
.report-popup {
  position: fixed; inset: 0; z-index: 2000;
  display: flex; align-items: center; justify-content: center;
}
.report-popup.hidden { display: none; }
.report-popup-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.45);
}
.report-popup-box {
  position: relative; z-index: 1;
  background: #fff;
  border-radius: 12px;
  padding: 1.5rem 1.5rem 1rem;
  width: min(560px, 96vw);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}
.report-popup-title { margin: 0 0 1rem; font-size: 1.2rem; }
.report-popup-form { display: flex; flex-direction: column; gap: 0.55rem; }
.report-popup-label { font-weight: 600; font-size: 0.9rem; color: #374151; }
.report-required { color: #dc2626; }
.report-popup-select, .report-popup-textarea {
  width: 100%; box-sizing: border-box;
  border: 1.5px solid #cbd5e1; border-radius: 7px; padding: 0.45rem 0.65rem;
  font-size: 0.95rem; font-family: inherit;
}
.report-popup-textarea { resize: vertical; min-height: 90px; }
.report-popup-screenshot-row { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.report-popup-screenshot-label { display: flex; align-items: center; gap: 0.4rem; font-size: 0.9rem; cursor: pointer; }
.report-popup-screenshot-status { font-size: 0.8rem; color: #64748b; }
.report-popup-preview-wrap { margin-top: 0.25rem; }
.report-popup-preview { max-width: 100%; max-height: 180px; border-radius: 6px; border: 1px solid #e2e8f0; display: block; }
.report-popup-error { color: #dc2626; font-size: 0.85rem; margin: 0; }
.report-popup-success { color: #166534; background: #f0fdf4; padding: 0.5rem 0.75rem; border-radius: 6px; font-size: 0.9rem; margin: 0; }
.report-popup-actions { display: flex; gap: 0.75rem; justify-content: flex-end; margin-top: 1rem; flex-wrap: wrap; }

/* === Admin reports — triage additions === */
.admin-reports-safety-banner {
  background: #dc2626; color: #fff; font-weight: 700;
  padding: 0.5rem 0.75rem; border-radius: 6px; margin-bottom: 0.5rem;
}

/* === PR10 — consent notice + checkboxes on the signup gate === */
.login-gate-consent-heading {
  margin: 0 0 0.4rem;
  font-size: 1.1rem;
  font-weight: 700;
  color: #0f172a;
}
.login-gate-consent-lede {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  color: #334155;
}
.login-gate-consent-sections {
  margin: 0 0 0.5rem;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
}
.login-gate-consent-section {
  border-bottom: 1px solid #e2e8f0;
}
.login-gate-consent-section:last-child { border-bottom: none; }
.login-gate-consent-section > summary {
  cursor: pointer;
  padding: 0.5rem 0.75rem;
  font-weight: 600;
  font-size: 0.93rem;
  color: #1e293b;
  list-style: revert;
}
.login-gate-consent-section > summary:hover { background: #eef2f6; }
.login-gate-consent-section[open] > summary { background: #eef2f6; }
.login-gate-consent-section > p,
.login-gate-consent-section > ul {
  margin: 0;
  padding: 0.25rem 1.1rem 0.65rem;
  font-size: 0.88rem;
  color: #334155;
  line-height: 1.45;
}
.login-gate-consent-section > ul { padding-left: 1.85rem; }
.login-gate-consent-section li { margin-bottom: 0.2rem; }
.login-gate-consent-version-note {
  font-size: 0.75rem;
  color: #94a3b8;
  margin: 0.25rem 0 0.75rem;
  text-align: right;
}
.login-gate-required-mark {
  color: #dc2626;
  font-weight: 700;
  font-size: 0.85em;
}
.login-gate-optional-mark {
  color: #64748b;
  font-weight: 400;
  font-size: 0.85em;
}
.login-gate-consent-checks {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0.5rem 0 0.9rem;
}
.login-gate-consent-check {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  font-size: 0.88rem;
  line-height: 1.4;
  color: #1e293b;
  cursor: pointer;
}
.login-gate-consent-check input[type="checkbox"] {
  margin-top: 0.18rem;
  width: 1.05rem;
  height: 1.05rem;
  flex-shrink: 0;
}
.login-gate-consent-foot {
  margin: 0.75rem 0 0;
  font-size: 0.78rem;
  color: #64748b;
  line-height: 1.45;
  text-align: center;
}
.login-gate-consent-foot a { color: inherit; text-decoration: underline; }

/* === PR10 — re-consent overlay === */
.reconsent-overlay {
  position: fixed;
  inset: 0;
  z-index: 10500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  box-sizing: border-box;
}
.reconsent-overlay.hidden { display: none !important; }
.reconsent-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}
.reconsent-box {
  position: relative;
  z-index: 1;
  background: #fff;
  border-radius: 12px;
  padding: 1.5rem 1.75rem;
  max-width: 34rem;
  width: 100%;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}
.reconsent-title {
  margin: 0 0 0.4rem;
  font-size: 1.25rem;
  color: #0f172a;
}
.reconsent-lede {
  margin: 0 0 0.85rem;
  font-size: 0.95rem;
  color: #334155;
}
.reconsent-changes,
.reconsent-notice {
  margin: 0 0 0.85rem;
  padding: 0.65rem 0.85rem;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 8px;
}
.reconsent-notice {
  background: #f8fafc;
  border-color: #e2e8f0;
}
.reconsent-changes h3,
.reconsent-notice h3 {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
  color: #0c4a6e;
}
.reconsent-notice h3 { color: #1e293b; }
.reconsent-changes ul,
.reconsent-notice ul {
  margin: 0;
  padding-left: 1.2rem;
  font-size: 0.88rem;
}
.reconsent-notice h2,
.reconsent-notice h3,
.reconsent-notice p,
.reconsent-notice ul,
.reconsent-notice ol { color: #1e293b; font-size: 0.9rem; line-height: 1.5; }
.reconsent-checks {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0.5rem 0 0.85rem;
}
.reconsent-actions {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.reconsent-actions .btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }

/* === PR10 — child micro-notice === */
.child-notice-overlay {
  position: fixed;
  inset: 0;
  z-index: 10300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.child-notice-overlay.hidden { display: none !important; }
.child-notice-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}
.child-notice-box {
  position: relative;
  z-index: 1;
  background: #fffaf0;
  border: 3px solid #fcd34d;
  border-radius: 14px;
  padding: 1.5rem 1.75rem;
  max-width: 28rem;
  width: 100%;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}
.child-notice-title {
  margin: 0 0 0.6rem;
  font-size: 1.4rem;
  color: #92400e;
}
.child-notice-box p {
  margin: 0 0 0.7rem;
  font-size: 1rem;
  line-height: 1.45;
  color: #1e293b;
}
.child-notice-ready { font-weight: 700; color: #92400e; }
.child-notice-actions { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin-top: 0.75rem; }
.child-notice-actions .btn { margin-top: 0; }
