:root {
  --ink: #17324d;
  --ink-soft: #4b6174;
  --paper: #fff9e9;
  --paper-deep: #f2e6c8;
  --surface: #fffdf5;
  --line: #b7c8cf;
  --accent: #e34d3d;
  --accent-dark: #a92d24;
  --math: #2377b8;
  --english: #278b67;
  --gold: #f1b93c;
  --good: #19734e;
  --bad: #b6382f;
  --shadow: 0 16px 38px rgba(34, 54, 67, 0.13);
  --display-font: "STKaiti", "KaiTi", "Kaiti SC", serif;
  --body-font: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --utility-font: "SFMono-Regular", Consolas, monospace;
}

[data-theme="forest"] {
  --ink: #173e35;
  --ink-soft: #52695c;
  --paper: #fbf8df;
  --paper-deep: #e1e9c9;
  --surface: #fffdf2;
  --line: #a9bda8;
  --accent: #d95f37;
  --accent-dark: #963b24;
  --math: #3477a0;
  --english: #347a46;
  --gold: #dda52e;
}

[data-theme="space"] {
  --ink: #eaf2ff;
  --ink-soft: #b5c4da;
  --paper: #121d35;
  --paper-deep: #1c2b49;
  --surface: #182744;
  --line: #40577d;
  --accent: #ff796d;
  --accent-dark: #ffaaa3;
  --math: #70b7ff;
  --english: #63d6a5;
  --gold: #ffd166;
  --good: #69d7aa;
  --bad: #ff8e84;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

[data-theme="ocean"] {
  --ink: #08364a;
  --ink-soft: #416b75;
  --paper: #eafbf6;
  --paper-deep: #bfe7df;
  --surface: #f6fffc;
  --line: #77aaa8;
  --accent: #df5e4c;
  --accent-dark: #a33c32;
  --math: #087ca7;
  --english: #087f67;
  --gold: #e9aa31;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--paper-deep);
  font-family: var(--body-font);
  line-height: 1.6;
  transition: color 180ms ease, background 180ms ease;
}

button, input, select { font: inherit; }
button { color: inherit; }

button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 4px solid color-mix(in srgb, var(--gold) 70%, white);
  outline-offset: 3px;
}

.paper-noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  opacity: .16;
  background-image: repeating-linear-gradient(0deg, transparent 0 7px, rgba(23, 50, 77, .09) 8px);
}

.site-header {
  min-height: 82px;
  padding: 12px clamp(18px, 4vw, 64px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: var(--surface);
  border-bottom: 2px solid var(--ink);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 0;
  background: none;
  cursor: pointer;
  text-align: left;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 43px;
  height: 43px;
  color: var(--paper);
  background: var(--ink);
  border-radius: 50% 48% 46% 52%;
  transform: rotate(-5deg);
  font-size: 1.25rem;
}

.brand strong { display: block; font-family: var(--display-font); font-size: 1.35rem; line-height: 1.2; }
.brand small { display: block; color: var(--ink-soft); font-size: .72rem; letter-spacing: .08em; }
.header-actions { display: flex; align-items: center; gap: 12px; }

.energy-wallet { display: grid; grid-template-columns: auto auto; align-items: center; column-gap: 5px; min-width: 84px; padding: 7px 11px; color: var(--ink); background: color-mix(in srgb, var(--gold) 22%, var(--surface)); border: 1px solid var(--gold); border-radius: 6px; cursor: pointer; }
.energy-wallet > span { color: #d79000; }
.energy-wallet strong { font: 900 .95rem var(--utility-font); }
.energy-wallet small { grid-column: 1 / -1; color: var(--ink-soft); font-size: .58rem; letter-spacing: .08em; }

.theme-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-soft);
  font-size: .85rem;
}

