:root {
  --bg: #fff8e8;
  --card: #fffdf7;
  --ink: #253238;
  --ink-soft: #5b6b70;
  --accent: #0f766e;
  --accent-2: #ff8a00;
  --bubble: #d7f1ff;
  --line: #6b7280;
  --border: #f0d7a5;
  --btn-shadow: 0 3px 0 rgba(16, 24, 40, 0.2);
  --surface-shadow: 0 8px 18px rgba(38, 30, 16, 0.12);

  /* Shelf/strand accent colors — one per themed "land" on the hub map. */
  --strand-harbor: #0f766e;
  --strand-falls: #1c7ed6;
  --strand-forest: #2f9e44;
  --strand-lagoon: #7c5cbf;
  --strand-summit: #c2542c;
  --strand-peak: #4338ca;

  --font-display: "Baloo 2", "Trebuchet MS", "Segoe UI", sans-serif;
  --font-body: "Atkinson Hyperlegible", "Segoe UI", "Trebuchet MS", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12181a;
    --card: #1c2528;
    --ink: #eef4f3;
    --ink-soft: #a9bcbb;
    --accent: #34d1c0;
    --accent-2: #ffb15c;
    --bubble: #16343a;
    --line: #7c8f8e;
    --border: #2d3a3e;
    --btn-shadow: 0 3px 0 rgba(0, 0, 0, 0.4);
    --surface-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);

    --strand-harbor: #34d1c0;
    --strand-falls: #5aa9f0;
    --strand-forest: #6fce78;
    --strand-lagoon: #b09ae8;
    --strand-summit: #e2905f;
    --strand-peak: #8b83f5;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 10%, #ffd8a8, transparent 35%),
    radial-gradient(circle at 90% 5%, #b7ebff, transparent 35%),
    linear-gradient(180deg, #fff8e8 0%, #ffecc7 100%);
}

@media (prefers-color-scheme: dark) {
  body {
    background:
      radial-gradient(circle at 10% 10%, rgba(52, 209, 192, 0.12), transparent 35%),
      radial-gradient(circle at 90% 5%, rgba(90, 169, 240, 0.12), transparent 35%),
      linear-gradient(180deg, #12181a 0%, #0d1113 100%);
  }
}

h1, h2, h3 {
  font-family: var(--font-display);
  letter-spacing: 0.01em;
}

.muted {
  color: var(--ink-soft);
}

.screen[hidden] {
  display: none;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.engine-controls-hidden {
  /* The native engine controls (#gameType, #difficulty, #newPuzzleBtn, ...)
     stay fully functional in the DOM — the hub + difficulty picker set their
     values and .click() them programmatically — just not shown to the player. */
  display: none;
}

.app {
  max-width: 900px;
  margin: 24px auto;
  padding: 0 16px 24px;
  display: grid;
  gap: 14px;
}

.card {
  background: var(--card);
  border: 2px solid #f0d7a5;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 8px 18px rgba(38, 30, 16, 0.12);
}

.hero {
  background:
    radial-gradient(circle at 100% 0%, #d7f1ff, transparent 40%),
    radial-gradient(circle at 0% 100%, #ffe3b2, transparent 45%),
    var(--card);
}

.row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

input,
select,
button {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #c8c8c8;
  font-size: 1.04rem;
}

button {
  background: var(--accent);
  color: white;
  border: none;
  cursor: pointer;
  font-weight: 700;
  box-shadow: var(--btn-shadow);
  transition: transform 0.08s ease, box-shadow 0.08s ease, background 0.16s ease;
}

button:hover {
  background: var(--accent-2);
  transform: translateY(-1px);
  box-shadow: 0 4px 0 rgba(16, 24, 40, 0.24);
}

button:active {
  transform: translateY(1px);
  box-shadow: 0 1px 0 rgba(16, 24, 40, 0.18);
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.32);
  outline-offset: 1px;
}

label[for="difficulty"] {
  font-weight: 700;
}

#difficulty {
  width: 88px;
  min-height: 50px;
  padding: 10px 8px;
  border: 2px solid #0f766e;
  border-radius: 12px;
  text-align: center;
  font-size: 1.04rem;
  font-weight: 700;
  background: #ffffff;
}

#difficulty::-webkit-outer-spin-button,
#difficulty::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

#difficulty {
  appearance: textfield;
}

#difficultyLabel {
  font-size: 1rem;
  padding: 8px 12px;
}

.difficulty-stepper {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.difficulty-stepper button {
  width: 42px;
  min-width: 42px;
  height: 42px;
  border-radius: 999px;
  padding: 0;
  font-size: 1.25rem;
  line-height: 1;
}

.puzzle {
  margin: 12px 0;
  font-size: 1.55rem;
  font-weight: bold;
  background: var(--bubble);
  border-radius: 12px;
  padding: 12px;
}

.puzzle.nb-win-pop {
  animation: nb-win-pop 0.55s ease;
}

.muted {
  color: #63717a;
}

#result {
  min-height: 1.4em;
  font-weight: 700;
}

#result.result-success {
  color: #166534;
  animation: result-pop 0.45s ease;
}

@keyframes result-pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.04); }
  100% { transform: scale(1); }
}

.pill {
  align-self: center;
  background: #fef3c7;
  border: 1px solid #f59e0b;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.9rem;
  font-weight: 700;
}

.choice-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.choice-grid button {
  min-width: 82px;
  min-height: 46px;
  font-size: 1.08rem;
  border-radius: 12px;
  background: #2563eb;
}

.number-line {
  margin: 10px 0 14px;
  padding: 8px 0 2px;
  position: relative;
}

.line-track {
  position: relative;
  height: 2px;
  background: var(--line);
}

.tick {
  position: absolute;
  transform: translateX(-50%);
  text-align: center;
  top: -10px;
}

.tick-mark {
  width: 2px;
  height: 10px;
  background: var(--line);
  margin: 0 auto 2px;
}

.tick-label {
  font-size: 0.72rem;
}

.nb-burst {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: visible;
}

.nb-dot {
  position: absolute;
  left: 50%;
  top: 10px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  transform: translate(-50%, 0);
  animation: nb-dot-burst 0.65s ease-out forwards;
}

@keyframes nb-win-pop {
  0% { transform: scale(1); }
  25% { transform: scale(1.05) rotate(-1deg); }
  60% { transform: scale(1.08) rotate(1deg); }
  100% { transform: scale(1); }
}

@keyframes nb-dot-burst {
  0% {
    transform: translate(-50%, 0) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(calc(-50% + var(--dx)), var(--dy)) scale(0.2);
    opacity: 0;
  }
}

