:root {
  --bg: #fffaf0;
  --bg-elevated: #ffffff;
  --text: #2d2b55;
  --text-dim: #6b6890;
  --border: #f1e4cc;
  --dot: rgba(255, 170, 60, 0.16);

  --blue: #3b5bdb;   --blue-dark: #2f49b0;   --blue-dim: #e8edff;   --blue-text: #3b5bdb;
  --orange: #e8590c; --orange-dark: #b9470a; --orange-dim: #fff1e6; --orange-text: #b8440b;
  --pink: #d6336c;   --pink-dark: #ab2956;   --pink-dim: #ffe8f0;   --pink-text: #b8225a;
  --purple: #7048e8; --purple-dark: #5a3ab9; --purple-dim: #f0ebff; --purple-text: #6741d9;
  --teal: #0c8599;   --teal-dark: #0a6a7a;   --teal-dim: #e3f7f9;   --teal-text: #0b6b7c;
  --green: #2b8a3e;  --green-dark: #226e32;  --green-dim: #e6f7ea;  --green-text: #1f6b30;
  --yellow: #fcc419; --yellow-dark: #e0a800; --yellow-dim: #fff3bf; --yellow-text: #8a5a00;
  --red: #e03131;    --red-dark: #b32727;    --red-dim: #fff0f0;    --red-text: #c92a2a;   --red-line: #ffc9c9;

  --primary: var(--blue);
  --primary-dark: var(--blue-dark);
  --primary-dim: var(--blue-dim);
  --on-color: #ffffff;
  --shadow: 0 4px 14px rgba(80, 60, 20, 0.08);
  --shadow-lg: 0 14px 34px rgba(80, 60, 20, 0.16);
  --radius: 22px;
  --nav-w: 232px;
  --topbar-h: 64px;
  --font: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  --font-display: ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1d1b33;
    --bg-elevated: #29274a;
    --text: #f1f0ff;
    --text-dim: #aeacd0;
    --border: #3b3866;
    --dot: rgba(255, 255, 255, 0.045);
    --blue-dim: #252b55;   --blue-text: #91a7ff;
    --orange-dim: #3d2c1e; --orange-text: #ffa94d;
    --pink-dim: #3d2033;   --pink-text: #faa2c1;
    --purple-dim: #2e2652; --purple-text: #b197fc;
    --teal-dim: #173b44;   --teal-text: #66d9e8;
    --green-dim: #1f3a2a;  --green-text: #69db7c;
    --yellow-dim: #3b3318; --yellow-text: #ffd43b;
    --red-dim: #3d2230;    --red-text: #ff8787;   --red-line: #5c2a3a;
    --shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 14px 34px rgba(0, 0, 0, 0.5);
  }
}
:root[data-theme="dark"] {
  --bg: #1d1b33;
  --bg-elevated: #29274a;
  --text: #f1f0ff;
  --text-dim: #aeacd0;
  --border: #3b3866;
  --dot: rgba(255, 255, 255, 0.045);
  --blue-dim: #252b55;   --blue-text: #91a7ff;
  --orange-dim: #3d2c1e; --orange-text: #ffa94d;
  --pink-dim: #3d2033;   --pink-text: #faa2c1;
  --purple-dim: #2e2652; --purple-text: #b197fc;
  --teal-dim: #173b44;   --teal-text: #66d9e8;
  --green-dim: #1f3a2a;  --green-text: #69db7c;
  --yellow-dim: #3b3318; --yellow-text: #ffd43b;
  --red-dim: #3d2230;    --red-text: #ff8787;   --red-line: #5c2a3a;
  --shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 14px 34px rgba(0, 0, 0, 0.5);
}

/* Color themes: any element with c-* gets --c (solid), --c-dark (3D edge), --c-dim (tint), --c-text */
.c-blue   { --c: var(--blue);   --c-dark: var(--blue-dark);   --c-dim: var(--blue-dim);   --c-text: var(--blue-text); }
.c-orange { --c: var(--orange); --c-dark: var(--orange-dark); --c-dim: var(--orange-dim); --c-text: var(--orange-text); }
.c-pink   { --c: var(--pink);   --c-dark: var(--pink-dark);   --c-dim: var(--pink-dim);   --c-text: var(--pink-text); }
.c-purple { --c: var(--purple); --c-dark: var(--purple-dark); --c-dim: var(--purple-dim); --c-text: var(--purple-text); }
.c-teal   { --c: var(--teal);   --c-dark: var(--teal-dark);   --c-dim: var(--teal-dim);   --c-text: var(--teal-text); }
.c-green  { --c: var(--green);  --c-dark: var(--green-dark);  --c-dim: var(--green-dim);  --c-text: var(--green-text); }
.c-red    { --c: var(--red);    --c-dark: var(--red-dark);    --c-dim: var(--red-dim);    --c-text: var(--red-text); }
.c-yellow { --c: var(--yellow); --c-dark: var(--yellow-dark); --c-dim: var(--yellow-dim); --c-text: var(--yellow-text); }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 17px;
  background-color: var(--bg);
  background-image: radial-gradient(var(--dot) 1.6px, transparent 1.7px);
  background-size: 22px 22px;
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { line-height: 1.25; font-family: var(--font-display); }
button, input, select, textarea { font-family: inherit; }
button, .lesson-card, .game-tile, .mode-tab, .nav-item, .lesson-chip, .audio-btn, .icon-btn, .btn {
  transition: transform .15s ease, box-shadow .15s ease, background-color .15s ease, border-color .15s ease, opacity .15s ease, color .15s ease;
}
.dim { color: var(--text-dim); }

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

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--bg-elevated);
  border-bottom: 4px solid transparent;
  border-image: linear-gradient(90deg, var(--blue), var(--purple), var(--pink), var(--orange), var(--yellow), var(--green)) 1;
}
.topbar-inner {
  display: flex; align-items: center; gap: 8px;
  height: calc(var(--topbar-h) - 4px);
  padding: 0 16px;
  max-width: 1240px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 8px; font-family: var(--font-display); font-weight: 800; font-size: 1.15rem; }
