:root {
  --bg: #ffffff;
  --bg2: #f7f9fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --green: #58cc02;
  --green-d: #46a302;
  --blue: #1cb0f6;
  --blue-d: #1899d6;
  --yellow: #ffc800;
  --yellow-d: #e5a900;
  --red: #ff4b4b;
  --red-d: #d93838;
  --purple: #ce82ff;
  --orange: #ff9600;
  --radius: 16px;
  --nav-h: 64px;
  --side-w: 84px;
  --top-h: 56px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131f24;
    --bg2: #1a2a32;
    --card: #1f313a;
    --text: #f3f4f6;
    --muted: #9ca3af;
    --border: #2c404a;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; height: 100%; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px; line-height: 1.45; overscroll-behavior: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
button:disabled { opacity: .45; cursor: not-allowed; }
.hidden { display: none !important; }
.center { text-align: center; }
.hint { color: var(--muted); font-size: .9rem; }
.ipa { font-family: "Lucida Sans Unicode", "Segoe UI", sans-serif; color: var(--blue-d); font-size: .95rem; }

/* Kids mode: bigger touch targets, friendlier font */
body.age-kids { font-size: 17px; }
body.age-kids .opt, body.age-kids .tile, body.age-kids .pair { min-height: 54px; font-size: 1.12rem; }
body.age-kids .btn-primary { min-height: 54px; font-size: 1.1rem; }
body.age-kids .node-btn { width: 78px; height: 78px; font-size: 1.9rem; }

/* Shell */
.shell { min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; height: calc(var(--top-h) + var(--safe-t));
  padding: var(--safe-t) calc(12px + var(--safe-r)) 0 calc(12px + var(--safe-l));
  background: var(--bg); border-bottom: 2px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.05rem; color: var(--green-d); }
.brand-dot { width: 32px; height: 32px; border-radius: 10px; background: var(--green); color: #fff; display: grid; place-items: center; font-size: 1.1rem; }
.stats-bar { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: .95rem; }
.stat-pill { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px; background: var(--bg2); }
.stat-pill.streak { color: var(--orange); }
.stat-pill.xp { color: var(--blue-d); }
.stat-pill.hearts { color: var(--red); }

.main {
  flex: 1; padding: 14px calc(14px + var(--safe-r)) calc(var(--nav-h) + var(--safe-b) + 18px) calc(14px + var(--safe-l));
  max-width: 720px; width: 100%; margin: 0 auto;
}

/* Bottom nav (portrait mobile) */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: var(--bg); border-top: 2px solid var(--border);
  display: flex; align-items: center; justify-content: space-around;
}
.nav-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; min-width: 64px; min-height: 48px; padding: 6px 10px; border-radius: 12px;
  color: var(--muted); font-weight: 700; font-size: .75rem;
}
.nav-btn .ico { font-size: 1.35rem; line-height: 1; }
.nav-btn.active { color: var(--blue-d); background: color-mix(in srgb, var(--blue) 12%, transparent); }

