:root {
  --ink: #24304a;
  --muted: #6f7890;
  --purple: #6957d9;
  --purple-dark: #5140bf;
  --yellow: #ffc83d;
  --mint: #36c994;
  --pink: #ff6d8e;
  --sky: #56b9ed;
  --paper: #ffffff;
  --bg: #f7f5ff;
  --border: #e7e3f6;
  --shadow: 0 12px 28px rgba(65, 49, 130, .12);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 6%, rgba(255,200,61,.23), transparent 22rem),
    radial-gradient(circle at 95% 25%, rgba(86,185,237,.18), transparent 24rem),
    var(--bg);
  font-family: ui-rounded, "Arial Rounded MT Bold", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  padding-bottom: 88px;
}
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { border: 0; cursor: pointer; }

.topbar {
  height: 72px;
  padding: 10px max(18px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255,255,255,.88);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 30;
  border-bottom: 1px solid rgba(105,87,217,.1);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.brand-mark {
  width: 49px; height: 49px; border-radius: 16px; color: white; display: grid; place-items: center;
  font-weight: 1000; font-size: 14px; letter-spacing: -1px; transform: rotate(-3deg);
  background: linear-gradient(145deg, var(--purple), #8c74f4); box-shadow: 0 6px 14px rgba(105,87,217,.3);
}
.brand strong { display: block; font-size: 18px; line-height: 1.05; }
.brand small { color: var(--muted); font-weight: 700; font-size: 10px; letter-spacing: .6px; }
.icon-btn { width: 45px; height: 45px; border-radius: 15px; background: #f0edff; font-size: 20px; }

#app { width: min(100%, 1060px); margin: auto; padding: 22px 18px 32px; outline: 0; }
.hero {
  border-radius: 30px; padding: 28px 22px; overflow: hidden; position: relative;
  background: linear-gradient(135deg, #6957d9, #8d74ed); color: white; box-shadow: var(--shadow);
}
.hero::after { content: "Aa"; position: absolute; right: -5px; bottom: -45px; font-size: 190px; font-weight: 1000; opacity: .1; transform: rotate(-8deg); }
.eyebrow { margin: 0 0 6px; font-weight: 900; text-transform: uppercase; letter-spacing: 1.2px; font-size: 12px; opacity: .85; }
h1 { margin: 0; font-size: clamp(29px, 7vw, 48px); line-height: 1.04; letter-spacing: -1.3px; }
.hero p { max-width: 560px; line-height: 1.5; font-weight: 650; opacity: .9; margin: 12px 0 19px; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; position: relative; z-index: 2; }
.btn { min-height: 48px; padding: 0 19px; border-radius: 16px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; font-weight: 900; transition: transform .15s, box-shadow .15s; }
.btn:active, .letter-card:active, .choice:active { transform: scale(.96); }
.btn-primary { background: var(--yellow); color: #473408; box-shadow: 0 7px 0 #dca71b; }
.btn-light { background: white; color: var(--purple-dark); }
.btn-purple { background: var(--purple); color: white; box-shadow: 0 6px 0 #4434a6; }
.btn-soft { background: #f0edff; color: var(--purple-dark); }
.btn-mint { background: var(--mint); color: white; box-shadow: 0 6px 0 #219c70; }
.btn-wide { width: 100%; }

.progress-card { background: white; border: 1px solid var(--border); border-radius: 22px; padding: 17px; box-shadow: var(--shadow); margin-top: 18px; }
.progress-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-weight: 900; }
.stars { color: #f3a800; white-space: nowrap; }
.progress-track { height: 13px; background: #ece9f8; border-radius: 20px; overflow: hidden; margin-top: 12px; }
.progress-fill { height: 100%; min-width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--mint), #63d8b0); transition: width .5s; }
.section-head { display: flex; justify-content: space-between; align-items: end; margin: 26px 2px 13px; gap: 12px; }
.section-head h2, .page-title h1 { font-size: 24px; margin: 0; color: var(--ink); letter-spacing: -.5px; }
.section-head p, .page-title p { margin: 4px 0 0; color: var(--muted); font-size: 14px; font-weight: 650; }
.text-link { color: var(--purple); font-weight: 900; text-decoration: none; white-space: nowrap; }
.activity-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 13px; }
.activity-card { color: var(--ink); text-decoration: none; min-height: 150px; border-radius: 22px; padding: 17px; background: white; border: 1px solid var(--border); box-shadow: 0 7px 18px rgba(65,49,130,.07); }
.activity-card .emoji { display: block; font-size: 35px; margin-bottom: 13px; }
.activity-card strong { display: block; font-size: 17px; }
.activity-card small { display: block; color: var(--muted); line-height: 1.35; margin-top: 5px; font-weight: 650; }
.parent-note { margin-top: 22px; padding: 16px 18px; border-radius: 18px; background: #fff6d9; color: #6d5212; font-size: 13px; line-height: 1.45; }

.page-title { margin: 4px 2px 18px; }
.alphabet-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 11px; }
.letter-card { aspect-ratio: .88; border-radius: 19px; display: flex; flex-direction: column; align-items: center; justify-content: center; background: white; color: var(--ink); border: 2px solid var(--border); box-shadow: 0 5px 0 #ded9f0; font-weight: 1000; font-size: clamp(24px, 5vw, 37px); position: relative; }
.letter-card span { font-size: 11px; color: var(--muted); }
.letter-card.done { border-color: #7cdbb8; background: #f1fff9; }
.letter-card.done::after { content: "★"; color: #f4b820; font-size: 13px; position: absolute; right: 7px; top: 5px; }

.lesson-shell { display: grid; grid-template-columns: 1.08fr .92fr; gap: 18px; }
.lesson-card, .trace-card, .game-card { background: white; border: 1px solid var(--border); border-radius: 28px; padding: 22px; box-shadow: var(--shadow); }
.lesson-main { text-align: center; }
.lesson-top { display: flex; justify-content: space-between; align-items: center; }
.round-btn { width: 46px; height: 46px; border-radius: 16px; color: var(--purple); background: #f0edff; font-size: 22px; font-weight: 1000; }
.big-letter { font-size: clamp(130px, 26vw, 220px); line-height: .92; font-weight: 1000; color: var(--purple); text-shadow: 0 7px 0 #e7e2ff; letter-spacing: -14px; margin: 16px 0 8px; }
.big-letter small { font-size: .54em; color: var(--pink); }
.sound-line { font-size: 20px; font-weight: 900; margin: 8px 0 18px; }
.sound-line em { color: var(--purple); font-style: normal; }
.examples { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.example { background: #f8f7fd; border-radius: 17px; padding: 12px 6px; font-weight: 850; }
.example span { display: block; font-size: 33px; margin-bottom: 3px; }
.lesson-nav { display: flex; gap: 10px; margin-top: 17px; }
.lesson-nav .btn { flex: 1; }

.trace-card h2 { margin: 0; font-size: 21px; }
.trace-card p { color: var(--muted); font-size: 13px; font-weight: 650; }
.canvas-wrap { background: #faf9ff; border: 3px dashed #d8d2f3; border-radius: 22px; margin: 14px 0; overflow: hidden; position: relative; aspect-ratio: 1; }
#traceCanvas { width: 100%; height: 100%; touch-action: none; display: block; }
.trace-actions { display: flex; gap: 10px; }
.trace-actions button { flex: 1; }

.word-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.word-picture { text-align: center; padding: 12px; }
.word-picture .giant-emoji { font-size: 105px; line-height: 1.15; filter: drop-shadow(0 9px 9px rgba(30,20,70,.12)); }
.word-picture h2 { margin: 5px 0; font-size: 25px; }
.slots { display: flex; justify-content: center; gap: 10px; margin: 22px 0; min-height: 66px; }
.slot { width: 62px; height: 66px; display: grid; place-items: center; background: #f4f1ff; border: 3px dashed #bdb3eb; border-radius: 16px; font-size: 31px; font-weight: 1000; text-transform: uppercase; }
.slot.filled { border-style: solid; border-color: var(--purple); background: white; }
.letter-bank { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.tile { width: 59px; height: 59px; border-radius: 16px; background: var(--yellow); color: #493708; font-size: 28px; font-weight: 1000; box-shadow: 0 5px 0 #dda918; }
.tile:disabled { opacity: .25; box-shadow: none; }
.word-controls { display: flex; gap: 10px; margin-top: 24px; }
.word-controls .btn { flex: 1; }
.mini-levels { display: flex; gap: 7px; margin-top: 14px; justify-content: center; flex-wrap: wrap; }
.level-dot { width: 36px; height: 36px; border-radius: 12px; background: #eeeaf9; color: var(--muted); font-weight: 900; }
.level-dot.active { background: var(--purple); color: white; }
.level-dot.complete { background: #dff9ef; color: #19825d; }

.quiz-wrap { max-width: 700px; margin: auto; }
.quiz-status { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 12px; font-weight: 900; }
.question { text-align: center; }
.question .prompt-emoji { font-size: 80px; display: block; margin: 15px 0 7px; }
.question h2 { font-size: 26px; margin: 5px 0 7px; }
.question p { color: var(--muted); font-weight: 700; }
.choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 21px; }
.choice { min-height: 90px; border-radius: 20px; background: #f8f7fd; border: 3px solid var(--border); color: var(--ink); font-weight: 1000; font-size: 34px; }
.choice.correct { background: #e5fff5; border-color: var(--mint); color: #14835e; }
.choice.wrong { background: #fff0f3; border-color: var(--pink); color: #c13f60; animation: shake .3s; }
.result { text-align: center; padding: 20px 5px; }
.result .trophy { font-size: 90px; }
.result h2 { font-size: 32px; margin: 5px; }

.bottom-nav { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: min(100%, 660px); min-height: 69px; padding: 7px max(10px, env(safe-area-inset-right)) calc(7px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(4, 1fr); background: rgba(255,255,255,.96); backdrop-filter: blur(15px); border: 1px solid var(--border); border-bottom: 0; border-radius: 23px 23px 0 0; z-index: 40; box-shadow: 0 -5px 22px rgba(44,34,90,.1); }
.bottom-nav a { color: var(--muted); text-decoration: none; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 11px; font-weight: 850; border-radius: 14px; }
.bottom-nav a span { font-size: 22px; line-height: 1.1; }
.bottom-nav a.active { color: var(--purple); background: #f1eeff; }
.toast { position: fixed; z-index: 100; left: 50%; bottom: 94px; transform: translate(-50%, 25px); background: #25304a; color: white; border-radius: 30px; padding: 12px 20px; font-weight: 850; opacity: 0; pointer-events: none; transition: .25s; text-align: center; width: max-content; max-width: 88vw; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
#confetti { position: fixed; inset: 0; z-index: 90; pointer-events: none; overflow: hidden; }
.confetti-piece { position: absolute; top: -15px; width: 10px; height: 16px; animation: fall 1.7s linear forwards; }
@keyframes fall { to { transform: translateY(105vh) rotate(720deg); opacity: .2; } }
@keyframes shake { 25% { transform: translateX(-7px); } 75% { transform: translateX(7px); } }

@media (max-width: 720px) {
  .activity-grid { grid-template-columns: 1fr; }
  .activity-card { min-height: 104px; display: grid; grid-template-columns: 60px 1fr; align-items: center; }
  .activity-card .emoji { grid-row: span 2; margin: 0; }
  .lesson-shell, .word-layout { grid-template-columns: 1fr; }
  .alphabet-grid { grid-template-columns: repeat(4, 1fr); gap: 9px; }
}
@media (max-width: 380px) {
  #app { padding-left: 12px; padding-right: 12px; }
  .brand strong { font-size: 16px; }
  .hero { padding: 24px 18px; }
  .lesson-card, .trace-card, .game-card { padding: 17px; }
  .alphabet-grid { gap: 7px; }
  .slot { width: 54px; height: 59px; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; animation-duration: .01ms !important; } }
