/* static weights (cut from the variable font): render the same in every engine */
@font-face { font-family: "Nunito"; src: url("fonts/Nunito-400.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Nunito"; src: url("fonts/Nunito-600.ttf") format("truetype"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Nunito"; src: url("fonts/Nunito-700.ttf") format("truetype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Nunito"; src: url("fonts/Nunito-800.ttf") format("truetype"); font-weight: 800; font-display: swap; }
@font-face { font-family: "Nunito"; src: url("fonts/Nunito-900.ttf") format("truetype"); font-weight: 900; font-display: swap; }

:root {
  --bg: #ffffff;
  --fg: #4b4b4b;
  --strong: #3c3c3c;
  --muted: #777777;
  --faint: #afafaf;
  --line: #e5e5e5;
  --hover: #f7f7f7;
  --green: #58cc02; --green-d: #58a700; --green-l: #d7ffb8; --green-t: #58a700;
  --red: #ff4b4b; --red-d: #ea2b2b; --red-l: #ffdfe0; --red-t: #ea2b2b;
  --blue: #1cb0f6; --blue-d: #1899d6; --blue-l: #ddf4ff; --blue-b: #84d8ff;
  --gold: #ffc800; --gold-d: #e5a400;
  --orange: #ff9600;
  --purple: #ce82ff;
  --off: #e5e5e5; --off-d: #cdcdcd; --off-fg: #afafaf;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131f24;
    --fg: #dce6ec;
    --strong: #f1f7fb;
    --muted: #8fa3ad;
    --faint: #52656d;
    --line: #37464f;
    --hover: #1b2b32;
    --green-l: #1d3320; --green-t: #79d634;
    --red-l: #3a2226; --red-t: #ff7a7a;
    --blue-l: #17313f; --blue-b: #1f6f99;
    --off: #37464f; --off-d: #26343a; --off-fg: #6b7f88;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html { -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; }
body {
  font-family: "Nunito", ui-rounded, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--fg);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }
h1, h2, h3 { color: var(--strong); margin: 0; }
[hidden] { display: none !important; }
.loading { display: grid; place-items: center; height: 100vh; font-size: 80px; animation: bird 1.2s ease-in-out infinite; }

/* ---------------------------------------------------------------- buttons */
.btn {
  --c: var(--green); --cd: var(--green-d); --t: #fff;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-width: 150px; height: 50px; padding: 0 24px;
  border: 0; border-radius: 16px;
  background: var(--c); color: var(--t);
  box-shadow: 0 4px 0 var(--cd);
  font-weight: 800; font-size: 15px; letter-spacing: .06em; text-transform: uppercase;
  cursor: pointer; user-select: none;
  transition: filter .15s;
}
.btn:hover:not(:disabled) { filter: brightness(1.07); }
.btn:active:not(:disabled) { transform: translateY(4px); box-shadow: none; }
.btn:disabled { --c: var(--off); --cd: var(--off); --t: var(--off-fg); cursor: default; }
.btn:focus-visible { outline: 3px solid var(--blue-b); outline-offset: 3px; }
.btn.red { --c: var(--red); --cd: var(--red-d); }
.btn.blue { --c: var(--blue); --cd: var(--blue-d); }
.btn.white { --c: #fff; --cd: #d9d9d9; }
.btn.ghost { --c: transparent; --cd: var(--line); --t: var(--faint); border: 2px solid var(--line); }
.btn.ghost:hover { --c: var(--hover); filter: none; }
.btn.outline { --c: var(--bg); --cd: var(--line); --t: var(--blue); border: 2px solid var(--line); }
.btn.outline:hover { --c: var(--hover); filter: none; }
.btn.wide { width: 100%; }
.btn.small { height: 40px; min-width: 0; padding: 0 16px; font-size: 13px; border-radius: 12px; }

.link-btn {
  background: none; border: 0; padding: 10px; cursor: pointer;
  color: var(--blue); font-weight: 800; font-size: 14px; letter-spacing: .06em; text-transform: uppercase;
}
.link-btn.danger { color: var(--red); }

.icon-btn {
  display: inline-grid; place-items: center; padding: 8px; border: 0; border-radius: 12px;
  background: none; color: var(--faint); cursor: pointer;
}
.icon-btn:hover { background: var(--hover); }
.icon-btn svg { width: 24px; height: 24px; }

.play-btn {
  display: inline-grid; place-items: center; flex-shrink: 0;
  width: 46px; height: 46px; border: 0; border-radius: 14px;
  background: var(--blue); color: #fff; box-shadow: 0 4px 0 var(--blue-d); cursor: pointer;
}
.play-btn:hover { filter: brightness(1.07); }
.play-btn:active { transform: translateY(4px); box-shadow: none; }
.play-btn svg { width: 26px; height: 26px; }
.play-btn.small { width: 36px; height: 36px; border-radius: 11px; box-shadow: 0 3px 0 var(--blue-d); }
.play-btn.small svg { width: 20px; height: 20px; }
.play-btn.small .turtle { font-size: 18px; }
.play-btn.big { width: 128px; height: 128px; border-radius: 26px; box-shadow: 0 6px 0 var(--blue-d); }
.play-btn.big svg { width: 60px; height: 60px; }
.play-btn.turtle { width: 76px; height: 76px; border-radius: 20px; }
.play-btn .turtle { font-size: 36px; line-height: 1; }

/* ------------------------------------------------------------------- home */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 24px; background: var(--bg); border-bottom: 2px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 6px; font-size: 30px; font-weight: 900; color: var(--green); letter-spacing: -.02em; }
.brand-bird { font-size: 32px; }
.stats { display: flex; align-items: center; gap: 4px; }
.stat { display: flex; align-items: center; gap: 4px; padding: 6px 10px; border-radius: 12px; font-size: 17px; font-weight: 800; }
.stat.streak { color: var(--orange); }
.stat.streak.off { color: var(--faint); filter: grayscale(1); }
.stat.xp { color: var(--gold-d); }

.home-grid {
  display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 48px;
  max-width: 1080px; margin: 0 auto; padding: 28px 24px;
}
.side { position: sticky; top: 92px; align-self: start; display: flex; flex-direction: column; gap: 16px; }
.card { border: 2px solid var(--line); border-radius: 16px; padding: 18px 20px; }
.card h3 { font-size: 19px; margin-bottom: 10px; }
.card p { margin: 0 0 14px; color: var(--muted); line-height: 1.4; }
.goal-row { display: flex; align-items: center; gap: 10px; font-weight: 800; color: var(--muted); }
.meter { flex: 1; height: 16px; border-radius: 99px; background: var(--off); overflow: hidden; }
.meter > div { position: relative; height: 100%; border-radius: 99px; background: var(--gold); transition: width .6s; }
.meter > div::after, .bar-fill::after {
  content: ""; position: absolute; left: 8px; right: 8px; top: 4px; height: 4px;
  border-radius: 99px; background: rgba(255, 255, 255, .35);
}
.week { display: flex; justify-content: space-between; align-items: flex-end; gap: 6px; margin-top: 16px; height: 74px; }
.week div { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; height: 100%; }
.week i { width: 100%; max-width: 26px; min-height: 4px; border-radius: 6px; background: var(--off); }
.week i.on { background: var(--gold); }
.week span { font-size: 12px; font-weight: 800; color: var(--faint); }
.week .today span { color: var(--gold-d); }
.status-line { display: flex; align-items: flex-start; gap: 8px; margin: 4px 0; font-size: 14px; color: var(--muted); line-height: 1.35; }
.dot { flex-shrink: 0; width: 10px; height: 10px; margin-top: 4px; border-radius: 50%; background: var(--faint); }
.dot.ok { background: var(--green); }
.dot.loading { background: var(--gold); animation: pulse 1s ease-in-out infinite; }
.dot.error { background: var(--red); }
@keyframes pulse { 50% { opacity: .3; } }

/* path */
.path { display: flex; flex-direction: column; align-items: center; padding-bottom: 140px; }
.section-banner {
  width: 100%; max-width: 620px; margin: 40px 0 44px; padding: 16px 22px;
  border-radius: 16px; background: var(--c); color: #fff; box-shadow: 0 4px 0 var(--cd);
}
.section-banner:first-child { margin-top: 0; }
.section-banner small { display: block; font-size: 13px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; opacity: .85; }
.section-banner b { font-size: 23px; font-weight: 900; }
.node-wrap { position: relative; display: flex; flex-direction: column; align-items: center; margin-bottom: 22px; }
.node-wrap.open { z-index: 20; }
.node-holder { position: relative; display: grid; place-items: center; width: 100px; height: 100px; }
.ring { position: absolute; inset: 0; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 8; }
.ring .track { stroke: var(--off); }
.ring .fill { stroke: var(--c); stroke-linecap: round; }
.node {
  position: relative; top: -4px;
  display: grid; place-items: center; width: 72px; height: 66px;
  border: 0; border-radius: 50%; background: var(--c); box-shadow: 0 7px 0 var(--cd);
  font-size: 30px; cursor: pointer; transition: filter .15s;
}
.node:hover { filter: brightness(1.08); }
.node:active { transform: translateY(6px); box-shadow: 0 1px 0 var(--cd); }
.node.fresh { background: var(--off); box-shadow: 0 7px 0 var(--off-d); }
.node.fresh .node-emoji { filter: grayscale(1); opacity: .5; }
.node-label { max-width: 170px; margin-top: 4px; font-size: 14px; font-weight: 800; line-height: 1.2; color: var(--muted); text-align: center; }
.node-wrap.current .node-label { color: var(--strong); }
.start-tip {
  position: absolute; top: -40px; z-index: 2; padding: 6px 12px; white-space: nowrap;
  border: 2px solid var(--line); border-radius: 12px; background: var(--bg);
  font-size: 14px; font-weight: 900; letter-spacing: .06em; color: var(--c);
  animation: bob 1.2s ease-in-out infinite;
}
.start-tip::after {
  content: ""; position: absolute; left: 50%; bottom: -8px; width: 12px; height: 12px;
  background: var(--bg); border-right: 2px solid var(--line); border-bottom: 2px solid var(--line);
  transform: translateX(-50%) rotate(45deg);
}
@keyframes bob { 50% { transform: translateY(-6px); } }
.popover {
  --pc: var(--c); /* resolved here, so the white button below can use the unit colour */
  position: absolute; top: 132px; width: 300px; padding: 16px; z-index: 5;
  border-radius: 16px; background: var(--c); color: #fff; box-shadow: 0 4px 0 var(--cd);
  animation: pop .15s ease-out;
}
.popover::before {
  content: ""; position: absolute; top: -7px; left: 50%; width: 16px; height: 16px;
  background: var(--c); border-radius: 3px; transform: translateX(-50%) rotate(45deg);
}
.pop-link {
  display: block; width: 100%; margin-top: 10px; padding: 6px; border: 0; background: none; cursor: pointer;
  color: #fff; font-size: 14px; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; opacity: .9;
}
.pop-link:hover { opacity: 1; }
.pop-title { font-size: 19px; font-weight: 900; }
.pop-sub { margin: 4px 0 14px; font-weight: 700; opacity: .9; }
.popover .btn.white { --t: var(--pc); }
@keyframes pop { from { transform: scale(.9); opacity: 0; } }

@media (max-width: 920px) {
  .home-grid { grid-template-columns: minmax(0, 1fr); gap: 20px; padding: 16px; }
  .side { position: static; order: -1; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
  .side .week, .side #status-card { display: none; }
  .side .card { padding: 14px 16px; }
  .side .card p { margin-bottom: 10px; font-size: 15px; }
  .topbar { padding: 8px 16px; }
}

/* ----------------------------------------------------------------- lesson */
.lesson { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.lesson-top {
  display: flex; align-items: center; gap: 14px;
  width: 100%; max-width: 1040px; margin: 0 auto; padding: 24px 24px 8px;
}
.bar { flex: 1; height: 16px; border-radius: 99px; background: var(--off); overflow: hidden; }
.bar-fill { position: relative; width: 0; height: 100%; border-radius: 99px; background: var(--green); transition: width .45s cubic-bezier(.3, .9, .4, 1); }
.combo {
  min-width: 0; white-space: nowrap; font-size: 15px; font-weight: 900; color: var(--orange);
  opacity: 0; transform: scale(.7); transition: .25s;
}
.combo.on { opacity: 1; transform: none; }
.lesson-body { flex: 1; display: flex; overflow-y: auto; padding: 16px 24px 32px; }
.ex { width: 100%; max-width: 620px; margin: auto; display: flex; flex-direction: column; }
.fade-in { animation: fadein .25s ease-out; }
@keyframes fadein { from { opacity: 0; transform: translateY(10px); } }
.ex-title { margin-bottom: 26px; font-size: 30px; font-weight: 800; }
.badge-new { margin-bottom: 6px; font-size: 14px; font-weight: 900; letter-spacing: .08em; color: var(--purple); }

.speech { display: flex; align-items: center; gap: 14px; margin-bottom: 30px; }
.mascot { flex-shrink: 0; font-size: 84px; line-height: 1; user-select: none; transform-origin: bottom center; animation: bird 3s ease-in-out infinite; }
@keyframes bird { 0%, 100% { transform: none; } 50% { transform: rotate(-5deg) translateY(-3px); } }
.bubble {
  position: relative; display: flex; align-items: center; gap: 12px;
  padding: 14px 18px; border: 2px solid var(--line); border-radius: 18px;
  font-size: 19px; line-height: 1.35; color: var(--strong);
}
.bubble::before {
  content: ""; position: absolute; left: -10px; top: 50%; width: 16px; height: 16px;
  background: var(--bg); border-left: 2px solid var(--line); border-bottom: 2px solid var(--line);
  transform: translateY(-50%) rotate(45deg);
}
/* word hints: dashed underline, Polish meaning on hover / tap */
.hint { position: relative; border-bottom: 2px dashed var(--faint); cursor: help; outline: none; }
.hint:hover, .hint:focus-visible, .hint.show { border-bottom-color: var(--blue); }
.hint::after {
  content: attr(data-gloss);
  position: absolute; left: 50%; bottom: calc(100% + 8px); z-index: 25;
  transform: translate(-50%, 4px); opacity: 0; pointer-events: none;
  width: max-content; max-width: 260px; padding: 7px 11px;
  border: 2px solid var(--line); border-radius: 12px; background: var(--bg); box-shadow: 0 4px 12px rgba(0, 0, 0, .12);
  color: var(--strong); font-size: 15px; font-weight: 700; line-height: 1.3; text-align: center; white-space: normal;
  transition: opacity .12s, transform .12s;
}
.hint:hover::after, .hint:focus-visible::after, .hint.show::after { opacity: 1; transform: translate(-50%, 0); }
.intro-help { margin-top: 14px; font-size: 13px; font-weight: 700; color: var(--faint); }
.tips small { color: var(--purple); font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.tips h2 { margin: 4px 0 14px; }
.tips ul { margin: 0; padding-left: 20px; }
.tips li { margin-bottom: 10px; line-height: 1.5; color: var(--fg); font-size: 16px; }
.bubble .w.ok { color: var(--green-t); font-weight: 800; }
.bubble .w.bad { color: var(--red-t); font-weight: 800; text-decoration: underline wavy; }

/* word tiles */
.answer-area {
  display: flex; flex-wrap: wrap; align-content: flex-start; gap: 14px 8px;
  min-height: 128px; padding: 6px 0 8px; margin-bottom: 28px;
  background: repeating-linear-gradient(to bottom, transparent 0 58px, var(--line) 58px 60px);
}
.bank { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 8px; }
.slot { border-radius: 12px; background: var(--off); }
.tile {
  height: 46px; padding: 0 14px; white-space: nowrap;
  border: 2px solid var(--line); border-radius: 12px; background: var(--bg);
  box-shadow: 0 2px 0 var(--line); color: var(--strong);
  font-size: 18px; font-weight: 600; cursor: pointer;
}
.tile:hover { background: var(--hover); }
.tile:active { transform: translateY(2px); box-shadow: none; }
.slot .tile.used { visibility: hidden; }
.tile.ghost { pointer-events: none; transition: transform .24s cubic-bezier(.2, .9, .3, 1); }
.locked .tile { cursor: default; }

/* choices & pairs */
.options { display: flex; flex-direction: column; gap: 12px; }
.option, .match-btn {
  display: flex; align-items: center; gap: 14px; text-align: left;
  padding: 14px 16px; border: 2px solid var(--line); border-radius: 14px;
  background: var(--bg); box-shadow: 0 2px 0 var(--line);
  font-size: 18px; font-weight: 600; color: var(--strong); cursor: pointer;
}
.option:hover, .match-btn:hover:not(:disabled) { background: var(--hover); }
.option:active, .match-btn:active:not(:disabled) { transform: translateY(2px); box-shadow: none; }
.num {
  display: grid; place-items: center; flex-shrink: 0; width: 30px; height: 30px;
  border: 2px solid var(--line); border-radius: 8px; font-size: 14px; font-weight: 800; color: var(--faint);
}
.selected { border-color: var(--blue-b) !important; background: var(--blue-l) !important; box-shadow: 0 2px 0 var(--blue-b) !important; color: var(--blue-d) !important; }
.selected .num { border-color: var(--blue-b); color: var(--blue-d); }
.right, .good { border-color: var(--green) !important; background: var(--green-l) !important; box-shadow: 0 2px 0 var(--green) !important; color: var(--green-t) !important; }
.wrong { border-color: var(--red) !important; background: var(--red-l) !important; box-shadow: 0 2px 0 var(--red) !important; color: var(--red-t) !important; animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.match { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.match-col { display: flex; flex-direction: column; gap: 12px; }
.match-btn { min-height: 62px; padding: 10px 14px; font-size: 17px; }
.match-btn.good { animation: pop .2s; }
.match-btn.gone { opacity: .4; cursor: default; }
.match-btn:disabled { cursor: default; }

/* typing */
.type-box {
  width: 100%; min-height: 150px; resize: vertical; padding: 14px 16px;
  border: 2px solid var(--line); border-radius: 14px; outline: none;
  background: var(--hover); color: var(--strong); font: inherit; font-size: 19px;
}
.type-box:focus { border-color: var(--blue-b); background: var(--bg); }
.chars { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.char {
  width: 44px; height: 44px; border: 2px solid var(--line); border-radius: 10px;
  background: var(--bg); box-shadow: 0 2px 0 var(--line);
  font-size: 19px; font-weight: 700; color: var(--strong); cursor: pointer;
}
.char:active { transform: translateY(2px); box-shadow: none; }

.listen { display: flex; justify-content: center; align-items: flex-end; gap: 18px; margin: 4px 0 32px; }

/* intro card */
.intro { display: flex; align-items: center; gap: 18px; }
.intro .mascot { font-size: 96px; }
.intro-card {
  flex: 1; padding: 26px 24px; text-align: center;
  border: 2px solid var(--line); border-radius: 20px; box-shadow: 0 4px 0 var(--line);
}
.intro-es { display: flex; align-items: center; justify-content: center; gap: 14px; font-size: 30px; font-weight: 800; color: var(--strong); line-height: 1.25; }
.intro-pl { margin-top: 14px; font-size: 20px; font-weight: 600; color: var(--muted); }
.intro-note { margin-top: 18px; padding: 10px 14px; border-radius: 12px; background: var(--blue-l); color: var(--blue-d); font-size: 15px; font-weight: 700; }
.intro-slow { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 18px; color: var(--faint); font-weight: 700; font-size: 14px; }

/* speaking */
.meaning { margin: -14px 0 26px 98px; color: var(--muted); font-weight: 600; }
.mic-btn {
  display: flex; align-items: center; justify-content: center; gap: 12px; width: 100%; height: 78px;
  border: 2px solid var(--line); border-radius: 18px; background: var(--bg); box-shadow: 0 4px 0 var(--line);
  color: var(--blue); font-size: 16px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; cursor: pointer;
}
.mic-btn:hover { background: var(--hover); }
.mic-btn:active { transform: translateY(4px); box-shadow: none; }
.mic-ico svg { width: 30px; height: 30px; display: block; }
.mic-btn.rec { border-color: var(--red); background: var(--red-l); box-shadow: 0 4px 0 var(--red); color: var(--red-t); }
.mic-btn.rec .mic-ico { animation: pulse .9s ease-in-out infinite; }
.mic-btn.busy { cursor: progress; opacity: .7; }
.levels { display: none; align-items: center; gap: 3px; height: 32px; }
.mic-btn.rec .levels { display: flex; }
.levels i { width: 4px; height: 4px; border-radius: 2px; background: currentColor; transition: height .08s; }
.heard { min-height: 24px; margin-top: 16px; text-align: center; font-weight: 700; color: var(--muted); }

/* footer */
.lesson-foot { display: flex; align-items: center; min-height: 140px; border-top: 2px solid var(--line); }
.lesson-foot.ok { background: var(--green-l); border-top-color: transparent; animation: slideup .2s ease-out; }
.lesson-foot.bad { background: var(--red-l); border-top-color: transparent; animation: slideup .2s ease-out; }
@keyframes slideup { from { transform: translateY(24px); } }
.foot-inner {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  width: 100%; max-width: 1040px; margin: 0 auto; padding: 20px 24px;
}
.res { display: flex; align-items: center; gap: 16px; min-width: 0; }
.res-icon { display: grid; place-items: center; flex-shrink: 0; width: 66px; height: 66px; border-radius: 50%; background: var(--bg); }
.res-icon svg { width: 36px; height: 36px; }
.ok .res-icon, .ok .res-body { color: var(--green-t); }
.bad .res-icon, .bad .res-body { color: var(--red-t); }
.res-head { font-size: 24px; font-weight: 900; }
.res-sol { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 4px; font-size: 18px; font-weight: 700; }
.res-extra { margin-top: 4px; font-size: 15px; font-weight: 600; opacity: .9; }

@media (max-width: 640px) {
  .lesson-top { padding: 16px 16px 4px; }
  .lesson-body { padding: 12px 16px 24px; }
  .ex-title { font-size: 24px; margin-bottom: 18px; }
  .mascot { font-size: 60px; }
  .intro .mascot { display: none; }
  .meaning { margin-left: 74px; }
  .foot-inner { flex-direction: column; align-items: stretch; padding: 16px; }
  .foot-inner > .btn { width: 100%; }
  .res-icon { display: none; }
  .lesson-foot { min-height: 0; }
  .match { gap: 10px; }
  .match-btn { font-size: 15px; padding: 8px 10px; gap: 8px; }
  .match-btn .num { display: none; }
}

/* ----------------------------------------------------------------- finish */
.finish { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; min-height: 100vh; padding: 24px; text-align: center; }
.finish-bird { font-size: 112px; animation: jump 1s ease-in-out infinite; }
@keyframes jump { 0%, 100% { transform: none; } 40% { transform: translateY(-18px) rotate(-6deg); } }
.finish h1 { font-size: 34px; font-weight: 900; color: var(--gold-d); }
.finish-sub { margin: -10px 0 0; color: var(--muted); font-weight: 700; }
.finish-stats { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; margin-bottom: 10px; }
.fstat { width: 152px; overflow: hidden; border: 2px solid var(--c); border-radius: 16px; background: var(--c); }
.fstat .lbl { padding: 6px 0; font-size: 13px; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; color: #fff; }
.fstat .val { padding: 14px 0; border-radius: 14px; background: var(--bg); font-size: 22px; font-weight: 900; color: var(--c); }
.confetti { position: fixed; inset: 0; z-index: 50; overflow: hidden; pointer-events: none; }
.confetti i { position: absolute; top: -24px; width: 10px; height: 16px; border-radius: 3px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(112vh) rotate(760deg); } }

/* ----------------------------------------------------------- modal, misc */
.overlay { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, .5); animation: fadein .15s; }
.modal { width: 100%; max-width: 520px; max-height: calc(100vh - 32px); overflow-y: auto; padding: 24px; border-radius: 20px; background: var(--bg); box-shadow: 0 12px 40px rgba(0, 0, 0, .3); }
.modal h2 { margin-bottom: 18px; font-size: 24px; }
.modal p { color: var(--muted); line-height: 1.45; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field > b { color: var(--strong); }
.field-row { display: flex; align-items: center; gap: 10px; }
.field-row > :first-child { flex: 1; min-width: 0; }
small { display: block; color: var(--muted); font-size: 13px; }
select, input[type=search] {
  width: 100%; padding: 10px 12px; border: 2px solid var(--line); border-radius: 12px;
  background: var(--bg); color: var(--strong); font: inherit; font-weight: 600;
}
input[type=range] { width: 100%; accent-color: var(--blue); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-top: 2px solid var(--line); cursor: pointer; }
.switch-row b { color: var(--strong); }
.switch { appearance: none; flex-shrink: 0; position: relative; width: 52px; height: 30px; margin: 0; border-radius: 99px; background: var(--off); cursor: pointer; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .2s; }
.switch:checked { background: var(--green); }
.switch:checked::after { transform: translateX(22px); }
.modal-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 20px; }
.modal-actions.col { flex-direction: column; align-items: stretch; }
.quit { text-align: center; }
.quit .mascot { display: block; margin: 0 auto 10px; }

.book { max-width: 780px; margin: 0 auto; padding: 0 24px 80px; }
.book-head { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; padding: 14px 0; background: var(--bg); border-bottom: 2px solid var(--line); }
.book-head h1 { font-size: 24px; white-space: nowrap; }
.book h2 { margin: 28px 0 8px; font-size: 20px; }
.row { display: flex; align-items: center; gap: 14px; padding: 10px 4px; border-bottom: 2px solid var(--line); }
.row .txt { flex: 1; min-width: 0; }
.row .es { font-weight: 800; color: var(--strong); }
.row .pl { color: var(--muted); }
.row .note { margin-top: 2px; font-size: 14px; color: var(--blue-d); }
.strength { display: flex; gap: 3px; }
.strength i { width: 8px; height: 8px; border-radius: 50%; background: var(--off); }
.strength i.on { background: var(--gold); }
.empty { padding: 40px 0; text-align: center; color: var(--muted); }

.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 60; transform: translateX(-50%);
  max-width: calc(100vw - 32px); padding: 12px 18px; border-radius: 14px;
  background: var(--strong); color: var(--bg); font-weight: 700; box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
}
.fatal { max-width: 560px; margin: 15vh auto; padding: 24px; text-align: center; }

.backup-row > * { flex: 1; }
.backup-card { border-color: var(--gold); }
.compare { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 14px; }
.offline-banner {
  position: fixed; left: 50%; top: max(10px, env(safe-area-inset-top)); z-index: 70; transform: translateX(-50%);
  max-width: calc(100vw - 32px); padding: 8px 14px; border-radius: 12px;
  background: var(--blue); color: #fff; font-size: 14px; font-weight: 800; box-shadow: 0 4px 14px rgba(0, 0, 0, .2);
}

/* iPhone: keep content clear of the notch and the home indicator */
.topbar { padding-top: max(10px, env(safe-area-inset-top)); }
.lesson-top { padding-top: max(24px, env(safe-area-inset-top)); }
.lesson-foot { padding-bottom: env(safe-area-inset-bottom); }
.book-head { padding-top: max(14px, env(safe-area-inset-top)); }
.finish { padding-top: max(24px, env(safe-area-inset-top)); padding-bottom: max(24px, env(safe-area-inset-bottom)); }
@media (max-width: 640px) {
  .lesson-top { padding-top: max(16px, env(safe-area-inset-top)); }
}

.fatal pre { white-space: pre-wrap; text-align: left; color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
