/* ===== Theme tokens ===== */
:root,
[data-theme='space'] {
  --bg: #eef1ff;
  --bg-2: #e2e7ff;
  --surface: #ffffff;
  --surface-2: #f6f7ff;
  --ink: #23275a;
  --muted: #5d6390;
  --line: #d9ddf5;
  --primary: #5b5bd6;
  --primary-ink: #ffffff;
  --accent: #ff9f43;
  --good: #1fa463;
  --good-bg: #e2f8ec;
  --soft-bad: #e8677a;
  --soft-bad-bg: #ffe9ec;
  --reveal: #ffb020;
  --field-1: #1d2155;
  --field-2: #3a3f8f;
  --sky-dot: #ffffff;
  --progress-from: #7bdff2;
  --bin-line: #b9bfe8;
  --select-bg: #f0f0ff;
  --feedback-bg: #fff8e8;
  --feedback-line: #ffe0a3;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 2px 0 rgba(35, 39, 90, 0.08), 0 8px 24px rgba(35, 39, 90, 0.08);
  --font: ui-rounded, 'SF Pro Rounded', 'Nunito', 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
  --tap: 48px;
  color-scheme: light;
}

[data-theme='forest'] {
  --bg: #f1f6e9;
  --bg-2: #dfead0;
  --surface: #ffffff;
  --surface-2: #f6f9ef;
  --ink: #2c3a22;
  --muted: #5c6b4f;
  --line: #d6e1c4;
  --primary: #c05a14;
  --primary-ink: #ffffff;
  --accent: #e39a2d;
  --good: #2e8b3e;
  --good-bg: #e2f3df;
  --field-1: #16301f;
  --field-2: #2f5a36;
  --sky-dot: rgba(108, 160, 70, 0.35);
  --progress-from: #a5d66f;
  --bin-line: #c3d4a8;
  --select-bg: #fff1e3;
  --feedback-bg: #fff6e6;
  --feedback-line: #f6d39a;
}

/* ===== Base ===== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: clamp(16px, 1.6vw + 10px, 18px);
  line-height: 1.45;
  color: var(--ink);
  background-color: var(--bg);
  /* soft starfield */
  background-image:
    radial-gradient(circle at 12% 18%, var(--sky-dot) 0 1.5px, transparent 2px),
    radial-gradient(circle at 78% 8%, var(--sky-dot) 0 1.2px, transparent 2px),
    radial-gradient(circle at 42% 62%, var(--sky-dot) 0 1.4px, transparent 2px),
    radial-gradient(circle at 88% 72%, var(--sky-dot) 0 1.6px, transparent 2px),
    linear-gradient(180deg, var(--bg-2), var(--bg) 420px);
  background-size: 220px 220px, 260px 260px, 300px 300px, 240px 240px, 100% 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
h1, h2, h3 { line-height: 1.15; margin: 0 0 0.4em; }
h1 { font-size: clamp(1.6rem, 4vw, 2.4rem); }
h2 { font-size: clamp(1.2rem, 2.6vw, 1.5rem); margin-top: 1.6em; }
a { color: var(--primary); }
button, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 50; }
.skip-link:focus { left: 8px; }
.muted { color: var(--muted); margin: 0; }
.container { width: 100%; max-width: 1100px; margin: 0 auto; padding: 16px 16px 48px; flex: 1; outline: none; }

/* ===== Header / footer ===== */
.site-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap;
  padding: 8px max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left));
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.logo { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); font-weight: 800; font-size: 1.15rem; }
.logo-bip svg { width: 36px; height: 42px; display: block; }
.controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.controls select {
  min-height: 40px; padding: 4px 30px 4px 10px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%235d6390' stroke-width='2'/%3E%3C/svg%3E") no-repeat right 10px center / 12px;
  appearance: none; -webkit-appearance: none; max-width: 46vw;
}
.icon-btn {
  min-width: 40px; min-height: 40px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); font-size: 1.1rem; display: inline-grid; place-items: center;
}
.site-footer { text-align: center; color: var(--muted); font-size: 0.9rem; padding: 16px; border-top: 1px solid var(--line); background: rgba(255, 255, 255, 0.6); }
.site-footer p { margin: 0; }
.support { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line); }
.support-text { max-width: 520px; font-size: 0.85rem; }
.last-update { margin-top: 12px !important; font-size: 0.8rem; }

/* ===== Buttons & chips ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--tap); padding: 8px 18px; border-radius: 999px;
  border: 2px solid var(--line); background: var(--surface); color: var(--ink);
  font-weight: 700; text-decoration: none; box-shadow: var(--shadow);
}
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 4px; }
.chip {
  display: inline-flex; align-items: center; min-height: 32px; padding: 2px 12px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); font-size: 0.85rem; font-weight: 700; text-decoration: none;
}
.chips .chip { min-height: 40px; font-size: 0.95rem; }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.back { display: inline-flex; align-items: center; min-height: 40px; font-weight: 700; text-decoration: none; }

/* ===== Home ===== */
.hero {
  display: flex; align-items: center; gap: 16px 28px; margin: 8px 0 8px;
  background: var(--surface); border-radius: 28px; padding: 20px; box-shadow: var(--shadow);
}
.hero-bip svg { width: clamp(90px, 18vw, 160px); height: auto; display: block; }
.hero-text h1 { margin-bottom: 0.1em; }
.tagline { margin: 0 0 10px; color: var(--muted); font-weight: 600; }
.bubble { margin: 0; }
.hero .bubble { display: inline-block; background: var(--surface-2); border: 2px solid var(--line); padding: 8px 14px; border-radius: 16px 16px 16px 4px; font-weight: 700; }
.promise { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-wrap: wrap; gap: 6px; }
.promise li { font-size: 0.85rem; font-weight: 700; color: var(--good); background: var(--good-bg); padding: 3px 10px; border-radius: 999px; }
.promise li::before { content: '✓ '; }

.planets { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.planet-tile {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px;
  padding: 12px 8px 14px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow);
  text-decoration: none; color: var(--ink); transition: transform 0.15s;
}
.planet-tile:hover { transform: translateY(-3px); }
.planet-img svg { width: 92px; height: 92px; display: block; transition: transform 0.4s; }
.planet-tile:hover .planet-img svg { transform: rotate(-10deg) scale(1.05); }
.pt-grade { font-weight: 800; font-size: 1.05rem; }
.pt-name { color: var(--muted); font-size: 0.85rem; }
.pt-count { margin-top: 4px; font-size: 0.8rem; font-weight: 700; color: var(--primary); }

