:root {
  --cream: #fff8ee;
  --paper: #fffdf8;
  --ink: #2a2650;
  --ink-soft: #5b567c;
  --coral: #ff6b57;
  --sky: #4ba3ff;
  --gold: #ffc857;
  --mint: #3ecca6;
  --line: rgba(42, 38, 80, 0.1);
  --shadow: 0 12px 30px rgba(42, 38, 80, 0.1);
  --accent: #ff6b57;
  --safe-top: env(safe-area-inset-top);
  --safe-bottom: env(safe-area-inset-bottom);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 12% -10%, #ffe7c7 0, transparent 42%),
    radial-gradient(circle at 110% 8%, #d7ecff 0, transparent 36%),
    var(--cream);
  color: var(--ink);
  font-family: Nunito, "Avenir Next", "Segoe UI", sans-serif;
  font-size: 20px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}

body {
  padding: calc(16px + var(--safe-top)) 16px calc(24px + var(--safe-bottom));
}

button,
input {
  font: inherit;
}

button {
  touch-action: manipulation;
  cursor: pointer;
}

h1,
h2 {
  font-family: Fredoka, Nunito, sans-serif;
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin: 0 0 0.4em;
}

h1 {
  font-size: clamp(2rem, 6vw, 3rem);
}

h2 {
  font-size: 1.6rem;
}

p {
  margin: 0 0 0.7em;
}

#app {
  width: min(760px, 100%);
  margin: 0 auto;
}

#app:has(.playground) {
  width: min(1100px, 100%);
}

.page {
  animation: rise 0.35s ease;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.eyebrow,
.kicker,
.mini-label,
.topbar-title,
.step-dots,
.star-count {
  font-family: Fredoka, Nunito, sans-serif;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.78rem;
  color: var(--ink-soft);
}

.lede,
.spark-line,
.why,
.grownups p {
  color: var(--ink);
}

.lede {
  font-size: 1.05rem;
}

.hero,
.card,
.diploma-card {
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: 28px 32px 26px 34px;
  box-shadow: var(--shadow);
  padding: 22px 20px 24px;
}

.hero {
  text-align: center;
  margin-bottom: 18px;
}

.star-count {
  display: inline-block;
  background: #fff3cc;
  color: #8a5a00;
  padding: 0.35em 0.8em;
  border-radius: 999px;
}

.spark {
  width: 108px;
  height: 108px;
  margin: 0 auto 8px;
  animation: bob 2.8s ease-in-out infinite;
}

.spark-wow {
  animation: pop 0.7s ease;
}

.spark-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.spark-body {
  fill: #fff8ee;
  stroke: var(--ink);
  stroke-width: 4;
}

.spark-eye {
  fill: var(--ink);
}

.spark-smile {
  fill: none;
  stroke: var(--ink);
  stroke-width: 4;
  stroke-linecap: round;
}

.spark-star {
  fill: var(--gold);
  stroke: var(--ink);
  stroke-width: 3;
}

@keyframes bob {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-6px);
  }
}

@keyframes pop {
  0% {
    transform: scale(0.86);
  }
  70% {
    transform: scale(1.08);
  }
  100% {
    transform: scale(1);
  }
}

.trail {
  display: grid;
  gap: 12px;
}

.trail-card {
  display: flex;
  gap: 14px;
  align-items: center;
  width: 100%;
  text-align: left;
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: 22px;
  padding: 14px 16px;
  box-shadow: 0 8px 0 rgba(42, 38, 80, 0.06);
  color: inherit;
}

.trail-card:active:not(.is-locked) {
  transform: translateY(2px);
  box-shadow: 0 4px 0 rgba(42, 38, 80, 0.06);
}

.trail-badge {
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-family: Fredoka, Nunito, sans-serif;
  font-size: 1.3rem;
}

.trail-card.is-done .trail-badge {
  background: var(--gold);
  color: var(--ink);
}

.trail-card.is-locked {
  opacity: 0.55;
}

.trail-copy {
  display: grid;
  gap: 2px;
}