.theme-picker select {
  padding: 8px 30px 8px 10px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.quiet-button, .back-button, .text-button, .danger-text-button {
  border: 0;
  background: transparent;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.quiet-button {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  text-decoration: none;
  background: var(--paper);
}

.quiet-button span {
  display: inline-grid;
  place-items: center;
  min-width: 23px;
  height: 23px;
  margin-left: 4px;
  color: white;
  background: var(--accent);
  border-radius: 50%;
  font: 700 .72rem var(--utility-font);
}

main { width: min(1220px, calc(100% - 32px)); margin: 0 auto; }
.screen { display: none; padding: clamp(28px, 5vw, 72px) 0; animation: reveal 320ms ease both; }
.screen.active { display: block; }

.grade-bar { display: grid; grid-template-columns: auto auto 1fr; align-items: center; gap: 20px; margin-bottom: 20px; padding: 14px 18px; background: var(--surface); border: 1px solid var(--line); }
.grade-bar > div:first-child span, .grade-bar > div:first-child strong { display: block; }
.grade-bar > div:first-child span { color: var(--ink-soft); font-size: .72rem; }
.grade-bar > div:first-child strong { font: 800 1.45rem var(--display-font); }
.grade-switcher { display: flex; gap: 6px; }
.grade-switcher button { display: grid; place-items: center; width: 38px; height: 38px; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 50%; font-weight: 800; cursor: pointer; }
.grade-switcher button.active { color: var(--paper); background: var(--ink); border-color: var(--ink); box-shadow: 3px 3px 0 var(--gold); }
.grade-bar > p { justify-self: end; margin: 0; color: var(--ink-soft); font-size: .82rem; text-align: right; }

@keyframes reveal { from { opacity: 0; transform: translateY(8px); } }

.notebook-panel {
  position: relative;
  background: var(--surface);
  border: 2px solid var(--ink);
  box-shadow: 8px 8px 0 var(--ink), var(--shadow);
}

.hero {
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  min-height: 445px;
  overflow: hidden;
}

.hero::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 52%;
  border-left: 1px dashed var(--line);
}

.hero-copy { padding: clamp(34px, 6vw, 78px); align-self: center; }
.eyebrow { margin: 0 0 10px; color: var(--accent); font: 800 .74rem var(--utility-font); letter-spacing: .11em; text-transform: uppercase; }

h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { line-height: 1.15; }

.hero h1 {
  margin-bottom: 22px;
  font-family: var(--display-font);
  font-size: clamp(2.8rem, 6vw, 5.7rem);
  font-weight: 800;
  letter-spacing: -.05em;
}

.hero h1 em { color: var(--accent); font-style: normal; position: relative; }
.hero h1 em::after { content: ""; position: absolute; left: 4%; right: -2%; bottom: -5px; height: 8px; border-top: 3px solid var(--accent); border-radius: 50%; transform: rotate(-1deg); }
.hero-intro { max-width: 560px; color: var(--ink-soft); font-size: 1.05rem; }
.active-title { display: inline-block; margin: 0; padding: 5px 11px; color: var(--ink); background: color-mix(in srgb, var(--gold) 25%, var(--paper)); border: 1px solid var(--gold); border-radius: 20px; font: 800 .75rem var(--utility-font); transform: rotate(-1deg); }
.hero-actions, .summary-actions, .wrong-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-top: 28px; }

.primary-button, .secondary-button, .subject-button {
  min-height: 48px;
  padding: 12px 20px;
  border: 2px solid var(--ink);
  border-radius: 7px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 130ms ease, box-shadow 130ms ease;
}

.primary-button, .subject-button { color: var(--paper); background: var(--ink); box-shadow: 4px 4px 0 var(--accent); }
.secondary-button { color: var(--ink); background: var(--paper); box-shadow: 4px 4px 0 var(--line); }
.primary-button:hover, .secondary-button:hover, .subject-button:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--accent); }
.text-button { font-weight: 700; }

.route-map { position: relative; display: grid; align-content: center; gap: 12px; min-height: 430px; padding: 38px; background: color-mix(in srgb, var(--paper-deep) 66%, var(--surface)); overflow: hidden; }
.route-map::after { content: "学习路线"; position: absolute; right: -8px; bottom: -20px; color: color-mix(in srgb, var(--ink) 8%, transparent); font: 800 4.5rem var(--display-font); transform: rotate(-6deg); }
.route-map-heading { position: relative; z-index: 2; margin: 0 0 4px; color: var(--ink-soft); font: 800 .72rem var(--utility-font); letter-spacing: .1em; }
.route-line { position: absolute; z-index: 0; top: 94px; bottom: 83px; left: 67px; border-left: 3px dashed var(--line); }
.route-stop, .finish-flag { position: relative; z-index: 1; display: grid; grid-template-columns: 52px 1fr; grid-template-rows: auto auto; align-items: center; column-gap: 12px; min-height: 64px; padding: 8px 12px; color: var(--ink); background: color-mix(in srgb, var(--surface) 85%, transparent); border: 1px solid var(--line); border-radius: 8px; text-align: left; }
.route-stop { width: 100%; cursor: pointer; }
.route-stop:hover { border-color: currentColor; transform: translateX(3px); }
.route-stop span, .finish-flag > span { grid-row: 1 / 3; display: grid; place-items: center; width: 48px; height: 48px; color: white; border-radius: 50%; font: 800 1.35rem var(--display-font); }
.route-stop strong, .finish-flag strong { align-self: end; font-size: .9rem; }
.route-stop small, .finish-flag small { align-self: start; color: var(--ink-soft); font-size: .68rem; }
.route-stop.chinese span { background: var(--accent); }
.route-stop.math span { background: var(--math); }
.route-stop.english span { background: var(--english); font-size: 1rem; }
.finish-flag > span { color: var(--accent); background: var(--paper); border: 2px solid var(--accent); }

