:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --text: #1e2433;
  --muted: #6b7280;
  --primary: #4f46e5;
  --primary-soft: #eef0ff;
  --green: #16a34a;
  --green-soft: #e8f7ee;
  --amber: #d97706;
  --amber-soft: #fdf3e3;
  --red: #dc2626;
  --red-soft: #fdeaea;
  --border: #e5e7eb;
  --shadow: 0 2px 10px rgba(30, 36, 51, 0.07);
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] { display: none !important; }

body {
  font-family: "Nunito", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: linear-gradient(180deg, #eef1fb 0%, #f6f7fb 220px, #f6f7fb 100%);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
}

/* ===== Topbar ===== */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 20px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.logo { font-size: 20px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.logo span { color: var(--primary); }
#mainNav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.nav-btn {
  border: none; background: transparent; color: var(--muted);
  font-size: 14.5px; font-weight: 600; padding: 8px 14px;
  border-radius: 10px; cursor: pointer; white-space: nowrap;
}
.nav-btn:hover { background: var(--primary-soft); color: var(--primary); }
.nav-btn.active { background: var(--primary); color: #fff; }
.streak { font-weight: 700; font-size: 15px; background: var(--amber-soft); color: var(--amber); padding: 6px 12px; border-radius: 99px; white-space: nowrap; }

main { max-width: 980px; margin: 0 auto; padding: 28px 20px 80px; }
.view h1 { font-size: 26px; margin-bottom: 14px; }
.muted { color: var(--muted); margin-bottom: 18px; }
.section-title { font-size: 19px; margin: 26px 0 12px; }

/* ===== Home ===== */
.hero { margin-bottom: 22px; }
.hero h1 { font-size: 30px; }
.hero p { color: var(--muted); font-size: 16px; }
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.stat-card { background: var(--card); border-radius: var(--radius); padding: 16px; text-align: center; box-shadow: var(--shadow); }
.stat-num { font-size: 28px; font-weight: 800; color: var(--primary); }
.stat-label { font-size: 13px; color: var(--muted); }
.home-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.home-card {
  background: var(--card); border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow); cursor: pointer; border: 2px solid transparent;
  transition: border-color .15s, transform .15s;
}
.home-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.home-icon { font-size: 32px; margin-bottom: 8px; }
.home-card h3 { margin-bottom: 6px; }
.home-card p { font-size: 13.5px; color: var(--muted); }
.tip-box {
  margin-top: 24px; background: var(--primary-soft); border-left: 4px solid var(--primary);
  padding: 14px 16px; border-radius: 8px; font-size: 14.5px;
}

/* ===== Buttons ===== */
.btn-ghost {
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  padding: 8px 14px; border-radius: 10px; cursor: pointer; font-size: 14px; font-weight: 600;
}
.btn-ghost:hover { background: var(--primary-soft); }
.btn-audio {
  border: none; background: var(--primary-soft); color: var(--primary);
  padding: 8px 16px; border-radius: 99px; cursor: pointer; font-size: 14.5px; font-weight: 600;
  margin-top: 12px;
}
.btn-audio:hover { background: #dfe3ff; }

/* ===== Vocab levels ===== */
.level-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.level-card {
  background: var(--card); border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow); cursor: pointer; border: 2px solid transparent;
  transition: border-color .15s;
}
.level-card:hover { border-color: var(--primary); }
.level-card h3 { font-size: 17px; margin-bottom: 4px; }
.level-card .lv-count { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.lv-bar { height: 7px; background: var(--border); border-radius: 99px; overflow: hidden; }
.lv-bar > div { height: 100%; background: var(--green); border-radius: 99px; }
.lv-due { display: inline-block; margin-top: 10px; font-size: 12.5px; font-weight: 700; color: var(--amber); background: var(--amber-soft); padding: 2px 10px; border-radius: 99px; }

/* ===== Flashcard ===== */
.study-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.progress-text { font-weight: 700; color: var(--muted); font-size: 14.5px; }
.flashcard { perspective: 1200px; cursor: pointer; max-width: 560px; margin: 0 auto; }
.fc-inner {
  position: relative; width: 100%; min-height: 320px;
  transition: transform .45s; transform-style: preserve-3d;
}
.flashcard.flipped .fc-inner { transform: rotateY(180deg); }
.fc-face {
  position: absolute; inset: 0; backface-visibility: hidden;
  background: var(--card); border-radius: 18px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 28px; text-align: center;
}
.fc-back { transform: rotateY(180deg); }
.fc-word { font-size: 40px; font-weight: 800; }
.fc-ipa { font-size: 19px; color: var(--muted); margin-top: 6px; }
.fc-hint { position: absolute; bottom: 14px; font-size: 12.5px; color: var(--muted); }
.fc-type { font-size: 13px; font-weight: 700; color: var(--primary); background: var(--primary-soft); padding: 3px 12px; border-radius: 99px; margin-bottom: 10px; }
.fc-meaning { font-size: 26px; font-weight: 800; margin-bottom: 14px; }
.fc-example { font-size: 16.5px; font-style: italic; }
.fc-example-vn { font-size: 14px; color: var(--muted); margin-top: 4px; }
.rating-row { display: flex; gap: 10px; justify-content: center; margin-top: 20px; }
.btn-rate {
  border: none; border-radius: 12px; padding: 12px 18px; cursor: pointer;
  font-size: 15px; font-weight: 700; display: flex; flex-direction: column; gap: 2px; align-items: center;
  min-width: 130px;
}
.btn-rate small { font-weight: 500; font-size: 11.5px; opacity: .75; }
.rate-hard { background: var(--red-soft); color: var(--red); }
.rate-ok { background: var(--amber-soft); color: var(--amber); }
.rate-easy { background: var(--green-soft); color: var(--green); }
.btn-rate:hover { filter: brightness(.95); }

/* ===== Pronunciation ===== */
.pron-grid, .grammar-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 12px; }
.pron-card, .grammar-card {
  background: var(--card); border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow); cursor: pointer; border: 2px solid transparent;
}
.pron-card:hover, .grammar-card:hover { border-color: var(--primary); }
.pron-card h3, .grammar-card h3 { font-size: 16.5px; margin-bottom: 6px; }
.pron-card p, .grammar-card p { font-size: 13.5px; color: var(--muted); }
.lv-tag { display: inline-block; font-size: 12px; font-weight: 700; color: var(--primary); background: var(--primary-soft); padding: 2px 10px; border-radius: 99px; margin-bottom: 8px; }
.pron-lesson-head { margin: 16px 0 20px; }
.pron-why { color: var(--muted); margin: 8px 0 12px; }
.drill-card {
  background: var(--card); border-radius: var(--radius); padding: 16px 18px;
  box-shadow: var(--shadow); margin-bottom: 12px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
}
.drill-text { flex: 1; min-width: 200px; }
.drill-text .d-en { font-size: 18px; font-weight: 700; }
.drill-text .d-ipa { font-size: 14px; color: var(--muted); }
.drill-text .d-note { font-size: 13px; color: var(--amber); font-weight: 600; }
.drill-actions { display: flex; gap: 8px; align-items: center; }
.btn-mic {
  border: none; background: var(--red-soft); color: var(--red);
  padding: 9px 16px; border-radius: 99px; cursor: pointer; font-size: 14.5px; font-weight: 700;
}
.btn-mic.listening { background: var(--red); color: #fff; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .65; } }
.drill-result { width: 100%; font-size: 14.5px; padding: 10px 12px; border-radius: 10px; }
.drill-result.good { background: var(--green-soft); color: var(--green); }
.drill-result.mid { background: var(--amber-soft); color: var(--amber); }
.drill-result.bad { background: var(--red-soft); color: var(--red); }
.drill-result .heard { color: var(--text); font-weight: 400; }
.drill-result b.wrong { text-decoration: underline wavy var(--red); }

/* ===== Grammar ===== */
.g-formula {
  background: #101322; color: #a5b4fc; font-family: Consolas, monospace;
  font-size: 16px; padding: 14px 18px; border-radius: 12px; margin: 14px 0;
  overflow-x: auto;
}
.g-explain { margin-bottom: 16px; }
.g-example {
  background: var(--card); border-radius: 12px; padding: 12px 16px; margin-bottom: 8px;
  box-shadow: var(--shadow); display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.g-example .ex-en { font-weight: 600; }
.g-example .ex-vn { color: var(--muted); font-size: 14px; width: 100%; }
.quiz-block { background: var(--card); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-top: 10px; }
.quiz-q { font-weight: 700; margin-bottom: 10px; }
.quiz-opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.quiz-opt {
  border: 1.5px solid var(--border); background: var(--bg); border-radius: 10px;
  padding: 9px 12px; cursor: pointer; font-size: 14.5px; text-align: left;
}
.quiz-opt:hover { border-color: var(--primary); }
.quiz-opt.correct { border-color: var(--green); background: var(--green-soft); color: var(--green); font-weight: 700; }
.quiz-opt.wrong { border-color: var(--red); background: var(--red-soft); color: var(--red); }

/* ===== Conversation ===== */
.conv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 12px; }
.conv-card {
  background: var(--card); border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow); cursor: pointer; border: 2px solid transparent;
}
.conv-card:hover { border-color: var(--primary); }
.conv-card .c-icon { font-size: 30px; }
.conv-card h3 { margin: 6px 0 4px; }
.conv-card p { font-size: 13.5px; color: var(--muted); }
.conv-head { margin: 16px 0; }
.conv-mode-row { display: flex; gap: 8px; margin-top: 12px; }
.btn-mode {
  border: 1.5px solid var(--border); background: var(--card); border-radius: 99px;
  padding: 8px 16px; cursor: pointer; font-size: 14px; font-weight: 600; color: var(--muted);
}
.btn-mode.active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.phrases-box { background: var(--card); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); margin-bottom: 18px; }
.phrases-box h4 { margin-bottom: 8px; }
.phrase-line { display: flex; gap: 10px; align-items: baseline; padding: 5px 0; flex-wrap: wrap; }
.phrase-line .p-en { font-weight: 600; }
.phrase-line .p-vn { color: var(--muted); font-size: 13.5px; }
.dlg-line {
  display: flex; gap: 12px; margin-bottom: 10px; align-items: flex-start;
}
.dlg-line.role-b { flex-direction: row-reverse; }
.dlg-avatar { font-size: 24px; margin-top: 4px; }
.dlg-bubble {
  background: var(--card); border-radius: 14px; padding: 12px 16px;
  box-shadow: var(--shadow); max-width: 76%;
}
.dlg-line.role-b .dlg-bubble { background: var(--primary-soft); }
.dlg-en { font-weight: 600; }
.dlg-vn { color: var(--muted); font-size: 13.5px; margin-top: 3px; }
.dlg-tools { margin-top: 8px; display: flex; gap: 8px; flex-wrap: wrap; }
.dlg-tools button { font-size: 13px; padding: 5px 12px; margin-top: 0; }
.dlg-result { margin-top: 8px; font-size: 14px; padding: 8px 10px; border-radius: 8px; }
.roleplay-controls {
  position: sticky; bottom: 12px; background: var(--card); border-radius: var(--radius);
  box-shadow: 0 4px 20px rgba(30,36,51,.18); padding: 14px 18px; margin-top: 18px;
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
}
.roleplay-status { flex: 1; font-size: 14.5px; font-weight: 600; min-width: 180px; }
.btn-primary {
  border: none; background: var(--primary); color: #fff; border-radius: 99px;
  padding: 10px 20px; cursor: pointer; font-size: 15px; font-weight: 700;
}
.btn-primary:hover { filter: brightness(1.08); }
.dlg-line.dimmed { opacity: .35; }
.dlg-line.current .dlg-bubble { outline: 2.5px solid var(--primary); }