.brand-emoji { font-size: 1.8rem; display: inline-block; animation: wobble 4s ease-in-out infinite; }
@keyframes wobble {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-3px) rotate(-6deg); }
}
.brand-text small { font-weight: 600; color: var(--text-dim); font-size: 0.68em; margin-left: 4px; }
.topbar-spacer { flex: 1; }
.icon-btn {
  background: var(--bg-elevated); border: 2px solid var(--border); border-radius: 14px;
  width: 42px; height: 42px; font-size: 1.1rem; cursor: pointer; color: var(--text);
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--blue-dim); }
.badge {
  position: relative;
  font-family: var(--font-display); font-weight: 800; font-size: 0.95rem;
  border-radius: 999px; padding: 6px 12px; white-space: nowrap;
}
.star-badge { background: var(--yellow-dim); color: var(--yellow-text); }
.streak-badge { background: var(--orange-dim); color: var(--orange-text); }
.badge.pop { animation: badgePop .5s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes badgePop { 0% { transform: scale(1); } 40% { transform: scale(1.3); } 100% { transform: scale(1); } }
.plus-one {
  position: absolute; left: 50%; top: 100%;
  font-size: 0.85rem; font-weight: 800; color: var(--yellow-text); white-space: nowrap; pointer-events: none;
  animation: plusOne 1.1s ease-out forwards;
}
@keyframes plusOne {
  0% { opacity: 0; transform: translate(-50%, -6px) scale(.6); }
  20% { opacity: 1; transform: translate(-50%, 4px) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%, 24px) scale(1); }
}

/* App shell / side nav */
.app-shell { display: flex; max-width: 1240px; margin: 0 auto; align-items: flex-start; }
.side-nav {
  width: var(--nav-w); flex-shrink: 0;
  position: sticky; top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 20px 14px;
}
.lesson-picker-label { font-size: 0.85rem; color: var(--text-dim); margin-bottom: 8px; font-weight: 700; }
.lesson-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 20px; }
.lesson-chip {
  border: 2px solid var(--border); background: var(--bg-elevated); color: var(--text);
  border-radius: 999px; padding: 5px 12px; font-size: 0.88rem; font-weight: 700; cursor: pointer;
}
.lesson-chip:hover { border-color: var(--blue); }
.lesson-chip.active { background: var(--blue); color: var(--on-color); border-color: var(--blue); box-shadow: 0 3px 0 var(--blue-dark); }
.lesson-chips-inline { display: none; }
.nav-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.nav-item {
  width: 100%; display: flex; align-items: center; gap: 10px;
  text-align: left; background: none; border: none; color: var(--text);
  padding: 8px 10px; border-radius: 18px; font-size: 1rem; cursor: pointer;
}
.nav-icon {
  width: 40px; height: 40px; flex-shrink: 0; border-radius: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.25rem; background: var(--c-dim);
}
.nav-label { font-weight: 800; font-family: var(--font-display); }
.nav-sub { font-size: 0.78rem; color: var(--text-dim); font-weight: 600; }
.nav-item:hover { background: var(--c-dim); }
.nav-item.active { background: var(--c); color: var(--on-color); box-shadow: 0 4px 0 var(--c-dark); }
.nav-item.active .nav-icon { background: rgba(255, 255, 255, 0.25); }
.nav-item.active .nav-sub { color: rgba(255, 255, 255, 0.85); }

.main { flex: 1; min-width: 0; padding: 28px 28px 80px; }
.view { display: none; }
.view.active { display: block; animation: floatIn .35s cubic-bezier(.2,.8,.2,1) backwards; }
@keyframes floatIn { from { opacity: 0; transform: translateY(10px);} to { opacity: 1; transform: none; } }
@keyframes revealFade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes popIn { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: none; } }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); } 40% { transform: translateX(7px); }
  60% { transform: translateX(-4px); } 80% { transform: translateX(4px); }
}

h1 { font-size: 1.75rem; font-weight: 800; margin: 0 0 6px; }
h1 small { font-size: 0.55em; color: var(--text-dim); font-weight: 700; margin-left: 4px; }
.subtitle { color: var(--text-dim); margin: 0 0 18px; max-width: 68ch; line-height: 1.65; }
h1 + .stat-row { margin-top: 16px; }
.section-title { font-size: 1.25rem; font-weight: 800; margin: 30px 0 14px; }

/* Home: mascot hero */
.hero { display: flex; align-items: center; gap: 18px; margin-bottom: 20px; }
.mascot { font-size: 4.6rem; line-height: 1; flex-shrink: 0; animation: mascotFloat 3s ease-in-out infinite; }
@keyframes mascotFloat {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-8px) rotate(3deg); }
}
.hero-bubble {
  position: relative; flex: 1;
  background: var(--bg-elevated); border: 3px solid var(--border); border-radius: 26px;
  padding: 16px 20px; box-shadow: var(--shadow);
}
.hero-bubble::before {
  content: ""; position: absolute; left: -14px; top: 50%; transform: translateY(-50%) rotate(45deg);
  width: 22px; height: 22px; background: var(--bg-elevated);
  border-left: 3px solid var(--border); border-bottom: 3px solid var(--border);
}
.hero-bubble h1 { margin: 0 0 4px; }
.hero-bubble p { margin: 0; color: var(--text-dim); }

/* Stat pills */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 8px; }
.stat-pill {
  background: var(--c-dim, var(--bg-elevated)); border-radius: 20px;
  padding: 14px 16px; display: flex; flex-direction: column; gap: 2px;
  animation: popIn .35s cubic-bezier(.3,1.4,.5,1) backwards;
}
.stat-pill .sp-emoji { font-size: 1.5rem; line-height: 1.2; }
.stat-pill .num { font-family: var(--font-display); font-size: 1.75rem; font-weight: 800; color: var(--c-text, var(--blue-text)); line-height: 1.15; }
.stat-pill .num small { font-size: 0.55em; color: var(--text-dim); font-weight: 700; }
.stat-pill .label { font-size: 0.85rem; color: var(--text-dim); font-weight: 600; }

