/* Animister Simple. Palette, type and motion come from the core tokens (/core/css/tokens.css): paper canvas, one coral
   action accent with ink labels, 60 px child targets, nothing active in the bottom 24 px. */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--paper); color: var(--ink); font: 700 var(--body)/1.3 var(--font);
  -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; overscroll-behavior: none;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
button:focus-visible, input:focus-visible { outline: 4px solid var(--cobalt); outline-offset: 3px; }
.ico { width: 28px; height: 28px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.screen {
  min-height: 100dvh; display: flex; flex-direction: column; align-items: center; gap: 22px;
  padding: calc(28px + env(safe-area-inset-top)) var(--gutter) var(--edge);
}
.say { margin: 0; font-size: clamp(1.7rem, 6vw, 2.4rem); font-weight: 800; line-height: 1.15; text-align: center; text-wrap: balance; }
.note { margin: 0; max-width: 30rem; color: var(--muted); font-size: var(--muted-size); font-weight: 600; text-align: center; }
.muted { color: var(--muted); }
.row { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--tap-gap); }

.btn {
  min-height: var(--tap); padding: 0 26px; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  border: 2px solid var(--line); border-radius: 999px; background: var(--card); box-shadow: var(--shadow);
  font-weight: 800; transition: transform var(--t-micro) var(--spring);
}
.btn.primary { background: var(--coral); border-color: var(--coral-deep); box-shadow: var(--press), var(--shadow); }
.btn:active:not(:disabled) { transform: translateY(2px) scale(.97); }
.btn:disabled { opacity: .45; box-shadow: none; cursor: default; }
.btn.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: var(--press), 0 0 0 10px color-mix(in srgb, var(--coral) 24%, transparent); } }

/* ---- home ---- */
#home { justify-content: center; }
.cam {
  width: min(62vw, 250px); aspect-ratio: 1; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  border: 3px solid var(--coral-deep); background: var(--coral); box-shadow: var(--press), var(--shadow-lift);
  font-size: 1.35rem; font-weight: 800; transition: transform var(--t-micro) var(--spring);
}
.cam .ico { width: 42%; height: auto; aspect-ratio: 1; stroke-width: 1.6; }
.cam:active:not(:disabled) { transform: scale(.95); }
.cam:disabled { opacity: .45; }
.shelf-wrap { width: 100%; max-width: 720px; }
.shelf-title { margin: 6px 0 10px; font-size: var(--label); font-weight: 800; color: var(--muted); text-align: center; }
.shelf { display: flex; gap: var(--tap-gap); padding: 6px var(--gutter) 12px; margin: 0 calc(-1 * var(--gutter)); overflow-x: auto; scroll-snap-type: x proximity; justify-content: safe center; }
.toy {
  flex: none; width: 104px; height: 104px; padding: 10px; border: 2px solid var(--hair); border-radius: var(--tile); background: var(--card);
  box-shadow: var(--shadow); scroll-snap-align: center;
}
.toy img { width: 100%; height: 100%; object-fit: contain; display: block; }
.toy:active { transform: scale(.95); }

/* ---- choose ---- */
#choose { justify-content: space-between; }
.photo-wrap { flex: 1; min-height: 0; width: 100%; display: flex; align-items: center; justify-content: center; }
.photo-wrap canvas {
  max-width: 100%; max-height: calc(100dvh - 300px); border-radius: var(--radius); box-shadow: var(--shadow-lift);
  background: var(--sand); touch-action: manipulation; cursor: pointer;
}
.photo-wrap.working canvas { opacity: .7; }
.photo-wrap.nope canvas { animation: nope .4s; }
@keyframes nope { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }

/* ---- wait ---- */
#wait { justify-content: center; }
.wait-on, .wait-fail { display: flex; flex-direction: column; align-items: center; gap: 22px; }
.ring { position: relative; width: min(70vw, 280px); aspect-ratio: 1; display: grid; place-items: center; }
.ring svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 7; stroke-linecap: round; }
.ring-bg { stroke: var(--sand); }
.ring-bar { stroke: var(--coral); stroke-dasharray: 339.292; stroke-dashoffset: 339.292; transition: stroke-dashoffset 3.5s linear; }
/* Before the first progress: a short arc going round. */
.queued .ring-bar { stroke-dashoffset: 290 !important; transition: none; transform-origin: 60px 60px; animation: round 1.6s linear infinite; }
@keyframes round { to { transform: rotate(360deg); } }
.ring img { width: 62%; height: 62%; object-fit: contain; filter: drop-shadow(0 10px 14px rgba(93, 63, 26, .22)); }
.bob { animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-10px) rotate(3deg); } }
.spark { position: absolute; width: 14px; height: 14px; border-radius: 50%; background: var(--butter); animation: spark 2.2s ease-in-out infinite; }
.spark.s1 { top: 14%; left: 20%; }
.spark.s2 { top: 24%; right: 14%; width: 10px; height: 10px; background: var(--signal); animation-delay: .7s; }
.spark.s3 { bottom: 18%; left: 12%; width: 9px; height: 9px; background: var(--coral); animation-delay: 1.3s; }
@keyframes spark { 0%, 100% { transform: scale(.3); opacity: 0; } 50% { transform: scale(1); opacity: 1; } }

