/* ============================================================
   Plato's Playground — shared design system
   Toddler-first: huge targets, soft shapes, instant feedback.
   No external fonts, no external anything. Everything self-hosted.
   ============================================================ */

:root {
  --sky-hi: #8fd0f8;
  --sky-lo: #d6efff;
  --sun: #ffd93d;
  --grass: #7ed957;
  --grass-deep: #58c15a;
  --coral: #ff7b54;
  --berry: #b980f0;
  --bubble: #4fb6f5;
  --cream: #fff7e6;
  --ink: #2b3a67;
  --ink-soft: rgba(43, 58, 103, 0.55);
  --white: #ffffff;
  --card-shadow: 0 10px 24px rgba(43, 58, 103, 0.16);
  --card-shadow-press: 0 4px 10px rgba(43, 58, 103, 0.22);
  --radius-big: 28px;
  --radius-huge: 40px;
  --font-round: ui-rounded, "Hiragino Maru Gothic ProN", "Varela Round",
    Quicksand, Comfortaa, "Comic Sans MS", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-round);
  color: var(--ink);
  background: linear-gradient(180deg, var(--sky-hi) 0%, var(--sky-lo) 70%, var(--cream) 100%);
  min-height: 100%;
  overscroll-behavior: none;
}

body.kid-game {
  position: fixed;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

/* ---------- chunky round buttons (game chrome) ---------- */
.kid-chrome-btn {
  position: fixed;
  z-index: 60;
  width: 64px;
  height: 64px;
  border: none;
  border-radius: 50%;
  background: var(--white);
  box-shadow: var(--card-shadow);
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
  transition: transform 0.12s ease;
  touch-action: manipulation;
}
.kid-chrome-btn:active { transform: scale(0.88); box-shadow: var(--card-shadow-press); }
.kid-chrome-btn svg { width: 36px; height: 36px; display: block; }
.kid-btn-home { top: max(12px, env(safe-area-inset-top)); left: max(12px, env(safe-area-inset-left)); }
.kid-btn-sound { top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); }
.kid-btn-sound.is-off svg .kid-sound-waves { display: none; }
.kid-btn-sound.is-off svg .kid-sound-slash { display: block; }
.kid-btn-sound svg .kid-sound-slash { display: none; }

/* ---------- star counter chip ---------- */
.kid-star-chip {
  position: fixed;
  z-index: 60;
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  background: var(--white);
  border-radius: 999px;
  box-shadow: var(--card-shadow);
  padding: 8px 18px 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 26px;
  font-weight: 800;
  color: var(--ink);
  pointer-events: none;
}
.kid-star-chip svg { width: 32px; height: 32px; }
.kid-star-chip.kid-bump { animation: kid-chip-bump 0.4s ease; }
@keyframes kid-chip-bump {
  0% { transform: translateX(-50%) scale(1); }
  40% { transform: translateX(-50%) scale(1.25); }
  100% { transform: translateX(-50%) scale(1); }
}

/* ---------- flying star ---------- */
.kid-fly-star {
  position: fixed;
  z-index: 70;
  width: 48px;
  height: 48px;
  pointer-events: none;
  will-change: transform, opacity;
}

/* ---------- celebration overlay canvas ---------- */
.kid-fx-canvas {
  position: fixed;
  inset: 0;
  z-index: 55;
  pointer-events: none;
}

/* ---------- big friendly cards (hub) ---------- */
.kid-card {
  display: block;
  border: none;
  text-decoration: none;
  background: var(--white);
  border-radius: var(--radius-big);
  box-shadow: var(--card-shadow);
  padding: 14px 14px 18px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  text-align: center;
  color: var(--ink);
  font-family: var(--font-round);
}
.kid-card:active { transform: scale(0.94); box-shadow: var(--card-shadow-press); }
@media (hover: hover) {
  .kid-card:hover { transform: translateY(-4px) rotate(-1deg); }
}
.kid-card .kid-card-art {
  width: 100%;
  aspect-ratio: 5 / 4;
  border-radius: 20px;
  overflow: hidden;
  display: block;
}
.kid-card .kid-card-art svg { width: 100%; height: 100%; display: block; }
.kid-card .kid-card-name {
  margin-top: 10px;
  font-size: clamp(18px, 2.6vw, 24px);
  font-weight: 800;
  letter-spacing: 0.02em;
}
.kid-card .kid-card-stars {
  margin-top: 4px;
  font-size: 18px;
  min-height: 22px;
  letter-spacing: 2px;
}

/* gentle idle wiggle, staggered per-card via --wiggle-delay */
@keyframes kid-wiggle {
  0%, 92%, 100% { transform: rotate(0deg); }
  94% { transform: rotate(-2deg); }
  96% { transform: rotate(2deg); }
  98% { transform: rotate(-1deg); }
}
.kid-card { animation: kid-wiggle 7s ease-in-out infinite; animation-delay: var(--wiggle-delay, 0s); }

