/* KidoDino games – shared stage, v6 (15 Nov 2026). Built only from tokens.css.
   One layout for every game (Sivan, 15 Nov): Kido on his own at the side with air around him, the game in the middle,
   the game's own tools on the other side. Grape band on top (home · stars and the way-to-play switch · grown-ups).
   Soft field in the volume colour, so the coloured pictures stand out. Ink outlines, one soft shadow, nothing tilted.
   The game starts at once: no Play screen. The end is a card over the finished board. No words for the child. */
:root { --band: 80px; --field: #E2F4FE; --tint: #B5E3FC; --field-d: #CBEBFD; --kido-w: clamp(120px, 15vw, 190px);
  --stars: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cpath d='M44 24l6 12 13 2-10 9 3 13-12-7-12 7 3-13-10-9 13-2z'/%3E%3Cpath d='M176 132l4 9 10 1-8 7 3 10-9-6-9 6 3-10-8-7 10-1z'/%3E%3Ccircle cx='130' cy='44' r='6'/%3E%3Ccircle cx='66' cy='166' r='5'/%3E%3Ccircle cx='206' cy='216' r='6'/%3E%3Ccircle cx='22' cy='110' r='4'/%3E%3Ccircle cx='214' cy='70' r='4'/%3E%3C/svg%3E"); }
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--field); color: var(--ink, #2B2D5C); font-family: var(--font); overflow: hidden; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: manipulation; }
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; }
:focus-visible { outline: 4px solid var(--grape); outline-offset: 4px; border-radius: var(--r-sm); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
svg { display: block; width: 100%; height: 100%; overflow: visible; }
.kd-sil * { fill: var(--ink) !important; stroke: var(--ink) !important; opacity: 1 !important; }

.stage { position: fixed; inset: 0; display: grid; grid-template-rows: var(--band) 1fr; background-color: var(--field); transition: background-color .6s; }
.stage::before { content: ""; position: absolute; inset: 0; background: var(--tint); pointer-events: none; transition: background-color .6s;
  -webkit-mask: var(--stars) 0 0 / 240px 240px; mask: var(--stars) 0 0 / 240px 240px; }

/* band */
.band { background: var(--grape); display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  padding: env(safe-area-inset-top, 0px) max(var(--s3), env(safe-area-inset-right, 0px)) 0 max(var(--s3), env(safe-area-inset-left, 0px)); position: relative; z-index: var(--z-sticky); }
.band-mid { display: flex; align-items: center; gap: var(--s5); }
.round { width: 60px; height: 60px; flex: none; border-radius: 50%; background: var(--paper); border: var(--outline); display: grid; place-items: center; position: relative; transition: transform .12s; }
.round svg { width: 36px; height: 36px; }
.round:active { transform: scale(.94); }
.gate .ring { position: absolute; inset: -9px; width: 72px; height: 72px; transform: rotate(-90deg); pointer-events: none; }
.gate .ring circle { fill: none; stroke: var(--sun); stroke-width: 6; stroke-dasharray: 214; stroke-dashoffset: 214; }
.gate.holding .ring circle { transition: stroke-dashoffset 2s linear; stroke-dashoffset: 0; }
.stars { display: flex; gap: var(--s1); align-items: center; }
.stars span { width: 38px; height: 38px; display: block; transition: transform .4s var(--ease); }
.stars span.new { transform: scale(1.5) rotate(-12deg); }

/* the way-to-play switch sits above the rule card, with clear air between them so it reads as its own control */
.toggle { position: relative; display: flex; padding: 4px; gap: 4px; background: var(--paper); border: var(--outline); border-radius: var(--r-pill); }
.toggle i { position: relative; z-index: 1; width: 64px; height: 48px; display: grid; place-items: center; transition: opacity .25s, filter .25s; }
.toggle i svg { width: 36px; height: 36px; }
.toggle::before { content: ""; position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc(50% - 6px); border-radius: var(--r-pill); background: var(--sun); transition: transform .28s var(--ease); }
.toggle[aria-checked="true"]::before { transform: translateX(calc(100% + 4px)); }
.toggle[aria-checked="false"] i:last-child, .toggle[aria-checked="true"] i:first-child { opacity: .45; filter: grayscale(1); }
.toggle.nudge { animation: call .9s 2; }

/* field: three columns – Kido · game · tools */
.field { position: relative; z-index: 1; min-height: 0; display: grid; grid-template-columns: var(--kido-w) minmax(0, 1fr) auto; align-items: center;
  gap: clamp(var(--s4), 3vw, var(--s7)); padding: var(--s5) max(var(--s6), env(safe-area-inset-right, 0px)) var(--s6) max(var(--s6), env(safe-area-inset-left, 0px)); }
.hills { position: absolute; left: 0; right: 0; bottom: 0; height: 18%; color: var(--field-d); pointer-events: none; transition: color .6s; }
.hills svg { width: 100%; height: 100%; }
.side { position: relative; z-index: 1; align-self: end; display: grid; justify-items: center; padding-bottom: var(--s4); }
.kido { width: var(--kido-w); aspect-ratio: 851 / 1191; border-radius: var(--r-md); }
.kido .kido-art { display: block; height: 100%; transform-origin: 50% 100%; }
.kido .kido-art svg, .kido .kido-art img { height: 100%; width: auto; }
.kido.hop .kido-art { animation: hop .55s; } .kido.wig .kido-art { animation: wig .6s; } .kido.dance .kido-art { animation: dance 1.2s; } .kido.nope .kido-art { animation: nope .45s; }

/* Treasure Hunt: board in the middle, the goal (rule card + basket under it) on the right */
.board { position: relative; z-index: 1; display: grid; place-content: center; gap: var(--gap, 14px); min-height: 0; height: 100%; }
.card { width: var(--tile, 120px); height: var(--tile, 120px); background: var(--paper); border: var(--outline); border-radius: 22%; box-shadow: var(--shadow);
  display: grid; place-items: center; padding: 12%; position: relative; animation: drop .45s both var(--ease); transition: transform .12s; }
.card:active { transform: scale(.95); }
.card.gone svg { visibility: hidden; } .card.gone { box-shadow: none; background: rgb(255 253 246 / .5); border-style: dashed; }
.card.wob { animation: wob .4s; } .card.glow { animation: glow 1s infinite; }
.goal { position: relative; z-index: 1; display: grid; justify-items: center; gap: var(--s4); }
.goal .toggle { margin-bottom: var(--s6); }
.rule { width: clamp(108px, 12vw, 150px); aspect-ratio: 1; padding: var(--s4); background: var(--paper); border: var(--outline); border-radius: var(--r-md); box-shadow: var(--shadow); display: grid; place-items: center; }
.rule svg { width: 100%; height: 100%; }
.rule.pulse { animation: pulse .5s 2; }
.basket { position: relative; display: grid; grid-template-columns: repeat(2, 46px); gap: 6px; padding: 14px 14px 16px; border-radius: 12px 12px 30px 30px; border: var(--outline);
  background: repeating-linear-gradient(90deg, #DDA568 0 18px, #CF9557 18px 20px); justify-content: center; }
.basket::before { content: ""; position: absolute; left: -9px; right: -9px; top: -8px; height: 14px; border-radius: 8px; background: #BE8346; border: var(--outline); }
.slot { width: 46px; height: 46px; border-radius: 50%; border: 3px dashed #8A5A26; background: rgb(255 243 214 / .6); }
.slot.full { border: 0; background: none; animation: pop .35s; }

.flyer { position: fixed; z-index: var(--z-hint); pointer-events: none; }
.sparkle { position: fixed; z-index: var(--z-hint); width: 90px; height: 90px; margin: -45px 0 0 -45px; pointer-events: none; animation: spark .55s forwards; }
.hand { position: fixed; z-index: var(--z-hint); width: 64px; height: 64px; pointer-events: none; animation: point 1s infinite; }

/* the end: a card over the finished board */
.ending { position: fixed; inset: 0; z-index: var(--z-overlay); display: grid; place-items: center; padding: var(--s4); background: rgb(43 45 92 / .28); overflow: hidden; }
.end-card { position: relative; width: min(100%, 420px); background: var(--paper); border-radius: 28px; box-shadow: var(--shadow-lift); padding: var(--s6) var(--s6) var(--s5);
  display: grid; justify-items: center; gap: var(--s4); animation: rise .5s var(--ease) both; }
.end-stars { display: flex; gap: var(--s1); } .end-stars span { width: 40px; height: 40px; animation: pop .5s both; }
.end-stars span:nth-child(2) { animation-delay: .08s; } .end-stars span:nth-child(3) { animation-delay: .16s; } .end-stars span:nth-child(4) { animation-delay: .24s; } .end-stars span:nth-child(5) { animation-delay: .32s; }
.end-card .kido { width: 150px; }
.choices { display: flex; gap: var(--s6); }
.round.big { width: 84px; height: 84px; } .round.big svg { width: 50px; height: 50px; }
#again { background: var(--sun); }
.end-note { margin: 0; font: var(--t-small); color: var(--muted); text-align: center; max-width: 30ch; }
.confetti { position: absolute; left: 50%; top: 45%; width: 40px; height: 40px; margin: -20px 0 0 -20px; animation: burst 1.1s var(--ease) both; pointer-events: none; }

/* grown-ups panel */
.panel { position: fixed; inset: 0; z-index: var(--z-panel); background: rgb(43 45 92 / .5); display: grid; place-items: center; padding: var(--s4); user-select: text; -webkit-user-select: text; }
.panel-in { background: var(--paper); border-radius: var(--r-md); box-shadow: var(--shadow-lift); max-width: 620px; width: 100%; max-height: 92vh; overflow: auto; padding: var(--s6); font: var(--t-body); }
.panel h2 { margin: 0 0 var(--s2); font: var(--t-h3); } .panel h3 { margin: var(--s5) 0 var(--s2); font: var(--t-label); } .panel p { margin: 0 0 var(--s2); }
.seg { display: flex; flex-wrap: wrap; gap: var(--s2); }
.seg button { min-height: 48px; padding: var(--s2) var(--s4); border-radius: var(--r-pill); border: var(--outline); background: var(--white); font: var(--t-label); }
.seg button[aria-pressed="true"] { background: var(--sun); }
.seg .btn { background: var(--green-deep); border-color: var(--green-deep); color: var(--white); }

/* Kido Builds: page in the middle, tray on the right */
.page { position: relative; z-index: 1; justify-self: center; height: min(100%, 60vw); max-height: 560px; aspect-ratio: 200 / 170; max-width: 100%;
  background: var(--paper); border: var(--outline); border-radius: var(--r-md); box-shadow: var(--shadow); padding: 3%; }
.page svg { overflow: visible; }
.gap { fill: rgb(255 253 246 / .3); stroke: var(--ink); stroke-width: 3; stroke-dasharray: 9 7; stroke-linejoin: round; stroke-linecap: round; }
.gap.now { fill: #FFE08A; stroke-width: 3.5; animation: gapnow 1s infinite; }
.piece { animation: pop .35s; transform-box: fill-box; transform-origin: center; }
.alive.drive { animation: drive 2.2s ease-in-out; } .alive.launch { animation: launch 2.2s ease-in; } .alive.bob { animation: bob 2.2s ease-in-out; } .alive.jump { animation: jump 1.6s; }
.tray { position: relative; z-index: 1; display: grid; gap: var(--s4); justify-items: center; align-content: center; }
.tray button { width: clamp(88px, 15vh, 132px); aspect-ratio: 1; background: var(--paper); border: var(--outline); border-radius: 24%; box-shadow: var(--shadow); display: grid; place-items: center; padding: 14%; animation: drop .4s both; transition: transform .12s; }
.tray button:active { transform: scale(.95); }
.tray button.wob { animation: wob .4s; } .tray button.glow { animation: glow 1s infinite; }

/* tall screens: tools on top, game below, Kido small beside the tools */
@media (orientation: portrait) {
  :root { --kido-w: clamp(84px, 22vw, 130px); }
  .band-mid { gap: var(--s3); }
  .field { grid-template-columns: var(--kido-w) minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); align-items: start; padding: var(--s4) var(--s4) var(--s6); gap: var(--s4); }
  .side { grid-column: 1; grid-row: 1; align-self: center; padding: 0; }
  .goal, .tray { grid-column: 2; grid-row: 1; justify-self: start; align-self: center; }
  .goal { grid-template-columns: auto auto; align-items: center; justify-items: start; column-gap: var(--s4); row-gap: 0; }
  .goal .toggle { grid-column: 1 / -1; margin: 0 0 var(--s4); }
  .tray { grid-auto-flow: column; }
  .board, .page { grid-column: 1 / -1; grid-row: 2; }
  .board { align-content: start; }
  .page { height: auto; width: 100%; max-width: 60vh; align-self: start; }
  .rule { width: 92px; padding: var(--s3); }
  .basket { grid-template-columns: repeat(2, 34px); padding: 10px 10px 12px; } .slot { width: 34px; height: 34px; }
  .tray button { width: clamp(64px, 18vw, 92px); }
  /* four shapes (level 3) do not fit in one row beside Kido on a phone: two rows of two, keeping 64px+ targets */
  .tray:has(> :nth-child(4)) { grid-auto-flow: row; grid-template-columns: repeat(2, auto); gap: var(--s3); }
}
/* a phone on its side */
@media (orientation: landscape) and (max-height: 520px) {
  :root { --band: 62px; --kido-w: 96px; }
  .round { width: 48px; height: 48px; } .round svg { width: 30px; height: 30px; } .gate .ring { width: 60px; height: 60px; }
  .stars span { width: 28px; height: 28px; } .toggle i { width: 52px; height: 40px; } .toggle i svg { width: 30px; height: 30px; }
  .field { padding: var(--s2) var(--s5) var(--s3); gap: var(--s4); }
  .rule { width: 84px; padding: var(--s3); } .slot { width: 34px; height: 34px; } .basket { grid-template-columns: repeat(2, 34px); padding: 10px; }
  .tray { gap: var(--s2); } .tray button { width: 68px; }
}
@media (max-width: 440px) { .stars span { width: 24px; height: 24px; } .stars { gap: 2px; } .round { width: 48px; height: 48px; } .round svg { width: 30px; height: 30px; } .gate .ring { width: 60px; height: 60px; } .toggle i { width: 46px; height: 40px; } .toggle i svg { width: 28px; height: 28px; } .band-mid { gap: var(--s2); } }

@keyframes pulse { 50% { transform: scale(1.06); } }
@keyframes hop { 30% { transform: translateY(-9%) scale(1.03, .97); } 60% { transform: translateY(0) scale(.97, 1.03); } }
@keyframes wig { 25% { transform: rotate(-5deg); } 75% { transform: rotate(5deg); } }
@keyframes nope { 25% { transform: translateX(-3%); } 75% { transform: translateX(3%); } }
@keyframes dance { 15% { transform: rotate(-7deg) translateY(-5%); } 40% { transform: rotate(7deg); } 65% { transform: rotate(-7deg) translateY(-5%); } 90% { transform: rotate(4deg); } }
@keyframes call { 0%, 100% { transform: rotate(0) scale(1); } 20% { transform: rotate(-5deg) scale(1.08); } 40% { transform: rotate(4deg) scale(1.08); } 60% { transform: rotate(0) scale(1); } }
@keyframes drop { from { opacity: 0; transform: translateY(-24px) scale(.8); } }
@keyframes wob { 20% { transform: rotate(-6deg); } 50% { transform: rotate(5deg); } 80% { transform: rotate(-3deg); } }
@keyframes glow { 50% { box-shadow: 0 0 0 8px rgb(255 199 58 / .9); } }
@keyframes pop { from { transform: scale(.9); opacity: 0; } 60% { transform: scale(1.08); opacity: 1; } }
@keyframes spark { from { transform: scale(.3) rotate(0); opacity: 1; } to { transform: scale(1.5) rotate(50deg); opacity: 0; } }
@keyframes point { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(12px); } }
@keyframes rise { from { opacity: 0; transform: translateY(30px) scale(.92); } }
@keyframes burst { from { transform: translate(0, 0) scale(.3); opacity: 0; } 20% { opacity: 1; } to { transform: translate(var(--dx), var(--dy)) scale(1) rotate(200deg); opacity: 0; } }
@keyframes gapnow { 50% { fill: #FFC73A; } }
@keyframes drive { 35% { transform: translateX(120%); } 36% { transform: translateX(-120%); } 100% { transform: none; } }
@keyframes launch { 45% { transform: translateY(-130%); } 46% { transform: translateY(130%); } 100% { transform: none; } }
@keyframes bob { 20% { transform: translate(6%, -4%) rotate(4deg); } 50% { transform: translate(-6%, 2%) rotate(-4deg); } 80% { transform: translate(4%, -3%) rotate(3deg); } }
@keyframes jump { 25% { transform: translateY(-9%) scale(1.04); } 50% { transform: none; } 70% { transform: translateY(-5%); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01s !important; animation-iteration-count: 1 !important; transition-duration: .01s !important; } }

/* Kido's Color Lab v3 (15 Nov): "Stir" from the mixing prototype. The picture is the hero; the finished card sits small in
   the corner; jars and Kido's palette share one table at the bottom. The brush is the pointer. */
.field.mix { grid-template-columns: var(--kido-w) minmax(0, 1fr) auto; grid-template-rows: minmax(0, 1fr) auto; align-items: stretch;
  grid-template-areas: "kido page ref" "kido table table"; row-gap: var(--s4); padding-bottom: var(--s4); cursor: none; }
.mix .side { grid-area: kido; } .mix .cpage { grid-area: page; } .mix .ref { grid-area: ref; align-self: start; } .mix .table { grid-area: table; }
.mix .cpage { height: 100%; max-height: none; width: auto; justify-self: center; }
.mix button, .mix .palette, .mix .area { cursor: none; }
.cpage { background: #fff; border: var(--outline); border-radius: var(--r-md); box-shadow: var(--shadow); overflow: hidden; padding: 0; }
.cpage canvas, .cpage svg, .cpage #lines { position: absolute; inset: 0; width: 100%; height: 100%; }
.cpage #lines { pointer-events: none; }
.mix .cpage { aspect-ratio: 896 / 1200; }
.ref img { width: 100%; height: 100%; object-fit: contain; display: block; }
.cpage svg { overflow: hidden; }
#marks { pointer-events: none; animation: breathe 1.4s ease-in-out infinite; }
.area:focus-visible { outline: none; stroke: var(--grape); stroke-width: 4; }
.area.wob { animation: wob .4s; transform-box: fill-box; transform-origin: center; }
.num.fade { animation: numout 150ms cubic-bezier(.23,1,.32,1) forwards; }
@keyframes numout { to { opacity: 0; } }
.num { pointer-events: none; font-weight: 700; font-family: var(--font); fill: var(--ink); text-anchor: middle; paint-order: stroke; stroke: #fff; stroke-width: 6px; stroke-linejoin: round; }
.cpage.alive { animation: pulse .5s 3; }
.ref { position: relative; z-index: 1; width: clamp(96px, 9vw, 130px); aspect-ratio: 896 / 1200; padding: 6px; background: #fff; border: var(--outline); border-radius: var(--r-sm); box-shadow: var(--shadow); transform: rotate(3deg); }
.ref svg { width: 100%; height: 100%; }
.table { position: relative; z-index: 1; justify-self: center; display: flex; align-items: center; gap: var(--s5); padding: var(--s3) var(--s5);
  background: var(--paper); border: var(--outline); border-radius: var(--r-md); box-shadow: var(--shadow); }
.shelf-jars { display: flex; gap: var(--s2); align-items: flex-end; padding-right: var(--s5); border-right: 3px dashed var(--line); }
.jar { width: clamp(66px, 6.4vw, 90px); display: grid; justify-items: center; gap: 2px; padding: 4px 2px; border-radius: var(--r-sm); transition: transform .15s cubic-bezier(.23,1,.32,1); }
.jar svg { width: 100%; height: auto; aspect-ratio: 120 / 150; overflow: visible; }
.jar text.jn { font: 700 22px var(--font); fill: var(--ink); text-anchor: middle; }
.jar.on { transform: translateY(-8px); }
.jar:active { transform: scale(.97); }
.jar.wob { animation: wob .4s; } .jar.glow { animation: glow 1s infinite; }
.dots { display: flex; gap: 3px; height: 14px; align-items: center; justify-content: center; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--ink); opacity: .55; }
.dots.done svg { width: 18px; height: 18px; }
.palette { position: relative; width: clamp(200px, 20vw, 290px); aspect-ratio: 34 / 22; touch-action: none; border-radius: var(--r-md); }
.palette canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.palette.call { animation: call .9s; } .palette.glow { animation: glow 1s infinite; } .palette.wob { animation: wob .4s; }
.palette:focus-visible { outline: 4px solid var(--grape); outline-offset: 4px; }
#fx { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; pointer-events: none; z-index: var(--z-hint); }
#brush { position: fixed; left: 0; top: 0; width: 108px; height: 108px; pointer-events: none; z-index: var(--z-hint); }
#brush svg { width: 100%; height: 100%; overflow: visible; transform-origin: 17% 83%; transition: transform 140ms cubic-bezier(.23,1,.32,1); }
#brush.dip svg { transform: translate(4px, 8px) rotate(6deg); }
#brush.hide { opacity: 0; }
body.done #brush { opacity: 0; }
@keyframes breathe { 50% { opacity: .35; } }
@media (orientation: portrait) {
  /* phone: the picture on top as big as the height allows, the finished card tucked in its corner, Kido beside the table */
  .field.mix { grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto auto; align-content: start; align-items: center; row-gap: var(--s3);
    grid-template-areas: "page page" "kido table"; padding: var(--s3) var(--s3) var(--s4); }
  .mix .cpage { height: min(54vh, calc((100vw - 24px) * 1200 / 896)); width: auto; max-width: 100%; justify-self: center; }
  .mix .ref { grid-area: page; justify-self: end; align-self: start; width: clamp(64px, 18vw, 96px); margin: var(--s2) var(--s2) 0 0; z-index: 2; }
  .mix .side { width: clamp(56px, 16vw, 80px); } .mix .kido { width: 100%; }
  .table { flex-wrap: wrap; justify-content: center; padding: var(--s2) var(--s3); gap: var(--s2); }
  .shelf-jars { flex-wrap: nowrap; justify-content: center; border-right: 0; padding-right: 0; }
  .jar { width: clamp(46px, 13vw, 64px); } .palette { width: clamp(150px, 46vw, 220px); }
}
}
@media (orientation: landscape) and (max-height: 520px) {
  .ref { width: 96px; } .jar { width: 48px; } .palette { width: 170px; } .table { padding: var(--s1) var(--s3); }
}
@media (hover: none) { .field.mix, .mix button, .mix .palette, .mix .area { cursor: auto; } }
