/* ------------------------------------------------------------
   Colours and shapes for the whole app.
   To re-brand, change the colour codes in the first block.
   ------------------------------------------------------------ */
:root {
  /* Room kept free at the bottom when the hosting service shows its own badge there (set by js/app.js). */
  --host-badge: 0px;
  --bg: #fbf8f3;
  --surface: #ffffff;
  --ink: #2b2140;
  --ink-2: #6e6682;
  --ink-3: #a59fb3;
  --line: #e9e3da;
  --line-soft: #f3eee6;
  --primary: #5b4bdb;
  --primary-dark: #4234b0;
  --primary-soft: #eeebff;
  --accent: #f2762e;
  --accent-dark: #c9591a;
  --good: #17a77f;
  --good-dark: #0f8262;
  --good-bg: #dcf6ec;
  --bad: #e5484d;
  --bad-dark: #b8343a;
  --bad-bg: #fde6e6;
  --gold: #f7b500;
  --blue: #2a93e8;
  --radius: 18px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: 'Fredoka', 'Vazirmatn', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 17px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
h1, h2, p { margin: 0; }
h1 { font-size: 26px; font-weight: 600; line-height: 1.25; text-wrap: balance; }
h2 { font-size: 20px; font-weight: 600; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 55%, transparent); outline-offset: 2px; }
.muted { color: var(--ink-2); }
.dim { filter: grayscale(1); opacity: 0.45; }
.grow { flex: 1; min-width: 0; }
.mascot { display: inline-flex; flex: none; }
.mascot svg { display: block; }

/* ---------- Buttons ---------- */
.btn {
  --b: var(--primary);
  --bd: var(--primary-dark);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 22px;
  border: 0; border-radius: 16px;
  background: var(--b); color: #fff;
  font-weight: 600; font-size: 17px; letter-spacing: 0.01em;
  box-shadow: 0 4px 0 var(--bd);
  transition: transform 0.06s, box-shadow 0.06s, filter 0.15s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { filter: brightness(1.05); }
.btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 0 0 var(--bd); }
.btn:disabled { background: var(--line); color: var(--ink-3); box-shadow: none; }
.btn.good { --b: var(--good); --bd: var(--good-dark); }
.btn.bad { --b: var(--bad); --bd: var(--bad-dark); }
.btn.accent { --b: var(--accent); --bd: var(--accent-dark); }
.btn.ghost { background: var(--surface); color: var(--ink-2); box-shadow: 0 4px 0 var(--line); outline: 2px solid var(--line); outline-offset: -2px; }
.btn.ghost:disabled { color: var(--ink-3); background: var(--line-soft); }
.btn.ghost.danger { color: var(--bad); }
.btn.light { background: #fff; color: var(--u, var(--primary)); box-shadow: 0 4px 0 rgb(0 0 0 / 0.18); }
.btn.small { padding: 8px 14px; font-size: 15px; border-radius: 13px; }

.tag { display: inline-flex; align-items: center; padding: 4px 12px; border-radius: 99px; background: var(--primary-soft); color: var(--primary-dark); font-size: 14px; font-weight: 600; }
.tag.new { align-self: flex-start; background: #ffeedd; color: var(--accent-dark); }

/* ---------- App frame ---------- */
.shell { display: flex; min-height: 100dvh; }
.page { flex: 1; min-width: 0; padding-bottom: 92px; }
.main { max-width: 640px; margin: 0 auto; padding: 4px 16px calc(150px + var(--host-badge)); display: flex; flex-direction: column; gap: 14px; }
.stats {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  max-width: 640px; margin: 0 auto; padding: 10px 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
}
.stat-group { display: flex; gap: 4px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 10px; border: 0; border-radius: 12px; background: transparent; font-weight: 600; font-variant-numeric: tabular-nums; }
.chip:hover { background: var(--line-soft); }
.course-chip { outline: 2px solid var(--line); outline-offset: -2px; background: var(--surface); }
.flag { font-size: 20px; line-height: 1; }
.flag.big { font-size: 34px; }

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around; gap: 2px;
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom) + var(--host-badge));
  background: var(--surface); border-top: 2px solid var(--line);
}
.nav .brand { display: none; }
.nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 6px 2px; border-radius: 14px; color: var(--ink-2); text-decoration: none; font-size: 12px; font-weight: 600; }
.nav a .ico { position: relative; font-size: 22px; line-height: 1.2; }
.nav a.on { color: var(--primary-dark); background: var(--primary-soft); }
.nav .dot { position: absolute; top: 0; right: -6px; width: 10px; height: 10px; border-radius: 50%; background: var(--bad); border: 2px solid var(--surface); }