/* Home: game tiles */
.game-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.game-tile {
  background: var(--c); color: var(--on-color); border: none; border-radius: 24px;
  padding: 18px 16px; min-height: 140px; cursor: pointer; text-align: left;
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  box-shadow: 0 6px 0 var(--c-dark);
  animation: popIn .4s cubic-bezier(.3,1.4,.5,1) backwards;
}
.game-tile:nth-child(2) { animation-delay: .04s; }
.game-tile:nth-child(3) { animation-delay: .08s; }
.game-tile:nth-child(4) { animation-delay: .12s; }
.game-tile:nth-child(5) { animation-delay: .16s; }
.game-tile:nth-child(6) { animation-delay: .2s; }
.game-tile:hover { transform: translateY(-3px); box-shadow: 0 9px 0 var(--c-dark); }
.game-tile:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--c-dark); }
.gt-emoji {
  width: 56px; height: 56px; border-radius: 18px; margin-bottom: 6px;
  background: rgba(255, 255, 255, 0.24);
  display: inline-flex; align-items: center; justify-content: center; font-size: 1.9rem;
}
.gt-title { font-family: var(--font-display); font-size: 1.2rem; font-weight: 800; }
.gt-sub { font-size: 0.88rem; opacity: 0.92; }

/* Home: lesson cards */
.lesson-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.lesson-card {
  background: var(--bg-elevated); color: var(--text);
  border: 3px solid var(--c-dim); border-radius: var(--radius);
  padding: 16px 18px; cursor: pointer; text-align: left; font-size: 1rem;
  animation: floatIn .4s cubic-bezier(.2,.8,.2,1) backwards;
}
.lesson-card:hover { border-color: var(--c); transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.lc-badge {
  width: 46px; height: 46px; border-radius: 16px; background: var(--c-dim);
  display: inline-flex; align-items: center; justify-content: center; font-size: 1.5rem; margin-bottom: 8px;
}
.lesson-card h3 { margin: 0 0 6px; font-size: 1.05rem; font-weight: 800; color: var(--c-text); }
.lesson-card p { margin: 0 0 12px; color: var(--text-dim); font-size: 0.88rem; line-height: 1.55; }
.bar-track { height: 12px; border-radius: 999px; background: var(--c-dim, var(--border)); overflow: hidden; }
.bar-fill { height: 100%; min-width: 0; border-radius: 999px; background: var(--c, var(--blue)); transition: width .6s cubic-bezier(.2,.8,.2,1); }
.lesson-card .pct { font-size: 0.82rem; color: var(--text-dim); margin-top: 6px; display: block; font-weight: 600; }

/* Mode tabs */
.mode-tabs { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.mode-tab {
  background: var(--bg-elevated); border: 2px solid var(--border); color: var(--text);
  border-radius: 999px; padding: 9px 18px; font-size: 0.98rem; font-weight: 700; cursor: pointer;
}
.mode-tab:hover { border-color: var(--blue); }
.mode-tab.active { background: var(--blue); border-color: var(--blue); color: var(--on-color); box-shadow: 0 4px 0 var(--blue-dark); }

.practice-area { max-width: 680px; }

/* Flashcard */
.flashcard {
  background: linear-gradient(180deg, var(--blue-dim) 0%, var(--bg-elevated) 55%);
  border: 4px solid var(--blue-dim); border-radius: 30px;
  box-shadow: var(--shadow-lg); padding: 36px 24px; text-align: center; min-height: 260px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  cursor: pointer; user-select: none;
  animation: popIn .35s cubic-bezier(.3,1.3,.5,1) backwards;
}
.flashcard:hover { transform: translateY(-3px); }
.flashcard .word-en { font-family: var(--font-display); font-size: 2.8rem; font-weight: 800; letter-spacing: .02em; color: var(--blue-text); }
.flashcard .word-pos { font-size: 0.8rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.flashcard .word-zh { font-size: 1.5rem; font-weight: 800; color: var(--pink-text); display: none; }
.flashcard .word-example { font-size: 1rem; color: var(--text-dim); margin-top: 8px; display: none; font-style: italic; line-height: 1.6; }
.flashcard.revealed .word-zh, .flashcard.revealed .word-example { display: block; animation: revealFade .3s cubic-bezier(.2,.8,.2,1) backwards; }
.flashcard.revealed .word-example { animation-delay: .05s; }
.mastery-badge { font-size: 0.85rem; font-weight: 800; color: var(--purple-text); background: var(--purple-dim); border-radius: 999px; padding: 4px 12px; display: inline-flex; align-items: center; gap: 6px; }
.mastery-badge.new { color: var(--orange-text); background: var(--orange-dim); }
.mastery-badge.done { color: var(--green-text); background: var(--green-dim); }
.saved-stats { color: var(--green-text); }
.flashcard .flip-hint { font-size: 0.85rem; color: var(--text-dim); margin-top: 6px; }

.card-controls { display: flex; justify-content: center; gap: 12px; margin-top: 20px; flex-wrap: wrap; }
.progress-line { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; color: var(--text-dim); font-size: 0.9rem; font-weight: 700; }

/* Chunky "3D" buttons */
.btn {
  border-radius: 18px; padding: 11px 22px; font-size: 1rem; font-weight: 800; cursor: pointer;
  border: 2px solid transparent; font-family: var(--font-display);
  box-shadow: 0 4px 0 var(--btn-edge, transparent);
}
.btn.primary { background: var(--blue); color: var(--on-color); --btn-edge: var(--blue-dark); }
.btn.success { background: var(--green); color: var(--on-color); --btn-edge: var(--green-dark); }
.btn.ghost { background: var(--bg-elevated); border-color: var(--border); color: var(--text); --btn-edge: var(--border); }
.btn.danger-ghost { background: var(--red-dim); border-color: var(--red-line); color: var(--red-text); --btn-edge: var(--red-line); }
.btn.small { padding: 7px 14px; font-size: 0.88rem; border-radius: 14px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:not(:disabled):hover { transform: translateY(-2px); box-shadow: 0 6px 0 var(--btn-edge, transparent); }
.btn:not(:disabled):active { transform: translateY(4px); box-shadow: 0 0 0 var(--btn-edge, transparent); }
.file-btn { display: inline-flex; align-items: center; }

.audio-btn {
  background: var(--yellow); color: #3b2a00; border: none; border-radius: 50%;
  width: 52px; height: 52px; font-size: 1.35rem; cursor: pointer; flex-shrink: 0;
  box-shadow: 0 4px 0 var(--yellow-dark);
}
.audio-btn:hover { transform: translateY(-2px) scale(1.05); box-shadow: 0 6px 0 var(--yellow-dark); }
.audio-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--yellow-dark); }
.audio-btn.small { width: 38px; height: 38px; font-size: 1rem; box-shadow: 0 3px 0 var(--yellow-dark); }

/* Exercise cards */
.exercise-card {
  background: var(--bg-elevated); border: 3px solid var(--border); border-radius: 26px;
  padding: 22px; box-shadow: var(--shadow); margin-bottom: 16px;
  animation: popIn .35s cubic-bezier(.3,1.3,.5,1) backwards;
}
.exercise-prompt { font-size: 1.15rem; font-weight: 600; line-height: 1.6; margin-bottom: 14px; display: flex; align-items: center; gap: 12px; }
.exercise-input {
  width: 100%; padding: 13px 16px; border-radius: 16px; border: 3px solid var(--border);
  background: var(--bg); color: var(--text); font-size: 1.2rem; margin-bottom: 12px;
}
.exercise-input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 4px var(--blue-dim); }
.exercise-feedback { font-size: 1rem; line-height: 1.65; margin-top: 10px; padding: 12px 16px; border-radius: 18px; display: none; }
.exercise-feedback.show { display: block; animation: revealFade .3s cubic-bezier(.2,.8,.2,1) backwards; }
.exercise-feedback.correct { background: var(--green-dim); color: var(--green-text); }
.exercise-feedback.wrong { background: var(--red-dim); color: var(--red-text); }
.exercise-feedback + .btn, .exercise-feedback + .card-controls { margin-top: 14px; }
.diff-ok { color: var(--green-text); font-weight: 700; }
.diff-bad { color: var(--red-text); font-weight: 700; text-decoration: underline; }

/* Spelling challenge */
.spell-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.spell-stars { font-size: 1.3rem; letter-spacing: 2px; line-height: 1; white-space: nowrap; }
.stars-on { color: var(--yellow); text-shadow: 0 2px 0 var(--yellow-dark); }
.stars-off { color: var(--border); }
.spell-stage { font-size: 0.85rem; font-weight: 800; color: var(--purple-text); background: var(--purple-dim); padding: 4px 12px; border-radius: 999px; }
.spell-meaning { margin: 0 0 12px; font-size: 1.1rem; font-weight: 700; color: var(--pink-text); }
.spell-board { container-type: inline-size; margin: 4px 0 18px; }
.spell-word {
  --gap: 6px;
  --tile: 44px;
  --tile: max(28px, min(54px, calc((100cqw - (var(--n) - 1) * var(--gap)) / var(--n))));
  display: flex; flex-wrap: wrap; gap: 12px calc(var(--tile) * 0.55);
}
.spell-chunk { display: inline-flex; flex-wrap: wrap; gap: var(--gap); }
.letter-tile, .letter-box {
  width: var(--tile); height: calc(var(--tile) * 1.22); min-width: 0;
  border-radius: calc(var(--tile) * 0.28);
  font-family: var(--font-display); font-weight: 800;
  font-size: max(16px, calc(var(--tile) * 0.62));
  display: inline-flex; align-items: center; justify-content: center;
  text-align: center; padding: 0; margin: 0;
}
.letter-tile { background: var(--blue-dim); color: var(--blue-text); }
.letter-tile.sym { background: transparent; color: var(--text-dim); width: auto; min-width: calc(var(--tile) * 0.45); }
.letter-box {
  -webkit-appearance: none; appearance: none;
  background: var(--bg-elevated); color: var(--text);
  border: 3px dashed var(--orange); caret-color: var(--orange);
}
.letter-box:focus { outline: none; border-style: solid; box-shadow: 0 0 0 4px var(--orange-dim); transform: translateY(-2px); }
.letter-box.filled { border-style: solid; border-color: var(--purple); color: var(--purple-text); }
.letter-box.ok { border-style: solid; border-color: var(--green); background: var(--green-dim); color: var(--green-text); }
.letter-box.bad { border-style: solid; border-color: var(--red); background: var(--red-dim); color: var(--red-text); }
.spell-board.win .spell-word { animation: hop .55s cubic-bezier(.3,1.6,.5,1); }
.spell-board.miss .spell-word, .nudge { animation: shake .4s ease; }
@keyframes hop { 0% { transform: translateY(0); } 40% { transform: translateY(-12px) scale(1.04); } 100% { transform: none; } }
.hint.spell-rule { margin: 20px 0 0; }

/* Mistake book */
.nav-icon { position: relative; }
.nav-badge {
  position: absolute; top: -6px; right: -8px;
  min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px;
  background: var(--red); color: var(--on-color); font-size: 0.7rem; font-weight: 800; line-height: 20px; text-align: center;
  box-shadow: 0 0 0 2px var(--bg-elevated);
}
.nav-badge[hidden] { display: none; }
.mistake-banner {
  width: 100%; margin-top: 16px; display: flex; align-items: center; gap: 14px;
  background: var(--red-dim); color: var(--text); border: 3px solid var(--red-line); border-radius: 22px;
  padding: 14px 18px; cursor: pointer; text-align: left; font-size: 1rem;
  box-shadow: 0 4px 0 var(--red-line);
}
.mistake-banner:hover { transform: translateY(-2px); box-shadow: 0 6px 0 var(--red-line); }
.mistake-banner:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--red-line); }
.mb-emoji { font-size: 2rem; }
.mb-text { flex: 1; display: flex; flex-direction: column; }
.mb-text b { font-family: var(--font-display); color: var(--red-text); font-size: 1.1rem; }
.mb-text small { color: var(--text-dim); font-size: 0.88rem; }
.mb-go { font-family: var(--font-display); font-weight: 800; color: var(--on-color); background: var(--red); border-radius: 999px; padding: 8px 16px; white-space: nowrap; }
.mistake-tag { font-weight: 800; color: var(--c-text); background: var(--c-dim); border-radius: 999px; padding: 3px 12px; }
.streak-dots { display: inline-flex; gap: 4px; vertical-align: middle; margin-right: 4px; }
.streak-dots i { width: 11px; height: 11px; border-radius: 50%; background: var(--border); display: inline-block; }
.streak-dots i.on { background: var(--green); }
.mistake-note { margin-top: 10px; font-weight: 700; }
.mistake-note.flash { margin: 0 0 12px; padding: 10px 14px; border-radius: 16px; background: var(--yellow-dim); color: var(--text); animation: revealFade .3s cubic-bezier(.2,.8,.2,1) backwards; }
.mistake-list { display: flex; flex-direction: column; gap: 8px; }
.mistake-row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  background: var(--bg-elevated); color: var(--text); border: 3px solid var(--c-dim); border-radius: 18px;
  padding: 10px 14px; cursor: pointer; text-align: left; font-size: 0.95rem; line-height: 1.5;
}
.mistake-row:hover { border-color: var(--c); }
.mr-tag { font-size: 0.78rem; font-weight: 800; color: var(--c-text); background: var(--c-dim); padding: 2px 10px; border-radius: 999px; white-space: nowrap; }
.mr-text { flex: 1; min-width: 0; }
.mr-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; white-space: nowrap; }
.mr-meta small { color: var(--text-dim); font-size: 0.78rem; }
.empty-state { text-align: center; padding: 36px 20px; background: var(--bg-elevated); border: 3px dashed var(--border); border-radius: 24px; color: var(--text-dim); font-size: 1.05rem; }
.es-emoji { font-size: 3rem; margin-bottom: 6px; }

