:root {
  --bg1: #fff6e0; --bg2: #e0f4ff; --ink: #2d2a4a; --muted: #6b6890;
  --purple: #6c5ce7; --pink: #fd79a8; --orange: #ff9f43; --green: #00b894;
  --blue: #0984e3; --yellow: #fdcb6e; --red: #e17055; --card: #ffffff;
  --radius: 22px; --shadow: 0 6px 0 rgba(45, 42, 74, .12), 0 12px 24px rgba(45, 42, 74, .08);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Fredoka', 'Comic Sans MS', system-ui, sans-serif; color: var(--ink);
  background: linear-gradient(160deg, var(--bg1), var(--bg2)) fixed; min-height: 100vh;
}
a { color: inherit; }
button { font-family: inherit; }
main { max-width: 1000px; margin: 0 auto; padding: 20px 16px 80px; }
.loading { text-align: center; font-size: 28px; padding: 80px 0; }

.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; background: var(--purple); color: #fff; box-shadow: 0 4px 0 rgba(0,0,0,.15);
}
.topbar[hidden] { display: none; }
.brand { font-weight: 700; font-size: 22px; text-decoration: none; white-space: nowrap; }
.topbar nav { display: flex; gap: 6px; margin-left: auto; }
.topbar nav a { text-decoration: none; padding: 8px 14px; border-radius: 999px; background: rgba(255,255,255,.15); font-weight: 600; }
.topbar nav a:hover, .topbar nav a.on { background: #fff; color: var(--purple); }
.who { text-decoration: none; font-size: 26px; background: #fff; border-radius: 50%; width: 46px; height: 46px; display: grid; place-items: center; flex: none; }
@media (max-width: 640px) { .topbar nav a span, .brand { display: none; } .topbar nav { margin-left: 0; } .topbar { justify-content: space-between; } }

h1 { font-size: clamp(28px, 5vw, 44px); margin: 10px 0 6px; }
h2 { font-size: 28px; margin: 24px 0 12px; }
h3 { font-size: 22px; margin: 0 0 8px; }
.sub { color: var(--muted); font-size: 20px; margin: 0 0 18px; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }

.btn {
  border: 0; cursor: pointer; font-size: 20px; font-weight: 600; padding: 14px 26px; border-radius: 999px;
  color: #fff; background: var(--purple); box-shadow: 0 5px 0 rgba(0,0,0,.2); transition: transform .08s;
  text-decoration: none; display: inline-flex; align-items: center; gap: 8px;
}
.btn:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0,0,0,.2); }
.btn.green { background: var(--green); } .btn.orange { background: var(--orange); } .btn.pink { background: var(--pink); }
.btn.blue { background: var(--blue); } .btn.ghost { background: #fff; color: var(--purple); }
.btn.big { font-size: 26px; padding: 18px 36px; }
.btn.small { font-size: 16px; padding: 8px 16px; }
.btn:disabled { opacity: .5; cursor: default; }

/* Profiles */
.hero { text-align: center; padding: 20px 0; }
.hero .logo { font-size: 80px; animation: bob 2.5s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-10px) rotate(-4deg); } }
.profiles { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; margin: 20px 0; }
.profile { width: 160px; text-align: center; cursor: pointer; border: 0; background: #fff; border-radius: var(--radius); padding: 18px 10px; box-shadow: var(--shadow); font-size: 20px; font-weight: 600; }
.profile .av { font-size: 64px; display: block; }
.profile:hover { transform: translateY(-4px); }
.avatars { display: flex; flex-wrap: wrap; gap: 8px; }
.avatars button { font-size: 36px; background: #f3f1ff; border: 3px solid transparent; border-radius: 16px; width: 64px; height: 64px; cursor: pointer; }
.avatars button.on { border-color: var(--purple); background: #fff; }
input[type=text], textarea {
  font-family: 'Lexend', sans-serif; font-size: 22px; padding: 12px 16px; border-radius: 14px; border: 3px solid #ddd8ff; width: 100%; color: var(--ink);
}
input[type=text]:focus, textarea:focus { outline: none; border-color: var(--purple); }
.levels { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.level-pick { border: 3px solid transparent; border-radius: 16px; padding: 12px; cursor: pointer; text-align: left; color: #fff; font-size: 18px; }
.level-pick small { display: block; font-size: 14px; opacity: .9; }
.level-pick.on { border-color: var(--ink); transform: scale(1.03); }

/* Home */
.welcome { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.welcome .av { font-size: 72px; }
.stats { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); margin: 18px 0; }
.stat { border-radius: var(--radius); padding: 16px; color: #fff; text-align: center; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 36px; }
.bubble { background: #fff; border-radius: var(--radius); padding: 16px 20px; margin: 10px 0; font-size: 20px; border-left: 8px solid var(--yellow); box-shadow: var(--shadow); }

/* Story cards */
.story-card { position: relative; border-radius: var(--radius); color: #fff; padding: 20px; text-decoration: none; box-shadow: var(--shadow); min-height: 210px; display: flex; flex-direction: column; transition: transform .15s; }
.story-card:hover { transform: translateY(-5px) rotate(-1deg); }
.story-card .emoji { font-size: 56px; }
.story-card h3 { font-size: 24px; margin: 8px 0 4px; }
.story-card p { margin: 0; opacity: .95; font-size: 16px; flex: 1; }
.story-card .meta { margin-top: 10px; font-size: 14px; display: flex; gap: 8px; flex-wrap: wrap; }
.pill { background: rgba(255,255,255,.25); border-radius: 999px; padding: 3px 10px; font-weight: 600; }
.story-card .stars { position: absolute; top: 14px; right: 16px; font-size: 22px; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.tab { border: 0; border-radius: 999px; padding: 10px 18px; font-size: 18px; font-weight: 600; cursor: pointer; background: #fff; color: var(--ink); box-shadow: 0 3px 0 rgba(0,0,0,.1); }
.tab.on { color: #fff; }

/* Reader */
.reader-head { border-radius: var(--radius); color: #fff; padding: 22px; box-shadow: var(--shadow); }
.progress-bar { height: 16px; background: #ece9ff; border-radius: 999px; overflow: hidden; margin: 14px 0; }
.progress-bar > div { height: 100%; background: linear-gradient(90deg, var(--green), var(--yellow)); transition: width .4s; }
.page { font-family: 'Lexend', sans-serif; font-size: 22px; line-height: 1.75; }
.page p { margin: 0 0 18px; position: relative; }
.page p.speaking { background: #fff3c4; border-radius: 10px; }
.page .say { border: 0; background: #f0edff; border-radius: 50%; width: 34px; height: 34px; font-size: 16px; cursor: pointer; margin-right: 6px; vertical-align: middle; }
.vocab-word { background: #fff3c4; border-bottom: 3px dotted var(--orange); cursor: help; border-radius: 4px; padding: 0 2px; }
.word-list { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.word-list div { background: #f7f5ff; border-radius: 14px; padding: 10px 14px; font-size: 17px; }
.word-list b { color: var(--purple); font-size: 20px; }

.question { margin-top: 20px; }
.question .q { font-size: 24px; font-weight: 600; margin-bottom: 14px; }
.choices { display: grid; gap: 10px; }
.choice { text-align: left; border: 3px solid #e3dfff; background: #fff; border-radius: 16px; padding: 14px 18px; font-size: 20px; cursor: pointer; font-family: 'Lexend', sans-serif; color: var(--ink); }
.choice:hover:not(:disabled) { border-color: var(--purple); background: #f7f5ff; }
.choice.right { border-color: var(--green); background: #dcfff4; }
.choice.wrong { border-color: var(--red); background: #ffe6df; }
.choice:disabled { cursor: default; }
.explain { margin-top: 12px; padding: 14px 18px; border-radius: 14px; font-size: 19px; }
.explain.good { background: #dcfff4; } .explain.bad { background: #fff3c4; }
.skill-tag { display: inline-block; font-size: 14px; background: #f0edff; color: var(--purple); border-radius: 999px; padding: 3px 10px; margin-bottom: 8px; }
.timer { font-size: 16px; opacity: .9; }

/* Results */
.big-stars { font-size: 72px; text-align: center; letter-spacing: 8px; }
.score { font-size: 64px; font-weight: 700; text-align: center; color: var(--purple); }

/* Spelling */
.spell-word { font-size: 56px; font-weight: 700; text-align: center; letter-spacing: 4px; color: var(--purple); margin: 10px 0; font-family: 'Lexend', sans-serif; }
.spell-hidden { filter: blur(14px); user-select: none; }
.spell-list { columns: 2; font-size: 24px; font-family: 'Lexend', sans-serif; padding-left: 28px; }
@media (max-width: 520px) { .spell-list { columns: 1; } }
.letters { text-align: center; font-size: 30px; letter-spacing: 6px; font-family: 'Lexend', sans-serif; }
.letters .ok { color: var(--green); } .letters .no { color: var(--red); text-decoration: underline; }

/* Progress */
.skillbar { margin: 10px 0; }
.skillbar .lbl { display: flex; justify-content: space-between; font-size: 18px; font-weight: 600; }
.skillbar .track { height: 22px; background: #ece9ff; border-radius: 999px; overflow: hidden; }
.skillbar .fill { height: 100%; border-radius: 999px; }
.chart { display: flex; align-items: flex-end; gap: 8px; height: 180px; padding: 10px 0; border-bottom: 3px solid #ece9ff; overflow-x: auto; }
.chart .bar { flex: 1 0 28px; border-radius: 10px 10px 0 0; position: relative; min-width: 28px; }
.chart .bar span { position: absolute; top: -22px; width: 100%; text-align: center; font-size: 13px; font-weight: 600; }
.tips li { font-size: 18px; margin: 8px 0; font-family: 'Lexend', sans-serif; }

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

@media print {
  .topbar, .btn, .no-print { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; }
}

/* ---- wow extras ---- */
body::before, body::after { content: ''; position: fixed; z-index: -1; border-radius: 50%; filter: blur(40px); opacity: .45; animation: drift 18s ease-in-out infinite alternate; }
body::before { width: 380px; height: 380px; background: var(--pink); top: -120px; left: -100px; }
body::after { width: 420px; height: 420px; background: var(--blue); bottom: -160px; right: -120px; animation-delay: -9s; }
@keyframes drift { to { transform: translate(80px, 60px) scale(1.15); } }
.no-say .say, .no-say [data-say] { display: none !important; }

.map { display: flex; align-items: center; gap: 0; overflow-x: auto; padding: 26px 6px 14px; margin: 10px 0; }
.island { flex: 0 0 auto; width: 120px; text-align: center; text-decoration: none; background: #fff; border-radius: 26px; padding: 12px 8px; box-shadow: var(--shadow); border: 4px solid var(--c); position: relative; transition: transform .2s; }
.island .ic { font-size: 34px; display: block; }
.island b { display: block; font-size: 16px; color: var(--c); }
.island small { color: var(--muted); font-size: 12px; }
.island.here { transform: scale(1.12); background: var(--c); }
.island.here b, .island.here small { color: #fff; }
.island.next { opacity: .6; }
.island .you { position: absolute; top: -26px; left: 50%; transform: translateX(-50%); font-size: 34px; animation: bob 1.6s ease-in-out infinite; }
.path { flex: 1 0 24px; height: 6px; background: repeating-linear-gradient(90deg, var(--purple) 0 10px, transparent 10px 18px); }

.upload { margin-top: 14px; padding: 14px; border: 3px dashed #d6d0ff; border-radius: 18px; }
.upload p { margin: 0 0 10px; font-size: 18px; }
.photo-prev { max-width: 100%; max-height: 360px; border-radius: 14px; margin-top: 10px; display: block; }
.review { margin-top: 18px; background: #fffaf0; border-radius: 20px; padding: 18px; border: 3px solid var(--yellow); }
.review-top { text-align: center; }
.transcript { background: #fff; border-radius: 14px; padding: 12px 16px; font-size: 19px; }
.rubric { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin: 14px 0; }
.rubric div { background: #fff; border-radius: 14px; padding: 10px 14px; }
.rubric b { display: block; } .rubric span { color: var(--orange); font-size: 22px; letter-spacing: 3px; } .rubric small { display: block; color: var(--muted); font-size: 15px; }
.fixes div { background: #fff; border-radius: 14px; padding: 10px 14px; margin: 8px 0; font-size: 19px; font-family: 'Lexend', sans-serif; }
.fixes .old { color: var(--red); text-decoration: line-through; } .fixes .new { color: var(--green); font-weight: 600; }
.fixes small { display: block; color: var(--muted); font-size: 15px; }
.glowgrow { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.glowgrow > div { background: #fff; border-radius: 14px; padding: 12px 16px; font-size: 17px; }

.toggles { display: grid; gap: 12px; }
.toggle { display: flex; gap: 14px; align-items: center; background: #f7f5ff; border-radius: 16px; padding: 12px 16px; cursor: pointer; }
.toggle input { display: none; }
.toggle .sw { flex: none; width: 56px; height: 32px; border-radius: 999px; background: #ccc; position: relative; transition: background .2s; }
.toggle .sw::after { content: ''; position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: left .2s; }
.toggle input:checked + .sw { background: var(--green); }
.toggle input:checked + .sw::after { left: 28px; }
.toggle small { display: block; color: var(--muted); font-size: 15px; }
.kid { background: #f7f5ff; border-radius: 14px; padding: 12px 16px; margin: 8px 0; font-size: 18px; }
.kid summary { cursor: pointer; }
.wr-item { background: #fff; border-radius: 12px; padding: 10px 14px; margin: 10px 0; font-family: 'Lexend', sans-serif; font-size: 16px; }
code { background: #f0edff; padding: 2px 6px; border-radius: 6px; }