.stats-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin: 38px 0 70px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.stats-strip div { padding: 20px 24px; border-right: 1px dashed var(--line); }
.stats-strip div:last-child { border-right: 0; }
.stats-strip span { display: block; color: var(--ink-soft); font-size: .8rem; }
.stats-strip strong { display: block; font: 800 1.85rem var(--utility-font); }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 30px; margin-bottom: 24px; }
.section-heading h1, .section-heading h2 { margin-bottom: 0; font-family: var(--display-font); font-size: clamp(2rem, 4vw, 3.2rem); }
.section-heading > p { max-width: 270px; margin-bottom: 5px; color: var(--ink-soft); text-align: right; }
.subject-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }

.subject-card {
  position: relative;
  padding: 42px 28px 28px;
  background: var(--surface);
  border: 2px solid var(--ink);
  border-radius: 4px 4px 18px 4px;
  box-shadow: var(--shadow);
}

.subject-card::after { content: ""; position: absolute; right: 10px; bottom: 10px; width: 20px; height: 20px; border-right: 2px solid var(--line); border-bottom: 2px solid var(--line); }
.subject-tab { position: absolute; top: -15px; left: 18px; padding: 6px 14px; color: white; background: var(--accent); border: 2px solid var(--ink); border-radius: 4px; font: 800 .74rem var(--utility-font); }
.math-card .subject-tab { background: var(--math); }
.english-card .subject-tab { background: var(--english); }
.subject-icon { display: grid; place-items: center; width: 70px; height: 70px; margin-bottom: 20px; color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); border: 2px solid currentColor; border-radius: 50%; font: 800 2.1rem var(--display-font); transform: rotate(-4deg); }
.math-card .subject-icon { color: var(--math); transform: rotate(3deg); }
.english-card .subject-icon { color: var(--english); transform: rotate(-2deg); }
.subject-icon-en { font-family: var(--body-font); font-size: 1.55rem; }
.subject-card h3 { margin-bottom: 8px; font: 800 1.8rem var(--display-font); }
.subject-card p { min-height: 52px; color: var(--ink-soft); }
.subject-progress { margin: 22px 0; }
.subject-progress > span { display: block; height: 8px; overflow: hidden; background: var(--paper-deep); border-radius: 20px; }
.subject-progress i { display: block; width: 0; height: 100%; background: var(--accent); transition: width 350ms ease; }
.math-card .subject-progress i { background: var(--math); }
.english-card .subject-progress i { background: var(--english); }
.subject-progress small { display: block; margin-top: 6px; color: var(--ink-soft); }
.subject-button { width: 100%; color: white; background: var(--accent); }
.math-card .subject-button { background: var(--math); }
.english-card .subject-button { background: var(--english); }

.review-grid { display: grid; grid-template-columns: 1.35fr .65fr; gap: 24px; margin: 70px 0 20px; }
.review-card { padding: 32px; background: var(--surface); border: 1px solid var(--line); }
.review-card h2 { margin-bottom: 8px; font-family: var(--display-font); font-size: 2rem; }
.wrong-card { display: flex; align-items: center; justify-content: space-between; gap: 26px; border-left: 8px solid var(--accent); }
.wrong-card p:last-child { margin-bottom: 0; color: var(--ink-soft); }
.method-card ol { display: grid; gap: 10px; padding: 0; list-style: none; }
.method-card li { display: flex; align-items: center; gap: 10px; }
.method-card li span { display: grid; place-items: center; width: 26px; height: 26px; color: var(--paper); background: var(--ink); border-radius: 50%; font: 700 .75rem var(--utility-font); }

