/* Wonder Chime — playful, big-tap-target styling for very little hands. */

:root {
  --round: 28%;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;              /* it's a single fixed screen, never scrolls */
}

body {
  min-height: 100dvh;
  color: #fff;
  font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background:
    radial-gradient(1200px 820px at 18% -12%, #3a2a6b, transparent 70%),
    radial-gradient(1000px 720px at 108% 8%, #10395f, transparent 70%),
    linear-gradient(160deg, #1b1032, #0e1b34);
  /* kill mobile tap quirks so play feels instant */
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

button { font-family: inherit; }

/* ---------- screens ---------- */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding:
    max(10px, env(safe-area-inset-top))
    max(10px, env(safe-area-inset-right))
    max(10px, env(safe-area-inset-bottom))
    max(10px, env(safe-area-inset-left));
}

.stage {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(16px, 4vh, 40px);
  overflow: hidden;
}

/* ---------- top bar ---------- */
.hud { display: flex; align-items: center; gap: 12px; padding: 4px 6px 10px; }
.hud-spacer { flex: 1; }

.back {
  width: 54px; height: 54px;
  border: none; border-radius: 50%;
  background: rgba(255, 255, 255, 0.14); color: #fff;
  font-size: 36px; line-height: 1; padding: 0 0 6px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.back:active { transform: scale(0.93); }

.stars {
  display: flex; align-items: center; gap: 6px;
  font-weight: 800; font-size: 22px;
  background: rgba(255, 255, 255, 0.14);
  padding: 8px 16px; border-radius: 22px;
}
.stars .star { font-size: 20px; }

/* ---------- home ---------- */
.home { align-items: center; justify-content: center; gap: clamp(28px, 7vh, 64px); }
.logo { text-align: center; }
.title {
  font-weight: 900; line-height: 0.92; letter-spacing: -0.02em;
  font-size: clamp(46px, 14vw, 116px);
  background: linear-gradient(180deg, #ffffff, #ffe1b0);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 8px 34px rgba(0, 0, 0, 0.35);
}
.title span {
  display: block;
  background: linear-gradient(90deg, #ffd23f, #ff6fb5 55%, #43a9ff);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.subtitle {
  margin-top: 0.5em; font-weight: 700; opacity: 0.82;
  font-size: clamp(15px, 3.6vw, 22px);
}

.home-buttons { display: flex; flex-wrap: wrap; gap: clamp(16px, 4vw, 28px); justify-content: center; }
.big-btn {
  display: flex; align-items: center; gap: 0.6em;
  padding: 0.72em 1.15em;
  border: none; border-radius: 28px;
  font-weight: 800; font-size: clamp(21px, 4.6vw, 32px);
  color: #241a00; cursor: pointer;
  background: linear-gradient(180deg, #fff, #ffe6b3);
  box-shadow: 0 10px 0 rgba(0, 0, 0, 0.18), 0 20px 44px rgba(0, 0, 0, 0.42);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.home-buttons .big-btn:nth-child(1) { background: linear-gradient(180deg, #8be9a3, #39c46e); color: #043a1a; }
.home-buttons .big-btn:nth-child(2) { background: linear-gradient(180deg, #ffd98b, #ff8c3f); color: #3a1a04; }
.big-btn:active {
  transform: translateY(6px);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.18), 0 10px 24px rgba(0, 0, 0, 0.42);
}
.bb-icon { font-size: 1.5em; }
.bb-text { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.05; }
.bb-text small { font-size: 0.48em; font-weight: 700; opacity: 0.62; }

.gear {
  position: absolute; right: 16px; bottom: 16px;
  width: 58px; height: 58px; border: none; border-radius: 50%;
  font-size: 26px; cursor: pointer;
  background: rgba(255, 255, 255, 0.14); color: #fff;
}
.gear:active { transform: scale(0.93); }

/* ---------- creature grid ---------- */
/* Sized wrapper the grid measures itself against (100cqh = space it may fill). */
.grid-fit {
  flex: 1; min-height: 0; align-self: stretch;
  container-type: size;
  display: flex; align-items: center; justify-content: center;
}
.grid {
  --gap: clamp(12px, 3vw, 26px);
  --cols: 1;
  --rows: 1;
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  gap: var(--gap);
  /* Cells are square (aspect-ratio), so cap the width three ways: a max cell
     size, the viewport width, and whatever keeps the whole grid — rows of
     square cells plus gaps — inside the wrapper height. */
  width: min(
    calc(280px * var(--cols) + (var(--cols) - 1) * var(--gap)),
    94vw,
    calc((100cqh - (var(--rows) - 1) * var(--gap)) * var(--cols) / var(--rows)
         + (var(--cols) - 1) * var(--gap))
  );
}

.creature {
  position: relative;
  aspect-ratio: 1;
  container-type: inline-size;   /* lets face/label scale with the cell (cqw) */
  border: none; border-radius: var(--round);
  cursor: pointer;
  background: radial-gradient(120% 120% at 30% 22%, var(--c1), var(--c2));
  box-shadow:
    0 10px 0 rgba(0, 0, 0, 0.16),
    0 18px 34px rgba(0, 0, 0, 0.4),
    inset 0 3px 12px rgba(255, 255, 255, 0.55);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  transition: transform 0.08s ease, opacity 0.25s ease, filter 0.25s ease;
}
.creature .face {
  font-size: clamp(20px, 46cqw, 96px); line-height: 1;
  filter: drop-shadow(0 3px 2px rgba(0, 0, 0, 0.22));
}
.creature .label {
  margin-top: 0.28em; font-weight: 800;
  font-size: clamp(9px, 11cqw, 21px);
  color: rgba(0, 0, 0, 0.55); text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
}
.creature:active { transform: translateY(4px) scale(0.98); }

.creature.pop   { animation: pop 0.45s cubic-bezier(0.2, 1.4, 0.4, 1); }
.creature.dance { animation: dance 0.6s ease infinite; }
.creature.shake { animation: shake 0.4s ease; }
.creature.dim   { opacity: 0.34; filter: grayscale(0.35); }
.creature.hint::after {
  content: ""; position: absolute; inset: -6%;
  border-radius: calc(var(--round) + 4%);
  box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.85);
  animation: hintpulse 1s ease infinite;
}

@keyframes pop {
  0% { transform: scale(1); }
  30% { transform: scale(1.12) rotate(-3deg); }
  60% { transform: scale(0.97) rotate(2deg); }
  100% { transform: scale(1); }
}
@keyframes dance {
  0%, 100% { transform: translateY(0) rotate(-5deg); }
  50% { transform: translateY(-14px) rotate(5deg); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}
@keyframes hintpulse {
  0%, 100% { opacity: 0.25; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.03); }
}

/* ---------- challenge ---------- */
.quiz-stage { justify-content: space-between; padding: clamp(8px, 3vh, 26px) 0; }
.singer-wrap { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.singer {
  width: clamp(120px, 30vw, 200px); aspect-ratio: 1;
  border: none; border-radius: 50%; cursor: pointer;
  background: radial-gradient(130% 130% at 30% 25%, #fff, #cfe3ff 55%, #8bb4ff);
  box-shadow:
    0 12px 0 rgba(0, 0, 0, 0.14),
    0 22px 50px rgba(0, 0, 0, 0.42),
    inset 0 4px 14px rgba(255, 255, 255, 0.7);
  display: flex; align-items: center; justify-content: center;
}
.singer-face { font-size: clamp(48px, 14vw, 96px); }
.singer:active { transform: translateY(4px) scale(0.99); }
.singer.ring { animation: ring 0.6s ease; }
@keyframes ring {
  0%   { box-shadow: 0 12px 0 rgba(0,0,0,0.14), 0 0 0 0 rgba(255,255,255,0.7), inset 0 4px 14px rgba(255,255,255,0.7); }
  100% { box-shadow: 0 12px 0 rgba(0,0,0,0.14), 0 0 0 42px rgba(255,255,255,0), inset 0 4px 14px rgba(255,255,255,0.7); }
}
.cue { font-weight: 800; font-size: clamp(18px, 4vw, 26px); opacity: 0.9; }
/* .answers is a JS hook only (see clearAnswerFx); sizing comes from .grid-fit/.grid. */

/* ---------- settings ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(6, 8, 20, 0.6); backdrop-filter: blur(6px);
}
.card {
  width: min(460px, 94vw); max-height: 90dvh; overflow: auto;
  background: #20183a; border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 24px; padding: 22px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}
.card h2 { margin: 0 0 6px; font-size: 26px; }
.hint-text { margin: 0 0 18px; opacity: 0.75; font-size: 15px; line-height: 1.45; }
.step-label { font-weight: 800; margin-bottom: 10px; text-align: center; }
.stepper { display: flex; align-items: center; justify-content: center; gap: 20px; margin-bottom: 20px; }
.step {
  width: 66px; height: 66px; border: none; border-radius: 20px;
  font-size: 34px; font-weight: 800; cursor: pointer;
  background: rgba(255, 255, 255, 0.14); color: #fff;
}
.step:disabled { opacity: 0.3; }
.step-val { font-size: 42px; font-weight: 900; min-width: 60px; text-align: center; }
.legend { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.legend-row {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255, 255, 255, 0.06); padding: 8px 12px; border-radius: 14px;
}
.legend-row b { font-weight: 800; }
.legend-row small { opacity: 0.7; }
.legend-row .dot { width: 16px; height: 16px; border-radius: 50%; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.2); }
.legend-row .lg-emoji { font-size: 22px; }
.legend-row .hear {
  margin-left: auto; width: 42px; height: 42px; border: none; border-radius: 50%;
  font-size: 15px; cursor: pointer; background: rgba(255, 255, 255, 0.14); color: #fff;
}
.done {
  width: 100%; padding: 16px; border: none; border-radius: 18px;
  font-weight: 800; font-size: 20px; cursor: pointer;
  background: linear-gradient(180deg, #8be9a3, #39c46e); color: #043a1a;
}

/* ---------- confetti ---------- */
.confetti-piece {
  position: fixed; width: 14px; height: 14px; border-radius: 3px;
  pointer-events: none; z-index: 50; will-change: transform, opacity;
  transition: transform 1.1s cubic-bezier(0.15, 0.6, 0.4, 1), opacity 1.1s ease;
}

/* Respect users who ask for less motion. */
@media (prefers-reduced-motion: reduce) {
  .creature.dance { animation: none; }
  .confetti-piece { display: none; }
}
