:root {
  --ink: #f4f1e8; --yellow: #ffe27a; --pink: #ff9fb2; --blue: #9fd8ff; --good: #7be0a0; --bad: #ff8a7a; --kid: #ffc8ec;
  --bg: #0e1714; --panel: #16211d; --panel-2: #1d2b26; --line: rgba(244,241,232,.12); --muted: rgba(244,241,232,.62);
  --chalk: 'Kalam', 'Comic Sans MS', cursive; --ui: 'Nunito', system-ui, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--ui); }
body { overflow: hidden; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
button:disabled { cursor: default; }
input { font: inherit; }
[hidden] { display: none !important; }
.root { height: 100dvh; max-width: 1180px; margin: 0 auto; position: relative; }
.screen { height: 100%; overflow-y: auto; padding: calc(12px + var(--safe-t)) 16px calc(96px + var(--safe-b)); display: flex; flex-direction: column; gap: 16px; }
.screen.loading { align-items: center; justify-content: center; }
.spinner { width: 40px; height: 40px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--yellow); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg) } }
.chalky { font-family: var(--chalk); font-weight: 700; font-size: 34px; color: var(--ink); text-shadow: 0 0 1px rgba(255,255,255,.4); }
.chalky.small { font-size: 19px; font-weight: 400; } .chalky.y { color: var(--yellow); }
.lede { margin: 0; color: var(--muted); font-size: 16.5px; line-height: 1.5; }
.chip { font-size: 11.5px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; padding: 5px 10px; border-radius: 999px; background: rgba(255,226,122,.14); color: var(--yellow); white-space: nowrap; }
.go { width: 100%; min-height: 56px; border-radius: 18px; background: var(--yellow); color: #1b1a10; font-weight: 900; font-size: 17px; box-shadow: 0 10px 26px rgba(255,226,122,.22); transition: transform .1s, opacity .2s; }
.go:active { transform: scale(.97); } .go:disabled { opacity: .45; box-shadow: none; }
.link { color: var(--muted); font-weight: 700; padding: 8px; }
.soft-btn { min-height: 50px; border-radius: 16px; background: var(--panel-2); border: 1px solid var(--line); font-weight: 800; }
.big-emoji { font-size: 44px; }
.chalkboard, .login-board, .today-board, .board {
  background: radial-gradient(120% 90% at 30% 10%, rgba(255,255,255,.075), transparent 60%), radial-gradient(140% 120% at 70% 100%, rgba(0,0,0,.35), transparent 60%), linear-gradient(160deg, #1f3d33, #142a21);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.06), inset 0 0 60px rgba(0,0,0,.3);
}
.toast { position: fixed; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translate(-50%, 20px); max-width: calc(100% - 32px); padding: 12px 16px; border-radius: 14px; background: #2b3d36; color: var(--ink); font-weight: 800; font-size: 14.5px; box-shadow: 0 12px 30px rgba(0,0,0,.4); opacity: 0; pointer-events: none; transition: .25s; z-index: 50; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- login ---------- */
.login { justify-content: center; max-width: 440px; margin: 0 auto; gap: 18px; padding-bottom: 40px; }
.login-board { border-radius: 26px; height: 190px; display: grid; place-items: center; align-content: center; gap: 6px; }
.brand { font-family: var(--chalk); font-size: 46px; margin: 6px 0 0; line-height: 1; color: var(--yellow); }
.login-form { display: grid; gap: 12px; }
.code-input { height: 64px; border-radius: 18px; border: 2px solid var(--line); background: var(--panel); color: var(--ink); text-align: center; font: 700 30px var(--chalk); letter-spacing: .18em; text-transform: uppercase; outline: none; }
.code-input:focus { border-color: rgba(255,226,122,.6); }

/* ---------- home ---------- */
.hello { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.hello h1 { margin: 0; font-size: 25px; font-weight: 900; }
.hello p { margin: 2px 0 0; color: var(--muted); font-weight: 700; font-size: 14px; }
.pills { display: flex; gap: 6px; flex: none; }
.pill { padding: 7px 11px; border-radius: 99px; background: var(--panel-2); border: 1px solid var(--line); font-weight: 900; font-size: 14px; }
.today { padding: 14px; border-radius: 26px; background: linear-gradient(160deg, #233f35, #172a23); border: 1px solid rgba(255,226,122,.22); box-shadow: 0 18px 40px rgba(0,0,0,.32); display: grid; gap: 12px; }
.today-board { border-radius: 18px; min-height: 120px; display: grid; place-items: center; padding: 16px; text-align: center; }
.today-board .chalky { font-size: 26px; line-height: 1.2; }
.today-text h2 { margin: 0; font-size: 19px; font-weight: 900; }
.today-text p { margin: 3px 0 0; color: var(--muted); font-weight: 700; font-size: 13.5px; }
.today.done-all { text-align: center; justify-items: center; padding: 26px 18px; }
.today.done-all h2 { margin: 0; } .today.done-all p { margin: 0; color: var(--muted); font-weight: 700; }
.path { display: grid; gap: 10px; position: relative; }
.path-title { margin: 8px 4px 2px; font-size: 12.5px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.node { display: flex; align-items: center; gap: 14px; text-align: left; padding: 8px; border-radius: 20px; position: relative; width: 82%; }
.node.right { margin-left: auto; flex-direction: row-reverse; text-align: right; }
.node .dot { width: 58px; height: 58px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 22px; border: 3px solid rgba(255,255,255,.08); background: var(--panel-2); }
.node.done .dot { background: #1f5a3f; border-color: var(--good); color: var(--good); font-weight: 900; }
.node.now .dot { background: var(--yellow); color: #1b1a10; box-shadow: 0 0 0 8px rgba(255,226,122,.14), 0 0 30px rgba(255,226,122,.4); animation: glow 2.4s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: 0 0 0 12px rgba(255,226,122,.08), 0 0 40px rgba(255,226,122,.5); } }
.node.locked { opacity: .55; }
.node-text { display: grid; gap: 2px; } .node-text b { font-size: 15px; } .node-text small { font-size: 12.5px; color: var(--yellow); letter-spacing: 1px; font-weight: 800; }
.node.locked small { color: var(--muted); letter-spacing: 0; }
.nav { position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); width: min(100%, 560px); height: calc(74px + var(--safe-b)); padding-bottom: var(--safe-b); display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); background: rgba(14,23,20,.92); backdrop-filter: blur(10px); z-index: 5; }
.nav-item { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11.5px; font-weight: 800; color: var(--muted); }
.nav-item span { font-size: 21px; } .nav-item.on { color: var(--yellow); }
.nav-item.cam span { width: 50px; height: 50px; border-radius: 17px; background: var(--pink); display: grid; place-items: center; margin-top: -22px; box-shadow: 0 10px 22px rgba(255,159,178,.35); }
.card-dark { padding: 14px; border-radius: 20px; background: var(--panel); border: 1px solid var(--line); }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; }
.stat { padding: 12px 6px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); text-align: center; }
.card-dark .stat { background: var(--panel-2); }
.stat b { display: block; font-size: 21px; font-weight: 900; } .stat small { color: var(--muted); font-weight: 800; font-size: 12px; }

/* ---------- photo ---------- */
.photo-drop { border-radius: 24px; border: 2px dashed rgba(255,159,178,.45); background: rgba(255,159,178,.05); min-height: 260px; display: grid; place-items: center; align-content: center; gap: 6px; text-align: center; padding: 16px; position: relative; overflow: hidden; }
.photo-drop b { font-size: 17px; } .photo-drop small { color: var(--muted); font-weight: 700; }
.photo-drop img { max-width: 100%; max-height: 50vh; border-radius: 14px; }
.photo-drop .change { position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,.55); padding: 5px 10px; border-radius: 99px; color: #fff; }
.q-input { height: 52px; border-radius: 16px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: 0 14px; font-weight: 700; outline: none; }

/* ---------- celebration ---------- */
.cele { align-items: center; text-align: center; justify-content: center; position: relative; overflow: hidden; }
.cele h1 { font-family: var(--chalk); font-size: 54px; margin: 0; line-height: 1; } .cele h1 em { font-style: normal; color: var(--yellow); }
.bigstars { font-size: 52px; letter-spacing: 6px; filter: drop-shadow(0 8px 18px rgba(255,226,122,.35)); }
.bigstars span { display: inline-block; animation: popin .6s cubic-bezier(.2,1.6,.4,1) both; }
.bigstars span:nth-child(2) { animation-delay: .25s } .bigstars span:nth-child(3) { animation-delay: .5s }
.bigstars .off { opacity: .2; filter: grayscale(1); }
@keyframes popin { from { transform: scale(0) rotate(-30deg); opacity: 0 } }
.next { width: 100%; padding: 14px; border-radius: 20px; background: linear-gradient(160deg, #233f35, #172a23); border: 1px solid rgba(123,224,160,.35); display: flex; gap: 12px; align-items: center; text-align: left; }
.next .ic { width: 48px; height: 48px; border-radius: 14px; background: rgba(123,224,160,.16); display: grid; place-items: center; font-size: 24px; }
.next b { display: block; } .next small { color: var(--good); font-weight: 800; }
.sent { margin: 0; color: var(--muted); font-weight: 800; font-size: 13.5px; }
.confetti { position: absolute; inset: 0; pointer-events: none; }
.confetti i { position: absolute; top: -20px; width: 6px; height: 16px; border-radius: 3px; opacity: .9; animation: fall 3.2s linear infinite; }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); } }

/* ---------- the classroom ---------- */
.room { height: 100%; display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto auto; position: relative; }
.room-top { padding: calc(10px + var(--safe-t)) 12px 8px; display: grid; grid-template-columns: auto 1fr; gap: 8px 10px; align-items: center; }
.round-btn { width: 36px; height: 36px; border-radius: 50%; background: var(--panel-2); border: 1px solid var(--line); font-weight: 900; color: var(--muted); }
.room-meta { display: flex; gap: 10px; align-items: center; min-width: 0; }
.room-title { font-weight: 800; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.progress { grid-column: 1 / -1; height: 5px; border-radius: 5px; background: var(--line); overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--good), var(--yellow)); border-radius: inherit; transition: width .6s ease; }
.in-quiz .progress i { background: linear-gradient(90deg, var(--pink), var(--yellow)); }
.stage { min-height: 0; display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: 8px; padding: 0 10px; }
.board { position: relative; min-height: 0; overflow: hidden; border-radius: 22px; touch-action: manipulation; }
.board-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.board-svg .chalk path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.hand { position: absolute; left: 0; top: 0; width: 110px; height: 80px; pointer-events: none; z-index: 3; opacity: 0; transition: opacity .35s; filter: drop-shadow(0 8px 10px rgba(0,0,0,.35)); will-change: transform; }
.hand.on { opacity: 1; }
.bubble { position: absolute; right: 12px; bottom: 12px; z-index: 5; max-width: min(78%, 320px); padding: 10px 14px; border-radius: 18px 18px 4px 18px; background: #2b3d36; border: 1px solid rgba(255,255,255,.12); font-weight: 800; font-size: 14.5px; line-height: 1.35; box-shadow: 0 10px 24px rgba(0,0,0,.3); }
.bubble small { display: block; font-size: 11px; color: var(--muted); letter-spacing: .05em; text-transform: uppercase; margin-bottom: 2px; }
.pinned { position: absolute; right: 12px; bottom: 12px; width: 34%; max-width: 160px; padding: 6px 6px 16px; background: #f6f2e8; border-radius: 4px; transform: rotate(-3deg); box-shadow: 0 12px 24px rgba(0,0,0,.4); z-index: 2; }
.pinned img { width: 100%; display: block; border-radius: 2px; }
.pinned::before { content: ''; position: absolute; top: -9px; left: 50%; width: 54px; height: 18px; margin-left: -27px; background: rgba(255,236,170,.75); transform: rotate(3deg); }
.teacher { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 18px; background: var(--panel); border: 1px solid var(--line); min-height: 58px; }
.voice { position: relative; width: 38px; height: 38px; flex: none; }
.voice-dot { position: absolute; inset: 0; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff3b8, var(--yellow) 60%); }
.voice-ring { position: absolute; inset: -4px; border-radius: 50%; border: 3px solid rgba(255,226,122,.55); transform: scale(var(--level, 1)); opacity: calc(var(--level, 1) - .9); transition: transform .08s linear; }
.caption { margin: 0; font-size: 14.5px; line-height: 1.4; font-weight: 700; color: var(--muted); min-width: 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.caption .w { transition: color .15s; } .caption .w.said { color: var(--ink); }
.live-tag { font-size: 10px; font-weight: 900; letter-spacing: .08em; color: #0e1714; background: var(--good); padding: 2px 6px; border-radius: 5px; margin-right: 6px; vertical-align: 2px; }
.thinking::after { content: '…'; display: inline-block; animation: dots 1.2s steps(4) infinite; width: 1.2em; overflow: hidden; vertical-align: bottom; }
@keyframes dots { from { width: 0 } to { width: 1.2em } }
.asking .caption { -webkit-line-clamp: 2; font-size: 13.5px; }
.paused .board-svg { opacity: .55; transition: opacity .3s; }

.panel { margin: 8px 10px 0; padding: 12px; border-radius: 20px; background: var(--panel); border: 1px solid var(--line); display: grid; gap: 10px; animation: rise .28s cubic-bezier(.2,.9,.3,1.1); }
@keyframes rise { from { transform: translateY(16px); opacity: 0 } }
.panel-title { margin: 0; text-align: center; font-weight: 900; font-size: 15.5px; }
.choices { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); }
.choices:empty { display: none; }
.choice { min-height: 56px; border-radius: 16px; background: var(--panel-2); border: 2px solid var(--line); font-family: var(--chalk); font-size: 21px; font-weight: 700; padding: 6px 10px; line-height: 1.1; transition: transform .1s, border-color .2s, background .2s, opacity .2s; }
.choice:active { transform: scale(.96); }
.choice.wrong { opacity: .35; text-decoration: line-through; text-decoration-color: var(--bad); border-color: transparent; pointer-events: none; }
.choice.right { border-color: var(--good); background: rgba(123,224,160,.14); color: var(--good); }
.shake { animation: shake .4s; }
@keyframes shake { 20%,60% { transform: translateX(-7px) } 40%,80% { transform: translateX(7px) } }
.number-in { display: grid; gap: 8px; }
.answer-row { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; }
.prefix { font: 700 26px var(--chalk); color: var(--yellow); padding-left: 6px; }
.answer { height: 52px; border-radius: 14px; display: grid; place-items: center; background: #1f3d33; border: 2px dashed rgba(255,200,236,.4); color: var(--kid); font: 700 30px var(--chalk); }
.answer:empty::before { content: '?'; color: rgba(255,255,255,.25); }
.answer.right { border: 2px solid var(--good); color: var(--good); }
.say-btn { --lvl: 0; width: 52px; height: 52px; border-radius: 50%; background: var(--panel-2); border: 2px solid rgba(255,200,236,.45); font-size: 22px; position: relative; }
.say-btn.on { background: rgba(255,200,236,.18); }
.say-btn::after, .mic::after { content: ''; position: absolute; inset: -6px; border-radius: 50%; border: 3px solid var(--kid); opacity: calc(var(--lvl, 0) * 1.2); transform: scale(calc(1 + var(--lvl, 0) * .35)); transition: transform .08s; }
.numpad { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.key { height: 44px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); font-size: 19px; font-weight: 800; }
.key:active { background: #26372f; }
.key.ok { grid-column: span 3; background: var(--good); color: #0e1714; font-size: 15px; font-weight: 900; }
.key.ok:disabled { opacity: .35; }
.mic { --lvl: 0; width: 84px; height: 84px; border-radius: 50%; background: var(--panel-2); border: 2px solid rgba(255,200,236,.45); font-size: 34px; display: grid; place-items: center; position: relative; justify-self: center; }
.mic.on { background: rgba(255,200,236,.16); }
.say-status { margin: 0; color: var(--muted); font-weight: 700; font-size: 14.5px; text-align: center; }
.typed { display: flex; gap: 8px; }
.typed input { flex: 1; min-width: 0; height: 46px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); color: var(--ink); font-weight: 700; padding: 0 12px; outline: none; }
.go-btn { height: 46px; border-radius: 12px; background: var(--good); color: #0e1714; font-weight: 900; padding: 0 18px; }

.dock { display: grid; grid-template-columns: 1fr 1.25fr 1fr .8fr .8fr; gap: 6px; padding: 8px 10px calc(10px + var(--safe-b)); }
.dk { height: 56px; border-radius: 15px; background: var(--panel-2); border: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; transition: transform .1s, background .2s; }
.dk span { font-size: 19px; line-height: 1; display: grid; place-items: center; } .dk small { font-size: 11px; font-weight: 800; color: var(--muted); white-space: nowrap; }
.dk:active { transform: scale(.95); }
.dk.waiting { background: rgba(255,226,122,.14); border-color: rgba(255,226,122,.5); } .dk.waiting small { color: var(--yellow); }
.dk.waiting span { animation: wave 1s ease-in-out infinite; }
.dk.on { background: rgba(123,224,160,.14); border-color: rgba(123,224,160,.5); } .dk.on small { color: var(--good); }
@keyframes wave { 0%,100% { transform: rotate(0) } 30% { transform: rotate(14deg) } 60% { transform: rotate(-8deg) } }

.cover { position: absolute; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; background: radial-gradient(120% 80% at 50% 0%, rgba(29,58,49,.95), rgba(14,23,20,.98)); }
.card { width: min(100%, 440px); display: grid; gap: 14px; justify-items: start; }
.card h1 { font-family: var(--chalk); font-weight: 700; font-size: clamp(36px, 10vw, 56px); line-height: 1.05; margin: 2px 0 0; }
.facts { list-style: none; display: flex; gap: 8px; padding: 0; margin: 0; flex-wrap: wrap; }
.facts li { padding: 8px 12px; border-radius: 12px; background: rgba(255,255,255,.06); font-weight: 700; color: var(--muted); }
.facts b { color: var(--ink); }
.card .link { justify-self: center; }

@media (min-width: 900px) {
  .screen { padding-left: max(16px, calc(50% - 280px)); padding-right: max(16px, calc(50% - 280px)); }
  .room { grid-template-columns: 1fr 360px; grid-template-rows: auto minmax(0, 1fr) auto; column-gap: 16px; padding: 0 16px 16px; }
  .room-top { grid-column: 1 / -1; padding: 16px 0 10px; }
  .stage { grid-column: 1; grid-row: 2 / 4; padding: 0; }
  .panel { grid-column: 2; grid-row: 2; align-self: end; margin: 0; }
  .dock { grid-column: 2; grid-row: 3; padding: 10px 0 0; }
}
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