.quiz-shell { position: relative; max-width: 1180px; margin: 0 auto; }
.quiz-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 14px; }
.back-button { padding: 6px 0; font-weight: 700; }
.quiz-meta { display: flex; flex-wrap: wrap; justify-content: end; gap: 8px; }
.quiz-meta span { padding: 5px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; font: 700 .75rem var(--utility-font); }
.progress-track { height: 12px; margin-bottom: 24px; overflow: hidden; background: var(--surface); border: 1px solid var(--ink); border-radius: 20px; }
.progress-track i { display: block; width: 0; height: 100%; background: var(--accent); transition: width 260ms ease; }
.quiz-workspace { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 28px; align-items: start; }
.question-paper { position: relative; min-height: 510px; padding: clamp(32px, 7vw, 72px); background: var(--surface); border: 2px solid var(--ink); box-shadow: 9px 9px 0 var(--ink), var(--shadow); overflow: hidden; }
.question-paper::before { content: ""; position: absolute; inset: 0; pointer-events: none; background: repeating-linear-gradient(transparent 0 35px, color-mix(in srgb, var(--line) 30%, transparent) 36px); opacity: .38; }
.paper-margin { position: absolute; top: 0; bottom: 0; left: 37px; width: 1px; background: color-mix(in srgb, var(--accent) 45%, transparent); }
.question-paper > *:not(.paper-margin) { position: relative; z-index: 1; }
.question-topline { display: flex; gap: 8px; margin-bottom: 24px; }
.question-topline span { padding: 5px 10px; color: var(--ink-soft); background: var(--paper); border: 1px solid var(--line); border-radius: 4px; font: 700 .72rem var(--utility-font); }
.question-paper h2 { max-width: 740px; margin-bottom: 12px; font-family: var(--display-font); font-size: clamp(1.65rem, 4vw, 2.6rem); }
.question-note { color: var(--ink-soft); }
#answerForm { margin-top: 30px; }
.choice-list { display: grid; gap: 12px; }
.choice-option { position: relative; display: flex; align-items: center; gap: 13px; padding: 14px 16px; background: color-mix(in srgb, var(--paper) 75%, var(--surface)); border: 2px solid var(--line); border-radius: 7px; cursor: pointer; transition: border-color 130ms ease, transform 130ms ease; }
.choice-option:hover { border-color: var(--ink); transform: translateX(3px); }
.choice-option:has(input:checked) { border-color: var(--accent); box-shadow: inset 5px 0 0 var(--accent); }
.choice-option input { width: 20px; height: 20px; accent-color: var(--accent); }
.choice-letter { display: grid; place-items: center; width: 29px; height: 29px; flex: 0 0 auto; border: 1px solid var(--line); border-radius: 50%; font: 700 .8rem var(--utility-font); }
.text-answer { width: min(520px, 100%); padding: 15px 16px; color: var(--ink); background: var(--paper); border: 2px solid var(--line); border-radius: 7px; font-size: 1.05rem; }
.matching-list { display: grid; gap: 12px; }
.matching-row { display: grid; grid-template-columns: 1fr 38px 1fr; align-items: center; gap: 10px; }
.matching-row strong { padding: 12px; background: var(--paper); border-left: 4px solid var(--accent); }
.matching-row span { text-align: center; }
.matching-row select { width: 100%; padding: 12px; color: var(--ink); background: var(--paper); border: 2px solid var(--line); border-radius: 6px; }
.submit-button { min-width: 160px; margin-top: 24px; }
.form-message { min-height: 24px; margin: 10px 0 0; color: var(--bad); font-weight: 700; }
.scratch-panel { padding: 18px; background: var(--surface); border: 2px solid var(--ink); box-shadow: 6px 7px 0 var(--line); }
.scratch-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.scratch-heading span:first-child { color: var(--accent); font: 800 .7rem var(--utility-font); letter-spacing: .08em; }
.scratch-heading h2 { margin: 2px 0 0; font: 800 1.8rem var(--display-font); }
.pencil-mark { font-size: 2rem; transform: rotate(-12deg); }
#scratchCanvas { display: block; width: 100%; height: 360px; cursor: crosshair; touch-action: none; background-color: var(--paper); background-image: linear-gradient(color-mix(in srgb, var(--math) 18%, transparent) 1px, transparent 1px), linear-gradient(90deg, color-mix(in srgb, var(--math) 18%, transparent) 1px, transparent 1px); background-size: 20px 20px; border: 1px solid var(--line); }
.scratch-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.scratch-actions button { min-height: 40px; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 5px; font-weight: 700; cursor: pointer; }
.scratch-actions button:hover { border-color: var(--ink); }
.scratch-actions button:disabled { opacity: .45; cursor: not-allowed; }
.scratch-panel > p { margin: 10px 0 0; color: var(--ink-soft); font-size: .75rem; }
.quiz-side-note { width: calc(100% - 328px); margin: 24px 0 0; padding: 14px 18px; display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--paper); border: 1px solid var(--line); box-shadow: 3px 4px 0 var(--line); }
.quiz-side-note p { margin: 0; color: var(--accent); font: 800 .72rem var(--utility-font); }
.quiz-side-note strong, .quiz-side-note span { display: block; }

.fraction { display: inline-grid; grid-template-rows: auto auto; min-width: 1.35em; margin: 0 .12em; vertical-align: middle; color: inherit; font-family: var(--body-font); font-size: .82em; font-weight: 800; line-height: 1.02; text-align: center; }
.fraction-numerator { padding: 0 .18em .08em; border-bottom: 2px solid currentColor; }
.fraction-denominator { padding: .08em .18em 0; }