/* ---- play ---- */
#play { padding: 0; gap: 0; height: 100dvh; }
.stage {
  position: relative; flex: 1; min-height: 0; width: 100%; overflow: hidden;
  background: radial-gradient(circle at 50% 42%, #FFF6DC 0, var(--paper) 62%);
}
.stage .gl { display: block; position: absolute; inset: 0; touch-action: none; }
.round {
  position: absolute; top: calc(14px + env(safe-area-inset-top)); width: var(--tap); height: var(--tap); border-radius: 50%; display: grid; place-items: center;
  border: 2px solid var(--line); background: var(--overlay-bg); box-shadow: var(--shadow);
}
.round.back { left: 14px; }
.round.trash { right: 14px; width: 48px; height: 48px; color: var(--muted); }
.round:active { transform: scale(.94); }
.moves {
  flex: none; width: 100%; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px 4px; justify-items: center;
  padding: 12px 10px var(--edge); background: var(--card); border-top: 2px solid var(--hair);
}
.move { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 0; border: 0; background: none; min-width: var(--tap); }
.move-ico {
  width: var(--tap); height: var(--tap); border-radius: 50%; display: grid; place-items: center;
  border: 2px solid var(--line); background: var(--paper); transition: transform var(--t-micro) var(--spring), background var(--t-micro);
}
.move-ico .ico { width: 30px; height: 30px; }
.move-name { font-size: .875rem; font-weight: 800; }
.move:active .move-ico { transform: scale(.92); }
.move[aria-pressed="true"] .move-ico { background: var(--coral); border-color: var(--coral-deep); box-shadow: var(--press), 0 0 0 4px color-mix(in srgb, var(--coral) 28%, transparent); transform: scale(1.06); }
@media (min-width: 760px) {
  .moves { grid-template-columns: repeat(10, minmax(0, 88px)); justify-content: center; }
}
.zzz { position: absolute; left: 58%; top: 34%; display: none; font-size: 2rem; font-weight: 800; color: var(--cobalt); pointer-events: none; }
.stage[data-move="sleep"] .zzz { display: block; }
.zzz span { position: absolute; opacity: 0; animation: zzz 3s ease-out infinite; }
.zzz span:nth-child(2) { animation-delay: 1s; }
.zzz span:nth-child(3) { animation-delay: 2s; }
@keyframes zzz { 0% { transform: translate(0, 0) scale(.5); opacity: 0; } 25% { opacity: 1; } 100% { transform: translate(34px, -90px) scale(1.3); opacity: 0; } }

/* ---- sheets (for a grown-up: plainer type) ---- */
.sheet {
  width: min(460px, calc(100vw - 28px)); max-height: calc(100dvh - 28px); padding: 22px; border: 0; border-radius: 28px;
  background: var(--card); color: var(--ink); box-shadow: var(--shadow-lift); font-size: var(--label); font-weight: 600;
}
.sheet::backdrop { background: rgba(24, 22, 18, .55); }
.sheet form { display: flex; flex-direction: column; gap: 12px; }
.sheet h2 { margin: 0; display: flex; align-items: center; gap: 10px; font-size: 1.3rem; font-weight: 800; }
.sheet p { margin: 0; }
.checker {
  display: grid; place-items: center; padding: 10px; border-radius: var(--tile); border: 2px solid var(--hair);
  background: repeating-conic-gradient(#EDE3D2 0% 25%, #FFFBF3 0% 50%) 50% / 24px 24px;
}
.checker img { max-width: 100%; max-height: 30dvh; object-fit: contain; display: block; }
.gate-q { font-weight: 800; }
.gate-row input {
  width: 100%; min-height: var(--tap); padding: 0 18px; border: 2px solid var(--line); border-radius: 18px; background: #fff;
  font: inherit; font-size: 1.4rem; font-weight: 800; letter-spacing: .12em; text-align: center; color: var(--ink);
}
.sheet .row { margin-top: 4px; }
.sheet .btn { padding: 0 20px; font-size: var(--label); }

/* ---- busy and toast ---- */
.busy { position: fixed; inset: 0; z-index: var(--z-sheet); display: grid; place-items: center; background: rgba(247, 241, 231, .7); }
.spin { width: 64px; height: 64px; border-radius: 50%; border: 7px solid var(--sand); border-top-color: var(--coral); animation: round 0.9s linear infinite; }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--edge) + 12px); z-index: var(--z-toast); transform: translateX(-50%);
  max-width: calc(100vw - 32px); padding: 14px 22px; border-radius: 22px; background: var(--night); color: #fff;
  font-size: var(--label); font-weight: 700; text-align: center; box-shadow: var(--shadow-lift);
}

@media (prefers-reduced-motion: reduce) {
  .bob, .spark, .btn.pulse, .zzz span { animation: none; }
  .zzz span { opacity: 1; position: static; }
}
