:root {
  --paper: #f6efe3;
  --paper-2: #efe5d4;
  --card: #fffaf2;
  --ink: #221c18;
  --muted: #6d6158;
  --line: #e4d7c3;
  --red: #c8372d;
  --red-soft: #f6dcd6;
  --jade: #2b8a66;
  --jade-soft: #d6efe3;
  --gold: #d9982a;
  --shadow: 0 1px 0 rgba(60, 40, 20, .04), 0 10px 30px -12px rgba(80, 50, 20, .25);
  --t1: #cf3f35;
  --t2: #2f8a55;
  --t3: #2f66c9;
  --t4: #8a4dc4;
  --t5: #8b8178;
  --radius: 20px;
  --hz: "Noto Serif SC", "Songti SC", "SimSun", serif;
  --display: "Fraunces", Georgia, serif;
  --ui: "DM Sans", system-ui, -apple-system, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #17130f; --paper-2: #1e1914; --card: #231d17; --ink: #f2eadd; --muted: #a8998a; --line: #3a3027;
    --red: #e2584b; --red-soft: #4a221d; --jade: #45b98c; --jade-soft: #193a2d; --gold: #e6ab45;
    --shadow: 0 10px 30px -12px rgba(0, 0, 0, .6);
    --t1: #f06a5f; --t2: #52c07f; --t3: #6b9cf2; --t4: #b585ee; --t5: #a49a90;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #17130f; --paper-2: #1e1914; --card: #231d17; --ink: #f2eadd; --muted: #a8998a; --line: #3a3027;
  --red: #e2584b; --red-soft: #4a221d; --jade: #45b98c; --jade-soft: #193a2d; --gold: #e6ab45;
  --t1: #f06a5f; --t2: #52c07f; --t3: #6b9cf2; --t4: #b585ee; --t5: #a49a90;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--ui); color: var(--ink); line-height: 1.55;
  background:
    radial-gradient(1200px 500px at 85% -10%, color-mix(in srgb, var(--red) 10%, transparent), transparent 60%),
    radial-gradient(900px 500px at -10% 20%, color-mix(in srgb, var(--gold) 12%, transparent), transparent 60%),
    var(--paper);
  min-height: 100vh; overflow-x: hidden;
}
a { color: inherit; }
button { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; line-height: 1.15; margin: 0; letter-spacing: -0.01em; }
main { max-width: 1100px; margin: 0 auto; padding: 8px 20px 40px; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--red) 60%, transparent); outline-offset: 3px; border-radius: 10px; }

.t1 { color: var(--t1); } .t2 { color: var(--t2); } .t3 { color: var(--t3); } .t4 { color: var(--t4); } .t5 { color: var(--t5); }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 20px; max-width: 1140px; margin: 0 auto;
  background: color-mix(in srgb, var(--paper) 82%, transparent); backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.seal-logo {
  font-family: var(--hz); font-weight: 700; color: #fffaf2; background: var(--red); border-radius: 12px;
  width: 46px; height: 46px; display: grid; place-items: center; font-size: 17px; letter-spacing: -1px;
  writing-mode: vertical-rl; box-shadow: inset 0 0 0 2px rgba(255,255,255,.25); transform: rotate(-4deg);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text b { font-family: var(--display); font-size: 21px; }
.nw { white-space: nowrap; }
.brand-text small { color: var(--muted); font-size: 12px; white-space: nowrap; }
.stats { display: flex; gap: 10px; align-items: center; }
.stat {
  display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line);
  padding: 6px 12px 6px 6px; border-radius: 999px; box-shadow: var(--shadow);
}
.stat b { font-size: 15px; white-space: nowrap; }
.stat-lbl { color: var(--muted); font-size: 12px; }
.stat-ico { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-family: var(--hz); font-weight: 700; font-size: 15px; }
.stat-ico.flame { background: color-mix(in srgb, var(--gold) 25%, transparent); color: var(--gold); }
.stat-ico.seal { background: var(--red); color: #fffaf2; font-size: 12px; }
.rank-body { display: grid; grid-template-columns: auto auto; column-gap: 6px; align-items: baseline; }
.xpbar { grid-column: 1 / -1; height: 4px; border-radius: 4px; background: var(--line); overflow: hidden; margin-top: 2px; width: 100px; }
.xpbar i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--red)); border-radius: 4px; transition: width .6s; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; cursor: pointer;
  border: 1px solid transparent; border-radius: 999px; padding: 10px 18px; font-weight: 700; font-size: 15px;
  transition: transform .15s, background .2s, box-shadow .2s;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--red); color: #fffaf2; box-shadow: 0 6px 18px -6px color-mix(in srgb, var(--red) 70%, transparent); }