.feedback-overlay, .simple-dialog {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(11, 25, 38, .66);
  backdrop-filter: blur(4px);
}

.feedback-overlay[hidden], .simple-dialog[hidden] { display: none; }
.feedback-card, .simple-dialog > section { position: relative; width: min(590px, 100%); max-height: calc(100vh - 40px); overflow: auto; padding: clamp(30px, 6vw, 52px); color: var(--ink); background: var(--surface); border: 2px solid var(--ink); box-shadow: 9px 9px 0 var(--accent); }
.feedback-card.correct { box-shadow: 9px 9px 0 var(--good); }
.feedback-card.wrong { box-shadow: 9px 9px 0 var(--bad); }
.feedback-mark { display: grid; place-items: center; width: 58px; height: 58px; margin-bottom: 20px; color: white; background: var(--good); border-radius: 50%; font-size: 1.8rem; font-weight: 900; }
.feedback-card.wrong .feedback-mark { background: var(--bad); }
.feedback-card h2, .simple-dialog h2 { font-family: var(--display-font); font-size: 2rem; }
.answer-line { font-weight: 800; }
.explanation-box { padding: 17px 18px; background: var(--paper); border-left: 5px solid var(--gold); }
.explanation-box p { margin: 5px 0 0; }
.transfer-notice { margin: 18px 0 0; color: var(--accent); font-weight: 800; }
.feedback-card .primary-button { margin-top: 24px; }
.dialog-close { position: absolute; top: 14px; right: 18px; width: 36px; height: 36px; border: 0; background: transparent; font-size: 1.8rem; cursor: pointer; }
.simple-dialog ol { display: grid; gap: 18px; padding: 0; list-style: none; }
.simple-dialog li { display: grid; grid-template-columns: 110px 1fr; gap: 15px; border-bottom: 1px dashed var(--line); padding-bottom: 14px; }
.simple-dialog li span { color: var(--ink-soft); }

.summary-card { max-width: 820px; margin: 0 auto; padding: clamp(34px, 7vw, 76px); text-align: center; }
.summary-card h1 { font: 800 clamp(2.7rem, 7vw, 5rem) var(--display-font); margin-bottom: 8px; }
.summary-card > p:not(.eyebrow) { color: var(--ink-soft); }
.summary-stamp { position: absolute; top: 34px; right: 38px; padding: 8px 12px; color: var(--accent); border: 3px double var(--accent); border-radius: 50%; font: 900 .8rem var(--utility-font); transform: rotate(9deg); }
.summary-numbers { display: grid; grid-template-columns: repeat(3, 1fr); margin: 35px 0; border: 1px solid var(--line); }
.summary-numbers div { padding: 20px 10px; border-right: 1px dashed var(--line); }
.summary-numbers div:last-child { border-right: 0; }
.summary-numbers strong, .summary-numbers span { display: block; }
.summary-numbers strong { font: 900 1.7rem var(--utility-font); }
.summary-numbers span { color: var(--ink-soft); font-size: .78rem; }
.weak-topics { padding: 22px; background: var(--paper); text-align: left; }
.weak-topics h2 { font-family: var(--display-font); }
#weakTopicList { display: flex; flex-wrap: wrap; gap: 8px; }
#weakTopicList span { padding: 6px 10px; border: 1px solid var(--line); border-radius: 20px; }
.summary-actions { justify-content: center; }

.wrong-book-page { min-height: 620px; padding: clamp(28px, 6vw, 64px); }
.wrong-filter { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; }
.wrong-filter button { padding: 8px 14px; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 20px; cursor: pointer; }
.wrong-filter button.active { color: var(--paper); background: var(--ink); }
.wrong-list { display: grid; gap: 14px; }
.wrong-item { display: grid; grid-template-columns: auto 1fr auto; gap: 15px; align-items: start; padding: 18px; background: var(--paper); border-left: 5px solid var(--accent); }
.wrong-item-tag { padding: 4px 8px; color: white; background: var(--accent); border-radius: 4px; font-size: .75rem; }
.wrong-item h3 { margin-bottom: 5px; font-size: 1rem; }
.wrong-item p { margin-bottom: 0; color: var(--ink-soft); font-size: .88rem; }
.master-button { padding: 7px 10px; color: var(--good); background: transparent; border: 1px solid var(--good); border-radius: 5px; cursor: pointer; }
.empty-state { padding: 70px 20px; text-align: center; border: 2px dashed var(--line); }
.empty-state strong { display: block; font: 800 2rem var(--display-font); }
.empty-state span { color: var(--ink-soft); }
.danger-text-button { color: var(--bad); }

