:root {
  --ink: #1d1b33;
  --muted: #5d5a78;
  --pri: #6c4ff6;
  --pink: #ff6b9d;
  --yellow: #ffd93d;
  --card: #fffdf8;
  --line: #e7e3fb;
  --page-bg: #f2f8ff;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: 'Fredoka', 'Baloo 2', system-ui, sans-serif; color: var(--ink); background: var(--page-bg); -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- game page ---------- */
body.game { height: 100%; overflow: hidden; background: #2fa8e0; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; overscroll-behavior: none; }
#world { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

.hud-top { position: fixed; top: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left)); pointer-events: none; }
.hud-top > * { pointer-events: auto; }
.scenes, .hud-right { display: flex; gap: 8px; }
.scenes { background: rgba(255,255,255,.35); padding: 6px; border-radius: 999px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }

.star-pill { display: flex; align-items: center; gap: 6px; border: 0; cursor: pointer; background: #fff; border-radius: 999px; padding: 6px 12px 6px 8px; box-shadow: 0 4px 0 rgba(0,0,0,.15); font-size: 22px; }
.star-pill b { font-size: 24px; min-width: 1.4em; text-align: left; }
.star-ico { font-size: 26px; display: inline-block; animation: spinStar 6s ease-in-out infinite; }
@keyframes spinStar { 0%, 80%, 100% { transform: rotate(0) scale(1); } 88% { transform: rotate(20deg) scale(1.2); } }
.next-track { width: 64px; height: 12px; border-radius: 999px; background: #efeafe; overflow: hidden; }
.next-track i { display: block; height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, #ffd93d, #ff9f43); transition: width .6s cubic-bezier(.34,1.56,.64,1); }
.star-pill.bump { animation: bump .5s cubic-bezier(.34,1.56,.64,1); }
@keyframes bump { 40% { transform: scale(1.25); } }

.round { position: relative; width: 52px; height: 52px; border-radius: 50%; border: 0; background: #fff; font-size: 26px; line-height: 1; box-shadow: 0 4px 0 rgba(0,0,0,.18); cursor: pointer; display: grid; place-items: center; text-decoration: none; transition: transform .15s, background .15s; padding: 0; }
.round:active { transform: translateY(3px) scale(.94); box-shadow: 0 1px 0 rgba(0,0,0,.18); }
.round.small { width: 44px; height: 44px; font-size: 20px; flex: none; }
.scene-btn[aria-pressed="true"] { background: var(--yellow); transform: scale(1.12); }
.scene-btn.locked { filter: grayscale(1); opacity: .75; }
.scene-btn.locked::after, .tool.locked::after { content: '🔒'; position: absolute; right: -4px; bottom: -4px; font-size: 16px; filter: none; }
.album-btn .badge { position: absolute; top: -6px; right: -10px; background: #ff4d6d; color: #fff; font-size: 12px; font-weight: 700; padding: 2px 6px; border-radius: 999px; box-shadow: 0 2px 0 rgba(0,0,0,.2); }

.draw-btn { position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%); border: 0; cursor: pointer; font-size: 32px; font-weight: 700; color: #fff; padding: 14px 34px; border-radius: 999px; background: linear-gradient(135deg, #ff9f43, #ff6b9d 60%, #b16cff); box-shadow: 0 7px 0 #c2407a, 0 14px 30px rgba(0,0,0,.25); text-shadow: 0 2px 0 rgba(0,0,0,.2); animation: bob 2.2s ease-in-out infinite; }
.draw-btn:active { box-shadow: 0 2px 0 #c2407a; translate: 0 5px; }
@keyframes bob { 0%, 100% { transform: translateX(-50%) translateY(0) rotate(-1deg); } 50% { transform: translateX(-50%) translateY(-9px) rotate(1deg); } }
.hand { position: fixed; left: 50%; bottom: calc(max(20px, env(safe-area-inset-bottom)) + 84px); font-size: 48px; transform: translateX(-50%); animation: point 1s ease-in-out infinite; pointer-events: none; }
@keyframes point { 50% { transform: translateX(-50%) translateY(14px); } }
.gift { position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: max(24px, env(safe-area-inset-bottom)); width: 72px; height: 72px; border: 0; border-radius: 22px; background: rgba(255,255,255,.9); font-size: 46px; cursor: pointer; box-shadow: 0 5px 0 rgba(0,0,0,.18), 0 0 0 0 rgba(255,217,61,.7); animation: giftBounce 1.4s ease-in-out infinite, giftGlow 1.4s ease-out infinite; }
@keyframes giftBounce { 50% { transform: translateY(-10px) rotate(-6deg); } }
@keyframes giftGlow { to { box-shadow: 0 5px 0 rgba(0,0,0,.18), 0 0 0 22px rgba(255,217,61,0); } }
.gift.shake { animation: giftShake .35s, giftGlow 1.4s ease-out infinite; }
@keyframes giftShake { 25% { transform: rotate(-18deg) scale(1.15); } 75% { transform: rotate(18deg) scale(1.15); } }

/* drawing card */
.panel { position: fixed; inset: 0; display: grid; place-items: center; padding: 10px; background: rgba(20,16,60,.45); animation: fadeIn .2s; }
@keyframes fadeIn { from { opacity: 0; } }
.card { background: var(--card); border-radius: 28px; padding: 12px; width: min(560px, 100%); max-height: 100%; display: grid; gap: 10px; box-shadow: 0 10px 0 rgba(0,0,0,.15), 0 24px 60px rgba(0,0,0,.35); animation: pop .4s cubic-bezier(.34,1.56,.64,1); }
@keyframes pop { from { transform: scale(.6) rotate(-4deg); opacity: 0; } }
.card.magic-out { animation: magicOut .38s ease-in forwards; }
@keyframes magicOut { to { transform: scale(.15) rotate(-14deg); opacity: 0; filter: brightness(2.2); } }
.card.shake { animation: shake .45s; }
@keyframes shake { 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }
.card-top { display: flex; gap: 10px; align-items: center; }
.ref-box { flex: none; width: 92px; height: 92px; border-radius: 20px; border: 3px solid #ffd9e6; background: #fff7fa; padding: 4px; cursor: pointer; position: relative; }
.ref-box::after { content: '▶'; position: absolute; right: 4px; bottom: 2px; font-size: 13px; color: var(--pink); }
.ref-svg { width: 100%; height: 100%; display: block; }
.ref-svg path { fill: none; stroke: var(--pink); stroke-width: 18; stroke-linecap: round; stroke-linejoin: round; }
.ref-svg.ghost path { stroke: #cfc8f3; }
.idea-col { flex: 1; min-width: 0; display: grid; gap: 6px; }
.idea-text { font-size: 24px; font-weight: 700; line-height: 1.1; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 0; cursor: pointer; background: #f1eefe; border-radius: 999px; padding: 6px 12px; font-size: 16px; font-weight: 600; }
.chip:disabled { opacity: .4; cursor: default; }
.chip[aria-pressed="true"] { background: var(--yellow); }
#showBtn:not(:disabled) { background: #ffe0ea; }
.paper { position: relative; width: min(100%, calc(100vh - 400px)); width: min(100%, calc(100dvh - 400px)); min-width: 220px; aspect-ratio: 1; margin: 0 auto; border-radius: 20px; background: #fff radial-gradient(circle, #e9e5fb 1.4px, transparent 1.6px) 0 0 / 22px 22px; border: 4px dashed #d9d2fb; overflow: hidden; }
.paper canvas, .paper .trace { position: absolute; inset: 0; width: 100%; height: 100%; }
.paper canvas { touch-action: none; }
#inkfx, .trace { pointer-events: none; }
.trace path { fill: none; stroke: #b9b0f0; stroke-width: 12; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1 24; transition: opacity .3s; }
.trace.off path { opacity: 0; }
.trace.demo path { stroke: #ff6b9d; stroke-width: 14; opacity: .85; }
.tools { display: grid; gap: 8px; }
.colors { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.swatch { width: 40px; height: 40px; border-radius: 50%; border: 4px solid #fff; box-shadow: 0 0 0 2px #ddd; cursor: pointer; padding: 0; transition: transform .15s; }
.swatch[aria-pressed="true"] { transform: scale(1.2); box-shadow: 0 0 0 3px var(--ink); }
.row2 { display: flex; justify-content: center; gap: 8px; align-items: center; flex-wrap: wrap; }
.sizes, .brushes { display: flex; gap: 4px; background: #f1eefe; padding: 4px; border-radius: 999px; }
.tool { position: relative; width: 44px; height: 44px; border-radius: 50%; border: 0; background: #f1eefe; font-size: 22px; cursor: pointer; display: grid; place-items: center; padding: 0; transition: transform .15s; }
.tool:active { transform: scale(.9); }
.tool[aria-pressed="true"] { background: var(--yellow); }
.sizes .tool, .brushes .tool { background: #fff; width: 40px; height: 40px; }
.sizes .tool[aria-pressed="true"], .brushes .tool[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--ink); background: #fff7cc; }
.brushes .tool.locked { opacity: .55; }
.size i { display: block; border-radius: 50%; }
.life-btn { border: 0; cursor: pointer; font-size: 26px; font-weight: 700; color: #fff; border-radius: 999px; padding: 14px; background: linear-gradient(135deg, #ffd93d, #ff9f43 45%, #ff6b9d); text-shadow: 0 2px 0 rgba(0,0,0,.2); box-shadow: 0 6px 0 #d9487e; }
.life-btn:disabled { filter: grayscale(.9) opacity(.55); cursor: default; }
.life-btn:not(:disabled) { animation: glow 1.3s ease-in-out infinite; }
.life-btn:active:not(:disabled) { box-shadow: 0 2px 0 #d9487e; transform: translateY(4px); }
@keyframes glow { 50% { transform: scale(1.04); box-shadow: 0 6px 0 #d9487e, 0 0 28px rgba(255,217,61,.9); } }

@media (orientation: landscape) and (max-height: 640px) {
  .card { width: auto; grid-template-columns: auto minmax(220px, 290px); grid-template-areas: "paper top" "paper tools" "paper life"; align-items: start; }
  .card-top { grid-area: top; }
  .paper { grid-area: paper; width: calc(100vh - 50px); width: calc(100dvh - 50px); min-width: 180px; }
  .tools { grid-area: tools; }
  .life-btn { grid-area: life; font-size: 22px; align-self: end; }
  .ref-box { width: 72px; height: 72px; }
  .idea-text { font-size: 19px; }
  .chip { padding: 5px 9px; font-size: 14px; }
  .swatch { width: 30px; height: 30px; border-width: 3px; }
  .sizes .tool, .brushes .tool, .tool { width: 34px; height: 34px; font-size: 18px; }
}
@media (max-width: 600px) {
  .hud-top { flex-wrap: wrap; }
  .scenes { order: 3; margin: 0 auto; }
  .round { width: 44px; height: 44px; font-size: 22px; }
  .next-track { width: 40px; }
}
@media (max-width: 420px) {
  .colors { gap: 5px; }
  .swatch { width: 32px; height: 32px; border-width: 3px; }
  .idea-text { font-size: 19px; }
  .ref-box { width: 80px; height: 80px; }
  .chip { font-size: 14px; padding: 5px 9px; }
  .sizes .tool, .brushes .tool, .tool { width: 36px; height: 36px; font-size: 18px; }
}

/* album */
.overlay { position: fixed; inset: 0; display: grid; place-items: center; padding: 12px; background: rgba(20,16,60,.5); animation: fadeIn .2s; }
.sheet { background: var(--card); border-radius: 28px; padding: 16px; width: min(640px, 100%); max-height: 100%; overflow: auto; box-shadow: 0 24px 60px rgba(0,0,0,.35); animation: pop .4s cubic-bezier(.34,1.56,.64,1); }
.sheet-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.sheet-top h2 { margin: 0; font-size: 26px; }
.sheet-sub { margin: 4px 0 8px; color: var(--muted); }
.album-sec h3 { margin: 12px 0 8px; font-size: 20px; display: flex; justify-content: space-between; }
.album-sec h3 span { color: var(--muted); font-weight: 500; }
.album-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.album-card { position: relative; aspect-ratio: 1; border-radius: 18px; border: 3px dashed #d9d2fb; background: #fff; cursor: pointer; padding: 8px; display: grid; place-items: center; }
.album-card.done { border: 3px solid #4cd97b; background: #effff3; }
.album-card img { max-width: 100%; max-height: 100%; }
.album-card .ghost { opacity: .7; }
.album-card .q { position: absolute; right: 6px; bottom: 4px; font-size: 22px; }
.album-card .tick { position: absolute; right: -6px; top: -6px; width: 26px; height: 26px; border-radius: 50%; background: #4cd97b; color: #fff; display: grid; place-items: center; font-size: 15px; font-weight: 700; }

/* banner */
.banner { position: fixed; left: 50%; top: 84px; transform: translateX(-50%); display: flex; align-items: center; gap: 12px; background: #fff; border-radius: 24px; padding: 12px 20px 12px 14px; box-shadow: 0 8px 0 rgba(0,0,0,.12), 0 20px 50px rgba(0,0,0,.3); max-width: calc(100% - 32px); z-index: 5; }
.banner.show { animation: bannerIn .55s cubic-bezier(.34,1.56,.64,1); }
@keyframes bannerIn { from { transform: translateX(-50%) translateY(-30px) scale(.6); opacity: 0; } }
.banner-icon { font-size: 46px; animation: wiggle 1s ease-in-out infinite; }
@keyframes wiggle { 50% { transform: rotate(12deg) scale(1.1); } }
.banner-title { font-size: 22px; font-weight: 700; }
.banner-sub { color: var(--muted); font-size: 16px; }

/* night / break time */
.night { position: fixed; inset: 0; display: grid; place-items: end center; padding: 16px 16px max(28px, env(safe-area-inset-bottom)); pointer-events: none; }
.night-card { pointer-events: auto; background: rgba(255,255,255,.94); border-radius: 28px; padding: 18px 22px; text-align: center; max-width: 420px; box-shadow: 0 10px 40px rgba(0,0,0,.35); animation: pop .5s cubic-bezier(.34,1.56,.64,1); }
.night-card h2 { margin: 4px 0; font-size: 30px; }
.night-card p { margin: 0 0 14px; font-size: 19px; color: var(--muted); }
.moon { font-size: 54px; animation: wiggle 3s ease-in-out infinite; }
.hold { position: relative; overflow: hidden; border: 2px solid #c9c2f2; background: #fff; border-radius: 999px; padding: 10px 16px; font-size: 15px; color: var(--muted); cursor: pointer; touch-action: none; }
.hold-fill { position: absolute; inset: 0; background: #c9f7d6; transform-origin: left; transform: scaleX(0); }
.hold-label { position: relative; }

.fade { position: fixed; inset: 0; background: #fff; opacity: 0; pointer-events: none; transition: opacity .22s; }
.fade.on { opacity: 1; }
.noscript { position: fixed; inset: auto 0 40% 0; text-align: center; font-size: 22px; background: #fff; padding: 16px; }

/* ---------- info pages ---------- */
.page-header { background: #fff; border-bottom: 1px solid var(--line); }
.wrap { max-width: 860px; margin: 0 auto; padding: 0 16px; }
.page-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 12px; padding-bottom: 12px; flex-wrap: wrap; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 22px; color: var(--ink); text-decoration: none; }
.nav { display: flex; gap: 14px; flex-wrap: wrap; }
.nav a { color: var(--pri); text-decoration: none; font-weight: 500; }
.nav a[aria-current="page"] { color: var(--ink); text-decoration: underline; }
.prose { padding: 28px 16px 40px; line-height: 1.6; font-size: 18px; }
.prose h1 { font-size: 34px; line-height: 1.2; margin: 0 0 12px; }
.prose h2 { font-size: 24px; margin: 30px 0 8px; }
.prose a { color: var(--pri); }
.muted { color: var(--muted); }
.btn { display: inline-block; border: 0; cursor: pointer; text-decoration: none; font-weight: 700; font-size: 22px; color: #fff; padding: 12px 26px; border-radius: 999px; background: linear-gradient(135deg, #ff9f43, #ff6b9d 60%, #b16cff); box-shadow: 0 5px 0 #c2407a; }
.setting { background: #fff; border: 2px solid var(--line); border-radius: 20px; padding: 16px 18px; margin: 14px 0; }
.setting .choices { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.setting .choices button { border: 2px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 16px; cursor: pointer; font-size: 17px; }
.setting .choices button[aria-pressed="true"] { background: var(--yellow); border-color: var(--yellow); font-weight: 600; }
.setting .danger { border: 2px solid #ffc2c2; background: #fff5f5; color: #b3261e; border-radius: 999px; padding: 6px 16px; cursor: pointer; font-size: 17px; margin-top: 8px; }
.site-footer { border-top: 1px solid var(--line); background: #fff; padding: 20px 0; font-size: 15px; color: var(--muted); }
.site-footer .links { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 8px; }
.site-footer a { color: var(--pri); }

/* ---------- Doodleverse story ---------- */
.mission { position: fixed; left: 50%; top: calc(max(10px, env(safe-area-inset-top)) + 66px); transform: translateX(-50%); display: flex; align-items: center; gap: 8px; background: rgba(255,255,255,.95); border-radius: 999px; padding: 6px 14px 6px 8px; box-shadow: 0 4px 0 rgba(0,0,0,.12); max-width: calc(100% - 24px); }
.mission-icon { font-size: 26px; }
.mission-text { font-weight: 700; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mission-dots { display: flex; align-items: center; gap: 4px; margin-left: 4px; }
.mission-dots i { width: 10px; height: 10px; border-radius: 50%; background: #e3def7; }
.mission-dots i.done { background: #4cd97b; }
.mission-dots i.now { background: #ff6b9d; box-shadow: 0 0 0 3px #ffd1e0; }
.mission-dots b { font-size: 14px; filter: grayscale(1) opacity(.5); }
.mission-dots b.now { filter: none; animation: wiggle 1s infinite; }
.talk { position: fixed; max-width: min(560px, calc(100% - 140px)); background: #fff; border-radius: 22px 22px 22px 6px; padding: 10px 18px 12px; box-shadow: 0 6px 0 rgba(0,0,0,.12), 0 16px 40px rgba(0,0,0,.25); cursor: pointer; z-index: 3; }
.talk.pop { animation: talkIn .35s cubic-bezier(.34,1.56,.64,1); }
@keyframes talkIn { from { transform: scale(.7) translateY(10px); opacity: 0; } }
.talk-name { font-weight: 700; font-size: 15px; }
.talk-text { font-size: 21px; line-height: 1.3; min-height: 1.3em; }
.talk-next { position: absolute; right: 12px; bottom: 6px; font-size: 12px; color: #c3bce6; }
.chooser-sheet, .chapter-sheet { text-align: center; max-width: 520px; }
.chooser-sheet h2, .chapter-sheet h2 { margin: 4px 0 10px; font-size: 28px; }
.chooser-img { max-width: 140px; max-height: 120px; display: block; margin: 0 auto 10px; }
.chooser-btns { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.choose { display: grid; justify-items: center; gap: 4px; border: 3px solid #e7e3fb; background: #fff; border-radius: 20px; padding: 10px; cursor: pointer; font-size: 18px; font-weight: 600; }
.choose:first-child { border-color: #ff6b9d; background: #fff4f8; }
.choose svg { width: 70px; height: 70px; }
.choose-ico { font-size: 52px; line-height: 70px; }
.chapter-gem { font-size: 80px; animation: wiggle 1.2s infinite; }
.rewards { list-style: none; padding: 0; margin: 0 0 16px; font-size: 20px; line-height: 1.8; }
.chapter-btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.btn-big { border: 0; cursor: pointer; font-size: 20px; font-weight: 700; color: #fff; padding: 12px 22px; border-radius: 999px; background: linear-gradient(135deg, #4d96ff, #b16cff); box-shadow: 0 5px 0 #5b3fc4; }
.btn-big.alt { background: linear-gradient(135deg, #4cd97b, #2e9e55); box-shadow: 0 5px 0 #1f7a3f; }
.title { position: fixed; inset: 0; display: grid; place-items: center; background: radial-gradient(circle at 50% 40%, rgba(255,255,255,.3), rgba(30,60,120,.6)); z-index: 10; padding: 16px; transition: opacity .45s; }
.title.out { opacity: 0; }
.title-inner { text-align: center; }
.title-doodle { width: 170px; height: 170px; display: block; margin: 0 auto -10px; }
.logo-text { margin: 0; font-size: clamp(46px, 11vw, 96px); font-weight: 700; letter-spacing: 1px; line-height: 1; }
.logo-text span { display: inline-block; color: #fff; -webkit-text-stroke: 3px #3a2a7a; paint-order: stroke fill; text-shadow: 0 6px 0 #3a2a7a; animation: letter 2.4s ease-in-out infinite; }
.logo-text span:nth-child(5n+1) { color: #ff6b9d; } .logo-text span:nth-child(5n+2) { color: #ffd93d; } .logo-text span:nth-child(5n+3) { color: #4cd97b; } .logo-text span:nth-child(5n+4) { color: #4d96ff; } .logo-text span:nth-child(5n) { color: #ff9f43; }
.logo-text span:nth-child(2) { animation-delay: .1s; } .logo-text span:nth-child(3) { animation-delay: .2s; } .logo-text span:nth-child(4) { animation-delay: .3s; } .logo-text span:nth-child(5) { animation-delay: .4s; } .logo-text span:nth-child(6) { animation-delay: .5s; } .logo-text span:nth-child(7) { animation-delay: .6s; } .logo-text span:nth-child(8) { animation-delay: .7s; } .logo-text span:nth-child(9) { animation-delay: .8s; } .logo-text span:nth-child(10) { animation-delay: .9s; } .logo-text span:nth-child(11) { animation-delay: 1s; }
@keyframes letter { 0%, 70%, 100% { transform: translateY(0) rotate(0); } 80% { transform: translateY(-14px) rotate(-6deg); } 90% { transform: translateY(0) rotate(4deg); } }
.tagline { color: #fff; font-size: 22px; font-weight: 600; text-shadow: 0 2px 6px rgba(0,0,0,.4); margin: 12px 0 20px; }
.play-btn { border: 0; cursor: pointer; font-size: 36px; font-weight: 700; color: #fff; padding: 14px 54px; border-radius: 999px; background: linear-gradient(135deg, #4cd97b, #2e9e55); box-shadow: 0 8px 0 #1f7a3f, 0 16px 30px rgba(0,0,0,.3); text-shadow: 0 2px 0 rgba(0,0,0,.2); }
.play-btn:active { transform: translateY(5px); box-shadow: 0 3px 0 #1f7a3f; }
.title-link { display: block; margin-top: 18px; color: #fff; opacity: .85; font-size: 15px; }
.flash { position: fixed; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.flash.on { animation: flash 1.2s ease-out; }
@keyframes flash { 0% { opacity: 0; } 10% { opacity: .95; } 100% { opacity: 0; } }
.banner { top: 136px; }
@media (max-width: 600px) { .mission { top: calc(max(10px, env(safe-area-inset-top)) + 116px); } .mission-text { font-size: 15px; } .talk-text { font-size: 18px; } .banner { top: 186px; } }

.lang-pick { display: inline-flex; gap: 6px; background: rgba(255,255,255,.3); padding: 6px; border-radius: 999px; margin-bottom: 18px; }
.lang-pick button { border: 0; cursor: pointer; border-radius: 999px; padding: 8px 18px; font-size: 20px; font-weight: 700; background: rgba(255,255,255,.85); color: #3a2a7a; }
.lang-pick button[aria-pressed="true"] { background: #ffd93d; box-shadow: 0 3px 0 #c9a100; }
.lang-btn { font-size: 18px; font-weight: 700; color: #3a2a7a; }
:lang(hi) .talk-text { font-size: 22px; line-height: 1.45; }
:lang(hi) .idea-text { font-size: 22px; }

/* ---------- mission-to-mission transition ---------- */
.transit { position: fixed; inset: 0; z-index: 8; display: grid; place-items: center; pointer-events: auto; overflow: hidden; }
.transit .tr-glow { position: absolute; inset: 0; background: radial-gradient(circle at 50% 45%, rgba(255,255,255,.55), rgba(120,90,255,.45) 45%, rgba(40,20,110,.75)); opacity: 0; }
.transit .tr-rays { position: absolute; left: 50%; top: 45%; width: 220vmax; height: 220vmax; margin: -110vmax 0 0 -110vmax; background: repeating-conic-gradient(rgba(255,255,255,.16) 0 9deg, rgba(255,255,255,0) 9deg 18deg); opacity: 0; border-radius: 50%; }
.transit .tr-rainbow { position: absolute; left: 50%; bottom: 0; width: min(1100px, 150vw); transform: translateX(-50%); opacity: 0; }
.transit .tr-rainbow path { fill: none; stroke-width: 44; stroke-linecap: round; stroke-dasharray: 1400; stroke-dashoffset: 1400; opacity: .85; }
.transit .tr-badge, .transit .tr-next { position: absolute; display: grid; justify-items: center; gap: 10px; text-align: center; padding: 0 16px; opacity: 0; }
.tr-medal { width: 130px; height: 130px; border-radius: 50%; display: grid; place-items: center; font-size: 74px; background: radial-gradient(circle at 35% 30%, #fff8c4, #ffd93d 45%, #ff9f1c); box-shadow: 0 0 0 8px rgba(255,255,255,.7), 0 0 60px rgba(255,217,61,.9); }
.tr-medal span { display: inline-block; animation: spinStar 2.2s ease-in-out infinite; }
.tr-great { font-size: clamp(34px, 7vw, 58px); font-weight: 700; color: #fff; -webkit-text-stroke: 2px #3a2a7a; paint-order: stroke fill; text-shadow: 0 5px 0 #3a2a7a; }
.tr-dots { display: flex; gap: 10px; align-items: center; }
.tr-dots i { width: 22px; height: 22px; border-radius: 50%; background: rgba(255,255,255,.45); box-shadow: inset 0 -3px 0 rgba(0,0,0,.12); }
.tr-dots i.on { background: #4cd97b; }
.tr-dots b { font-size: 26px; filter: grayscale(1) opacity(.6); }
.tr-dots b.on { filter: none; }
.tr-bubble { width: 170px; height: 170px; border-radius: 50%; display: grid; place-items: center; font-size: 92px; background: radial-gradient(circle at 32% 28%, rgba(255,255,255,.95), rgba(255,255,255,.35) 22%, rgba(180,220,255,.25) 60%, rgba(255,160,230,.35)); box-shadow: inset 0 0 30px rgba(255,255,255,.9), 0 0 50px rgba(160,200,255,.9), 0 0 0 4px rgba(255,255,255,.6); }
.tr-bubble span { display: inline-block; animation: wiggle 1.2s ease-in-out infinite; }
.tr-label { font-size: 22px; font-weight: 700; color: #3a2a7a; background: #ffd93d; padding: 4px 18px; border-radius: 999px; box-shadow: 0 4px 0 #c9a100; }
.tr-text { font-size: clamp(24px, 4.6vw, 38px); font-weight: 700; color: #fff; text-shadow: 0 3px 0 #3a2a7a, 0 0 18px rgba(58,42,122,.6); max-width: 760px; }
.transit.play .tr-glow { animation: trFade 4.4s ease both; }
.transit.play .tr-rays { animation: trFade 4.4s ease both, trSpin 14s linear infinite; }
.transit.play .tr-rainbow { animation: trFade 4.4s ease both; }
.transit.play .tr-rainbow path { animation: trDraw 1.1s cubic-bezier(.3,.7,.2,1) forwards; }
.transit.play .tr-rainbow path:nth-child(2) { animation-delay: .08s; } .transit.play .tr-rainbow path:nth-child(3) { animation-delay: .16s; } .transit.play .tr-rainbow path:nth-child(4) { animation-delay: .24s; } .transit.play .tr-rainbow path:nth-child(5) { animation-delay: .32s; } .transit.play .tr-rainbow path:nth-child(6) { animation-delay: .4s; }
.transit.play .tr-badge { animation: trBadge 2s cubic-bezier(.34,1.56,.64,1) .15s both; }
.transit.play .tr-dots i, .transit.play .tr-dots b { animation: trDot .5s cubic-bezier(.34,1.56,.64,1) both; }
.transit.play .tr-next { animation: trNext 2.4s ease 2s both; }
@keyframes trFade { 0% { opacity: 0; } 9% { opacity: 1; } 88% { opacity: 1; } 100% { opacity: 0; } }
@keyframes trSpin { to { transform: rotate(360deg); } }
@keyframes trDraw { to { stroke-dashoffset: 0; } }
@keyframes trBadge { 0% { opacity: 0; transform: scale(.3) rotate(-12deg); } 22% { opacity: 1; transform: scale(1.08) rotate(3deg); } 32% { transform: scale(1) rotate(0); } 80% { opacity: 1; transform: translateY(0) scale(1); } 100% { opacity: 0; transform: translateY(-60px) scale(.85); } }
@keyframes trDot { from { transform: scale(0); } }
@keyframes trNext { 0% { opacity: 0; transform: translateY(-70vh) scale(.6); } 22% { opacity: 1; transform: translateY(14px) scale(1.04); } 30% { transform: translateY(0) scale(1); } 68% { opacity: 1; transform: translateY(0) scale(1); } 100% { opacity: 0; transform: translateY(-40vh) scale(.22); } }
.mission.pulse { animation: missionPulse .9s cubic-bezier(.34,1.56,.64,1); }
@keyframes missionPulse { 0% { transform: translateX(-50%) scale(.4); opacity: 0; } 60% { transform: translateX(-50%) scale(1.12); opacity: 1; } 100% { transform: translateX(-50%) scale(1); } }
@media (prefers-reduced-motion: reduce) {
  .transit.play .tr-rays { animation: trFade 4.4s ease both; }
  .transit.play .tr-next, .transit.play .tr-badge { animation-name: trFade; }
}
/* ---------- name screen ---------- */
.name-sheet { text-align: center; max-width: 440px; }
.name-sheet h2 { margin: 4px 0; font-size: 30px; }
.name-wave { font-size: 60px; animation: wiggle 1s ease-in-out infinite; transform-origin: 70% 80%; }
.name-input { width: 100%; font: inherit; font-size: 28px; font-weight: 600; text-align: center; padding: 12px 16px; border: 3px solid #d9d2fb; border-radius: 18px; margin: 12px 0 16px; color: var(--ink); background: #fff; }
.name-input:focus { outline: none; border-color: #6c4ff6; box-shadow: 0 0 0 4px rgba(108,79,246,.2); }
.name-btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.btn-big.ghost { background: #efeafe; color: #3a2a7a; box-shadow: 0 5px 0 #cfc6f3; }
.name-chip { display: block; margin: 14px auto 0; border: 0; cursor: pointer; background: rgba(255,255,255,.85); color: #3a2a7a; font-size: 17px; padding: 6px 16px; border-radius: 999px; }
/* Phones: keep the top bar to two rows so the mission card never covers the world buttons. */
@media (max-width: 600px) {
  .star-pill { padding: 4px 10px 4px 6px; font-size: 18px; gap: 4px; }
  .star-pill b { font-size: 20px; min-width: 1.2em; }
  .star-ico { font-size: 22px; }
  .star-pill .next-track { display: none; }
  .hud-right { gap: 6px; }
  .hud-right .round { width: 42px; height: 42px; font-size: 20px; }
  .lang-btn { font-size: 16px; }
  .mission { top: calc(max(10px, env(safe-area-inset-top)) + 124px); }
}
@media (max-width: 360px) { .hud-right .round { width: 38px; height: 38px; font-size: 18px; } }
/* Small and landscape phones: the drawing card always fits (and can scroll as a last resort). */
.card { overflow-y: auto; overscroll-behavior: contain; }
@media (max-width: 380px) {
  .swatch { width: 29px; height: 29px; border-width: 3px; }
  .colors { gap: 4px; }
  .sizes .tool, .brushes .tool, .tool { width: 33px; height: 33px; font-size: 17px; }
  .ref-box { width: 70px; height: 70px; }
  .paper { width: min(100%, calc(100vh - 380px)); width: min(100%, calc(100dvh - 380px)); }
  .life-btn { font-size: 22px; padding: 11px; }
}
@media (orientation: landscape) and (max-height: 640px) {
  .card { padding: 10px; gap: 6px; }
  .paper { width: calc(100vh - 40px); width: calc(100dvh - 40px); }
  .swatch { width: 28px; height: 28px; }
  .colors { gap: 4px; }
  .sizes .tool, .brushes .tool, .tool { width: 31px; height: 31px; font-size: 16px; }
  .chips .chip { padding: 4px 8px; }
  .life-btn { font-size: 20px; padding: 9px; }
}

.mission { pointer-events: none; }
@media (orientation: landscape) and (max-height: 500px) {
  .talk { max-width: min(46vw, 420px); padding: 8px 14px 10px; }
  .talk-text { font-size: 17px; }
}

/* ---------- Paint tools ---------- */
.modes { display: flex; gap: 4px; background: #f1eefe; padding: 4px; border-radius: 999px; }
.modes .tool { background: #fff; width: 40px; height: 40px; color: #3a2a7a; }
.modes .tool[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--ink); background: #fff7cc; }
.modes .tool svg { display: block; }
.swatch.picker { background: conic-gradient(#ff4757, #feca57, #2ed573, #1e90ff, #5f27cd, #ff6b9d, #ff4757); }
.swatch[data-color="#ffffff"] { box-shadow: 0 0 0 2px #cfc8e8; }
.color-pick { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.tools { position: relative; }
.paper { width: min(100%, calc(100vh - 450px)); width: min(100%, calc(100dvh - 450px)); }
@media (max-width: 600px) {
  .colors, .tools .row2 { flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start; padding: 3px 2px 6px; scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
  .colors > *, .tools .row2 > * { flex: none; }
  .paper { width: min(100%, calc(100vh - 420px)); width: min(100%, calc(100dvh - 420px)); }
}
@media (max-width: 380px) { .modes .tool { width: 33px; height: 33px; } .modes .tool svg { width: 20px; height: 20px; } }
@media (orientation: landscape) and (max-height: 640px) {
  .card { grid-template-columns: auto minmax(240px, 330px); }
  .paper { width: min(calc(100vh - 40px), calc(100vw - 380px)); width: min(calc(100dvh - 40px), calc(100vw - 380px)); }
  .modes .tool { width: 31px; height: 31px; } .modes .tool svg { width: 19px; height: 19px; }
  .colors { flex-wrap: wrap; }
}

/* Transition, step by step: the badge stays until Doodle finishes talking, then the next picture comes. */
.transit.play .tr-glow, .transit.play .tr-rainbow { animation: trIn .45s ease both; }
.transit.play .tr-rays { animation: trIn .45s ease both, trSpin 14s linear infinite; }
.transit.play .tr-badge { animation: trBadgeIn .7s cubic-bezier(.34,1.56,.64,1) .15s both; }
.transit.play .tr-next { animation: none; opacity: 0; }
.transit.play.next .tr-badge { animation: trBadgeOut .45s ease forwards; }
.transit.play.next .tr-next { animation: trNext2 2.3s ease both; }
.transit.play.out { animation: trOut .45s ease forwards; }
@keyframes trIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes trOut { to { opacity: 0; } }
@keyframes trBadgeIn { 0% { opacity: 0; transform: scale(.3) rotate(-12deg); } 70% { opacity: 1; transform: scale(1.08) rotate(3deg); } 100% { opacity: 1; transform: scale(1) rotate(0); } }
@keyframes trBadgeOut { from { opacity: 1; } to { opacity: 0; transform: translateY(-60px) scale(.85); } }
@keyframes trNext2 { 0% { opacity: 0; transform: translateY(-70vh) scale(.6); } 30% { opacity: 1; transform: translateY(14px) scale(1.04); } 40% { transform: translateY(0) scale(1); } 78% { opacity: 1; transform: translateY(0) scale(1); } 100% { opacity: 0; transform: translateY(-40vh) scale(.22); } }
/* Landscape phones: colours and tools become one swipeable row each, so "Bring to life!" always shows. */
@media (orientation: landscape) and (max-height: 500px) {
  .colors, .tools .row2 { flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start; padding: 3px 2px 5px; scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
  .colors > *, .tools .row2 > * { flex: none; }
  .tools { gap: 4px; }
  .card-top .ref-box { width: 60px; height: 60px; }
  .idea-text { font-size: 17px; }
}

/* During break time the story waits quietly behind the night sky. */
body.is-night .talk, body.is-night .transit, body.is-night .mission { display: none !important; }

/* Laptops and tablets on their side: a big paper on the left, the tools in a column on the right, like Paint. */
@media (orientation: landscape) and (min-width: 760px) and (min-height: 641px) {
  .card { width: auto; max-width: 100%; grid-template-columns: auto minmax(260px, 330px); grid-template-rows: auto 1fr auto; grid-template-areas: "paper top" "paper tools" "paper life"; align-items: start; }
  .card-top { grid-area: top; }
  .paper { grid-area: paper; width: min(calc(100vh - 52px), calc(100vw - 400px), 820px); width: min(calc(100dvh - 52px), calc(100vw - 400px), 820px); }
  .tools { grid-area: tools; }
  .life-btn { grid-area: life; align-self: end; }
}

/* Short screens (phones on their side): shrink the title so Play is always fully on screen. */
.title { overflow-y: auto; }
@media (max-height: 560px) {
  .title-doodle { width: 92px; height: 92px; margin-bottom: -6px; }
  .logo-text { font-size: clamp(40px, 9vh, 64px); }
  .tagline { font-size: 17px; margin: 6px 0 10px; }
  .play-btn { font-size: 28px; padding: 10px 44px; }
  .name-chip { margin-top: 8px; font-size: 15px; }
  .title-link { margin-top: 8px; }
}
@media (max-height: 380px) {
  .title-doodle { width: 64px; height: 64px; }
  .tagline { display: none; }
  .lang-pick { margin-bottom: 8px; }
}

/* Name window: sits above the title screen, the hand waves once when it opens and then rests. */
#nameBox { z-index: 12; }
.name-wave { animation: none; display: inline-block; }
#nameBox.wave .name-wave { animation: handWave 1.4s ease-in-out .25s 1 both; }
@keyframes handWave { 0%, 100% { transform: rotate(0); } 15%, 45%, 75% { transform: rotate(16deg); } 30%, 60% { transform: rotate(-8deg); } }
