/* Rainbow Island (Linsays Kids). Tablet first, big targets, Lin's palette; no outside fonts or scripts. */
:root {
  --cream: #fff6e0; --paper: #fffdf7; --ink: #2b2433; --ink-2: #5a5363; --hoodie: #f5b83d; --hoodie-ink: #7a5300;
  --leaf: #46a758; --sky: #4a8fe7; --rose: #e5484d; --line: #e9dfc6;
  --round: ui-rounded, "SF Pro Rounded", "Hiragino Maru Gothic ProN", "Arial Rounded MT Bold", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--cream); color: var(--ink); font-family: var(--round); -webkit-tap-highlight-color: transparent; }
body { padding: env(safe-area-inset-top, 0px) max(12px, env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px) max(12px, env(safe-area-inset-left, 0px)); }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible { outline: 4px solid var(--sky); outline-offset: 3px; }
#app { max-width: 1100px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; gap: 14px; padding-block: 12px 20px; }
.loading { text-align: center; font-size: 24px; padding: 40vh 0 0; }
.hint { margin: 0; color: var(--ink-2); font-size: 14px; line-height: 1.5; text-align: center; }

/* home */
.top { display: grid; grid-template-columns: 96px 1fr 80px; align-items: center; gap: 12px; }
.top h1 { margin: 0 0 4px; font-size: clamp(28px, 5vw, 44px); letter-spacing: .01em; }
.top .hint { text-align: left; }
.me { width: 96px; height: 106px; }
.pipbox { width: 80px; height: 130px; }
.go { align-self: center; border: 5px solid var(--ink); background: var(--hoodie); border-radius: 999px; padding: 18px 40px; font-size: clamp(22px, 4vw, 30px); font-weight: 800; box-shadow: 0 6px 0 var(--ink); transition: transform .12s, box-shadow .12s; }
.go:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--ink); }
.go.small { padding: 12px 28px; font-size: 20px; }
.map { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-top: 6px; }
.stop { position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 18px 10px; border: 4px solid var(--ink); border-radius: 26px; background: var(--paper); min-height: 130px; transition: transform .15s; }
.stop:hover { transform: translateY(-3px); }
.stop .n { width: 54px; height: 54px; border-radius: 50%; border: 4px solid var(--ink); display: grid; place-items: center; font-size: 26px; font-weight: 800; background: #fff; }
.stop .t { font-size: 16px; font-weight: 700; text-align: center; }
.stop.here { background: #fff1cf; box-shadow: 0 0 0 6px var(--hoodie); }
.stop.done .n { background: var(--leaf); color: #fff; }
.stop .ok { position: absolute; top: 8px; right: 12px; font-size: 22px; color: var(--leaf); font-weight: 800; }
.grown { margin-top: auto; display: flex; flex-direction: column; align-items: center; gap: 8px; padding-top: 18px; }
.hold { position: relative; overflow: hidden; border: 2px solid var(--line); background: transparent; border-radius: 14px; padding: 8px 16px; display: flex; flex-direction: column; align-items: center; color: var(--ink-2); touch-action: none; user-select: none; -webkit-user-select: none; }
.hold small { font-size: 12px; }
.hold::after { content: ""; position: absolute; inset: auto 0 0 0; height: 4px; background: var(--hoodie); transform: scaleX(0); transform-origin: left; }
.hold.holding::after { transform: scaleX(1); transition: transform 3s linear; }

/* lesson */
.lesson { position: relative; display: flex; flex-direction: column; gap: 12px; }
.home { align-self: flex-start; width: 52px; height: 52px; border-radius: 50%; border: 4px solid var(--ink); background: var(--paper); font-size: 26px; line-height: 1; }
.stage { width: min(100%, calc(58vh * 5 / 3)); height: auto; align-self: center; border: 5px solid var(--ink); border-radius: 28px; background: var(--paper); display: block; overflow: hidden; }
.stage .paint { transition: fill 1.1s ease, stroke 1.1s ease; }
.cap { margin: 0; min-height: 2.6em; text-align: center; font-size: clamp(20px, 3.4vw, 30px); font-weight: 700; line-height: 1.3; }
.cap b { display: inline-block; margin-right: 8px; padding: 2px 12px; border-radius: 999px; background: var(--hoodie); font-size: .6em; vertical-align: middle; }
.ctl { min-height: 150px; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 18px; }
.word { font-size: clamp(34px, 6vw, 54px); font-weight: 800; padding: 6px 24px; border: 4px dashed var(--ink); border-radius: 20px; background: #fff; }
.mic, .tick { width: 112px; height: 112px; border-radius: 50%; border: 5px solid var(--ink); background: var(--rose); color: #fff; display: grid; place-items: center; box-shadow: 0 6px 0 var(--ink); }
.mic svg { width: 54px; height: 54px; fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; }
.mic.on { animation: pulse 1s ease-in-out infinite; }
.tick { background: var(--leaf); font-size: 56px; font-weight: 800; }
.opts { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; }
.opt { width: 140px; height: 140px; border: 5px solid var(--ink); border-radius: 26px; background: #fff; padding: 10px; box-shadow: 0 5px 0 var(--ink); }
.opt svg { width: 100%; height: 100%; }
.opt .lt { font-size: 74px; font-weight: 800; }
.opt.right { background: #dff3e2; border-color: var(--leaf); }
.opt.wrong { animation: wiggle .4s; }
.letter { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: center; width: 100%; }
.letter b { font-size: clamp(64px, 11vw, 96px); font-weight: 800; color: var(--hoodie-ink); margin-right: 8px; }
.letter svg { width: 90px; height: 90px; }
.done { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: center; }
.dot { width: 38px; height: 38px; border-radius: 50%; border: 4px solid var(--ink); }

/* characters */
.char, .stage g[data-obj] > * { transform-box: fill-box; transform-origin: 50% 100%; }
.away { opacity: 0; pointer-events: none; }
#tum, #echo { transition: opacity .4s; }
.char.bounce { animation: bounce .9s ease; }
.char.talk { animation: talk .5s ease-in-out infinite alternate; }
.pop > * { animation: pop .9s ease; }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 30% { transform: translateY(-26px); } 60% { transform: translateY(0); } 75% { transform: translateY(-8px); } }
@keyframes talk { from { transform: scale(1, 1); } to { transform: scale(1.03, .97); } }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.18); } 100% { transform: scale(1); } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-6deg); } 75% { transform: rotate(6deg); } }

.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.confetti i { position: absolute; top: -20px; left: var(--x); width: 14px; height: 20px; background: var(--c); border-radius: 4px; animation: fall var(--d) ease-in forwards; animation-iteration-count: 2; }
@keyframes fall { to { transform: translateY(105vh) rotate(540deg); } }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media (max-width: 600px) {
  .top { grid-template-columns: 64px 1fr 56px; }
  .me { width: 64px; height: 72px; } .pipbox { width: 56px; height: 92px; }
  .opt { width: 104px; height: 104px; } .mic, .tick { width: 96px; height: 96px; }
  .stage { border-width: 4px; border-radius: 20px; }
}