.btn.primary:hover { background: color-mix(in srgb, var(--red) 88%, black); }
.btn.soft { background: var(--card); border-color: var(--line); }
.btn.soft:hover { border-color: color-mix(in srgb, var(--red) 40%, var(--line)); }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.big { padding: 14px 24px; font-size: 16px; }
.btn.round { width: 48px; height: 48px; padding: 0; background: var(--card); border-color: var(--line); font-size: 20px; }
.btn[disabled] { opacity: .35; pointer-events: none; }
.btn kbd { font: 600 11px var(--ui); opacity: .7; border: 1px solid rgba(255,255,255,.4); padding: 1px 6px; border-radius: 6px; }
.speak {
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); color: var(--red);
  display: inline-grid; place-items: center; cursor: pointer; vertical-align: middle; transition: transform .15s, background .2s;
}
.speak:hover { background: var(--red-soft); transform: scale(1.06); }

/* ---------- Hero ---------- */
.hero {
  display: grid; grid-template-columns: 1.15fr 1fr; gap: 28px; align-items: center;
  margin-top: 12px; padding: 36px; border-radius: 32px; background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow);
  overflow: hidden; position: relative;
}
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: 12px; font-weight: 700; color: var(--red); margin: 0 0 10px; }
.hero h1 { font-size: clamp(32px, 5vw, 54px); }
.lede { color: var(--muted); font-size: 17px; max-width: 56ch; margin: 14px 0 0; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
.hero-art {
  position: relative; height: 300px; border-radius: 24px; overflow: hidden;
  background: linear-gradient(180deg, color-mix(in srgb, var(--gold) 22%, var(--paper)) 0%, var(--paper) 70%);
}
.mountains { position: absolute; inset: auto 0 0 0; width: 100%; height: 70%; }
.mountains .m1 { fill: color-mix(in srgb, var(--ink) 12%, transparent); }
.mountains .m2 { fill: color-mix(in srgb, var(--ink) 20%, transparent); }
.sun { position: absolute; width: 90px; height: 90px; border-radius: 50%; background: var(--red); opacity: .85; right: 7%; top: 9%; }
.hero-glyph {
  position: absolute; left: 0; right: 0; top: 18%; text-align: center; font-family: var(--hz); font-weight: 700;
  font-size: 110px; line-height: 1; letter-spacing: 6px; animation: float 6s ease-in-out infinite;
}
.hero-glyph span { text-shadow: 0 4px 0 var(--card); }
.hero-py { position: absolute; bottom: 20px; left: 0; right: 0; text-align: center; font-weight: 700; font-size: 18px; }
@keyframes float { 50% { transform: translateY(-8px); } }

/* ---------- Blocks ---------- */
.block { margin-top: 48px; }
.block-head { margin-bottom: 18px; }
.block-head h2 { font-size: clamp(24px, 3vw, 32px); }
.block-head p { color: var(--muted); margin: 6px 0 0; }

.levels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.level {
  text-align: left; cursor: pointer; padding: 22px; border-radius: var(--radius); background: var(--card);
  border: 2px solid var(--line); display: flex; flex-direction: column; gap: 6px; transition: border-color .2s, transform .15s, box-shadow .2s;
}
.level:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.level.on { border-color: var(--red); box-shadow: 0 0 0 4px var(--red-soft), var(--shadow); }
.level-steps { display: flex; gap: 4px; margin-bottom: 6px; }
.level-steps i { width: 22px; height: 6px; border-radius: 3px; background: var(--red); }
.level-steps i.off { background: var(--line); }
.level-zh { font-family: var(--hz); font-size: 30px; font-weight: 700; display: flex; align-items: baseline; gap: 8px; }
.level-zh small { font-family: var(--ui); font-size: 13px; color: var(--muted); font-weight: 500; }
.level-name { font-weight: 700; font-size: 18px; }
.level-desc { color: var(--muted); font-size: 14px; }

.cats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; }
.cat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px;
  display: flex; flex-direction: column; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.cat::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 5px; background: var(--accent);
}
.cat-characters { --accent: var(--red); }
.cat-words { --accent: var(--jade); }
.cat-phrases { --accent: var(--t3); }
.cat-numbers { --accent: var(--gold); }
.cat-tones { --accent: var(--t4); }
.cat-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; }
.cat-glyph {
  font-family: var(--hz); font-size: 44px; font-weight: 700; line-height: 1; color: var(--accent);
  width: 72px; height: 72px; border-radius: 18px; display: grid; place-items: center; position: relative;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.cat-glyph small { position: absolute; bottom: -18px; font: 600 12px var(--ui); color: var(--muted); }
.ring {
  width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--line) 0);
}
.ring span { width: 42px; height: 42px; border-radius: 50%; background: var(--card); display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.cat h3 { font-size: 21px; margin-top: 10px; }
.cat p { color: var(--muted); font-size: 14px; margin: 6px 0 10px; flex: 1; }
.cat-meta { font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 14px; }
.cat-actions { display: flex; gap: 8px; }
.cat-actions .btn { flex: 1; padding: 10px 8px; }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.wotd-body { display: flex; gap: 22px; align-items: center; }
.wotd-hz { font-family: var(--hz); font-size: 72px; font-weight: 700; line-height: 1; white-space: nowrap; }
.wotd-py { font-size: 22px; font-weight: 700; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.wotd-en { font-size: 18px; }
.wotd-note { color: var(--muted); font-size: 14px; margin: 8px 0 0; }
.journey-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.journey-grid div { display: flex; flex-direction: column; }
.journey-grid b { font-family: var(--display); font-size: 30px; }
.journey-grid span { color: var(--muted); font-size: 13px; line-height: 1.3; }
.journey-tip { color: var(--muted); font-size: 14px; margin: 16px 0 0; padding-top: 14px; border-top: 1px dashed var(--line); }

.guide-card {
  display: flex; gap: 24px; align-items: center; padding: 26px; border-radius: var(--radius);
  background: linear-gradient(135deg, var(--red-soft), color-mix(in srgb, var(--gold) 18%, var(--card)));
  border: 1px solid var(--line);
}
.guide-glyph { font-family: var(--hz); font-weight: 700; font-size: 54px; color: var(--red); writing-mode: vertical-rl; line-height: 1; }
.guide-card h3 { font-size: 22px; }
.guide-card p { margin: 8px 0 14px; }
.guide-ctl { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-block; font-weight: 700; font-size: 13px; padding: 2px 9px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); margin: 2px 0; }

/* ---------- Page heads ---------- */
.page-head { margin: 20px 0 22px; }
.page-head h1 { font-size: clamp(30px, 4vw, 44px); }
.zh-sub { font-family: var(--hz); color: var(--red); font-size: .8em; margin-left: 6px; }
.back { display: inline-block; text-decoration: none; color: var(--muted); font-weight: 600; margin-bottom: 10px; }
.back:hover { color: var(--red); }
.center { text-align: center; margin-top: 28px; }
.cta-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }

/* ---------- Tones ---------- */
.tone-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.tone {
  cursor: pointer; text-align: center; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 14px; display: flex; flex-direction: column; align-items: center; gap: 4px; box-shadow: var(--shadow);
  transition: transform .15s; border-top: 5px solid currentColor;
}
.tone:hover { transform: translateY(-3px); }
.contour { width: 100%; max-width: 140px; height: 70px; }
.contour line { stroke: var(--line); stroke-dasharray: 3 4; }
.contour path { fill: none; stroke: currentColor; stroke-width: 6; stroke-linecap: round; }
.tone-num { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; }
.tone-py { font-size: 30px; font-weight: 700; font-family: var(--display); }
.tone-hz { font-family: var(--hz); font-size: 44px; font-weight: 700; color: var(--ink); line-height: 1.1; }
.tone-en { color: var(--ink); font-weight: 600; }
.tone-how { color: var(--muted); font-size: 13px; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.fact { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: flex; gap: 14px; }
.fact > b { font-family: var(--display); font-size: 34px; color: var(--red); line-height: 1; }
.fact p { margin: 0; color: var(--muted); }
.fact p b { color: var(--ink); }

/* ---------- Study ---------- */
.tips { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin-bottom: 20px; }
.tip { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--gold); border-radius: 14px; padding: 12px 14px; display: flex; flex-direction: column; font-size: 14px; }
.tip span { color: var(--muted); }
.study { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.counter { color: var(--muted); font-weight: 600; }
.counter span { color: var(--ink); font-size: 20px; }
.flip { width: min(440px, 100%); height: 340px; perspective: 1200px; cursor: pointer; position: relative; }
.face {
  position: absolute; inset: 0; border-radius: 28px; background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; text-align: center;
  backface-visibility: hidden; transition: transform .55s cubic-bezier(.2,.8,.2,1);
}
.face.front {
  background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 50% 50%; background-position: center; background-color: var(--card);
}
.face.rear { transform: rotateY(180deg); }
.flip.flipped .front { transform: rotateY(-180deg); }
.flip.flipped .rear { transform: rotateY(0); }
.card-hz { font-family: var(--hz); font-weight: 700; font-size: 150px; line-height: 1.1; background: var(--card); padding: 0 10px; }
.card-hz.words { font-size: 100px; }
.card-hz.phrases { font-size: 48px; line-height: 1.3; }
.card-hz.numbers { font-size: 60px; }
.card-hz.small { font-size: 72px; background: none; }
.card-hz.small.words { font-size: 60px; }
.card-hz.small.phrases { font-size: 34px; }
.card-hz.small.numbers { font-size: 40px; }
.num-big { font-family: var(--display); font-size: 84px; font-weight: 700; background: var(--card); padding: 0 12px; line-height: 1.1; }
.hint { position: absolute; bottom: 18px; font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
.card-py { font-size: 26px; font-weight: 700; margin-top: 6px; }
.card-en { font-size: 20px; margin-top: 4px; }
.card-note { color: var(--muted); font-size: 14px; margin: 12px 0 0; max-width: 34ch; }
.stars { display: flex; gap: 6px; margin-top: 12px; }
.stars i { width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.stars i.on { background: var(--gold); }
.study-ctl { display: flex; gap: 10px; align-items: center; }
.study-ctl .speak { width: 48px; height: 48px; }
.dots { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; max-width: 440px; }
.dot { width: 10px; height: 10px; border-radius: 50%; border: 0; padding: 0; background: var(--line); cursor: pointer; }
.dot.seen { background: color-mix(in srgb, var(--red) 40%, var(--line)); }
.dot.on { background: var(--red); transform: scale(1.3); }
.study-end { display: none; text-align: center; margin-top: 18px; padding: 22px; border-radius: var(--radius); background: var(--jade-soft); }
.study-end.show { display: block; animation: rise .4s ease; }
.study-end p { margin: 0 0 12px; font-weight: 600; }
.mini-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.mini {
  cursor: pointer; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; transition: border-color .2s, transform .15s; text-align: center;
}
.mini:hover { transform: translateY(-2px); border-color: var(--red); }
.mini.on { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.mini-hz { font-family: var(--hz); font-size: 28px; font-weight: 700; line-height: 1.3; }
.mini-hz.phrases, .mini-hz.numbers { font-size: 16px; }
.mini-hz.numbers { font-family: var(--display); font-size: 20px; }
.mini-en { font-size: 12px; color: var(--muted); line-height: 1.3; }

/* ---------- Quiz ---------- */
.quiz { max-width: 720px; margin: 10px auto 0; }
.quiz-top { display: flex; align-items: center; gap: 14px; }
.quiz-top .back { margin: 0; font-size: 20px; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; }
.qbar { flex: 1; height: 14px; border-radius: 10px; background: var(--line); overflow: hidden; }
.qbar i { display: block; height: 100%; border-radius: 10px; background: linear-gradient(90deg, var(--jade), color-mix(in srgb, var(--jade) 60%, var(--gold))); transition: width .5s; }
.combo { font-family: var(--hz); font-weight: 700; padding: 6px 12px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.combo.hot { background: var(--gold); color: #2a1a05; border-color: var(--gold); animation: pop .4s; }
.quiz-meta { color: var(--muted); font-size: 13px; font-weight: 600; margin: 14px 0 10px; text-align: center; }
.q-card { background: var(--card); border: 1px solid var(--line); border-radius: 28px; padding: 22px 20px 30px; text-align: center; box-shadow: var(--shadow); animation: rise .35s ease; }
.q-prompt { margin: 0 0 8px; font-weight: 700; color: var(--muted); }
.q-big { min-height: 130px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.q-hz { font-family: var(--hz); font-weight: 700; font-size: 110px; line-height: 1.15; }
.q-hz.words { font-size: 84px; }
.q-hz.phrases { font-size: 44px; line-height: 1.35; }
.q-hz.numbers { font-size: 64px; }
.q-hz.numbers.long { font-size: 44px; }
.q-py { font-size: 24px; font-weight: 700; }
.q-en { font-family: var(--display); font-size: 40px; font-weight: 700; }
.q-num { font-family: var(--display); font-size: 76px; font-weight: 700; }
.listen-big {
  cursor: pointer; border: 0; width: 120px; height: 120px; border-radius: 50%; background: var(--red); color: #fffaf2;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 12px; font-weight: 700;
  box-shadow: 0 0 0 10px var(--red-soft); animation: breathe 2.4s ease-in-out infinite;
}
.listen-big svg { width: 42px; height: 42px; }
.listen-big + .q-py { margin-top: 26px; }
@keyframes breathe { 50% { box-shadow: 0 0 0 18px var(--red-soft); } }
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.opt {
  cursor: pointer; position: relative; text-align: left; display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 2px solid var(--line); border-bottom-width: 4px; border-radius: 18px; padding: 14px 16px; min-height: 76px;
  transition: border-color .15s, transform .1s, background .2s;
}
.opt:hover:not(:disabled) { border-color: color-mix(in srgb, var(--red) 45%, var(--line)); transform: translateY(-1px); }
.opt:active:not(:disabled) { transform: translateY(2px); border-bottom-width: 2px; }
.key { flex: none; width: 26px; height: 26px; border-radius: 8px; border: 1px solid var(--line); display: grid; place-items: center; font-size: 12px; font-weight: 700; color: var(--muted); }
.opt-body { display: flex; flex-direction: column; font-size: 17px; font-weight: 600; line-height: 1.3; }
.opt-hz { font-family: var(--hz); font-size: 30px; font-weight: 700; line-height: 1.25; }
.opt-hz.phrases { font-size: 20px; }
.opt-hz.numbers { font-size: 24px; }
.opt-sub { font-size: 13px; color: var(--muted); font-weight: 500; }
.opt-py { font-size: 20px; }
.opt-num { font-family: var(--display); font-size: 24px; }
.opt-tone { display: flex; align-items: center; gap: 12px; font-size: 18px; }
.opt-tones { font-size: 19px; }
.mini-contour { width: 46px; height: 27px; flex: none; }
.mini-contour path { fill: none; stroke: currentColor; stroke-width: 9; stroke-linecap: round; }
.opt.right { border-color: var(--jade); background: var(--jade-soft); }
.opt.right .key { background: var(--jade); color: #fff; border-color: var(--jade); }
.opt.wrong { border-color: var(--red); background: var(--red-soft); animation: shake .35s; }
.opt.wrong .key { background: var(--red); color: #fff; border-color: var(--red); }
.opt.dim { opacity: .5; }
.opt:disabled { cursor: default; }
.feedback { display: none; margin-top: 16px; border-radius: 22px; padding: 18px 20px; }
.feedback.show { display: block; animation: rise .3s ease; }
.feedback.good { background: var(--jade-soft); border: 1px solid color-mix(in srgb, var(--jade) 40%, transparent); }
.feedback.bad { background: var(--red-soft); border: 1px solid color-mix(in srgb, var(--red) 35%, transparent); }
.fb-head { display: flex; justify-content: space-between; align-items: center; font-size: 18px; }
.good .fb-head b { color: var(--jade); }
.bad .fb-head b { color: var(--red); }
.xp-pop { font-weight: 700; color: var(--gold); animation: pop .5s; }
.fb-card { display: flex; gap: 18px; align-items: center; margin: 12px 0 16px; background: var(--card); border-radius: 16px; padding: 14px 16px; }
.fb-hz { font-family: var(--hz); font-size: 52px; font-weight: 700; line-height: 1.1; white-space: nowrap; }
.fb-hz.phrases { font-size: 26px; white-space: normal; }
.fb-hz.numbers { font-size: 30px; }
.fb-py { font-size: 20px; font-weight: 700; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.fb-en { font-size: 17px; }
.fb-note { font-size: 14px; color: var(--muted); margin-top: 4px; }
.feedback .btn { width: 100%; }

/* ---------- Results ---------- */
.results { max-width: 760px; margin: 10px auto 0; }
.res-card { text-align: center; background: var(--card); border: 1px solid var(--line); border-radius: 32px; padding: 34px 24px; box-shadow: var(--shadow); }
.res-stars { display: flex; justify-content: center; gap: 8px; }
.star { font-size: 54px; color: var(--line); animation: pop .5s both; }
.star.on { color: var(--gold); }
.res-zh { font-family: var(--hz); font-size: 40px; font-weight: 700; color: var(--red); }
.res-card h1 { font-size: 36px; }
.res-card .lede { margin-left: auto; margin-right: auto; }
.res-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 24px auto 0; max-width: 480px; }
.res-stats div { background: var(--paper-2); border-radius: 16px; padding: 12px; display: flex; flex-direction: column; }
.res-stats b { font-family: var(--display); font-size: 30px; }
.res-stats span { color: var(--muted); font-size: 13px; }
.badge { display: inline-block; margin-top: 16px; padding: 6px 14px; border-radius: 999px; background: var(--gold); color: #2a1a05; font-weight: 700; font-size: 14px; }
.res-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 24px; }
.review { display: grid; gap: 10px; }
.rev { display: flex; align-items: center; gap: 16px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px 16px; }
.rev-hz { font-family: var(--hz); font-size: 36px; font-weight: 700; min-width: 70px; line-height: 1.2; }
.rev-hz.phrases, .rev-hz.numbers { font-size: 22px; }
.rev-info { flex: 1; }
.rev-btns { display: flex; gap: 6px; }
.rev-py { font-weight: 700; }
.rev-en { color: var(--muted); }
.perfect { font-weight: 700; color: var(--jade); font-size: 18px; }

/* ---------- Writing practice ---------- */
.writer {
  position: fixed; inset: 0; z-index: 60; display: none; align-items: center; justify-content: center; padding: 16px;
  background: color-mix(in srgb, var(--ink) 45%, transparent); backdrop-filter: blur(4px);
}
.writer.show { display: flex; }
.writer.show .w-card { animation: rise .25s ease; }
body.modal-open { overflow: hidden; }
.w-card {
  position: relative; width: min(400px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; text-align: center;
  background: var(--card); border: 1px solid var(--line); border-radius: 28px; box-shadow: var(--shadow); padding: 22px 20px 24px;
}
.w-x { position: absolute; top: 12px; right: 12px; width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); cursor: pointer; font-size: 15px; }
.w-word { display: flex; align-items: baseline; justify-content: center; gap: 4px 12px; flex-wrap: wrap; font-family: var(--hz); font-size: 34px; font-weight: 700; line-height: 1.2; padding: 0 30px; }
.w-mean { font-family: var(--ui); font-size: 15px; font-weight: 600; color: var(--muted); }
.w-tabs { display: flex; justify-content: center; gap: 8px; margin-top: 12px; }
.w-tab { font-family: var(--hz); font-size: 22px; font-weight: 700; width: 46px; height: 46px; border-radius: 12px; border: 2px solid var(--line); background: var(--card); cursor: pointer; }
.w-tab.on { border-color: var(--red); background: var(--red-soft); }
.w-pad { position: relative; box-sizing: content-box; margin: 16px auto 0; border: 2px solid var(--line); border-radius: 18px; background: var(--paper); touch-action: none; overflow: hidden; }
.w-grid { position: absolute; inset: 0; width: 100%; height: 100%; }
.w-grid path { stroke: var(--line); stroke-width: .6; stroke-dasharray: 2 2; fill: none; vector-effect: non-scaling-stroke; }
#wTarget { position: relative; }
.w-msg { min-height: 42px; margin: 12px 0 6px; color: var(--muted); font-size: 14px; }
.w-msg b { color: var(--jade); }
.w-ctl { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* ---------- Footer, toast, confetti ---------- */
.foot { text-align: center; color: var(--muted); font-size: 13px; padding: 20px 20px 40px; }
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 30px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--paper); padding: 12px 18px; border-radius: 14px; font-size: 14px; max-width: calc(100% - 32px);
  transition: opacity .25s, transform .25s; z-index: 50; text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 40; }
#confetti i { position: absolute; top: -20px; width: 9px; height: 14px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { top: 105vh; transform: rotate(720deg) translateX(40px); } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes pop { 0% { transform: scale(.4); opacity: 0; } 70% { transform: scale(1.15); } 100% { transform: scale(1); opacity: 1; } }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- Responsive ---------- */
@media (max-width: 1060px) {
  .cats { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 960px) {
  .tone-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 760px) {
  main { padding: 4px 16px 32px; }
  .topbar { padding: 10px 16px; }
  .brand { gap: 10px; } .stats { gap: 6px; }
  .brand-text b { font-size: 15px; line-height: 1.15; }
  .seal-logo { width: 38px; height: 38px; font-size: 14px; border-radius: 10px; }
  .stat { padding: 4px 9px 4px 4px; gap: 6px; } .stat-ico { width: 28px; height: 28px; }
  .stat-lbl, .xpbar { display: none; }
  .hero { grid-template-columns: 1fr; padding: 22px; }
  .hero-art { height: 220px; order: -1; }
  .hero-glyph { font-size: 84px; }
  .levels, .split, .facts { grid-template-columns: 1fr; }
  .cats { grid-template-columns: repeat(2, 1fr); }
  .cats > :last-child:nth-child(odd) { grid-column: 1 / -1; }
  .tone-grid { grid-template-columns: repeat(2, 1fr); }
  .journey-grid { grid-template-columns: repeat(2, 1fr); row-gap: 14px; }
  .guide-card { flex-direction: column; align-items: flex-start; }
  .guide-glyph { writing-mode: horizontal-tb; font-size: 40px; }
  .wotd-hz { font-size: 56px; }
  .q-hz { font-size: 88px; } .q-hz.words { font-size: 64px; } .q-hz.phrases { font-size: 32px; }
  .q-hz.numbers { font-size: 48px; } .q-hz.numbers.long { font-size: 32px; }
  .q-en { font-size: 30px; } .q-num { font-size: 52px; }
  .flip { height: 300px; }
  .card-hz { font-size: 120px; } .card-hz.words { font-size: 72px; } .card-hz.phrases { font-size: 34px; }
}
@media (max-width: 520px) {
  .cats { grid-template-columns: 1fr; }
  .options { grid-template-columns: 1fr; }
  .opt { min-height: 64px; }
  .fb-card { flex-direction: column; align-items: flex-start; gap: 6px; }
  .res-actions .btn { flex: 1 1 100%; }
}