/* ===== Mismo ===== */
.mismo-zone {
  margin: 12px 0;
  border-radius: 16px;
  border: 2px solid #ec4899;
  padding: 14px;
  background:
    radial-gradient(circle at 10% 0%, #f9a8d4, transparent 35%),
    radial-gradient(circle at 90% 100%, #c4b5fd, transparent 45%),
    linear-gradient(180deg, #4a044e 0%, #701a75 100%);
  color: #fdf4ff;
}

.mismo-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-weight: 700;
}

.mismo-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}

.mismo-card {
  border: 2px solid rgba(244, 114, 182, 0.5);
  border-radius: 12px;
  background: rgba(39, 39, 42, 0.45);
  color: #fff;
  font-weight: 700;
  min-height: 72px;
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.14s ease, background 0.14s ease;
}

.mismo-card:hover {
  transform: translateY(-2px);
  border-color: #f9a8d4;
}

.mismo-card.selected {
  border-color: #22d3ee;
  background: rgba(34, 211, 238, 0.2);
}

.mismo-card.matched {
  border-color: #86efac;
  background: rgba(34, 197, 94, 0.25);
  opacity: 0.85;
}

.mismo-card.wrong {
  border-color: #f87171;
  animation: xouts-shake 0.25s ease;
}

/* ===== X-Outs ===== */
.xouts-zone {
  margin: 12px 0;
  border-radius: 16px;
  border: 2px solid #60a5fa;
  padding: 14px;
  background:
    linear-gradient(180deg, #eff6ff 0%, #dbeafe 100%);
  transition: border-color 0.22s ease, box-shadow 0.22s ease, transform 0.22s ease;
}

.xouts-status {
  font-weight: 700;
  color: #1e3a8a;
  margin-bottom: 8px;
}

.xouts-zone.xouts-solved {
  border-color: #22c55e;
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.2);
  transform: translateY(-1px);
}

.xouts-status.xouts-win {
  color: #166534;
  font-size: 1.08rem;
}

/* ===== Number Paths: stepping-stone trail across Number Harbor's pond =====
   Reskinned to a pond of round stones with a start anchor (⚓) and goal flag
   (🏁) badge, and a rope line traced live between tapped stones. All colors
   come from the shared design tokens so it follows the light/dark theme;
   the tap-to-build-path interaction and grading (npToggle/npTrySubmit) are
   untouched -- only the rendering in npDrawBoard/npRefreshMarks changed. */
.np-zone {
  margin: 12px 0;
  border-radius: 16px;
  border: 2px solid var(--strand-harbor);
  padding: 14px;
  background: linear-gradient(180deg, var(--bubble) 0%, var(--card) 100%);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.np-zone.np-solved {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.18);
}

.np-status {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 12px;
  min-height: 1.4em;
}

.np-board {
  display: inline-block;
  overflow-x: auto;
  max-width: 100%;
}

.np-pond {
  display: inline-block;
  padding: 14px;
  border-radius: 18px;
  background:
    radial-gradient(circle at 15% 15%, var(--bubble), transparent 55%),
    radial-gradient(circle at 85% 85%, var(--bubble), transparent 55%),
    var(--card);
}

/* No padding of its own: sizes exactly to the table so the connector <svg>
   overlay (inset:0) lines up 1:1 with the rendered stone buttons. */
.np-stones-layer {
  position: relative;
  display: inline-block;
}

.np-table {
  position: relative;
  z-index: 2;
  border-collapse: separate;
  border-spacing: 10px;
}

.np-connectors {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  width: 100%;
  height: 100%;
}

.np-rope-line {
  stroke: var(--accent-2);
  stroke-width: 6;
  stroke-linecap: round;
}

.np-cell {
  position: relative;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: radial-gradient(circle at 32% 28%, var(--card) 0%, var(--bubble) 100%);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: var(--btn-shadow);
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.np-cell:hover {
  transform: translateY(-2px);
  border-color: var(--strand-harbor);
}

.np-cell.np-selected {
  background: var(--accent-2);
  color: #2a1400;
  border-color: var(--accent-2);
}

.np-cell.np-start {
  box-shadow: var(--btn-shadow), inset 0 0 0 3px var(--accent);
}

.np-cell.np-end {
  box-shadow: var(--btn-shadow), inset 0 0 0 3px var(--ink);
}

/* Fixed badges for the stones already showing the prompt's printed start/
   target numbers (e.g. "Path: 3 -> 15") -- purely a readability aid, not a
   hint, since those values are unique in the grid by construction. */
.np-cell.np-anchor-start::after,
.np-cell.np-anchor-goal::after {
  position: absolute;
  top: -9px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--card);
  box-shadow: var(--btn-shadow);
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.np-cell.np-anchor-start::after {
  content: "\2693";
  left: -9px;
}

.np-cell.np-anchor-goal::after {
  content: "\1F3C1";
  right: -9px;
}

@media (prefers-color-scheme: dark) {
  .np-cell.np-selected {
    color: #211200;
  }
}

/* ===== Story Logic Grids ===== */
.slg-zone {
  margin: 12px 0;
  border-radius: 16px;
  border: 2px solid #0f766e;
  padding: 14px;
  background: linear-gradient(180deg, #ecfeff 0%, #f0fdfa 100%);
  color: #12343b;
}

.slg-intro {
  font-weight: 700;
  margin-bottom: 10px;
}

.slg-clues {
  background: #ffffff;
  border: 1px solid #99f6e4;
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 12px;
}

.slg-clue-list {
  margin: 0;
  padding-left: 22px;
}

.slg-clue-list li {
  margin: 5px 0;
}

.slg-grid {
  overflow-x: auto;
}

.slg-table {
  width: 100%;
  min-width: 560px;
  border-collapse: separate;
  border-spacing: 0;
  background: #ffffff;
  border: 1px solid #99f6e4;
  border-radius: 12px;
  overflow: hidden;
}

.slg-table th,
.slg-table td {
  padding: 8px;
  border-bottom: 1px solid #ccfbf1;
  text-align: left;
}

.slg-table th {
  background: #ccfbf1;
  color: #134e4a;
  font-weight: 900;
}

.slg-table tbody tr:last-child th,
.slg-table tbody tr:last-child td {
  border-bottom: none;
}

.slg-table select {
  width: 100%;
  min-width: 120px;
  border: 2px solid #99f6e4;
  border-radius: 8px;
  background: #ffffff;
  font-size: 0.96rem;
}

.slg-table select.slg-duplicate {
  border-color: #ef4444;
  background: #fff1f2;
}

.slg-controls {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

.slg-banner {
  min-height: 28px;
  margin-top: 8px;
  font-size: 1.2rem;
  font-weight: 900;
  color: #0f766e;
  text-align: center;
}

.xouts-board {
  display: inline-block;
  overflow-x: auto;
}

.xouts-table {
  border-collapse: separate;
  border-spacing: 6px;
}

.xouts-cell,
.xouts-target {
  width: 48px;
  height: 48px;
  text-align: center;
  border-radius: 10px;
  font-weight: 800;
}

.xouts-cell {
  border: 2px solid #bfdbfe;
  background: #ffffff;
  color: #1f2937;
  cursor: pointer;
  position: relative;
}

.xouts-cell.crossed {
  background: #e5e7eb;
  color: #6b7280;
}

.xouts-cell.crossed::after {
  content: "X";
  position: absolute;
  inset: 0;
  color: #dc2626;
  font-size: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
}

.xouts-target {
  border: 2px solid #93c5fd;
  background: #dbeafe;
  color: #1d4ed8;
}

.xouts-target.ok {
  border-color: #4ade80;
  background: #dcfce7;
  color: #166534;
}

.xouts-target.bad {
  border-color: #f87171;
  background: #fee2e2;
  color: #991b1b;
}

@keyframes xouts-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

/* ===== Factor Ninja Theme ===== */
.fn-zone {
  --fn-bg: #1a1040;
  --fn-accent: #39ff14;
  --fn-gold: #ffd700;
  --fn-orb-glow: #7c3aed;
  --fn-card-bg: #2d1b69;
  --fn-text: #e8e0ff;
  background: linear-gradient(135deg, #1a1040 0%, #2d1b69 50%, #1a1040 100%);
  border-radius: 16px;
  padding: 20px;
  margin: 12px 0;
  color: var(--fn-text);
  position: relative;
  overflow: hidden;
  min-height: 280px;
}

.fn-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.fn-streak {
  font-weight: 700;
  color: var(--fn-gold);
  font-size: 0.95rem;
}

.fn-sub-label {
  font-size: 0.85rem;
  opacity: 0.7;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.fn-hint-btn {
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(167, 139, 250, 0.5);
  color: #f5f3ff;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.fn-hint-btn:hover {
  background: rgba(167, 139, 250, 0.28);
}

.fn-arena {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

/* --- Orb (prime factors mode) --- */
.fn-orb-area {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 120px;
}

.fn-orb {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #a78bfa, var(--fn-orb-glow) 60%, #4c1d95);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  font-weight: 900;
  color: #fff;
  box-shadow: 0 0 30px rgba(124, 58, 237, 0.6), 0 0 60px rgba(124, 58, 237, 0.3);
  animation: fn-pulse 2s ease-in-out infinite;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.fn-orb.fn-orb-split {
  animation: fn-slash 0.4s ease-out;
}

.fn-orb.fn-orb-shake {
  animation: fn-shake 0.4s ease-out;
}

.fn-orb.fn-orb-done {
  background: radial-gradient(circle at 35% 35%, #86efac, #22c55e 60%, #15803d);
  box-shadow: 0 0 30px rgba(34, 197, 94, 0.6), 0 0 60px rgba(34, 197, 94, 0.3);
  animation: fn-pulse 1s ease-in-out infinite;
}

/* --- Collected factor tray --- */
.fn-tray {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  min-height: 36px;
}

.fn-factor-chip {
  background: var(--fn-accent);
  color: #111;
  padding: 6px 14px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 1.1rem;
  animation: fn-chip-in 0.35s ease-out;
}

/* --- Prime buttons (throwing stars) --- */
.fn-primes {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.fn-prime-btn {
  width: 56px;
  height: 56px;
  border: none;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 30%, #fde68a, #f59e0b 70%, #b45309);
  color: #1a1040;
  font-size: 1.2rem;
  font-weight: 900;
  cursor: pointer;
  position: relative;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.4);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.fn-prime-btn::before {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0%, #fbbf24 12.5%, transparent 25%,
    #fbbf24 37.5%, transparent 50%, #fbbf24 62.5%, transparent 75%, #fbbf24 87.5%, transparent 100%);
  opacity: 0.35;
  z-index: -1;
}

.fn-prime-btn:hover {
  transform: scale(1.15);
  box-shadow: 0 4px 16px rgba(245, 158, 11, 0.7);
}

.fn-prime-btn:active {
  transform: scale(0.95);
}

/* --- GCF/LCM cards --- */
.fn-cards {
  display: flex;
  gap: 20px;
  justify-content: center;
  flex-wrap: wrap;
}

.fn-num-card {
  background: var(--fn-card-bg);
  border: 2px solid rgba(139, 92, 246, 0.4);
  border-radius: 14px;
  padding: 16px 24px;
  text-align: center;
  min-width: 140px;
}

.fn-num-card .fn-big-num {
  font-size: 2.4rem;
  font-weight: 900;
  color: #fff;
}

.fn-num-card .fn-factor-list {
  margin-top: 8px;
  display: flex;
  gap: 4px;
  justify-content: center;
  flex-wrap: wrap;
}

.fn-num-card .fn-mini-chip {
  background: rgba(139, 92, 246, 0.3);
  border: 1px solid rgba(139, 92, 246, 0.5);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.85rem;
}

/* --- Keypad (GCF/LCM) --- */
.fn-keypad {
  display: grid;
  grid-template-columns: repeat(3, 64px);
  gap: 8px;
  justify-content: center;
}

.fn-key {
  width: 64px;
  height: 52px;
  border: 2px solid rgba(139, 92, 246, 0.4);
  border-radius: 10px;
  background: var(--fn-card-bg);
  color: var(--fn-text);
  font-size: 1.3rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.fn-key:hover {
  background: #4c1d95;
  border-color: var(--fn-accent);
}

.fn-key.fn-key-action {
  background: #4c1d95;
  font-size: 0.9rem;
}

.fn-key.fn-key-go {
  background: #15803d;
  border-color: var(--fn-accent);
  color: var(--fn-accent);
}

.fn-keypad-display {
  grid-column: 1 / -1;
  background: rgba(0, 0, 0, 0.3);
  border: 2px solid rgba(139, 92, 246, 0.3);
  border-radius: 10px;
  padding: 10px;
  text-align: right;
  font-size: 1.6rem;
  font-weight: 700;
  color: #fff;
  min-height: 46px;
}

/* --- Hint area --- */
.fn-hint-area {
  font-size: 0.9rem;
  opacity: 0.7;
  text-align: center;
  min-height: 20px;
}

/* --- Victory banner --- */
.fn-banner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  font-size: 2rem;
  font-weight: 900;
  color: var(--fn-accent);
  text-shadow: 0 0 20px rgba(57, 255, 20, 0.5);
  pointer-events: none;
  z-index: 10;
  white-space: nowrap;
}

.fn-banner.fn-banner-show {
  animation: fn-banner-pop 0.5s ease-out forwards;
}

/* --- Particles --- */
.fn-particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  overflow: hidden;
}

.fn-particle {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  animation: fn-particle-fly 0.8s ease-out forwards;
}

/* ===== Keyframe Animations ===== */
@keyframes fn-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

@keyframes fn-slash {
  0% { transform: scale(1); clip-path: inset(0); }
  30% { transform: scale(1.1); clip-path: inset(0 50% 0 0); }
  60% { transform: scale(0.9); opacity: 0.6; }
  100% { transform: scale(1); opacity: 1; clip-path: inset(0); }
}

@keyframes fn-shake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-8px); }
  30% { transform: translateX(8px); }
  45% { transform: translateX(-6px); }
  60% { transform: translateX(6px); }
  75% { transform: translateX(-3px); }
  90% { transform: translateX(3px); }
}

@keyframes fn-chip-in {
  0% { transform: scale(0) translateY(-20px); opacity: 0; }
  60% { transform: scale(1.2) translateY(0); }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

@keyframes fn-banner-pop {
  0% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
  60% { transform: translate(-50%, -50%) scale(1.15); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

@keyframes fn-particle-fly {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { opacity: 0; }
}

/* Smooth transition between puzzles */
.fn-arena.fn-fade-out {
  animation: fn-fade 0.25s ease-out forwards;
}

@keyframes fn-fade {
  0% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(10px); }
}

/* Wrong answer flash for keypad */
.fn-keypad-display.fn-wrong {
  animation: fn-wrong-flash 0.4s ease-out;
}

@keyframes fn-wrong-flash {
  0%, 100% { border-color: rgba(139, 92, 246, 0.3); }
  25% { border-color: #ef4444; background: rgba(239, 68, 68, 0.2); }
  75% { border-color: #ef4444; }
}

/* ===== KenKen Theme ===== */
.kk-zone {
  background: linear-gradient(135deg, #1e3a5f 0%, #0f2940 100%);
  border-radius: 16px;
  padding: 20px;
  margin: 12px 0;
  color: #e0f0ff;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.kk-grid {
  display: inline-grid;
  gap: 0;
  background: #0a1929;
  border: 3px solid #4fc3f7;
  border-radius: 4px;
}

.kk-cell {
  width: var(--kk-cell, 52px);
  height: var(--kk-cell, 52px);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  transition: background 0.15s;
  border: 1px solid rgba(79, 195, 247, 0.2);
}

.kk-cell:hover {
  background: rgba(79, 195, 247, 0.15);
}

.kk-cell.kk-selected {
  background: rgba(79, 195, 247, 0.25);
  box-shadow: inset 0 0 0 2px #4fc3f7;
}

.kk-cell.kk-correct {
  background: rgba(34, 197, 94, 0.25);
}

.kk-cell.kk-wrong {
  background: rgba(239, 68, 68, 0.25);
}

.kk-cage-label {
  position: absolute;
  top: 2px;
  left: 4px;
  font-size: 0.65rem;
  font-weight: 600;
  color: #90caf9;
  pointer-events: none;
}

/* Cage borders: thick borders on edges where adjacent cells belong to different cages */
.kk-cell.kk-border-top { border-top: 2.5px solid #4fc3f7; }
.kk-cell.kk-border-bottom { border-bottom: 2.5px solid #4fc3f7; }
.kk-cell.kk-border-left { border-left: 2.5px solid #4fc3f7; }
.kk-cell.kk-border-right { border-right: 2.5px solid #4fc3f7; }

.kk-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.kk-numpad {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 100%;
}

.kk-numpad button {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  border: 2px solid rgba(79, 195, 247, 0.4);
  background: #0a1929;
  color: #e0f0ff;
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.kk-numpad button:hover {
  background: #1e3a5f;
  border-color: #4fc3f7;
}

.kk-check-btn {
  padding: 10px 24px;
  border-radius: 10px;
  background: #15803d;
  color: #fff;
  font-weight: 700;
  border: none;
  cursor: pointer;
  font-size: 1rem;
}

.kk-check-btn:hover { background: #22c55e; }

.kk-banner {
  font-size: 1.5rem;
  font-weight: 900;
  color: #4fc3f7;
  min-height: 32px;
  text-align: center;
}

/* ===== Balance Scale Theme ===== */
.bs-zone {
  background: linear-gradient(135deg, #2d1b4e 0%, #1a0f2e 100%);
  border-radius: 16px;
  padding: 20px;
  margin: 12px 0;
  color: #e8d5ff;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.bs-scale {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 0;
  width: 100%;
  max-width: 500px;
  height: 140px;
  position: relative;
  transform-origin: 50% 92%;
  transition: transform 0.22s ease;
}

.bs-pan {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  align-items: flex-end;
  padding: 10px;
  min-height: 80px;
  border-bottom: 4px solid #a78bfa;
  position: relative;
  transition: transform 0.22s ease, border-bottom-color 0.22s ease;
}

.bs-fulcrum {
  width: 0;
  height: 0;
  border-left: 20px solid transparent;
  border-right: 20px solid transparent;
  border-bottom: 30px solid #a78bfa;
  align-self: flex-end;
  flex-shrink: 0;
}

.bs-term {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 1.2rem;
}

.bs-term-var {
  background: linear-gradient(135deg, #7c3aed, #a78bfa);
  color: #fff;
}

.bs-term-const {
  background: linear-gradient(135deg, #f59e0b, #fbbf24);
  color: #1a0f2e;
}

.bs-term-op {
  font-size: 1.2rem;
  color: #a78bfa;
  font-weight: 700;
}

.bs-equation {
  font-size: 1.6rem;
  font-weight: 900;
  color: #fff;
  text-align: center;
  letter-spacing: 1px;
}

.bs-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bs-label {
  font-size: 1.4rem;
  font-weight: 700;
  color: #a78bfa;
}

.bs-keypad {
  display: grid;
  grid-template-columns: repeat(5, 48px);
  gap: 6px;
}

.bs-keypad button {
  width: 48px;
  height: 42px;
  border-radius: 8px;
  border: 2px solid rgba(167, 139, 250, 0.4);
  background: #2d1b4e;
  color: #e8d5ff;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}

.bs-keypad button:hover {
  background: #4c1d95;
  border-color: #a78bfa;
}

.bs-keypad button.bs-key-go {
  background: #15803d;
  border-color: #22c55e;
  color: #fff;
}

.bs-keypad button.bs-key-action {
  background: #4c1d95;
  font-size: 0.85rem;
}

.bs-display {
  grid-column: 1 / -1;
  background: rgba(0, 0, 0, 0.3);
  border: 2px solid rgba(167, 139, 250, 0.3);
  border-radius: 8px;
  padding: 8px;
  text-align: right;
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
  min-height: 40px;
}

.bs-display.bs-wrong {
  animation: fn-wrong-flash 0.4s ease-out;
}

.bs-banner {
  font-size: 1.5rem;
  font-weight: 900;
  color: #a78bfa;
  min-height: 32px;
  text-align: center;
}

.bs-scale.bs-balanced .bs-pan { border-bottom-color: #22c55e; }
.bs-scale.bs-balanced .bs-fulcrum { border-bottom-color: #22c55e; }
.bs-scale.bs-tip-left { transform: rotate(-6deg); }
.bs-scale.bs-tip-right { transform: rotate(6deg); }
.bs-scale.bs-tip-left .bs-left { transform: translateY(10px); }
.bs-scale.bs-tip-left .bs-right { transform: translateY(-6px); }
.bs-scale.bs-tip-right .bs-right { transform: translateY(10px); }
.bs-scale.bs-tip-right .bs-left { transform: translateY(-6px); }

/* ===== Shikaku Theme ===== */
.sk-zone {
  background: linear-gradient(135deg, #0c3b2e 0%, #081f18 100%);
  border-radius: 16px;
  padding: 20px;
  margin: 12px 0;
  color: #c8f7dc;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.sk-grid-wrap {
  position: relative;
  cursor: crosshair;
}

.sk-grid-wrap canvas {
  border: 3px solid #34d399;
  border-radius: 4px;
  display: block;
  touch-action: none;
}

.sk-controls {
  display: flex;
  gap: 10px;
}

.sk-controls button {
  padding: 8px 18px;
  border-radius: 8px;
  border: 2px solid rgba(52, 211, 153, 0.4);
  background: #0c3b2e;
  color: #c8f7dc;
  font-weight: 700;
  cursor: pointer;
  font-size: 0.95rem;
  transition: background 0.15s;
}

.sk-controls button:hover {
  background: #15803d;
  border-color: #34d399;
}

.sk-check-btn { background: #15803d !important; color: #fff !important; }

.sk-banner {
  font-size: 1.5rem;
  font-weight: 900;
  color: #34d399;
  min-height: 32px;
  text-align: center;
}

/* ===== Angle Chase Studio Theme ===== */
.acs-zone {
  background: linear-gradient(135deg, #111a35 0%, #050914 100%);
  border-radius: 16px;
  padding: 20px;
  margin: 12px 0;
  color: #cbd5f5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.acs-svg-wrap {
  width: 100%;
  max-width: 480px;
  border: 3px solid #334155;
  border-radius: 10px;
  background: radial-gradient(circle at 50% 0%, #16213f 0%, #0a0f1f 100%);
}

.acs-svg {
  width: 100%;
  height: auto;
  display: block;
}

.acs-line {
  stroke: #93c5fd;
  stroke-width: 2.5;
  stroke-linecap: round;
}

.acs-circle {
  fill: none;
  stroke: #64748b;
  stroke-width: 2;
}

.acs-arc {
  fill: none;
  stroke: rgba(203, 213, 245, 0.28);
  stroke-width: 2;
}

.acs-arc-given {
  fill: none;
  stroke: #38bdf8;
  stroke-width: 3;
}

.acs-arc-target {
  fill: none;
  stroke: #fbbf24;
  stroke-width: 3.5;
  filter: drop-shadow(0 0 3px rgba(251, 191, 36, 0.6));
}

.acs-vertex-dot {
  fill: #e2e8f0;
}

.acs-label {
  fill: #e2e8f0;
  font-size: 15px;
  font-weight: 700;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
}

.acs-label-given {
  fill: #7dd3fc;
}

.acs-label-target {
  fill: #fbbf24;
  font-size: 17px;
}

.acs-point-label {
  fill: #f1f5f9;
  font-size: 15px;
  font-weight: 700;
  font-style: italic;
  font-family: "Cambria Math", "Times New Roman", Georgia, serif;
  paint-order: stroke;
  stroke: rgba(15, 23, 42, 0.85);
  stroke-width: 3px;
}

.acs-legend {
  display: flex;
  gap: 18px;
  font-size: 0.85rem;
  font-weight: 700;
}

.acs-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.acs-legend .acs-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}

.acs-legend .acs-swatch-given { background: #38bdf8; }
.acs-legend .acs-swatch-target { background: #fbbf24; }

/* ===== Counting Lab Theme ===== */
.cl-zone {
  background: linear-gradient(135deg, #062521 0%, #08130f 100%);
  border-radius: 16px;
  padding: 20px;
  margin: 12px 0;
  color: #d1fae5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.cl-diagram {
  width: 100%;
  overflow-x: auto;
  display: flex;
  justify-content: center;
}

.cl-chain-row,
.cl-cases-row,
.cl-pigeonhole-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.cl-slot {
  background: radial-gradient(circle at 30% 20%, #134e3f 0%, #0a2e25 100%);
  border: 2px solid #2dd4bf;
  border-radius: 10px 10px 16px 16px;
  min-width: 76px;
  padding: 10px 8px;
  text-align: center;
  box-shadow: 0 0 8px rgba(45, 212, 191, 0.25);
}

.cl-slot-count {
  font-size: 1.4rem;
  font-weight: 800;
  color: #5eead4;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
}

.cl-slot-label {
  font-size: 0.7rem;
  color: #a7f3d0;
  margin-top: 4px;
  word-break: break-word;
}

.cl-op {
  font-size: 1.5rem;
  font-weight: 800;
  color: #fbbf24;
}

.cl-case {
  border: 2px dashed #34d399;
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.cl-case-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: #fde68a;
}

.cl-hole {
  background: #0a2e25;
  border: 2px solid #5eead4;
  border-radius: 14px;
  min-width: 78px;
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 0.65rem;
  text-align: center;
  color: #a7f3d0;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.15s ease;
}
.cl-hole:hover { box-shadow: 0 0 10px rgba(94, 234, 212, 0.4); }
.cl-hole:active { transform: scale(0.96); }
.cl-hole-name { font-weight: 700; color: #a7f3d0; }
.cl-hole-dots { font-size: 0.9rem; color: #5eead4; letter-spacing: 1px; min-height: 1em; }
.cl-hole-count { color: #fde68a; font-weight: 700; }
.cl-hole-flash { animation: cl-flash 0.26s ease; border-color: #fca5a5; }
@keyframes cl-flash { 0%, 100% { background: #0a2e25; } 50% { background: #4c1d1d; } }

.cl-pigeonhole-note {
  font-size: 0.85rem;
  color: #fde68a;
  font-weight: 700;
  text-align: center;
}

.cl-legend {
  font-size: 0.8rem;
  color: #a7f3d0;
  text-align: center;
  max-width: 420px;
}

/* Interactive count builder */
.cl-station {
  background: radial-gradient(circle at 30% 20%, #134e3f 0%, #0a2e25 100%);
  border: 2px solid #2dd4bf;
  border-radius: 10px 10px 16px 16px;
  min-width: 92px;
  max-width: 150px;
  padding: 8px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 0 8px rgba(45, 212, 191, 0.2);
}
.cl-station-done {
  border-color: #fbbf24;
  box-shadow: 0 0 12px rgba(251, 191, 36, 0.45);
}
.cl-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: center;
}
.cl-chip {
  background: #0a2e25;
  border: 1px solid #34d399;
  color: #d1fae5;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 0.72rem;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.12s ease;
}
.cl-chip:hover { background: #145a49; }
.cl-chip:active { transform: scale(0.94); }
.cl-chip-picked {
  background: #fbbf24;
  color: #0a2e25;
  border-color: #fbbf24;
  font-weight: 800;
}
.cl-chip-dim { opacity: 0.35; }
.cl-chip:disabled { cursor: default; }

.cl-runtotal {
  font-size: 0.95rem;
  font-weight: 700;
  color: #fde68a;
  text-align: center;
  background: rgba(10, 46, 37, 0.7);
  border-radius: 8px;
  padding: 8px 12px;
  min-width: 240px;
}

.cl-grouping {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  max-width: 460px;
}
.cl-grouping-q {
  font-size: 0.85rem;
  color: #d1fae5;
  text-align: center;
}
.cl-group-btn {
  background: #0d9488;
  color: #ecfeff;
  border: none;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
}
.cl-group-btn:hover { background: #0f766e; }
.cl-group-btn-alt { background: #334155; }
.cl-group-btn-alt:hover { background: #475569; }

.cl-case-done .cl-case-label { color: #fbbf24; }

.cl-finish {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.cl-finish-total {
  font-size: 1.1rem;
  font-weight: 800;
  color: #5eead4;
}
.cl-finish-btn {
  background: #f59e0b;
  color: #0a2e25;
  border: none;
  border-radius: 999px;
  padding: 9px 22px;
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
}
.cl-finish-btn:hover { background: #fbbf24; }
.cl-finish-note { font-size: 0.75rem; color: #a7f3d0; }

/* ===== Proof Blocks ===== */
.pb-zone {
  background: linear-gradient(135deg, #1e1b3a 0%, #0f0d20 100%);
  border-radius: 16px;
  padding: 18px;
  margin: 12px 0;
  color: #e6e2ff;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.pb-goal {
  font-weight: 800;
  font-size: 1.05rem;
  text-align: center;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(167, 139, 250, 0.15);
  border: 1px solid rgba(167, 139, 250, 0.5);
  color: #f5f3ff;
}

.pb-diagram {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.pb-diagram-wrap {
  width: 100%;
  max-width: 440px;
  border: 3px solid #4c4680;
  border-radius: 10px;
  background: radial-gradient(circle at 50% 0%, #241f45 0%, #12102a 100%);
}

.pb-svg {
  width: 100%;
  height: auto;
  display: block;
}

.pb-diagram-legend {
  display: flex;
  gap: 18px;
  font-size: 0.82rem;
  font-weight: 700;
  color: #c4b5fd;
}

.pb-diagram-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.pb-diagram-legend .pb-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}

.pb-diagram-legend .pb-swatch-given { background: #38bdf8; }
.pb-diagram-legend .pb-swatch-target { background: #fbbf24; }

.pb-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.pb-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.pb-col-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  color: #c4b5fd;
}

.pb-bank,
.pb-proof {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 80px;
  padding: 8px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px dashed rgba(196, 181, 253, 0.35);
}

.pb-empty {
  font-size: 0.82rem;
  color: #a5a0c9;
  font-style: italic;
  text-align: center;
  padding: 14px 6px;
}

.pb-chip {
  position: relative;
  border-radius: 10px;
  padding: 9px 11px;
  background: #2c2850;
  border: 1px solid #4c4680;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

.pb-chip-given {
  background: #14352e;
  border-color: #2f855a;
}

.pb-chip-goal {
  background: #3a2340;
  border-color: #c026d3;
}

.pb-clickable {
  cursor: pointer;
  transition: transform 0.08s ease, border-color 0.12s ease;
}

.pb-clickable:hover {
  transform: translateY(-1px);
  border-color: #a78bfa;
}

.pb-chip-meta {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 800;
  color: #c4b5fd;
  margin-bottom: 2px;
}

.pb-chip-given .pb-chip-meta {
  color: #86efac;
}

.pb-chip-goal .pb-chip-meta {
  color: #f0abfc;
}

.pb-chip-statement {
  font-size: 0.95rem;
  font-weight: 700;
  color: #f8f7ff;
  line-height: 1.3;
}

.pb-chip-reason {
  font-size: 0.78rem;
  color: #b9b4dd;
  margin-top: 3px;
  line-height: 1.25;
}

/* ===== Potion Panic ===== */
.pp-zone {
  background: linear-gradient(135deg, #2a0f3d 0%, #12071f 100%);
  border-radius: 16px;
  padding: 20px;
  margin: 12px 0;
  color: #f3e8ff;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.pp-cauldron-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.pp-cauldron-wrap {
  position: relative;
  width: 140px;
  height: 220px;
}

.pp-cauldron {
  position: relative;
  width: 140px;
  height: 220px;
  border-radius: 12px 12px 50px 50px;
  border: 3px solid #a855f7;
  background: radial-gradient(circle at 30% 15%, #3b1a55 0%, #1a0b29 100%);
  overflow: hidden;
  box-shadow: 0 0 18px rgba(168, 85, 247, 0.35) inset, 0 0 10px rgba(168, 85, 247, 0.25);
}

.pp-fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 0%;
  background: linear-gradient(180deg, #34d399 0%, #059669 65%, #047857 100%);
  transition: height 0.35s ease, background 0.25s ease;
  box-shadow: 0 -2px 10px rgba(52, 211, 153, 0.6);
}

.pp-fill.pp-fill-overflow {
  background: linear-gradient(180deg, #f87171 0%, #dc2626 65%, #991b1b 100%);
  box-shadow: 0 -2px 10px rgba(248, 113, 113, 0.7);
}

.pp-target-line {
  position: absolute;
  left: -6px;
  right: -6px;
  bottom: 0%;
  height: 2px;
  background: #fbbf24;
  box-shadow: 0 0 6px rgba(251, 191, 36, 0.85);
  z-index: 2;
}

.pp-target-label {
  position: absolute;
  right: -8px;
  bottom: 0%;
  transform: translate(100%, 50%);
  font-size: 0.72rem;
  font-weight: 800;
  color: #fbbf24;
  white-space: nowrap;
}

.pp-total {
  font-size: 1rem;
  font-weight: 800;
  color: #fef3c7;
  text-align: center;
}

.pp-jugs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  max-width: 480px;
}

.pp-jug {
  background: radial-gradient(circle at 30% 20%, #6d28d9 0%, #3b0764 100%);
  border: 2px solid #c084fc;
  border-radius: 10px 10px 18px 18px;
  color: #f3e8ff;
  min-width: 68px;
  padding: 10px 12px;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.15s ease;
}

.pp-jug:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(192, 132, 252, 0.45);
}

.pp-jug:active:not(:disabled) { transform: scale(0.95); }

.pp-jug:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pp-log-wrap {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}

.pp-log-label {
  font-size: 0.78rem;
  color: #d8b4fe;
}

.pp-log {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  min-height: 30px;
}

.pp-log-chip {
  background: #4c1d95;
  border: 1px solid #c084fc;
  color: #f3e8ff;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.pp-log-chip:hover { background: #5b21b6; }

.pp-controls {
  display: flex;
  gap: 10px;
}

.pp-clear-btn {
  background: transparent;
  border: 1px solid #c084fc;
  color: #e9d5ff;
  border-radius: 999px;
  padding: 6px 16px;
  font-size: 0.82rem;
  cursor: pointer;
}

.pp-clear-btn:hover { background: rgba(192, 132, 252, 0.15); }

.pp-banner {
  min-height: 1.2em;
  font-size: 0.9rem;
  font-weight: 700;
  text-align: center;
  color: #fde68a;
}

.pp-banner.pp-banner-overflow { color: #fca5a5; }
.pp-banner.pp-banner-success { color: #86efac; }

.pb-placed {
  padding-right: 12px;
}

.pb-chip-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

.pb-step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #a78bfa;
  color: #1e1b3a;
  font-weight: 800;
  font-size: 0.78rem;
}

.pb-move,
.pb-remove {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 1px solid #4c4680;
  background: #1e1b3a;
  color: #e6e2ff;
  font-weight: 800;
  cursor: pointer;
  line-height: 1;
}

.pb-move:disabled {
  opacity: 0.35;
  cursor: default;
}

.pb-remove {
  margin-left: auto;
  border-color: #7f1d4b;
  color: #fda4c7;
}

.pb-move:not(:disabled):hover,
.pb-remove:hover {
  border-color: #a78bfa;
}

.pb-controls {
  display: flex;
  gap: 10px;
  justify-content: center;
}

#proofBlocksCheckBtn {
  background: #7c3aed;
  color: #fff;
  border: none;
  padding: 9px 20px;
  border-radius: 10px;
  font-weight: 800;
  cursor: pointer;
}

#proofBlocksClearBtn {
  background: transparent;
  color: #c4b5fd;
  border: 1px solid #4c4680;
  padding: 9px 16px;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
}

.pb-banner {
  min-height: 24px;
  text-align: center;
  font-weight: 700;
  color: #f0abfc;
  line-height: 1.35;
}

@media (max-width: 640px) {
  .pb-columns {
    grid-template-columns: 1fr;
  }
}

/* ===== Progress display ===== */
#progress {
  font-size: 0.85rem;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
  max-height: 360px;
  overflow-y: auto;
}

/* ===== Mobile responsive ===== */
@media (max-width: 520px) {
  .card {
    padding: 12px;
  }

  /* Login row: name input and grade select fill available space */
  #name {
    flex: 1 1 120px;
    min-width: 0;
  }
  #gradeBand {
    flex: 1 1 100px;
    min-width: 0;
  }

  /* Puzzle controls: game selector and Start button go full width */
  #puzzleControlsRow > select,
  #puzzleControlsRow > #newPuzzleBtn {
    width: 100%;
    flex: 0 0 100%;
  }

  /* Difficulty stepper stays compact, pill floats right */
  #puzzleControlsRow > #difficultyLabel {
    margin-left: auto;
  }

  /* Answer input stretches */
  #answer {
    flex: 1 1 120px;
    min-width: 0;
  }

  /* Progress font slightly smaller */
  #progress {
    font-size: 0.78rem;
  }
}

/* ===== Reasoning capture panel ("Explain your thinking") ===== */
.reasoning-panel {
  margin-top: 12px;
  border: 2px dashed #f0d7a5;
  border-radius: 14px;
  background: linear-gradient(180deg, #fffdf7 0%, #fff4dd 100%);
  padding: 4px 12px;
}

.reasoning-summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--accent);
  list-style: none;
  padding: 8px 2px;
  user-select: none;
}

.reasoning-summary::-webkit-details-marker {
  display: none;
}

.reasoning-summary::before {
  content: "▸ ";
  display: inline-block;
  transition: transform 0.15s ease;
}

.reasoning-panel[open] .reasoning-summary::before {
  content: "▾ ";
}

.reasoning-body {
  display: grid;
  gap: 12px;
  padding: 4px 2px 12px;
}

.reasoning-field {
  display: grid;
  gap: 6px;
}

.reasoning-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
}

.reasoning-textarea {
  width: 100%;
  resize: vertical;
  font-family: inherit;
  font-size: 0.95rem;
  padding: 10px 12px;
  border-radius: 10px;
  border: 2px solid #e6cfa0;
  background: #fffdf7;
  color: var(--ink);
}

.reasoning-textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.reasoning-note {
  margin: 0;
  font-size: 0.8rem;
}

/* Explanation-quality feedback: friendly, additive, never a grade/number. */
.explanation-feedback {
  margin-top: 12px;
  border: 2px solid #cdeee9;
  border-radius: 14px;
  background: linear-gradient(180deg, #f2fbf9 0%, #e7f7f3 100%);
  padding: 10px 14px;
  animation: xf-pop 0.25s ease;
}

@keyframes xf-pop {
  from { transform: scale(0.97); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.explanation-feedback .xf-title {
  font-weight: 800;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  color: var(--accent);
  text-transform: uppercase;
}

.explanation-feedback .xf-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 2px;
}

.explanation-feedback .xf-badge {
  display: inline-block;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent);
  background: #ffffff;
  border: 2px solid #b9e6de;
  border-radius: 999px;
  padding: 3px 10px;
}

.explanation-feedback .xf-note {
  margin: 6px 0 0;
  font-size: 0.9rem;
  color: var(--ink);
}

/* ===== Chocolate Snap Theme ===== */
.cs-zone {
  background: linear-gradient(135deg, #3b2313 0%, #1c1108 100%);
  border-radius: 16px;
  padding: 20px;
  margin: 12px 0;
  color: #f5e3c8;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.cs-expression {
  font-size: 1.05rem;
  font-weight: 700;
  color: #ffd27a;
  text-align: center;
}

.cs-board {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto 1fr;
  gap: 4px;
  max-width: 100%;
}

.cs-corner {
  grid-column: 1;
  grid-row: 1;
}

.cs-col-headers {
  grid-column: 2;
  grid-row: 1;
  display: grid;
  gap: 2px;
}

.cs-row-headers {
  grid-column: 1;
  grid-row: 2;
  display: grid;
  gap: 2px;
}

.cs-grid {
  grid-column: 2;
  grid-row: 2;
  display: grid;
  gap: 2px;
  background: #170d06;
  border: 3px solid #8a5a2b;
  border-radius: 6px;
  padding: 3px;
}

.cs-header-btn {
  min-width: 28px;
  min-height: 28px;
  padding: 4px 6px;
  border-radius: 6px;
  border: 2px solid rgba(255, 210, 122, 0.35);
  background: #2a1608;
  color: #f5e3c8;
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.cs-header-btn:hover {
  border-color: #ffd27a;
}

.cs-header-btn.active {
  background: #8a5a2b;
  border-color: #ffd27a;
  color: #1c1108;
}

.cs-cell {
  min-width: 24px;
  min-height: 24px;
  width: 100%;
  height: 100%;
  border-radius: 3px;
  transition: background 0.15s;
}

.cs-cell-plain {
  background: repeating-linear-gradient(45deg, #4a2c14 0, #4a2c14 6px, #3b2313 6px, #3b2313 12px);
  border: 1px solid #241407;
}

.cs-cell-col {
  background: #6b4322;
  border: 1px solid #8a5a2b;
}

.cs-cell-row {
  background: #a9702f;
  border: 1px solid #c4863d;
}

.cs-cell-overlap {
  background: #ffd27a;
  border: 1px solid #fff2cf;
  box-shadow: inset 0 0 0 2px rgba(28, 17, 8, 0.35);
}

.cs-readout {
  font-size: 0.95rem;
  text-align: center;
  color: #f5e3c8;
}

.cs-controls {
  display: flex;
  gap: 10px;
}

.cs-controls button {
  padding: 8px 18px;
  border-radius: 8px;
  border: 2px solid rgba(255, 210, 122, 0.4);
  background: #3b2313;
  color: #f5e3c8;
  font-weight: 700;
  cursor: pointer;
  font-size: 0.95rem;
  transition: background 0.15s;
}

.cs-controls button:hover {
  background: #8a5a2b;
  border-color: #ffd27a;
}

.cs-check-btn { background: #b8722f !important; color: #1c1108 !important; }

.cs-banner {
  font-size: 1.4rem;
  font-weight: 900;
  color: #ffd27a;
  min-height: 30px;
  text-align: center;
}

/* ===== Lily Leap ===== */
.ll-zone {
  margin: 12px 0;
  border-radius: 16px;
  border: 2px solid #0891b2;
  padding: 14px;
  background:
    radial-gradient(circle at 0% 0%, #a5f3fc, transparent 35%),
    radial-gradient(circle at 100% 100%, #bbf7d0, transparent 40%),
    linear-gradient(180deg, #ecfeff 0%, #cffafe 100%);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.ll-zone.ll-solved {
  border-color: #0d9488;
  box-shadow: 0 0 0 4px rgba(8, 145, 178, 0.2);
}

.ll-zone.ll-splashed {
  border-color: #dc2626;
  box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.18);
}

.ll-status {
  font-weight: 700;
  color: #0e7490;
  margin-bottom: 12px;
  min-height: 1.4em;
}

.ll-zone.ll-splashed .ll-status {
  color: #b91c1c;
}

.ll-line {
  position: relative;
  margin: 34px 4px 42px;
}

.ll-track {
  position: relative;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, #67e8f9, #0891b2);
  box-shadow: inset 0 0 0 2px rgba(8, 145, 178, 0.35);
}

.ll-start-mark {
  position: absolute;
  top: -6px;
  width: 4px;
  height: 22px;
  background: #0e7490;
  border-radius: 2px;
  transform: translateX(-2px);
}

.ll-pad {
  position: absolute;
  top: -13px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #86efac, #16a34a);
  border: 2px solid #15803d;
  transform: translateX(-15px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.ll-pad-label {
  position: absolute;
  top: 34px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.78rem;
  font-weight: 700;
  color: #14532d;
  white-space: nowrap;
  background: #ffffffcc;
  border-radius: 6px;
  padding: 1px 5px;
}

.ll-frog {
  position: absolute;
  top: -30px;
  transform: translateX(-16px);
  font-size: 1.6rem;
  line-height: 1;
  transition: left 0.35s ease;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.25));
}

.ll-tray {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.ll-jump-btn {
  padding: 10px 16px;
  border-radius: 12px;
  border: 2px solid #0e7490;
  background: #ffffff;
  color: #0e7490;
  font-size: 1.05rem;
  font-weight: 800;
  cursor: pointer;
}

.ll-jump-btn:hover {
  background: linear-gradient(180deg, #22d3ee 0%, #06b6d4 100%);
  color: #ffffff;
}

.ll-controls {
  margin-bottom: 8px;
}

.ll-undo-btn {
  padding: 8px 14px;
  border-radius: 10px;
  border: 2px solid #b45309;
  background: #fff7ed;
  color: #9a3412;
  font-weight: 700;
  cursor: pointer;
}

.ll-undo-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.ll-path {
  font-size: 0.88rem;
  color: #0e7490;
  min-height: 1.2em;
}

/* ===== Pattern Train: a friendly engine + numbered cars on a rail =====
   The engine and rail are decorative; each sequence value is a "car" and
   the masked value renders as a dashed, gently bobbing car with a "?"
   window. The three answer choices render below as small tappable cars --
   tapping one fills the gap's window and submits through the exact same
   answer flow the generic #choiceButtons used (see ptChooseCar in app.js).
   All colors use the shared design tokens so the theme follows light/dark. */
.pt-zone {
  margin: 12px 0;
  border-radius: 16px;
  border: 2px solid var(--strand-harbor);
  padding: 16px 14px 20px;
  background: linear-gradient(180deg, var(--card) 0%, var(--bubble) 100%);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.pt-zone.pt-solved {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.18);
}

.pt-status {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 14px;
  min-height: 1.4em;
}

.pt-track {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  padding: 12px 8px 28px;
  margin-bottom: 4px;
  overflow-x: auto;
  position: relative;
}

/* The rail beneath the train. */
.pt-track::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 12px;
  height: 4px;
  border-radius: 2px;
  background: repeating-linear-gradient(90deg, var(--line) 0 14px, transparent 14px 22px);
}

.pt-engine {
  position: relative;
  width: 60px;
  height: 66px;
  flex-shrink: 0;
}

.pt-engine-cab {
  position: absolute;
  bottom: 10px;
  left: 0;
  width: 60px;
  height: 42px;
  border-radius: 14px 14px 8px 8px;
  background: linear-gradient(180deg, var(--accent-2) 0%, var(--strand-summit) 100%);
  box-shadow: var(--btn-shadow);
}

.pt-engine-cab::before {
  content: "";
  position: absolute;
  top: 8px;
  left: 10px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--bubble);
  border: 3px solid var(--card);
}

.pt-engine-cab::after {
  content: "";
  position: absolute;
  bottom: -8px;
  left: 8px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--ink);
  box-shadow: 28px 0 0 var(--ink);
}

.pt-engine-stack {
  position: absolute;
  bottom: 44px;
  right: 8px;
  width: 11px;
  height: 20px;
  border-radius: 4px 4px 2px 2px;
  background: var(--ink-soft);
}

.pt-engine-stack::before {
  content: "";
  position: absolute;
  top: -12px;
  left: -4px;
  width: 16px;
  height: 12px;
  border-radius: 50%;
  background: var(--card);
  opacity: 0.85;
  animation: pt-puff 2.6s ease-in-out infinite;
}

@keyframes pt-puff {
  0% { transform: translateY(0) scale(0.85); opacity: 0.85; }
  60% { transform: translateY(-14px) scale(1.15); opacity: 0.15; }
  100% { transform: translateY(-14px) scale(1.15); opacity: 0; }
}

.pt-car {
  position: relative;
  width: 64px;
  height: 52px;
  flex-shrink: 0;
  border-radius: 10px;
  background: var(--card);
  border: 2px solid var(--border);
  box-shadow: var(--btn-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
}

.pt-car::after {
  content: "";
  position: absolute;
  bottom: -10px;
  left: 10px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--ink);
  box-shadow: 32px 0 0 var(--ink);
}

.pt-window {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 32px;
  border-radius: 8px;
  background: var(--bubble);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 800;
}

.pt-car-missing {
  border-style: dashed;
  border-color: var(--accent-2);
  animation: pt-bob 1.8s ease-in-out infinite;
}

.pt-car-missing .pt-window {
  background: transparent;
  border: 2px dashed var(--accent-2);
  color: var(--accent-2);
}

@keyframes pt-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

.pt-car-coupled {
  border-style: solid;
  border-color: var(--accent);
  animation: none;
}

.pt-window-filled {
  background: var(--accent);
  color: var(--card);
  border: none;
}

.pt-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-top: 6px;
}

.pt-choice-car {
  min-width: 84px;
  min-height: 58px;
  border-radius: 10px;
  border: 2px solid var(--strand-harbor);
  background: var(--card);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: var(--btn-shadow);
  transition: transform 0.12s ease, background 0.15s ease, color 0.15s ease;
}

.pt-choice-car::after {
  content: "";
  display: block;
  margin: 6px auto 0;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--ink-soft);
  box-shadow: 22px 0 0 var(--ink-soft);
}

.pt-choice-car:hover {
  transform: translateY(-2px);
  background: var(--bubble);
}

.pt-choice-car:active {
  transform: scale(0.96);
}

.pt-choice-car.pt-choice-picked {
  background: var(--accent);
  color: var(--card);
  border-color: var(--accent);
}

/* =====================================================================
   SHELL: login / hub (Made-for-You Shelves) / player wrapper / parent door
   None of the rules below touch the per-game zone classes above (fn-, kk-,
   bs-, sk-, acs-, cl-, pp-, mismo-, xouts-, np-, slg-, pb-, cs-, ll-, pt-) --
   the puzzle player keeps its existing look untouched.
   ===================================================================== */

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

.app {
  max-width: 1080px;
}

.btn-primary,
.btn-ghost {
  font-family: var(--font-body);
}

.btn-primary {
  background: var(--accent-2);
  color: #2a1400;
  border: none;
  border-radius: 999px;
  font-weight: 800;
  padding: 12px 22px;
  box-shadow: var(--btn-shadow);
}

@media (prefers-color-scheme: dark) {
  .btn-primary {
    color: #211200;
  }
}

.btn-large {
  font-size: 1.1rem;
  padding: 14px 26px;
  width: 100%;
}

.btn-ghost {
  background: transparent;
  color: var(--accent);
  border: 2px solid var(--border);
  box-shadow: none;
  font-weight: 700;
}

.btn-ghost:hover {
  background: var(--bubble);
  color: var(--accent);
  transform: translateY(-1px);
  box-shadow: none;
}

.section-eyebrow {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin: 0 0 10px;
}

.small-label {
  margin: 12px 0 6px;
  font-size: 0.92rem;
}

/* ----- Login screen ----- */
.atlas-hero {
  position: relative;
  text-align: center;
  padding: 28px 20px 24px;
}

.atlas-compass {
  font-size: 2.4rem;
  display: inline-block;
  margin-bottom: 6px;
  animation: compass-sway 6s ease-in-out infinite;
}

@keyframes compass-sway {
  0%, 100% { transform: rotate(-6deg); }
  50% { transform: rotate(6deg); }
}

.atlas-hero h1 {
  margin: 4px 0 6px;
  font-size: 2rem;
}

.atlas-hero p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 1.05rem;
}

.login-card {
  padding: 20px;
}

.profile-tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 8px;
}

.profile-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 108px;
  padding: 14px 8px;
  border-radius: 18px;
  border: 2px solid var(--border);
  background: var(--card);
  box-shadow: var(--surface-shadow);
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
}

.profile-tile-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(160deg, var(--accent) 0%, var(--strand-lagoon) 100%);
}

.profile-tile-add .profile-tile-avatar {
  background: transparent;
  border: 2px dashed var(--line);
  color: var(--ink-soft);
}

.profile-tile-add {
  border-style: dashed;
  background: transparent;
  box-shadow: none;
}

.profile-tile-name {
  font-size: 0.92rem;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.new-profile-form {
  display: none;
  flex-direction: column;
  gap: 4px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 2px dashed var(--border);
}

.new-profile-form.open {
  display: flex;
}

.new-profile-form #name {
  flex: 1;
  min-width: 0;
}

.grade-band-picker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.grade-band-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: var(--card);
  color: var(--ink);
  box-shadow: none;
  cursor: pointer;
  text-align: left;
}

.grade-band-btn:hover {
  background: var(--bubble);
  color: var(--ink);
  transform: none;
}

.grade-band-btn.active {
  border-color: var(--accent);
  background: var(--bubble);
}

.gb-title {
  font-weight: 800;
  font-size: 0.98rem;
}

.gb-sub {
  font-size: 0.8rem;
  color: var(--ink-soft);
}

/* ----- Hub screen ----- */
.screen-hub {
  display: grid;
  gap: 16px;
}

.hub-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.hub-greeting {
  display: flex;
  align-items: center;
  gap: 14px;
}

.hub-avatar {
  width: 54px;
  height: 54px;
  min-width: 54px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(160deg, var(--accent) 0%, var(--strand-lagoon) 100%);
}

.hub-greeting h1 {
  margin: 0;
  font-size: 1.5rem;
}

.hub-greeting p {
  margin: 2px 0 0;
}

.hub-header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.kid-progress-card {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  padding: 14px 18px;
}

.kid-progress-card p {
  margin: 0;
  font-size: 1rem;
}

.todays-pick-card {
  border-radius: 20px;
  padding: 18px 20px;
  background:
    radial-gradient(circle at 100% 0%, rgba(255, 138, 0, 0.16), transparent 55%),
    var(--card);
  border: 2px solid var(--accent-2);
  box-shadow: var(--surface-shadow);
}

.todays-pick-label {
  display: inline-block;
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--accent-2);
  margin-bottom: 8px;
}

.todays-pick-body {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.todays-pick-emoji {
  font-size: 2.6rem;
  line-height: 1;
}

.todays-pick-text {
  flex: 1;
  min-width: 160px;
}

.todays-pick-text h2 {
  margin: 0 0 2px;
  font-size: 1.3rem;
}

.todays-pick-text p {
  margin: 0;
}

.strand-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}

.strand-chip {
  flex: 0 0 auto;
  padding: 8px 16px;
  border-radius: 999px;
  border: 2px solid var(--border);
  background: var(--card);
  color: var(--ink);
  font-weight: 700;
  font-size: 0.92rem;
  box-shadow: none;
  white-space: nowrap;
}

.strand-chip:hover {
  background: var(--bubble);
  color: var(--ink);
  transform: none;
}

.strand-chip.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

/* The shelves sit on a dotted "expedition trail" spine -- the one signature
   flourish that turns generic streaming rows into a map you walk through. */
.shelves {
  position: relative;
  display: grid;
  gap: 22px;
  padding-left: 26px;
}

.shelves::before {
  content: "";
  position: absolute;
  left: 9px;
  top: 6px;
  bottom: 6px;
  width: 0;
  border-left: 3px dotted var(--line);
  opacity: 0.45;
}

.shelf {
  position: relative;
}

.shelf-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.shelf-waypoint {
  position: absolute;
  left: -26px;
  top: 2px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  background: var(--card);
  border: 2px solid var(--line);
}

.shelf-header h2 {
  margin: 0;
  font-size: 1.2rem;
}

.shelf-header p {
  margin: 2px 0 0;
  font-size: 0.9rem;
}

.shelf-track {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 4px 4px 10px;
  scroll-snap-type: x proximity;
}

.game-card {
  scroll-snap-align: start;
  flex: 0 0 148px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 10px;
  border-radius: 18px;
  border: 2px solid var(--border);
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--surface-shadow);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.game-card:hover {
  background: var(--card);
  color: var(--ink);
  transform: translateY(-3px);
  box-shadow: 0 12px 22px rgba(38, 30, 16, 0.18);
}

.game-card:active {
  transform: translateY(0);
}

.game-card-emoji {
  font-size: 2.1rem;
  line-height: 1;
}

.game-card-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.98rem;
  text-align: center;
}

.game-card-grades {
  font-size: 0.78rem;
  color: var(--ink-soft);
}

/* ----- Player screen ----- */
.screen-player {
  display: grid;
  gap: 14px;
}

.player-topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 12px 16px;
}

.player-game-title {
  flex: 1;
  margin: 0;
  font-size: 1.15rem;
  min-width: 120px;
}

.difficulty-picker {
  display: flex;
  gap: 6px;
  background: var(--bg);
  border-radius: 999px;
  padding: 4px;
  border: 2px solid var(--border);
}

.difficulty-picker button {
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  box-shadow: none;
  font-size: 0.88rem;
  padding: 8px 12px;
  font-weight: 700;
}

.difficulty-picker button:hover {
  background: var(--bubble);
  color: var(--ink);
  transform: none;
  box-shadow: none;
}

.difficulty-picker button.active {
  background: var(--accent);
  color: #fff;
}

.player-footer {
  display: flex;
  justify-content: center;
  margin-top: 6px;
}

/* ----- Parent (grown-ups) door ----- */
.parent-modal {
  border: none;
  border-radius: 20px;
  padding: 0;
  max-width: min(560px, 92vw);
  width: 100%;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.28);
}

.parent-modal::backdrop {
  background: rgba(20, 24, 26, 0.45);
}

.parent-modal-inner {
  position: relative;
  background: var(--card);
  color: var(--ink);
  border-radius: 20px;
  padding: 24px;
  font-family: var(--font-body);
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-soft);
  box-shadow: none;
  font-size: 1.3rem;
  line-height: 1;
  padding: 0;
}

.modal-close:hover {
  background: var(--bubble);
  color: var(--ink);
  transform: none;
  box-shadow: none;
}

.parent-summary p {
  margin: 0 0 10px;
  line-height: 1.5;
}

.parent-detail-toggle {
  margin-top: 14px;
  border-top: 2px dashed var(--border);
  padding-top: 10px;
}

.parent-detail-toggle summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--accent);
}

/* ----- Small-screen tweaks for the shell ----- */
@media (max-width: 640px) {
  .profile-tile {
    width: 92px;
  }

  .game-card {
    flex: 0 0 130px;
  }

  .shelves {
    padding-left: 20px;
  }

  .shelf-waypoint {
    left: -20px;
    width: 22px;
    height: 22px;
    font-size: 0.85rem;
  }

  .hub-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .player-topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .difficulty-picker {
    justify-content: space-between;
  }
}
