/* Word Island — mobile first. Reading text uses Andika (a typeface designed for new readers:
   single-storey a and g, clearly different b d p q). */

:root {
  --ink: #1e293b; --soft: #64748b; --sky: #38bdf8; --sea: #0ea5e9; --card: #fff;
  --go: #22c55e; --goD: #15803d; --warn: #f97316; --bad: #ef4444; --line: #e2e8f0;
  --read: 'Andika', 'Comic Sans MS', 'Trebuchet MS', sans-serif;
  --ui: 'Baloo 2', 'Andika', system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #0c4a6e; color: var(--ink); font-family: var(--read); overscroll-behavior: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; touch-action: manipulation; }
[hidden] { display: none !important; }

#app { position: relative; height: 100%; max-width: 480px; margin: 0 auto; overflow: hidden; background: linear-gradient(#bae6fd, #e0f2fe 45%, #fef9c3); }
.screen { position: absolute; inset: 0; display: none; flex-direction: column; }
.screen.on { display: flex; }

h1, h2, h3 { font-family: var(--ui); margin: 0; line-height: 1.1; }

/* Buttons: chunky, with a pressed-down edge */
.btn { font-family: var(--ui); font-weight: 800; font-size: 20px; padding: 12px 22px; border-radius: 18px; background: #fff; box-shadow: 0 5px 0 #cbd5e1; transition: transform .08s, box-shadow .08s; }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #cbd5e1; }
.btn.go { background: var(--go); color: #fff; box-shadow: 0 5px 0 var(--goD); }
.btn.go:active { box-shadow: 0 1px 0 var(--goD); }
.btn.big { font-size: 26px; padding: 16px 44px; }
.btn.danger { background: #fee2e2; color: #b91c1c; box-shadow: 0 5px 0 #fca5a5; margin: 16px 0 30px; display: block; width: 100%; }

/* Splash and result */
#splash, #result, #place { align-items: center; justify-content: center; gap: 14px; padding: 24px; text-align: center; }
.pip { width: 150px; line-height: 0; }
#splash h1, #result h1 { font-size: 46px; color: #0369a1; }
#place h1 { font-size: 32px; color: #0369a1; }
#place .tag { max-width: 320px; line-height: 1.4; }
#place #plSkip { font-size: 16px; color: var(--soft); }
.btn.wide { display: block; width: 100%; margin-top: 16px; font-size: 17px; }
.btn.unsure { order: 9; flex-basis: 100%; font-size: 15px; font-weight: 600; color: var(--soft); background: none; box-shadow: none; padding: 4px 0 0; }
.btn.skip { font-size: 17px; color: var(--soft); }
.opt.picked { background: #dbeafe; box-shadow: 0 6px 0 #93c5fd; }
.world.side .banner { border: 3px dashed rgba(255,255,255,.75); }
.world.side .path { gap: 34px; }
.node.skipped { background: #a7f3d0; }
.node.skipped .nIcon { color: #047857; font-size: 30px; }
.tag { margin: 0; color: var(--soft); font-size: 18px; }
#nameInput { font: 700 22px var(--read); text-align: center; padding: 12px; border-radius: 16px; border: 3px solid #7dd3fc; width: 220px; outline: none; }
@keyframes bob { 50% { transform: translateY(-10px) rotate(-4deg); } }

/* Home */
.top { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; background: rgba(255,255,255,.85); backdrop-filter: blur(6px); }
.chip { font: 800 18px var(--ui); background: #fff; border-radius: 14px; padding: 4px 12px; box-shadow: 0 2px 0 var(--line); }
.hello { font: 800 20px var(--ui); color: #0369a1; }
#tabBody { flex: 1; overflow-y: auto; padding: 14px 14px 30px; -webkit-overflow-scrolling: touch; }
.tabs { display: flex; background: #fff; border-top: 2px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs button { flex: 1; padding: 8px 0 6px; font: 600 12px var(--ui); color: var(--soft); display: flex; flex-direction: column; align-items: center; }
.tabs button span { font-size: 24px; filter: grayscale(.8); opacity: .6; }
.tabs button.on { color: var(--sea); }
.tabs button.on span { filter: none; opacity: 1; transform: scale(1.15); }

/* Map */
.practice { display: block; width: 100%; margin-bottom: 16px; background: #fef3c7; box-shadow: 0 5px 0 #fcd34d; }
.world { margin-bottom: 26px; }
.banner { display: flex; align-items: center; gap: 12px; background: var(--c); color: #fff; padding: 12px 14px; border-radius: 20px; box-shadow: 0 5px 0 rgba(0,0,0,.18); }
.banner .wEmoji { font-size: 40px; }
.banner h2 { font-size: 21px; }
.banner p { margin: 2px 0 0; font-size: 13px; opacity: .95; line-height: 1.25; }
.banner b { margin-left: auto; font: 800 16px var(--ui); background: rgba(255,255,255,.25); padding: 3px 9px; border-radius: 12px; white-space: nowrap; }
.path { display: flex; flex-direction: column; align-items: center; gap: 40px; padding: 26px 0 6px; }
.node { position: relative; width: 78px; height: 78px; border-radius: 50%; background: var(--c); box-shadow: 0 7px 0 rgba(0,0,0,.22), inset 0 -6px 0 rgba(0,0,0,.1); display: grid; place-items: center; }
.node:active { margin-top: 4px; margin-bottom: -4px; box-shadow: 0 3px 0 rgba(0,0,0,.22); }
.node .nIcon { font-size: 36px; color: #fff; line-height: 1; }
.node .nStars { position: absolute; top: -13px; left: 50%; transform: translateX(-50%); font-size: 13px; white-space: nowrap; }
.node .nTitle { position: absolute; top: 84px; left: 50%; transform: translateX(-50%); font: 600 12px/1.15 var(--ui); color: var(--soft); width: 128px; text-align: center; }
.node.locked { background: #cbd5e1; }
.node.locked .nIcon { font-size: 26px; opacity: .7; }
.node.boss { width: 92px; height: 92px; border-radius: 28px; }
.node.boss .nTitle { top: 98px; }
.node.done { background: #fbbf24; }
.node.current { animation: pulse 1.3s ease-in-out infinite; }
.node.current::before { content: ''; position: absolute; inset: -9px; border-radius: inherit; border: 4px solid var(--c); opacity: .45; }
.node .nPip { position: absolute; right: -50px; top: -26px; width: 56px; line-height: 0; pointer-events: none; }
@keyframes pulse { 50% { scale: 1.08; } }

/* Words, stickers, grown-ups */
.tabTitle { font-size: 24px; color: #0369a1; margin: 28px 0 10px; }
.tabTitle:first-child { margin-top: 6px; }
.tabSub { font-size: 16px; color: var(--soft); margin: 16px 0 8px; }
.tabNote { color: var(--soft); font-size: 14px; margin: 10px 2px 12px; line-height: 1.45; }
.tabTitle + .tabNote { margin-top: -4px; }
.empty { text-align: center; padding: 40px 10px; color: var(--soft); font-size: 18px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.wchip { background: #fff; border-radius: 14px; padding: 6px 12px 4px; font: 700 20px var(--read); box-shadow: 0 3px 0 var(--line); display: flex; flex-direction: column; align-items: center; }
.wchip small { font-size: 8px; letter-spacing: 2px; color: #f59e0b; }
.wchip.l5 { background: #fef3c7; box-shadow: 0 3px 0 #fcd34d; }
.stickers { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.sticker { aspect-ratio: 1; display: grid; place-items: center; font-size: 30px; border-radius: 16px; background: rgba(255,255,255,.55); border: 2px dashed #94a3b8; filter: grayscale(1); opacity: .5; }
.sticker.got { background: #fff; border: 2px solid #fbbf24; filter: none; opacity: 1; box-shadow: 0 3px 0 #fcd34d; }
.gate { text-align: center; padding: 50px 10px; display: flex; flex-direction: column; gap: 14px; align-items: center; color: var(--soft); }
.gate h2 { color: #0369a1; font-size: 26px; }
.gate .sum { font: 800 40px var(--ui); color: var(--ink); margin: 0; }
.gate input { font: 700 30px var(--read); text-align: center; width: 140px; padding: 10px; border-radius: 16px; border: 3px solid #7dd3fc; outline: none; }
.gate p { margin: 0; }
.holding { animation: fill 2s linear forwards; }
@keyframes fill { to { background: #0369a1; box-shadow: 0 5px 0 #0c4a6e; } }
.rows { background: #fff; border-radius: 16px; padding: 8px 14px; }
.row { display: flex; align-items: center; gap: 8px; padding: 7px 0; font-size: 14px; }
.row span { width: 46%; }
.row b { font-family: var(--ui); width: 34px; text-align: right; }
.mini { flex: 1; height: 9px; background: var(--line); border-radius: 9px; overflow: hidden; }
.mini i { display: block; height: 100%; border-radius: 9px; }
.plan { background: #fff; border-radius: 16px; padding: 14px 16px 8px 36px; margin: 0; font-size: 14px; line-height: 1.45; }
.plan li { margin-bottom: 8px; }
.soundGrid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.soundGrid button { font: 700 24px/1 var(--read); background: #fff; border-radius: 14px; height: 54px; padding-bottom: 4px; box-shadow: 0 4px 0 var(--line); transition: transform .08s, background .15s; }
.soundGrid button:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }
.soundGrid button.playing { background: #bbf7d0; box-shadow: 0 4px 0 #4ade80; }
.trow { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.trow b { font: 700 28px/1 var(--read); width: 30px; text-align: center; padding-bottom: 4px; }
.trow button { flex: 1; height: 50px; font: 800 18px var(--ui); background: #fff; border-radius: 14px; box-shadow: 0 4px 0 var(--line); }
.trow button:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }
.trow button.sel { background: #bbf7d0; box-shadow: 0 4px 0 #4ade80; }
.soundGrid button.failed { background: #fee2e2; box-shadow: 0 4px 0 #fca5a5; }
.set { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: #fff; border-radius: 14px; padding: 12px 14px; margin-bottom: 10px; font-size: 16px; min-height: 56px; }
.set input[type=checkbox] { width: 26px; height: 26px; }
.set input:not([type=checkbox]):not([type=range]) { font: inherit; padding: 6px 10px; border: 2px solid var(--line); border-radius: 10px; width: 140px; }

/* Lesson chrome */
.lbar { display: flex; align-items: center; gap: 10px; padding: 12px 14px 6px; }
#quitBtn { font-size: 22px; color: var(--soft); width: 44px; height: 44px; }
.prog { flex: 1; height: 16px; background: #fff; border-radius: 16px; overflow: hidden; box-shadow: inset 0 2px 0 rgba(0,0,0,.08); }
.prog i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #4ade80, #22c55e); border-radius: 16px; transition: width .4s; }
#lessonTitle { font: 600 12px var(--ui); color: var(--soft); max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prompt { display: flex; align-items: center; gap: 10px; padding: 4px 14px; min-height: 52px; }
#again { position: relative; width: 58px; height: 62px; flex: none; line-height: 0; }
#again i { position: absolute; right: -4px; bottom: 0; font-size: 15px; font-style: normal; line-height: 1; background: #fff; border-radius: 50%; padding: 3px; box-shadow: 0 2px 0 #bae6fd; }
#again:active { transform: scale(.92); }
#promptText { font: 800 19px var(--ui); color: #0369a1; line-height: 1.15; }
.stage { flex: 1; overflow-y: auto; display: flex; flex-direction: column; align-items: center; justify-content: safe center; gap: 18px; padding: 8px 16px; }
#foot { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 14px; padding: 10px 16px calc(16px + env(safe-area-inset-bottom)); min-height: 86px; }
#foot .go { min-width: 180px; }
#foot .help { font-size: 28px; padding: 8px 14px; }
.mic { width: 84px; height: 84px; border-radius: 50%; font-size: 40px; padding: 0; background: var(--sea); box-shadow: 0 6px 0 #0369a1; }
.mic.live { background: var(--bad); box-shadow: 0 6px 0 #991b1b; animation: listen 1s ease-in-out infinite; }
@keyframes listen { 50% { box-shadow: 0 6px 0 #991b1b, 0 0 0 16px rgba(239,68,68,.22); } }
.micStatus { width: 100%; text-align: center; font-size: 15px; color: var(--soft); min-height: 20px; }
#toast { position: absolute; top: 38%; left: 50%; translate: -50% 0; font: 800 30px var(--ui); color: #fff; background: var(--go); padding: 8px 24px; border-radius: 40px; box-shadow: 0 6px 0 var(--goD); opacity: 0; pointer-events: none; white-space: nowrap; }
#toast.show { animation: toast 1s ease-out; }
@keyframes toast { 0% { opacity: 0; scale: .5; } 20% { opacity: 1; scale: 1.1; } 70% { opacity: 1; scale: 1; } 100% { opacity: 0; translate: -50% -40px; } }

/* Game pieces */
.pic { font-size: 64px; line-height: 1.1; display: inline-block; }
.pic svg { width: 1em; height: 1em; vertical-align: -0.12em; }
.wordPic { width: 1.25em; height: 1.25em; display: block; object-fit: contain; pointer-events: none; user-select: none; }
.pic:has(> .wordPic) { line-height: 0; }
.card { background: var(--card); border-radius: 28px; padding: 22px 26px; box-shadow: 0 7px 0 rgba(0,0,0,.1); text-align: center; width: 100%; max-width: 340px; display: block; }
.card .letters { font: 700 96px var(--read); color: var(--sea); line-height: 1; }
.card .big { font-size: 84px; line-height: 1.1; }
.card h2 { font-size: 26px; color: #0369a1; margin-top: 6px; }
.card .cap { font-size: 24px; margin: 8px 0 0; color: var(--soft); }
.card .cap b { color: var(--warn); }
.card.q h2 { font-size: 22px; }
.card.q .big { font-size: 44px; }
.word { font: 700 72px var(--read); color: var(--ink); line-height: 1.1; padding: 4px 14px; border-radius: 18px; transition: background .2s; }
.word.heard { background: #bbf7d0; }
.bigLetter { font: 700 100px var(--read); color: var(--sea); line-height: 1; }
.bigPic { background: #fff; border-radius: 28px; padding: 10px 28px; box-shadow: 0 6px 0 rgba(0,0,0,.1); }
.bigPic .pic { font-size: 100px; }
.speaker { width: 120px; height: 120px; border-radius: 50%; font-size: 60px; background: #fff; box-shadow: 0 7px 0 #bae6fd; }
.speaker:active { transform: translateY(5px); box-shadow: 0 2px 0 #bae6fd; }

.opts { display: grid; gap: 12px; width: 100%; max-width: 380px; }
.opts.pics, .opts.letters, .opts.houses { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.opts.letters:has(.opt:nth-child(4)) { grid-template-columns: repeat(4, 1fr); }
.opts.words { grid-template-columns: 1fr; max-width: 300px; }
.opts.scenes { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.opt { background: #fff; border-radius: 20px; padding: 12px 6px; box-shadow: 0 6px 0 #cbd5e1; font: 700 34px var(--read); min-height: 76px; display: flex; flex-direction: column; align-items: center; justify-content: center; transition: transform .08s, opacity .25s; }
.opt:active { transform: translateY(4px); box-shadow: 0 2px 0 #cbd5e1; }
.opts.letters .opt { font-size: 52px; line-height: 1; padding: 8px 0 14px; }
.opt small { font: 700 20px var(--read); color: var(--soft); }
.opt.right { background: #bbf7d0; box-shadow: 0 6px 0 #4ade80; animation: pop .35s; }
.opt.wrong { animation: shake .35s; opacity: .3; box-shadow: none; }
.opts.scenes .pic { font-size: 30px; }
.opts.scenes .scene > div { gap: 0; }
.scene { display: flex; flex-direction: column; align-items: center; line-height: 1; }
.scene > div { display: flex; gap: 4px; }
.stage > div > .scene .pic, .card .scene .pic { font-size: 76px; }
.scenePic { display: block; width: 220px; max-width: 100%; aspect-ratio: 1; border-radius: 18px; pointer-events: none; user-select: none; }
.opts.scenes .opt { padding: 6px; }
.opts.scenes .scene, .storyAll .scene { width: 100%; }
.opts.scenes .scenePic { width: 100%; border-radius: 14px; }
.storyAll .scene { width: 74px; }
.storyAll .scenePic { width: 74px; border-radius: 10px; }
@keyframes pop { 50% { scale: 1.12; } }
@keyframes shake { 20%, 60% { translate: -7px 0; } 40%, 80% { translate: 7px 0; } }
.shake { animation: shake .35s; }
.pop { animation: pop .35s; }

.sounds { display: flex; gap: 10px; }
.sbtn { font: 700 56px var(--read); line-height: 1; width: 84px; height: 96px; padding-bottom: 8px; background: #fff; border-radius: 20px; box-shadow: 0 6px 0 #fdba74; border-bottom: 6px solid var(--warn); }
.sbtn.on { background: #ffedd5; }
.sbtn.silent { opacity: .35; border-bottom-style: dashed; }
.opts.lines .opt { font-size: 22px; line-height: 1.25; padding: 12px 14px; min-height: 60px; }
.opt.lit { background: #fde68a; box-shadow: 0 6px 0 #f59e0b; }
.storyAll { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 420px; }
.storyAll .line { display: flex; align-items: center; gap: 10px; background: #fff; border-radius: 16px; padding: 8px 12px; box-shadow: 0 3px 0 var(--line); transition: background .15s; }
.storyAll .line.lit { background: #fde68a; }
.storyAll .scene { flex: none; width: 74px; }
.storyAll .scene .pic { font-size: 26px; }
.storyAll .sentence { font-size: 23px; line-height: 1.35; text-align: left; }
.storyAll .sw { padding: 0 3px; }
.t-storyAll.stage { justify-content: flex-start; padding-top: 4px; }
.opts.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.opts.five, .opts.letters.five:has(.opt:nth-child(4)) { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.opts.five .opt { font-size: 38px; min-height: 62px; padding: 4px 0 10px; }
.opts.four.pics .pic { font-size: 50px; }
.opts.wordish .opt { font-size: 28px; padding: 14px 2px 18px; line-height: 1; }
.pic.flip { transform: scaleX(-1); }
.gridPic { display: grid; gap: 6px; background: #fff; border-radius: 20px; padding: 10px; box-shadow: 0 5px 0 rgba(0,0,0,.1); }
.gridPic.g2 { grid-template-columns: repeat(2, 58px); }
.gridPic.g3 { grid-template-columns: repeat(3, 52px); }
.gridPic span, .gridPic button { font-size: 38px; line-height: 1.25; text-align: center; border-radius: 12px; padding: 0; }
.gridPic button { background: #f1f5f9; }
.gridPic .found { background: #bbf7d0; box-shadow: 0 0 0 3px #4ade80; }
.arrow { font-size: 22px; line-height: 1; }
.t-spotDiff.stage { gap: 8px; }
.wanted { background: #fff; border-radius: 18px; padding: 2px 18px; box-shadow: 0 4px 0 rgba(0,0,0,.1); }
.wanted .pic { font-size: 44px; }
.busy { position: relative; width: 100%; max-width: 380px; height: min(46vh, 300px); background: #fff; border-radius: 24px; overflow: hidden; box-shadow: 0 5px 0 rgba(0,0,0,.1); flex: none; }
.busy button { position: absolute; line-height: 1; padding: 0; }
.busy .found { filter: drop-shadow(0 0 6px #22c55e) drop-shadow(0 0 2px #22c55e); z-index: 9 !important; }
.t-busyFind.stage, .t-busyCount.stage { gap: 10px; }
.practice.due { animation: pulse 1.6s ease-in-out infinite; }
.magicWord { font: 700 64px/1.1 var(--read); }
.magicWord b { color: var(--warn); }
.dots { font-size: 34px; letter-spacing: 10px; color: var(--sea); min-height: 44px; }
.sbtn.rime { width: auto; min-width: 124px; padding-left: 16px; padding-right: 16px; }
.sbtn:active { transform: translateY(4px); }
.slots { display: flex; gap: 8px; }
.slot { width: 68px; height: 80px; border-radius: 16px; border: 3px dashed #94a3b8; display: grid; place-items: center; font: 700 50px var(--read); line-height: 1; padding-bottom: 6px; }
.slot.full { border: 3px solid var(--go); background: #fff; }
.slot.hot { border-color: var(--warn); background: #ffedd5; color: var(--warn); }
.tray { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; max-width: 380px; }
.tile { font: 700 44px var(--read); line-height: 1; min-width: 64px; height: 72px; padding: 0 12px 6px; background: #fff; border-radius: 16px; box-shadow: 0 5px 0 #cbd5e1; }
.tile.wide { font-size: 30px; height: 60px; padding: 0 16px 4px; }
.tile:active { transform: translateY(4px); box-shadow: 0 1px 0 #cbd5e1; }
.tile.used { visibility: hidden; }

.rime { display: flex; align-items: center; justify-content: center; gap: 8px; font: 700 54px var(--read); line-height: 1; }
.rime i { font-style: normal; background: #e0f2fe; border-radius: 14px; padding: 4px 14px 10px; }
.rime u { text-decoration: none; color: var(--soft); font-size: 30px; }
.rime b { background: #ffedd5; color: var(--warn); border-radius: 14px; padding: 4px 16px 10px; }
.famList { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 16px; }
.famList span { font: 700 26px var(--read); background: #f1f5f9; padding: 2px 12px 4px; border-radius: 12px; }

.pad { width: min(72vw, 270px); height: min(72vw, 270px); background: #fff; border-radius: 26px; box-shadow: 0 6px 0 rgba(0,0,0,.1); touch-action: none; }
.t-write .pad { width: min(56vw, 210px); height: min(56vw, 210px); }
.bigPic.small { padding: 4px 20px; }
.bigPic.small .pic { font-size: 54px; }
.t-write .slot { width: 52px; height: 60px; font-size: 38px; }
.t-write.stage { gap: 10px; }
.chant { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; max-width: 380px; }
.chant button { font: 700 26px/1 var(--read); background: #fff; border-radius: 12px; min-width: 44px; padding: 8px 10px 12px; box-shadow: 0 3px 0 var(--line); transition: background .15s; }
.chant.wide button { font-size: 22px; padding: 8px 14px 11px; }
.chant button.lit { background: #fde68a; box-shadow: 0 3px 0 #f59e0b; }
.seqRow { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.seqRow span { font: 700 52px/1 var(--read); background: #fff; border-radius: 16px; padding: 8px 18px 14px; box-shadow: 0 4px 0 var(--line); }
.seqRow.wide span { font-size: 32px; padding: 10px 18px 14px; }
.seqRow span.q { background: #ffedd5; color: var(--warn); box-shadow: 0 4px 0 #fdba74; }
.opts.letters.pairs { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 300px; }
.opts.letters.pairs .opt { font-size: 44px; }
.sentence { font: 700 34px/1.5 var(--read); text-align: center; margin: 0; max-width: 400px; }
.sentence.line { min-height: 110px; width: 100%; border-bottom: 4px dashed #94a3b8; }
.sw { display: inline-block; padding: 0 6px; border-radius: 10px; transition: background .15s; }
.sw.lit { background: #fde68a; }
.sw.heard { background: #bbf7d0; }
.sw.next, .word.next { box-shadow: inset 0 -5px 0 var(--sea); }
.sw.missed, .word.missed { background: #fed7aa; }
.sw.oops, .word.oops { background: #fdba74; animation: shake .4s; }
.sw.blank { min-width: 84px; height: 44px; border-bottom: 5px solid var(--warn); vertical-align: bottom; }
.page { font: 600 14px var(--ui); color: var(--soft); }

/* Result */
.resStars { font-size: 60px; display: flex; gap: 8px; }
.resStars span { filter: grayscale(1); opacity: .3; }
.resStars span.lit { filter: none; opacity: 1; animation: starIn .5s backwards; }
@keyframes starIn { from { scale: 0; rotate: -90deg; } 70% { scale: 1.3; } }
.newSticker { font-size: 70px; width: 110px; height: 110px; margin: 0 auto; display: grid; place-items: center; background: #fff; border-radius: 26px; border: 4px solid #fbbf24; box-shadow: 0 6px 0 #fcd34d; animation: starIn .6s .9s backwards; }
.resSticker p { margin: 6px 0 0; font: 800 18px var(--ui); color: #b45309; }
.confetti { position: absolute; top: -40px; animation: fall 2.6s linear forwards; pointer-events: none; }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); } }

@media (max-height: 640px) {
  .pic { font-size: 52px; } .bigPic .pic { font-size: 76px; } .word { font-size: 58px; }
  .card .letters { font-size: 76px; } .bigLetter { font-size: 76px; } .speaker { width: 96px; height: 96px; font-size: 46px; }
  .stage { gap: 12px; }
}


/* Sound buttons: tap to hear the sound and pick it, then Check. */
.opts.listen .opt { position: relative; padding-top: 30px; }
.opts.listen .opt i { position: absolute; top: 6px; left: 0; right: 0; font-size: 18px; font-style: normal; line-height: 1; opacity: .8; }
.btn:disabled { opacity: .45; }

/* ---------- Pip, the vector parrot ---------- */
.pipSvg { display: block; width: 100%; height: auto; overflow: visible; }
.pipSvg .pAll { transform-origin: 60px 120px; animation: pipBob 2.6s ease-in-out infinite; }
.pipSvg .pHead { transform-origin: 60px 86px; animation: pipNod 5.2s ease-in-out infinite; }
.pipSvg .pEye { transform-box: fill-box; transform-origin: center; animation: pipBlink 4.3s infinite; }
.pipSvg .pWingL { transform-origin: 38px 84px; }
.pipSvg .pWingR { transform-origin: 82px 84px; }
.pipSvg .pTail { transform-origin: 60px 102px; animation: pipTail 2.6s ease-in-out infinite; }
.pipSvg .pShadow { transform-origin: 60px 126px; animation: pipShadow 2.6s ease-in-out infinite; }
.pipSvg .pBrow { opacity: 0; transition: transform .2s, opacity .2s; transform-box: fill-box; transform-origin: center; }
@keyframes pipBob { 50% { transform: translateY(-4px) scale(1.015, .985); } }
@keyframes pipShadow { 50% { transform: scaleX(.9); } }
@keyframes pipNod { 0%, 40%, 100% { transform: rotate(0); } 50%, 90% { transform: rotate(-4deg); } }
@keyframes pipBlink { 0%, 93%, 100% { transform: scaleY(1); } 96% { transform: scaleY(.08); } }
@keyframes pipTail { 50% { transform: rotate(5deg); } }

/* speaking: the beak opens and shuts */
.pipTalk .pipSvg .pBeakLow { animation: pipTalk .24s ease-in-out infinite alternate; }
@keyframes pipTalk { to { transform: translateY(6px); } }

/* right answer: jump and flap */
body[data-pip="cheer"] .pipSvg .pAll { animation: pipJump .5s ease-out 2; }
body[data-pip="cheer"] .pipSvg .pWingL { animation: pipFlapL .13s ease-in-out infinite alternate; }
body[data-pip="cheer"] .pipSvg .pWingR { animation: pipFlapR .13s ease-in-out infinite alternate; }
@keyframes pipJump { 0% { transform: translateY(0) scale(1.06, .92); } 45% { transform: translateY(-20px) scale(.96, 1.06); } 100% { transform: translateY(0) scale(1); } }
@keyframes pipFlapL { from { transform: rotate(10deg); } to { transform: rotate(70deg); } }
@keyframes pipFlapR { from { transform: rotate(-10deg); } to { transform: rotate(-70deg); } }

/* wrong answer: a puzzled head tilt, never a telling-off */
body[data-pip="oops"] .pipSvg .pHead { animation: pipTilt .9s ease-in-out; }
body[data-pip="oops"] .pipSvg .pBrow { opacity: 1; transform: rotate(-14deg); }
body[data-pip="oops"] .pipSvg .pBrowR { transform: rotate(14deg); }
@keyframes pipTilt { 25%, 75% { transform: rotate(-14deg); } 50% { transform: rotate(-10deg); } }

.pip.bounce .pipSvg .pAll { animation: pipJump .6s ease-out infinite; }
.pip.bounce .pipSvg .pWingL { animation: pipFlapL .15s ease-in-out infinite alternate; }
.pip.bounce .pipSvg .pWingR { animation: pipFlapR .15s ease-in-out infinite alternate; }

/* ---------- Motion ---------- */
.screen.on { animation: screenIn .28s ease-out; }
@keyframes screenIn { from { opacity: 0; transform: translateY(14px); } }
:where(#stage) > * { animation: rise .32s cubic-bezier(.2, .9, .3, 1.2) backwards; }
:where(#stage) > :nth-child(2) { animation-delay: .06s; }
:where(#stage) > :nth-child(3) { animation-delay: .12s; }
:where(.opts) > .opt { animation: optIn .34s cubic-bezier(.2, .9, .3, 1.3) backwards; }
:where(.opts) > .opt:nth-child(2) { animation-delay: .07s; }
:where(.opts) > .opt:nth-child(3) { animation-delay: .14s; }
:where(.opts) > .opt:nth-child(4) { animation-delay: .21s; }
:where(.opts) > .opt:nth-child(5) { animation-delay: .28s; }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } }
@keyframes optIn { from { opacity: 0; transform: translateY(18px) scale(.86); } }
#foot .btn { animation: rise .3s ease-out backwards; }
.btn.go:not(:disabled) { transition: transform .08s, box-shadow .08s, filter .15s; }
.btn.go:not(:disabled):hover { filter: brightness(1.06); }
.prog i { position: relative; transition: width .5s cubic-bezier(.3, 1.4, .5, 1); }
.prog i::after { content: ''; position: absolute; left: 8px; right: 8px; top: 3px; height: 4px; border-radius: 4px; background: rgba(255,255,255,.45); }
.node.current .nIcon { animation: starSpin 2.6s ease-in-out infinite; }
@keyframes starSpin { 0%, 70%, 100% { transform: rotate(0) scale(1); } 80% { transform: rotate(-14deg) scale(1.15); } 90% { transform: rotate(14deg) scale(1.15); } }
.chip { transition: transform .2s; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
