/* LinguaQuest — visual system
   Palette: warm paper base, ink text, tangerine primary, deep teal secondary, golden XP.
   Each language overrides --lang-accent on its screens. Icons come from Font Awesome Free. */

:root {
  --bg: #FBF8F2;
  --bg-2: #F3EEE3;
  --surface: #FFFFFF;
  --surface-2: #F7F2E8;
  --ink: #1A1613;
  --ink-soft: #5A5248;
  --ink-mute: #6F675D;
  --line: #E6DFD2;
  --primary: #E74C3C;
  --primary-ink: #FFFFFF;
  --primary-soft: #FDECEA;
  --secondary: #2E7D6B;
  --secondary-soft: #E3F0EC;
  --gold: #F4B93B;
  --gold-soft: #FDF3D9;
  --danger: #D64545;
  --success: #2E7D6B;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  --radius-pill: 999px;
  --shadow-sm: 0 2px 6px rgba(26, 22, 19, 0.06);
  --shadow-md: 0 8px 24px rgba(26, 22, 19, 0.10);
  --shadow-lg: 0 18px 40px rgba(26, 22, 19, 0.14);
  --font-display: "Baloo 2", system-ui, sans-serif;
  --font-body: "DM Sans", system-ui, sans-serif;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur-fast: 160ms;
  --dur-med: 260ms;
  --dur-slow: 420ms;
  --lang-accent: #E74C3C;
  --lang-accent-soft: #FDECEA;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  line-height: 1.5;
}
button { font-family: inherit; }
img { max-width: 100%; display: block; }
i { line-height: 1; }

.app { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }

/* ---------- Typography ---------- */
h1, h2, h3 { font-family: var(--font-display); font-weight: 700; line-height: 1.15; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: clamp(2rem, 6vw, 3.2rem); }
h2 { font-size: clamp(1.5rem, 4vw, 2.2rem); }
h3 { font-size: clamp(1.15rem, 3vw, 1.5rem); }
p { margin: 0; }
.small { font-size: 0.85rem; color: var(--ink-soft); }
.mute { color: var(--ink-mute); }

/* ---------- Layout ---------- */
.container { width: 100%; max-width: 480px; margin: 0 auto; padding: 0 20px; }
@media (min-width: 720px) { .container { max-width: 720px; } }
@media (min-width: 1024px) { .container { max-width: 960px; } }

.screen {
  flex: 1; display: flex; flex-direction: column; padding: 20px 0 32px;
  animation: screen-in var(--dur-slow) var(--ease-out) both;
}
.screen.center { justify-content: center; align-items: center; text-align: center; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; gap: 10px;
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
}
.topbar-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.topbar .brand {
  font-family: var(--font-display); font-weight: 800; font-size: 1.2rem; color: var(--ink);
  display: flex; align-items: center; gap: 8px; min-width: 0;
}
.topbar .brand > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 42vw; }
.topbar .brand .brand-mark { width: 24px; height: 24px; flex-shrink: 0; border-radius: 8px; }
.topbar .actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; cursor: pointer; font-family: var(--font-body); font-weight: 600;
  padding: 12px 20px; border-radius: var(--radius-pill);
  transition: transform var(--dur-fast) var(--ease-spring), box-shadow var(--dur-fast) var(--ease-out), background var(--dur-fast), color var(--dur-fast);
  user-select: none; -webkit-tap-highlight-color: transparent;
  font-size: 1rem; line-height: 1;
}
.btn i { font-size: 0.95em; }
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--lang-accent); color: #fff; box-shadow: 0 5px 0 color-mix(in srgb, var(--lang-accent) 68%, #000 32%), var(--shadow-sm); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 7px 0 color-mix(in srgb, var(--lang-accent) 68%, #000 32%), var(--shadow-md); }
.btn-secondary { background: var(--surface); color: var(--ink); box-shadow: 0 4px 0 var(--line), var(--shadow-sm); border: 2px solid var(--line); }
.btn-secondary:hover { border-color: color-mix(in srgb, var(--lang-accent) 40%, var(--line)); }
.btn-ghost { background: transparent; color: var(--ink-soft); }
.btn-ghost:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); color: var(--ink); }
.btn-gold { background: var(--gold); color: #3A2A00; box-shadow: 0 6px 0 #C9931F; }
.btn-danger { background: var(--danger); color: #fff; box-shadow: 0 5px 0 #A83232; }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 13px; font-size: 0.88rem; }
.btn-lg { padding: 16px 28px; font-size: 1.08rem; }
.btn-icon { padding: 10px; border-radius: var(--radius-md); }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border-radius: var(--radius-lg);
  padding: 20px; box-shadow: var(--shadow-sm); border: 1px solid var(--line);
}
.card.lang-card {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px;
  cursor: pointer; transition: transform var(--dur-fast) var(--ease-spring), box-shadow var(--dur-fast);
  border-left: 6px solid var(--card-accent, var(--lang-accent));
  animation: card-in var(--dur-med) var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 45ms);
}
.card.lang-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.card.lang-card:active { transform: scale(0.985); }

