:root {
  --bg: #f6f4ef;
  --card: #ffffff;
  --ink: #1f2328;
  --muted: #666a72;
  --line: #e3e0d8;
  --primary: #1b7b5b;
  --primary-dark: #135a42;
  --btn: #1b7b5b; /* button background with white text */
  --btn-shadow: #135a42;
  --bad-btn: #c13f3f;
  --primary-soft: #dff3ea;
  --bad: #c13f3f;
  --bad-soft: #fde6e6;
  --gold: #f2a91e; /* fills and stars */
  --gold-text: #8a5f12; /* gold-coloured text */
  --gold-soft: #fff1d3;
  --locked: #c9c6bf;
  --der: #2d69cb;
  --die: #c12e62;
  --das: #237d3b;
  --gem: #196cb7;
  --gem-soft: #e3f0fd;
  --hot: #ff7a1a;
  --hot-text: #aa5212;
  --radius: 16px;
  --shadow: 0 2px 0 rgba(0, 0, 0, 0.08);
  --font: 'Vazirmatn', Tahoma, 'Segoe UI', system-ui, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15181c;
    --card: #1f2329;
    --ink: #eceef1;
    --muted: #9aa1ab;
    --line: #333942;
    --primary: #2fb386;
    --primary-dark: #22906b;
    --primary-soft: #19382e;
    --bad: #ff6b6b;
    --bad-soft: #3d2023;
    --gold: #ffbf40;
    --gold-soft: #3a2f17;
    --locked: #464c55;
    --der: #6aa3ff;
    --die: #ff6fa0;
    --das: #5fd27f;
    --gem: #4dabf7;
    --gem-soft: #15283a;
    --hot: #ff922b;
    --hot-text: #ff922b;
    --gold-text: #ffbf40;
    --btn: #1c8160;
    --btn-shadow: #135a42;
    --bad-btn: #c13f3f;
    --shadow: 0 2px 0 rgba(0, 0, 0, 0.4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.6;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.de { direction: ltr; unicode-bidi: isolate; font-family: 'Segoe UI', system-ui, -apple-system, Roboto, Arial, sans-serif; }
.muted { color: var(--muted); }
.loading { padding: 40vh 16px; text-align: center; color: var(--muted); }

#app { max-width: 600px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; font-size: 19px; flex: 1; }
.spacer { flex: 1; }
.stat { display: inline-flex; align-items: center; gap: 4px; font-weight: 800; padding: 3px 10px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); border-bottom-width: 3px; font-size: 15px; line-height: 1.5; }
button.stat:active { transform: translateY(2px); border-bottom-width: 1px; }
.stat.fire { color: #e8590c; }
.stat.off { color: var(--muted); filter: grayscale(1); }
.stat.xp { color: var(--gold-text); }
.stat.gem { color: var(--gem); }
.stat.level { color: var(--primary); }
.stat .frz { font-size: 11px; margin-inline-start: 2px; }
.stat.bump { animation: bump .6s ease; }
@keyframes bump { 30% { transform: scale(1.3); } 60% { transform: scale(.95); } }

main.page { flex: 1; padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); }

/* ---------- Cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.goal { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.goal .ring { --p: 0; width: 56px; height: 56px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: conic-gradient(var(--gold) calc(var(--p) * 1%), var(--line) 0); }
.goal .ring span { width: 44px; height: 44px; border-radius: 50%; background: var(--card); display: grid; place-items: center; font-size: 20px; }
.goal h3, .review h3 { margin: 0; font-size: 16px; }
.goal p, .review p { margin: 0; color: var(--muted); font-size: 14px; }
.review { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.review .ico { font-size: 30px; }
.review > div { flex: 1; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 14px; padding: 12px 20px; font-weight: 800; font-size: 17px;
  background: var(--btn); color: #fff; box-shadow: 0 4px 0 var(--btn-shadow);
  transition: transform .05s, box-shadow .05s, filter .15s;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--primary-dark); }
.btn:disabled { background: var(--line); color: var(--muted); box-shadow: 0 4px 0 var(--locked); cursor: default; transform: none; }
.btn.block { width: 100%; }
.btn.ghost { background: var(--card); color: var(--ink); border: 2px solid var(--line); box-shadow: 0 3px 0 var(--line); }
.btn.bad { background: var(--bad-btn); box-shadow: 0 4px 0 #8f2b2b; }
.btn.small { padding: 8px 14px; font-size: 15px; }
.icon-btn { border: 0; background: transparent; font-size: 22px; padding: 6px; border-radius: 10px; line-height: 1; }
.icon-btn:hover { background: var(--line); }

/* ---------- Path ---------- */
.unit { margin: 8px 0 28px; }
.unit-head {
  border-radius: var(--radius); padding: 14px 16px; color: #fff; display: flex; align-items: center; gap: 12px;
  box-shadow: 0 4px 0 rgba(0,0,0,.18);
}
.unit-head .emoji { font-size: 34px; }
.unit-head h2 { margin: 0; font-size: 18px; }
.unit-head p { margin: 0; font-size: 14px; }
.nodes { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 22px 0 4px; }
.node-wrap { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.node {
  width: 76px; height: 72px; border-radius: 50%; border: 0; font-size: 30px; color: #fff;
  background: var(--unit-color, var(--primary)); box-shadow: 0 7px 0 rgba(0,0,0,.22);
  display: grid; place-items: center; position: relative; transition: transform .05s;
}
.node:active { transform: translateY(4px); box-shadow: 0 3px 0 rgba(0,0,0,.22); }
.node.locked { background: var(--locked); color: var(--muted); box-shadow: 0 7px 0 rgba(0,0,0,.12); }
.node.current { animation: pulse 1.6s infinite; width: 84px; height: 80px; }
.node.done { background: linear-gradient(180deg, color-mix(in srgb, var(--unit-color) 80%, #fff), var(--unit-color)); }
.node-label { font-size: 13px; color: var(--muted); font-weight: 600; text-align: center; max-width: 160px; }
@keyframes pulse { 0%,100% { outline: 6px solid transparent; } 50% { outline: 8px solid color-mix(in srgb, var(--unit-color, var(--primary)) 35%, transparent); } }

/* trail behind the nodes */
.nodes { position: relative; }
.node-wrap { position: relative; z-index: 1; }
.trail { position: absolute; inset: 0; z-index: 0; pointer-events: none; overflow: visible; }
.trail path { fill: none; stroke: var(--unit-color, var(--primary)); stroke-width: 7; stroke-linecap: round; stroke-dasharray: 0 15; opacity: .35; }

/* stars under finished lessons */
.node-stars { display: flex; gap: 1px; direction: ltr; margin-top: 2px; line-height: 1; }
.node-stars i { font-style: normal; font-size: 15px; color: var(--locked); }
.node-stars i.on { color: var(--gold); text-shadow: 0 1px 0 rgba(0,0,0,.15); }

/* speech bubble above the current node */
.bubble { position: absolute; top: -40px; left: 50%; transform: translateX(-50%); white-space: nowrap; z-index: 2;
  background: var(--unit-color, var(--btn)); color: #fff; border-radius: 12px;
  padding: 2px 12px; font-weight: 800; font-size: 14px; animation: hover 1.4s ease-in-out infinite; }
.bubble::after { content: ''; position: absolute; bottom: -5px; left: 50%; width: 10px; height: 10px; background: inherit;
  transform: translateX(-50%) rotate(45deg); z-index: -1; }
.bubble.gold { background: var(--gold); color: #3b1d00; }
@keyframes hover { 50% { transform: translate(-50%, -5px); } }
.node-wrap.has-bubble { margin-top: 30px; }

/* mascot */
.mascot { width: 64px; height: 64px; display: block; }
.mascot .m-shadow { fill: rgba(0,0,0,.12); }
.mascot .m-body { fill: #c47a35; stroke: #8f5220; stroke-width: 3; }
.mascot .m-cut { fill: none; stroke: #e9a868; stroke-width: 4; stroke-linecap: round; }
.mascot .m-salt { fill: #fff; }
.mascot .m-eye { fill: #3b2412; }
.mascot .m-cheek { fill: #ff8a8a; opacity: .6; }
.mascot .m-mouth { fill: none; stroke: #3b2412; stroke-width: 3; stroke-linecap: round; }
.mascot .m-bob { animation: bob 2.2s ease-in-out infinite; transform-origin: 50% 90%; }
.mascot.cheer { width: 110px; height: 110px; }
.mascot.cheer .m-bob { animation: jump .9s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-4px) rotate(-3deg); } }
@keyframes jump { 0%,100% { transform: translateY(0) scale(1, 1); } 15% { transform: translateY(0) scale(1.08, .9); } 50% { transform: translateY(-14px) scale(.96, 1.05); } }
.mascot-spot { position: absolute; top: 4px; }
.mascot-spot.right { left: calc(50% + 56px); }
.mascot-spot.left { right: calc(50% + 56px); }

/* chest nodes */
.node.chest { font-size: 34px; border-radius: 22px; }
.node.chest.locked { filter: grayscale(.8); }
.node.chest.ready { background: linear-gradient(180deg, #ffd43b, var(--gold)); animation: wiggle 1.6s ease-in-out infinite; box-shadow: 0 7px 0 #c47f00, 0 0 0 6px color-mix(in srgb, var(--gold) 30%, transparent); }
.node.chest.opened { background: var(--card); border: 2px solid var(--line); box-shadow: 0 5px 0 var(--line); }
@keyframes wiggle { 0%,60%,100% { transform: rotate(0); } 70% { transform: rotate(-8deg); } 80% { transform: rotate(8deg); } 90% { transform: rotate(-4deg); } }

/* unit header progress */
.grow { flex: 1; min-width: 0; }
.unit-bar { height: 6px; background: rgba(255,255,255,.3); border-radius: 999px; margin-top: 6px; overflow: hidden; }
.unit-bar > div { height: 100%; background: #fff; border-radius: 999px; }
.unit-count { font-weight: 800; font-size: 15px; background: rgba(0,0,0,.15); border-radius: 999px; padding: 2px 10px; }

/* German levels */
.lv-badge { display: inline-grid; place-items: center; min-width: 46px; height: 46px; border-radius: 14px; font-weight: 800; font-size: 17px; direction: ltr;
  color: #fff; background: linear-gradient(135deg, var(--btn), #2d69cb); box-shadow: 0 3px 0 rgba(0,0,0,.18); flex: none; }
.level-head { background: var(--card); border: 2px solid var(--line); border-radius: 20px; padding: 14px; margin: 6px 0 18px; box-shadow: var(--shadow); }
.level-head.complete { border-color: var(--gold); background: linear-gradient(180deg, var(--gold-soft), var(--card)); }
.lv-top { display: flex; align-items: center; gap: 12px; }
.lv-top h2 { margin: 0; font-size: 18px; }
.lv-top p { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.5; }
.lv-pct { font-weight: 800; font-size: 20px; color: var(--primary); }
.lv-bar { height: 12px; background: var(--line); border-radius: 999px; overflow: hidden; margin: 10px 0 8px; }
.lv-bar.small { height: 8px; margin: 4px 0; }
.lv-bar > div { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--primary), #2f6fd6); transition: width 1s cubic-bezier(.2,.8,.2,1); min-width: 6px; }
.lv-stats { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--muted); font-weight: 600; }
.levels-later { display: flex; flex-direction: column; gap: 10px; margin: 8px 0 20px; }
.level-soon { display: flex; align-items: center; gap: 12px; padding: 12px; border: 2px dashed var(--line); border-radius: 18px; }
.level-soon .lv-badge, .level-row.soon .lv-badge { background: var(--card); color: var(--muted); border: 2px dashed var(--line); box-shadow: none; }
.level-soon h3 { margin: 0; font-size: 15px; }
.level-soon p { margin: 0; font-size: 13px; color: var(--muted); }
.level-soon > span { font-size: 13px; color: var(--muted); white-space: nowrap; }
.level-row { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 16px; border: 2px solid var(--line); }
.level-row.cur { border-color: var(--primary); background: var(--primary-soft); }
.level-row h3 { margin: 0; font-size: 15px; }
.level-row h3 small { color: var(--primary); }
.level-row p { margin: 0; font-size: 13px; color: var(--muted); }
.level-row .lv-pct { font-size: 16px; }

/* shop */
.shop-item { display: flex; align-items: center; gap: 12px; margin: 14px 0; padding: 12px; border: 2px solid var(--line); border-radius: 16px; }
.shop-ico { font-size: 38px; }
.shop-item h3 { margin: 0; font-size: 16px; }
.shop-item p { margin: 0; font-size: 13px; color: var(--muted); }
.gem-count { color: var(--gem); }

/* chest opening */
.chest-open { text-align: center; padding: 10px 0; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.chest-big { font-size: 96px; line-height: 1.1; }
.chest-big.shaking { animation: chestshake .35s ease-in-out infinite; }
.chest-big.burst { animation: burst .6s cubic-bezier(.2,1.6,.4,1); }
.chest-reward { font-size: 34px; font-weight: 800; color: var(--gem); margin: 0; }
.hidden { display: none !important; }
@keyframes chestshake { 25% { transform: rotate(-9deg) scale(1.03); } 75% { transform: rotate(9deg) scale(1.03); } }
@keyframes burst { from { transform: scale(.2); opacity: 0; } }
.modal-stars { color: var(--gold-text); font-size: 18px; letter-spacing: 2px; }

/* ---------- Bottom nav ---------- */
.nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: flex; justify-content: center; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-inner { display: flex; width: 100%; max-width: 600px; }
.nav button { flex: 1; border: 0; background: transparent; padding: 8px 0 10px; display: flex; flex-direction: column; align-items: center; gap: 0; font-size: 12px; color: var(--muted); font-weight: 600; }
.nav button .i { font-size: 22px; line-height: 1.3; }
.nav button.on { color: var(--primary); }
.nav button.on .i { transform: scale(1.12); }
.nav-brand { display: none; }

/* Wide screens: the navigation becomes a sidebar on the right (start side in RTL). */
@media (min-width: 900px) {
  body.with-nav { padding-right: 230px; }
  .nav { top: 0; bottom: 0; left: auto; right: 0; width: 230px; border-top: 0; border-left: 1px solid var(--line); align-items: flex-start; padding: 0; }
  .nav-inner { flex-direction: column; gap: 4px; padding: 20px 14px; }
  .nav-brand { display: block; font-weight: 800; font-size: 20px; padding: 4px 10px 16px; color: var(--primary); }
  .nav button { flex: none; flex-direction: row; gap: 12px; justify-content: flex-start; padding: 10px 14px; font-size: 16px; border-radius: 14px; border: 2px solid transparent; }
  .nav button:hover { background: var(--bg); }
  .nav button.on { background: var(--primary-soft); border-color: color-mix(in srgb, var(--primary) 40%, transparent); }
  main.page { padding-bottom: 32px; }
  .toast { bottom: 30px; }
}

/* shop page */
.gem-card { display: flex; align-items: center; gap: 14px; background: linear-gradient(135deg, var(--gem-soft), var(--card)); }
.gem-big { font-size: 46px; }
.gem-card .gem-count { font-size: 32px; font-weight: 800; }
.earn { display: flex; flex-direction: column; gap: 0; padding: 4px 16px; }
.earn > div { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.earn > div:last-child { border-bottom: 0; }
.earn b { color: var(--gem); white-space: nowrap; }
.shop-item.card { margin: 0; }

/* ---------- Modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 30; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.modal { background: var(--card); width: 100%; max-width: 600px; border-radius: 22px 22px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); max-height: 88vh; overflow: auto; animation: up .2s ease-out; }
.modal h2 { margin: 0 0 4px; font-size: 21px; }
.modal .row { display: flex; gap: 10px; margin-top: 16px; }
.modal .row .btn { flex: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip { background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; font-size: 14px; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: .5; } }

/* ---------- Tip ---------- */
.tip h3 { margin: 0 0 8px; }
.tip p { margin: 0 0 10px; }
.examples { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.example { display: flex; justify-content: space-between; align-items: center; gap: 12px; background: var(--bg); border-radius: 12px; padding: 8px 12px; }
.example .de { font-weight: 700; }

/* ---------- Gender colours ---------- */
.g-der { color: var(--der); }
.g-die { color: var(--die); }
.g-das { color: var(--das); }

/* ---------- Lesson ---------- */
.lesson { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
.lesson-top { display: flex; align-items: center; gap: 12px; padding: calc(12px + env(safe-area-inset-top)) 16px 8px; }
.bar { flex: 1; height: 16px; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar > div { height: 100%; background: var(--primary); border-radius: 999px; transition: width .35s ease; min-width: 8px; }
.ex { flex: 1; padding: 12px 16px 24px; display: flex; flex-direction: column; gap: 18px; }
.ex h2 { margin: 0; font-size: 21px; }
.prompt { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.prompt .big { font-size: 28px; font-weight: 800; }
.speak { border: 0; background: var(--btn); color: #fff; border-radius: 14px; width: 52px; height: 52px; font-size: 24px; box-shadow: 0 4px 0 var(--btn-shadow); flex: none; }
.speak.slow { background: var(--card); color: var(--ink); border: 2px solid var(--line); box-shadow: 0 3px 0 var(--line); width: 44px; height: 44px; font-size: 20px; }
.speak.huge { width: 110px; height: 110px; font-size: 48px; border-radius: 26px; }
.listen-row { display: flex; align-items: center; justify-content: center; gap: 16px; padding: 16px 0; }

.options { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 480px) { .options.two { grid-template-columns: 1fr 1fr; } }
.opt {
  text-align: start; border: 2px solid var(--line); border-bottom-width: 4px; border-radius: 14px; background: var(--card);
  padding: 12px 14px; font-size: 18px; display: flex; align-items: center; gap: 10px; min-height: 56px;
}
.opt .k { font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 0 6px; font-weight: 700; }
.opt.sel { border-color: var(--primary); background: var(--primary-soft); }
.opt.right { border-color: var(--primary); background: var(--primary-soft); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt:disabled { cursor: default; }

/* intro card */
.intro { text-align: center; padding: 18px; }
.intro .emoji { font-size: 72px; line-height: 1.2; }
.intro .word { font-size: 34px; font-weight: 800; margin: 6px 0; }
.intro .fa { font-size: 22px; }
.badge-new { display: inline-block; background: var(--gold-soft); color: #9a5b00; border-radius: 999px; padding: 0 12px; font-weight: 800; font-size: 14px; }
@media (prefers-color-scheme: dark) { .badge-new { color: var(--gold); } }

/* match */
.match { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.match .col { display: flex; flex-direction: column; gap: 10px; }
.match .opt { justify-content: center; text-align: center; min-height: 58px; }
.match .opt.gone { opacity: .35; border-color: var(--line); background: var(--card); }
.match .opt.shake { animation: shake .3s; border-color: var(--bad); background: var(--bad-soft); }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

/* article */
.articles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.articles .opt { justify-content: center; font-weight: 800; font-size: 22px; }

/* typing */
.type-input { width: 100%; font-size: 22px; padding: 14px; border-radius: 14px; border: 2px solid var(--line); background: var(--card); direction: ltr; text-align: left; }
.type-input:focus { outline: none; border-color: var(--primary); }
.special { display: flex; gap: 8px; flex-wrap: wrap; direction: ltr; }
.special button { border: 2px solid var(--line); background: var(--card); border-radius: 10px; min-width: 44px; height: 44px; font-size: 20px; font-weight: 700; }

/* word bank */
.answer-line { min-height: 64px; border-bottom: 2px solid var(--line); display: flex; flex-wrap: wrap; gap: 8px; align-content: flex-start; padding: 8px 0; }
.answer-line.ltr { direction: ltr; }
.bank { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; padding-top: 8px; }
.bank.ltr { direction: ltr; }
.tile { border: 2px solid var(--line); border-bottom-width: 4px; border-radius: 12px; background: var(--card); padding: 6px 14px; font-size: 18px; min-height: 46px; }
.tile.used { visibility: hidden; }
.sentence-fa { font-size: 22px; font-weight: 700; }
.sentence-de { font-size: 22px; font-weight: 700; }

/* feedback footer */
.foot { border-top: 2px solid var(--line); padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); background: var(--bg); position: sticky; bottom: 0; }
.foot.ok { background: var(--primary-soft); border-color: transparent; }
.foot.no { background: var(--bad-soft); border-color: transparent; }
.foot .msg { margin-bottom: 12px; }
.foot .msg strong { font-size: 20px; display: block; }
.foot.ok .msg strong { color: var(--primary); }
.foot.no .msg strong { color: var(--bad); }
.foot .msg .ans { font-size: 18px; font-weight: 700; }
.foot.ok .btn.next { background: var(--btn); }
.foot.no .btn.next { background: var(--bad-btn); box-shadow: 0 4px 0 #8f2b2b; }
.foot .note { font-size: 15px; }

/* complete screen */
.done-screen { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px 16px; gap: 14px; }
.done-screen .big { font-size: 80px; line-height: 1; }
.done-screen h1 { margin: 0; font-size: 28px; }
.done-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 100%; margin: 10px 0; }
.done-stats .card { padding: 10px; }
.done-stats b { display: block; font-size: 22px; }
.done-stats span { font-size: 13px; color: var(--muted); }

/* words list */
.search { width: 100%; padding: 12px 14px; border-radius: 14px; border: 2px solid var(--line); background: var(--card); margin-bottom: 14px; }
.wgroup h3 { margin: 18px 0 8px; font-size: 16px; color: var(--muted); }
.wrow { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 6px; }
.wrow .em { font-size: 22px; width: 30px; text-align: center; }
.wrow .txt { flex: 1; min-width: 0; }
.wrow .txt .de { font-weight: 700; display: block; text-align: right; }
.wrow .txt .fa { font-size: 14px; color: var(--muted); }
.strength { display: flex; gap: 2px; direction: ltr; }
.strength i { width: 5px; height: 16px; border-radius: 2px; background: var(--line); }
.strength i.on { background: var(--primary); }
.wrow.unseen { background: transparent; border-style: dashed; } /* not learned yet: outlined, still readable */

/* settings */
.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.setting:last-child { border-bottom: 0; }
.setting label { flex: 1; }
.setting small { display: block; color: var(--muted); font-size: 13px; }
.setting select { padding: 6px 10px; border-radius: 10px; border: 2px solid var(--line); background: var(--card); }
.switch { appearance: none; width: 50px; height: 30px; border-radius: 999px; background: var(--line); position: relative; flex: none; cursor: pointer; transition: background .2s; }
.switch::after { content: ''; position: absolute; top: 3px; right: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: right .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch:checked { background: var(--primary); }
.switch:checked::after { right: 23px; }
.section-title { margin: 22px 0 8px; font-size: 15px; color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: 10px; }
.toast { position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 8px 16px; border-radius: 12px; z-index: 50; font-size: 15px; animation: fade .2s; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

/* ---------- sign-in ---------- */
.auth { flex: 1; display: flex; flex-direction: column; gap: 16px; padding: calc(32px + env(safe-area-inset-top)) 16px 32px; justify-content: center; }
.auth-hero { text-align: center; }
.auth-hero img { border-radius: 18px; }
.auth-hero h1 { margin: 8px 0 0; font-size: 28px; }
.auth-hero p { margin: 0; color: var(--muted); }
.seg { display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 4px; margin-bottom: 16px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 8px; border-radius: 9px; font-weight: 700; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 15px; }
.field input { font-size: 17px; padding: 12px 14px; border-radius: 12px; border: 2px solid var(--line); background: var(--card); text-align: left; }
.field input:focus { outline: none; border-color: var(--primary); }
.err { color: var(--bad); margin: 0; min-height: 1.2em; font-size: 15px; }
.linkbtn { border: 0; background: transparent; color: var(--primary); font-weight: 700; padding: 8px; }

/* ======================= game feel ======================= */
/* progress bar shine + "hot" during a combo */
.bar > div { position: relative; overflow: hidden; }
.bar > div::after { content: ''; position: absolute; top: 3px; left: 8px; right: 8px; height: 4px; border-radius: 999px; background: rgba(255,255,255,.35); }
.bar.hot > div { background: linear-gradient(90deg, var(--gold), var(--hot)); }

/* combo chip */
.combo { display: inline-flex; align-items: center; gap: 2px; font-weight: 800; color: var(--muted); opacity: .35; transition: transform .2s, opacity .2s; direction: ltr; }
.combo b { font-size: 15px; }
.combo.on { opacity: 1; color: var(--hot-text); animation: bump .5s ease; }
.combo.big { transform: scale(1.2); text-shadow: 0 0 10px color-mix(in srgb, var(--hot) 50%, transparent); }

/* answer feedback */
.pop { animation: pop .35s cubic-bezier(.2,1.8,.4,1); }
@keyframes pop { 40% { transform: scale(1.06); } }
.shake { animation: shake .3s; }
.opt { transition: transform .08s; }
.opt:not(:disabled):active { transform: translateY(2px); border-bottom-width: 2px; }
.tile:active { transform: translateY(2px); }
.foot.ok, .foot.no { animation: slideup .22s ease-out; }
@keyframes slideup { from { transform: translateY(30px); opacity: .4; } }

.float-text { position: fixed; z-index: 60; transform: translate(-50%, 0); font-weight: 800; font-size: 22px; color: var(--primary);
  pointer-events: none; animation: floatup 1.05s ease-out forwards; text-shadow: 0 2px 0 var(--card); }
.float-text.hot { color: var(--hot-text); font-size: 26px; }
@keyframes floatup { from { opacity: 0; transform: translate(-50%, 0) scale(.6); } 20% { opacity: 1; transform: translate(-50%, -16px) scale(1.15); } to { opacity: 0; transform: translate(-50%, -70px) scale(1); } }

.combo-banner { position: fixed; top: 22%; left: 50%; z-index: 60; pointer-events: none; white-space: nowrap;
  background: var(--btn); color: #fff; font-weight: 800; font-size: 22px; padding: 10px 22px; border-radius: 18px;
  box-shadow: 0 6px 0 var(--primary-dark), 0 12px 30px rgba(0,0,0,.2); animation: bannerin 1.5s ease forwards; }
.combo-banner.hot { color: #3b1d00; background: linear-gradient(135deg, #ffd43b, var(--gold)); box-shadow: 0 6px 0 #b85500, 0 12px 30px rgba(0,0,0,.2); }
@keyframes bannerin {
  0% { opacity: 0; transform: translate(-50%, 20px) scale(.5); }
  15% { opacity: 1; transform: translate(-50%, 0) scale(1.1); }
  25% { transform: translate(-50%, 0) scale(1); }
  80% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -20px) scale(.9); }
}

/* confetti */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 70; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 9px; height: 14px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { transform: translate(var(--dx), 110vh) rotate(var(--rot)); } }

/* done screen */
.done-screen { gap: 10px; }
.stars-big { display: flex; gap: 10px; direction: ltr; }
.stars-big i { font-style: normal; font-size: 54px; line-height: 1; color: var(--locked); }
.stars-big i.on { color: var(--gold); animation: starin .5s cubic-bezier(.2,1.8,.4,1) both; text-shadow: 0 3px 0 #c47f00; }
.stars-big i:nth-child(2) { font-size: 66px; transform: translateY(-8px); }
.stars-big i.on:nth-child(2) { animation-name: starin2; }
@keyframes starin { from { transform: scale(0) rotate(-90deg); opacity: 0; } }
@keyframes starin2 { from { transform: translateY(-8px) scale(0) rotate(-90deg); opacity: 0; } to { transform: translateY(-8px); } }
.new-best { margin: 0; font-weight: 800; color: var(--gold-text); }
.c-gold { color: var(--gold-text); }
.c-gem { color: var(--gem); }
.c-primary { color: var(--primary); }
.done-lines p { margin: 2px 0; }
.streak-line { font-weight: 700; }
.flame { display: inline-block; animation: flame .8s ease-in-out infinite alternate; }
@keyframes flame { from { transform: scale(1) rotate(-6deg); } to { transform: scale(1.3) rotate(6deg); } }
.done-level { display: flex; align-items: center; gap: 10px; width: 100%; font-weight: 800; color: var(--primary); }
.done-level .lv-bar { margin: 0; }
.done-level .lv-badge { min-width: 40px; height: 40px; font-size: 15px; }

/* certificate */
.cert { text-align: center; border: 3px double var(--gold); border-radius: 18px; padding: 18px 14px; background: linear-gradient(180deg, var(--gold-soft), var(--card)); }
.cert .seal { font-size: 54px; line-height: 1.1; }
.cert h2 { margin: 6px 0; }
.cert .lv-badge { min-width: 64px; height: 64px; font-size: 24px; margin: 6px 0; }
.cert p { margin: 4px 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .combo-banner { animation: none !important; transform: translate(-50%, 0); } /* still shown, just not moving */
}