/* Banners */
.banner {
  padding: 12px 14px; border-radius: 14px; margin-bottom: 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  font-size: .92rem; font-weight: 600;
}
.banner.warn { background: #fff7ed; color: #9a3412; border: 2px solid #fed7aa; }
.banner.danger { background: #fef2f2; color: #991b1b; border: 2px solid #fecaca; }
.banner.info { background: #eff6ff; color: #1e40af; border: 2px solid #bfdbfe; }
@media (prefers-color-scheme: dark) {
  .banner.warn { background: #3b2410; color: #fed7aa; border-color: #7c2d12; }
  .banner.danger { background: #3b1313; color: #fecaca; border-color: #7f1d1d; }
  .banner.info { background: #13253b; color: #bfdbfe; border-color: #1e3a8a; }
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 46px; padding: 10px 18px; border-radius: 14px; font-weight: 800;
  transition: transform .08s, filter .15s;
}
.btn:active:not(:disabled) { transform: translateY(2px); }
.btn-primary { background: var(--green); color: #fff; box-shadow: 0 4px 0 var(--green-d); }
.btn-primary:active:not(:disabled) { box-shadow: 0 1px 0 var(--green-d); }
.btn-blue { background: var(--blue); color: #fff; box-shadow: 0 4px 0 var(--blue-d); }
.btn-danger { background: var(--red); color: #fff; box-shadow: 0 4px 0 var(--red-d); }
.btn-ghost { background: var(--bg2); color: var(--text); border: 2px solid var(--border); }
.btn-sm { min-height: 38px; padding: 6px 12px; font-size: .88rem; border-radius: 10px; }
.link { color: var(--blue-d); font-weight: 700; padding: 8px; text-decoration: underline; }

/* Cards & Home Map */
.card { background: var(--card); border: 2px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.hero-row { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.hero-row h2 { margin: 0 0 4px; font-size: 1.2rem; }
.modules-grid { display: flex; flex-direction: column; gap: 18px; }
.mod-head {
  padding: 14px 16px; border-radius: var(--radius); color: #fff;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  box-shadow: 0 4px 0 rgba(0,0,0,.15);
}
.mod-head h3 { margin: 0 0 2px; font-size: 1.1rem; }
.mod-head p { margin: 0; opacity: .92; font-size: .88rem; }
.mod-badge { background: rgba(255,255,255,.22); padding: 4px 10px; border-radius: 999px; font-size: .78rem; font-weight: 800; white-space: nowrap; }

.path { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 18px 0 8px; }
.node { display: flex; flex-direction: column; align-items: center; gap: 6px; transition: transform .15s; }
.node-btn {
  position: relative; width: 70px; height: 70px; border-radius: 50%;
  display: grid; place-items: center; font-size: 1.7rem; color: #fff;
  background: var(--green); box-shadow: 0 6px 0 var(--green-d);
}
.node-btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 3px 0 var(--green-d); }
.node.done .node-btn { background: var(--yellow); box-shadow: 0 6px 0 var(--yellow-d); color: #5c3d00; }
.node.locked .node-btn { background: #cbd5e1; box-shadow: 0 6px 0 #94a3b8; color: #64748b; }
@media (prefers-color-scheme: dark) { .node.locked .node-btn { background: #334155; box-shadow: 0 6px 0 #1e293b; color: #94a3b8; } }
.node-crowns { position: absolute; top: -8px; right: -8px; background: #fff; color: #d97706; border: 2px solid var(--yellow); border-radius: 999px; font-size: .72rem; font-weight: 800; padding: 1px 6px; }
.node-title { font-weight: 700; font-size: .9rem; text-align: center; max-width: 150px; }
.node-sub { font-size: .76rem; color: var(--muted); }

/* Lesson Runner */
.lesson-wrap { position: fixed; inset: 0; z-index: 40; background: var(--bg); display: flex; flex-direction: column; }
.lesson-top {
  display: flex; align-items: center; gap: 12px;
  padding: calc(10px + var(--safe-t)) calc(14px + var(--safe-r)) 10px calc(14px + var(--safe-l));
  border-bottom: 2px solid var(--border);
}
.btn-x { width: 42px; height: 42px; border-radius: 12px; font-size: 1.3rem; color: var(--muted); display: grid; place-items: center; }
.btn-x:hover { background: var(--bg2); }
.prog { flex: 1; height: 14px; background: var(--bg2); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.prog-fill { height: 100%; background: var(--green); border-radius: 999px; transition: width .35s ease; }

.lesson-body {
  flex: 1; overflow-y: auto; padding: 16px calc(16px + var(--safe-r)) 20px calc(16px + var(--safe-l));
  max-width: 760px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; justify-content: center;
}
.lesson-foot {
  padding: 12px calc(16px + var(--safe-r)) calc(12px + var(--safe-b)) calc(16px + var(--safe-l));
  border-top: 2px solid var(--border); background: var(--bg);
}
.lesson-foot.ok { background: #e8fad4; border-color: var(--green); }
.lesson-foot.bad { background: #ffe4e4; border-color: var(--red); }
@media (prefers-color-scheme: dark) {
  .lesson-foot.ok { background: #1a3312; }
  .lesson-foot.bad { background: #3b1616; }
}
.foot-inner { max-width: 760px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.fb-msg { font-weight: 800; font-size: 1rem; }
.fb-msg.ok { color: var(--green-d); }
.fb-msg.bad { color: var(--red-d); }
.fb-ans { font-size: .9rem; color: var(--text); font-weight: 600; margin-top: 2px; }

/* Exercises */
.ex { display: flex; flex-direction: column; gap: 14px; align-items: stretch; }
.ex-left, .ex-right { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.ex-title { margin: 0; font-size: 1.15rem; font-weight: 800; text-align: center; }
.ex-question { font-size: 1.25rem; font-weight: 800; text-align: center; padding: 12px; background: var(--bg2); border-radius: 14px; }
.ex-sentence { font-size: 1.25rem; font-weight: 700; text-align: center; padding: 14px; background: var(--bg2); border-radius: 14px; }
.blank { display: inline-block; min-width: 70px; border-bottom: 3px solid var(--blue); padding: 0 8px; color: var(--blue-d); font-weight: 800; }
.blank.right { color: var(--green-d); border-color: var(--green); }
.blank.wrong { color: var(--red); border-color: var(--red); }
.ex-emoji { font-size: 3.4rem; text-align: center; line-height: 1.1; }
.ex-img { max-width: 180px; max-height: 140px; border-radius: 14px; object-fit: contain; margin: 0 auto; }
.tip-box { background: #fffbeb; color: #92400e; border: 2px solid #fde68a; border-radius: 12px; padding: 8px 12px; font-size: .88rem; width: 100%; }
@media (prefers-color-scheme: dark) { .tip-box { background: #33270d; color: #fde68a; border-color: #78350f; } }

/* Flashcard 3D */
.flash { width: min(320px, 90vw); height: 210px; perspective: 900px; cursor: pointer; margin: 0 auto; }
.flash-inner { position: relative; width: 100%; height: 100%; transition: transform .55s; transform-style: preserve-3d; }
.flash.flipped .flash-inner { transform: rotateY(180deg); }
.flash-front, .flash-back {
  position: absolute; inset: 0; backface-visibility: hidden;
  border: 2px solid var(--border); border-radius: 20px; background: var(--card);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 16px;
  box-shadow: 0 6px 0 var(--border); text-align: center;
}
.flash-back { transform: rotateY(180deg); background: var(--bg2); }
.flash-word { font-size: 1.8rem; font-weight: 900; }
.flash-vi { font-size: 1.45rem; font-weight: 800; color: var(--green-d); }
.flash-ex { font-size: 1rem; font-style: italic; }

/* Speakers */
.speakers { display: flex; align-items: center; justify-content: center; gap: 12px; }
.btn-speaker {
  width: 56px; height: 56px; border-radius: 16px; background: var(--blue); color: #fff;
  font-size: 1.5rem; box-shadow: 0 4px 0 var(--blue-d); display: grid; place-items: center;
}
.btn-speaker.big { width: 78px; height: 78px; font-size: 2.1rem; border-radius: 22px; }
.btn-speaker.slow { width: 48px; height: 48px; font-size: 1.3rem; }

/* Options */
.options { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; width: 100%; }
.opt {
  min-height: 52px; padding: 12px 14px; border-radius: 14px;
  border: 2px solid var(--border); background: var(--card); box-shadow: 0 3px 0 var(--border);
  display: flex; align-items: center; gap: 10px; font-weight: 700; text-align: left;
}
.opt-key { width: 26px; height: 26px; border-radius: 8px; border: 1.5px solid var(--border); display: grid; place-items: center; font-size: .8rem; color: var(--muted); flex-shrink: 0; }
.opt.sel { border-color: var(--blue); background: color-mix(in srgb, var(--blue) 12%, var(--card)); box-shadow: 0 3px 0 var(--blue); }
.opt.right { border-color: var(--green); background: color-mix(in srgb, var(--green) 16%, var(--card)); box-shadow: 0 3px 0 var(--green); }
.opt.wrong { border-color: var(--red); background: color-mix(in srgb, var(--red) 14%, var(--card)); box-shadow: 0 3px 0 var(--red); animation: shake .35s; }
.mp-word { display: flex; flex-direction: column; }

/* Word order */
.bubble-row { display: flex; align-items: center; gap: 12px; width: 100%; }
.speech-bubble {
  flex: 1; padding: 12px 14px; border-radius: 16px; border: 2px solid var(--border);
  background: var(--card); font-weight: 700;
}
.answer-line {
  min-height: 60px; padding: 10px; border-radius: 14px; border: 2px dashed var(--border);
  background: var(--bg2); display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
}
.answer-line.right { border-color: var(--green); border-style: solid; }
.answer-line.wrong { border-color: var(--red); border-style: solid; animation: shake .35s; }
.bank { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.tile-slot { display: inline-flex; min-width: 44px; min-height: 44px; border-radius: 12px; background: var(--bg2); }
.tile {
  min-height: 44px; padding: 8px 14px; border-radius: 12px;
  border: 2px solid var(--border); background: var(--card); box-shadow: 0 3px 0 var(--border);
  font-weight: 700;
}

/* Match pairs */
.pairs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
.pairs .col { display: flex; flex-direction: column; gap: 10px; }
.pair {
  min-height: 52px; padding: 10px 12px; border-radius: 14px;
  border: 2px solid var(--border); background: var(--card); box-shadow: 0 3px 0 var(--border);
  font-weight: 700; text-align: center;
}
.pair.sel { border-color: var(--blue); background: color-mix(in srgb, var(--blue) 14%, var(--card)); }
.pair.done { opacity: .35; border-color: var(--green); box-shadow: none; }

/* Dictation */
.dict-input {
  width: 100%; padding: 14px; border-radius: 14px; border: 2px solid var(--border);
  background: var(--card); font-size: 16px; resize: none;
}
.dict-input:focus { outline: none; border-color: var(--blue); }
.dict-input.right { border-color: var(--green); }
.dict-input.wrong { border-color: var(--red); }

/* Speak / Pronunciation */
.speak-text { font-size: 1.25rem; font-weight: 800; line-height: 1.6; }
.sw { display: inline-block; padding: 1px 6px; border-radius: 8px; cursor: pointer; }
.sw.ok { background: #dcfce7; color: #166534; }
.sw.near { background: #fef9c3; color: #854d0e; }
.sw.bad { background: #fee2e2; color: #991b1b; text-decoration: underline wavy; }
@media (prefers-color-scheme: dark) {
  .sw.ok { background: #14532d; color: #bbf7d0; }
  .sw.near { background: #713f12; color: #fef08a; }
  .sw.bad { background: #7f1d1d; color: #fecaca; }
}
.mic-row { display: flex; align-items: center; justify-content: center; gap: 16px; margin: 6px 0; }
.mic {
  position: relative; width: 82px; height: 82px; border-radius: 50%;
  background: var(--blue); color: #fff; font-size: 2rem; box-shadow: 0 5px 0 var(--blue-d);
  display: grid; place-items: center;
}
.mic.on { background: var(--red); box-shadow: 0 5px 0 var(--red-d); }
.mic .ring { position: absolute; inset: 0; border-radius: 50%; border: 3px solid var(--red); opacity: 0; pointer-events: none; }
.mic.on .r1 { animation: pulse 1.3s infinite; }
.mic.on .r2 { animation: pulse 1.3s .55s infinite; }
.wave { display: flex; align-items: center; gap: 4px; height: 34px; opacity: .25; }
.wave.on { opacity: 1; }
.wave i { display: block; width: 5px; height: 10px; border-radius: 4px; background: var(--blue); }
.wave.on i { animation: wave .6s ease-in-out infinite alternate; }
.wave i:nth-child(2) { animation-delay: .1s; } .wave i:nth-child(3) { animation-delay: .2s; }
.wave i:nth-child(4) { animation-delay: .3s; } .wave i:nth-child(5) { animation-delay: .2s; }
.wave i:nth-child(6) { animation-delay: .1s; }
.mic-status { font-weight: 700; text-align: center; font-size: .95rem; }
.heard { font-size: .9rem; color: var(--muted); text-align: center; min-height: 20px; }
.legend { font-size: .8rem; color: var(--muted); text-align: center; display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; align-items: center; }
.score-ring { position: relative; width: 76px; height: 76px; display: grid; place-items: center; }
.score-ring svg { width: 76px; height: 76px; transform: rotate(-90deg); }
.score-ring circle { fill: none; stroke-width: 8; }
.score-ring .bg { stroke: var(--border); }
.score-ring .fg { stroke-linecap: round; transition: stroke-dashoffset .7s ease; }
.score-ring b { position: absolute; font-size: 1.25rem; }

/* Summary */
.summary { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; padding: 10px 0; }
.sum-cards { display: grid; grid-template-columns: repeat(3, minmax(90px, 1fr)); gap: 10px; width: 100%; max-width: 420px; }
.sum-box { border-radius: 16px; padding: 12px 8px; border: 2px solid var(--border); background: var(--card); }
.sum-box b { display: block; font-size: 1.5rem; color: var(--green-d); }
.sum-box span { font-size: .8rem; color: var(--muted); font-weight: 700; }

/* Leaderboard & Profile */
.tabs { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.tab { padding: 8px 14px; border-radius: 999px; font-weight: 800; font-size: .88rem; background: var(--bg2); color: var(--muted); }
.tab.active { background: var(--blue); color: #fff; }
.lb-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.lb-row:last-child { border: none; }
.lb-rank { width: 32px; font-weight: 900; text-align: center; font-size: 1.05rem; }
.lb-name { flex: 1; font-weight: 700; }
.lb-xp { font-weight: 800; color: var(--blue-d); }
.badges { display: flex; flex-wrap: wrap; gap: 8px; }
.badge-chip { padding: 6px 12px; border-radius: 999px; background: var(--bg2); border: 1.5px solid var(--border); font-size: .85rem; font-weight: 700; }
.badge-chip.earned { background: #fef9c3; border-color: var(--yellow); color: #713f12; }
.prof-list { display: flex; flex-direction: column; gap: 8px; }
.prof-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border: 2px solid var(--border); border-radius: 14px; }
.prof-item.active { border-color: var(--green); background: color-mix(in srgb, var(--green) 8%, var(--card)); }

/* Forms & Modals */
.modal-bg {
  position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.5);
  display: grid; place-items: center; padding: 16px;
}
.modal {
  background: var(--bg); border-radius: 20px; padding: 20px; width: min(440px, 100%);
  max-height: 90dvh; overflow-y: auto; box-shadow: 0 20px 50px rgba(0,0,0,.3);
}
.modal h3 { margin: 0 0 12px; font-size: 1.2rem; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field label { font-size: .88rem; font-weight: 700; color: var(--muted); }
.field input, .field select {
  min-height: 46px; padding: 10px 12px; border-radius: 12px;
  border: 2px solid var(--border); background: var(--card); font-size: 16px;
}
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.age-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.age-card {
  padding: 12px 6px; border-radius: 14px; border: 2px solid var(--border); background: var(--card);
  display: flex; flex-direction: column; align-items: center; gap: 4px; font-weight: 800; font-size: .9rem;
}
.age-card span { font-size: 1.8rem; }
.age-card.sel { border-color: var(--green); background: color-mix(in srgb, var(--green) 12%, var(--card)); }

/* Toast & Confetti */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 16px); z-index: 80;
  transform: translate(-50%, 20px); opacity: 0; transition: .25s;
  background: #1f2937; color: #fff; padding: 10px 16px; border-radius: 12px; font-weight: 700; font-size: .92rem; max-width: 90vw;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast.err { background: var(--red-d); }
.toast.ok { background: var(--green-d); }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 90; overflow: hidden; }
.confetti i {
  position: absolute; top: -12px; width: 10px; height: 14px;
  animation: fall linear forwards;
}

/* Mascot Kiwi SVG */
.mascot { flex-shrink: 0; }
.mascot svg { width: 100%; height: 100%; overflow: visible; }
.m-shadow { fill: rgba(0,0,0,.12); }
.m-torso { fill: #58cc02; }
.m-belly { fill: #d9f99d; }
.m-wing { fill: #46a302; transform-origin: 60px 66px; }
.m-tuft { fill: #58cc02; }
.m-feet path { fill: #ff9600; }
.m-pupil { fill: #1f2937; }
.m-lid { fill: #58cc02; transform-origin: center top; transform: scaleY(0); }
.m-brow { stroke: #365314; stroke-width: 3; stroke-linecap: round; fill: none; opacity: 0; }
.m-beak-top { fill: #ff9600; }
.m-beak-bot { fill: #f59e0b; transform-origin: 60px 72px; }
.m-cheek { fill: #fda4af; opacity: .55; }
.m-body { transform-origin: 60px 100px; }

.m-idle .m-body { animation: bob 2.6s ease-in-out infinite; }
.m-idle .m-lid { animation: blink 4.2s infinite; }
.m-happy .m-body { animation: jump .55s ease-in-out infinite; }
.m-happy .m-wing-l { animation: flapL .35s infinite alternate; }
.m-happy .m-wing-r { animation: flapR .35s infinite alternate; }
.m-dance .m-body { animation: dance .7s ease-in-out infinite; }
.m-sad .m-body { transform: translateY(5px) scaleY(.95); }
.m-sad .m-brow { opacity: 1; }
.m-think .m-body { animation: tilt 1.4s ease-in-out infinite; }
.m-talk .m-beak-bot { animation: talk .22s infinite alternate; }

@keyframes bob { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-4px)} }
@keyframes blink { 0%,92%,100%{transform:scaleY(0)} 96%{transform:scaleY(1)} }
@keyframes jump { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-11px)} }
@keyframes dance { 0%,100%{transform:rotate(-5deg) translateY(0)} 50%{transform:rotate(5deg) translateY(-9px)} }
@keyframes tilt { 0%,100%{transform:rotate(-4deg)} 50%{transform:rotate(4deg)} }
@keyframes flapL { to{transform:rotate(-16deg)} }
@keyframes flapR { to{transform:rotate(16deg)} }
@keyframes talk { to{transform:scaleY(1.6) translateY(2px)} }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-6px)} 75%{transform:translateX(6px)} }
@keyframes pulse { 0%{transform:scale(1);opacity:.75} 100%{transform:scale(1.65);opacity:0} }
@keyframes wave { from{height:8px} to{height:32px} }
@keyframes fall { to{transform:translate(var(--dx), 105vh) rotate(var(--rot)); opacity: .2;} }

/* Smartphone Landscape (chiều cao < 540px và màn ngang) */
@media (orientation: landscape) and (max-height: 540px) {
  .nav {
    top: calc(var(--top-h) + var(--safe-t)); bottom: 0; right: auto; width: calc(var(--side-w) + var(--safe-l));
    height: auto; flex-direction: column; justify-content: flex-start; padding: 10px 6px 10px calc(6px + var(--safe-l)); gap: 8px;
    border-top: none; border-right: 2px solid var(--border);
  }
  .main { padding: 12px calc(16px + var(--safe-r)) 20px calc(var(--side-w) + var(--safe-l) + 16px); max-width: 1100px; }
  .modules-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .lesson-body { max-width: 960px; padding: 8px calc(16px + var(--safe-r)) 8px calc(16px + var(--safe-l)); }
  .ex-flash, .ex-speak, .ex-mp {
    display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: center;
  }
  .flash { height: 175px; }
  .lesson-top { padding-top: calc(6px + var(--safe-t)); padding-bottom: 6px; }
  .lesson-foot { padding-top: 8px; padding-bottom: calc(8px + var(--safe-b)); }
  .summary { flex-direction: row; justify-content: center; gap: 24px; text-align: left; }
}

/* Tablet / Desktop >= 900px */
@media (min-width: 900px) and (min-height: 541px) {
  .nav {
    top: var(--top-h); bottom: 0; right: auto; width: 170px; height: auto;
    flex-direction: column; justify-content: flex-start; align-items: stretch; padding: 16px 12px; gap: 8px;
    border-top: none; border-right: 2px solid var(--border);
  }
  .nav-btn { flex-direction: row; justify-content: flex-start; gap: 10px; font-size: .95rem; padding: 10px 14px; }
  .main { padding: 20px 24px 30px 194px; max-width: 960px; }
}

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