.lang-dot {
  width: 46px; height: 46px; border-radius: 15px; display: grid; place-items: center;
  color: #fff; font-size: 1.15rem; flex-shrink: 0; box-shadow: var(--shadow-sm);
}
.lang-info { flex: 1; min-width: 0; }
.lang-info strong { font-family: var(--font-display); font-size: 1.08rem; }
.lang-meta { display: flex; align-items: center; gap: 6px; font-size: 0.82rem; color: var(--ink-soft); margin-top: 1px; }
.meta-sep { color: var(--ink-mute); }
.mini-progress { height: 5px; border-radius: var(--radius-pill); background: var(--line); margin-top: 8px; overflow: hidden; }
.mini-progress > span { display: block; height: 100%; border-radius: var(--radius-pill); transition: width var(--dur-slow) var(--ease-out); }
.lang-right { display: flex; align-items: center; gap: 6px; color: var(--ink-mute); flex-shrink: 0; }
.lang-right .pct { font-family: var(--font-display); font-weight: 700; font-size: 0.9rem; color: var(--ink-soft); }
.lang-right i { font-size: 0.75rem; }

/* ---------- Stats / HUD ---------- */
.hud { display: flex; gap: 8px; flex-wrap: wrap; margin: 18px 0; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: var(--radius-pill);
  background: var(--surface); border: 1px solid var(--line);
  font-weight: 600; font-size: 0.9rem;
  animation: pill-in var(--dur-med) var(--ease-spring) both;
  animation-delay: calc(var(--i, 0) * 55ms);
}
.pill i { font-size: 0.9em; }
.pill.xp { background: var(--gold-soft); color: #7A5A00; border-color: #F0D99A; }
.pill.xp i { color: #C9931F; }
.pill.streak { background: #FDECEA; color: #9A2A1E; border-color: #F5C4BE; }
.pill.streak i { color: var(--primary); }
.pill.hearts { background: #FDECEA; color: #9A2A1E; border-color: #F5C4BE; }
.pill.hearts i { color: var(--primary); }
.pill.lost { animation: heart-shake 0.45s var(--ease-out); }

/* ---------- Progress bar ---------- */
.progress { height: 10px; background: var(--line); border-radius: var(--radius-pill); overflow: hidden; }
.progress > span {
  display: block; height: 100%; background: var(--lang-accent);
  border-radius: var(--radius-pill); transition: width var(--dur-slow) var(--ease-out);
}

/* ---------- Home hero ---------- */
.hero {
  display: grid; gap: 18px; padding: 18px 0 4px;
  grid-template-columns: 1fr;
}
@media (min-width: 720px) {
  .hero { grid-template-columns: 240px 1fr; align-items: center; gap: 28px; }
}
.hero-art { display: flex; align-items: center; gap: 12px; }
.hero-orb {
  width: 104px; height: 104px; border-radius: 34px; flex-shrink: 0;
  background: var(--lang-accent-soft); display: grid; place-items: center;
  border: 2px solid color-mix(in srgb, var(--lang-accent) 22%, transparent);
  transform: rotate(-4deg);
  animation: hero-pop var(--dur-slow) var(--ease-spring) both;
}
.hero-orb .mascot { box-shadow: none; width: 72px; height: 72px; transform: rotate(4deg); }
.hero-bubble {
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px 18px 18px 4px;
  padding: 12px 16px; box-shadow: var(--shadow-sm);
  flex: 1 1 auto; min-width: 0; max-width: 260px;
  display: flex; flex-direction: column; gap: 2px;
  animation: card-in var(--dur-med) var(--ease-out) both; animation-delay: 120ms;
}
.hero-bubble strong { font-family: var(--font-display); font-size: 1rem; }
.hero-bubble span { font-size: 0.85rem; color: var(--ink-soft); }
.hero-copy h1 { color: var(--ink); }
.hero .lead { font-size: 1.05rem; color: var(--ink-soft); margin-top: 10px; max-width: 42ch; }
.hero .cta-row { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.hero .cta-row .btn { flex: 1 1 180px; }

/* ---------- Section head ---------- */
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 6px 0 14px; }
#langlist { scroll-margin-top: 76px; }

/* ---------- Daily goal ---------- */
.goal-card { margin-bottom: 22px; }
.goal-card.done { background: var(--gold-soft); border-color: #F0D99A; }
.goal-card.done .progress > span { background: var(--gold); }
.goal-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; gap: 10px; }
.goal-label { display: flex; align-items: center; gap: 8px; }
.goal-label i { color: var(--lang-accent); }
.goal-card.done .goal-label i { color: #C9931F; }

/* ---------- Language grid ---------- */
.lang-grid { display: grid; gap: 12px; }
@media (min-width: 720px) { .lang-grid { grid-template-columns: 1fr 1fr; } }

/* ---------- Language hero ---------- */
.lang-hero {
  display: grid; grid-template-columns: auto 1fr; align-items: center;
  gap: 6px 14px; margin-bottom: 22px;
}
.lang-hero .progress { grid-column: 1 / -1; margin-top: 8px; }
.lang-hero-icon {
  width: 62px; height: 62px; border-radius: 20px; display: grid; place-items: center;
  color: #fff; font-size: 1.6rem; box-shadow: var(--shadow-sm);
}
.lang-hero-info h2 { font-size: 1.7rem; }
.lang-hero-info p { margin-top: 2px; }

/* ---------- Lesson path ---------- */
.path { display: flex; flex-direction: column; gap: 16px; align-items: center; padding: 18px 0 10px; }
.path-row { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; align-items: flex-start; }
.path-col { display: flex; flex-direction: column; align-items: center; }
.node {
  width: 70px; height: 70px; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer; position: relative;
  font-family: var(--font-display); font-weight: 800; font-size: 1.1rem; color: #fff;
  background: var(--lang-accent);
  box-shadow: 0 5px 0 color-mix(in srgb, var(--lang-accent) 58%, #000 42%), var(--shadow-md);
  transition: transform var(--dur-fast) var(--ease-spring), box-shadow var(--dur-fast);
  animation: node-pop var(--dur-med) var(--ease-spring) both;
  animation-delay: calc(var(--i, 0) * 60ms);
}
.node:hover { transform: translateY(-3px) scale(1.06); }
.node:active { transform: scale(0.96); }
.node.next {
  box-shadow: 0 5px 0 color-mix(in srgb, var(--lang-accent) 58%, #000 42%),
              0 0 0 5px var(--lang-accent-soft), var(--shadow-md);
}
.node .node-num { transform: translateY(1px); }
.node.locked { background: #CFC8BC; box-shadow: 0 5px 0 #ADA69A; cursor: not-allowed; color: #fff; }
.node.locked:hover { transform: none; }
.node.locked > i { font-size: 1rem; opacity: 0.9; }
.node.done { background: var(--secondary); box-shadow: 0 5px 0 #1F5A4D, var(--shadow-md); }
.node .star {
  position: absolute; top: -8px; right: -4px; background: var(--gold); color: #3A2A00;
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  font-size: 0.65rem; box-shadow: var(--shadow-sm); border: 2px solid var(--surface);
}
.node-label { font-size: 0.78rem; color: var(--ink-soft); text-align: center; max-width: 96px; margin-top: 8px; line-height: 1.25; }

.unit { width: 100%; margin-bottom: 12px; }
.unit-header { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.unit-header .num {
  width: 32px; height: 32px; border-radius: 10px; background: var(--lang-accent); color: #fff;
  display: grid; place-items: center; font-family: var(--font-display); font-weight: 800; font-size: 0.95rem;
}
.unit-icon { color: var(--ink-mute); font-size: 0.95rem; }
.unit-header h3 { font-size: 1.2rem; }

/* ---------- Exercise area ---------- */
.exercise { display: flex; flex-direction: column; gap: 16px; flex: 1; }
.mascot-wrap { display: flex; justify-content: center; padding: 2px 0 0; }
.type-ribbon {
  align-self: center; display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 13px; border-radius: var(--radius-pill);
  background: var(--lang-accent-soft); color: color-mix(in srgb, var(--lang-accent) 70%, var(--ink) 30%);
  font-size: 0.78rem; font-weight: 700; letter-spacing: 0.01em;
  animation: pill-in var(--dur-med) var(--ease-spring) both;
}
.type-ribbon i { font-size: 0.85em; }

.prompt { text-align: center; }
.prompt .target, .target {
  font-family: var(--font-display); font-size: clamp(1.8rem, 6vw, 2.6rem);
  font-weight: 800; color: var(--ink); line-height: 1.15;
}
.roman { font-size: 1rem; color: var(--ink-soft); margin-top: 3px; }
.meaning { font-size: 1.02rem; color: var(--ink-mute); margin-top: 5px; }
.question { font-size: 1.08rem; font-weight: 600; color: var(--ink-soft); }
.prompt-emoji { text-align: center; font-size: 2.6rem; line-height: 1; }
.flash-emoji { font-size: 2.4rem; margin-bottom: 6px; }

.options { display: grid; gap: 10px; }
.options.grid2 { grid-template-columns: 1fr 1fr; }
@media (min-width: 720px) { .options.grid2 { grid-template-columns: 1fr 1fr; } }

.opt {
  position: relative; background: var(--surface); border: 2px solid var(--line);
  border-radius: var(--radius-md); padding: 16px 30px; cursor: pointer;
  font-size: 1rem; font-weight: 500; text-align: center; color: var(--ink);
  transition: border-color var(--dur-fast), background var(--dur-fast), transform var(--dur-fast) var(--ease-spring);
  animation: opt-in var(--dur-med) var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 45ms);
  min-height: 58px;
}
.opt:hover { border-color: var(--lang-accent); transform: translateY(-2px); }
.opt:active { transform: scale(0.98); }
.opt.selected { border-color: var(--lang-accent); background: var(--lang-accent-soft); }
.opt.correct { border-color: var(--success); background: var(--secondary-soft); color: var(--secondary); }
.opt.wrong { border-color: var(--danger); background: #FDECEA; color: var(--danger); }
.opt-mark { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: 1.05rem; }
.opt.correct .opt-mark { color: var(--success); }
.opt.wrong .opt-mark { color: var(--danger); }

.answer-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 4px; }
.answer-actions .btn { width: 100%; }

/* Flashcard */
.flashcard {
  perspective: 1000px; cursor: pointer; min-height: 220px;
  display: flex; align-items: center; justify-content: center;
  animation: card-in var(--dur-med) var(--ease-out) both;
}
.flashcard .inner {
  position: relative; width: 100%; min-height: 220px;
  transition: transform var(--dur-slow) var(--ease-out);
  transform-style: preserve-3d;
}
.flashcard.flipped .inner { transform: rotateY(180deg); }
.flashcard .face {
  position: absolute; inset: 0; backface-visibility: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--surface); border-radius: var(--radius-xl); border: 1px solid var(--line);
  box-shadow: var(--shadow-md); padding: 24px; text-align: center;
}
.flashcard .back { transform: rotateY(180deg); background: var(--lang-accent-soft); }
.flashcard .hint { font-size: 0.82rem; color: var(--ink-mute); margin-top: 14px; display: inline-flex; align-items: center; gap: 6px; }

/* Memory match */
.memory-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
@media (min-width: 720px) { .memory-grid { grid-template-columns: repeat(4, 1fr); max-width: 560px; margin: 0 auto; } }
.mem-card {
  aspect-ratio: 1; border-radius: var(--radius-md); cursor: pointer;
  background: var(--surface); border: 2px solid var(--line);
  display: grid; place-items: center; position: relative; overflow: hidden;
  transition: transform var(--dur-fast) var(--ease-spring), background var(--dur-fast), border-color var(--dur-fast);
  animation: opt-in var(--dur-med) var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 35ms);
}
.mem-card:hover { transform: translateY(-2px); }
.mem-card .cover {
  position: absolute; inset: 0; background: var(--lang-accent); display: grid; place-items: center;
  color: #fff; font-family: var(--font-display); font-weight: 800; font-size: 1.2rem;
  transition: opacity var(--dur-fast);
}
.mem-card .mem-label { display: none; font-size: 0.82rem; font-weight: 600; padding: 6px; text-align: center; word-break: break-word; line-height: 1.25; }
.mem-card.flipped { background: var(--lang-accent-soft); border-color: var(--lang-accent); }
.mem-card.flipped .cover { opacity: 0; pointer-events: none; }
.mem-card.flipped .mem-label { display: block; animation: pop-in var(--dur-fast) var(--ease-spring) both; }
.mem-card.matched { background: var(--secondary-soft); border-color: var(--secondary); opacity: 0.72; cursor: default; }
.mem-card.matched .mem-label { color: var(--secondary); }

/* Sentence builder */
.builder { display: flex; flex-direction: column; gap: 10px; }
.builder-label { font-size: 0.8rem; font-weight: 700; color: var(--ink-mute); }
.bank { display: flex; flex-wrap: wrap; gap: 8px; min-height: 52px; padding: 12px; background: var(--surface-2); border-radius: var(--radius-md); border: 2px dashed var(--line); }
.slot {
  display: flex; flex-wrap: wrap; gap: 8px; min-height: 58px; padding: 11px;
  background: var(--surface); border-radius: var(--radius-md); border: 2px solid var(--lang-accent);
  transition: border-color var(--dur-fast), background var(--dur-fast);
}
.slot.is-correct { border-color: var(--success); background: var(--secondary-soft); }
.slot.is-wrong { border-color: var(--danger); background: #FDECEA; }
.chip {
  padding: 8px 14px; border-radius: var(--radius-pill); background: var(--surface);
  border: 1.5px solid var(--line); cursor: pointer; font-weight: 500; user-select: none;
  transition: transform var(--dur-fast) var(--ease-spring), border-color var(--dur-fast), opacity var(--dur-fast);
}
.chip:hover { transform: translateY(-2px); border-color: var(--lang-accent); }
.chip:active { transform: scale(0.95); }
.chip.used { opacity: 0.32; pointer-events: none; }

/* Listen */
.play-audio { margin: 10px auto 4px; display: flex; }
.play-audio.playing { animation: play-pulse 0.9s var(--ease-out); }

/* Speed round */
.speedbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.speed-stat { display: flex; align-items: center; gap: 8px; color: var(--ink-soft); }
.speed-stat i { color: var(--lang-accent); }
.speed-stat.score i { color: var(--gold); }
.timer { font-family: var(--font-display); font-weight: 800; font-size: 1.6rem; color: var(--ink); }
.speed-stat.danger .timer, .speed-stat.danger i { color: var(--danger); }
.score-big { font-family: var(--font-display); font-weight: 800; font-size: 1.8rem; color: var(--ink); }
.score-big.bump { animation: bump 0.3s var(--ease-spring); }
.timebar { height: 8px; background: var(--line); border-radius: var(--radius-pill); overflow: hidden; }
.timebar > span { display: block; height: 100%; background: var(--lang-accent); border-radius: var(--radius-pill); transition: width 1s linear, background var(--dur-fast); }
.speed-target { margin: 14px 0 10px; text-align: center; }

/* ---------- Mascot ---------- */
.mascot {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--lang-accent); color: #fff;
  display: grid; place-items: center; font-size: 1.8rem;
  box-shadow: var(--shadow-md);
  transition: transform var(--dur-med) var(--ease-spring);
  position: relative;
}
.mascot::after {
  content: ""; position: absolute; inset: -6px; border-radius: 50%;
  border: 2px dashed color-mix(in srgb, var(--lang-accent) 35%, transparent);
  opacity: 0.7;
}
.mascot i { transform: translateY(1px); }
.mascot.happy { animation: bounce 0.5s var(--ease-spring); }
.mascot.sad { animation: shake 0.5s; }
.mascot.cheer { animation: cheer 0.7s var(--ease-spring); }
@keyframes bounce { 0%{transform:scale(1)} 40%{transform:scale(1.18) translateY(-7px)} 100%{transform:scale(1)} }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-6px)} 75%{transform:translateX(6px)} }
@keyframes cheer { 0%{transform:rotate(0)} 25%{transform:rotate(-12deg) scale(1.06)} 75%{transform:rotate(12deg) scale(1.06)} 100%{transform:rotate(0)} }

/* ---------- Feedback overlay ---------- */
.feedback { position: fixed; inset: 0; z-index: 50; pointer-events: none; display: flex; align-items: center; justify-content: center; }
.feedback .badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 13px 24px; border-radius: var(--radius-pill);
  font-family: var(--font-display); font-weight: 800; font-size: 1.3rem;
  color: #fff; box-shadow: var(--shadow-lg);
  animation: pop-in 0.4s var(--ease-spring);
}
.feedback .badge.ok { background: var(--secondary); }
.feedback .badge.no { background: var(--danger); }
@keyframes pop-in { 0%{transform:scale(0.6);opacity:0} 100%{transform:scale(1);opacity:1} }

.xp-float {
  position: fixed; z-index: 55; transform: translate(-50%, 0);
  font-family: var(--font-display); font-weight: 800; font-size: 1.25rem;
  color: #7A5A00; background: var(--gold-soft); border: 1px solid #F0D99A;
  padding: 4px 12px; border-radius: var(--radius-pill); pointer-events: none;
  animation: float-up 1.05s var(--ease-out) forwards;
}
@keyframes float-up {
  0% { opacity: 0; transform: translate(-50%, 6px) scale(0.8); }
  20% { opacity: 1; transform: translate(-50%, -4px) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -52px) scale(0.95); }
}

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.confetti span { position: absolute; width: 8px; height: 14px; top: -20px; animation: fall 1.2s linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); opacity: 0; } }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(26,22,19,0.5); z-index: 40; display: grid; place-items: center; padding: 20px; animation: fade-in var(--dur-med) ease both; }
.modal { background: var(--surface); border-radius: var(--radius-xl); padding: 26px; max-width: 420px; width: 100%; box-shadow: var(--shadow-lg); animation: pop-in var(--dur-med) var(--ease-spring) both; }
.modal h2 { margin-bottom: 8px; }
.modal .actions { display: flex; gap: 10px; margin-top: 20px; justify-content: flex-end; flex-wrap: wrap; }

