/* Colorín – one bright, single-theme look (a kids' app, deliberately not dark-mode aware).
   Layout: full-screen app; each screen fills the viewport, the paint screen is canvas + palette rail. */
:root {
  --ink: #2B2350;          /* outline ink, used for all line art and text */
  --sky: #E6F4FF;          /* app background */
  --paper: #FFFFFF;        /* canvas */
  --sun: #FFC93C;          /* stars, highlights */
  --coral: #FF6F59;        /* primary action */
  --mint: #4CC9A0;         /* success */
  --muted: #6E6790;        /* secondary text */
  --font: 'Nunito', 'Trebuchet MS', 'Segoe UI', system-ui, sans-serif;
  color-scheme: light;
}
html, body { height: 100%; overscroll-behavior: none; }
body {
  margin: 0; background: var(--sky); color: var(--ink); font-family: var(--font); font-weight: 800;
  -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  touch-action: manipulation;
  background-image: radial-gradient(rgba(43,35,80,.06) 2px, transparent 2.5px);
  background-size: 26px 26px;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
button:focus-visible { outline: 4px solid var(--ink); outline-offset: 3px; }

#app { position: fixed; inset: 0; }
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; overflow: hidden;
  padding: env(safe-area-inset-top, 0px) max(16px, env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px) max(16px, env(safe-area-inset-left, 0px)); }
.scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; touch-action: pan-y; }

