:root {
  --paper: #f8f0df;
  --paper-2: #fffaf0;
  --ink: #49301f;
  --muted: #7d6a58;
  --orange: #e9793f;
  --yellow: #f4c55e;
  --green: #789463;
  --blue: #79a9c8;
  --pink: #eaa7a0;
  --brown: #875b38;
  --line: rgba(97, 66, 42, .18);
  --shadow: 0 18px 45px rgba(100, 70, 37, .13);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--paper);
  font-family: "Kaiti SC", "STKaiti", "Songti SC", "Noto Serif SC", serif;
  overflow-x: hidden;
}
button, input, textarea, select { font: inherit; }
button { color: inherit; }
.paper-noise {
  position: fixed; inset: 0; pointer-events: none; opacity: .28; z-index: 20;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.08'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}

.topbar {
  position: sticky; top: 0; z-index: 30; height: 76px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px max(22px, calc((100vw - 1180px) / 2));
  background: rgba(248, 240, 223, .92); border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}
.brand { border: 0; background: none; display: flex; align-items: center; gap: 11px; cursor: pointer; text-align: left; }
.brand-mark { width: 44px; height: 44px; display: grid; place-items: center; background: var(--yellow); border: 2px solid var(--ink); border-radius: 44% 56% 47% 53%; font-weight: 900; transform: rotate(-3deg); }
.brand b { display: block; font-size: 17px; }
.brand small { display: block; color: var(--muted); margin-top: 2px; letter-spacing: .08em; }
.header-stats { display: flex; align-items: center; gap: 10px; font-family: system-ui, sans-serif; font-size: 13px; }
.header-stats span { padding: 7px 12px; background: rgba(255,255,255,.55); border: 1px solid var(--line); border-radius: 999px; }
.header-stats span:first-child { color: #c7692f; font-weight: 800; }

#app { width: min(1180px, calc(100% - 32px)); margin: 0 auto; }
.stage { display: none; min-height: calc(100vh - 154px); padding: 52px 0 110px; animation: stageIn .45s ease both; }
.stage.is-active { display: block; }
@keyframes stageIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }

.hero-stage.is-active { display: grid; grid-template-columns: 1.02fr .98fr; align-items: center; gap: 40px; padding-top: 34px; }
.eyebrow { margin: 0 0 8px; font-family: system-ui, sans-serif; font-size: 12px; font-weight: 800; letter-spacing: .18em; color: var(--orange); text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(54px, 7vw, 92px); line-height: .98; letter-spacing: -.045em; }
h1 em { color: var(--orange); font-style: normal; background: linear-gradient(transparent 72%, rgba(244,197,94,.54) 0); }
.hero-lead { max-width: 620px; margin: 26px 0 22px; font-size: 19px; line-height: 1.8; color: #69503b; }
.mission-preview { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 30px; }
.mission-preview button { min-height: 44px; padding: 8px 11px; background: rgba(255,255,255,.55); border: 1px dashed rgba(73,48,31,.28); border-radius: 10px; font-size: 14px; cursor: pointer; }
.mission-preview button:hover { background: #fff5d7; border-color: var(--orange); }
.mission-preview button:focus-visible, .chapter-btn:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }
.activity-complete { margin-top: 24px; padding: 18px; border: 1px dashed var(--green); background: #f2f4e7; border-radius: 16px; }
.activity-complete p { margin: 0 0 12px; line-height: 1.7; }
.primary-btn, .secondary-btn { border: 0; border-radius: 14px; padding: 13px 20px; cursor: pointer; font-weight: 800; transition: transform .18s, box-shadow .18s, background .18s; }
.primary-btn { color: #fff; background: var(--orange); box-shadow: 0 8px 18px rgba(201,89,43,.2); }
.primary-btn:hover, .secondary-btn:hover { transform: translateY(-2px); }
.primary-btn:active, .secondary-btn:active { transform: translateY(1px); }
.primary-btn.large { font-size: 18px; padding: 16px 24px; }
.primary-btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.secondary-btn { background: #fff8e9; border: 1px solid var(--line); }
.text-btn { border: 0; background: transparent; padding: 9px 4px; color: #a2582f; text-decoration: underline; text-underline-offset: 4px; cursor: pointer; }
.tiny-note { font-size: 12px; color: var(--muted); margin: 12px 0 0 7px; }
.hero-art { position: relative; min-height: 650px; display: grid; place-items: end center; }
.hero-art::before { content:""; position: absolute; width: 78%; aspect-ratio: 1; border-radius: 50%; background: #f5d889; opacity: .46; filter: blur(2px); top: 6%; }
.hero-art img { position: relative; z-index: 2; width: min(100%, 620px); height: auto; object-fit: contain; }
.sun-doodle { position: absolute; right: 4%; top: 9%; color: #e99b26; font-size: 66px; transform: rotate(10deg); }
.speech-bubble { position: absolute; z-index: 3; top: 16%; left: 0; background: #fffaf1; border: 2px solid var(--ink); border-radius: 22px 22px 22px 4px; padding: 14px 19px; font-size: 16px; line-height: 1.5; box-shadow: var(--shadow); transform: rotate(-3deg); }

.stage-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 30px; }
.stage-heading h2 { margin: 0; font-size: clamp(34px, 5vw, 58px); line-height: 1.1; }
.stage-number { display: inline-grid; place-items: center; width: 54px; height: 42px; margin-bottom: 14px; border: 2px solid var(--ink); border-radius: 50%; font-family: system-ui, sans-serif; font-weight: 900; transform: rotate(-4deg); background: var(--yellow); }
.stage-count { flex: none; font: 800 14px/1 system-ui, sans-serif; padding: 10px 14px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.58); }
.stage-instruction { color: var(--muted); font-size: 17px; margin: -14px 0 24px; }
.lesson-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.game-card, .toolbox-card, .quiz-shell, .notebook, .completion-card { background: rgba(255,250,240,.78); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 25px; }
.game-card { padding: 32px; position: relative; }
.card-label { margin: 0 0 10px; color: var(--muted); font: 800 12px/1.4 system-ui, sans-serif; letter-spacing: .13em; }
.pinyin-display { font: 900 clamp(40px, 7vw, 74px)/1.1 system-ui, sans-serif; letter-spacing: .06em; margin: 28px 0 34px; color: var(--brown); }
.sound-btn { position: absolute; right: 28px; top: 26px; width: 45px; height: 45px; border-radius: 50%; border: 1px solid var(--line); background: var(--yellow); cursor: pointer; font-size: 21px; }
.game-card label, .notebook label { display: block; margin-bottom: 8px; font-weight: 800; }
.answer-row { display: flex; gap: 10px; }
input, textarea, select { width: 100%; color: var(--ink); background: rgba(255,255,255,.8); border: 2px solid rgba(114,83,57,.2); border-radius: 13px; padding: 13px 15px; outline: none; }
input:focus, textarea:focus, select:focus { border-color: var(--orange); box-shadow: 0 0 0 4px rgba(233,121,63,.12); }
.answer-row input { min-width: 0; font-size: 20px; }
.feedback { min-height: 30px; margin-top: 12px; color: var(--muted); line-height: 1.6; }
.feedback.good { color: #527147; font-weight: 800; }
.feedback.bad { color: #bb5234; }
.centered { text-align: center; }
.toolbox-card { padding: 24px; }
.toolbox-title { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 1px dashed var(--line); padding-bottom: 14px; }
.toolbox-title span { font-size: 21px; font-weight: 900; }
.toolbox-title small { color: var(--muted); }
.material-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 18px; }
.material { min-height: 82px; display: grid; place-items: center; align-content: center; gap: 5px; background: #eee4cf; border: 2px dashed rgba(89,65,45,.2); border-radius: 17px; color: #9b8a77; transition: .3s; }
.material.is-earned { background: #fff5d8; border-style: solid; border-color: #e5b956; color: var(--ink); animation: pop .35s ease; }
.material b { font-size: 21px; }.material small { font: 12px system-ui, sans-serif; }
@keyframes pop { 50% { transform: scale(1.06) rotate(1deg); } }

.pair-board { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; max-width: 900px; margin: 0 auto; }
.pair-card { min-height: 112px; padding: 12px; border: 2px solid rgba(86,57,34,.18); border-radius: 18px; background: rgba(255,250,240,.75); box-shadow: 0 9px 20px rgba(83,51,29,.08); cursor: pointer; font-size: 25px; font-weight: 800; transition: .2s; }
.pair-card:hover { transform: translateY(-3px) rotate(-1deg); border-color: var(--orange); }
.pair-card.is-selected { background: #fff1bd; border-color: var(--orange); transform: translateY(-3px); }
.pair-card.is-matched { opacity: .42; pointer-events: none; background: #dfe8cf; border-color: var(--green); text-decoration: line-through; }
.knowledge-strip { max-width: 900px; margin: 26px auto 0; display: flex; gap: 20px; padding: 16px 18px; background: #dfe9d4; border-left: 5px solid var(--green); border-radius: 10px; }
.knowledge-strip b { white-space: nowrap; }.knowledge-strip span { color: #54624a; }

.site-scene { position: relative; overflow: hidden; border: 5px solid #fff9ed; outline: 1px solid var(--line); border-radius: 26px; box-shadow: var(--shadow); background: #d9c393; }
.site-scene img { display: block; width: 100%; aspect-ratio: 16/9; object-fit: cover; }
.site-hotspot { position: absolute; border: 2px solid #fff; color: #fff; background: rgba(62,49,34,.77); backdrop-filter: blur(4px); border-radius: 999px; padding: 8px 13px 8px 8px; cursor: pointer; box-shadow: 0 7px 18px rgba(0,0,0,.2); transition: .2s; }
.site-hotspot:hover { transform: scale(1.05); }.site-hotspot:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.site-hotspot span { display: inline-grid; place-items: center; width: 28px; height: 28px; background: var(--yellow); color: var(--ink); border-radius: 50%; font-family: system-ui, sans-serif; font-weight: 900; }
.site-hotspot.damp { left: 9%; bottom: 28%; }.site-hotspot.flat { left: 43%; bottom: 34%; }.site-hotspot.slope { right: 8%; bottom: 31%; }
.site-hotspot.is-correct { background: #55734b; animation: pulse 1.3s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 12px rgba(244,197,94,.2); } }
.site-task-card { display: grid; grid-template-columns: 1.3fr .7fr; gap: 30px; margin-top: 20px; padding: 24px; background: rgba(255,250,240,.83); border: 1px solid var(--line); border-radius: 22px; }
.collocation-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.collocation { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.collocation select { width: auto; flex: 1; padding: 8px; border-width: 1px; }
.collocation.is-correct { background: #edf3df; border-color: #a8bb88; }
.site-decision { padding-left: 25px; border-left: 1px dashed var(--line); }
.site-result { line-height: 1.75; color: var(--muted); }

.build-layout { display: grid; grid-template-columns: 1.45fr .55fr; gap: 22px; align-items: stretch; }
.cutaway-shell { position: relative; min-height: 500px; overflow: hidden; border: 5px solid #fff9ed; outline: 1px solid var(--line); border-radius: 25px; background: #9c6a3c; box-shadow: var(--shadow); }
.unbuilt-layer { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: 8px; color: #f8e8ca; text-align: center; background: repeating-linear-gradient(18deg,#8d5d36 0,#8d5d36 12px,#95663e 12px,#95663e 24px); font-size: 26px; }
.unbuilt-layer small { font-size: 14px; opacity: .78; }
.cutaway-reveal { position: absolute; inset: 0; overflow: hidden; clip-path: inset(0 100% 0 0); transition: clip-path .8s cubic-bezier(.2,.8,.2,1); }
.cutaway-reveal img { width: 100%; height: 100%; object-fit: cover; }
.build-spark { position: absolute; inset: 0; pointer-events: none; }
.build-spark.burst::before { content:"✦  ·  ✦"; position: absolute; left: 50%; top: 50%; color: #ffd666; font-size: 44px; animation: dust .7s ease both; }
@keyframes dust { from { opacity: 0; transform: translate(-50%,-20%) scale(.5); } 40% { opacity: 1; } to { opacity: 0; transform: translate(-50%,-100%) scale(1.5); } }
.build-console { padding: 24px; border: 1px solid var(--line); border-radius: 24px; background: rgba(255,250,240,.8); }
.tool-callout { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding-bottom: 16px; border-bottom: 1px dashed var(--line); }
.tool-callout b { font-size: 30px; }.tool-callout span { color: var(--muted); font-size: 14px; }
.verb-palette { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 18px 0; }
.verb-btn { padding: 15px 10px; background: #fff; border: 2px solid var(--line); border-radius: 13px; cursor: pointer; font-size: 22px; font-weight: 900; }
.verb-btn:hover { border-color: var(--orange); background: #fff5d7; }.verb-btn:disabled { opacity: .35; }
.build-sequence { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.build-sequence span { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: #e8ddc8; font-weight: 900; }
.build-sequence span.done { color: #fff; background: var(--green); }

.quiz-shell { width: min(760px, 100%); margin: 0 auto; padding: 30px; }
.quiz-progress { height: 8px; overflow: hidden; background: #e9dfcc; border-radius: 9px; margin-bottom: 28px; }
.quiz-progress span { display: block; height: 100%; width: 25%; background: var(--orange); transition: width .35s; }
.quiz-title { margin: 0 0 20px; font-size: 28px; line-height: 1.5; }
.quiz-options { display: grid; gap: 10px; }
.quiz-option { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; background: #fff; border: 2px solid var(--line); border-radius: 13px; cursor: pointer; }
.quiz-option:has(input:checked) { background: #fff2c8; border-color: var(--orange); }
.quiz-option input { width: auto; margin-top: 4px; accent-color: var(--orange); }

.notebook-layout { display: grid; grid-template-columns: 1.05fr .95fr; gap: 24px; }
.notebook, .completion-card { padding: 28px; }
.notebook select { margin-bottom: 18px; }.notebook textarea { min-height: 220px; resize: vertical; line-height: 2; font-size: 17px; background-image: repeating-linear-gradient(transparent 0,transparent 31px,rgba(107,83,59,.13) 32px); }
.writing-meta { display: flex; justify-content: space-between; margin: 8px 4px 18px; color: var(--muted); font-size: 13px; }
.writing-actions { display: flex; justify-content: space-between; gap: 12px; }
.completion-card { display: grid; justify-items: center; text-align: center; background: #f2e1a9; }
.completion-card img { width: min(72%, 360px); height: auto; max-height: 310px; object-fit: contain; object-position: center bottom; }
.completion-card h3 { font-size: 30px; margin: 5px 0; }.completion-card p { max-width: 430px; line-height: 1.75; }
.badge-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 8px 0; }.badge-row span { padding: 7px 10px; border-radius: 999px; background: rgba(255,255,255,.55); border: 1px solid rgba(91,59,29,.16); font-size: 13px; }

.chapter-nav { position: fixed; z-index: 25; bottom: max(13px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 6px; padding: 7px; max-width: calc(100vw - 24px); background: rgba(67,47,31,.92); border-radius: 18px; box-shadow: 0 12px 35px rgba(40,24,13,.25); backdrop-filter: blur(12px); }
.chapter-btn { border: 0; background: transparent; color: rgba(255,255,255,.6); padding: 9px 12px; border-radius: 12px; cursor: pointer; font: 700 12px/1 system-ui, sans-serif; white-space: nowrap; }
.chapter-btn.is-active { color: var(--ink); background: var(--yellow); }
.chapter-btn.is-complete:not(.is-active) { color: #c9e0b5; }
.toast { position: fixed; z-index: 60; left: 50%; bottom: 92px; transform: translate(-50%, 20px); padding: 11px 18px; border-radius: 999px; background: #49301f; color: #fff; opacity: 0; pointer-events: none; transition: .25s; box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: translate(-50%,0); }

@media (max-width: 820px) {
  .topbar { height: 66px; padding: 8px 14px; }.brand small, #progressText { display: none; }.header-stats { gap: 4px; }
  #app { width: min(100% - 22px, 680px); }.stage { min-height: calc(100vh - 120px); padding: 28px 0 100px; }
  .hero-stage.is-active { display: flex; flex-direction: column-reverse; gap: 4px; padding-top: 15px; }
  .hero-art { min-height: 320px; width: 100%; }.hero-art img { width: min(90%, 420px); max-height: 350px; object-fit: contain; }.hero-art::before { width: 65%; top: 0; }.speech-bubble { top: 8%; left: 2%; font-size: 13px; padding: 10px 13px; }.sun-doodle { font-size: 42px; }
  h1 { font-size: clamp(45px, 14vw, 68px); }.hero-lead { font-size: 16px; margin: 17px 0; }.mission-preview { gap: 5px; margin-bottom: 18px; }.mission-preview button { font-size: 12px; padding: 6px 8px; }
  .stage-heading { align-items: flex-start; margin-bottom: 22px; }.stage-heading h2 { font-size: 34px; }.stage-number { width: 47px; height: 36px; margin-bottom: 10px; }.stage-count { margin-top: 8px; font-size: 11px; padding: 8px 10px; }
  .lesson-grid, .site-task-card, .build-layout, .notebook-layout { grid-template-columns: 1fr; }.game-card, .toolbox-card, .quiz-shell, .notebook, .completion-card { border-radius: 19px; }.game-card { padding: 22px; }.answer-row { flex-direction: column; }.material-grid { grid-template-columns: repeat(4,1fr); }.material { min-height: 67px; }.material b { font-size: 16px; }
  .pair-board { grid-template-columns: repeat(2, 1fr); }.pair-card { min-height: 85px; font-size: 21px; }.knowledge-strip { font-size: 14px; }
  .site-scene { min-height: 430px; }.site-scene img { height: 430px; object-fit: cover; object-position: center; }.site-hotspot { font-size: 12px; padding-right: 9px; }.site-hotspot.damp { left: 2%; bottom: 27%; }.site-hotspot.flat { left: 38%; bottom: 34%; }.site-hotspot.slope { right: 2%; bottom: 28%; }.site-task-card { gap: 20px; padding: 16px; }.site-decision { padding: 18px 0 0; border-left: 0; border-top: 1px dashed var(--line); }.collocation-list { grid-template-columns: 1fr; }
  .cutaway-shell { min-height: 310px; }.build-console { padding: 18px; }.tool-callout b { font-size: 25px; }
  .quiz-shell { padding: 20px; }.quiz-title { font-size: 22px; }
  .chapter-nav { width: calc(100vw - 18px); overflow-x: auto; justify-content: flex-start; scrollbar-width: none; }.chapter-nav::-webkit-scrollbar { display:none; }.chapter-btn { padding: 9px 10px; }
}

@media (max-width: 640px) {
  .chapter-nav { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 3px; overflow: visible; }
  .chapter-btn { min-height: 39px; padding: 8px 2px; font-size: 12px; }
  .stage { padding-bottom: 130px; }
  .toast { bottom: 120px; max-width: calc(100vw - 30px); width: max-content; text-align: center; }
}
@media (max-width: 430px) {
  .brand b { font-size: 14px; }.brand-mark { width: 39px; height: 39px; }.header-stats span { padding: 6px 9px; }
  .hero-art { min-height: 275px; }.hero-art img { max-height: 290px; }.speech-bubble { display: none; }
  .material-grid { grid-template-columns: repeat(2,1fr); }.site-scene, .site-scene img { min-height: 370px; height: 370px; }.site-scene img { object-position: 52% center; }
  .writing-actions { flex-direction: column; }.completion-card img { width: 88%; }
}

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