/* ---------- Summary ---------- */
.summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat-card {
  background: var(--surface); border-radius: var(--radius-md); padding: 16px;
  border: 1px solid var(--line); text-align: left;
  animation: card-in var(--dur-med) var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 70ms);
}
.stat-icon { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; background: var(--lang-accent-soft); color: var(--lang-accent); margin-bottom: 8px; }
.stat-card .val { font-family: var(--font-display); font-weight: 800; font-size: 1.9rem; color: var(--ink); line-height: 1.1; }
.stat-card .lbl { font-size: 0.8rem; color: var(--ink-soft); margin-top: 2px; }
.stat-card .val.stars { display: flex; gap: 4px; font-size: 1.2rem; }
.stat-card .val.stars .on { color: var(--gold); }
.stat-card .val.stars .off { color: var(--line); }
.levelup-card { display: flex; align-items: center; gap: 10px; margin-top: 16px; background: var(--gold-soft); border-color: #F0D99A; animation: pop-in var(--dur-med) var(--ease-spring) both; }
.levelup-card i { color: #C9931F; font-size: 1.2rem; }
.summary-actions { display: flex; gap: 10px; margin-top: 24px; justify-content: center; flex-wrap: wrap; }

/* ---------- Daily missions ---------- */
.mission-list { display: flex; flex-direction: column; gap: 10px; }
.mission { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--surface); border-radius: var(--radius-md); border: 1px solid var(--line); animation: card-in var(--dur-med) var(--ease-out) both; }
.mission.done { opacity: 0.62; text-decoration: line-through; }
.mission .check { width: 24px; height: 24px; border-radius: 7px; border: 2px solid var(--line); display: grid; place-items: center; color: #fff; background: var(--secondary); flex-shrink: 0; }
.mission .check i { font-size: 0.7rem; }
.mission .check.empty { background: transparent; color: transparent; }
.challenge-card { margin-top: 20px; text-align: left; }
.challenge-icon { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; background: var(--lang-accent-soft); color: var(--lang-accent); margin-bottom: 10px; }

/* ---------- Badges ---------- */
.badge-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (min-width: 720px) { .badge-grid { grid-template-columns: repeat(6, 1fr); } }
.badge-item {
  text-align: center; padding: 16px 8px; background: var(--surface);
  border-radius: var(--radius-md); border: 1px solid var(--line);
  animation: card-in var(--dur-med) var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 55ms);
}
.badge-item.locked { opacity: 0.42; filter: grayscale(1); }
.badge-item .icon {
  width: 44px; height: 44px; margin: 0 auto 8px; border-radius: 14px;
  display: grid; place-items: center; font-size: 1.1rem; color: #fff; background: var(--lang-accent);
}
.badge-item .name { font-size: 0.8rem; font-weight: 700; }

/* ---------- Settings row ---------- */
.settings-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 0; border-bottom: 1px solid var(--line); gap: 12px; }
.settings-label { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.settings-label i { color: var(--ink-mute); width: 18px; text-align: center; }

/* ---------- Empty / loading ---------- */
.empty { text-align: center; padding: 40px 20px; color: var(--ink-soft); }
.empty .icon { font-size: 2.4rem; margin-bottom: 10px; color: var(--ink-mute); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: var(--radius-pill);
  font-weight: 600; z-index: 70; box-shadow: var(--shadow-lg);
  animation: toast-in var(--dur-med) var(--ease-spring);
  max-width: calc(100vw - 40px);
}
.toast i { color: var(--gold); }

/* ---------- Motion keyframes ---------- */
@keyframes screen-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes card-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes opt-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes pill-in { from { opacity: 0; transform: scale(0.85); } to { opacity: 1; transform: scale(1); } }
@keyframes node-pop { from { opacity: 0; transform: scale(0.7); } to { opacity: 1; transform: scale(1); } }
@keyframes hero-pop { from { opacity: 0; transform: rotate(-10deg) scale(0.8); } to { opacity: 1; transform: rotate(-4deg) scale(1); } }
@keyframes bump { 0% { transform: scale(1); } 50% { transform: scale(1.25); } 100% { transform: scale(1); } }
@keyframes heart-shake { 0%,100% { transform: translateX(0); } 20% { transform: translateX(-4px); } 60% { transform: translateX(4px); } }
@keyframes play-pulse { 0% { transform: scale(1); box-shadow: 0 4px 0 var(--line); } 40% { transform: scale(1.05); box-shadow: 0 0 0 8px color-mix(in srgb, var(--lang-accent) 18%, transparent); } 100% { transform: scale(1); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* ---------- Focus ---------- */
:focus-visible { outline: 3px solid var(--lang-accent); outline-offset: 2px; border-radius: 6px; }

/* ---------- Small screens ---------- */
@media (max-width: 560px) {
  .topbar .actions .btn span { display: none; }
  .topbar .actions .btn { padding: 9px 11px; }
  .topbar .brand > span:last-child { max-width: 34vw; }
  .summary-grid { gap: 10px; }
}
@media (max-width: 420px) {
  .options.grid2 { grid-template-columns: 1fr; }
  .hero-orb { width: 84px; height: 84px; border-radius: 26px; }
  .hero-orb .mascot { width: 60px; height: 60px; font-size: 1.5rem; }
  .mem-card .mem-label { font-size: 0.72rem; padding: 4px; }
  .node { width: 62px; height: 62px; }
}