/* Basic 850: scene picker, animated scenes, word cards, quizzes */
body[data-view="basic850"] .lesson-chips-inline, body[data-view="progress"] .lesson-chips-inline { display: none; }
.b850-area { max-width: 760px; }
.scene-chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 10px; margin-bottom: 8px; scrollbar-width: thin; }
.scene-chip {
  flex-shrink: 0; border: 2px solid var(--border); background: var(--bg-elevated); color: var(--text);
  border-radius: 999px; padding: 6px 12px; font-size: 0.9rem; font-weight: 700; cursor: pointer; white-space: nowrap;
}
.scene-chip small { color: var(--text-dim); font-weight: 700; }
.scene-chip:hover { border-color: var(--teal); }
.scene-chip.active { background: var(--teal); border-color: var(--teal); color: var(--on-color); box-shadow: 0 3px 0 var(--teal-dark); }
.scene-chip.active small { color: rgba(255,255,255,.85); }

.scene-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.scene-tile {
  background: var(--bg-elevated); border: 3px solid var(--border); border-radius: 22px; padding: 0; overflow: hidden;
  cursor: pointer; text-align: left; color: var(--text); font-size: 1rem; animation: popIn .4s cubic-bezier(.3,1.4,.5,1) backwards;
}
.scene-tile:hover { border-color: var(--teal); transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.scene-thumb { line-height: 0; }
.scene-tile-body { padding: 10px 14px 14px; display: flex; flex-direction: column; gap: 4px; }
.scene-tile-body b { font-family: var(--font-display); font-size: 1.05rem; }
.scene-tile-body small { color: var(--text-dim); }
.scene-tile-body .bar-track { --c: var(--teal); --c-dim: var(--teal-dim); height: 8px; margin-top: 4px; }
.scene-tile-body .dim { font-size: 0.82rem; font-weight: 700; }

.scene-card { background: var(--bg-elevated); border: 3px solid var(--border); border-radius: 26px; padding: 18px; box-shadow: var(--shadow); }
.scene-head h2 { margin: 0 0 4px; font-size: 1.35rem; }
.scene-head h2 small { font-size: 0.65em; color: var(--text-dim); margin-left: 6px; }
.scene-head p { margin: 0 0 12px; color: var(--text-dim); line-height: 1.6; }
.scene-art { border-radius: 20px; overflow: hidden; line-height: 0; border: 3px solid var(--teal-dim); }
.scene-svg { width: 100%; height: auto; display: block; }
.scene-tip { margin: 10px 0 6px; }

/* Actors */
.scene-svg .actor .anim-bob, .scene-svg [class^="anim-"], .scene-svg [class*=" anim-"], .scene-svg .actor-pop { transform-box: fill-box; transform-origin: center; }
.scene-svg .actor.has-word { cursor: pointer; }
.scene-svg.quiz .actor, .scene-svg.thumb .actor { cursor: default; }
.scene-svg .hit { fill: transparent; }
.scene-svg .focus-ring { fill: rgba(255, 216, 77, 0.28); stroke: #FFB703; stroke-width: 4; stroke-dasharray: 8 6; opacity: 0; }
.scene-svg .focus-label { display: none; pointer-events: none; }
.scene-svg .focus-label rect { fill: #2D2B55; }
.scene-svg .focus-label text { fill: #fff; font: 800 15px ui-rounded, "Arial Rounded MT Bold", sans-serif; }
.scene-svg .actor.focus .focus-ring { opacity: 1; animation: ringSpin 6s linear infinite; transform-box: fill-box; transform-origin: center; }
.scene-svg .actor.focus .focus-label { display: block; animation: popIn .3s cubic-bezier(.3,1.5,.5,1) backwards; }
.scene-svg .actor.focus.no-label .focus-label { display: none; }
.scene-svg .actor.focus .actor-pop { animation: focusPop .9s cubic-bezier(.3,1.6,.5,1) infinite alternate; }
.scene-svg .actor.has-word:hover .actor-pop, .scene-svg .actor.has-word:focus-visible .actor-pop { transform: scale(1.12); }
.scene-svg .actor:focus { outline: none; }
@keyframes ringSpin { to { transform: rotate(360deg); } }
@keyframes focusPop { from { transform: scale(1.08); } to { transform: scale(1.28); } }

.anim-bob { animation: aBob 2.4s ease-in-out infinite; }
.anim-float { animation: aFloat 3s ease-in-out infinite; }
.anim-sway { animation: aSway 2.6s ease-in-out infinite; }
.anim-spin { animation: aSpin 12s linear infinite; }
.anim-glow { animation: aGlow 2s ease-in-out infinite; }
.anim-shake { animation: aShake 1.6s ease-in-out infinite; }
.anim-bounce { animation: aBounce 1.4s cubic-bezier(.3,1.6,.5,1) infinite; }
.anim-drip { animation: aDrip 1.4s ease-in infinite; }
.anim-steam { animation: aBob 1.6s ease-in-out infinite; }
.anim-wobble { animation: aWobble 2s ease-in-out infinite; }
.anim-walk { animation: aWalk 4s ease-in-out infinite; }
.anim-run { animation: aRun 2.2s ease-in-out infinite; }
.anim-fly { animation: aFly 6s ease-in-out infinite; }
.anim-jump { animation: aJump 1.2s cubic-bezier(.3,1.4,.5,1) infinite; }
.anim-kick { animation: aKick 1.6s ease-in-out infinite; }
.anim-roll { animation: aRoll 1.6s ease-in-out infinite; }
.anim-wave { animation: aWave 1.2s ease-in-out infinite; }
.anim-blink { animation: aBlink 3.5s ease-in-out infinite; }
.anim-trot { animation: aTrot 1s ease-in-out infinite; }
.anim-peck { animation: aPeck 1.4s ease-in-out infinite; }
.anim-drive { animation: aDrive 5s ease-in-out infinite; }
.anim-drift { animation: aDrift 9s ease-in-out infinite; }
.anim-blow { animation: aBlow 1.8s ease-in-out infinite; }
.anim-shiver { animation: aShiver .25s linear infinite; }
.anim-fall { animation: aFall .9s linear infinite; }
.anim-snowfall { animation: aSnow 2.4s linear infinite; }
@keyframes aBob { 50% { transform: translateY(-4px); } }
@keyframes aFloat { 50% { transform: translate(4px, -9px); } }
@keyframes aSway { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg); } }
@keyframes aSpin { to { transform: rotate(360deg); } }
@keyframes aGlow { 50% { transform: scale(1.12); filter: drop-shadow(0 0 8px #FFE066); } }
@keyframes aShake { 0%, 60%, 100% { transform: rotate(0); } 65%, 75%, 85% { transform: rotate(-14deg); } 70%, 80%, 90% { transform: rotate(14deg); } }
@keyframes aBounce { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-9px); } }
@keyframes aDrip { 0% { transform: translateY(-6px); opacity: 0; } 30% { opacity: 1; } 100% { transform: translateY(14px); opacity: 0; } }
@keyframes aWobble { 0%, 100% { transform: rotate(-5deg); } 50% { transform: rotate(5deg) translateY(-2px); } }
@keyframes aWalk { 0%, 100% { transform: translateX(-10px); } 50% { transform: translateX(12px); } }
@keyframes aRun { 0%, 100% { transform: translateX(-22px); } 50% { transform: translateX(22px); } }
@keyframes aFly { 0%, 100% { transform: translate(0, 0); } 25% { transform: translate(40px, -12px); } 50% { transform: translate(90px, 4px); } 75% { transform: translate(40px, 10px); } }
@keyframes aJump { 0%, 100% { transform: translateY(0) scaleY(1); } 15% { transform: translateY(2px) scaleY(.88); } 50% { transform: translateY(-26px) scaleY(1.05); } }
@keyframes aKick { 0%, 100% { transform: rotate(0); } 40% { transform: rotate(-35deg); } }
@keyframes aRoll { 0%, 100% { transform: translateX(0) rotate(0); } 50% { transform: translateX(26px) rotate(240deg); } }
@keyframes aWave { 0%, 100% { transform: rotate(-16deg); } 50% { transform: rotate(16deg); } }
@keyframes aBlink { 0%, 46%, 54%, 100% { transform: scaleY(1); } 50% { transform: scaleY(.15); } }
@keyframes aTrot { 50% { transform: translateY(-5px) rotate(-3deg); } }
@keyframes aPeck { 0%, 60%, 100% { transform: rotate(0); } 75% { transform: rotate(28deg); } }
@keyframes aDrive { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(-30px); } }
@keyframes aDrift { 0%, 100% { transform: translateX(-14px); } 50% { transform: translateX(16px); } }
@keyframes aBlow { 0%, 100% { transform: translateX(0) scaleX(1); } 50% { transform: translateX(10px) scaleX(1.12); } }
@keyframes aShiver { 0% { transform: translateX(-1.5px); } 50% { transform: translateX(1.5px); } 100% { transform: translateX(-1.5px); } }
@keyframes aFall { from { transform: translateY(0); opacity: 1; } to { transform: translateY(60px); opacity: 0; } }
@keyframes aSnow { from { transform: translate(0, 0); opacity: 1; } to { transform: translate(-10px, 90px); opacity: 0; } }

/* Word chips + detail card */
.word-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.word-chip {
  border: 2px solid var(--border); background: var(--bg); color: var(--text); border-radius: 14px;
  padding: 6px 12px; font-size: 1rem; font-weight: 800; font-family: var(--font-display); cursor: pointer;
}
.word-chip.seen { border-color: var(--teal-dim); background: var(--teal-dim); }
.word-chip.done { border-color: var(--green); background: var(--green-dim); color: var(--green-text); }
.word-chip.active { border-color: var(--teal); background: var(--teal); color: var(--on-color); box-shadow: 0 3px 0 var(--teal-dark); }
.word-detail { display: flex; gap: 16px; align-items: center; background: var(--teal-dim); border-radius: 20px; padding: 14px 16px; animation: revealFade .3s cubic-bezier(.2,.8,.2,1) backwards; }
.wd-pic { flex-shrink: 0; width: 112px; height: 112px; display: flex; align-items: center; justify-content: center; background: var(--bg-elevated); border-radius: 22px; }
.word-pic-emoji { line-height: 1; }
.wd-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.wd-word { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-size: 2rem; font-weight: 800; color: var(--teal-text); line-height: 1.1; }
.wd-zh { font-size: 1.15rem; font-weight: 800; }
.wd-ex { display: flex; gap: 8px; align-items: flex-start; line-height: 1.5; }
.wd-ex mark { background: #FFE58A; color: inherit; border-radius: 4px; padding: 0 2px; }
.wd-note { font-size: 0.9rem; }

/* Quizzes */
.quiz-title { font-weight: 800; font-size: 1.1rem; margin-bottom: 10px; }
.quiz-art { margin-bottom: 12px; }
.quiz-prompt:empty { display: none; }
.quiz-prompt { text-align: center; margin-bottom: 12px; }
.quiz-big-pic { display: flex; justify-content: center; line-height: 1; margin-bottom: 6px; }
.quiz-zh { font-size: 1.6rem; font-weight: 800; color: var(--pink-text); }
.quiz-en { font-family: var(--font-display); font-size: 2.2rem; font-weight: 800; color: var(--teal-text); display: inline-flex; align-items: center; gap: 10px; }
.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice-btn {
  border: 3px solid var(--border); background: var(--bg-elevated); color: var(--text); border-radius: 18px;
  padding: 14px 10px; font-size: 1.2rem; font-weight: 800; font-family: var(--font-display); cursor: pointer;
  box-shadow: 0 4px 0 var(--border);
}
.choice-btn:not(:disabled):hover { border-color: var(--teal); transform: translateY(-2px); }
.choice-btn:not(:disabled):active { transform: translateY(3px); box-shadow: 0 1px 0 var(--border); }
.choice-btn.right { border-color: var(--green); background: var(--green-dim); color: var(--green-text); box-shadow: 0 4px 0 var(--green); }
.choice-btn.wrong { border-color: var(--red); background: var(--red-dim); color: var(--red-text); box-shadow: 0 4px 0 var(--red-line); animation: shake .4s ease; }
.choice-btn:disabled { cursor: default; }
.b850-spell-pic { display: flex; justify-content: center; line-height: 1; margin: 4px 0 10px; }

/* Home feature card */
.feature-card {
  width: 100%; margin-top: 18px; display: flex; align-items: center; gap: 16px;
  background: linear-gradient(120deg, var(--teal) 0%, #13A3B8 60%, #36C1A5 100%); color: var(--on-color);
  border: none; border-radius: 24px; padding: 18px 20px; cursor: pointer; text-align: left; font-size: 1rem;
  box-shadow: 0 6px 0 var(--teal-dark);
}
.feature-card:hover { transform: translateY(-3px); box-shadow: 0 9px 0 var(--teal-dark); }
.feature-card:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--teal-dark); }
.fc-art { font-size: 2.2rem; letter-spacing: -4px; flex-shrink: 0; }
.fc-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.fc-text b { font-family: var(--font-display); font-size: 1.25rem; }
.fc-text small { opacity: .92; }
.fc-stat { font-size: 0.85rem; font-weight: 800; opacity: .95; }
.fc-go { font-family: var(--font-display); font-weight: 800; background: rgba(255,255,255,.22); border-radius: 999px; padding: 8px 16px; white-space: nowrap; }

/* Dialogue */
.dialogue-card { background: var(--bg-elevated); border: 3px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; box-shadow: var(--shadow); animation: floatIn .4s cubic-bezier(.2,.8,.2,1) backwards; }
.dialogue-card h3 { margin: 0 0 4px; font-weight: 800; color: var(--teal-text); }
.dialogue-card .zh-title { color: var(--text-dim); font-size: 0.9rem; margin: 0 0 14px; }
.dlg-line { display: flex; gap: 10px; align-items: center; padding: 10px 8px; border-top: 2px dashed var(--border); line-height: 1.6; transition: background-color .15s ease; }
.dlg-line:first-of-type { border-top: none; }
.dlg-line:hover { background-color: var(--teal-dim); border-radius: 14px; }
.dlg-speaker { font-weight: 800; min-width: 76px; color: var(--purple-text); font-size: 0.9rem; }
.dlg-text { flex: 1; }

.question-card { background: var(--bg-elevated); border: 3px solid var(--border); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 12px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 12px; animation: floatIn .35s cubic-bezier(.2,.8,.2,1) backwards; }
.question-card .q-text { flex: 1; line-height: 1.6; font-weight: 600; }
.question-card .exercise-input { font-size: 1rem; font-weight: 400; margin-bottom: 0; }

/* Progress page */
.progress-lessons { display: flex; flex-direction: column; gap: 10px; max-width: 680px; }
.progress-lesson-row { display: flex; align-items: center; gap: 12px; background: var(--bg-elevated); border: 3px solid var(--c-dim, var(--border)); border-radius: 18px; padding: 12px 16px; }
.progress-lesson-row .name { min-width: 170px; font-weight: 800; font-size: 0.95rem; }
.progress-lesson-row .bar-track { flex: 1; }
.progress-lesson-row .pct { font-size: 0.9rem; color: var(--c-text); font-weight: 800; min-width: 48px; text-align: right; }
.settings-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20, 16, 50, 0.45); display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 16px;
  animation: backdropFade .2s ease both;
}
.modal-backdrop[hidden] { display: none; }
@keyframes backdropFade { from { opacity: 0; } to { opacity: 1; } }
.modal { background: var(--bg-elevated); border-radius: 26px; width: 100%; max-width: 480px; max-height: 88vh; overflow-y: auto; box-shadow: var(--shadow-lg); animation: popIn .25s cubic-bezier(.3,1.3,.5,1) backwards; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 2px solid var(--border); }
.modal-header h2 { margin: 0; font-size: 1.15rem; font-weight: 800; }
.modal-body { padding: 18px 20px; }
.settings-section { margin-bottom: 24px; }
.settings-section h3 { margin: 0 0 6px; font-size: 1.05rem; }
.hint { color: var(--text-dim); font-size: 0.88rem; line-height: 1.55; margin: 0 0 10px; }
.field-label { display: block; font-size: 0.88rem; font-weight: 700; margin: 12px 0 4px; }
.modal-body select {
  width: 100%; padding: 10px 12px; border-radius: 12px; border: 2px solid var(--border); background: var(--bg); color: var(--text);
  margin-bottom: 4px; font-size: 0.95rem;
}
.modal-body select:focus { outline: 2px solid var(--blue); outline-offset: 1px; }
.modal-body input[type="range"] { width: 100%; accent-color: var(--blue); margin-bottom: 12px; }
.settings-row { margin-top: 14px; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 12px 22px; border-radius: 999px;
  font-size: 0.95rem; font-weight: 700; z-index: 200; box-shadow: var(--shadow-lg);
  max-width: calc(100vw - 32px); text-align: center;
  animation: toastIn .3s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* Celebration particles (see js/fx.js) */
.confetti {
  position: fixed; z-index: 300; pointer-events: none; font-size: 1.4rem; line-height: 1;
  transform: translate(-50%, -50%);
  animation: confettiFly .95s cubic-bezier(.2,.7,.3,1) forwards;
}
@keyframes confettiFly {
  0% { transform: translate(-50%, -50%) scale(.4); opacity: 1; }
  70% { opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) rotate(var(--rot)) scale(1); opacity: 0; }
}