.play-section { margin: 74px 0 22px; }
.play-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.play-card { position: relative; min-height: 280px; padding: 28px; overflow: hidden; background: var(--surface); border: 2px solid var(--ink); box-shadow: 5px 6px 0 var(--line); }
.play-card::after { content: ""; position: absolute; right: -30px; bottom: -46px; width: 135px; height: 135px; border: 18px double color-mix(in srgb, var(--line) 48%, transparent); border-radius: 50%; }
.play-card-mark { display: grid; place-items: center; width: 58px; height: 58px; margin-bottom: 24px; color: var(--paper); background: var(--ink); border-radius: 50%; font: 900 1.45rem var(--utility-font); transform: rotate(-4deg); }
.factor-card .play-card-mark { background: var(--math); }
.word-card .play-card-mark { background: var(--english); }
.pet-card .play-card-mark { background: var(--gold); color: var(--ink); }
.play-card h3 { margin-bottom: 7px; font: 800 1.65rem var(--display-font); }
.play-card p:not(.eyebrow) { color: var(--ink-soft); }
.play-card .secondary-button { position: relative; z-index: 1; margin-top: 10px; }

.answer-actions { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; }
.hint-button { min-height: 48px; padding: 10px 15px; color: var(--ink); background: color-mix(in srgb, var(--gold) 16%, var(--surface)); border: 2px dashed var(--gold); border-radius: 7px; font-weight: 800; cursor: pointer; }
.hint-button:disabled { opacity: .5; cursor: not-allowed; }
.hint-button span { display: inline-grid; place-items: center; min-width: 24px; height: 24px; margin-left: 4px; color: var(--paper); background: var(--ink); border-radius: 50%; font: 800 .72rem var(--utility-font); }
.hint-message { min-height: 24px; margin: 12px 0 0; color: var(--accent); font-weight: 800; }
.condition-token { display: inline-block; margin-left: 6px; padding: 2px 7px; color: var(--ink); background: color-mix(in srgb, var(--gold) 40%, var(--paper)); border: 1px solid var(--gold); border-radius: 4px; }
.scan-button { min-height: 48px; padding: 10px 15px; color: var(--ink); background: color-mix(in srgb, var(--math) 14%, var(--surface)); border: 2px dashed var(--math); border-radius: 7px; font-weight: 800; cursor: pointer; }
.scan-button[hidden] { display: none; }
.scan-button:disabled { opacity: .5; cursor: not-allowed; }
.scan-button span { display: inline-grid; place-items: center; min-width: 24px; height: 24px; margin-left: 4px; color: var(--paper); background: var(--math); border-radius: 50%; font: 800 .72rem var(--utility-font); }
.multi-note { margin-bottom: 10px; color: var(--ink-soft); font-size: .85rem; }
.ordering-answer { display: grid; gap: 12px; }
.order-pool, .order-result { min-height: 58px; padding: 10px; background: var(--paper); border: 2px dashed var(--line); border-radius: 7px; }
.order-result { border-style: solid; }
.order-chip { margin: 4px; padding: 8px 12px; color: var(--ink); background: var(--surface); border: 1px solid var(--ink); border-radius: 20px; cursor: pointer; }
.order-chip:disabled { opacity: .35; cursor: not-allowed; }
.order-controls button { padding: 6px 10px; color: var(--ink); background: transparent; border: 1px solid var(--line); border-radius: 5px; cursor: pointer; }