/* ---------- parent gate overlay ---------- */
.kid-gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(43, 58, 103, 0.55);
  display: grid;
  place-items: center;
  backdrop-filter: blur(3px);
}
.kid-gate-box {
  background: var(--white);
  border-radius: var(--radius-big);
  box-shadow: var(--card-shadow);
  padding: 28px 26px;
  width: min(360px, 86vw);
  text-align: center;
}
.kid-gate-box h2 { margin: 0 0 6px; font-size: 24px; }
.kid-gate-box p { margin: 0 0 18px; color: var(--ink-soft); font-size: 16px; line-height: 1.4; }
.kid-gate-hold {
  position: relative;
  width: 120px;
  height: 120px;
  margin: 0 auto 14px;
  border: none;
  border-radius: 50%;
  background: var(--bubble);
  color: var(--white);
  font-size: 17px;
  font-weight: 800;
  font-family: var(--font-round);
  cursor: pointer;
  display: grid;
  place-items: center;
  touch-action: none;
}
.kid-gate-hold svg.kid-gate-ring {
  position: absolute;
  inset: -8px;
  width: 136px;
  height: 136px;
  transform: rotate(-90deg);
}
.kid-gate-hold .kid-gate-ring circle {
  fill: none;
  stroke: var(--sun);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 402;
  stroke-dashoffset: 402;
}
.kid-gate-cancel {
  border: none;
  background: none;
  color: var(--ink-soft);
  font-size: 16px;
  font-family: var(--font-round);
  cursor: pointer;
  padding: 8px 16px;
}

/* ---------- sticker book ---------- */
.pp-book {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: linear-gradient(180deg, rgba(143, 208, 248, 0.97), rgba(255, 247, 230, 0.97));
  overflow-y: auto;
  padding: 0 16px 40px;
}
.pp-book-head {
  position: sticky;
  top: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 4px 10px;
  z-index: 2;
}
.pp-book-title {
  background: var(--white);
  border-radius: 999px;
  box-shadow: var(--card-shadow);
  padding: 10px 22px;
  font-size: 24px;
  font-weight: 900;
  color: var(--ink);
}
.pp-book-close {
  width: 56px;
  height: 56px;
  border: none;
  border-radius: 50%;
  background: var(--white);
  box-shadow: var(--card-shadow);
  font-size: 24px;
  font-weight: 900;
  color: var(--ink-soft);
  cursor: pointer;
}
.pp-book-close:active { transform: scale(0.9); }
.pp-book-grid {
  max-width: 860px;
  margin: 8px auto 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 14px;
}
.pp-sticker {
  position: relative;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  aspect-ratio: 1;
  filter: drop-shadow(0 6px 10px rgba(43, 58, 103, 0.2));
  transition: transform 0.15s ease;
}
.pp-sticker svg { width: 100%; height: 100%; }
.pp-sticker.is-earned:active { transform: scale(0.9); }
.pp-sticker.is-locked { filter: grayscale(1) opacity(0.55); }
.pp-sticker .pp-price {
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--white);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 13px;
  font-weight: 800;
  color: var(--ink-soft);
  font-family: var(--font-round);
}
.pp-sticker.pp-pop { animation: pp-sticker-pop 0.5s ease; }
@keyframes pp-sticker-pop {
  0% { transform: scale(1) rotate(0); }
  35% { transform: scale(1.25) rotate(-6deg); }
  70% { transform: scale(0.95) rotate(4deg); }
  100% { transform: scale(1) rotate(0); }
}
.pp-sticker.is-new { animation: pp-sticker-arrive 0.9s cubic-bezier(.2,1.4,.4,1) backwards; }
@keyframes pp-sticker-arrive {
  0% { transform: scale(3.2) rotate(-16deg); opacity: 0; }
  60% { transform: scale(0.92) rotate(3deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); }
}

/* hub cards pop in on load */
.kid-card { animation: kid-card-in 0.5s cubic-bezier(.2,1.3,.4,1) backwards, kid-wiggle 7s ease-in-out 2s infinite; }
.kid-card:nth-child(1) { animation-delay: 0.05s, 2s; } .kid-card:nth-child(2) { animation-delay: 0.1s, 2.9s; }
.kid-card:nth-child(3) { animation-delay: 0.15s, 3.7s; } .kid-card:nth-child(4) { animation-delay: 0.2s, 2.4s; }
.kid-card:nth-child(5) { animation-delay: 0.25s, 3.2s; } .kid-card:nth-child(6) { animation-delay: 0.3s, 4.1s; }
.kid-card:nth-child(7) { animation-delay: 0.35s, 2.6s; } .kid-card:nth-child(8) { animation-delay: 0.4s, 3.5s; }
.kid-card:nth-child(9) { animation-delay: 0.45s, 2.2s; } .kid-card:nth-child(10) { animation-delay: 0.5s, 3.9s; }
.kid-card:nth-child(11) { animation-delay: 0.55s, 2.7s; } .kid-card:nth-child(12) { animation-delay: 0.6s, 3.3s; }
@keyframes kid-card-in {
  from { transform: scale(0.6) translateY(24px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

/* ---------- utility ---------- */
.kid-hidden { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  .kid-card { animation: none; }
  .kid-chrome-btn, .kid-card { transition: none; }
}