.subjects { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.subject-tile {
  display: flex; flex-direction: column; gap: 2px; padding: 14px; border-radius: var(--radius);
  background: var(--surface); border-top: 6px solid var(--c); box-shadow: var(--shadow); text-decoration: none; color: var(--ink);
}
.st-icon { font-size: 1.8rem; }
.st-name { font-weight: 800; }
.st-count { font-size: 0.8rem; color: var(--muted); font-weight: 700; }

/* ===== Listing pages ===== */
.page-head { display: flex; align-items: center; gap: 14px; margin: 4px 0 8px; }
.page-head h1 { margin: 0; }
.page-planet svg { width: 72px; height: 72px; display: block; }
.page-icon { font-size: 2.6rem; }
.subject-section h2 { border-left: 6px solid var(--c); padding-left: 10px; }
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.game-card {
  display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow); text-decoration: none; color: var(--ink);
  border: 2px solid transparent; transition: transform 0.15s, border-color 0.15s;
}
.game-card:hover { transform: translateY(-2px); border-color: var(--c); }
.gc-icon {
  flex: none; width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; font-size: 1.8rem;
  background: color-mix(in srgb, var(--c) 18%, white);
}
.gc-body { display: flex; flex-direction: column; min-width: 0; }
.gc-nick { font-weight: 800; font-size: 1.05rem; }
.gc-title { color: var(--muted); font-size: 0.85rem; }
.gc-meta { display: flex; gap: 6px; align-items: center; margin-top: 4px; flex-wrap: wrap; }
.gc-stars { color: #d99a00; font-weight: 800; font-size: 0.85rem; }
.empty { padding: 24px; background: var(--surface); border-radius: var(--radius); text-align: center; color: var(--muted); }

/* ===== Game shell ===== */
.game-section { background: var(--surface); border-radius: 24px; padding: 12px clamp(10px, 2.5vw, 24px) 18px; box-shadow: var(--shadow); }
.game-section:fullscreen { overflow: auto; border-radius: 0; padding: 16px 24px; }
.game-head { display: flex; justify-content: space-between; align-items: center; }
.game-title { display: flex; align-items: center; gap: 10px; margin: 2px 0 0; }
.gt-icon { font-size: 1.1em; }
.game-subtitle { margin: 0 0 10px; color: var(--muted); font-weight: 700; }
.instruction {
  display: flex; align-items: center; gap: 10px; padding: 6px 10px 6px 4px;
  background: var(--surface-2); border: 2px solid var(--line); border-radius: var(--radius); transition: background 0.2s, border-color 0.2s;
}
.instruction.feedback { background: var(--feedback-bg); border-color: var(--feedback-line); }
.shell-bip svg { width: 48px; height: 56px; display: block; }
.instruction .bubble { flex: 1; font-weight: 700; }
.say-btn {
  flex: none; min-width: var(--tap); min-height: var(--tap); border-radius: 999px; border: 2px solid var(--line);
  background: var(--surface); font-size: 1.3rem; display: inline-grid; place-items: center;
}
.say-btn.small { min-width: 40px; min-height: 40px; font-size: 1rem; }
.notice { background: #fff3d6; padding: 8px 12px; border-radius: var(--radius-sm); margin: 8px 0 0; }
.level-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 12px 0 6px; }
.level-label { font-weight: 800; }
.levels { display: flex; gap: 6px; flex-wrap: wrap; }
.level-btn {
  min-width: var(--tap); min-height: var(--tap); padding: 2px 8px; border-radius: 14px; border: 2px solid var(--line); background: var(--surface);
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1;
}
.level-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.mini-stars { font-size: 0.6rem; letter-spacing: 1px; color: #e0a800; }
.level-btn.active .mini-stars { color: #ffe27a; }
.level-desc { color: var(--muted); font-weight: 600; font-size: 0.95rem; }
.progress { display: flex; align-items: center; gap: 10px; margin: 6px 0 10px; }
.progress-track { flex: 1; height: 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.progress-fill { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--progress-from), var(--primary)); border-radius: 999px; transition: width 0.4s; }
.progress-text { font-weight: 800; font-variant-numeric: tabular-nums; min-width: 3.5em; text-align: right; }
.stage { position: relative; min-height: 360px; }
.notes { margin-top: 16px; background: var(--surface); border-radius: var(--radius); padding: 4px 16px; box-shadow: var(--shadow); }
.notes summary { cursor: pointer; font-weight: 800; min-height: var(--tap); display: flex; align-items: center; }
.notes dt { font-weight: 800; margin-top: 10px; }
.notes dd { margin: 2px 0 0; color: var(--muted); }
.notes dl { margin: 0 0 14px; }

/* End screen */
.end-screen { position: absolute; inset: 0; display: grid; place-items: center; background: color-mix(in srgb, var(--bg) 85%, transparent); border-radius: var(--radius); z-index: 5; animation: fade 0.3s; padding: 8px; }
.end-card { background: var(--surface); border-radius: 24px; padding: 18px 22px; text-align: center; box-shadow: var(--shadow); max-width: 420px; width: 100%; }
.end-bip svg { width: 90px; height: 105px; }
.end-title { font-size: 1.3rem; font-weight: 800; margin: 4px 0; }
.end-stars { display: flex; justify-content: center; gap: 8px; margin: 8px 0; }
.end-star svg { width: 52px; height: 52px; filter: grayscale(1) opacity(0.25); }
.end-star.on svg { filter: none; animation: star-in 0.5s var(--d) both; }
.end-note { font-weight: 800; color: var(--muted); margin: 0 0 6px; }
.end-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 10px; }

/* ===== Choice engine ===== */
.choice-engine { display: flex; flex-direction: column; gap: 14px; align-items: center; }
.prompt { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; min-height: 110px; text-align: center; width: 100%; }
.prompt-text { font-size: clamp(1.2rem, 3vw, 1.6rem); font-weight: 800; }
.choices { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 12px; width: 100%; max-width: 720px; }
.choice-cell { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.choice {
  width: 100%; min-height: 84px; padding: 10px; border-radius: var(--radius); border: 3px solid var(--line); background: var(--surface);
  font-size: clamp(1.6rem, 5vw, 2.4rem); font-weight: 800; box-shadow: 0 4px 0 var(--line);
  transition: transform 0.1s, background 0.2s, border-color 0.2s; touch-action: manipulation;
  display: grid; place-items: center;
}
.choice:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }
.choice.is-correct { background: var(--good-bg); border-color: var(--good); box-shadow: 0 4px 0 var(--good); animation: bounce 0.4s; }
.choice.is-wrong { background: var(--soft-bad-bg); border-color: var(--soft-bad); opacity: 0.55; animation: shake 0.4s; cursor: default; }
.choice.is-revealed { border-color: var(--reveal); background: #fff4d6; animation: pulse 0.8s 2; }
.choices.pictures .choice { font-size: clamp(2.6rem, 9vw, 4rem); min-height: 110px; }
.choices.words .choice, .choices.symbols .choice { font-size: clamp(1.3rem, 4vw, 1.8rem); }
.choices.groups { max-width: 640px; }
.choices.groups .choice { min-height: 150px; }
.dot-group { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; font-size: clamp(1.4rem, 4.5vw, 2rem); max-width: 220px; }
.sym { display: flex; flex-direction: column; align-items: center; line-height: 1; gap: 4px; }
.sym b { font-size: clamp(2rem, 6vw, 2.8rem); }
.sym small { font-size: 0.75rem; color: var(--muted); font-weight: 700; }
.equation { font-size: clamp(2rem, 7vw, 3.2rem); font-weight: 800; font-variant-numeric: tabular-nums; }
.blank { display: inline-block; min-width: 1.4em; border-bottom: 4px dashed var(--primary); color: var(--primary); }

/* count board */
.count-board { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 10px; font-size: clamp(1.8rem, 6vw, 2.6rem); max-width: 560px; }
.count-board.frames { gap: 14px; }
.ten-frame { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; padding: 6px; border: 3px solid var(--primary); border-radius: 12px; background: var(--surface-2); }
.ten-frame .cell { width: clamp(36px, 9vw, 52px); height: clamp(36px, 9vw, 52px); display: grid; place-items: center; border: 1px dashed var(--line); border-radius: 8px; font-size: clamp(1.4rem, 5vw, 2rem); }

/* balance */
.scale { position: relative; width: min(100%, 520px); height: 150px; }
.scale-beam {
  position: absolute; left: 6%; right: 6%; top: 34px; height: 12px; background: var(--primary); border-radius: 999px;
  transform: rotate(var(--tilt, 0deg)); transition: transform 0.8s cubic-bezier(0.3, 1.6, 0.5, 1);
}
.scale-pan {
  position: absolute; top: 12px; min-width: 96px; padding: 10px 14px; border-radius: 0 0 40px 40px; background: var(--surface-2);
  border: 3px solid var(--primary); border-top: none; font-size: clamp(1.4rem, 5vw, 2.2rem); font-weight: 800; text-align: center; font-variant-numeric: tabular-nums;
}
.scale-pan.left { left: -10px; } .scale-pan.right { right: -10px; }
.scale-slot {
  position: absolute; left: 50%; top: -26px; transform: translateX(-50%); width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 2rem; font-weight: 800; display: grid; place-items: center; box-shadow: var(--shadow);
}
.scale-stand { position: absolute; left: 50%; top: 40px; bottom: 0; width: 14px; transform: translateX(-50%); background: var(--muted); border-radius: 6px; }
.scale-stand::after { content: ''; position: absolute; left: 50%; bottom: 0; width: 120px; height: 14px; transform: translateX(-50%); background: var(--muted); border-radius: 8px; }
.scale.settled .scale-slot { background: var(--good); }

/* race */
.race { display: flex; align-items: center; gap: 10px; width: 100%; max-width: 720px; }
.race-track { position: relative; flex: 1; height: 48px; border-radius: 999px; background: linear-gradient(90deg, var(--field-1), var(--field-2)); }
.race-rocket { position: absolute; top: 2px; left: calc(var(--p, 0) * (100% - 52px)); width: 44px; height: 44px; transition: left 0.6s cubic-bezier(0.3, 1.4, 0.5, 1); }
.race-rocket svg { width: 100%; height: 100%; }
.race-finish { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font-size: 1.4rem; }
.race-timer { font-weight: 800; font-variant-numeric: tabular-nums; min-width: 4.5em; text-align: right; }

/* sound hunt */
.sound-prompt { display: flex; align-items: center; gap: 12px; }
.radar { font-size: 2.6rem; }
.sound-tag { font-size: clamp(2rem, 7vw, 3rem); font-weight: 800; background: var(--primary); color: #fff; padding: 4px 22px; border-radius: 999px; }
.word { font-weight: 800; }

/* ===== Sort engine ===== */
.sort-engine { display: flex; flex-direction: column; gap: 14px; touch-action: manipulation; }
.tray { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; min-height: 92px; padding: 10px; border-radius: var(--radius); background: var(--surface-2); border: 2px dashed var(--line); }
.item {
  min-width: 76px; min-height: 76px; padding: 8px 14px; border-radius: 16px; border: 3px solid var(--line); background: var(--surface);
  display: grid; place-items: center; font-size: 1.25rem; box-shadow: 0 4px 0 var(--line);
  touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab;
}
.item.selected { border-color: var(--primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 25%, transparent); transform: translateY(-3px); }
.item.dragging { opacity: 0.3; }
.item:disabled { opacity: 0.6; }
.ghost { position: fixed; z-index: 100; pointer-events: none; transform: translate(-50%, -50%) scale(1.08) rotate(-3deg); box-shadow: 0 12px 28px rgba(0, 0, 0, 0.2); margin: 0; }
.emoji-item { font-size: clamp(2rem, 7vw, 2.6rem); line-height: 1; }
.item .shape, .placed .shape { width: 56px; height: 56px; display: block; }
.bins { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(140px, 100%), 1fr)); gap: 10px; }
.bin {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; min-height: 150px; padding: 10px 8px 26px;
  border-radius: var(--radius); background: var(--surface); border: 3px dashed var(--bin-line); cursor: pointer; transition: border-color 0.15s, background 0.15s;
}
.has-selection .bin { border-color: var(--primary); background: var(--select-bg); }
.bin.hover { border-style: solid; border-color: var(--accent); background: #fff6ea; }
.bin.glow { animation: glow 0.6s; }
.bin.nope { animation: shake 0.4s; }
.bin-label { display: flex; align-items: center; gap: 6px; font-weight: 800; font-size: 1.05rem; text-align: center; }
.bin-hint { font-size: 0.78rem; color: var(--muted); text-align: center; line-height: 1.2; }
.bin-emoji { font-size: clamp(2.6rem, 9vw, 3.4rem); line-height: 1; }
.bin-shape { display: flex; flex-direction: column; align-items: center; color: var(--muted); }
.bin-shape .shape { width: 48px; height: 48px; }
.bin-content { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; }
.placed { padding: 2px 8px; border-radius: 10px; background: var(--good-bg); font-size: 0.95rem; animation: bounce 0.35s; display: grid; place-items: center; }
.placed .emoji-item { font-size: 1.6rem; }
.placed .shape { width: 34px; height: 34px; }
.placed.revealed { background: #fff4d6; outline: 2px solid var(--reveal); }
.bin-pad { position: absolute; left: 8%; right: 8%; bottom: 4px; height: 16px; }
.bin-pad svg { width: 100%; height: 100%; display: block; }

/* ===== Pairs engine ===== */
.pairs-engine { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.pairs-header { font-size: 1.3rem; }
.target-badge { font-size: clamp(1.4rem, 4vw, 2rem); font-weight: 800; background: var(--accent); color: #fff; padding: 4px 18px; border-radius: 999px; }
.cards { display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: clamp(6px, 1.5vw, 12px); width: 100%; max-width: calc(var(--cols) * 130px); }
.card { aspect-ratio: 3 / 4; border: none; padding: 0; background: none; perspective: 700px; touch-action: manipulation; }
.cards.face-up .card { aspect-ratio: 1; }
.card-inner { position: relative; display: block; width: 100%; height: 100%; transition: transform 0.45s; transform-style: preserve-3d; }
.cards.memory .card:not(.flipped) .card-inner { transform: rotateY(180deg); }
.card-face {
  position: absolute; inset: 0; display: grid; place-items: center; border-radius: 14px; overflow: hidden;
  backface-visibility: hidden; -webkit-backface-visibility: hidden; box-shadow: 0 3px 0 var(--line);
}
.card-front { background: var(--surface); border: 3px solid var(--line); }
.card-back { transform: rotateY(180deg); }
.card-back svg { width: 100%; height: 100%; }
.card.selected .card-front { border-color: var(--primary); background: var(--select-bg); }
.card.matched .card-front { border-color: var(--good); background: var(--good-bg); }
.cards.face-up .card.matched { animation: vanish 0.6s forwards; }
.card.hint .card-front { border-color: var(--reveal); animation: pulse 0.8s 3; }
.card.shake .card-front { border-color: var(--soft-bad); }
.emoji-card { font-size: clamp(1.6rem, 6vw, 3rem); }
.word-card { font-weight: 800; font-size: clamp(0.8rem, 2.6vw, 1.2rem); padding: 4px; text-align: center; word-break: break-word; }
.num-card { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.num-card b { font-size: clamp(1.4rem, 5vw, 2.2rem); }
.five-frame { display: grid; grid-template-columns: repeat(5, 8px); gap: 3px; }
.five-frame i { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }

/* ===== Targets engine ===== */
.targets-engine { display: flex; flex-direction: column; gap: 10px; }
.target-question { display: flex; align-items: center; justify-content: center; gap: 12px; font-size: clamp(1.8rem, 6vw, 2.6rem); font-weight: 800; font-variant-numeric: tabular-nums; }
.field {
  position: relative; height: clamp(320px, 58vh, 560px); border-radius: var(--radius); overflow: hidden; touch-action: none;
  background:
    radial-gradient(circle at 20% 30%, #fff 0 1.5px, transparent 2px) 0 0 / 120px 120px,
    radial-gradient(circle at 70% 60%, #fff 0 1px, transparent 2px) 0 0 / 90px 90px,
    linear-gradient(160deg, var(--field-1), var(--field-2));
}
.target { position: absolute; left: 0; top: 0; padding: 0; border: none; background: none; touch-action: none; will-change: transform; -webkit-tap-highlight-color: transparent; }
.target svg { width: 100%; height: 100%; display: block; pointer-events: none; }
.target.popping svg { animation: pop 0.35s forwards; }
.target.is-wrong { opacity: 0.35; }
.target.is-revealed svg { filter: drop-shadow(0 0 12px #ffd23f) drop-shadow(0 0 4px #ffd23f); animation: pulse 0.8s 3; }

/* ===== Order engine ===== */
.order-engine { display: flex; flex-direction: column; gap: 14px; align-items: center; }
.order-prompt { display: flex; align-items: center; gap: 12px; min-height: 56px; }
.order-hint { font-size: clamp(2.6rem, 9vw, 3.6rem); }
.slots { display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-end; gap: 8px; width: 100%; padding: 12px; border-radius: var(--radius); background: var(--surface-2); min-height: 84px; }
.slot { min-width: 64px; min-height: 56px; border-bottom: 4px solid var(--line); border-radius: 10px; display: grid; place-items: center; transition: border-color 0.15s, background 0.15s; }
.slot.hover { border-color: var(--accent); background: var(--feedback-bg); }
.slot-suffix { font-size: 1.8rem; font-weight: 800; align-self: flex-end; padding-bottom: 6px; }
.order-tray { min-height: 76px; width: 100%; }
.order-tray.hover { border-color: var(--accent); }
.tile {
  min-height: 52px; padding: 6px 14px; border-radius: 12px; border: 3px solid var(--line); background: var(--surface);
  font-size: clamp(1.1rem, 3.5vw, 1.4rem); font-weight: 800; box-shadow: 0 3px 0 var(--line);
  touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab;
}
.tile.is-correct, .tile.is-locked { border-color: var(--good); background: var(--good-bg); box-shadow: 0 3px 0 var(--good); }
.tile.is-locked { cursor: default; }
.tile.is-revealed { border-color: var(--reveal); background: #fff4d6; }
.tile.shake { border-color: var(--soft-bad); }

/* ===== Type engine ===== */
.type-engine { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.type-prompt { display: flex; flex-direction: column; align-items: center; gap: 10px; min-height: 90px; }
.type-question { font-size: clamp(1.4rem, 4vw, 2rem); font-weight: 800; text-align: center; }
.big-ear { font-size: 3.4rem; }
.type-tools { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.peek { font-size: clamp(1.8rem, 6vw, 2.6rem); font-weight: 800; letter-spacing: 1px; padding: 4px 18px; border-radius: 12px; background: var(--feedback-bg); border: 2px dashed var(--feedback-line); }
.type-row { display: flex; gap: 8px; width: 100%; max-width: 560px; }
.type-input {
  flex: 1; min-width: 0; min-height: 56px; padding: 6px 14px; font: inherit; font-size: clamp(1.3rem, 4vw, 1.7rem); font-weight: 700;
  border: 3px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink);
}
.type-input:focus { outline: none; border-color: var(--primary); }
.type-input.is-correct { border-color: var(--good); background: var(--good-bg); }
.type-feedback { min-height: 2.6em; text-align: center; font-weight: 700; }
.fb-ok { color: var(--good); font-size: 1.3rem; }
.fb-answer { margin-top: 6px; font-size: 1.2rem; }
.fb-answer b { font-size: 1.5rem; color: var(--primary); }
.diff { font-family: ui-monospace, Menlo, monospace; font-size: 1.3rem; letter-spacing: 2px; }
.d-ok { color: var(--good); }
.d-bad { color: var(--soft-bad); text-decoration: underline wavy; }
.accent-bar { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.accent-key { min-width: 40px; min-height: 40px; border-radius: 10px; border: 2px solid var(--line); background: var(--surface); font-size: 1.15rem; font-weight: 700; }

/* typing (keys mode) */
.keys-area { position: relative; width: 100%; padding: 18px 12px; border-radius: var(--radius); background: var(--surface-2); border: 2px solid var(--line); cursor: text; text-align: center; }
.keys-area:focus-within { border-color: var(--primary); }
.key-catcher { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; font-size: 16px; border: 0; cursor: text; }
.type-line { font-family: ui-monospace, Menlo, monospace; font-size: clamp(1.5rem, 5.5vw, 2.4rem); letter-spacing: 1px; display: inline-flex; flex-wrap: wrap; justify-content: center; }
.type-line .ch { padding: 0 1px; border-bottom: 4px solid transparent; color: var(--muted); }
.type-line .ch.space { color: var(--line); }
.type-line .ch.done { color: var(--good); }
.type-line .ch.cur { color: var(--ink); border-bottom-color: var(--primary); background: var(--select-bg); }
.type-line .ch.bad { animation: shake 0.3s; color: var(--soft-bad); }
.keyboard { display: flex; flex-direction: column; gap: 4px; align-items: center; user-select: none; width: 100%; max-width: 640px; }
.keyboard[hidden] { display: none; }
.kb-row { display: flex; gap: 4px; justify-content: center; width: 100%; }
.kb-r1 { padding-left: 2%; } .kb-r2 { padding-left: 4%; } .kb-r3 { padding-left: 0; }
.kb-key { flex: 0 1 52px; aspect-ratio: 1; max-height: 52px; display: grid; place-items: center; border-radius: 8px; border: 2px solid var(--line); background: var(--surface); font-weight: 800; font-size: clamp(0.7rem, 2.4vw, 1rem); transition: transform 0.1s; }
.kb-key.home { box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.18); }
.kb-shift { flex-basis: 64px; aspect-ratio: auto; }
.kb-space { flex: 0 1 300px; aspect-ratio: auto; height: 40px; }
.kb-key.f0, .kb-key.f7 { background: #ffe1ec; } .kb-key.f1, .kb-key.f6 { background: #e3f0ff; }
.kb-key.f2, .kb-key.f5 { background: #e6f8e6; } .kb-key.f3, .kb-key.f4 { background: #fff3d6; }
.kb-key.lit { background: var(--primary) !important; color: #fff; border-color: var(--primary); transform: scale(1.12); }

/* ===== Gaps engine ===== */
.gaps-engine { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.gaps-prompt { display: flex; align-items: center; gap: 10px; min-height: 48px; }
.tense-chip { background: var(--primary); color: #fff; font-weight: 800; padding: 4px 16px; border-radius: 999px; }
.gaps-board.is-flow { width: 100%; padding: 16px; border-radius: var(--radius); background: var(--surface-2); }
.flow-row { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: center; gap: 6px 8px; font-size: clamp(1.2rem, 3.6vw, 1.6rem); font-weight: 700; line-height: 1.9; }
.gap-wrap { display: inline-flex; flex-direction: column; align-items: center; }
.gap-label { font-size: 0.85rem; color: var(--muted); line-height: 1.2; }
.g-gap {
  font: inherit; font-weight: 800; color: var(--primary); text-align: center; min-height: 48px; padding: 2px 8px;
  border: none; border-bottom: 4px dashed var(--primary); border-radius: 8px 8px 0 0; background: var(--surface); max-width: 100%;
}
.g-gap:focus { outline: none; background: var(--select-bg); }
.g-gap.is-correct { color: var(--good); border-bottom: 4px solid var(--good); background: var(--good-bg); }
.g-gap.is-wrong { color: var(--soft-bad); border-bottom-color: var(--soft-bad); background: var(--soft-bad-bg); }
.g-gap.is-revealed { color: #9a6700; border-bottom: 4px solid var(--reveal); background: #fff4d6; }
.gaps-board.is-grid {
  --cell: clamp(36px, 10vw, 52px);
  display: grid; grid-template-columns: repeat(var(--cols), var(--cell)); gap: 4px; justify-content: center;
  padding: 14px 18px; border-radius: var(--radius); background: var(--surface-2);
  background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 14px 14px;
}
.g-cell { width: var(--cell); height: var(--cell); display: grid; place-items: center; font-size: clamp(1.4rem, 5vw, 2rem); font-weight: 800; font-variant-numeric: tabular-nums; }
input.g-cell { padding: 0; text-align: center; font: inherit; font-size: clamp(1.4rem, 5vw, 2rem); font-weight: 800; }
.is-grid .g-gap { border: 3px solid var(--primary); border-radius: 10px; background: var(--surface); }
.is-grid .g-gap.is-correct { border: 3px solid var(--good); }
.is-grid .g-gap.is-revealed { border: 3px solid var(--reveal); }
.g-scratch { height: calc(var(--cell) * 0.6); align-self: end; font-size: 0.95rem !important; color: var(--accent); border: 1px dashed var(--bin-line); border-radius: 6px; background: transparent; }
.g-rule { grid-column: 1 / -1; height: 0; border-top: 3px solid var(--ink); margin: 2px 0; }
.gaps-actions { display: flex; gap: 8px; }

/* ===== Reading ===== */
.reading { width: 100%; max-width: 760px; text-align: left; }
.reading-text {
  font-size: clamp(1.05rem, 2.6vw, 1.25rem); line-height: 1.7; padding: 14px 18px; border-radius: var(--radius);
  background: var(--surface-2); border-left: 6px solid var(--primary); white-space: pre-line;
}
.reading-q { font-weight: 800; font-size: clamp(1.1rem, 3vw, 1.35rem); margin: 12px 0 0; }
.choices.answers { grid-template-columns: 1fr 1fr; max-width: 760px; }
.choices.answers .choice { font-size: clamp(1rem, 2.8vw, 1.2rem); min-height: 64px; text-align: center; font-weight: 700; }

/* ===== Grid engine (sudoku, hidden picture, symmetry) ===== */
.grid-engine { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.palette { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.swatch {
  min-width: var(--tap); min-height: var(--tap); padding: 4px 10px; border-radius: 12px; border: 3px solid var(--line);
  background: var(--sw, var(--surface)); font-size: 1.3rem; font-weight: 800; display: grid; place-items: center;
}
.swatch.on { border-color: var(--ink); box-shadow: 0 0 0 3px var(--accent); transform: translateY(-2px); }
.swatch.eraser { background: var(--surface); }
.grid-board {
  --size: min(100%, calc(var(--cols) * 54px));
  display: grid; grid-template-columns: repeat(var(--cols), 1fr); width: var(--size);
  border: 3px solid var(--ink); border-radius: 10px; overflow: hidden; background: var(--surface); touch-action: manipulation;
}
.g-tile {
  aspect-ratio: 1; min-width: 0; padding: 0; border: 1px solid var(--line); background: var(--fill, var(--surface));
  display: grid; place-items: center; font-weight: 800; font-size: clamp(0.9rem, 4.2vw, 1.5rem); color: var(--ink); position: relative;
  transition: background 0.2s;
}
.g-tile.fixed { cursor: default; }
.g-tile.box-r { border-right: 3px solid var(--ink); }
.g-tile.box-b { border-bottom: 3px solid var(--ink); }
.g-tile.axis-r { border-right: 4px dashed var(--accent); }
.g-tile.axis-b { border-bottom: 4px dashed var(--accent); }
.g-tile.ok { animation: bounce 0.3s; }
.g-tile.split-r { border-right: 8px solid var(--ink); }
.g-tile.revealed { outline: 3px solid var(--reveal); outline-offset: -3px; }
/* Dark + white double ring: visible on any paint color, unlike a plain red outline on a red square. */
.g-tile.miss { box-shadow: inset 0 0 0 3px #1d1f3a, inset 0 0 0 6px #fff; }
.g-tile.extra::after, .g-tile.cleared::after {
  content: '✕'; position: absolute; inset: 0; display: grid; place-items: center; font-weight: 900; font-size: 1.4em; line-height: 1;
}
.g-tile.extra::after { color: #fff; text-shadow: 0 0 2px #1d1f3a, 0 0 4px #1d1f3a; }
.g-tile.cleared::after { color: var(--soft-bad); }
.g-label { font-size: clamp(0.66rem, 2.9vw, 0.9rem); font-weight: 700; color: var(--muted); line-height: 1; text-align: center; }
.g-tile.filled .g-label { visibility: hidden; }
.kind-sudoku .g-tile.fixed { background: var(--surface-2); color: var(--ink); }
.kind-sudoku .g-tile:not(.fixed) .g-val { color: var(--primary); }
.kind-sudoku.n4 { --size: min(100%, 300px); }
.kind-sudoku.n4 .g-tile { font-size: clamp(1.6rem, 8vw, 2.2rem); }
.kind-sudoku.n9 .g-tile { font-size: clamp(0.9rem, 4vw, 1.4rem); }
.kind-picture .g-tile { border-color: rgba(0, 0, 0, 0.06); }
.kind-mirror .g-tile.fixed { cursor: default; }
.kind-mirror .g-tile:not(.fixed) { background: var(--fill, var(--surface)); }
.kind-mirror .g-tile.fixed:not(.filled) { background: repeating-linear-gradient(45deg, var(--surface-2) 0 4px, var(--surface) 4px 8px); }
.grid-actions { display: flex; gap: 8px; }

/* ===== Robot ===== */
.robot-engine { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.robot-board {
  position: relative; display: grid; grid-template-columns: repeat(var(--n), 1fr); width: min(100%, calc(var(--n) * 70px));
  border-radius: 14px; overflow: hidden; border: 3px solid var(--ink); background: var(--surface-2);
}
.r-cell { aspect-ratio: 1; border: 1px solid var(--line); display: grid; place-items: center; }
.r-cell.trail::after { content: '•'; color: var(--accent); font-size: 1.6rem; }
.r-rock { width: 80%; height: 80%; }
.r-rock svg { width: 100%; height: 100%; display: block; }
.r-piece { position: absolute; width: calc(100% / var(--n)); aspect-ratio: 1; display: grid; place-items: center; transition: left 0.3s, top 0.3s; pointer-events: none; }
.r-piece svg { width: 78%; height: 78%; }
.r-goal svg { width: 62%; height: 62%; animation: pulse 1.6s infinite; }
.r-robot { z-index: 2; }
.r-robot.bump { animation: bump 0.45s; }
@keyframes bump { 40% { translate: var(--bx, 0) var(--by, 0); } }
.program { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; min-height: 48px; width: 100%; padding: 8px; border-radius: var(--radius); background: var(--surface-2); border: 2px dashed var(--line); }
.program[hidden] { display: none; }
.p-step { display: inline-flex; align-items: baseline; gap: 2px; min-width: 40px; justify-content: center; padding: 4px 8px; border-radius: 10px; background: var(--surface); border: 2px solid var(--line); font-size: 1.4rem; font-weight: 800; }
.p-step small { font-size: 0.8rem; color: var(--accent); }
.p-step.active { border-color: var(--primary); background: var(--select-bg); }
.p-empty { color: var(--muted); }
.robot-controls { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; justify-content: center; }
.arrow-pad { display: grid; grid-template-columns: repeat(3, 58px); grid-template-rows: repeat(3, 58px); gap: 4px; }
.arrow-btn { border-radius: 14px; border: 3px solid var(--line); background: var(--surface); font-size: 1.8rem; font-weight: 800; box-shadow: 0 3px 0 var(--line); touch-action: manipulation; }
.arrow-btn:active { transform: translateY(2px); box-shadow: none; }
.a-up { grid-area: 1 / 2; } .a-left { grid-area: 2 / 1; } .a-right { grid-area: 2 / 3; } .a-down { grid-area: 3 / 2; }
.program-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.program-actions .go { min-width: 72px; font-size: 1.3rem; }

/* ===== Number line ===== */
.numberline-engine { display: flex; flex-direction: column; align-items: center; gap: 12px; width: 100%; }
.nl-prompt { font-size: clamp(1.2rem, 3.6vw, 1.6rem); font-weight: 800; text-align: center; }
.nl-target { color: var(--primary); font-size: 1.3em; }
.nl-wrap { width: 100%; padding: 8px; border-radius: var(--radius); background: var(--surface-2); }
.nl-svg { width: 100%; height: auto; display: block; overflow: visible; touch-action: none; }
.nl-svg.placing { cursor: pointer; }
.nl-axis { stroke: var(--ink); stroke-width: 4; stroke-linecap: round; }
.nl-tick { stroke: var(--ink); stroke-width: 2; }
.nl-tick.major { stroke-width: 4; }
.nl-label { font-size: 30px; font-weight: 800; fill: var(--ink); font-family: var(--font); }
.nl-dot { fill: var(--accent); stroke: #fff; stroke-width: 3; }
.nl-marker { transition: transform 0.25s; }
.nl-marker.revealed .nl-dot { fill: var(--reveal); }
.nl-marker.jump > g { animation: hop 0.6s; }
@keyframes hop { 50% { transform: translate(-26px, -96px); } }
.nl-bottom { display: flex; justify-content: center; width: 100%; }

/* ===== Manipulate + kits ===== */
.manipulate-engine { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.manip-prompt { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; min-height: 60px; text-align: center; }
.manip-area { width: 100%; display: flex; justify-content: center; border-radius: var(--radius); transition: background 0.3s; }
.manip-area.is-correct { background: var(--good-bg); }
.manip-actions { display: flex; gap: 8px; }
.btn.small { min-height: 40px; padding: 4px 12px; font-size: 0.95rem; }
/* clock */
.clock { width: min(240px, 70vw); height: auto; display: block; }
.prompt .clock { width: min(220px, 60vw); }
.ck-face { fill: var(--surface); stroke: var(--ink); stroke-width: 5; }
.ck-tick { stroke: var(--muted); stroke-width: 1.5; } .ck-tick.big { stroke: var(--ink); stroke-width: 3; }
.ck-num { font-size: 17px; font-weight: 800; fill: var(--ink); font-family: var(--font); }
.ck-hour { stroke: var(--ink); stroke-width: 8; stroke-linecap: round; }
.ck-minute { stroke: var(--primary); stroke-width: 5; stroke-linecap: round; }
.ck-pin { fill: var(--accent); }
.clock.interactive { cursor: grab; touch-action: none; }
.clock.interactive .ck-hour, .clock.interactive .ck-minute { stroke-width: 10; }
.clock.revealed .ck-minute, .clock.revealed .ck-hour { stroke: var(--reveal); }
.clock-wrap { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.clock-controls { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.time-target { font-size: clamp(2rem, 7vw, 3rem); font-weight: 800; font-variant-numeric: tabular-nums; }
/* coins */
.coins-kit { display: flex; flex-direction: column; gap: 12px; width: 100%; }
.counter-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.counter { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; align-items: center; width: 100%; min-height: 90px; padding: 10px; border-radius: var(--radius); background: #e9dcc9; border: 3px solid #c8b28f; }
.counter.empty::before { content: '…'; color: #8d7a5c; font-size: 1.6rem; }
.money-total { font-weight: 800; font-size: 1.3rem; min-height: 1.4em; }
.purse { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.piece { padding: 0; border: none; background: none; display: grid; place-items: center; touch-action: manipulation; }
.money.coin { display: block; width: calc(64px * var(--s, 0.8)); height: calc(64px * var(--s, 0.8)); }
.money.bill { display: block; width: 104px; height: 56px; }
.money svg { width: 100%; height: 100%; display: block; }
.placed-piece .money.coin { width: calc(52px * var(--s, 0.8)); height: calc(52px * var(--s, 0.8)); }
.placed-piece .money.bill { width: 84px; height: 46px; }
.placed-piece.revealed { outline: 3px solid var(--reveal); border-radius: 50%; }
.shop-item { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: center; }
.shop-emoji { font-size: clamp(3rem, 10vw, 4rem); }
.price-tag { background: var(--accent); color: #fff; font-weight: 800; font-size: 1.5rem; padding: 4px 16px; border-radius: 10px 999px 999px 10px; }
.paid { font-size: 1.15rem; flex-basis: 100%; }
/* base-10 blocks */
.blocks-kit { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 10px; width: 100%; }
.blk-col { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px; border-radius: var(--radius); background: var(--surface-2); border: 2px solid var(--line); }
.blk-name { font-weight: 800; font-size: 0.95rem; }
.pile { display: flex; flex-wrap: wrap; gap: 3px; align-content: flex-end; justify-content: center; min-height: 120px; width: 100%; }
.pile.revealed { outline: 3px dashed var(--reveal); outline-offset: 2px; border-radius: 8px; }
.blk svg { display: block; fill: #7bdff2; stroke: #1e6f80; stroke-width: 1; }
.blk svg line { stroke: #1e6f80; stroke-width: 0.6; }
.blk-h svg { width: 50px; height: 50px; fill: #ffd166; } .blk-h svg line, .blk-h svg rect { stroke: #b07f00; }
.blk-t svg { width: 10px; height: 50px; fill: #90e39a; } .blk-t svg line, .blk-t svg rect { stroke: #2e7d32; }
.blk-o svg { width: 12px; height: 12px; fill: #ff9fb2; stroke: #c2185b; }
.blk-buttons { display: flex; align-items: center; gap: 4px; }
.blk-buttons .btn.small { min-width: 38px; padding: 4px 8px; }
.pile-count { min-width: 2ch; text-align: center; font-weight: 800; font-size: 1.2rem; }
.big-number { font-size: clamp(2.4rem, 9vw, 3.6rem); font-weight: 800; letter-spacing: 2px; }
.number-words { font-size: clamp(1.3rem, 4.5vw, 1.9rem); font-weight: 800; }
/* fractions */
.fraction-kit { display: flex; justify-content: center; width: 100%; }
.frac-svg.pizza { width: min(240px, 70vw); height: auto; }
.frac-svg.bar { width: min(420px, 90%); height: auto; }
.frac-svg .crust { fill: #f3c27a; }
.frac-svg .part { fill: #fff7e8; stroke: #c98a3a; stroke-width: 1.5; transition: fill 0.15s; }
.frac-svg.bar .part { stroke-width: 2; }
.frac-svg .part.on { fill: #ef6c4a; }
.frac-svg .part.revealed { fill: var(--reveal); }
.frac-svg.interactive .part { cursor: pointer; }
.prompt .frac-svg.pizza { width: min(200px, 55vw); }
.frac { display: inline-flex; flex-direction: column; align-items: center; line-height: 1.05; font-weight: 800; vertical-align: middle; margin: 0 4px; }
.frac .num { border-bottom: 3px solid currentColor; padding: 0 6px; }
.frac-prompt { font-size: clamp(1.4rem, 4.5vw, 2rem); font-weight: 800; display: flex; align-items: center; gap: 6px; }
.choices.fractions .choice { font-size: clamp(1.4rem, 4.5vw, 1.9rem); }
.frac-compare { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 520px; }
.fc-row { display: grid; grid-template-columns: 64px 1fr; align-items: center; gap: 10px; font-size: 1.5rem; }
.fc-row .frac-svg.bar { width: 100%; }

/* ===== Phase 4: shared bits ===== */
.say-btn.big { min-width: 72px; min-height: 72px; font-size: 2rem; }
.big-emoji { font-size: clamp(3.4rem, 12vw, 5rem); line-height: 1.1; display: block; text-align: center; }
.sentence { font-size: clamp(1.25rem, 3.8vw, 1.7rem); font-weight: 700; text-align: center; line-height: 1.6; }
.sentence .blank { padding: 0 6px; }
.read-word { font-size: clamp(2rem, 7vw, 3rem); font-weight: 800; letter-spacing: 1px; }
.picture.multi { font-size: clamp(1.4rem, 5vw, 2rem); letter-spacing: 2px; word-break: break-all; }
.equation.small { font-size: clamp(1.5rem, 5vw, 2.2rem); }
.story { font-size: clamp(1.05rem, 3vw, 1.25rem); font-weight: 600; line-height: 1.6; text-align: left; max-width: 640px; padding: 12px 16px; border-radius: var(--radius); background: var(--surface-2); border-left: 6px solid var(--primary); }
.situation { display: flex; gap: 12px; align-items: center; font-size: clamp(1.05rem, 3vw, 1.25rem); font-weight: 600; padding: 12px 16px; border-radius: var(--radius); background: var(--surface-2); }
.sit-emoji { font-size: 2.6rem; }
.letter-card { font-size: clamp(1.8rem, 6vw, 2.8rem); font-weight: 800; font-family: var(--font); }
.missing-word { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.mw-emoji { font-size: clamp(3rem, 10vw, 4rem); }
.mw-word { font-size: clamp(2rem, 7vw, 3rem); font-weight: 800; letter-spacing: 2px; }
.l2-prompt { display: flex; flex-direction: column; align-items: center; }
.l2-word { font-size: clamp(2rem, 7vw, 3rem); font-weight: 800; }
.folder { font-weight: 800; }
.file { display: inline-flex; align-items: center; gap: 6px; font-family: ui-monospace, Menlo, monospace; font-size: 0.95rem; }
.file-icon { font-size: 1.4rem; }
.bin-sense { display: flex; flex-direction: column; align-items: center; }
.bin-emoji.small { font-size: 2rem; }
.pattern { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; font-size: clamp(2rem, 7vw, 2.8rem); }
.pattern.numbers { font-size: clamp(1.4rem, 5vw, 2rem); font-weight: 800; }
.pat-item { min-width: 1.4em; text-align: center; }
.pat-item.q { color: var(--primary); border-bottom: 4px dashed var(--primary); }
.scene { position: relative; width: min(320px, 85vw); height: 200px; margin: 0 auto; border-radius: var(--radius); background: var(--surface-2); }
.sc-basket { position: absolute; top: 48%; transform: translate(-50%, -50%); font-size: 4rem; z-index: 2; }
.sc-animal { position: absolute; transform: translate(-50%, -50%); font-size: 2.6rem; z-index: 3; }
.scene.inside .sc-animal { z-index: 1; font-size: 2.2rem; }
.scene.small { width: 100%; max-width: 200px; height: 120px; }
.scene.small .sc-basket { font-size: 2.6rem; }
.scene.small .sc-animal { font-size: 1.7rem; }
.scene.small.inside .sc-animal { font-size: 1.4rem; }
.step-tile { display: flex; flex-direction: column; align-items: center; gap: 2px; line-height: 1.15; }
.step-tile small { font-size: 0.75rem; font-weight: 700; }
.step-emoji { font-size: 2rem; }
.geo-svg { width: min(320px, 85vw); height: auto; }
.geo-choice .geo-svg { width: 100%; max-width: 190px; }
.geo-line { stroke: var(--ink); stroke-width: 4; stroke-linecap: round; }
.geo-shape { fill: var(--select-bg); stroke: var(--ink); stroke-width: 4; stroke-linejoin: round; }
.geo-mark { fill: none; stroke: var(--accent); stroke-width: 3; }
.geo-dot { fill: var(--ink); }
.ruler-svg { width: 100%; max-width: 680px; height: auto; }
.ruler-body { fill: #ffe9a8; stroke: #b98f22; stroke-width: 2; }
.ruler-tick { stroke: #5b4a1a; stroke-width: 1.5; }
.ruler-num { font-size: 15px; font-weight: 800; fill: #5b4a1a; font-family: var(--font); }
.pencil { fill: #5b9cf5; stroke: #2b2f6b; stroke-width: 2; }
.pencil-tip { fill: #f3c27a; stroke: #2b2f6b; stroke-width: 2; }
.ruler-guide { stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 4 3; }
.target.wobble svg { animation: wobble 0.4s; }
@keyframes wobble { 25% { rotate: -8deg; } 75% { rotate: 8deg; } }

/* ===== Word guess (balloon) ===== */
.wordguess-engine { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.wg-top { display: flex; align-items: center; justify-content: center; gap: 16px; }
.wg-sky { width: 140px; transform: translateY(calc((1 - var(--alt, 1)) * 40px)); transition: transform 0.6s; }
.wg-sky.sway { animation: wobble 0.6s; }
.balloon-svg { width: 100%; height: auto; display: block; }
.balloon-svg .bag { transition: transform 0.6s, opacity 0.6s; }
.balloon-svg .bag.dropped { transform: translateY(60px); opacity: 0; }
.wg-clue { display: flex; align-items: center; gap: 8px; }
.wg-emoji { font-size: clamp(3rem, 10vw, 4rem); }
.wg-word { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.wg-slot { width: clamp(30px, 8vw, 44px); height: clamp(40px, 10vw, 54px); border-bottom: 4px solid var(--ink); display: grid; place-items: end center; font-size: clamp(1.4rem, 5vw, 2rem); font-weight: 800; }
.wg-slot.shown { color: var(--primary); }
.wg-word.revealed .wg-slot { color: #9a6700; }
.wg-sep { font-size: 1.6rem; align-self: end; }
.wg-keys { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 5px; width: 100%; max-width: 560px; }
.wg-key { min-height: 44px; border-radius: 10px; border: 2px solid var(--line); background: var(--surface); font-weight: 800; font-size: 1.1rem; touch-action: manipulation; }
.wg-key.hit { background: var(--good-bg); border-color: var(--good); color: var(--good); }
.wg-key.miss { background: var(--surface-2); color: var(--line); }

/* ===== Puzzle ===== */
.puzzle-engine { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.pz-board {
  display: grid; grid-template-columns: repeat(var(--cols), 1fr); grid-template-rows: repeat(var(--rows), 1fr);
  width: min(100%, 480px); aspect-ratio: 4 / 3; border: 3px solid var(--ink); border-radius: 10px; overflow: hidden; position: relative; background: var(--surface-2);
}
.pz-board.ghosted::before { content: ''; position: absolute; inset: 0; background: var(--img) center / cover; opacity: 0.18; pointer-events: none; }
.pz-board.complete { box-shadow: 0 0 0 5px var(--good); }
.pz-slot { border: 1px dashed var(--bin-line); position: relative; }
.pz-slot.hover, .has-selection .pz-slot:empty { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.pz-slot.nope { animation: shake 0.4s; }
.pz-slot .pz-piece { width: 100%; height: 100%; border: none; border-radius: 0; box-shadow: none; }
.pz-tray { display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 90px)); justify-content: center; gap: 8px; width: 100%; }
.pz-piece { aspect-ratio: var(--pa, 4 / 3); width: 100%; border-radius: 8px; border: 3px solid var(--line); background-color: var(--surface); background-repeat: no-repeat; touch-action: none; padding: 0; cursor: grab; }
.pz-piece.selected { border-color: var(--primary); box-shadow: 0 0 0 3px var(--accent); }
.pz-piece.revealed { outline: 3px solid var(--reveal); outline-offset: -3px; }
.ghost.pz-piece { width: 90px !important; }

/* ===== Scroll ===== */
.scroll-engine { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.scroll-prompt { font-size: 1.4rem; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.scroll-target { font-size: 2.6rem; }
.scroll-wrap { position: relative; width: 100%; max-width: 520px; }
.scroll-panel { height: 340px; overflow: auto; border-radius: var(--radius); border: 3px solid var(--ink); background: linear-gradient(180deg, #bde7ff, #2b6cb0); overscroll-behavior: contain; }
.scroll-panel.horizontal { overflow-x: auto; overflow-y: hidden; background: linear-gradient(90deg, #bde7ff, #2b6cb0); }
.scroll-content { position: relative; width: 100%; height: 100%; }
.scroll-panel.horizontal .scroll-content { height: 100%; }
.scroll-item { position: absolute; font-size: 2.4rem; background: none; border: none; padding: 4px; transform: translate(-50%, -50%); touch-action: manipulation; }
.scroll-item.found { animation: pop 0.6s forwards; }
.scroll-hint { position: absolute; right: 10px; bottom: 10px; font-size: 1.4rem; color: #fff; opacity: 0.8; pointer-events: none; }

/* ===== Teachers page ===== */
.lead { font-size: 1.1rem; color: var(--muted); max-width: 760px; }
.teacher-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); gap: 12px; }
.card-block { background: var(--surface); border-radius: var(--radius); padding: 4px 18px 12px; box-shadow: var(--shadow); }
.card-block h2 { margin-top: 0.8em; }
.check-list { list-style: none; padding: 0; }
.check-list li { padding-left: 1.6em; position: relative; margin: 6px 0; }
.check-list li::before { content: '✓'; position: absolute; left: 0; color: var(--good); font-weight: 800; }
.table-wrap { overflow-x: auto; border-radius: var(--radius); box-shadow: var(--shadow); }
.game-table { width: 100%; border-collapse: collapse; background: var(--surface); font-size: 0.95rem; }
.game-table th, .game-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.game-table th { background: var(--surface-2); font-size: 0.85rem; color: var(--muted); }
.game-table td small { display: block; color: var(--muted); }
.game-table td a { font-weight: 700; text-decoration: none; }
.teacher-banner { display: flex; gap: 14px; align-items: center; margin-top: 24px; padding: 14px 18px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); text-decoration: none; color: var(--ink); border-left: 6px solid var(--accent); }
.teacher-banner > span:first-child { font-size: 2.4rem; }
.site-footer a { color: var(--primary); font-weight: 700; }
.site-footer #footer p + p { margin-top: 6px; }
.head-actions { display: flex; gap: 6px; }
a.icon-btn { text-decoration: none; }
a.icon-btn[hidden] { display: none; }

/* ===== Worksheets ===== */
.ws-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.ws-toolbar .muted { flex-basis: 100%; font-size: 0.9rem; }
.ws-actions { display: flex; gap: 8px; }
.worksheet { background: #fff; color: #111; border-radius: 8px; padding: 24px 28px; margin-bottom: 18px; box-shadow: var(--shadow); font-size: 15px; }
.ws-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; border-bottom: 2px solid #111; padding-bottom: 8px; margin-bottom: 10px; }
.ws-title b { font-size: 1.2rem; }
.ws-fields { display: flex; gap: 18px; }
.ws-instructions { font-weight: 700; margin: 6px 0 12px; }
.ws-items { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 28px; padding: 0; margin: 0; list-style: none; counter-reset: q; }
.ws-items > li { counter-increment: q; position: relative; padding-left: 30px !important; }
.ws-items > li::before { content: counter(q) '.'; position: absolute; left: 0; top: 0; font-weight: 800; }
.ws-items.ws-wide, .ws-items.ws-order { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ws-items > li { break-inside: avoid; padding-left: 4px; }
.ws-items .prompt-text, .ws-items .sentence, .ws-items .story, .ws-items .reading-text { font-size: 15px !important; font-weight: 600; background: none; border: none; padding: 0; text-align: left; }
.ws-items .equation, .ws-items .big-number, .ws-items .read-word, .ws-items .mw-word, .ws-items .number-words { font-size: 22px !important; }
.ws-items .clock, .ws-items .frac-svg.pizza, .ws-items .geo-svg { width: 140px !important; height: auto; }
.ws-items .frac-svg.bar { width: 220px !important; }
.ws-items .ruler-svg { width: 100%; }
.ws-items .scene { transform: scale(0.75); transform-origin: left top; height: 160px; }
.ws-items .big-emoji, .ws-items .mw-emoji, .ws-items .order-hint, .ws-items .big-ear { font-size: 30px; }
.ws-items .count-board, .ws-items .dot-group { font-size: 20px; }
.ws-items .scale { transform: scale(0.7); transform-origin: left top; height: 110px; }
.ws-items .say-btn, .ws-items .radar { display: none; }
.ws-options { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 6px; }
.ws-option { display: inline-flex; align-items: center; gap: 6px; }
.ws-option .picture { font-size: 24px; }
.ws-option .sym small { display: none; }
.ws-option .scene.small { transform: none; width: 110px; height: 72px; flex: none; }
.ws-option .scene.small .sc-basket { font-size: 30px; }
.ws-option .scene.small .sc-animal { font-size: 18px; }
.ws-option .scene.small.inside .sc-animal { top: 20% !important; }
.ws-option .geo-choice .geo-svg { width: 100px !important; }
.ws-box { width: 14px; height: 14px; border: 2px solid #111; border-radius: 3px; flex: none; }
.ws-line { border-bottom: 1.5px solid #111; height: 28px; margin-top: 6px; }
.ws-blank { display: inline-block; min-width: 110px; border-bottom: 1.5px solid #111; margin: 0 4px; }
.ws-sentence { line-height: 2.2; }
.ws-shuffled { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.ws-tile { border: 1.5px solid #111; border-radius: 6px; padding: 2px 8px; }
.ws-tile .step-emoji { font-size: 18px; }
.ws-grid { display: grid; grid-template-columns: repeat(var(--cols), 30px); gap: 2px; font-size: 20px; font-weight: 700; }
.ws-cell { height: 30px; display: grid; place-items: center; }
.ws-boxcell { border: 1.5px solid #111; border-radius: 4px; }
.ws-scratch { border: 1px dashed #999; height: 18px; align-self: end; }
.ws-rule { grid-column: 1 / -1; border-top: 2px solid #111; }
.ws-key { columns: 2; padding-left: 1.4em; font-size: 15px; }
.ws-key li { break-inside: avoid; margin-bottom: 4px; }

@media print {
  @page { margin: 14mm; }
  body { background: #fff !important; }
  .site-header, .site-footer, .no-print, .skip-link { display: none !important; }
  .container { padding: 0; max-width: none; }
  .worksheet { box-shadow: none; padding: 0; margin: 0; border-radius: 0; }
  .worksheet.answers { break-before: page; }
}
@media (max-width: 600px) {
  .ws-items { grid-template-columns: 1fr !important; }
  .worksheet { padding: 16px; }
}

/* ===== Related ===== */
.related h2 { margin-top: 1.2em; }

/* ===== Animations (gentle, and disabled for reduced motion) ===== */
@keyframes shake { 0%, 100% { translate: 0; } 25% { translate: -6px; } 75% { translate: 6px; } }
@keyframes bounce { 0% { scale: 1; } 40% { scale: 1.08; } 100% { scale: 1; } }
@keyframes pulse { 0%, 100% { scale: 1; } 50% { scale: 1.07; } }
@keyframes pop { to { transform: scale(1.6); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
@keyframes star-in { from { transform: scale(0) rotate(-90deg); } to { transform: none; } }
@keyframes glow { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--good) 35%, transparent); } }
@keyframes vanish { 60% { opacity: 1; scale: 1.05; } to { opacity: 0.25; scale: 0.92; } }
.shake { animation: shake 0.4s; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* ===== Small screens ===== */
@media (max-width: 600px) {
  .hero { flex-direction: column; text-align: center; padding: 16px; }
  .promise { justify-content: center; }
  .planets { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .planet-img svg { width: 72px; height: 72px; }
  .subjects { grid-template-columns: repeat(2, 1fr); }
  .cards-grid { grid-template-columns: 1fr; }
  .site-header { position: static; }
  .logo-name { font-size: 1rem; }
  .controls { width: 100%; flex-wrap: nowrap; }
  .controls select { flex: 1 1 0; min-width: 0; max-width: none; min-height: 40px; font-size: 0.9rem; text-overflow: ellipsis; }
  .choices { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .choices.numbers, .choices.symbols { grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 8px; }
  .choices.numbers .choice { min-height: 72px; }
  .shell-bip svg { width: 38px; height: 44px; }
  .instruction .bubble { font-size: 0.95rem; }
  .bins { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bin { min-height: 120px; }
  .item { min-width: 64px; min-height: 64px; }
  .scale { height: 130px; }
  .scale-pan { min-width: 80px; padding: 8px; }
  .stage { min-height: 300px; }
  .level-desc { flex-basis: 100%; }
  .choices.answers { grid-template-columns: 1fr; }
  .kb-key { border-width: 1px; border-radius: 6px; }
  .type-row .btn { padding: 8px 12px; }
  .arrow-pad { grid-template-columns: repeat(3, 52px); grid-template-rows: repeat(3, 52px); }
  .blocks-kit { gap: 6px; }
  .blk-col { padding: 6px 4px; }
  .blk-h svg { width: 36px; height: 36px; }
  .pile { min-height: 90px; }
  .wg-keys { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .pz-tray { grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); }
  .scroll-panel { height: 300px; }
}