/* ---------- line art ---------- */
svg.pic { display: block; width: 100%; height: 100%; }
svg.pic .r { fill: #fff; stroke: var(--ink); stroke-linejoin: round; stroke-linecap: round; cursor: pointer; }
svg.pic .l { fill: none; stroke: var(--ink); stroke-linejoin: round; stroke-linecap: round; pointer-events: none; }
svg.pic .k { fill: var(--ink); stroke: none; pointer-events: none; }
svg.pic .w { fill: #fff; stroke: none; pointer-events: none; }
svg.pic .t { fill: var(--ink); stroke: none; font-family: var(--font); font-weight: 900; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
svg.pic .r.pop { animation: pop .28s ease-out; }
/* hand-drawn pictures: fills under a line image; no outline on regions, the hero doesn't jump away from its lines */
svg.pic.raster .r { stroke: none; shape-rendering: crispEdges; }
svg.pic.raster .r.pop { animation: none; }
svg.pic.raster .lines { pointer-events: none; }
svg.pic.raster .hero, svg.pic.raster .hero.alive, svg.pic.raster.alive .hero, .alive svg.pic.raster .hero { animation: none !important; transform: none !important; }
svg.pic.raster .hlines { display: none; pointer-events: none; }
svg.pic.raster.only-hero .hlines { display: inline; }
@keyframes pop { 40% { opacity: .6; } }
svg.pic .it, svg.pic .hero, svg.pic .wag, svg.pic .eye { transform-box: fill-box; }
svg.pic .it { transform-origin: 50% 50%; }
svg.pic .it.no { animation: no .5s ease; }
@keyframes no { 20%,60% { transform: rotate(-9deg); } 40%,80% { transform: rotate(9deg); } }
svg.pic .hero { transform-origin: 50% 100%; }
.alive .hero, svg.pic .hero.alive { animation: bounce 1.6s ease-in-out infinite; }
.alive .wag, svg.pic .hero.alive .wag { animation: wagit .5s ease-in-out infinite alternate; }
.alive .eye, svg.pic .hero.alive .eye { transform-origin: 50% 50%; animation: blink 3.2s infinite; }
@keyframes bounce { 0%,100% { transform: translateY(0) scale(1,1); } 15% { transform: translateY(0) scale(1.06,.94); } 40% { transform: translateY(-7%) scale(.97,1.04); } 65% { transform: translateY(0) scale(1.03,.97); } }
@keyframes wagit { from { transform: rotate(-12deg); } to { transform: rotate(14deg); } }
@keyframes blink { 0%,92%,100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }
.only-hero > :not(.hw) { display: none; }
svg.pic.ghost .r { fill: #F1EEFA !important; stroke: #CFC8E6; }
svg.pic.ghost .k, svg.pic.ghost .t { fill: #CFC8E6; }
svg.pic.ghost .l { stroke: #CFC8E6; }

/* ---------- shared bits ---------- */
.round { position: relative; width: 72px; height: 72px; border-radius: 50%; background: var(--paper); display: grid; place-items: center;
  box-shadow: 0 4px 0 rgba(43,35,80,.18); flex: none; transition: transform .1s; }
#back::after { content: ''; position: absolute; inset: -10px; } /* bigger target than the circle */
.logo.wig { animation: no .5s ease; }
.round:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(43,35,80,.18); }
.round svg { width: 34px; height: 34px; fill: none; stroke: var(--ink); stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; }
.topbar { display: flex; align-items: center; gap: 12px; padding-block: 12px; }
.title { font-size: clamp(26px, 4.5vw, 40px); font-weight: 900; margin: 0; flex: 1; text-wrap: balance; }
.stars { display: inline-flex; align-items: center; gap: 6px; background: var(--paper); border-radius: 999px; padding: 8px 16px; font-size: 22px;
  box-shadow: 0 4px 0 rgba(43,35,80,.12); font-variant-numeric: tabular-nums; }
.stars svg { width: 26px; height: 26px; }

/* ---------- language picker ---------- */
#lang { align-items: center; justify-content: center; gap: 24px; text-align: center; }
.langs { display: flex; flex-wrap: wrap; gap: 16px; justify-content: center; }
.langbtn { background: var(--paper); border-radius: 28px; padding: 22px 34px; font-size: 30px; font-weight: 900; min-width: 200px;
  box-shadow: 0 6px 0 rgba(43,35,80,.18); }
.langbtn small { display: block; font-size: 15px; color: var(--muted); font-weight: 800; margin-top: 4px; }
.langbtn:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(43,35,80,.18); }

/* ---------- logo ---------- */
.logo { font-size: clamp(44px, 9vw, 84px); font-weight: 900; letter-spacing: .01em; line-height: 1; margin: 0;
  paint-order: stroke fill; -webkit-text-stroke: 0; text-shadow: 0 5px 0 rgba(43,35,80,.15); }
.logo span { display: inline-block; }
.logo span:nth-child(odd) { transform: rotate(-4deg); } .logo span:nth-child(even) { transform: rotate(4deg) translateY(-3px); }

/* ---------- home ---------- */
#home .head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-block: 14px 6px; flex-wrap: wrap; }
.themes { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; padding-block: 10px; }
.theme { position: relative; border-radius: 30px; display: flex; flex-direction: column; overflow: hidden; min-height: 0;
  box-shadow: 0 6px 0 rgba(43,35,80,.18); transition: transform .12s; }
.theme:active { transform: translateY(4px) rotate(-1deg); }
.theme .art { flex: 1; min-height: 0; padding: 22px 12px 0; }
.theme .art svg { width: 100%; height: 100%; overflow: visible; }
.theme .label { background: rgba(255,255,255,.92); margin: 10px; border-radius: 18px; padding: 10px 8px; font-size: clamp(16px, 2vw, 26px); font-weight: 900; text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.theme .label em { position: absolute; top: 10px; right: 10px; font-style: normal; font-size: 16px; background: rgba(255,255,255,.92); color: var(--ink);
  border-radius: 999px; padding: 4px 10px; font-variant-numeric: tabular-nums; }
.homefoot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-block: 8px 14px; }
.friendsbtn { display: inline-flex; align-items: center; gap: 12px; background: var(--sun); border-radius: 999px; padding: 12px 26px 12px 14px;
  font-size: clamp(20px, 2.6vw, 26px); font-weight: 900; box-shadow: 0 5px 0 rgba(43,35,80,.2); }
.friendsbtn:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(43,35,80,.2); }
.friendsbtn .bub { width: 44px; height: 44px; border-radius: 50%; background: var(--paper); display: grid; place-items: center; }
.friendsbtn .bub svg { width: 28px; height: 28px; }
.gear { position: relative; width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.7); }
.gear svg.ic { width: 28px; height: 28px; fill: none; stroke: var(--muted); stroke-width: 2.4; }
.gear svg.ring { position: absolute; inset: 0; width: 52px; height: 52px; transform: rotate(-90deg); }
.gear svg.ring circle { fill: none; stroke: var(--coral); stroke-width: 4; stroke-dasharray: 151; stroke-dashoffset: 151; }
.gear.holding svg.ring circle { transition: stroke-dashoffset 2s linear; stroke-dashoffset: 0; }
.gearhint { position: absolute; right: 0; bottom: 60px; background: var(--ink); color: #fff; font-size: 14px; padding: 8px 12px; border-radius: 12px; white-space: nowrap; }

/* ---------- theme page ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; padding-block: 6px 24px; }
.card { background: var(--paper); border-radius: 24px; padding: 10px; box-shadow: 0 5px 0 rgba(43,35,80,.14); position: relative; text-align: left; }
.card:active { transform: translateY(3px); }
.card .thumb { aspect-ratio: 4/3; border-radius: 16px; overflow: hidden; border: 3px solid #EFEBFA; max-width: 100%; }
.card .thumb svg .r { cursor: inherit; }
.card .cap { display: flex; align-items: center; justify-content: space-between; padding: 10px 6px 4px; font-size: 22px; font-weight: 900; gap: 8px; }
.card .cap .kind { display: inline-flex; gap: 4px; }
.badge { width: 34px; height: 34px; }
.badge.off { opacity: .55; }

/* ---------- paint screen ---------- */
#paint { display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto 1fr; gap: 12px; padding-block: 12px; }
#paint .topbar { grid-column: 1 / -1; padding: 0; }
.task { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; background: var(--paper); border-radius: 22px; padding: 8px 10px 8px 18px;
  box-shadow: 0 4px 0 rgba(43,35,80,.14); }
.task p { margin: 0; flex: 1; min-width: 0; font-size: clamp(17px, 2.4vw, 25px); line-height: 1.2; text-wrap: balance; }
.task .say { width: 64px; height: 64px; background: var(--sun); box-shadow: none; }
.task.done { background: #E5F8EF; }
.task .tick { width: 34px; height: 34px; flex: none; }
.canvas { position: relative; min-width: 0; min-height: 0; background: var(--paper); border-radius: 26px; box-shadow: 0 6px 0 rgba(43,35,80,.14); padding: 8px; display: flex; }
.canvas svg.pic { touch-action: none; }
.palette { display: grid; grid-template-columns: repeat(2, auto); gap: 12px; align-content: center; padding: 10px; background: var(--paper); border-radius: 26px;
  box-shadow: 0 6px 0 rgba(43,35,80,.14); }
.sw { width: 68px; height: 68px; border-radius: 50%; position: relative; box-shadow: inset 0 -5px 0 rgba(0,0,0,.14), inset 0 0 0 3px rgba(0,0,0,.12); transition: transform .12s; }
.sw.on { transform: scale(1.08); box-shadow: inset 0 -5px 0 rgba(0,0,0,.14), inset 0 0 0 3px rgba(0,0,0,.12), 0 0 0 4px var(--paper), 0 0 0 8px var(--ink); }
.sw.eraser { background: #fff; box-shadow: inset 0 0 0 3px #D9D3EE; display: grid; place-items: center; }
.sw.eraser.on { box-shadow: inset 0 0 0 3px #D9D3EE, 0 0 0 4px var(--paper), 0 0 0 8px var(--ink); }
.sw.eraser svg { width: 30px; height: 30px; }
#paint .round.undo { background: #BFE3FF; flex: none; }
.quizmode .round.undo { display: none; }
.round.undo svg { width: 30px; height: 30px; fill: none; stroke: var(--ink); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }

.sw.undo { margin-top: 0; }
.canvas .hand { position: absolute; width: 96px; height: 96px; margin: -10px 0 0 -30px; pointer-events: none; z-index: 3; animation: handtap 1.2s ease-in-out 3; }
.canvas .hand svg { width: 100%; height: 100%; }
@keyframes handtap { 0%,100% { transform: translate(18px, 26px) scale(1); opacity: .9; } 45% { transform: translate(0, 0) scale(.9); opacity: 1; } 55% { transform: translate(0, 0) scale(.86); } }
.splash { position: fixed; width: 24px; height: 24px; margin: -12px 0 0 -12px; border-radius: 50%; pointer-events: none; z-index: 19;
  border: 3px solid var(--ink); animation: splash .4s ease-out forwards; }
@keyframes splash { to { transform: scale(3); opacity: 0; } }

@media (orientation: portrait) {
  /* picture takes what is left, the colours always whole at the bottom: on a phone the palette covered the bottom of the picture
     and taps on the hidden items (Elly's cup, the sock) hit a colour instead (CEO 18.11) */
  #paint { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr) auto; }
  #paint .canvas { align-self: stretch; }
  .palette { grid-template-columns: repeat(6, 84px); justify-content: center; align-content: center; align-self: end; gap: 16px; padding: 18px; }
  .quizmode .qpanel { align-self: end; }
  .sw { width: 84px; height: 84px; }
  .themes { grid-template-columns: repeat(2, 1fr); }
  .theme:last-child:nth-child(odd) { grid-column: span 2; }
}
@media (max-width: 560px) {
  .sw { width: 64px; height: 64px; }
  .palette { grid-template-columns: repeat(4, 64px); gap: 12px; }
  .round { width: 60px; height: 60px; }
  .task .say { width: 52px; height: 52px; }
  .grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .card .cap { font-size: 17px; }
}
@media (max-height: 520px) and (orientation: landscape) {
  /* phone held sideways: 3 columns of colours, so the picture and the eraser are never cut off (audit 18.11) */
  #paint { grid-template-rows: auto minmax(0, 1fr); }
  .sw { width: min(50px, calc((100dvh - 128px) / 4.5)); height: min(50px, calc((100dvh - 128px) / 4.5)); }
  .palette { grid-template-columns: repeat(3, auto); gap: 6px; padding: 8px; }
  .round { width: 56px; height: 56px; }
  .task .say { width: 48px; height: 48px; }
}

/* ---------- questions from the hero ---------- */
svg.pic [data-part] { transform-box: fill-box; transform-origin: 50% 50%; }
svg.pic .found { animation: found .8s ease 2; }
@keyframes found { 50% { transform: scale(1.18); } }
svg.pic .hint { animation: hintk 1.4s ease 2; }
@keyframes hintk { 50% { transform: scale(1.12); filter: drop-shadow(0 0 10px #FFC93C) drop-shadow(0 0 4px #FFC93C); } }
svg.pic .tap { animation: tapk .4s ease; }
@keyframes tapk { 50% { transform: scale(1.06); } }
/* quiz is its own mode: no palette (nothing to colour by mistake), yellow frame, brush button to go back */
.qpanel { display: none; }
#paint { transition: background-color .3s; }
#paint.quizmode { background-color: #FFF3C4; }
.quizmode .palette { display: none; }
.quizmode .qpanel { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 12px; background: #FFF6D6; border-radius: 26px;
  box-shadow: 0 6px 0 rgba(43,35,80,.14); }
.topaint { width: 88px; height: 88px; border-radius: 50%; background: #fff; display: grid; place-items: center; box-shadow: 0 4px 0 rgba(43,35,80,.2); flex: none; }
.topaint svg { width: 50px; height: 50px; fill: none; stroke: var(--ink); stroke-width: 2.6; stroke-linejoin: round; stroke-linecap: round; }
.quizmode .canvas { box-shadow: 0 0 0 8px var(--sun), 0 6px 0 8px rgba(43,35,80,.14); }
.quizmode svg.pic .l, .quizmode svg.pic .k, .quizmode svg.pic .w { pointer-events: visiblePainted; }
/* the hero asks: its face + a speech bubble */
.qface { display: none; width: 64px; height: 64px; flex: none; border-radius: 50%; background: var(--sun); overflow: hidden; }
.qface svg, .qhero svg { width: 100%; height: 100%; }
.quizmode .qface { display: block; }
.quizmode .task { background: #fff; position: relative; }
.qdots { display: flex; gap: 8px; margin-bottom: 4px; }
.qdots[hidden] { display: none; }
.qdots i { width: 14px; height: 14px; border-radius: 50%; background: #E7E1F5; }
.qdots i.ok { background: var(--mint); }
.qdots i.now { background: var(--sun); width: 18px; height: 18px; margin-top: -2px; }
.qbtn { flex: none; width: 76px; height: 76px; margin: 0 8px; border-radius: 50%; background: var(--sun); padding: 5px;
  box-shadow: 0 5px 0 rgba(43,35,80,.22), 0 0 0 4px #fff; animation: qpulse 1.6s ease-in-out infinite; }
.qhero { display: block; width: 100%; height: 100%; border-radius: 50%; overflow: hidden; background: #fff; }
.qbtn[hidden] { display: none; }
@keyframes qpulse { 50% { transform: scale(1.1); } }

/* ---------- grown-ups gate ---------- */
.gate { position: fixed; inset: 0; z-index: 30; background: rgba(43,35,80,.55); display: grid; place-items: center; padding: 16px; }
.gatebox { position: relative; background: var(--paper); border-radius: 28px; padding: 22px 22px 20px; width: min(380px, 100%); display: grid; gap: 12px; text-align: center; }
.gatebox.bad { animation: shake .5s ease; }
.gatebox h3 { margin: 0; font-size: 22px; }
.gatebox p { margin: 0; font-weight: 700; color: var(--muted); }
.gx { position: absolute; top: 10px; right: 10px; width: 46px; height: 46px; }
.gx svg { width: 22px; height: 22px; }
.gatebox .gtask { color: var(--ink); font-size: 20px; font-weight: 900; }
.gatebox.locked .gkeys { opacity: .35; pointer-events: none; }
.gsum { font-size: 38px; font-weight: 900; font-variant-numeric: tabular-nums; }
.gsum b { display: inline-block; min-width: 2.2ch; color: var(--coral); }
.gkeys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.gkeys button { height: 64px; border-radius: 16px; background: var(--sky); font-size: 26px; font-weight: 900; display: grid; place-items: center; }
.gkeys button:disabled { opacity: .45; }
.gkeys button svg { width: 26px; height: 26px; fill: none; stroke: var(--ink); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.gkeys .gok { background: var(--mint); color: #fff; font-size: 18px; }
.task { flex-wrap: wrap; }
.qstep { display: block; font-size: .62em; color: var(--muted); letter-spacing: .02em; }
.ans { display: flex; flex-direction: column; gap: 16px; }
.ans[hidden] { display: none; }
.num { width: 88px; height: 88px; border-radius: 24px; background: var(--sun); font-size: 44px; line-height: 1; font-weight: 900; box-shadow: 0 4px 0 rgba(43,35,80,.2);
  font-variant-numeric: tabular-nums; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.pips { display: flex; flex-wrap: wrap; justify-content: center; gap: 3px; max-width: 64px; }
.pips i { width: 9px; height: 9px; border-radius: 50%; background: var(--ink); }
@media (orientation: portrait) { .quizmode .qpanel, .ans { flex-direction: row; } }
.num:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(43,35,80,.2); }
.num.ok { background: var(--mint); color: #fff; }
.num.bad { animation: shake .5s ease; }
@keyframes shake { 20%,60% { transform: translateX(-6px); } 40%,80% { transform: translateX(6px); } }
.burst { position: fixed; width: 80px; height: 80px; margin: -40px 0 0 -40px; pointer-events: none; z-index: 22; animation: burst .85s ease-out forwards; }
.burst svg { width: 100%; height: 100%; }
@keyframes burst { from { transform: scale(.3); opacity: 1; } to { transform: scale(1.7) rotate(50deg); opacity: 0; } }
.badges { display: inline-flex; gap: 2px; }
@media (max-width: 560px) {
  .num { width: 76px; height: 76px; font-size: 36px; } .topaint { width: 76px; height: 76px; }
  .qbtn { width: 60px; height: 60px; margin: 0; padding: 4px; } .qface { width: 44px; height: 44px; }
  #paint .topbar { gap: 8px; } .task { gap: 6px; padding: 6px 6px 6px 12px; } .task p { font-size: 15px; } .task .tick { display: none; }
}
@media (max-height: 520px) and (orientation: landscape) { .num { width: 64px; height: 64px; font-size: 30px; } .pips { display: none; } .ans { gap: 8px; } .quizmode .qpanel { gap: 8px; } .topaint { width: 64px; height: 64px; } }

/* ---------- friends ---------- */
.friends { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; padding-block: 6px 24px; }
.friend { background: var(--paper); border-radius: 24px; padding: 10px 10px 8px; box-shadow: 0 5px 0 rgba(43,35,80,.14); text-align: center; }
.friend svg { width: 100%; aspect-ratio: 1; display: block; }
.friend b { display: block; font-size: 20px; padding-top: 4px; }
.friend.locked { background: rgba(255,255,255,.55); box-shadow: none; }
.friend.locked b { color: #B9B1D6; }
.empty { font-size: 20px; color: var(--muted); margin: 4px 0 10px; max-width: 60ch; }

/* ---------- parents ---------- */
.panel { background: var(--paper); border-radius: 24px; padding: 18px 20px; box-shadow: 0 5px 0 rgba(43,35,80,.12); display: grid; gap: 12px; max-width: 720px; }
.panel h3 { margin: 0; font-size: 20px; }
.panel p { margin: 0; font-weight: 700; color: var(--muted); line-height: 1.45; max-width: 65ch; }
.row { display: flex; flex-wrap: wrap; gap: 10px; }
.chip { border-radius: 999px; padding: 10px 18px; background: var(--sky); font-weight: 900; font-size: 17px; }
.chip.on { background: var(--ink); color: #fff; }
.chip.warn { background: #FFE3DE; color: #B23A26; }
.stack { display: grid; gap: 16px; padding-block: 4px 30px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-weight: 800; font-variant-numeric: tabular-nums; }
.kv span:nth-child(odd) { color: var(--muted); font-weight: 700; }

/* ---------- celebration ---------- */
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 20; }
.confetti i { position: absolute; top: -20px; width: 12px; height: 18px; border-radius: 4px; animation: fall 2.4s cubic-bezier(.2,.6,.4,1) forwards; }
@keyframes fall { to { transform: translate(var(--dx), 110vh) rotate(var(--r)); } }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: #fff;
  padding: 14px 24px; border-radius: 999px; font-size: 20px; z-index: 21; display: flex; gap: 10px; align-items: center; max-width: calc(100vw - 32px);
  animation: toast 3.2s ease forwards; pointer-events: none; }
@media (orientation: portrait) { .toast { bottom: auto; top: calc(110px + env(safe-area-inset-top, 0px)); } }
/* phone upright: suggest turning it */
.rotate { position: fixed; inset: 0; z-index: 25; background: rgba(43,35,80,.55); display: grid; place-items: center; padding: 16px; }
.rotbox { background: var(--paper); border-radius: 28px; padding: 24px; display: grid; gap: 16px; justify-items: center; text-align: center; max-width: 320px; }
.rotbox p { margin: 0; font-size: 20px; }
.rotbox .phone { width: 46px; height: 76px; border: 5px solid var(--ink); border-radius: 12px; animation: turn 2s ease-in-out infinite; }
@keyframes turn { 30%,70% { transform: rotate(-90deg); } }
.toast svg { width: 26px; height: 26px; flex: none; }
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, 20px); } 10%,85% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; transform: translate(-50%, 10px); } }

@media (prefers-reduced-motion: reduce) {
  .alive .hero, svg.pic .hero.alive, .alive .wag, svg.pic .hero.alive .wag, .alive .eye, svg.pic .hero.alive .eye { animation: none; }
  .confetti { display: none; }
}

/* ---------- the hero's screen (v12, CEO 15.11): the hero moves, the yellow button opens its 3 games, 5 stars ---------- */
#hero { padding-block: 12px; }
.srow { display: inline-flex; gap: 3px; flex: none; }
.srow svg { width: 24px; height: 24px; }
.srow.big { gap: 8px; }
.srow.big svg { width: clamp(40px, 7vmin, 60px); height: clamp(40px, 7vmin, 60px); }
.srow svg.pop { animation: starpop .9s ease 2; }
@keyframes starpop { 50% { transform: scale(1.5) rotate(20deg); } }
.card .cap { flex-wrap: wrap; row-gap: 4px; }
.gamesbtn { flex: none; width: 88px; height: 88px; border-radius: 50%; background: var(--sun); display: grid; place-items: center;
  box-shadow: 0 5px 0 rgba(43,35,80,.22); animation: callme 1.5s ease-in-out infinite; }
.gamesbtn svg { width: 50px; height: 50px; } /* the triangle itself is drawn optically centred (CEO 18.11) */
.gamesbtn.calm { animation: none; }
@keyframes callme { 0%,100% { transform: scale(1); } 50% { transform: scale(1.12); } }
.stage { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding-bottom: 12px; }
.bighero { flex: 0 1 auto; width: min(78vw, 62vh, 560px); aspect-ratio: 1; min-height: 0; transform-origin: 50% 100%;
  animation: idle 2.8s ease-in-out infinite; }
.bighero svg { width: 100%; height: 100%; }
@keyframes idle { 0%,100% { transform: translateY(0) rotate(0) scale(1); } 25% { transform: translateY(-3%) rotate(-2.5deg); }
  50% { transform: translateY(0) scale(1.03,.97); } 75% { transform: translateY(-3%) rotate(2.5deg); } }
.bighero.jump { animation: hop .75s ease; }
@keyframes hop { 20% { transform: scale(1.08,.9); } 50% { transform: translateY(-16%) scale(.95,1.06); } 80% { transform: translateY(0) scale(1.05,.95); } 100% { transform: none; } }
.sheet { position: absolute; inset: 0; z-index: 10; background: rgba(43,35,80,.4); display: grid; place-items: center; padding: 16px; }
.sheetbox { position: relative; background: var(--paper); border-radius: 30px; padding: 18px 18px 20px; width: min(860px, 100%); max-height: 100%; overflow-y: auto;
  animation: sheetin .25s ease-out; }
.sheetbox h3 { margin: 0 0 14px; font-size: 30px; text-align: center; }
@keyframes sheetin { from { transform: scale(.85); } }
.games { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.game { background: #F4F1FF; border-radius: 24px; padding: 10px 10px 12px; display: flex; flex-direction: column; align-items: center; gap: 8px;
  box-shadow: 0 5px 0 rgba(43,35,80,.14); font-size: clamp(16px, 2vw, 21px); text-align: center; line-height: 1.1; font-weight: 900; }
.game:active { transform: translateY(3px); }
.game .gart { position: relative; width: 100%; aspect-ratio: 1; border-radius: 18px; background: #fff; overflow: hidden; display: grid; place-items: center; }
.game .gart .gi { width: 80%; height: 80%; }
.game .gart.ga-task .gi, .game .gart.ga-pz .gi { width: 100%; height: 100%; }
.gart.ga-pz .pzlines { position: absolute; inset: 0; background: linear-gradient(90deg, transparent calc(50% - 2px), #9B6BFF calc(50% - 2px) calc(50% + 2px), transparent calc(50% + 2px)),
  linear-gradient(transparent calc(50% - 2px), #9B6BFF calc(50% - 2px) calc(50% + 2px), transparent calc(50% + 2px)); }
.game.done { background: #E5F8EF; }
.game.locked .gart { opacity: .5; }
.game.no { animation: no .5s ease; }
.gart .qmark { position: absolute; top: 2%; right: 8%; font-size: clamp(40px, 8vw, 70px); color: var(--coral); line-height: 1; z-index: 1; }
.gart.q .qf { width: 78%; height: 78%; }
.gart .lk { position: absolute; inset: 0; display: grid; place-items: center; z-index: 2; }
.gart .lk svg { width: 40%; height: 40%; }
.nextbtn { flex: none; width: 76px; height: 76px; border-radius: 50%; background: var(--sun); display: grid; place-items: center;
  box-shadow: 0 4px 0 rgba(43,35,80,.2); animation: callme 1.5s ease-in-out infinite; }
.nextbtn[hidden] { display: none; }
.nextbtn svg { width: 44px; height: 44px; }
@media (max-width: 560px) {
  .gamesbtn { width: 72px; height: 72px; } .gamesbtn svg { width: 40px; height: 40px; }
  .nextbtn { width: 60px; height: 60px; } .nextbtn svg { width: 34px; height: 34px; }
  .srow svg { width: 19px; height: 19px; }
  .games { grid-template-columns: 1fr; gap: 10px; }
  .game { flex-direction: row; gap: 12px; padding: 8px 12px 8px 8px; font-size: 20px; }
  .game .gart { width: 96px; flex: none; aspect-ratio: 1; margin: 0; }
  .game b { flex: 1; text-align: left; }
}
@media (prefers-reduced-motion: reduce) { .bighero, .gamesbtn, .nextbtn { animation: none; } }
#paint.won .round.undo { display: none; }
.bighero { background: radial-gradient(circle at 50% 58%, #fff 0 56%, rgba(255,255,255,0) 57%); border-radius: 50%; }

/* ---------- v13 (CEO 15.11): 5 different games per hero – shadows, puzzle, "colour me" on its own canvas ---------- */
.only-item > :not(.solo) { display: none; }
svg.pic.shadow { filter: brightness(0); opacity: .85; }
.won .task { background: #E5F8EF; }
#shadow .shstage, #puzzle .pzwrap { flex: 1; min-height: 0; margin-bottom: 12px; }
.shstage { display: flex; align-items: center; justify-content: center; gap: clamp(16px, 4vw, 48px); }
.shmodel { width: min(34vw, 52vh, 360px); aspect-ratio: 1; border-radius: 50%; background: var(--paper); box-shadow: 0 6px 0 rgba(43,35,80,.14); padding: 4%; flex: none; }
.shmodel.in { animation: sheetin .35s ease-out; }
.shopts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.shopts:has(> :nth-child(3):last-child) { grid-template-columns: repeat(3, 1fr); }
.shopt { width: min(19vw, 26vh, 190px); aspect-ratio: 1; border-radius: 26px; background: var(--paper); padding: 10%; box-shadow: 0 5px 0 rgba(43,35,80,.14); }
.shopt:active { transform: translateY(3px); }
.shopt.right { background: #E5F8EF; box-shadow: 0 0 0 6px var(--mint); }
.shopt.no { animation: no .5s ease; }
@media (max-aspect-ratio: 1/1) {
  .shstage { flex-direction: column; }
  .shmodel { width: min(56vw, 30vh); }
  .shopt { width: min(28vw, 18vh); }
}
.pzwrap { position: relative; touch-action: none; }
.pzboard { position: absolute; border-radius: 12px; background: var(--paper); box-shadow: 0 6px 0 rgba(43,35,80,.14); }
.pzboard svg.pzghost { opacity: .22; filter: grayscale(1); }
.pzboard.full svg.pzghost { opacity: 0; }
.pzslots { position: absolute; inset: 0; display: grid; grid-auto-rows: 1fr; pointer-events: none; }
.pzslots i { border: 2px dashed #CFC8E6; }
.pzboard.full .pzslots { display: none; }
.pzslots i.hint { animation: slothint .6s ease 4; }
@keyframes slothint { 50% { background: rgba(255,201,60,.55); border-color: var(--sun); } }
.piece { position: absolute; left: 0; top: 0; overflow: hidden; transform-origin: 0 0; background: #fff; border-radius: 6px; cursor: grab; touch-action: none;
  box-shadow: 0 4px 10px rgba(43,35,80,.28); transition: transform .3s ease; z-index: 2; }
.piece svg.pzpic { position: absolute; max-width: none; pointer-events: none; }
.piece.drag { transition: none; box-shadow: 0 12px 24px rgba(43,35,80,.35); cursor: grabbing; }
.piece.placed { box-shadow: none; border-radius: 0; cursor: default; }
#paint.memode .canvas { background: radial-gradient(circle at 50% 50%, #fff 0 60%, #FFF6DA 61%); }
/* grown-ups gate on a phone held sideways: question left, keys right, OK always on screen (audit 18.11) */
@media (max-height: 520px) and (orientation: landscape) {
  .gate { place-items: start center; overflow-y: auto; padding: 10px; }
  .gatebox { width: min(640px, 100%); grid-template-columns: 1fr 1.25fr; align-items: center; column-gap: 18px; row-gap: 8px; padding: 12px 16px; }
  .gatebox > :not(.gkeys):not(.gx) { grid-column: 1; }
  .gatebox .gkeys { grid-column: 2; grid-row: 1 / span 4; gap: 8px; }
  .gatebox .gx { right: auto; left: 10px; }
  .gatebox h3 { padding-top: 40px; }
  .gkeys button { height: min(56px, calc((100dvh - 80px) / 4.6)); }
}
/* phone held upright (CEO 18.11): the task text gets its own full-width line under the buttons,
   colours in 2 rows of 6 – the picture keeps most of the screen (iPhone SE had 58 px of picture) */
@media (orientation: portrait) and (max-width: 560px) {
  .topbar:has(.task) { flex-wrap: wrap; row-gap: 8px; }
  .topbar:has(.task) .task { order: 3; flex-basis: 100%; }
  .topbar:has(.task) #back + .task + * { margin-left: auto; }
  .topbar:has(.task) .task p { font-size: 15px; text-wrap: pretty; }
  .palette { grid-template-columns: repeat(6, 46px); gap: 8px 10px; padding: 10px; }
  .sw { width: 46px; height: 46px; }
  .sw.on { box-shadow: inset 0 -4px 0 rgba(0,0,0,.14), inset 0 0 0 3px rgba(0,0,0,.12), 0 0 0 3px var(--paper), 0 0 0 6px var(--ink); }
  .sw.eraser svg { width: 24px; height: 24px; }
}
/* the win must be obvious (CEO 18.11: "I coloured 3 stars and it didn't count" – it did, but only a pale bubble and a small button showed it):
   a big pulsing "next" button with "+1 star" in the middle of the bottom, the palette fades */
.won .nextbtn { position: fixed; z-index: 30; left: 50%; bottom: calc(28px + env(safe-area-inset-bottom, 0px)); margin-left: -62px;
  width: 124px; height: 124px; box-shadow: 0 0 0 12px rgba(255,201,60,.35), 0 6px 0 rgba(43,35,80,.25); }
.won .nextbtn svg { width: 66px; height: 66px; }
.won .nextbtn::before { content: '+1 \2605'; position: absolute; top: -50px; left: 50%; transform: translateX(-50%); white-space: nowrap;
  font-family: var(--font); font-weight: 900; font-size: 34px; line-height: 1; color: #FFC93C; -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; }
#paint.won .palette { opacity: .35; }
.won .task .tick { display: block !important; }

/* ======================================================================
   v19 look (CEO 19.11): concept B – bright glossy 3D toy buttons, like Red Button,
   but a calm background (soft sky, two quiet clouds, no dot pattern). Only visuals here: sizes and layout rules above stay.
   ====================================================================== */
:root { --sky: #DDF1FF; --glossTop: rgba(255,255,255,.55); --lift: 0 6px 0 rgba(43,35,80,.22); --purple: #8B5CF6; --pink: #F25BA6; }
body { background-color: #DDF1FF; background-image: linear-gradient(180deg, #C7E8FF 0%, #DFF2FF 50%, #EEF8FF 100%); background-size: auto; background-attachment: fixed; }
body::before, body::after { content: ''; position: fixed; z-index: 0; pointer-events: none; background: url(../art/ui/cloud.png?v=19) center / contain no-repeat; opacity: .55; }
body::before { width: 120px; height: 70px; top: 14%; right: -40px; }
body::after { width: 150px; height: 86px; bottom: 6%; left: -56px; opacity: .45; }
#app { z-index: 1; }

/* glossy buttons: highlight on top, darker rim at the bottom, a solid lift shadow */
.round { background: linear-gradient(180deg, #fff 0%, #EEF0FF 100%); box-shadow: inset 0 -5px 0 rgba(43,35,80,.10), inset 0 3px 0 #fff, var(--lift); }
#back { background: linear-gradient(180deg, #B39BFF 0%, var(--purple) 55%, #6B3FE0 100%); box-shadow: inset 0 -5px 0 rgba(40,0,120,.30), inset 0 3px 0 rgba(255,255,255,.45), var(--lift); }
#back svg { stroke: #fff; stroke-width: 4; }
.round:active, #back:active { transform: translateY(4px); box-shadow: inset 0 -3px 0 rgba(43,35,80,.12), 0 2px 0 rgba(43,35,80,.22); }
.stars { background: linear-gradient(180deg, #A98BFF, var(--purple) 60%, #6B3FE0); color: #fff; box-shadow: inset 0 -4px 0 rgba(40,0,120,.3), inset 0 2px 0 rgba(255,255,255,.4), var(--lift);
  text-shadow: 0 2px 0 rgba(40,0,120,.35); }
.title { text-shadow: 0 3px 0 #fff, 0 5px 0 rgba(43,35,80,.12); }

/* logo: chunky candy letters with a white rim */
.logo { -webkit-text-stroke: 7px #fff; paint-order: stroke fill; filter: drop-shadow(0 5px 0 rgba(43,35,80,.18)); text-shadow: none; }

/* home tiles: candy glass */
.theme { border-radius: 32px; box-shadow: inset 0 -8px 0 rgba(0,0,0,.14), inset 0 4px 0 rgba(255,255,255,.45), 0 7px 0 rgba(43,35,80,.20), 0 14px 22px rgba(43,35,80,.12); }
.theme::before { content: ""; position: absolute; left: 7%; right: 7%; top: 5px; height: min(22%, 80px); border-radius: 26px 26px 60% 60% / 26px 26px 40% 40%;
  background: linear-gradient(180deg, rgba(255,255,255,.35), rgba(255,255,255,0)); pointer-events: none; z-index: 1; }
.theme .art { position: relative; z-index: 2; }
.theme .art svg { filter: drop-shadow(0 4px 0 rgba(43,35,80,.18)); }
.theme .label { position: static; background: none; color: #fff; font-size: clamp(20px, 2.6vw, 30px); text-shadow: 0 3px 0 rgba(0,0,0,.22), 0 0 2px rgba(0,0,0,.25); order: -1; margin: 8px 10px 0; padding: 2px; z-index: 2; }
.theme .label em { top: auto; bottom: 12px; right: 12px; background: rgba(43,35,80,.28); color: #fff; text-shadow: none; padding: 5px 12px 5px 30px; font-size: 17px;
  box-shadow: inset 0 2px 0 rgba(0,0,0,.12); background-image: url(../art/ui/star.png?v=19); background-repeat: no-repeat; background-size: 20px; background-position: 7px 50%; }
.theme .art { padding: 2px 10px 50px; }

.friendsbtn { background: linear-gradient(180deg, #FF8CC6, var(--pink) 60%, #D63A88); color: #fff; text-shadow: 0 2px 0 rgba(120,0,60,.35);
  box-shadow: inset 0 -5px 0 rgba(120,0,60,.28), inset 0 3px 0 rgba(255,255,255,.45), var(--lift); }
.gear { background: linear-gradient(180deg, #A98BFF, var(--purple) 60%, #6B3FE0); box-shadow: inset 0 -4px 0 rgba(40,0,120,.3), inset 0 2px 0 rgba(255,255,255,.4), var(--lift); }
.gear svg.ic { stroke: #fff; }

/* yellow action buttons (play, next, say) */
.gamesbtn, .nextbtn, .task .say, .qbtn, .num { background: linear-gradient(180deg, #FFE58A 0%, var(--sun) 55%, #F0A800 100%);
  box-shadow: inset 0 -6px 0 rgba(160,90,0,.30), inset 0 3px 0 rgba(255,255,255,.6), var(--lift); }
.won .nextbtn { box-shadow: inset 0 -6px 0 rgba(160,90,0,.30), inset 0 3px 0 rgba(255,255,255,.6), 0 0 0 12px rgba(255,201,60,.35), 0 6px 0 rgba(43,35,80,.25); }
.num.ok { background: linear-gradient(180deg, #7DE8BE, var(--mint) 60%, #2AA77E); }
#paint .round.undo { background: linear-gradient(180deg, #D8EEFF, #A9D8FF); }

/* cards and panels: white candy with a soft lift */
.card, .friend, .panel, .game, .shopt, .shmodel, .task, .canvas, .palette, .quizmode .qpanel, .sheetbox, .gatebox, .rotbox {
  box-shadow: inset 0 -4px 0 rgba(43,35,80,.06), 0 6px 0 rgba(43,35,80,.12), 0 12px 20px rgba(43,35,80,.08); }
.card { border-radius: 26px; }
.card .thumb { border: 0; box-shadow: inset 0 0 0 3px #EEE9FB; }
.game { background: linear-gradient(180deg, #FFFFFF, #F1ECFF); }
.game.done { background: linear-gradient(180deg, #F2FFF8, #D7F6E7); }
.task { border-radius: 999px; }
.canvas { border: 5px solid #fff; background: #fff; }

/* paint blobs: glossy, like the concept */
.sw { box-shadow: inset 0 -6px 0 rgba(0,0,0,.18), inset 0 0 0 3px rgba(0,0,0,.08), 0 4px 0 rgba(43,35,80,.18); }
.sw::after { content: ''; position: absolute; left: 20%; top: 10%; width: 44%; height: 30%; border-radius: 50%; background: rgba(255,255,255,.55); pointer-events: none; }
.sw.eraser::after { display: none; }
.sw.on { box-shadow: inset 0 -6px 0 rgba(0,0,0,.18), 0 0 0 4px #fff, 0 0 0 8px var(--purple), 0 6px 10px rgba(43,35,80,.25); }

/* hero screen: soft sunny glow behind the hero */
.bighero { background: radial-gradient(circle at 50% 56%, #fff 0 52%, rgba(255,240,170,.9) 58%, rgba(255,240,170,0) 70%); }
.srow.big svg { filter: drop-shadow(0 3px 0 rgba(43,35,80,.15)); }

/* home: two crayons peeking from the sides, nothing else (calm) */
#home::before, #home::after { content: ''; position: absolute; pointer-events: none; z-index: 0; width: 92px; height: 92px; background: center / contain no-repeat; opacity: .95; }
#home::before { left: -18px; bottom: 96px; background-image: url(../art/ui/crayons_l.png?v=19); }
#home::after { right: -18px; top: 120px; background-image: url(../art/ui/crayons_r.png?v=19); }
#home > * { position: relative; z-index: 1; }
@media (max-width: 560px) { #home::before, #home::after { width: 70px; height: 70px; } }

/* ======================================================================
   v20 (QA 19.11): small phones and edge cases
   ====================================================================== */
/* theme names never cut ("Cachor…", "Dinosa…" on a phone held sideways): the name follows the tile width */
.theme { container-type: inline-size; }
@supports (container-type: inline-size) { .theme .label { font-size: clamp(11px, 12cqi, 30px); }
  @media (orientation: portrait) { .theme:last-child:nth-child(odd) .label { font-size: clamp(11px, 6cqi, 30px); } } }
@media (max-height: 520px) and (orientation: landscape) { .theme .label { margin: 6px 4px 0; } }

@media (orientation: portrait) and (max-width: 560px) {
  /* the picture column may never grow wider than the screen (iPhone SE 320: palette pushed undo and a colour off screen) */
  #paint { grid-template-columns: minmax(0, 1fr); }
  .sw { width: min(46px, calc((100vw - 78px) / 6)); height: min(46px, calc((100vw - 78px) / 6)); }
  .palette { grid-template-columns: repeat(6, auto); justify-content: center; }
  /* games menu: all 5 tiles fit without scrolling */
  .game .gart { width: clamp(52px, calc((100dvh - 210px) / 5 - 16px), 96px); }
  .sheetbox { padding: 14px 14px 16px; } .sheetbox h3 { font-size: 26px; margin-bottom: 10px; }
}
@media (orientation: portrait) and (max-width: 380px) {
  .palette { gap: 8px 6px; padding: 8px; }
  /* home on a small phone: logo and stars on one row, so the heroes on the tiles get the room */
  #home .head { flex-wrap: nowrap; padding-block: 10px 2px; }
  #home .logo { font-size: 36px; -webkit-text-stroke-width: 5px; }
  #home .stars { font-size: 17px; padding: 6px 12px; } #home .stars svg { width: 20px; height: 20px; }
  .theme .art { padding: 0 6px 34px; }
  .theme .label em { bottom: 6px; right: 8px; font-size: 14px; padding: 3px 9px 3px 25px; background-size: 16px; }
}

/* shadows: 4 options in portrait and 3 on a wide iPad stay on screen */
@media (max-aspect-ratio: 1/1) {
  .shmodel { width: min(56vw, 26vh); }
  .shopt { width: min(28vw, 15vh); }
  .shopts:has(> :nth-child(3):last-child) .shopt { width: min(26vw, 15vh); }
}
@media (max-aspect-ratio: 1/1) and (max-height: 600px) { .shmodel { width: min(56vw, 23vh); } .shopt, .shopts:has(> :nth-child(3):last-child) .shopt { width: min(28vw, 14vh); } }
@media (min-aspect-ratio: 1/1) {
  .shstage { min-width: 0; }
  .shmodel { width: min(30vw, 52vh, 360px); }
  .shopts:has(> :nth-child(3):last-child) .shopt { width: min(15vw, 24vh, 170px); }
}

/* v24: privacy policy inside "For parents" */
.policy { margin-top: 12px; text-align: left; }
.policy p { font-size: 15px; line-height: 1.45; margin: 0 0 8px; font-weight: 700; }
#parents .chip { min-height: 46px; }