.shop-page, .mini-game-page { min-height: 650px; padding: clamp(28px, 6vw, 64px); }
.shop-wallet { display: inline-grid; grid-template-columns: auto auto; align-items: center; gap: 4px 8px; margin-bottom: 26px; padding: 14px 22px; background: color-mix(in srgb, var(--gold) 18%, var(--paper)); border: 2px solid var(--gold); transform: rotate(-1deg); }
.shop-wallet > span { grid-row: 1 / 3; color: #d79000; font-size: 2rem; }
.shop-wallet strong { font: 900 2rem var(--utility-font); }
.shop-wallet small { color: var(--ink-soft); }
.shop-grid { display: grid; gap: 14px; }
.shop-item { display: grid; grid-template-columns: 78px 1fr auto; align-items: center; gap: 20px; padding: 22px; background: var(--paper); border: 1px solid var(--line); }
.shop-item-icon { display: grid; place-items: center; width: 66px; height: 66px; color: var(--paper); background: var(--ink); border-radius: 50%; font: 900 1.5rem var(--utility-font); }
.shop-item h2 { margin-bottom: 4px; font: 800 1.5rem var(--display-font); }
.shop-item p { margin-bottom: 0; color: var(--ink-soft); }
.shop-item button { min-width: 130px; padding: 11px 14px; color: var(--paper); background: var(--ink); border: 2px solid var(--ink); border-radius: 6px; font-weight: 800; cursor: pointer; }
.shop-item button:disabled { color: var(--ink-soft); background: var(--surface); border-color: var(--line); cursor: not-allowed; }
.shop-message { min-height: 26px; margin: 18px 0 0; color: var(--accent); font-weight: 800; }

.mini-game-panel { position: relative; padding: clamp(24px, 5vw, 48px); background: var(--paper); border: 2px solid var(--ink); }
.game-switcher { display: flex; gap: 8px; margin-bottom: 14px; }
.game-switcher button { padding: 8px 14px; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 20px; cursor: pointer; }
.game-switcher button.active { color: var(--paper); background: var(--ink); border-color: var(--ink); }
.mini-game-panel[hidden], .game-result[hidden] { display: none; }
.mini-game-panel h2 { margin-bottom: 8px; font: 800 clamp(2rem, 5vw, 3.4rem) var(--display-font); }
.mini-game-panel h2 span { color: var(--accent); }
.game-reward { position: absolute; top: 18px; right: 20px; color: var(--ink-soft); }
.game-reward strong { color: var(--accent); }
.factor-board { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; margin: 28px 0; }
.factor-number { aspect-ratio: 1; color: var(--ink); background: var(--surface); border: 2px solid var(--line); border-radius: 50%; font: 900 1.2rem var(--utility-font); cursor: pointer; }
.factor-number.selected { color: var(--paper); background: var(--math); border-color: var(--ink); transform: rotate(-5deg); }
.memory-board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 650px; margin: 28px auto 0; }
.memory-card { min-height: 110px; padding: 12px; color: transparent; background: var(--ink); border: 2px solid var(--ink); border-radius: 8px; font-weight: 900; cursor: pointer; }
.memory-card::before { content: "?"; color: var(--paper); font: 900 1.8rem var(--utility-font); }
.memory-card.flipped, .memory-card.matched { color: var(--ink); background: var(--surface); }
.memory-card.flipped::before, .memory-card.matched::before { display: none; }
.memory-card.matched { border-color: var(--english); box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--english) 25%, transparent); }
.game-result { margin-top: 18px; padding: 20px; background: color-mix(in srgb, var(--gold) 18%, var(--surface)); border-left: 7px solid var(--gold); }
.game-result strong { font: 800 1.65rem var(--display-font); }
.game-result p { margin: 4px 0 14px; }
.toast { position: fixed; left: 50%; bottom: 28px; z-index: 50; min-width: 240px; padding: 12px 18px; color: var(--paper); background: var(--ink); border: 2px solid var(--gold); border-radius: 6px; box-shadow: var(--shadow); font-weight: 800; text-align: center; transform: translateX(-50%); }
.toast[hidden] { display: none; }

.pet-page { min-height: 650px; padding: clamp(28px, 6vw, 64px); }
.active-pet-panel { display: grid; grid-template-columns: 110px 1fr auto; align-items: center; gap: 24px; margin-bottom: 28px; padding: 24px; background: var(--paper); border: 2px solid var(--ink); }
.active-pet-icon, .pet-avatar { display: grid; place-items: center; border-radius: 50%; color: var(--paper); font: 900 1.5rem var(--display-font); }
.active-pet-icon { width: 92px; height: 92px; background: var(--ink); box-shadow: 5px 5px 0 var(--gold); }
.active-pet-panel h2 { margin-bottom: 5px; font: 800 2rem var(--display-font); }
.active-pet-panel p { margin-bottom: 10px; color: var(--ink-soft); }
.pet-level { max-width: 420px; }
.pet-level > span { display: block; height: 10px; overflow: hidden; background: var(--paper-deep); border: 1px solid var(--line); border-radius: 20px; }
.pet-level i { display: block; width: 0; height: 100%; background: var(--gold); transition: width 220ms ease; }
.pet-level small { color: var(--ink-soft); }
.pet-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.pet-option { padding: 24px; background: var(--surface); border: 1px solid var(--line); text-align: center; }
.pet-avatar { width: 78px; height: 78px; margin: 0 auto 16px; }
.pet-avatar.cat { background: var(--accent); }
.pet-avatar.fox { background: var(--math); }
.pet-avatar.owl { background: var(--english); }
.pet-option h2 { margin-bottom: 6px; font: 800 1.5rem var(--display-font); }
.pet-option p { min-height: 52px; color: var(--ink-soft); }
.pet-option button { width: 100%; min-height: 44px; color: var(--paper); background: var(--ink); border: 2px solid var(--ink); border-radius: 6px; font-weight: 800; cursor: pointer; }
.pet-option button:disabled { color: var(--ink-soft); background: var(--paper); border-color: var(--line); cursor: not-allowed; }
.pet-option.active { border: 2px solid var(--gold); box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--gold) 18%, transparent); }
.pet-message { min-height: 26px; margin: 18px 0 0; color: var(--accent); font-weight: 800; }