/* ===== Linh vật Poly 🦜 ===== */
.mascot { display: block; }
.mascot-greet {
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border-radius: 20px; padding: 12px 18px;
  box-shadow: var(--shadow); max-width: 600px; margin: 4px auto 10px;
}
.mascot-greet .mascot { flex-shrink: 0; animation: mascotBob 2.4s ease-in-out infinite; }
@keyframes mascotBob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
.mascot-bubble {
  position: relative; background: var(--primary-soft); border-radius: 16px;
  padding: 12px 16px; font-weight: 700; font-size: 15px; color: var(--text);
}
.mascot-bubble::before {
  content: ""; position: absolute; left: -8px; top: 50%; transform: translateY(-50%);
  border: 8px solid transparent; border-right-color: var(--primary-soft); border-left: 0;
}
.hero-with-mascot { display: flex; align-items: center; gap: 18px; }
.hero-with-mascot .mascot { animation: mascotBob 2.4s ease-in-out infinite; }
.finish-mascot { display: flex; justify-content: center; margin-bottom: 6px; }
.finish-mascot .mascot { animation: mascotBob 1.2s ease-in-out infinite; }
.reflex-orb .mascot { margin-top: 6px; }
@media (max-width: 640px) {
  .hero-with-mascot { flex-direction: column; text-align: center; }
  .mascot-greet { flex-direction: column; text-align: center; }
  .mascot-bubble::before { display: none; }
}

