/* Fredoka (SIL Open Font License), kept in the app so it works offline. */
@font-face {
  font-family: 'Fredoka';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url('fonts/fredoka-latin.woff2') format('woff2');
}

/* Kid palette: a calm cream background, bright colours only on buttons and characters. */
:root {
  --bg: #fff8e7;
  --surface: #ffffff;
  --ink: #3d2c1e;
  --muted: #7a6654;
  --line: #f0e0bf;
  --honey: #ffc93c;
  --honey-soft: #fff0c2;
  --coral: #ff6b6b;
  --coral-deep: #d63a40;
  --coral-soft: #ffe1df;
  --sky: #4fc3f7;
  --sky-soft: #dcf3fd;
  --grass: #7ed957;
  --grass-soft: #e5f8da;
  --grape: #a78bfa;
  --grape-soft: #eee8fe;
  --good: #2b8a3e;
  --good-soft: #e5f8da;
  --bad: #c92a3a;
  --bad-soft: #ffe1df;
  --accent: #1c7fb8;
  --radius: 24px;
  --shadow: 0 4px 0 rgba(61, 44, 30, 0.08), 0 8px 24px rgba(61, 44, 30, 0.06);
  --tap: 60px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1d1813;
    --surface: #2a231c;
    --ink: #fbf3e6;
    --muted: #c9b8a4;
    --line: #45392c;
    --coral-soft: #4a2626;
    --sky-soft: #1d3644;
    --grass-soft: #22371b;
    --grape-soft: #2f2747;
    --accent: #6cc4f0;
    --honey-soft: #3a3320;
    --good-soft: #1d3a2a;
    --bad-soft: #3d2222;
    --shadow: none;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #1d1813;
  --surface: #2a231c;
  --ink: #fbf3e6;
  --muted: #c9b8a4;
  --line: #45392c;
  --coral-soft: #4a2626;
  --sky-soft: #1d3644;
  --grass-soft: #22371b;
  --grape-soft: #2f2747;
  --accent: #6cc4f0;
  --honey-soft: #3a3320;
  --good-soft: #1d3a2a;
  --bad-soft: #3d2222;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Fredoka", ui-rounded, "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Bengali", "Hind Siliguri", sans-serif;
  font-size: 18px;
  -webkit-tap-highlight-color: transparent;
  line-height: 1.45;
}

a { color: var(--accent); }