@media (max-width: 900px) {
  .quiz-workspace { grid-template-columns: 1fr; }
  #scratchCanvas { height: 260px; }
  .quiz-side-note { width: 100%; }
}
@media (max-width: 860px) {
  .site-header { align-items: flex-start; }
  .theme-picker span { display: none; }
  .hero { grid-template-columns: 1fr; }
  .hero::before { display: none; }
  .grade-bar { grid-template-columns: 1fr; gap: 10px; }
  .grade-bar > p { justify-self: start; text-align: left; }
  .route-map { min-height: 360px; }
  .stats-strip { grid-template-columns: repeat(2, 1fr); }
  .stats-strip div:nth-child(2) { border-right: 0; }
  .stats-strip div:nth-child(-n+2) { border-bottom: 1px dashed var(--line); }
  .subject-grid { grid-template-columns: 1fr; }
  .subject-card p { min-height: auto; }
  .review-grid { grid-template-columns: 1fr; }
  .play-grid { grid-template-columns: 1fr; }
  .wrong-card { align-items: flex-start; flex-direction: column; }
  .shop-item { grid-template-columns: 70px 1fr; }
  .shop-item button { grid-column: 1 / -1; }
  .factor-board { grid-template-columns: repeat(4, 1fr); }
  .pet-grid { grid-template-columns: 1fr; }
  .active-pet-panel { grid-template-columns: 92px 1fr; }
  .active-pet-panel > button { grid-column: 1 / -1; }
}

@media (max-width: 600px) {
  main { width: min(100% - 20px, 1220px); }
  .site-header { min-height: 70px; padding: 10px; gap: 8px; }
  .brand-mark { width: 36px; height: 36px; }
  .brand strong { font-size: 1.08rem; }
  .brand small { display: none; }
  .header-actions { max-width: 250px; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
  .energy-wallet { min-width: 58px; padding: 5px 7px; }
  .energy-wallet small { display: none; }
  .theme-picker select { width: 92px; padding: 7px 4px; font-size: .72rem; }
  .quiet-button { padding: 7px 8px; font-size: .8rem; }
  .hero-copy { padding: 34px 24px; }
  .hero h1 { font-size: 3.15rem; }
  .grade-switcher { flex-wrap: wrap; }
  .route-map { min-height: 0; padding: 20px; }
  .route-stop strong { display: block; }
  .route-stop.math { right: auto; }
  .stats-strip { margin-bottom: 50px; }
  .stats-strip div { padding: 15px; }
  .section-heading { align-items: flex-start; flex-direction: column; gap: 8px; }
  .section-heading > p { text-align: left; }
  .subject-card { padding: 38px 22px 22px; }
  .review-grid { margin-top: 50px; }
  .quiz-toolbar { align-items: flex-start; }
  .quiz-meta { max-width: 190px; }
  .quiz-meta span { font-size: .67rem; }
  .question-paper { min-height: 500px; padding: 30px 22px 35px 34px; box-shadow: 5px 6px 0 var(--ink); }
  .paper-margin { left: 20px; }
  .matching-row { grid-template-columns: 1fr; gap: 4px; }
  .matching-row span { transform: rotate(90deg); }
  .feedback-card, .simple-dialog > section { padding: 30px 22px; }
  .simple-dialog li { grid-template-columns: 1fr; gap: 3px; }
  .summary-card { padding: 44px 22px; }
  .summary-stamp { top: 16px; right: 16px; }
  .summary-numbers strong { font-size: 1.25rem; }
  .wrong-book-page { padding: 30px 18px; }
  .wrong-item { grid-template-columns: 1fr; }
  .quiz-side-note { display: grid; grid-template-columns: repeat(2, 1fr); }
  .scratch-panel { padding: 14px; }
  #scratchCanvas { height: 230px; }
  .shop-page, .mini-game-page, .pet-page { padding: 30px 18px; }
  .shop-item { grid-template-columns: 1fr; }
  .shop-item-icon { width: 52px; height: 52px; }
  .shop-item button { grid-column: auto; width: 100%; }
  .game-reward { position: static; }
  .factor-board { grid-template-columns: repeat(3, 1fr); }
  .memory-board { grid-template-columns: repeat(2, 1fr); }
  .active-pet-panel { grid-template-columns: 1fr; text-align: center; }
  .active-pet-icon { margin: 0 auto; }
  .pet-level { margin: 0 auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