.trail-copy em {
  font-style: normal;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.home-actions,
.row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.home-actions {
  justify-content: center;
  margin: 8px 0 0;
}

.btn {
  border: 0;
  border-radius: 999px;
  padding: 0.85em 1.2em;
  min-height: 52px;
  background: #efeaf8;
  color: var(--ink);
}

.btn-primary {
  background: var(--ink);
  color: #fff8ee;
}

.btn-gold {
  background: var(--gold);
}

.btn-speak {
  background: #e8f4ff;
}

.btn-quiet,
.btn-ghost {
  background: transparent;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.btn:disabled {
  opacity: 0.55;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.topbar-title {
  margin: 0;
}

.step-dots {
  margin: 0 0 10px 4px;
}

.talk-card,
.gate,
.diploma {
  text-align: center;
}

.prompt,
.question {
  font-family: Fredoka, Nunito, sans-serif;
  font-size: 1.25rem;
  margin-bottom: 12px;
}

.item-card {
  display: grid;
  place-items: center;
  gap: 6px;
  min-height: 120px;
  margin: 12px 0 16px;
  background: #fff3e4;
  border-radius: 24px;
  border: 2px dashed rgba(42, 38, 80, 0.16);
  font-size: 1.2rem;
}

.item-icon {
  font-size: 2.2rem;
}

.bins,
.choices {
  display: grid;
  gap: 10px;
}

.bins {
  grid-template-columns: 1fr 1fr;
}

.bins-3 {
  grid-template-columns: 1fr;
}

.bin,
.choice,
.chip {
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 18px;
  padding: 14px 12px;
  color: inherit;
}

.bin {
  min-height: 88px;
}

.bin span,
.status,
.why {
  display: block;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.choice.is-good,
.chip.is-on {
  background: #e8fff5;
  border-color: var(--mint);
}

.choice.is-bad {
  background: #ffe8e4;
  border-color: var(--coral);
}

.choice-emoji {
  font-size: 1.8rem;
}

.pattern {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 8px 0 16px;
}

.pat {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  background: #fff3e4;
  border-radius: 16px;
  font-size: 1.5rem;
}

.pat.mystery {
  background: var(--ink);
  color: var(--gold);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
}

.chip {
  min-height: 48px;
  padding: 0.55em 0.9em;
}

.ask-line {
  background: #fff3cc;
  border-radius: 16px;
  padding: 12px 14px;
  font-weight: 700;
}

.story-row {
  margin-bottom: 8px;
}

.recap-card,
.diploma-card {
  text-align: center;
  position: relative;
  overflow: hidden;
}

.star-big {
  font-size: 3rem;
  margin: 0;
  color: var(--gold);
}

.confetti {
  position: absolute;
  top: 20px;
  animation: fall 1.2s ease-out forwards;
  pointer-events: none;
  font-size: 1.1rem;
}

@keyframes fall {
  to {
    transform: translateY(160px) rotate(40deg);
    opacity: 0;
  }
}

.ask-area {
  min-height: 64px;
  resize: none;
  line-height: 1.35;
}

.btn-tiny {
  min-height: 40px;
  padding: 0.35em 0.8em;
  font-size: 0.85rem;
  margin-top: 8px;
}

.setup-form {
  margin: 12px 0 28px;
}

.banner {
  font-size: 1.05rem;
  font-weight: 800;
  padding: 14px 16px;
  border-radius: 18px;
  margin: 0 0 16px;
}

.banner-wait {
  background: #fff3cc;
  color: #8a5a00;
}

.banner-ok {
  background: #e8fff5;
  color: #0d6b4c;
}

.banner-bad {
  background: #ffe8e4;
  color: #9b1d1d;
}

.page.playground {
  display: flex;
  flex-direction: column;
  min-height: calc(100dvh - 32px);
}

.page.playground .chat {
  flex: 1 1 auto;
  min-height: 58vh;
  max-height: none;
}

.page.playground .starters {
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
}

.page.playground .starters .chip {
  flex: 0 0 auto;
}

.chat {
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: 24px;
  min-height: 240px;
  overflow: auto;
  padding: 16px;
  display: grid;
  gap: 16px;
  margin-bottom: 12px;
}

.bubble {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  align-items: start;
  width: 100%;
}

.bubble .spark {
  width: 44px;
  height: 44px;
  margin: 0;
}

.bubble.from-kid {
  justify-items: end;
}

.bubble.from-kid .bubble-body {
  background: #fff3cc;
  max-width: min(28rem, 80%);
}

.bubble.from-spark .bubble-body {
  width: 100%;
  max-width: none;
}

.bubble-body {
  min-width: 0;
  background: #eef6ff;
  border-radius: 22px;
  padding: 18px 22px 16px;
}

.bubble-body p {
  margin: 0 0 0.9em;
  padding: 0;
  background: none;
  color: #1a1638;
  font-size: 1.28rem;
  font-weight: 750;
  line-height: 1.55;
}

.bubble-body p:last-of-type {
  margin-bottom: 0;
}

.ask-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 10px;
}

.ask-input {
  width: 100%;
  min-height: 52px;
  border-radius: 16px;
  border: 2px solid var(--line);
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
  font-size: 16px;
}

.grownups a {
  color: var(--sky);
  font-weight: 800;
}

.grownup-list {
  padding-left: 1.1em;
}

.grownup-list li {
  margin-bottom: 0.7em;
}

.gate .ask-form {
  margin-top: 16px;
}

.pin-gate {
  text-align: center;
}

.pin-dots {
  font-size: 2rem;
  letter-spacing: 0.25em;
  margin: 8px 0 18px;
}

.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, minmax(72px, 1fr));
  gap: 12px;
  max-width: 320px;
  margin: 0 auto;
}

.pin-key {
  min-height: 72px;
  border-radius: 20px;
  font-size: 1.6rem;
  font-weight: 800;
}

@media (min-width: 740px) {
  .bins-3 {
    grid-template-columns: 1fr 1fr 1fr;
  }

  .choices {
    grid-template-columns: 1fr 1fr;
  }

  .home-actions {
    margin-top: 22px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .spark,
  .page,
  .confetti {
    animation: none;
  }
}
