:root {
  --bg: #fff6e6;
  --ink: #2d2a32;
  --soft: #7a7280;
  --card: #ffffff;
  --accent: #ff8a5b;
  --good: #2fc497;
  --bad: #ff5d73;
  --hi: #e8423f;
  --shadow: 0 6px 0 rgba(45, 42, 50, 0.12), 0 10px 24px rgba(45, 42, 50, 0.08);
  /* Fonts with a single-story "a", like children learn to write */
  --font: "Andika", "Chalkboard SE", "Comic Sans MS", "Comic Neue", "Segoe Print", system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); }
body { min-height: 100dvh; overscroll-behavior: none; user-select: none; -webkit-user-select: none; }
#app { max-width: 1100px; margin: 0 auto; padding: max(12px, env(safe-area-inset-top)) 16px 40px; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; color: inherit; border: 0; cursor: pointer; background: none; }
img { -webkit-user-drag: none; }
.hi { color: var(--hi); }
.dim { opacity: 0.22; }

/* ---------- buttons ---------- */
.big-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent); color: #fff; font-size: clamp(22px, 3.4vw, 30px); font-weight: 700;
  padding: 16px 34px; border-radius: 999px; box-shadow: 0 6px 0 #d9653a; transition: transform .1s;
}
.big-btn.alt { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
.big-btn:active, .round-btn:active, .small-btn:active { transform: translateY(4px); box-shadow: none; }
.small-btn { display: inline-block; background: #fff; padding: 10px 18px; border-radius: 999px; font-size: 18px; box-shadow: var(--shadow); }
.small-btn.danger { background: #ffe1e5; }
.icon-btn {
  width: 52px; height: 52px; flex: none; border-radius: 50%; background: #fff; box-shadow: var(--shadow);
  display: grid; place-items: center; font-size: 26px; font-weight: 700;
}
.round-btn {
  width: 76px; height: 76px; border-radius: 50%; background: #fff; box-shadow: var(--shadow);
  font-size: 30px; display: grid; place-items: center;
}
.round-btn.go { background: var(--accent); color: #fff; box-shadow: 0 6px 0 #d9653a; }
.round-btn:disabled { opacity: .3; }

/* ---------- header ---------- */
.top { display: flex; align-items: center; gap: 14px; margin: 4px 0 18px; }
.top h1 { flex: 1; margin: 0; font-size: clamp(24px, 4vw, 38px); }
.star-count, .counter { background: #fff; border-radius: 999px; padding: 8px 16px; font-size: 22px; font-weight: 700; box-shadow: var(--shadow); white-space: nowrap; }

/* ---------- start ---------- */
.start { min-height: 90dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; text-align: center; }
.start h1 { font-size: clamp(44px, 9vw, 84px); margin: 0; color: var(--accent); text-shadow: 0 4px 0 #ffd9c7; }
.start-art { display: flex; gap: 10px; }
.start-art img { width: clamp(70px, 16vw, 140px); border-radius: 24px; box-shadow: var(--shadow); animation: bob 2.4s ease-in-out infinite; }
.start-art img:nth-child(2) { animation-delay: .3s; } .start-art img:nth-child(3) { animation-delay: .6s; } .start-art img:nth-child(4) { animation-delay: .9s; }
@keyframes bob { 50% { transform: translateY(-10px) rotate(-2deg); } }

/* ---------- home ---------- */
.quick { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 8px; }
.quick-btn { background: #fff; border-radius: 24px; padding: 14px 18px; box-shadow: var(--shadow); display: grid; grid-template-columns: auto 1fr; column-gap: 12px; align-items: center; font-size: 22px; font-weight: 700; }
.quick-btn span { grid-row: span 2; font-size: 40px; }
.quick-btn small { font-size: 15px; color: var(--soft); font-weight: 400; }
.quick-btn:first-child { background: var(--accent); color: #fff; }
.quick-btn:first-child small { color: #fff3; color: rgba(255,255,255,.85); }
.unit h2 { font-size: 26px; margin: 26px 0 12px; display: flex; align-items: center; gap: 10px; }
.unit h2::before { content: ""; width: 18px; height: 18px; border-radius: 6px; background: var(--c); }
.lesson-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.lesson-tile {
  position: relative; background: #fff; border-radius: 24px; padding: 12px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; gap: 6px; border: 4px solid transparent; transition: transform .15s;
}
.lesson-tile:active { transform: scale(.96); }
.lesson-tile.next { border-color: var(--c); animation: glow 1.8s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: 0 0 0 8px color-mix(in srgb, var(--c) 25%, transparent), var(--shadow); } }
.lesson-tile .badge { position: absolute; top: -12px; right: -6px; background: var(--c); color: #fff; padding: 4px 10px; border-radius: 999px; font-size: 15px; }
.lesson-tile .sound { position: absolute; top: 8px; left: 10px; background: var(--c); color: #fff; font-weight: 700; font-size: 20px; padding: 2px 10px; border-radius: 12px; }
.lesson-tile img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 16px; }
.lt-title { font-size: 19px; font-weight: 700; text-align: center; }
.bar { width: 100%; height: 10px; background: #f1ebe2; border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: #ffc531; border-radius: 99px; }

/* ---------- lesson ---------- */
.lesson-hero { display: flex; gap: 18px; align-items: center; background: color-mix(in srgb, var(--c) 18%, #fff); border-radius: 30px; padding: 18px; margin-bottom: 18px; flex-wrap: wrap; }
.sound-big {
  width: 150px; height: 150px; border-radius: 34px; background: var(--c); color: #fff; font-size: 52px; font-weight: 700;
  display: flex; flex-direction: column; align-items: center; justify-content: center; box-shadow: var(--shadow); line-height: 1;
}
.sound-big small { font-size: 22px; margin-top: 8px; }
.hero-words { display: flex; gap: 10px; flex: 1; flex-wrap: wrap; }
.mini-word { background: #fff; border-radius: 18px; padding: 6px; width: 104px; box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; font-size: 22px; font-weight: 700; }
.mini-word img { width: 92px; height: 92px; border-radius: 14px; }
.activities { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.activity {
  background: #fff; border-radius: 24px; padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 2px; position: relative; min-height: 130px;
}
.activity:active { transform: scale(.97); }
.activity .a-icon { font-size: 40px; }
.activity b { font-size: 23px; }
.activity small { color: var(--soft); font-size: 16px; }
.activity .stars { position: absolute; top: 14px; right: 16px; color: #ffc531; font-size: 24px; letter-spacing: 2px; }
.activity.learn { background: #fff4c8; }
.activity.book { background: #e6f4ff; padding: 10px 10px 14px; }
.activity.book img { width: 100%; aspect-ratio: 16/10; object-fit: cover; border-radius: 16px; margin-bottom: 6px; }
.lesson-nav { display: flex; justify-content: space-between; margin-top: 22px; }

/* ---------- learn ---------- */
.flash { display: flex; flex-direction: column; align-items: center; gap: 20px; }
.flash-card {
  background: #fff; border-radius: 34px; box-shadow: var(--shadow); padding: 18px 18px 10px; display: flex; flex-direction: column; align-items: center;
  width: min(520px, 92vw);
}
.flash-card img { width: 100%; border-radius: 24px; aspect-ratio: 1; max-height: 44dvh; object-fit: contain; }
.flash-word { font-size: clamp(64px, 12vw, 110px); font-weight: 700; line-height: 1.1; letter-spacing: 3px; }
.flash-card .hint { color: var(--soft); font-size: 16px; }
.flash-card.pop { animation: pop .35s; }
@keyframes pop { 40% { transform: scale(1.04); } }
.flash-nav { display: flex; gap: 30px; align-items: center; }

/* ---------- questions ---------- */
.game-top .dots { flex: 1; display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.dots i { width: 18px; height: 18px; border-radius: 50%; background: #eadfce; }
.dots i.done { background: var(--good); }
.dots i.now { background: var(--accent); transform: scale(1.3); }
.question { display: flex; flex-direction: column; align-items: center; gap: clamp(14px, 3vh, 28px); }
.prompt { display: flex; flex-direction: column; align-items: center; gap: 8px; min-height: 140px; justify-content: center; }
.mode-tag { background: #fff; border-radius: 999px; padding: 4px 14px; font-size: 18px; color: var(--soft); }
.speaker { width: 140px; height: 140px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 64px; box-shadow: 0 8px 0 #d9653a; }
.speaker.pulse { animation: pulse 0.7s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.08); } }
.prompt-word {
  background: #fff; border-radius: 30px; padding: 6px 44px; box-shadow: var(--shadow);
  font-size: clamp(70px, 13vw, 130px); font-weight: 700; letter-spacing: 4px; line-height: 1.15;
}
.prompt-word.glow { box-shadow: 0 0 0 8px var(--good), var(--shadow); }
.prompt-pic { background: #fff; border-radius: 30px; padding: 10px; box-shadow: var(--shadow); }
.prompt-pic img { width: clamp(180px, 30vh, 300px); border-radius: 22px; display: block; }
.choices { display: grid; grid-template-columns: repeat(2, 1fr); gap: clamp(12px, 2.4vw, 24px); width: 100%; max-width: 760px; }
.picture-answers .choices { max-width: min(760px, 88vh); }
@media (min-aspect-ratio: 4/3) { .picture-answers .choices { grid-template-columns: repeat(4, 1fr); max-width: 1000px; } }
.choice {
  background: #fff; border-radius: 28px; box-shadow: var(--shadow); padding: 10px; transition: transform .12s, opacity .3s;
  border: 5px solid transparent;
}
.choice:active { transform: scale(.96); }
.choice.pic img { width: 100%; aspect-ratio: 1; display: block; border-radius: 20px; }
.choice.word { font-size: clamp(46px, 8vw, 76px); font-weight: 700; padding: 22px 10px; letter-spacing: 2px; }
.choice.right { border-color: var(--good); transform: scale(1.06); animation: cheer .5s; }
.choice.wrong { border-color: var(--bad); animation: shake .4s; opacity: .35; }
.choice.fade { opacity: .25; }
.choice.hint { border-color: #ffc531; animation: pulse .8s ease-in-out infinite; }
@keyframes shake { 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }
@keyframes cheer { 50% { transform: scale(1.14) rotate(-2deg); } }

/* ---------- spell it ---------- */
.spell, .trace { display: flex; flex-direction: column; align-items: center; gap: clamp(12px, 2.6vh, 24px); }
.spell-prompt, .trace-prompt { display: flex; align-items: center; gap: 20px; }
.spell-pic { width: clamp(140px, 24vh, 230px); border-radius: 26px; background: #fff; padding: 8px; box-shadow: var(--shadow); }
.slots { display: flex; gap: 10px; padding: 12px 18px; border-radius: 26px; background: #fff; box-shadow: var(--shadow); transition: box-shadow .3s; }
.slots.done { box-shadow: 0 0 0 7px var(--good), var(--shadow); }
.slot {
  min-width: calc(clamp(52px, 9vw, 78px) * var(--w, 1)); height: clamp(70px, 12vw, 100px);
  border-bottom: 6px solid #e6d9c4; display: grid; place-items: center;
  font-size: clamp(46px, 8vw, 72px); font-weight: 700; line-height: 1;
}
.slots.long { gap: 6px; padding: 10px; }
.slots.long .slot { min-width: calc(clamp(36px, 7vw, 70px) * var(--w, 1)); font-size: clamp(36px, 7vw, 66px); }
.slot.next { border-color: var(--accent); animation: blink 1s ease-in-out infinite; }
.slot.filled { border-color: var(--good); animation: cheer .35s; }
.slot.team.filled { color: var(--hi); }
@keyframes blink { 50% { border-color: #ffd2bd; } }
.tiles { display: flex; flex-wrap: wrap; justify-content: center; gap: clamp(10px, 2vw, 16px); max-width: 760px; }
.tile {
  min-width: clamp(64px, 11vw, 92px); height: clamp(64px, 11vw, 92px); padding: 0 12px; border-radius: 22px;
  background: #fff; box-shadow: 0 6px 0 #e2d5c0; font-size: clamp(40px, 7vw, 60px); font-weight: 700;
  transition: transform .1s, opacity .25s;
}
.tile.team { background: #fff1ec; color: var(--hi); }
.tile:active { transform: translateY(4px); box-shadow: none; }
.tile.used { opacity: 0; pointer-events: none; }
.tile.wrong { animation: shake .4s; background: #ffe1e5; }
.tile.hint { animation: pulse .8s ease-in-out infinite; box-shadow: 0 0 0 5px #ffc531, 0 6px 0 #e2d5c0; }

/* ---------- trace it ---------- */
.trace-pic { width: clamp(90px, 15vh, 150px); border-radius: 22px; background: #fff; padding: 6px; box-shadow: var(--shadow); }
.speaker.small { width: 90px; height: 90px; font-size: 42px; }
.trace-box { position: relative; width: 100%; max-width: 1000px; background: #fff; border-radius: 30px; box-shadow: var(--shadow); overflow: hidden; }
.trace-box canvas { position: absolute; inset: 0; }
#ink { touch-action: none; cursor: crosshair; }
.loading { text-align: center; font-size: 60px; margin-top: 30vh; animation: pulse 1s infinite; }

/* ---------- finish ---------- */
.finish { min-height: 85dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; text-align: center; }
.finish h1 { font-size: clamp(44px, 8vw, 72px); margin: 0; }
.finish p { font-size: 22px; color: var(--soft); margin: 0; }
.big-stars { display: flex; gap: 10px; font-size: clamp(80px, 14vw, 130px); color: #e9dfd0; }
.big-stars span.on { color: #ffc531; animation: starIn .6s both; text-shadow: 0 6px 0 #e2a400; }
@keyframes starIn { from { transform: scale(0) rotate(-90deg); } 70% { transform: scale(1.25); } }
.finish-btns { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; margin: 10px 0; }

/* ---------- books ---------- */
.shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; }
.book-tile { background: #fff; border-radius: 24px; padding: 10px 10px 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 4px; }
.book-tile img { width: 100%; aspect-ratio: 16/11; object-fit: cover; border-radius: 16px; }
.book-tile b { font-size: 22px; padding: 0 6px; }
.book-tile small { color: var(--soft); font-size: 15px; padding: 0 6px; }
.book-cover { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.book-cover img { width: min(760px, 100%); border-radius: 30px; box-shadow: var(--shadow); border: 10px solid #fff; }
.book-cover h2 { font-size: clamp(40px, 7vw, 64px); margin: 0; }
.page { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.page-art { width: min(820px, 100%); max-height: 56dvh; object-fit: contain; border-radius: 26px; box-shadow: var(--shadow); background: #fff; }
.sentence { font-size: clamp(42px, 7vw, 72px); font-weight: 700; text-align: center; line-height: 1.35; max-width: 900px; }
.tw { font-size: inherit; font-weight: inherit; padding: 0 6px; border-radius: 14px; transition: background .15s; }
.tw.reading { background: #ffe58a; }
.tw.bounce { animation: cheer .45s; background: #dff7ef; }
.page-nav { display: flex; align-items: center; gap: 22px; }

/* ---------- grown-ups ---------- */
.panel { background: #fff; border-radius: 24px; padding: 20px; box-shadow: var(--shadow); font-family: system-ui, sans-serif; font-size: 17px; line-height: 1.5; }
.report { border-collapse: collapse; margin: 12px 0 20px; width: 100%; font-size: 15px; }
.report td { padding: 5px 8px; border-bottom: 1px solid #eee; color: #e2a400; white-space: nowrap; }
.report td:first-child { color: var(--ink); font-weight: 600; }

.report-wrap { overflow-x: auto; }
.panel.offline { margin-top: 18px; }
.panel h3 { margin: 0 0 6px; font-family: var(--font); font-size: 24px; }
.panel .tip { color: var(--soft); font-size: 15px; }
#offline-status { margin-left: 8px; font-weight: 600; }

/* ---------- confetti ---------- */
#confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 10; }
#confetti i { position: absolute; top: -20px; width: 12px; height: 18px; border-radius: 3px; animation: fall linear forwards; }
@keyframes fall { to { top: 105vh; transform: rotate(720deg) translateX(40px); } }

@media (max-width: 600px) {
  .sound-big { width: 110px; height: 110px; font-size: 40px; }
  .mini-word { width: 84px; } .mini-word img { width: 72px; height: 72px; }
  .speaker { width: 110px; height: 110px; font-size: 50px; }
}