/* ===== XP box ===== */
.xp-box { font-weight: 700; font-size: 14px; background: var(--primary-soft); color: var(--primary); padding: 6px 12px; border-radius: 99px; white-space: nowrap; }

/* ===== Path map chủ đề (kiểu Duolingo) ===== */
.path-map { display: flex; flex-direction: column; align-items: center; padding: 10px 0 40px; }
.unit-banner {
  width: 100%; max-width: 600px; border-radius: 20px; color: #fff;
  padding: 20px 24px; margin: 30px 0 20px; box-shadow: 0 8px 24px rgba(30,36,51,.16);
  display: flex; align-items: center; gap: 16px;
}
.unit-icon { font-size: 42px; filter: drop-shadow(0 3px 4px rgba(0,0,0,.2)); }
.unit-title { font-size: 20px; font-weight: 900; letter-spacing: .2px; }
.unit-desc { font-size: 13.5px; opacity: .92; }
.path-node { display: flex; flex-direction: column; align-items: center; margin: 14px 0; width: 260px; }
.node-btn {
  position: relative;
  width: 84px; height: 84px; border-radius: 50%; border: none; cursor: pointer;
  font-size: 36px;
  background: radial-gradient(circle at 30% 25%, #ffffff 0%, #f1f3f7 60%);
  box-shadow: 0 6px 0 #c9cedb, 0 10px 18px rgba(30,36,51,.12), inset 0 0 0 5px var(--node-color, #d1d5db);
  transition: transform .12s;
  display: flex; align-items: center; justify-content: center;
}
.node-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #c9cedb, inset 0 0 0 5px var(--node-color, #d1d5db); }
.node-emoji { filter: drop-shadow(0 2px 2px rgba(0,0,0,.12)); }
.node-check {
  position: absolute; right: -4px; top: -4px;
  width: 28px; height: 28px; border-radius: 50%; background: var(--green); color: #fff;
  font-size: 16px; font-weight: 900; display: flex; align-items: center; justify-content: center;
  border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.2);
}
.path-node.locked .node-btn { cursor: not-allowed; filter: grayscale(1); opacity: .55; box-shadow: 0 5px 0 #d5d8e0, inset 0 0 0 5px #d1d5db; font-size: 26px; }
.path-node.avail .node-btn { animation: bounce 1.7s infinite; }
@keyframes bounce { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.node-label { margin-top: 8px; font-size: 13.5px; font-weight: 800; color: var(--muted); text-align: center; max-width: 230px; }
.path-node.avail .node-label { color: var(--text); }
.node-goal { font-size: 11.5px; font-weight: 600; color: var(--muted); margin-top: 2px; }
.node-best { color: var(--green); }

/* ===== Lesson overlay ===== */
.lesson-overlay {
  position: fixed; inset: 0; z-index: 100; background: var(--bg);
  display: flex; flex-direction: column;
}
.lesson-top {
  display: flex; align-items: center; gap: 14px;
  max-width: 720px; width: 100%; margin: 0 auto; padding: 16px 20px 6px;
}
.lesson-close { border: none; background: transparent; font-size: 20px; color: var(--muted); cursor: pointer; padding: 4px 8px; }
.lesson-close:hover { color: var(--red); }
.lesson-progress { flex: 1; height: 14px; background: var(--border); border-radius: 99px; overflow: hidden; }
.lesson-progress > div { height: 100%; width: 0%; background: var(--green); border-radius: 99px; transition: width .3s; }
.lesson-hearts { font-size: 15px; letter-spacing: 1px; white-space: nowrap; }
.lesson-body {
  flex: 1; overflow-y: auto; width: 100%; max-width: 720px; margin: 0 auto;
  padding: 24px 20px; display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.ex-title { font-size: 21px; font-weight: 800; margin-bottom: 18px; text-align: center; }
.intro-card {
  background: var(--card); border-radius: 18px; box-shadow: var(--shadow);
  padding: 28px; text-align: center; max-width: 520px; width: 100%;
}
.intro-word { font-size: 36px; font-weight: 800; }
.intro-ipa { color: var(--muted); margin: 4px 0 8px; }
.intro-meaning { font-size: 22px; font-weight: 700; color: var(--primary); margin-bottom: 12px; }
.intro-ex { font-style: italic; }
.intro-exvn { font-size: 13.5px; color: var(--muted); margin-bottom: 4px; }
.big-audio {
  border: none; width: 92px; height: 92px; border-radius: 24px; font-size: 40px;
  background: var(--primary); color: #fff; cursor: pointer; box-shadow: 0 5px 0 #3730a3;
  margin-bottom: 20px;
}
.big-audio:active { transform: translateY(3px); box-shadow: none; }
.ex-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; width: 100%; max-width: 560px; }
.ex-opt {
  border: 2px solid var(--border); border-bottom-width: 4px; background: var(--card);
  border-radius: 14px; padding: 14px 16px; cursor: pointer; font-size: 16px; text-align: center;
}
.ex-opt:hover:not(:disabled) { background: var(--primary-soft); }
.ex-opt.selected { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.ex-opt.correct { border-color: var(--green); background: var(--green-soft); color: var(--green); font-weight: 700; }
.ex-opt.wrong { border-color: var(--red); background: var(--red-soft); color: var(--red); }
.order-prompt { font-size: 17px; margin-bottom: 20px; text-align: center; color: var(--text); }
.order-answer {
  min-height: 56px; width: 100%; max-width: 560px; border-bottom: 2px solid var(--border);
  display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 4px; margin-bottom: 22px;
}
.order-bank { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 560px; }
.order-token {
  border: 2px solid var(--border); border-bottom-width: 4px; background: var(--card);
  border-radius: 12px; padding: 9px 14px; cursor: pointer; font-size: 16px; font-weight: 600;
}
.order-token.used { visibility: hidden; }
.order-token.in-answer { border-color: var(--primary); }
.type-input {
  width: 100%; max-width: 480px; font-size: 19px; padding: 14px 18px;
  border: 2px solid var(--border); border-radius: 14px; outline: none;
}
.type-input:focus { border-color: var(--primary); }
.match-grid { display: flex; gap: 14px; width: 100%; max-width: 600px; }
.match-col { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.match-opt.matched { opacity: .25; pointer-events: none; border-color: var(--green); }
.shake { animation: shakeX .35s; }
@keyframes shakeX { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.speak-card { background: var(--card); border-radius: 18px; box-shadow: var(--shadow); padding: 26px; text-align: center; max-width: 560px; width: 100%; }
.speak-text { font-size: 24px; font-weight: 800; }
.speak-note { color: var(--muted); margin-top: 6px; }
.lesson-footer {
  border-top: 2px solid var(--border); padding: 16px 20px;
  display: flex; align-items: center; gap: 16px; justify-content: space-between;
  max-width: 720px; width: 100%; margin: 0 auto;
}
.lesson-footer.f-correct { background: var(--green-soft); border-color: var(--green); }
.lesson-footer.f-wrong { background: var(--red-soft); border-color: var(--red); }
.lesson-feedback { font-size: 16px; font-weight: 700; flex: 1; }
.f-correct .lesson-feedback { color: var(--green); }
.f-wrong .lesson-feedback { color: var(--red); }
.btn-check {
  border: none; background: var(--green); color: #fff; font-size: 16px; font-weight: 800;
  padding: 13px 34px; border-radius: 14px; cursor: pointer; box-shadow: 0 4px 0 #15803d;
  margin-left: auto;
}
.btn-check:disabled { background: var(--border); color: var(--muted); box-shadow: none; cursor: not-allowed; }
.btn-check:active:not(:disabled) { transform: translateY(3px); box-shadow: none; }
/* Chip 5 bước của bài học chủ đề */
.lesson-phase {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  max-width: 720px; width: 100%; margin: 4px auto 0; padding: 4px 20px;
  flex-wrap: wrap;
}
.phase-dot {
  width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 16px; background: var(--border); opacity: .45;
}
.phase-dot.past { opacity: .8; background: var(--green-soft); }
.phase-dot.on {
  opacity: 1; background: #fff; box-shadow: 0 0 0 3px var(--phc, var(--primary));
  transform: scale(1.12);
}
.phase-line { width: 12px; height: 3px; background: var(--border); border-radius: 2px; }
.phase-name { font-size: 13.5px; font-weight: 800; margin-left: 10px; }

/* Confetti */
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.confetti span {
  position: absolute; top: -40px; left: var(--x, 50%);
  font-size: 24px; animation: confFall 2.6s ease-in var(--d, 0s) forwards;
}
@keyframes confFall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(105vh) rotate(360deg); opacity: .6; }
}

.finish-card { text-align: center; }
.finish-emoji { font-size: 64px; margin-bottom: 8px; }
.finish-stats { display: flex; gap: 14px; justify-content: center; margin-top: 18px; }
.finish-stat { background: var(--card); border-radius: 14px; padding: 14px 20px; box-shadow: var(--shadow); }
.fs-num { font-size: 22px; font-weight: 800; }
.fs-label { font-size: 12.5px; color: var(--muted); }

/* ===== Luyện phản xạ ===== */
.reflex-stage { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 20px 0 40px; }
.reflex-orb {
  width: 130px; height: 130px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 52px; background: var(--card); box-shadow: var(--shadow); transition: background .2s;
}
.reflex-orb.speaking { background: var(--primary-soft); animation: orbPulse 1.2s infinite; }
.reflex-orb.listening { background: var(--red-soft); animation: orbPulse .8s infinite; }
.reflex-orb.ok { background: var(--green-soft); }
.reflex-orb.fail { background: var(--amber-soft); }
@keyframes orbPulse { 50% { transform: scale(1.08); box-shadow: 0 0 0 14px rgba(79,70,229,.08); } }
.reflex-timebar-track { width: 100%; max-width: 420px; height: 10px; background: var(--border); border-radius: 99px; overflow: hidden; }
.reflex-timebar { height: 100%; width: 100%; background: linear-gradient(90deg, var(--green), var(--amber), var(--red)); border-radius: 99px; }
.reflex-status { font-size: 17px; font-weight: 600; text-align: center; min-height: 26px; }
.reflex-reveal {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 22px; max-width: 560px; width: 100%;
}
.reveal-q { font-size: 20px; font-weight: 800; }
.reveal-qvn { color: var(--muted); margin-bottom: 8px; }
.reveal-hint { background: var(--primary-soft); color: var(--primary); border-radius: 10px; padding: 8px 12px; font-size: 14.5px; margin-bottom: 10px; }
.reveal-sample { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-style: italic; }
.reflex-retry-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* ===== Toast ===== */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #1e2433; color: #fff; padding: 12px 22px; border-radius: 99px;
  font-size: 14.5px; z-index: 99; box-shadow: 0 6px 24px rgba(0,0,0,.25);
}

@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; }
  #mainNav { order: 3; width: 100%; }
  .rating-row { flex-direction: column; }
  .btn-rate { width: 100%; }
  .dlg-bubble { max-width: 100%; }
}