/* Phones & tablets in portrait: the side nav becomes a bottom tab bar */
@media (max-width: 860px) {
  .side-nav {
    position: fixed; top: auto; left: 0; right: 0; bottom: 0; z-index: 40;
    width: auto; height: auto; overflow: visible;
    background: var(--bg-elevated);
    border-top: 2px solid var(--border);
    box-shadow: 0 -6px 20px rgba(40, 30, 10, 0.07);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  }
  .lesson-picker { display: none; }
  .nav-list { flex-direction: row; gap: 2px; }
  .nav-list li { flex: 1; min-width: 0; }
  .nav-item { flex-direction: column; justify-content: center; gap: 2px; padding: 6px 2px; border-radius: 16px; text-align: center; }
  .nav-icon { width: 38px; height: 30px; border-radius: 12px; font-size: 1.15rem; background: none; }
  .nav-label { font-size: 0.75rem; }
  .nav-sub { display: none; }
  .nav-item:hover { background: none; }
  .nav-item.active { background: var(--c-dim); color: var(--c-text); box-shadow: none; }
  .nav-item.active .nav-icon { background: var(--c); }

  .lesson-chips-inline {
    display: flex; flex-wrap: nowrap; overflow-x: auto; gap: 6px;
    margin: 0 -14px 16px; padding: 2px 14px 6px;
    scrollbar-width: none;
  }
  .lesson-chips-inline::-webkit-scrollbar { display: none; }
  .lesson-chips-inline .lesson-chip { flex-shrink: 0; }

  .main { padding: 16px 14px calc(100px + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(96px + env(safe-area-inset-bottom)); }
  h1 { font-size: 1.45rem; }
  .flashcard .word-en { font-size: 2.2rem; }
  .exercise-card { padding: 18px 16px; }
}

@media (max-width: 520px) {
  body { font-size: 16px; }
  .brand-text small { display: none; }
  .brand-text { font-size: 1rem; }
  .badge { padding: 5px 9px; font-size: 0.85rem; }
  .hero { gap: 10px; }
  .mascot { font-size: 3.2rem; }
  .hero-bubble { padding: 12px 14px; }
  .hero-bubble h1 { font-size: 1.2rem; }
  .hero-bubble p { font-size: 0.9rem; }
  .stat-row { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .game-tiles { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .game-tile { min-height: 124px; padding: 14px; }
  .gt-emoji { width: 48px; height: 48px; font-size: 1.6rem; }
  .gt-title { font-size: 1.05rem; }
  .gt-sub { font-size: 0.8rem; }
  .progress-lesson-row { flex-wrap: wrap; }
  .progress-lesson-row .name { min-width: 0; width: 100%; }
  .card-controls .btn { flex: 1 1 auto; }
  .spell-word { --gap: 4px; }
  .mistake-row { flex-wrap: wrap; }
  .mr-text { flex-basis: 100%; order: 3; }
  .mr-meta { margin-left: auto; flex-direction: row; align-items: center; gap: 8px; }
  .mb-go { display: none; }
  .scene-card { padding: 12px; border-radius: 22px; }
  .word-detail { flex-direction: column; align-items: stretch; text-align: left; }
  .wd-pic { width: 100%; height: 96px; }
  .wd-word { font-size: 1.7rem; }
  .scene-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .scene-tile-body { padding: 8px 10px 10px; }
  .scene-tile-body small { display: none; }
  .choice-btn { font-size: 1.05rem; padding: 12px 6px; }
  .fc-go { display: none; }
  .fc-art { font-size: 1.7rem; }
  .mode-tabs { flex-wrap: nowrap; gap: 6px; }
  .mode-tab { flex: 1 1 0; min-width: 0; padding: 8px 4px; font-size: 0.88rem; white-space: nowrap; }
}