.topbar {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand {
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.logo { font-size: 1.3em; }
.topbar-actions { display: flex; gap: 6px; flex-shrink: 0; }

main {
  max-width: 760px;
  min-height: calc(100dvh - 70px);
  margin: 0 auto;
  padding: 16px max(16px, env(safe-area-inset-right)) calc(96px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  outline: none;
}

h1 { font-size: 1.7rem; font-weight: 700; margin: 8px 0 12px; }
h2 { font-size: 1.25rem; font-weight: 600; margin: 20px 0 8px; }
p { margin: 6px 0; }
.muted { color: var(--muted); }
.small { font-size: 0.88rem; }
.center { text-align: center; }

.card {
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin: 12px 0;
}

.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.spread { justify-content: space-between; }

button, .btn {
  font: inherit;
  border: 0;
  border-radius: 18px;
  padding: 12px 20px;
  min-height: var(--tap);
  background: var(--coral-deep);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 4px 0 rgba(61, 44, 30, 0.15);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

/* A little bounce when pressed. */
button:active:not(:disabled), .btn:active { transform: translateY(3px) scale(0.97); box-shadow: 0 1px 0 rgba(61, 44, 30, 0.15); }
button:disabled { opacity: 0.45; cursor: default; box-shadow: none; }
button.secondary, .btn.secondary { background: var(--honey); color: var(--ink); }
button.ghost, .btn.ghost { background: var(--surface); color: var(--ink); border: 2px solid var(--line); box-shadow: none; }
button.danger { background: var(--bad-soft); color: var(--bad); box-shadow: none; }
button.big, .btn.big { width: 100%; font-size: 1.3rem; min-height: 68px; border-radius: 22px; }
.small-btn { min-height: 48px; min-width: 48px; padding: 6px 10px; border-radius: 14px; }

.chip {
  font-size: 0.85rem;
  padding: 6px 12px;
  min-height: 36px;
  border-radius: 999px;
  background: var(--honey-soft);
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.child-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 18px 12px;
  text-decoration: none;
  color: var(--ink);
}

.avatar { font-size: 3rem; line-height: 1; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { text-align: center; padding: 10px 4px; border-radius: 18px; background: var(--honey-soft); }
.stat:nth-child(2) { background: var(--coral-soft); }
.stat:nth-child(3) { background: var(--grass-soft); }
.stat b { display: block; font-size: 1.4rem; }

.word-big {
  font-size: clamp(2rem, 9vw, 3.2rem);
  font-weight: 800;
  letter-spacing: 0.04em;
  text-align: center;
  margin: 8px 0;
  word-break: break-word;
}

.syllables { text-align: center; font-size: 1.3rem; color: var(--muted); letter-spacing: 0.05em; }
.tricky { background: var(--honey-soft); border-radius: 6px; padding: 0 2px; color: var(--ink); }

.answer {
  min-height: 64px;
  border: 2px dashed var(--line);
  border-radius: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  justify-content: center;
  padding: 8px;
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.tiles { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin: 12px 0; }
.tile, .quiz-tile, .slot { user-select: none; -webkit-user-select: none; touch-action: manipulation; }

.tile {
  width: 60px;
  height: 60px;
  min-height: 60px;
  padding: 0;
  font-size: 1.8rem;
  border-radius: 16px;
  background: var(--surface);
  border: 3px solid var(--sky);
  color: var(--ink);
}

.tile.used { visibility: hidden; }

input, textarea, select {
  font: inherit;
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

textarea { min-height: 140px; resize: vertical; }
label { display: block; font-weight: 600; margin: 12px 0 4px; }

.feedback { border-radius: 12px; padding: 12px; margin: 12px 0; font-weight: 600; }
.feedback.good { background: var(--good-soft); color: var(--good); }
.feedback.bad { background: var(--bad-soft); color: var(--bad); }
.feedback.info { background: var(--honey-soft); }

.word-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.word-chip { padding: 4px 10px; border-radius: 999px; background: var(--honey-soft); font-size: 0.9rem; }
.word-chip.warn { background: var(--bad-soft); color: var(--bad); }
.word-chip.ok { background: var(--good-soft); color: var(--good); }

table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }

.bar { height: 10px; border-radius: 999px; background: var(--line); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--good); }

.badges { display: flex; flex-wrap: wrap; gap: 8px; }
.badge { padding: 6px 10px; border-radius: 12px; background: var(--honey-soft); font-size: 0.9rem; }
.badge.locked { opacity: 0.4; }

#toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 12px;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  max-width: calc(100% - 32px);
}

#toast.show { opacity: 1; }

.progress-dots { display: flex; gap: 4px; justify-content: center; margin: 8px 0; flex-wrap: wrap; }
.progress-dots span { width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.progress-dots span.done { background: var(--good); }
.progress-dots span.miss { background: var(--bad); }
.progress-dots span.now { background: var(--honey); }

/* ---------- Learnt celebration ---------- */

.learnt-pop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.35);
}

.learnt-pop .card { text-align: center; max-width: 340px; animation: cheer 0.6s ease-in-out 2; }
.learnt-pop .clap { font-size: 88px; line-height: 1; }
.learnt-pop .word-big { margin: 8px 0; }

/* ---------- Learn game ---------- */

.steps {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 0;
  margin: 12px 0 0;
}

.steps li {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 2px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 1.2rem;
  opacity: 0.55;
}

.steps li.now { opacity: 1; border-color: var(--honey); background: var(--honey-soft); }
.steps li.done { opacity: 0.9; }
.steps .step-name { font-size: 0.68rem; text-align: center; line-height: 1.15; color: var(--muted); }

.learn-card { min-height: 360px; position: relative; overflow: hidden; }
.next-btn { flex: 1; }

.picture {
  display: flex;
  margin: 8px auto;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: var(--honey-soft);
  font-size: 110px;
  line-height: 1;
  padding: 0;
  animation: bob 2.4s ease-in-out infinite;
}

.letter-pic { font-size: 120px; font-weight: 800; color: var(--accent); }
.picture.small-pic { width: 120px; height: 120px; font-size: 64px; }
.family { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; align-items: center; margin-top: 12px; }


.fly-row {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 160px;
  align-items: center;
  margin: 24px 0;
}

.fly {
  font-size: clamp(3rem, 16vw, 5.5rem);
  font-weight: 800;
  opacity: 0;
  transform: translate(var(--dx, 0), var(--dy, -150px)) rotate(var(--rot, 0)) scale(0.4);
}

.fly.in { animation: fly-in 0.7s cubic-bezier(0.2, 1.4, 0.4, 1) forwards; }
.fly.cheer { opacity: 1; transform: none; animation: cheer 0.6s ease-in-out 2; }

@keyframes fly-in {
  to { opacity: 1; transform: translate(0, 0) rotate(0) scale(1); }
}

@keyframes cheer {
  50% { transform: translateY(-14px) scale(1.12); }
}

@keyframes bob {
  50% { transform: translateY(-8px); }
}

.trace-word { display: flex; justify-content: center; gap: 6px; font-size: 1.8rem; font-weight: 800; margin: 4px 0 8px; }
.trace-word span { color: var(--muted); padding: 0 4px; border-bottom: 3px solid transparent; }
.trace-word span.now { color: var(--ink); border-bottom-color: var(--honey); }
.trace-word span.done { color: var(--good); }
.trace-wrap { display: flex; justify-content: center; }

canvas.trace {
  touch-action: none;
  border-radius: 20px;
  background: var(--surface);
  border: 2px dashed var(--line);
  max-width: 100%;
}

.slots { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; margin: 24px 0 8px; }

.slot {
  width: 54px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  font-weight: 800;
  border-bottom: 4px solid var(--line);
}

.slot.blank { border-bottom-color: var(--honey); background: var(--honey-soft); border-radius: 10px 10px 0 0; }
.slot.cur { animation: bob 1.2s ease-in-out infinite; }
.slot.ok { color: var(--good); }
.syl-slots { gap: 12px; }
.syl-slots .syl { display: flex; gap: 4px; }
.syl-slots .slot { width: var(--sw); height: calc(var(--sw) * 1.18); font-size: calc(var(--sw) * 0.62); }

.tile.shake { animation: shake 0.35s; border-color: var(--bad); }

@keyframes shake {
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.burst { position: absolute; left: 50%; top: 55%; pointer-events: none; }
.burst span { position: absolute; font-size: 1.8rem; animation: burst 1.2s ease-out forwards; }

@keyframes burst {
  from { transform: translate(0, 0) scale(0.5); opacity: 1; }
  to { transform: translate(var(--x), var(--y)) scale(1.2); opacity: 0; }
}

.word-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }

.word-tile:nth-child(5n+1) { background: var(--sky-soft); }
.word-tile:nth-child(5n+2) { background: var(--honey-soft); }
.word-tile:nth-child(5n+3) { background: var(--grass-soft); }
.word-tile:nth-child(5n+4) { background: var(--grape-soft); }
.word-tile:nth-child(5n+5) { background: var(--coral-soft); }
.word-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 6px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  min-height: 72px;
  justify-content: center;
}

.word-tile span { font-size: 1.6rem; min-height: 1.6rem; }
.word-tile.mastered { border-color: var(--good); }

@media (prefers-reduced-motion: reduce) {
  .picture, .slot.cur { animation: none; }
  .fly { opacity: 1; transform: none; }
  .fly.in, .fly.cheer { animation: none; }
}

/* ---------- Lessons (parent) ---------- */

.lesson-tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.lesson-tab {
  padding: 8px 14px;
  border: 2px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
}
.lesson-tab.on { border-color: var(--honey); background: var(--honey-soft); }

/* ---------- Honey jar ---------- */

.jar-card { display: flex; gap: 16px; align-items: center; }
.jar-info { flex: 1; min-width: 0; }
.jar-info h2 { margin: 8px 0 4px; }
.jar-done { border-color: var(--honey); box-shadow: 0 0 0 3px var(--honey-soft); }

.jar2 { position: relative; width: 132px; flex: none; padding-top: 6px; }
.jar2-lid { height: 18px; margin: 0 14px; border-radius: 8px 8px 4px 4px; background: #b07a2a; box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.15); }
.jar2-body {
  height: 170px;
  margin-top: -2px;
  padding: 8px;
  border: 4px solid rgba(160, 170, 190, 0.7);
  border-radius: 22px 22px 30px 30px;
  background: rgba(255, 255, 255, 0.55);
  overflow: hidden;
}
.jar2-cells { height: 100%; display: flex; flex-wrap: wrap-reverse; align-content: flex-start; justify-content: center; gap: 4px; }
.cell {
  width: var(--cell, 32px);
  height: calc(var(--cell, 32px) * 0.94);
  display: grid;
  place-items: center;
  font-size: calc(var(--cell, 32px) * 0.56);
  font-weight: 800;
  clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%);
}
.cell.empty { background: rgba(160, 170, 190, 0.3); }
.cell.honey { background: #ffd970; color: #7a4b00; }
.cell.gold { background: linear-gradient(135deg, #ffe066, #f6a800); color: #6b3d00; }
.cell.drop { animation: cell-drop 0.7s cubic-bezier(0.3, 1.4, 0.5, 1); }
.cell.shine { animation: cell-shine 0.9s ease-in-out; }
@keyframes cell-drop {
  0% { transform: translateY(-190px) scale(1.4); }
  70% { transform: translateY(6px) scale(0.95); }
  100% { transform: none; }
}
@keyframes cell-shine {
  0%, 100% { transform: none; filter: none; }
  40% { transform: scale(1.5) rotate(15deg); filter: brightness(1.4) drop-shadow(0 0 6px #ffd84d); }
}
.jar2.wobble { animation: jar-wobble 0.5s ease-in-out; }
@keyframes jar-wobble {
  25% { transform: rotate(-5deg); }
  75% { transform: rotate(5deg); }
}
.jar2-bee { position: absolute; top: -6px; right: -8px; font-size: 26px; opacity: 0; }
.jar2.busy .jar2-bee { opacity: 1; animation: bee-fly 2.4s ease-in-out infinite; }
@keyframes bee-fly {
  0% { transform: translate(0, 0) rotate(0); }
  25% { transform: translate(-70px, 30px) rotate(-20deg); }
  50% { transform: translate(-120px, -6px) rotate(10deg); }
  75% { transform: translate(-40px, -20px) rotate(-10deg); }
  100% { transform: translate(0, 0) rotate(0); }
}

/* ---------- Quiz ---------- */

.quiz-card { background: linear-gradient(160deg, #7b2ff7, #5a12c9); color: #fff; border: none; }
.quiz-head { display: flex; align-items: center; justify-content: center; gap: 12px; }
.quiz-head h1 { margin: 0; color: #fff; font-size: clamp(1.15rem, 6vw, 2rem); white-space: nowrap; text-shadow: 0 3px 0 rgba(0, 0, 0, 0.25); }
.quiz-num {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 50%;
  background: #ff3d7f;
  color: #fff;
  font-weight: 800;
  font-size: 1.3rem;
}
.quiz-pic {
  display: block;
  margin: 16px auto 4px;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  border-radius: 24px;
  width: 170px;
  height: 150px;
  font-size: 96px;
  line-height: 1;
  padding: 0;
}
.quiz-pic.no-pic { font-size: 80px; }
.quiz-hear {
  display: block;
  margin: 10px auto 4px;
  min-height: 52px;
  padding: 8px 22px;
  border-radius: 999px;
  background: #ffd84d;
  color: #3a2a1a;
  font-size: 1.2rem;
  font-weight: 800;
}
.quiz-card .slot { color: var(--ink); }
.quiz-card .slot.blank { background: #fff; border-bottom-color: var(--honey); }
.quiz-card .slot.over { outline: 3px dashed #ffd84d; }
.quiz-card .slot.hint { color: #8a5cf6; }
.quiz-card .small.muted { color: rgba(255, 255, 255, 0.85); }
.quiz-tile { touch-action: none; user-select: none; -webkit-user-select: none; }
.quiz-tile.dragging { opacity: 0.3; }
.drag-ghost { position: fixed; z-index: 60; pointer-events: none; transform: scale(1.15); box-shadow: var(--shadow); }
.timer {
  height: 22px;
  margin: 16px auto 4px;
  max-width: 420px;
  border-radius: 999px;
  background: #fff;
  border: 3px solid #fff;
  overflow: hidden;
}
.timer-fill { height: 100%; background: #ffc928; border-radius: 999px; transform-origin: left; }
.timer-fill.low { background: #ff5a5a; }

@media (prefers-reduced-motion: reduce) {
  .cell.drop, .cell.shine, .jar2.wobble, .jar2.busy .jar2-bee { animation: none; }
}

.word-actions { white-space: nowrap; text-align: right; }
.small-btn { min-height: 36px; padding: 4px 10px; }

.confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 70; pointer-events: none; }

.word-done .done-pic { font-size: 96px; line-height: 1; margin: 8px 0 0; animation: done-bounce 0.9s cubic-bezier(0.3, 1.6, 0.5, 1) both; }
.word-done h1 { margin: 8px 0 0; }
@keyframes done-bounce {
  0% { transform: scale(0.2) rotate(-30deg); opacity: 0; }
  100% { transform: none; opacity: 1; }
}
.done-next { width: 100%; margin-top: 12px; }
.done-next.ready { animation: ready-pulse 1.2s ease-in-out infinite; }
@keyframes ready-pulse {
  50% { transform: scale(1.04); box-shadow: 0 0 0 6px var(--honey-soft); }
}
@media (prefers-reduced-motion: reduce) {
  .word-done .done-pic, .done-next.ready { animation: none; }
}

/* ---------- Buzzy the bee ---------- */

.buddy { background: none; border: none; padding: 0; min-height: 0; width: 110px; flex: none; cursor: pointer; box-shadow: none; }
.buddy:hover, .buddy:active { background: none; transform: none; }
.buddy.big { width: 170px; margin: 0 auto; }
.buddy.mini { width: 44px; }
.buddy-svg { display: block; width: 100%; height: auto; overflow: visible; }
.buddy-svg g { transform-box: fill-box; }
.b-body { transform-origin: 50% 100%; animation: b-idle 2.4s ease-in-out infinite; }
.b-wing-l { transform-origin: 90% 90%; animation: b-flap-l 0.18s ease-in-out infinite alternate; }
.b-wing-r { transform-origin: 10% 90%; animation: b-flap-r 0.18s ease-in-out infinite alternate; }
.b-eyes { transform-origin: center; animation: b-blink 4s infinite; }
.b-open, .b-pot { display: none; }
@keyframes b-idle { 50% { transform: translateY(-5px) rotate(-2deg); } }
@keyframes b-flap-l { to { transform: rotate(-18deg) scaleY(0.85); } }
@keyframes b-flap-r { to { transform: rotate(18deg) scaleY(0.85); } }
@keyframes b-blink { 0%, 94%, 100% { transform: none; } 97% { transform: scaleY(0.1); } }

.buddy.wave .b-body { animation: b-wiggle 0.3s ease-in-out 6 alternate; }
@keyframes b-wiggle { from { transform: rotate(-10deg); } to { transform: rotate(10deg); } }

.buddy.dance .b-body { animation: b-dance 0.9s ease-in-out infinite; }
.buddy.dance .b-wing-l, .buddy.dance .b-wing-r { animation-duration: 0.08s; }
.buddy.dance .b-smile, .buddy.jump .b-smile, .buddy.eat .b-smile { display: none; }
.buddy.dance .b-open, .buddy.jump .b-open, .buddy.eat .b-open { display: inline; }
@keyframes b-dance {
  0% { transform: translate(0, 0) rotate(0); }
  25% { transform: translate(-10px, -12px) rotate(-14deg); }
  50% { transform: translate(0, -18px) rotate(0); }
  75% { transform: translate(10px, -12px) rotate(14deg); }
  100% { transform: translate(0, 0) rotate(0); }
}

.buddy.jump .b-body { animation: b-jump 0.35s ease-out 2 alternate; }
@keyframes b-jump { to { transform: translateY(-18px); } }

.buddy.eat .b-pot { display: inline; }
.buddy.eat .b-head { transform-origin: 50% 100%; animation: b-eat 0.2s ease-in-out 4 alternate; }
@keyframes b-eat { to { transform: translateY(3px) rotate(4deg); } }

.b-crown { transform-origin: 50% 100%; animation: b-crown 0.8s cubic-bezier(0.3, 1.6, 0.5, 1) both; }
@keyframes b-crown { from { transform: translateY(-30px) scale(0.3); opacity: 0; } }

.buddy-card { display: flex; gap: 12px; align-items: center; }
.buddy-talk { flex: 1; min-width: 0; }
.bubble {
  position: relative;
  margin: 0 0 8px;
  padding: 10px 14px;
  border-radius: 16px;
  background: var(--honey-soft);
  font-weight: 600;
}
.bubble::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 18px;
  border: 8px solid transparent;
  border-right-color: var(--honey-soft);
  border-left: 0;
}

.done-row { display: flex; align-items: flex-end; justify-content: center; gap: 8px; }
.done-row .buddy { width: 120px; }
.quiz-head .buddy.mini { margin-left: 4px; }

@media (prefers-reduced-motion: reduce) {
  .b-body, .b-eyes, .b-wing-l, .b-wing-r, .buddy.wave .b-body, .buddy.dance .b-body,
  .buddy.jump .b-body, .buddy.eat .b-head, .b-crown { animation: none; }
}

/* ---------- Word pictures ---------- */
.pic-img { width: 1em; height: 1em; object-fit: cover; border-radius: 0.18em; vertical-align: middle; }
.row-pic { min-height: 0; width: 40px; height: 40px; padding: 0; margin-right: 8px; font-size: 1.4rem; vertical-align: middle; }
.pic-picker { background: var(--honey-soft); border-radius: var(--radius); padding: 12px; }
.pic-now { font-size: 48px; line-height: 1; }
.pic-grid { display: flex; flex-wrap: wrap; gap: 4px; max-height: 220px; overflow-y: auto; }
.pic-grid button { min-height: 0; width: 44px; height: 44px; padding: 0; font-size: 1.6rem; }
.pic-photo { cursor: pointer; }

/* ---------- Balloon pop (every 5 new words) ---------- */
.balloon-party {
  position: fixed;
  inset: 0;
  z-index: 55;
  overflow: hidden;
  background: linear-gradient(180deg, #bfe9ff 0%, #e6f7ff 55%, var(--bg) 100%);
  animation: party-in 0.4s ease-out;
}
.balloon-party.bye { animation: party-out 0.4s ease-in forwards; }
@keyframes party-in { from { opacity: 0; } }
@keyframes party-out { to { opacity: 0; } }
.balloon-title { position: relative; z-index: 2; text-align: center; margin: 16px 56px 0; font-size: clamp(1.6rem, 6vw, 2.6rem); color: #3d2c1e; }
.balloon-sky {
  position: absolute;
  inset: 70px 8px 120px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-content: center;
  gap: clamp(10px, 3vw, 28px);
}
.balloon {
  --size: clamp(104px, 26vw, 170px);
  position: relative;
  width: var(--size);
  height: calc(var(--size) * 1.18);
  min-height: 0;
  padding: 0;
  border-radius: 50% 50% 48% 48% / 55% 55% 45% 45%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: #3d2c1e;
  box-shadow: inset -10px -14px 0 rgba(0, 0, 0, 0.08), inset 10px 10px 0 rgba(255, 255, 255, 0.35);
  animation: balloon-up 1.1s cubic-bezier(0.2, 1.2, 0.4, 1) both, balloon-sway 2.6s ease-in-out infinite;
  animation-delay: calc(var(--i) * 0.18s), calc(1.1s + var(--i) * 0.3s);
}
.balloon::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  width: 2px;
  height: 46px;
  background: rgba(61, 44, 30, 0.35);
}
.balloon.coral { background: #ff6b6b; }
.balloon.honey { background: #ffc93c; }
.balloon.sky { background: #4fc3f7; }
.balloon.grass { background: #7ed957; }
.balloon.grape { background: #a78bfa; }
.balloon-pic { font-size: calc(var(--size) * 0.36); line-height: 1; }
.balloon-pic .pic-img { border-radius: 50%; }
.balloon-word { font-size: calc(var(--size) * 0.19); font-weight: 700; background: rgba(255, 255, 255, 0.85); border-radius: 999px; padding: 0 10px; max-width: 92%; overflow: hidden; text-overflow: ellipsis; }
.balloon.popped { animation: balloon-pop 0.35s ease-out forwards; pointer-events: none; }
@keyframes balloon-up { from { transform: translateY(110vh); } }
@keyframes balloon-sway { 0%, 100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-14px) rotate(3deg); } }
@keyframes balloon-pop { 0% { transform: scale(1); opacity: 1; } 60% { transform: scale(1.3); opacity: 0.6; } 100% { transform: scale(0.2); opacity: 0; } }
.balloon-buzzy { position: absolute; left: 12px; bottom: 12px; }
.balloon-buzzy .buddy { width: clamp(90px, 20vw, 140px); }
.balloon-close { position: absolute; top: 12px; right: 12px; width: 48px; height: 48px; min-height: 0; padding: 0; border-radius: 50%; background: rgba(255, 255, 255, 0.8); z-index: 3; }
@media (prefers-reduced-motion: reduce) {
  .balloon { animation: none; }
  .balloon.popped { animation: none; visibility: hidden; }
}

/* ---------- Phone and tablet comfort ---------- */
.topbar button, .topbar .btn { min-height: 48px; padding: 8px 14px; box-shadow: none; }
.topbar { border-bottom: 2px solid var(--line); }
.steps li { border-width: 2px; border-radius: 16px; }
.steps li.now { background: var(--sky-soft); border-color: var(--sky); }
.word-big { font-weight: 700; }
.chip { min-height: 40px; }
input, textarea, select { min-height: 52px; border-width: 2px; border-radius: 16px; }
input:focus, textarea:focus, select:focus, button:focus-visible, .btn:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; }

/* Narrow phones: letters still fit on one or two rows. */
@media (max-width: 380px) {
  .tile { width: 52px; height: 52px; min-height: 52px; font-size: 1.6rem; }
  .slot { width: 46px; }
}

/* Tablets: everything a bit bigger, more room on the sides. */
@media (min-width: 700px) {
  html, body { font-size: 20px; }
  main { max-width: 980px; padding: 24px 32px 96px; }
  .tile { width: 76px; height: 76px; min-height: 76px; font-size: 2.2rem; border-radius: 20px; }
  .tiles { gap: 12px; }
  .slot { width: 68px; height: 80px; font-size: 2.8rem; }
  .picture { width: 240px; height: 240px; font-size: 150px; }
  .word-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
  .word-tile { min-height: 110px; }
  .word-tile span { font-size: 2.4rem; min-height: 2.4rem; }
  .quiz-pic { width: 230px; height: 200px; font-size: 130px; }
  .learn-card { min-height: 460px; }
  .buddy { width: 140px; }
  .done-row .buddy { width: 160px; }
  .jar2 { width: 170px; }
  .jar2-body { height: 220px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
}

/* Child home on wide screens: Buzzy and the honey jar side by side. */
@media (min-width: 900px) {
  .home-duo { display: grid; grid-template-columns: 1fr 1.3fr; gap: 16px; align-items: stretch; }
  .home-duo > .card { margin: 12px 0; }
}

/* Voice spelling: letters drop into boxes as the child speaks. */
.vslots { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 14px 0 8px; }
.vslot {
  width: 52px; height: 60px; border-radius: 14px; border: 3px dashed var(--sky);
  background: var(--surface); display: inline-flex; align-items: center; justify-content: center;
  font-size: 2rem; font-weight: 700; color: var(--ink); text-transform: uppercase;
}
.vslot.filled { border-style: solid; border-color: var(--grass); background: #f1fbe9; }
.vslot.unsure { border-color: var(--honey); background: #fff4d6; color: #a86b00; }
.vslot.asking { border-color: var(--grape); background: #f3eeff; box-shadow: 0 0 0 4px rgba(167, 139, 250, 0.35); animation: ready-pulse 1.2s ease-in-out infinite; }
.vslot.drop { animation: letter-drop 0.45s cubic-bezier(.3, 1.6, .5, 1) both; }
@keyframes letter-drop { from { transform: translateY(-40px) scale(0.6); opacity: 0; } to { transform: none; opacity: 1; } }
.did-you-say { font-size: 1.4rem; font-weight: 700; margin: 4px 0; }
.choose-tiles { gap: 16px; }
.tile.big-choice { width: 84px; height: 84px; min-height: 84px; font-size: 2.6rem; border-color: var(--grape); border-radius: 22px; }
@media (max-width: 380px) { .vslot { width: 42px; height: 52px; font-size: 1.6rem; } .tile.big-choice { width: 72px; height: 72px; min-height: 72px; } }
@media (min-width: 700px) { .vslot { width: 68px; height: 80px; font-size: 2.6rem; } .tile.big-choice { width: 104px; height: 104px; min-height: 104px; font-size: 3.2rem; } }

/* Mock bee: choose how to spell, once. */
.how-choices { display: flex; flex-direction: column; gap: 12px; align-items: stretch; max-width: 420px; margin: 8px auto; }
.how-choices .how { font-size: 1.3rem; }
.how-choices .picked { box-shadow: 0 0 0 4px var(--honey); }

/* Green = go / check. Red stays for "careful". */
button.go, .btn.go { background: #2b8a3e; color: #fff; box-shadow: 0 4px 0 #1e6b2e; }
.answer-fb { text-align: center; border-radius: 20px; padding: 14px 12px; margin: 10px 0 14px; }
.answer-fb.good { background: var(--grass-soft); border: 3px solid var(--grass); }
.answer-fb.bad { background: var(--honey-soft); border: 3px solid var(--honey); }
.answer-fb p { margin: 6px 0; }
.fb-title { font-size: 1.5rem; font-weight: 700; }
.fb-letters { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 8px 0; }
.fb-letters span { width: 52px; height: 60px; border-radius: 14px; background: var(--surface); border: 3px solid #2b8a3e; display: inline-flex; align-items: center; justify-content: center; font-size: 2rem; font-weight: 700; color: var(--ink); animation: letter-drop 0.45s cubic-bezier(.3, 1.6, .5, 1) both; }
.fb-letters span:nth-child(2) { animation-delay: 0.1s; } .fb-letters span:nth-child(3) { animation-delay: 0.2s; } .fb-letters span:nth-child(4) { animation-delay: 0.3s; } .fb-letters span:nth-child(5) { animation-delay: 0.4s; } .fb-letters span:nth-child(n+6) { animation-delay: 0.5s; }
@media (min-width: 700px) { .fb-letters span { width: 68px; height: 80px; font-size: 2.6rem; } }
.mistake-row { padding: 6px 0; border-bottom: 1px solid var(--line); }
.mistake-row:last-child { border-bottom: 0; }
.mistake-row p { margin: 2px 0 0; }
.lesson-prog { padding: 8px 0; border-bottom: 1px solid var(--line); }
.lesson-prog:last-child { border-bottom: 0; }
.lesson-prog p { margin: 4px 0 0; }
.bar.two { display: flex; }
.bar.two > span.gold { background: #E0A800; }
.bar.two > span.honey { background: var(--honey); }
.word-chip.good { background: var(--grass-soft); }
.card.track { border-width: 3px; }
.card.track.good { border-color: var(--grass); background: var(--grass-soft); }
.card.track.warn { border-color: var(--honey); background: var(--honey-soft); }
.track-title { font-size: 1.2rem; font-weight: 700; margin: 0 0 4px; }
.card.track p.small { margin: 0; }