@media (min-width: 900px) {
  .nav { position: sticky; top: 0; align-self: flex-start; height: 100dvh; width: 250px; flex: none; flex-direction: column; justify-content: flex-start; gap: 6px; padding: 22px 14px; border-top: 0; border-right: 2px solid var(--line); }
  .nav .brand { display: flex; flex-direction: row; align-items: center; gap: 10px; padding: 4px 12px 18px; font-size: 26px; font-weight: 700; color: var(--primary); background: none; }
  .nav a { flex: none; flex-direction: row; justify-content: flex-start; gap: 14px; padding: 11px 14px; font-size: 17px; }
  .page { padding-bottom: 0; }
  .main { padding-top: 8px; }
}

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card.center { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; }
.card.warn { border-color: var(--gold); background: #fff8e1; font-size: 15px; }
.warn-text { color: var(--bad-dark); }
.page-title { margin-top: 4px; }
.section-title { margin-top: 10px; }
.section-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-top: 10px; }
.section-row .section-title { margin: 0; }

.meter { height: 14px; border-radius: 99px; background: var(--line); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 99px; background: var(--good); transition: width 0.4s; min-width: 0; }
.meter.gold i { background: var(--gold); }
.goal-card { display: flex; flex-direction: column; gap: 10px; }
.goal-top { display: flex; justify-content: space-between; gap: 12px; }
.goal-top span { color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* ---------- Lesson trail ---------- */
.unit { --ud: color-mix(in srgb, var(--u) 72%, #000); margin-top: 8px; }
.unit-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; border-radius: 20px; background: var(--u); color: #fff; box-shadow: 0 5px 0 var(--ud); }
.unit-head .kicker { font-size: 13px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.85; }
.unit-head p { font-size: 15px; opacity: 0.92; }
.path { position: relative; padding: 14px 0 6px; }
.trail-wrap { position: absolute; left: 50%; top: 14px; width: 0; color: #ddd4c6; pointer-events: none; }
.trail { display: block; overflow: visible; }
.row { position: relative; height: 104px; display: flex; align-items: center; justify-content: center; }
.node {
  position: relative; width: 76px; height: 70px; border: 0; border-radius: 26px;
  transform: translateX(var(--x));
  background: var(--u); color: #fff; font-size: 30px; font-weight: 700;
  box-shadow: 0 7px 0 var(--ud);
  transition: transform 0.06s, box-shadow 0.06s;
}
.node:active { transform: translateX(var(--x)) translateY(5px); box-shadow: 0 2px 0 var(--ud); }
.node.locked { background: #e6e0d6; color: #a8a094; box-shadow: 0 7px 0 #cfc8bc; font-size: 24px; }
.node.locked span { filter: grayscale(1); opacity: 0.6; }
.node.kind-review:not(.locked) { background: var(--gold); box-shadow: 0 7px 0 #c48f00; }
.node.current::after { content: ''; position: absolute; inset: -9px; border-radius: 34px; border: 4px solid color-mix(in srgb, var(--u) 40%, transparent); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.08); opacity: 0.4; } }
.buddy { position: absolute; left: 50%; top: 50%; transform: translate(calc(-50% + var(--x)), -50%); animation: bob 2.4s ease-in-out infinite; pointer-events: none; }
@keyframes bob { 50% { transform: translate(calc(-50% + var(--x)), calc(-50% - 5px)); } }
.pop { position: absolute; top: calc(100% - 8px); left: 0; right: 0; z-index: 6; margin: 0 auto; max-width: 360px; padding: 16px; border-radius: 18px; background: var(--u); color: #fff; display: flex; flex-direction: column; gap: 8px; box-shadow: 0 5px 0 var(--ud); animation: popin 0.16s ease-out; }
.pop p { font-size: 15px; opacity: 0.95; }
.pop.locked { background: var(--surface); color: var(--ink-2); box-shadow: none; border: 2px solid var(--line); }
@keyframes popin { from { transform: scale(0.94); opacity: 0; } }

/* ---------- Lesson player ---------- */
.lesson, .onboard, .end { height: 100dvh; display: flex; flex-direction: column; background: var(--surface); }
.lesson-top { display: flex; align-items: center; gap: 14px; width: 100%; max-width: 760px; margin: 0 auto; padding: 16px; }
.x { width: 38px; height: 38px; border: 0; border-radius: 12px; background: transparent; color: var(--ink-3); font-size: 22px; }
.x:hover { background: var(--line-soft); color: var(--ink-2); }
.progress { flex: 1; height: 16px; border-radius: 99px; background: var(--line); overflow: hidden; }
.progress i { display: block; height: 100%; border-radius: 99px; background: var(--good); transition: width 0.4s; }
.lesson-hearts { font-weight: 600; font-variant-numeric: tabular-nums; min-width: 52px; text-align: end; }
.lesson-hearts.shake { animation: shake 0.4s; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.lesson-body { flex: 1; overflow-y: auto; padding: 8px 16px 24px; }
.ex { max-width: 600px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
.ex h1 q { color: var(--primary); }

.prompt { display: flex; align-items: flex-end; gap: 12px; }
.bubble { position: relative; display: flex; align-items: center; gap: 10px; padding: 12px 16px; border: 2px solid var(--line); border-radius: 18px; border-end-start-radius: 4px; font-size: 20px; background: var(--surface); margin-bottom: 14px; }
.say { flex: none; width: 40px; height: 40px; border: 0; border-radius: 12px; background: var(--primary-soft); font-size: 18px; }
.say:hover { background: #e0dbff; }
.hint { position: relative; border-bottom: 2px dotted var(--ink-3); cursor: help; }
.hint-tip { display: none; position: absolute; top: calc(100% + 8px); left: 50%; transform: translateX(-50%); z-index: 5; padding: 6px 12px; border-radius: 12px; background: var(--ink); color: #fff; font-size: 15px; white-space: nowrap; }
.hint.show .hint-tip { display: block; }

.opts { display: flex; flex-direction: column; gap: 10px; }
.opts.cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.opt { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 12px 16px; border: 2px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: 0 3px 0 var(--line); font-size: 18px; text-align: start; transition: transform 0.06s; }
.opt:hover { background: var(--line-soft); }
.opt:active { transform: translateY(2px); }
.opt-text { flex: 1; }
.opt-key { flex: none; width: 26px; height: 26px; display: none; align-items: center; justify-content: center; border: 2px solid var(--line); border-radius: 8px; color: var(--ink-3); font-size: 13px; font-weight: 600; }
@media (pointer: fine) { .opt-key { display: inline-flex; } }
.opt.card { flex-direction: column; justify-content: center; gap: 6px; padding: 18px 10px 12px; text-align: center; }
.opt.card .opt-key { position: absolute; display: none; }
.opt-emoji { font-size: 54px; line-height: 1.15; }
.opt.card img { width: 96px; height: 96px; object-fit: contain; }
.opt.sel, .tile.sel { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 3px 0 var(--primary); color: var(--primary-dark); }
.opt.right { border-color: var(--good); background: var(--good-bg); box-shadow: 0 3px 0 var(--good); color: var(--good-dark); }
.opt.wrong { border-color: var(--bad); background: var(--bad-bg); box-shadow: 0 3px 0 var(--bad); color: var(--bad-dark); }
.opt.faded { opacity: 0.45; }

.answer-line { display: flex; flex-wrap: wrap; align-content: flex-start; gap: 8px; min-height: 64px; padding: 8px 0 10px; border-top: 2px solid var(--line); border-bottom: 2px solid var(--line); }
.bank { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.tile { padding: 9px 14px; border: 2px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: 0 3px 0 var(--line); font-size: 18px; transition: transform 0.06s; }
.tile:active:not(:disabled) { transform: translateY(2px); }
.tile.used { color: transparent; background: var(--line-soft); border-color: var(--line-soft); box-shadow: none; }
.fill-line { font-size: 22px; line-height: 2; }
.blank { display: inline-block; min-width: 86px; padding: 0 10px; border-bottom: 3px solid var(--ink-3); text-align: center; color: var(--primary-dark); font-weight: 600; }
.type-box, .text-input { width: 100%; padding: 14px 16px; border: 2px solid var(--line); border-radius: 16px; background: var(--line-soft); font-size: 18px; resize: none; }
.type-box:focus, .text-input:focus { outline: none; border-color: var(--primary); background: var(--surface); }
.listen-row { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 8px 0; }
.big-say { width: 104px; height: 96px; font-size: 40px; border-radius: 26px; }
.slow-say { width: 62px; height: 58px; font-size: 24px; padding: 0; }
.match { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.match-col { display: flex; flex-direction: column; gap: 10px; }
.match-card { justify-content: center; text-align: center; }

.lesson-foot { border-top: 2px solid var(--line); padding: 16px 16px calc(16px + env(safe-area-inset-bottom) + var(--host-badge)); background: var(--surface); }
.lesson-foot .inner { max-width: 600px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
.foot-buttons { display: flex; gap: 10px; }
.foot-buttons .main-btn { flex: 1; }
.lesson-foot.ok { background: var(--good-bg); border-color: var(--good-bg); color: var(--good-dark); }
.lesson-foot.bad { background: var(--bad-bg); border-color: var(--bad-bg); color: var(--bad-dark); }
.feedback:empty { display: none; }
.feedback strong { font-size: 21px; }
.feedback p { font-size: 16px; }
.end-inner { flex-direction: row !important; justify-content: flex-end; }
.end-inner .main-btn { flex: 1; }
@media (min-width: 700px) {
  .lesson-foot .inner { flex-direction: row; align-items: center; justify-content: space-between; min-height: 56px; }
  .foot-buttons { margin-inline-start: auto; }
  .foot-buttons .main-btn, .end-inner .main-btn { flex: none; min-width: 170px; }
  .end-inner .main-btn { margin-inline-start: auto; }
}

/* ---------- End of lesson ---------- */
.end-main, .onboard-main { flex: 1; overflow-y: auto; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 24px 16px; text-align: center; }
.end-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 100%; max-width: 440px; }
.end-stat { --c: var(--gold); border: 2px solid var(--c); border-radius: 16px; overflow: hidden; background: var(--c); }
.end-stat small { display: block; padding: 4px 6px; color: #fff; font-weight: 600; font-size: 13px; }
.end-stat b { display: block; padding: 12px 4px; border-radius: 13px; background: var(--surface); color: var(--ink); font-size: 19px; font-weight: 600; }
.end-stat.gold b { color: #a77a00; }
.end-stat.green { --c: var(--good); } .end-stat.green b { color: var(--good-dark); }
.end-stat.blue { --c: var(--blue); } .end-stat.blue b { color: #1b6fb5; }
.end-extras { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.flame { font-size: 92px; line-height: 1; animation: bob2 1.4s ease-in-out infinite; }
@keyframes bob2 { 50% { transform: translateY(-6px) scale(1.04); } }
.streak-num { font-size: 76px; font-weight: 700; line-height: 1; color: var(--accent); }
.week { display: flex; gap: 8px; padding: 14px; border: 2px solid var(--line); border-radius: 18px; }
.week-day { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.week-day small { color: var(--ink-2); font-size: 13px; }
.week-day span { width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--line); color: #fff; font-weight: 700; }
.week-day.on span { background: var(--accent); }
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 30; }
.confetti i { position: absolute; top: -20px; width: 10px; height: 16px; border-radius: 3px; animation: fall linear forwards; }
@keyframes fall { to { top: 110%; transform: rotate(720deg); } }

/* ---------- Welcome ---------- */
.onboard-main { justify-content: flex-start; padding-top: 8vh; }
.onboard-main > * { width: 100%; max-width: 480px; }
.onboard-main .prompt { justify-content: center; }
.onboard-main .bubble { font-size: 19px; font-weight: 600; text-align: start; }
.lead { font-size: 19px; color: var(--ink-2); }
.course-list { display: flex; flex-direction: column; gap: 10px; text-align: start; }
.course-item { display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px 16px; border: 2px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: 0 3px 0 var(--line); text-align: start; }
.course-item strong, .course-item small { display: block; }
.course-item small { color: var(--ink-2); font-size: 14px; }
.course-item.on { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 3px 0 var(--primary); }
.tick { color: var(--primary); font-weight: 700; font-size: 20px; }
.center-screen { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 24px; text-align: center; }

/* ---------- Practice, quests, shop, profile ---------- */
.hero { display: flex; align-items: center; gap: 16px; }
.hero .grow { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.hero p { color: var(--ink-2); }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { display: flex; flex-direction: column; gap: 2px; padding: 14px 12px; }
.stat b { font-size: 21px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat small { color: var(--ink-2); font-size: 14px; line-height: 1.25; }
.word-list { padding: 4px 16px; }
.word-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 2px solid var(--line-soft); }
.word-row:last-child { border-bottom: 0; }
.word-row strong { flex: 1; font-weight: 600; }
.word-emoji { width: 28px; text-align: center; font-size: 20px; color: var(--ink-3); }

.quest, .shop-item { display: flex; align-items: center; gap: 14px; }
.quest-icon, .shop-icon { font-size: 34px; line-height: 1; }
.quest-bar { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.quest-bar .meter { flex: 1; }
.quest-bar small { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.quest.claimed { opacity: 0.65; }
.shop-item p { color: var(--ink-2); font-size: 15px; }

.profile-head { display: flex; align-items: center; gap: 14px; margin-top: 6px; }
.avatar { width: 72px; height: 72px; flex: none; display: flex; align-items: center; justify-content: center; border-radius: 26px; background: var(--primary); color: #fff; font-size: 34px; font-weight: 600; box-shadow: 0 5px 0 var(--primary-dark); }
.chart { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; align-items: end; }
.chart-col { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.chart-col small { font-size: 13px; min-height: 18px; font-variant-numeric: tabular-nums; }
.chart-bar { width: 100%; max-width: 34px; height: 90px; display: flex; align-items: flex-end; border-radius: 10px; background: var(--line-soft); overflow: hidden; }
.chart-bar i { display: block; width: 100%; border-radius: 10px; background: var(--primary); }
.ach { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 2px solid var(--line-soft); }
.ach:last-child { border-bottom: 0; }
.ach strong, .ach small { display: block; }
.ach .grow small { color: var(--ink-2); font-size: 14px; margin-bottom: 6px; }
.ach-icon { font-size: 32px; filter: grayscale(1); opacity: 0.45; }
.ach.got .ach-icon { filter: none; opacity: 1; }
.settings { padding: 4px 16px; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 0; border-bottom: 2px solid var(--line-soft); }
.setting:last-child { border-bottom: 0; }
.setting select { padding: 8px 10px; border: 2px solid var(--line); border-radius: 12px; background: var(--surface); }
.setting input[type='checkbox'] { width: 22px; height: 22px; accent-color: var(--primary); }

/* ---------- Pop-ups ---------- */
.modal-wrap { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; padding: 16px 16px calc(16px + var(--host-badge)); background: rgb(43 33 64 / 0.45); animation: fade 0.15s; }
.modal { width: 100%; max-width: 420px; max-height: 88dvh; overflow-y: auto; display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 22px 18px 18px; border-radius: 24px; background: var(--surface); text-align: center; animation: rise 0.2s ease-out; }
.modal > p { color: var(--ink-2); }
.modal > div { width: 100%; }
.modal-actions { display: flex; flex-direction: column; gap: 12px; margin-top: 6px; }
.hearts-row { display: flex; justify-content: center; gap: 6px; font-size: 30px; margin-bottom: 8px; }
.hearts-row + p { color: var(--ink-2); }
.guide { display: flex; flex-direction: column; gap: 12px; text-align: start; }
.tip { padding: 12px 14px; border-radius: 14px; background: var(--line-soft); }
.tip p { color: var(--ink-2); font-size: 16px; }
@media (min-width: 600px) { .modal-wrap { align-items: center; } }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(18px); opacity: 0; } }
.toast { position: fixed; left: 50%; bottom: calc(104px + var(--host-badge)); z-index: 60; transform: translateX(-50%); padding: 10px 18px; border-radius: 99px; background: var(--ink); color: #fff; font-weight: 600; transition: opacity 0.4s; animation: rise 0.2s ease-out; }
.toast.out { opacity: 0; }

@media (max-width: 420px) {
  .chip-label { display: none; }
  .tiles { gap: 8px; }
  .stat b { font-size: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ============================================================
   Lesson levels, legendary, chests, stories, speaking, combos,
   practice hub, lightning round, monthly challenge
   ============================================================ */
.tag.gold { background: #fff3c4; color: #8a6400; }
.boost-line { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.boost-chip { background: #fff3c4; color: #8a6400; animation: glow 1.6s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: 0 0 0 4px rgb(247 181 0 / 0.25); } }
.unit-actions { display: flex; flex-direction: column; gap: 8px; flex: none; }

/* level ring around the current lesson */
.ring { position: absolute; left: 50%; top: 50%; width: 100px; height: 94px; border-radius: 36px; transform: translate(calc(-50% + var(--x)), calc(-50% + 3px)); background: conic-gradient(var(--gold) calc(var(--p) * 1%), #e3dccf 0); animation: pulse-ring 1.8s ease-in-out infinite; }
@keyframes pulse-ring { 50% { filter: brightness(1.08); } }
.node.has-ring { outline: 6px solid var(--bg); }
.node.has-ring::after { display: none; }
.node.legend:not(.locked) { background: linear-gradient(160deg, #ffd84d, #f7b500); box-shadow: 0 7px 0 #c48f00; }
.node.kind-story:not(.locked) { background: #2a93e8; box-shadow: 0 7px 0 #1b6fb5; }
.node.kind-chest { background: transparent; box-shadow: none; font-size: 46px; }
.node.kind-chest.locked { background: transparent; box-shadow: none; font-size: 40px; }
.node.kind-chest.locked span { filter: grayscale(1); opacity: 0.45; }
.node.kind-chest.done { font-size: 26px; color: #a8a094; background: #e6e0d6; box-shadow: 0 7px 0 #cfc8bc; }
.node.kind-chest.current span { display: inline-block; animation: wiggle 1.4s ease-in-out infinite; }
.node.kind-chest.current::after { display: none; }
@keyframes wiggle { 0%, 60%, 100% { transform: rotate(0); } 70% { transform: rotate(-9deg) scale(1.08); } 85% { transform: rotate(9deg) scale(1.08); } }
.gold-btn { --b: #f7b500; --bd: #c48f00; color: #4a3500; }
.pop .btn + .btn { margin-top: 2px; }
.chest-open { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.chest-emoji { font-size: 72px; line-height: 1.1; animation: popbig 0.5s cubic-bezier(0.2, 1.6, 0.4, 1); }
@keyframes popbig { from { transform: scale(0.2) rotate(-20deg); opacity: 0; } }

/* each new exercise slides in */
.ex.enter, .match.enter { animation: slidein 0.22s ease-out; }
@keyframes slidein { from { transform: translateX(26px); opacity: 0; } }
[dir='rtl'] .ex.enter { animation-name: slidein-rtl; }
@keyframes slidein-rtl { from { transform: translateX(-26px); opacity: 0; } }
.opt.right { animation: tada 0.35s ease-out; }
@keyframes tada { 40% { transform: scale(1.03); } }
.lesson-foot.ok strong, .lesson-foot.bad strong { display: inline-block; animation: rise 0.2s ease-out; }
.mascot svg { overflow: visible; }
.prompt .mascot { animation: nod 3.2s ease-in-out infinite; transform-origin: 50% 90%; }
@keyframes nod { 0%, 86%, 100% { transform: rotate(0); } 90% { transform: rotate(-5deg); } 95% { transform: rotate(4deg); } }
.end-mascot { position: relative; animation: hop 0.9s ease-out; }
@keyframes hop { 0% { transform: translateY(40px) scale(0.7); opacity: 0; } 60% { transform: translateY(-12px) scale(1.05); opacity: 1; } 80% { transform: translateY(4px); } }
.crown { position: absolute; left: 50%; top: -34px; transform: translateX(-50%) rotate(-8deg); font-size: 52px; animation: popbig 0.6s 0.3s both cubic-bezier(0.2, 1.6, 0.4, 1); }
.end-stat { animation: rise 0.3s ease-out both; }
.end-stat:nth-child(2) { animation-delay: 0.1s; }
.end-stat:nth-child(3) { animation-delay: 0.2s; }

/* combo banner */
.combo { position: fixed; left: 50%; top: 84px; z-index: 40; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; padding: 10px 22px; border-radius: 18px; background: var(--accent); color: #fff; box-shadow: 0 5px 0 var(--accent-dark); pointer-events: none; animation: combo 1.5s ease-out both; }
.combo b { font-size: 21px; }
.combo span { font-size: 14px; opacity: 0.95; }
@keyframes combo { 0% { transform: translateX(-50%) scale(0.5); opacity: 0; } 14% { transform: translateX(-50%) scale(1.08); opacity: 1; } 22%, 78% { transform: translateX(-50%) scale(1); opacity: 1; } 100% { transform: translateX(-50%) translateY(-18px); opacity: 0; } }

/* speaking */
.speak-row { display: flex; justify-content: center; padding: 8px 0; }
.btn.mic { width: 108px; height: 108px; border-radius: 50%; font-size: 46px; padding: 0; }
.btn.mic.on { --b: var(--bad); --bd: var(--bad-dark); animation: listening 1s ease-in-out infinite; }
@keyframes listening { 50% { box-shadow: 0 4px 0 var(--bd), 0 0 0 14px rgb(229 72 77 / 0.18); } }
.speak-status { text-align: center; min-height: 1.5em; margin: 0; }
.btn.mic.on { transform: scale(calc(1 + var(--lvl, 0) * 0.12)); transition: transform 0.08s; }
.speak-status .heard { display: block; margin-top: 4px; font-size: 14px; color: var(--ink-3); }
.ex.speaking { gap: 12px; }
.speak-download { text-align: center; }
.speak-download small { display: block; color: var(--ink-2); margin-bottom: 6px; }
.speak-download .bar { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; max-width: 320px; margin: 0 auto; }
.speak-download .bar i { display: block; height: 100%; width: 0; background: var(--primary); transition: width 0.3s; }
.heard-line { text-align: center; font-size: 22px; font-weight: 600; line-height: 1.7; }
.heard-line .w-heard { color: var(--good-dark); }
.sound-line { text-align: center; font-size: 20px; color: var(--ink-2); letter-spacing: 0.02em; }
.sound-line .w-missed { color: var(--accent-dark); background: color-mix(in srgb, var(--accent) 22%, transparent); border-radius: 5px; padding: 0 2px; font-weight: 700; }
.sound-line[hidden] { display: none; }
.sound-line.rtl { font-family: Vazirmatn, Fredoka, sans-serif; font-size: 26px; letter-spacing: 0; }
.heard-line .w-missed { color: var(--accent-dark); background: color-mix(in srgb, var(--accent) 16%, transparent); border-radius: 6px; padding: 0 4px; text-decoration: underline wavy color-mix(in srgb, var(--accent) 60%, transparent); text-underline-offset: 5px; }
.speak-plays { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.speak-plays .btn[hidden], .self-mark[hidden], .reveal-answer[hidden], .heard-line[hidden], .speak-download[hidden] { display: none; }
.ex.speaking > .btn.ghost { align-self: center; }
.self-mark { text-align: center; }
.self-mark p { margin: 4px 0 8px; font-weight: 600; }
.self-mark > div { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.speech-test .row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; }
.speech-test pre { white-space: pre-wrap; word-break: break-word; font-size: 13px; background: var(--line-soft); padding: 10px; border-radius: 12px; max-height: 320px; overflow: auto; }

/* stories */
.ex.story { gap: 14px; }
.story-head { display: flex; align-items: center; gap: 12px; }
.story-emoji { font-size: 44px; line-height: 1; }
.story-lines { display: flex; flex-direction: column; gap: 10px; }
.story-line { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border: 2px solid var(--line); border-radius: 16px; background: var(--surface); font-size: 19px; opacity: 0.72; }
.story-line.now, .story-line:last-child { opacity: 1; }
.story-line.now { border-color: var(--primary); animation: rise 0.25s ease-out; }
.story-line .speaker { display: block; font-size: 13px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--primary); }
.story-meaning { display: block; margin-top: 4px; color: var(--ink-2); font-size: 15px; }
.meaning-btn { flex: none; width: 30px; height: 30px; border: 2px solid var(--line); border-radius: 50%; background: var(--surface); color: var(--ink-2); font-weight: 700; }
.story-line .say { flex: none; }

/* practice hub */
.modes { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 620px) { .modes { grid-template-columns: 1fr 1fr; } }
.mode { display: flex; align-items: center; gap: 14px; text-align: start; width: 100%; font: inherit; color: inherit; box-shadow: 0 4px 0 var(--line); transition: transform 0.06s, box-shadow 0.06s; }
.mode:not(:disabled):hover { background: var(--line-soft); }
.mode:not(:disabled):active { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }
.mode:disabled { opacity: 0.5; }
.mode-icon { font-size: 34px; line-height: 1; }
.mode small { display: block; color: var(--ink-2); font-size: 14px; line-height: 1.3; }
.strength { display: inline-flex; align-items: flex-end; gap: 3px; flex: none; }
.strength i { width: 5px; border-radius: 2px; background: var(--line); }
.strength i:nth-child(1) { height: 7px; } .strength i:nth-child(2) { height: 11px; } .strength i:nth-child(3) { height: 15px; } .strength i:nth-child(4) { height: 19px; }
.strength.s1 i:nth-child(-n+1) { background: var(--bad); }
.strength.s2 i:nth-child(-n+2) { background: var(--accent); }
.strength.s3 i:nth-child(-n+3) { background: var(--gold); }
.strength.s4 i { background: var(--good); }

/* lightning round */
.rush-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.rush-time { min-width: 52px; text-align: end; font-weight: 700; font-variant-numeric: tabular-nums; }
.progress.clock i { background: var(--primary); transition: width 1s linear; }
.progress.clock.low i { background: var(--bad); }
.end-inner .btn.ghost { flex: none; }

/* monthly challenge and badges */
.monthly { display: flex; align-items: center; gap: 14px; border-color: var(--gold); background: #fffaf0; }
.monthly.won { background: #fff3c4; }
.monthly-badge { font-size: 46px; line-height: 1; }
.monthly .kicker { font-size: 13px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: #8a6400; }
.badges { display: flex; flex-wrap: wrap; gap: 14px; }
.badge { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 84px; text-align: center; }
.badge span { font-size: 40px; line-height: 1.1; }

@media (prefers-reduced-motion: reduce) {
  .ex.enter, .match.enter, .combo, .end-mascot, .crown, .prompt .mascot, .node.kind-chest.current span, .ring, .boost-chip, .btn.mic.on { animation: none; }
}

/* Persian and Arabic display options (js/display.js) */
.translit { display: block; font-size: 0.72em; font-weight: 500; color: var(--ink-2); direction: ltr; unicode-bidi: isolate; font-family: system-ui, sans-serif; line-height: 1.3; margin-top: 2px; }
.harakat-toggle { border: 2px solid var(--line, #e5e0d8); background: transparent; border-radius: 10px; min-width: 40px; height: 34px; font-size: 1.05em; font-family: Vazirmatn, system-ui; cursor: pointer; color: inherit; }
.harakat-toggle.on { background: var(--primary, #5B4BDB); border-color: var(--primary, #5B4BDB); color: #fff; }
.reveal-answer .mascot { visibility: hidden; }
