/**
 * The syllabus pages — Nursery to Class 5.
 *
 * Designed for a 1280 × 800 smart board first, then a tablet, then a phone in
 * a parent's hand: the same screens reflow rather than having a phone version.
 * Targets are large (48px and up) because the hands using them are small and
 * not yet accurate, and nothing important depends on hover.
 *
 * Colour comes in three layers of custom property:
 *   --g-*      the class's theme (Class 1 blue, Class 3 orange…), set by
 *              app.js from the curriculum, so a teacher can tell at a glance
 *              which class the board is on.
 *   --a, --soft  the subject's accent: English indigo, Maths green, Hindi
 *              saffron — the same in every class.
 *   the rest   the shared ink, surfaces and feedback colours below.
 *
 * Baloo 2 is the only face: bundled, rounded, and it has real Devanagari.
 */

:root {
  --ink: #1A1B4B;
  --muted: #4A4B72;
  --faint: #9A99B5;
  --line: #E6E2F7;
  --surface: #FFFFFF;
  --surface-2: #F7F6FC;
  --good: #22B07A;
  --good-bg: #E7F7EE;
  --good-ink: #0E6B3D;
  --bad: #E0453A;
  --bad-bg: #FFE9E4;
  --bad-ink: #A12A20;
  --warn-bg: #FFF4D2;
  --warn-ink: #8A5E00;
  --sun: #FFC21A;
  --shadow: 0 14px 28px -14px rgba(40, 60, 140, .45);
  --shadow-lg: 0 24px 50px -22px rgba(40, 60, 140, .55);
  --radius: 26px;

  --g: #3B3FD8;
  --g-panel: #4C6FFF;
  --g-sky: #DDF3FF;
  --g-hill1: #C3EFC9;
  --g-hill2: #8FE0A8;
  --g-glow: rgba(59, 63, 216, .5);
  --a: #3B3FD8;
  --soft: #E3E4FF;

  --gutter: clamp(14px, 2.4vw, 32px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: 'Baloo 2', system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans Devanagari', sans-serif;
  font-weight: 600;
  background: linear-gradient(180deg, #DDF3FF 0%, #EEF8FF 45%, #FBF8F3 100%);
  -webkit-font-smoothing: antialiased;
}
body.themed { background: linear-gradient(180deg, var(--g-sky) 0%, #FFFFFF 70%); }

button, input, textarea { font: inherit; color: inherit; }
a { color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.1; font-weight: 800; }
p { margin: 0; }
.deva { line-height: 1.5; }
.hide-sm { display: inline; }
.grow { flex: 1 1 auto; }
.noscript { padding: 24px; }

:focus-visible { outline: 4px solid var(--sun); outline-offset: 3px; border-radius: 14px; }

/* ================================================================ backdrop */

.backdrop { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.backdrop .clouds { position: absolute; top: 0; left: 0; width: 100%; height: 220px; }
.backdrop .cloud { animation: cloud-drift 15s ease-in-out infinite; }
.backdrop .cloud.c2 { animation-duration: 12s; animation-direction: reverse; }
.backdrop .cloud.c3 { animation-duration: 19s; }
.backdrop .hills { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: min(26vh, 200px); }
@keyframes cloud-drift { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(46px); } }

/* The lesson screens sit in the same playroom as the tracing lessons
   (src/styles.css, "The classroom the app is used in"): one room for every
   class, Nursery to Class 5, instead of a sky per class. The class keeps its
   colour on its own buttons, badges and pack card. #app only: index.html
   uses .backdrop for its own sky. The colour is the fallback while the
   picture loads, the same as the tracing page's. */
#app > .backdrop { background: #1d4b63; }
/* The picture is softened, as on the tracing page (src/styles.css), so the
   lesson in front reads as the thing in focus. It sits on its own layer
   inset past the edges, because a blur fades at its borders and the
   backdrop's overflow: hidden clips the faded rim off. */
#app > .backdrop::before {
  content: '';
  position: absolute; inset: -30px;
  background: url('../../bg.webp') center / cover no-repeat;
  filter: blur(7px);
}
/* At z-index -1 the layer went under body's own background (html and body
   both paint one), so nothing behind the lessons was ever seen. Layer 0, with
   the screen stacked above it. */
#app > .backdrop { z-index: 0; }
#app > .screen { position: relative; z-index: 1; }
#app > .backdrop .clouds, #app > .backdrop .hills { display: none; }
/* Headings that stood straight on the pale sky get a card of their own, or
   they would be lost against the room. */
#app .syl-head, #app .step-head {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px clamp(16px, 2vw, 24px);
}

.bubbles-bg { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.float-bubble {
  position: absolute; left: var(--x); top: var(--y);
  width: var(--s); height: var(--s); border-radius: 30%;
  display: grid; place-items: center;
  background: #FFFFFF; color: #6C5CF5; opacity: .75;
  font-weight: 800; font-size: calc(var(--s) * .55);
  box-shadow: 0 12px 22px -14px rgba(40, 60, 140, .45);
  animation: bubble var(--d) ease-in-out infinite; animation-delay: var(--delay);
}
.float-bubble:nth-child(3n) { color: #E8357E; background: #FFE6F0; }
.float-bubble:nth-child(3n+1) { color: #13804F; background: #DDF4E7; }
@keyframes bubble {
  0%, 100% { transform: translate(0, 0) rotate(var(--r)); }
  33% { transform: translate(10px, -30px) rotate(calc(var(--r) * -1)); }
  66% { transform: translate(-8px, -14px) rotate(var(--r)); }
}

/* ================================================================== layout */

.app { min-height: 100dvh; }
/* The top bar runs the full width of the screen; everything under it stays
   in a centred column, 1216px at most (the old 1280px less the gutters). */
.screen {
  padding: max(14px, env(safe-area-inset-top)) max(var(--gutter), env(safe-area-inset-right)) calc(28px + env(safe-area-inset-bottom)) max(var(--gutter), env(safe-area-inset-left));
  display: flex; flex-direction: column; gap: 18px;
  min-height: 100dvh;
}
.screen:not(.loading, .error-screen) > :not(.topbar, .account-card) { width: 100%; max-width: 1216px; margin-inline: auto; }
.loading, .error-screen { align-items: center; justify-content: center; text-align: center; gap: 14px; }

/* ================================================================== top bar */

.topbar { display: flex; align-items: center; gap: 10px; min-height: 56px; flex-wrap: wrap; }
.pill-btn, .mini-pill {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 52px; padding: 0 18px 0 6px; border-radius: 999px;
  background: var(--surface); color: var(--ink); text-decoration: none;
  font-weight: 800; font-size: 16px; box-shadow: var(--shadow);
  border: 0; cursor: pointer;
}
.pill-ico, .grade-badge {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  background: var(--soft); color: var(--a);
}
.grade-badge { background: var(--g); color: #FFFFFF; font-size: 15px; }
/* Back, top left of every screen: solid, so it reads as the way out. */
.back-btn { background: var(--a); color: #FFFFFF; padding-right: 20px; }
.back-btn .pill-ico { background: rgba(255, 255, 255, .22); color: #FFFFFF; }
.back-btn:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
.pill-ico svg, .mini-ico svg, .btn-icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.brand { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; font-weight: 800; font-size: 20px; }
.brand img { height: 46px; width: auto; border-radius: 12px; }

.series { display: flex; gap: 6px; padding: 6px; background: var(--surface); border-radius: 999px; box-shadow: var(--shadow); }
.series-dot {
  min-width: 40px; height: 40px; padding: 0 8px; border-radius: 999px; display: inline-grid; place-items: center;
  text-decoration: none; font-weight: 800; color: var(--g); box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--g) 25%, transparent);
}
.series-dot.on { background: var(--g); color: #FFFFFF; box-shadow: 0 8px 14px -6px var(--g); }

/* ================================================================== buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 54px; padding: 0 22px; border-radius: 999px; border: 0;
  font-weight: 800; font-size: 17px; text-decoration: none; cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, opacity .15s;
  touch-action: manipulation; user-select: none;
}
.btn:active { transform: translateY(2px) scale(.98); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn-primary { background: var(--a); color: #FFFFFF; box-shadow: 0 14px 24px -12px var(--a); }
.btn-soft { background: var(--soft); color: var(--a); }
.btn-ghost { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 2px var(--line); }
.btn-danger { background: var(--bad); color: #FFFFFF; }
.btn-hint { background: var(--sun); color: var(--ink); box-shadow: 0 12px 20px -12px #E8A000; width: 100%; }
.btn-hint:disabled { background: var(--line); color: var(--faint); box-shadow: none; }
.btn-small { min-height: 44px; font-size: 15px; padding: 0 16px; }
.btn-icon-only { min-height: 44px; width: 44px; padding: 0; margin-left: 8px; vertical-align: middle; box-shadow: none; background: var(--soft); color: var(--a); }
.btn-icon { display: inline-grid; place-items: center; }
.btn-next {
  max-width: 300px; background: var(--g); color: #FFFFFF; padding: 0 8px 0 18px;
  box-shadow: 0 12px 22px -12px var(--g);
}
.btn-next .btn-icon { width: 40px; height: 40px; border-radius: 50%; background: #FFFFFF; color: var(--g); }
.ellip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============================================================= class picker */

.picker-head { text-align: center; padding: 8px 0 4px; }
.picker-head h1 { font-size: clamp(34px, 5vw, 56px); }
.picker-head p { color: var(--muted); font-size: clamp(16px, 2vw, 20px); margin-top: 6px; }

.class-grid {
  display: grid; gap: clamp(12px, 2vw, 22px);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
}
.class-card {
  position: relative; display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto auto auto;
  column-gap: 16px; row-gap: 2px; align-items: center;
  padding: 18px; border-radius: var(--radius); text-decoration: none;
  background: var(--surface); box-shadow: var(--shadow-lg);
  transition: transform .25s cubic-bezier(.3, 1.5, .5, 1);
}
.class-card:hover, .class-card:focus-visible { transform: translateY(-6px) rotate(calc(var(--tilt) * .3)); }
.class-big {
  grid-row: 1 / span 3; width: 92px; height: 92px; border-radius: 26px;
  display: grid; place-items: center; color: #FFFFFF; font-weight: 800; font-size: 46px;
  background: linear-gradient(150deg, var(--panel), var(--c)); box-shadow: 0 14px 24px -12px var(--glow);
  animation: card-bob 3.6s ease-in-out infinite; animation-delay: var(--delay);
}
@keyframes card-bob { 0%, 100% { transform: translateY(0) rotate(var(--tilt)); } 50% { transform: translateY(-6px) rotate(calc(var(--tilt) * -1)); } }
.class-tag { font-size: 12px; letter-spacing: .08em; color: var(--c); font-weight: 800; }
.class-name { font-size: 28px; font-weight: 800; line-height: 1; }
.class-sub { font-size: 15px; color: var(--muted); line-height: 1.25; }
.class-meter, .meter-bar { grid-column: 1 / -1; height: 10px; border-radius: 999px; background: var(--line); overflow: hidden; margin-top: 12px; display: block; }
.class-meter span, .meter-bar span { display: block; height: 100%; border-radius: inherit; background: var(--c, var(--a)); transition: width .6s ease; }
.class-go { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; margin-top: 10px; font-weight: 800; color: var(--c); }
.class-go span { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--c); color: #FFFFFF; }
.class-go svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }

/* ================================================================= account */

.account-pill.on .pill-ico { background: var(--good-bg); color: var(--good-ink); }
.account-card {
  width: 100%; max-width: 560px; margin: clamp(8px, 4vh, 40px) auto 0;
  display: flex; flex-direction: column; gap: 14px;
  padding: clamp(20px, 3vw, 32px); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow-lg);
}
.account-card h1 { font-size: clamp(28px, 4vw, 40px); }
.account-card > p { color: var(--muted); font-size: 17px; line-height: 1.45; }
.account-card .q-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.account-note { font-size: 14.5px !important; }
.account-who { display: flex; align-items: center; gap: 14px; }
.account-avatar {
  flex: none; width: 64px; height: 64px; border-radius: 22px; display: grid; place-items: center;
  background: linear-gradient(150deg, #4C6FFF, #3B3FD8); color: #FFFFFF; font-size: 30px; font-weight: 800;
}
.account-sub { color: var(--muted); }
.account-form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 800; }
.field input {
  min-height: 54px; padding: 0 16px; border-radius: 16px; border: 2px solid var(--line);
  background: var(--surface-2); font-size: 18px; font-weight: 700;
}
.field input:focus { outline: none; border-color: #3B3FD8; background: var(--surface); }
.field small { color: var(--faint); font-weight: 600; }
.account-error { color: var(--bad-ink); font-weight: 800; min-height: 1.2em; }
.account-error:empty { display: none; }

/* =============================================================== pack cover */

.pack-hero {
  display: flex; gap: clamp(16px, 3vw, 32px); align-items: center;
  padding: clamp(18px, 3vw, 30px); border-radius: 34px;
  background: linear-gradient(140deg, var(--g-panel), var(--g)); color: #FFFFFF;
  box-shadow: 0 30px 50px -28px var(--g-glow);
}
.pack-badge {
  flex: none; width: clamp(96px, 14vw, 150px); aspect-ratio: 1; border-radius: 34%;
  display: grid; place-items: center; background: rgba(255, 255, 255, .2);
  font-size: clamp(48px, 8vw, 84px); font-weight: 800; box-shadow: inset 0 0 0 4px rgba(255, 255, 255, .35);
  animation: card-bob 4s ease-in-out infinite; --tilt: -4deg;
}
.pack-tag { font-size: 13px; letter-spacing: .1em; opacity: .9; }
.pack-copy h1 { font-size: clamp(34px, 5vw, 58px); margin: 4px 0 6px; }
.pack-goal { font-size: clamp(16px, 2vw, 21px); }
.pack-books { font-size: 14px; opacity: .85; margin-top: 6px; }

.subject-grid { display: grid; gap: clamp(12px, 2vw, 22px); grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.subject-card {
  display: flex; flex-direction: column; gap: 12px; padding: 20px; border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow-lg); border-top: 8px solid var(--a);
}
.subject-top { display: flex; gap: 14px; align-items: center; }
.subject-glyph {
  width: 72px; height: 72px; border-radius: 22px; display: grid; place-items: center; flex: none;
  background: var(--card); color: var(--a); font-size: 42px; font-weight: 800;
}
.subject-top h2 { font-size: 28px; }
.subject-count { color: var(--muted); font-size: 15px; }
.kind-row { display: flex; flex-wrap: wrap; gap: 6px; }
.kind-chip, .mini-pill.kind {
  display: inline-flex; align-items: center; padding: 4px 12px; border-radius: 999px;
  background: var(--kb); color: var(--kf); font-size: 13px; font-weight: 800; white-space: nowrap;
}
.subject-card .meter-bar span { background: var(--a); }
.up-next { display: flex; flex-direction: column; color: var(--muted); font-size: 14px; }
.up-next b { color: var(--ink); font-size: 18px; }
.subject-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: auto; }
.subject-actions .btn { flex: 1 1 auto; }

/* ================================================================= syllabus */

.seg { display: inline-flex; gap: 4px; padding: 6px; border-radius: 999px; background: var(--surface); box-shadow: var(--shadow); flex-wrap: wrap; }
.seg-btn {
  min-height: 44px; padding: 0 18px; border-radius: 999px; border: 0; background: transparent;
  display: inline-flex; align-items: center; text-decoration: none; font-weight: 800; color: var(--muted); cursor: pointer;
}
.seg-btn.on { background: var(--a); color: #FFFFFF; }
.syl-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.syl-head h1 { font-size: clamp(30px, 4.4vw, 46px); }
.syl-head p { color: var(--muted); font-size: 17px; }
.syl-score { display: flex; align-items: center; gap: 10px; background: var(--surface); border-radius: 999px; padding: 8px 18px; box-shadow: var(--shadow); font-weight: 800; }

.step-path { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; position: relative; }
.step-path::before { content: ''; position: absolute; left: 35px; top: 20px; bottom: 20px; width: 6px; border-radius: 6px; background: repeating-linear-gradient(var(--line) 0 12px, transparent 12px 22px); }
.step-link {
  position: relative; display: grid; grid-template-columns: 52px 1fr auto auto; align-items: center; gap: 14px;
  padding: 12px 18px 12px 10px; border-radius: 22px; background: var(--surface); box-shadow: var(--shadow);
  text-decoration: none; transition: transform .2s;
}
.step-link:hover { transform: translateX(4px); }
.step-n {
  width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center;
  background: var(--soft); color: var(--a); font-weight: 800; font-size: 22px;
}
.step-n svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 3.4; stroke-linecap: round; stroke-linejoin: round; }
.step-node.done .step-n { background: var(--good); color: #FFFFFF; }
.step-node.next .step-link { box-shadow: 0 0 0 4px var(--sun), var(--shadow-lg); }
.step-node.next .step-n { background: var(--a); color: #FFFFFF; animation: pulse-ring 1.8s ease-out infinite; }
@keyframes pulse-ring { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--a) 50%, transparent); } 100% { box-shadow: 0 0 0 16px transparent; } }
.step-copy { display: flex; flex-direction: column; min-width: 0; }
.step-title { font-size: 20px; font-weight: 800; }
.step-sub { color: var(--muted); font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.partial, .next-tag { font-weight: 800; font-size: 14px; color: var(--a); background: var(--soft); padding: 4px 12px; border-radius: 999px; }
.next-tag { background: var(--sun); color: var(--ink); }

/* ================================================================ step shell */

.step-head { display: flex; flex-direction: column; gap: 6px; }
.chips-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.mini-pill { min-height: 36px; padding: 0 14px 0 8px; font-size: 13px; box-shadow: none; }
.mini-pill.solid { background: var(--a); color: #FFFFFF; padding: 0 14px; }
.mini-pill.kind { min-height: 36px; padding: 0 14px; }
.mini-ico svg { width: 14px; height: 14px; stroke-width: 3; }
.step-h1 { font-size: clamp(28px, 4vw, 40px); }
.step-lede, .step-intro { color: var(--muted); font-size: clamp(15px, 1.8vw, 18px); }
.stage { flex: 1 1 auto; display: flex; flex-direction: column; gap: 16px; }

.card, .rule-card, .try-card, .practice-board, .practice-panel, .solve-main, .solve-side > *, .read-stage, .read-side,
.poem-side, .poem-main, .book, .write-task, .write-pad, .match, .game-play, .game-ladder, .trace-side, .trace-main {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: clamp(14px, 2vw, 22px);
}

.q-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.q-count, .chip-label { font-weight: 800; color: var(--muted); font-size: 15px; }
.chip-label { background: var(--soft); color: var(--a); padding: 4px 12px; border-radius: 999px; }
.pips { display: inline-flex; gap: 6px; align-items: center; }
.pip { width: 10px; height: 10px; border-radius: 999px; background: var(--line); transition: width .3s; }
.pip.done { background: var(--good); }
.pip.now { width: 28px; background: var(--a); }
.q-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; margin-top: auto; }

.feedback { border-radius: 16px; padding: 12px 16px; background: var(--surface-2); color: var(--muted); font-weight: 700; font-size: 17px; }
.feedback.good { background: var(--good-bg); color: var(--good-ink); }
.feedback.bad { background: var(--bad-bg); color: var(--bad-ink); }
.feedback.warn { background: var(--warn-bg); color: var(--warn-ink); }

.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  min-height: 52px; padding: 0 20px; border-radius: 18px; border: 0; cursor: pointer;
  background: var(--surface); color: var(--ink); font-weight: 800; font-size: 20px;
  box-shadow: 0 0 0 2px var(--line); transition: transform .15s, background .15s;
}
.chip:active { transform: scale(.96); }
.chip.small { min-height: 44px; font-size: 16px; padding: 0 14px; border-radius: 14px; }
.chip.big { min-height: 64px; font-size: 24px; padding: 0 26px; }
.chip.starter { font-size: 16px; min-height: 46px; background: var(--surface-2); }
.chip.on { background: var(--g); color: #FFFFFF; box-shadow: 0 10px 18px -10px var(--g); }
.chip.right { background: var(--good); color: #FFFFFF; box-shadow: 0 10px 18px -10px var(--good); }
.chip.wrong { background: var(--bad); color: #FFFFFF; box-shadow: none; }
.chip.missed { box-shadow: 0 0 0 4px var(--good); }

.stars { display: inline-flex; gap: 3px; }
.star { width: var(--star); height: var(--star); display: inline-block; }
.star svg { width: 100%; height: 100%; fill: var(--line); stroke: #D3CFE8; stroke-width: 1.4; stroke-linejoin: round; }
.star.on svg { fill: #FFC21A; stroke: #E8A000; }
.stars .star.on { animation: star-pop .5s cubic-bezier(.3, 1.8, .5, 1) both; }
.stars .star:nth-child(2) { animation-delay: .12s; }
.stars .star:nth-child(3) { animation-delay: .24s; }
@keyframes star-pop { from { transform: scale(0) rotate(-30deg); } to { transform: none; } }

/* ================================================================ pictures */

.pic { display: inline-grid; place-items: center; width: var(--pic, 160px); max-width: 100%; aspect-ratio: 120 / 104; }
.pic svg { width: 100%; height: 100%; display: block; overflow: visible; }
.pic-bob svg { animation: pic-bob 2.4s ease-in-out infinite; }
@keyframes pic-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
.pic-empty { border-radius: 24px; background: radial-gradient(circle at 50% 40%, var(--soft), transparent 70%); }

/* ================================================================== trace */

.trace-layout { display: grid; grid-template-columns: minmax(220px, 300px) 1fr; gap: 16px; flex: 1 1 auto; }
.trace-side { display: flex; flex-direction: column; gap: 12px; }
.trace-card { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 16px; border-radius: 22px; background: var(--soft); }
.trace-lead { color: var(--a); font-weight: 800; font-size: 18px; }
.trace-word { font-size: clamp(34px, 5vw, 52px); font-weight: 800; line-height: 1.1; }
.trace-sub { color: var(--muted); font-size: 16px; }
.trace-tip { padding: 12px 14px; border-radius: 16px; background: var(--warn-bg); color: var(--warn-ink); font-weight: 800; }
.trace-main { display: flex; flex-direction: column; gap: 12px; }
.trace-board {
  position: relative; flex: 1 1 auto; min-height: clamp(220px, 46vh, 520px);
  display: grid; place-items: center; border-radius: 22px;
  background: repeating-linear-gradient(0deg, transparent 0 39px, rgba(26, 27, 75, .035) 39px 40px), var(--surface-2);
}
.trace-canvas { display: block; touch-action: none; cursor: crosshair; }
.trace-controls { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.trace-strip { display: flex; gap: 8px; overflow-x: auto; padding: 6px 4px 10px; scrollbar-width: thin; }
.strip-item {
  flex: none; min-width: 56px; min-height: 56px; padding: 0 14px; border-radius: 16px; border: 0; cursor: pointer;
  background: var(--surface); box-shadow: 0 0 0 2px var(--line); font-weight: 800; font-size: 24px;
}
.strip-item.done { background: var(--good-bg); color: var(--good-ink); }
.strip-item.now { background: var(--a); color: #FFFFFF; box-shadow: 0 10px 18px -10px var(--a); }
.count-pic { width: 150px; }

/* =================================================================== read */

.read-layout { display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px; flex: 1 1 auto; }
.read-stage { display: flex; flex-direction: column; gap: 14px; }
.read-big { flex: 1 1 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center; min-height: 280px; padding: 14px; border-radius: 22px; background: var(--soft); }
.read-text { font-weight: 800; line-height: 1.15; overflow-wrap: anywhere; }
.read-text.fs-xl { font-size: clamp(72px, 12vw, 120px); }
.read-text.fs-lg { font-size: clamp(44px, 7vw, 68px); }
.read-text.fs-md { font-size: clamp(28px, 4vw, 42px); }
.read-text.fs-sm { font-size: clamp(22px, 3vw, 32px); }
.read-sub { color: var(--muted); font-size: 20px; }
.read-nav { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.read-side { display: flex; flex-direction: column; gap: 10px; }
.read-side-head { display: flex; justify-content: space-between; color: var(--muted); font-weight: 800; }
.read-count { color: var(--a); }
.read-grid { display: grid; gap: 8px; grid-template-columns: repeat(3, minmax(0, 1fr)); align-content: start; }
.read-grid.many { grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); }
.read-grid.list { grid-template-columns: minmax(0, 1fr); }
.read-card {
  min-height: 62px; padding: 8px 12px; border-radius: 16px; border: 0; cursor: pointer; text-align: center;
  background: var(--surface-2); box-shadow: inset 0 0 0 2px #ECE9F6; font-weight: 800; font-size: 22px; position: relative;
}
.read-grid.list .read-card { text-align: left; font-size: 18px; }
.read-card.now { background: var(--a); color: #FFFFFF; box-shadow: 0 10px 18px -10px var(--a); }
.read-card.seen::after { content: '✓'; position: absolute; top: 4px; right: 8px; font-size: 13px; color: var(--good); }

/* ============================================================== practice */

.practice { display: flex; flex-direction: column; gap: 14px; flex: 1 1 auto; }
.practice-body { display: grid; grid-template-columns: 1.1fr 1fr; gap: 16px; flex: 1 1 auto; }
.practice-board { display: grid; place-items: center; min-height: 280px; }
.vis-wrap, .vis { width: 100%; max-width: 520px; }
.vis text { paint-order: stroke; }
.practice-panel { display: flex; flex-direction: column; gap: 14px; }
.q-text { font-size: clamp(24px, 3vw, 34px); }
.options { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.options.long { grid-template-columns: 1fr; }
.option {
  display: flex; align-items: center; gap: 12px; min-height: 66px; padding: 8px 16px 8px 8px;
  border-radius: 20px; border: 0; cursor: pointer; text-align: left;
  background: var(--surface-2); box-shadow: inset 0 0 0 2px #ECE9F6; font-weight: 800; font-size: 24px;
  transition: transform .15s;
}
.option-key { flex: none; width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: var(--surface); color: var(--a); font-size: 20px; }
.option.on { background: var(--a); color: #FFFFFF; box-shadow: 0 10px 18px -10px var(--a); }
.option.on .option-key { background: rgba(255, 255, 255, .25); color: #FFFFFF; }
.option.right { background: var(--good); }
.option.wrong { background: var(--bad); }

/* ================================================================== solve */

.solve { display: flex; flex-direction: column; gap: 12px; flex: 1 1 auto; }
.solve-stars { margin-left: auto; }
.solve-body { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; flex: 1 1 auto; }
.solve-main { display: flex; flex-direction: column; gap: 14px; align-items: center; text-align: center; }
.solve-q { font-size: clamp(44px, 7vw, 72px); }
.solve-q.word { font-size: clamp(26px, 3.6vw, 40px); }
.slots { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.slot {
  width: 72px; height: 84px; border-radius: 18px; display: grid; place-items: center;
  border: 3px dashed #D3CFE8; font-size: 48px; font-weight: 800; background: var(--surface);
}
.slot.filled { border: 3px solid var(--a); }
.slot.right { border-color: var(--good); background: var(--good-bg); color: var(--good-ink); }
.pad { display: grid; grid-template-columns: repeat(3, 76px); gap: 10px; justify-content: center; }
.pad.tiles { grid-template-columns: repeat(4, 70px); }
.key {
  height: 64px; border-radius: 18px; border: 0; cursor: pointer; font-size: 30px; font-weight: 800;
  background: #EEF0FF; color: var(--ink); box-shadow: inset 0 0 0 2px #ECE9F6, 0 4px 0 #D9D5F0; transition: transform .1s;
}
.key:active { transform: translateY(3px); box-shadow: inset 0 0 0 2px #ECE9F6; }
.key:disabled { opacity: .35; }
.key-del { background: var(--bad-bg); color: var(--bad-ink); font-size: 22px; }
.solve-side { display: flex; flex-direction: column; gap: 14px; }
.helper { display: grid; place-items: center; min-height: 200px; }
.helper-locked { color: var(--muted); text-align: center; padding: 18px; border-radius: 18px; background: var(--surface-2); border: 3px dashed var(--line); }
.hints { display: flex; flex-direction: column; gap: 10px; }
.hints-title { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 20px; }
.mascot svg { width: 40px; height: 40px; fill: var(--sun); stroke: #E8A000; stroke-width: 1.4; animation: pic-bob 2s ease-in-out infinite; }
.hint-idle { color: var(--muted); }
.hint-list { margin: 0; padding-left: 22px; display: grid; gap: 8px; }
.hint-list li { background: var(--warn-bg); color: var(--warn-ink); border-radius: 14px; padding: 8px 12px; font-weight: 700; animation: slide-in .35s ease both; }
@keyframes slide-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.solved { display: flex; flex-direction: column; align-items: center; gap: 8px; animation: slide-in .4s ease both; }
.solved-praise { font-size: 40px; font-weight: 800; color: var(--good-ink); }
.solved-say { font-size: 26px; font-weight: 800; }
.solved-note { color: var(--muted); }

/* ================================================================ grammar */

.grammar { display: grid; grid-template-columns: 1fr 1.3fr; gap: 16px; flex: 1 1 auto; }
.rule-card { display: flex; flex-direction: column; gap: 12px; background: linear-gradient(160deg, var(--surface), var(--soft)); }
.rule-label { font-size: 13px; letter-spacing: .12em; color: var(--a); font-weight: 800; }
.rule-topic { font-size: clamp(28px, 3.6vw, 40px); }
.rule-text { font-size: 20px; }
.rule-example { padding: 14px; border-radius: 18px; background: var(--surface); box-shadow: inset 0 0 0 2px var(--line); font-size: 19px; }
.rule-ex-label { display: block; font-size: 13px; letter-spacing: .1em; color: var(--muted); }
.try-card { display: flex; flex-direction: column; gap: 14px; }
.try-prompt { font-size: clamp(20px, 2.4vw, 26px); font-weight: 800; }
.chips.sentence .chip { font-size: 26px; min-height: 60px; }
.blank-sentence { font-size: clamp(22px, 3vw, 32px); font-weight: 700; line-height: 1.6; }
.blank-sentence.big { font-size: clamp(24px, 3.4vw, 36px); }
.blank { display: inline-block; min-width: 3.4em; text-align: center; padding: 0 10px; margin: 0 4px; border-radius: 12px; border-bottom: 4px dashed var(--faint); color: var(--warn-ink); background: var(--warn-bg); }
.blank.filled { border-bottom-style: solid; border-color: var(--g); color: var(--ink); background: var(--soft); }
.blank.right { background: var(--good-bg); border-color: var(--good); color: var(--good-ink); }

/* =================================================================== poem */

.poem { display: grid; grid-template-columns: minmax(240px, 340px) 1fr; gap: 16px; flex: 1 1 auto; }
.poem-side { display: flex; flex-direction: column; gap: 14px; align-items: center; text-align: center; background: linear-gradient(180deg, var(--soft), var(--surface) 70%); }
.poem-art { position: relative; display: grid; place-items: center; padding: 10px; }
.poem-art.singing .pic svg { animation: sing .6s ease-in-out infinite; }
@keyframes sing { 0%, 100% { transform: rotate(-3deg) scale(1); } 50% { transform: rotate(3deg) scale(1.05); } }
.poem-sparkles span {
  position: absolute; color: var(--sun); font-size: 22px; left: calc(10% + var(--i) * 19%); top: calc(8% + (var(--i) * 37 % 70) * 1%);
  animation: twinkle 2.6s ease-in-out infinite; animation-delay: calc(var(--i) * -.5s);
}
@keyframes twinkle { 0%, 100% { opacity: .15; transform: scale(.5) rotate(0); } 50% { opacity: 1; transform: scale(1.15) rotate(45deg); } }
.poem-title { font-size: clamp(26px, 3.2vw, 36px); }
.poem-credit { color: var(--muted); font-size: 14px; }
.poem-words { width: 100%; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.words-label { font-size: 13px; letter-spacing: .1em; color: var(--muted); font-weight: 800; text-transform: uppercase; }
.poem-main { display: flex; flex-direction: column; gap: 14px; }
.poem-body { display: flex; flex-direction: column; gap: 14px; flex: 1 1 auto; }
.poem-lines { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.poem-line-btn {
  width: 100%; display: flex; align-items: center; gap: 14px; text-align: left; cursor: pointer;
  padding: 14px 16px; border-radius: 20px; border: 0; background: var(--surface-2); font-size: clamp(20px, 2.6vw, 27px); font-weight: 700;
  transition: background .2s, box-shadow .2s;
}
.line-n { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: 16px; font-weight: 800; background: #C9C4EE; color: #FFFFFF; }
.poem-line.heard .line-n { background: var(--good); }
.poem-line.now .poem-line-btn { background: #FFF4D2; box-shadow: inset 0 0 0 3px #FFC93C; }
.poem-line.now .line-n { background: var(--g); }
.w { border-radius: 8px; padding: 0 2px; transition: background .15s, color .15s, transform .15s; display: inline-block; }
.w.lit { background: var(--g); color: #FFFFFF; transform: translateY(-2px) scale(1.06); }
.w.focus { box-shadow: inset 0 -5px 0 #FFC93C; }
.poem-controls { display: flex; gap: 10px; flex-wrap: wrap; }

/* ================================================================== story */

.story { display: flex; flex-direction: column; gap: 12px; flex: 1 1 auto; }
.story-title { font-size: clamp(26px, 3.4vw, 38px); }
.book { display: flex; flex-direction: column; gap: 14px; flex: 1 1 auto; background: linear-gradient(180deg, var(--g-panel), var(--g)); color: #FFFFFF; touch-action: pan-y; }
.page { display: grid; grid-template-columns: 1fr 1.3fr; gap: 20px; align-items: center; flex: 1 1 auto; }
.page.turn-in { animation: turn-in .45s ease both; }
.page.turn-back { animation: turn-back .45s ease both; }
@keyframes turn-in { from { opacity: 0; transform: translateX(40px) rotateY(-10deg); } to { opacity: 1; transform: none; } }
@keyframes turn-back { from { opacity: 0; transform: translateX(-40px) rotateY(10deg); } to { opacity: 1; transform: none; } }
.page-pic { display: grid; place-items: center; background: rgba(255, 255, 255, .92); border-radius: 26px; padding: 18px; min-height: 240px; }
.page-text-wrap { display: flex; flex-direction: column; gap: 14px; }
.page-text { font-weight: 700; line-height: 1.4; }
.page-text.fs-lg { font-size: clamp(26px, 3.4vw, 36px); }
.page-text.fs-md { font-size: clamp(22px, 2.8vw, 30px); }
.page-text.fs-sm { font-size: clamp(19px, 2.3vw, 24px); }
.moral { background: rgba(255, 255, 255, .95); color: var(--ink); border-radius: 20px; padding: 14px 16px; }
.moral-label { font-size: 13px; letter-spacing: .1em; color: var(--a); font-weight: 800; }
.moral-text { font-size: 22px; font-weight: 800; }
.story-words .words-label { color: rgba(255, 255, 255, .85); }
.book-nav { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: space-between; }
.page-dots { display: inline-flex; gap: 6px; }
.pd { width: 10px; height: 10px; border-radius: 999px; background: rgba(255, 255, 255, .45); transition: width .3s; }
.pd.on { width: 28px; background: #FFFFFF; }
.book .btn-ghost { background: rgba(255, 255, 255, .2); color: #FFFFFF; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .4); }
.book .btn-soft { background: #FFFFFF; color: var(--g); }
.book .btn-primary { background: #FFFFFF; color: var(--g); box-shadow: none; }

/* ================================================================== write */

.write { display: grid; grid-template-columns: 1fr 1.2fr; gap: 16px; flex: 1 1 auto; }
.write-task { display: flex; flex-direction: column; gap: 12px; }
.write-prompt { font-size: clamp(22px, 2.8vw, 30px); }
.write-pad { display: flex; flex-direction: column; gap: 12px; }
.write-area {
  flex: 1 1 auto; min-height: 260px; resize: vertical; padding: 18px; border-radius: 20px;
  border: 3px solid var(--line); background: repeating-linear-gradient(180deg, #FFFFFF 0 43px, #E9E6F8 43px 45px);
  font-size: 24px; line-height: 45px; font-weight: 600;
}
.write-area:focus { outline: none; border-color: var(--a); }
.write-meter { display: flex; align-items: center; gap: 12px; }
.write-meter .meter-bar { flex: 1; margin: 0; }
.write-meter .meter-bar span { background: var(--a); }
.meter-text { font-weight: 800; color: var(--muted); white-space: nowrap; }

/* ================================================================== match */

.match { display: flex; flex-direction: column; gap: 14px; flex: 1 1 auto; }
.match-head { display: flex; align-items: center; gap: 8px; }
.match-area { position: relative; display: grid; grid-template-columns: 1fr minmax(40px, .6fr) 1fr; gap: 0; flex: 1 1 auto; }
.match-col { display: flex; flex-direction: column; gap: 12px; justify-content: space-around; z-index: 1; }
.match-col.left { grid-column: 1; }
.match-col.right { grid-column: 3; }
.match-lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; overflow: visible; }
.match-card {
  position: relative; display: flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 84px; padding: 8px 18px; border-radius: 22px; border: 0; cursor: pointer;
  background: var(--surface-2); box-shadow: inset 0 0 0 3px #ECE9F6; touch-action: none;
  transition: transform .15s, background .2s, box-shadow .2s;
}
.match-card:active { transform: scale(.97); }
.match-card.on { background: var(--soft); box-shadow: inset 0 0 0 4px var(--a), 0 12px 20px -12px var(--a); transform: scale(1.03); }
.match-card.done { background: var(--good-bg); box-shadow: inset 0 0 0 3px var(--pair, var(--good)); cursor: default; }
.match-card.wrong { background: var(--bad-bg); box-shadow: inset 0 0 0 4px var(--bad); }
.match-text { font-size: clamp(20px, 2.6vw, 28px); font-weight: 800; }
.match-card .pic { width: 84px; }
.dots-pic { width: 96px; }
.match-dot { position: absolute; top: 50%; width: 16px; height: 16px; margin-top: -8px; border-radius: 50%; background: var(--faint); box-shadow: 0 0 0 4px #FFFFFF; }
.match-dot.left { right: -8px; }
.match-dot.right { left: -8px; }
.match-card.done .match-dot { background: var(--pair, var(--good)); }
.match-card.on .match-dot { background: var(--a); }

/* =================================================================== game */

.game { display: flex; flex-direction: column; gap: 12px; flex: 1 1 auto; }
.game-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; }
.game-name { font-size: clamp(26px, 3.4vw, 38px); }
.game-hud { display: flex; gap: 8px; flex-wrap: wrap; }
.hud-item { display: flex; flex-direction: column; align-items: center; min-width: 88px; padding: 6px 14px; border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); }
.hud-item span { font-size: 12px; letter-spacing: .08em; color: var(--muted); text-transform: uppercase; }
.hud-item b { font-size: 24px; }
.hud-item.rank b { color: var(--rank); }
.game-body { display: grid; grid-template-columns: 1fr minmax(220px, 280px); gap: 16px; flex: 1 1 auto; }
.game-play { display: flex; flex-direction: column; gap: 14px; background: linear-gradient(180deg, var(--surface), var(--soft)); }
.game-prompt { font-size: clamp(22px, 3vw, 32px); }
.bubbles { display: flex; flex-wrap: wrap; gap: 16px; justify-content: center; align-content: center; flex: 1 1 auto; padding: 10px; }
.bubble {
  min-height: 84px; padding: 0 26px; border-radius: 999px; border: 0; cursor: pointer;
  background: var(--bg); color: var(--ink); font-weight: 800; font-size: 30px;
  box-shadow: 0 10px 20px -12px rgba(26, 27, 75, .45), inset 0 0 0 3px rgba(26, 27, 75, .06);
  transform: rotate(var(--tilt)); animation: float-b 3.2s ease-in-out infinite; animation-delay: var(--d);
  transition: background .15s, box-shadow .15s;
}
.bubble.round { width: 112px; height: 112px; padding: 0; font-size: 44px; }
.bubble.long { min-height: 70px; font-size: 22px; }
@keyframes float-b { 0%, 100% { translate: 0 0; } 50% { translate: 0 -8px; } }
.bubble.on { background: var(--a); color: #FFFFFF; box-shadow: 0 0 0 5px var(--soft), 0 12px 22px -10px var(--a); scale: 1.08; }
.bubble.right { background: var(--good); color: #FFFFFF; box-shadow: 0 0 0 5px #C9F0D6; }
.bubble.wrong { background: var(--bad); color: #FFFFFF; box-shadow: 0 0 0 5px #FFD9D4; }
.bubble.missed { box-shadow: 0 0 0 5px var(--good); }
.bubble:disabled { cursor: default; }
.game-ladder { display: flex; flex-direction: column; gap: 10px; }
.ladder { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.rung { display: grid; grid-template-columns: 36px 1fr auto; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 16px; background: var(--surface-2); }
.rung.locked { opacity: .4; }
.rung.now { background: #FFF8E1; box-shadow: inset 0 0 0 3px #FFC93C; }
.rung-badge svg { width: 32px; height: 32px; fill: var(--rank); stroke: none; }
.rung-name { font-weight: 800; }
.rung-need { font-size: 13px; color: var(--muted); }
.rung-next { font-weight: 800; color: var(--a); }
.ladder-note { font-size: 13px; color: var(--muted); }
.game-ladder .meter-bar span { background: var(--a); }
.game-over { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center; flex: 1 1 auto; animation: slide-in .4s ease both; }
.game-over h3 { font-size: 40px; }
.big-star svg { width: 120px; height: 120px; fill: var(--rank); animation: star-pop .6s cubic-bezier(.3, 1.8, .5, 1) both, pic-bob 2.4s ease-in-out .6s infinite; }

/* ================================================================= finish */

.finish-overlay {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px;
  background: rgba(26, 27, 75, .45); backdrop-filter: blur(3px); animation: fade-in .25s ease both;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.finish-card {
  width: min(480px, 100%); display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center;
  padding: 28px 22px; border-radius: 34px; background: var(--surface); box-shadow: var(--shadow-lg);
  animation: pop-up .45s cubic-bezier(.3, 1.6, .5, 1) both;
}
@keyframes pop-up { from { transform: scale(.7); opacity: 0; } to { transform: none; opacity: 1; } }
.finish-card h2 { font-size: 40px; }
.finish-card p { color: var(--muted); font-size: 18px; }
.finish-card .q-actions { justify-content: center; margin-top: 8px; }

.fx-canvas { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 60; }

/* feedback motion */
/* Right and wrong: a tick or a cross over the answer (fx.js mark()). It
   grows from a fifth of its size past full and settles, the line draws itself
   as it grows, then the whole mark lifts away. */
.judge-mark {
  position: fixed; z-index: 60; pointer-events: none;
  width: var(--size, 160px); height: var(--size, 160px);
  margin: calc(var(--size, 160px) / -2) 0 0 calc(var(--size, 160px) / -2);
  animation: judge-in .5s cubic-bezier(.2, 1.6, .4, 1) both, judge-out .35s ease-in .95s forwards;
}
.judge-mark svg { width: 100%; height: 100%; display: block; overflow: visible; filter: drop-shadow(0 14px 22px rgba(26, 27, 75, .28)); }
.judge-mark circle { fill: #FFFFFF; stroke-width: 6; }
.judge-mark path {
  fill: none; stroke-width: 11; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 80; stroke-dashoffset: 80; animation: judge-draw .35s ease-out .12s forwards;
}
.judge-mark.is-right circle { stroke: #22B07A; }
.judge-mark.is-right path { stroke: #13A06A; }
.judge-mark.is-wrong circle { stroke: #E0453A; }
.judge-mark.is-wrong path { stroke: #E0453A; }
.judge-mark.is-wrong path + path { animation-delay: .26s; }
@keyframes judge-in {
  0% { transform: scale(.2); opacity: 0; }
  60% { transform: scale(1.12); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes judge-draw { to { stroke-dashoffset: 0; } }
@keyframes judge-out { to { transform: scale(1.25); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  /* The global rule cuts animations to nothing, which would end the mark
     before it is seen: shown whole, then simply gone. */
  .judge-mark { animation: judge-hold 1s step-end forwards !important; }
  .judge-mark path { stroke-dashoffset: 0; animation: none !important; }
}
@keyframes judge-hold { to { opacity: 0; } }

.shake { animation: shake .45s ease; }
@keyframes shake { 10%, 90% { transform: translateX(-2px); } 20%, 80% { transform: translateX(4px); } 30%, 50%, 70% { transform: translateX(-8px); } 40%, 60% { transform: translateX(8px); } }
.pulse { animation: pulse .5s ease; }
@keyframes pulse { 50% { transform: scale(1.08); } }

/* ============================================================ responsive */

@media (max-width: 960px) {
  .trace-layout, .read-layout, .practice-body, .solve-body, .grammar, .poem, .write, .game-body { grid-template-columns: minmax(0, 1fr); }
  .trace-side { flex-direction: row; flex-wrap: wrap; }
  .trace-card { flex: 1 1 260px; }
  .trace-tip { flex: 1 1 200px; align-self: center; }
  .poem-side { display: grid; grid-template-columns: auto 1fr; text-align: left; align-items: center; }
  .poem-words { grid-column: 1 / -1; align-items: flex-start; }
  .game-ladder { order: 2; }
}

@media (max-width: 640px) {
  .hide-sm { display: none; }
  .pill-btn { padding: 0 6px; }
  .pill-btn.back-btn { padding: 0 14px 0 6px; }   /* its word stays */
  .topbar .btn-next { max-width: 52vw; min-height: 48px; font-size: 14px; }
  .brand-name { display: none; }
  .series { order: 10; width: 100%; justify-content: space-between; }
  .pack-hero { flex-direction: column; text-align: center; }
  .step-link { grid-template-columns: 44px 1fr auto; padding: 10px 12px 10px 8px; gap: 10px; }
  .step-link > .kind-chip { display: none; }
  .step-n { width: 44px; height: 44px; font-size: 18px; }
  .step-path::before { left: 29px; }
  .step-title { font-size: 18px; }
  .page { grid-template-columns: minmax(0, 1fr); }
  .page-pic { min-height: 180px; }
  .pad { grid-template-columns: repeat(3, minmax(64px, 1fr)); width: 100%; }
  .pad.tiles { grid-template-columns: repeat(4, minmax(56px, 1fr)); }
  .slot { width: 56px; height: 68px; font-size: 38px; }
  .match-area { grid-template-columns: 1fr 28px 1fr; }
  .match-card { min-height: 72px; padding: 6px 10px; }
  .match-card .pic { width: 64px; }
  .bubble { min-height: 66px; font-size: 22px; padding: 0 18px; }
  .bubble.round { width: 84px; height: 84px; font-size: 34px; }
  .option { font-size: 20px; min-height: 58px; }
  .hud-item { min-width: 72px; }
  .chip.big { font-size: 20px; min-height: 56px; }
}

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

@media print {
  .backdrop, .bubbles-bg, .topbar, .q-actions { display: none; }
}
