/* ============================================================
   Silly Stories — mad libs for kids.
   Same house rules as the other kid-games: big targets, loud
   colours, and something wiggling at all times.
   ============================================================ */

:root {
  --grape: #6c3fd1;
  --grape-dark: #4a239c;
  --bubblegum: #ff5fa2;
  --sunshine: #ffc93c;
  --mint: #35d6a4;
  --sky-blue: #46bdf5;
  --tangerine: #ff8c42;
  --ink: #2c1b57;
  --paper: #fffdf7;

  --radius: 20px;
  --shadow-pop: 0 6px 0 rgba(0, 0, 0, 0.16);

  --font: "Baloo 2", "Comic Sans MS", "Chalkboard SE", "Comic Neue",
    "Trebuchet MS", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(170deg, #ffe6c7 0%, #ffd6ec 45%, #d6e8ff 100%);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- drifting background shapes ---------- */
.sky {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 12% 20%, rgba(255, 255, 255, 0.7) 0 42px, transparent 43px),
    radial-gradient(circle at 84% 30%, rgba(255, 255, 255, 0.55) 0 32px, transparent 33px),
    radial-gradient(circle at 68% 78%, rgba(255, 255, 255, 0.5) 0 52px, transparent 53px),
    radial-gradient(circle at 26% 88%, rgba(255, 255, 255, 0.45) 0 26px, transparent 27px);
  animation: drift 26s ease-in-out infinite alternate;
}
@keyframes drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(-28px, 22px, 0) scale(1.07); }
}

/* ---------- screens ---------- */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  padding: clamp(8px, 2vh, 20px);
  overflow: auto;
}
.screen.is-active { display: flex; }

.top { position: relative; flex: 0 0 auto; }

/* ---------- logo ---------- */
.logo {
  margin: clamp(6px, 3vh, 26px) 0 0;
  text-align: center;
  font-size: clamp(2.1rem, 8vw, 4.4rem);
  line-height: 1.05;
  letter-spacing: 2px;
}
.logo__word { display: block; }
.logo__letter {
  display: inline-block;
  color: var(--paper);
  text-shadow: 0 3px 0 var(--tangerine), 0 7px 12px rgba(0, 0, 0, 0.22);
  animation: letterHop 2.4s ease-in-out infinite;
  animation-delay: calc(var(--i) * 0.09s);
}
.logo__word--alt .logo__letter {
  color: var(--sunshine);
  text-shadow: 0 3px 0 var(--grape), 0 7px 12px rgba(0, 0, 0, 0.22);
}
@keyframes letterHop {
  0%, 62%, 100% { transform: translateY(0) rotate(0deg); }
  72%           { transform: translateY(-16px) rotate(-6deg); }
  84%           { transform: translateY(0) rotate(3deg); }
}

.tagline {
  text-align: center;
  font-size: clamp(1rem, 3vw, 1.35rem);
  color: var(--grape-dark);
  margin: 10px 0 clamp(10px, 3vh, 22px);
}
.tagline--small { font-size: clamp(0.9rem, 2.4vw, 1.1rem); margin: 4px 0 14px; }

/* ---------- theme / story cards ---------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
  width: min(980px, 100%);
  margin: 0 auto clamp(10px, 4vh, 40px);
}

.pick-card {
  position: relative;
  border: 0;
  font: inherit;
  cursor: pointer;
  text-align: left;
  padding: 18px 18px 16px;
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow-pop);
  transition: transform 0.14s ease;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.pick-card:hover { transform: translateY(-4px) rotate(-1deg); }
.pick-card:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.16); }
.pick-card__emoji {
  font-size: 2.4rem;
  line-height: 1;
  animation: wobble 3.4s ease-in-out infinite;
  animation-delay: calc(var(--i) * 0.17s);
}
.pick-card__name { font-size: 1.35rem; color: var(--grape-dark); }
.pick-card__blurb { font-size: 0.95rem; color: #6b5b93; }
.pick-card__count {
  position: absolute;
  top: 12px; right: 12px;
  font-size: 0.8rem;
  padding: 4px 10px;
  border-radius: 999px;
  background: #f0eaff;
  color: var(--grape-dark);
}
.pick-card--played .pick-card__count { background: var(--mint); color: #fff; }

@keyframes wobble {
  0%, 100% { transform: rotate(-7deg); }
  50%      { transform: rotate(7deg); }
}

/* ---------- top bar ---------- */
.bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}
.bar__title {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: clamp(1.05rem, 3.4vw, 1.6rem);
  color: var(--grape-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bar__emoji { font-size: 1.4em; animation: wobble 3s ease-in-out infinite; }
.bar__right { display: flex; align-items: center; gap: 8px; }
.bar__spacer { width: 46px; }

.icon-btn {
  border: 0;
  cursor: pointer;
  font-size: 1.4rem;
  width: 46px; height: 46px;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.15);
  transition: transform 0.12s ease;
}
.icon-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.15); }
.icon-btn--float { position: absolute; top: 0; right: 0; }

.pill {
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--grape);
  color: #fff;
  font-size: 1rem;
  white-space: nowrap;
}
.pill.is-bump { animation: bump 0.45s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes bump {
  50% { transform: scale(1.3) rotate(-5deg); background: var(--mint); }
}

/* ---------- progress dots ---------- */
.dots {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 7px;
  margin: 12px 0 4px;
}
.dot {
  width: 13px; height: 13px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.75);
  box-shadow: inset 0 0 0 2px rgba(108, 63, 209, 0.25);
  transition: transform 0.16s ease, background 0.16s ease;
}
.dot.is-filled { background: var(--mint); box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.08); }
.dot.is-current { transform: scale(1.55); background: var(--sunshine); }

/* ---------- the question ---------- */
.ask {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(6px, 2vh, 18px);
  padding: 6px 0 10px;
}

.buddy { position: relative; text-align: center; flex: 0 0 auto; }
.buddy__face {
  font-size: clamp(2.6rem, 9vw, 4.2rem);
  line-height: 1;
  animation: bob 2.6s ease-in-out infinite;
  display: inline-block;
}
.buddy[data-mood='happy'] .buddy__face { animation: cheer 0.6s ease-in-out 2; }
@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50%      { transform: translateY(-9px) rotate(3deg); }
}
@keyframes cheer {
  0%, 100% { transform: scale(1) rotate(0deg); }
  30%      { transform: scale(1.25) rotate(-12deg); }
  60%      { transform: scale(1.2) rotate(12deg); }
}
.buddy__speech {
  display: inline-block;
  margin-top: 2px;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--paper);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.12);
  font-size: clamp(0.9rem, 2.6vw, 1.05rem);
  color: var(--grape-dark);
  max-width: 78vw;
}

.ask__card {
  width: min(620px, 100%);
  padding: clamp(14px, 3vh, 26px) clamp(16px, 4vw, 30px) clamp(12px, 2vh, 20px);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow-pop);
  text-align: center;
}
.ask__card.is-new { animation: cardIn 0.38s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes cardIn {
  from { transform: scale(0.93) translateY(10px); opacity: 0.3; }
}
.ask__kicker {
  margin: 0;
  font-size: clamp(0.95rem, 2.6vw, 1.1rem);
  color: var(--bubblegum);
}
.ask__label {
  margin: 2px 0 4px;
  font-size: clamp(1.7rem, 6.5vw, 2.6rem);
  color: var(--grape-dark);
  line-height: 1.1;
}
.ask__hint { margin: 0 0 14px; font-size: clamp(0.9rem, 2.6vw, 1.05rem); color: #6b5b93; }
.ask__examples { margin: 10px 0 0; font-size: 0.9rem; color: #8a7bb0; }

.ask__row { display: flex; gap: 10px; align-items: center; }

.word-input {
  flex: 1 1 auto;
  min-width: 0;
  font: inherit;
  font-size: clamp(1.2rem, 5vw, 1.8rem);
  text-align: center;
  padding: 12px 14px;
  border: 3px dashed var(--grape);
  border-radius: 16px;
  background: #fff;
  color: var(--ink);
  outline: none;
}
.word-input:focus { border-style: solid; border-color: var(--mint); }
.word-input.is-shake { animation: shake 0.4s; }
@keyframes shake {
  25% { transform: translateX(-8px); }
  50% { transform: translateX(8px); }
  75% { transform: translateX(-5px); }
}

.dice-btn {
  flex: 0 0 auto;
  border: 0;
  cursor: pointer;
  font-size: 1.9rem;
  width: 62px; height: 62px;
  border-radius: 18px;
  background: var(--sunshine);
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.18);
  transition: transform 0.12s ease;
}
.dice-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.18); }
.dice-btn.is-rolling { animation: roll 0.42s ease-in-out; }
@keyframes roll {
  0%   { transform: rotate(0deg) scale(1); }
  50%  { transform: rotate(200deg) scale(1.18); }
  100% { transform: rotate(360deg) scale(1); }
}

/* ---------- buttons ---------- */
.controls {
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  padding-top: 10px;
}
.controls--wrap { flex-wrap: wrap; padding-bottom: 6px; }

.big-btn {
  border: 0;
  font: inherit;
  cursor: pointer;
  font-size: clamp(1rem, 3vw, 1.15rem);
  padding: 12px 22px;
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.18);
  transition: transform 0.12s ease;
}
.big-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.18); }
.big-btn--go   { background: var(--mint); color: #fff; }
.big-btn--wild { background: var(--sunshine); }
.big-btn--read { background: var(--sky-blue); color: #fff; }
.big-btn--nav  { padding: 12px 18px; }
.big-btn[disabled] { opacity: 0.4; cursor: default; }

/* ---------- the finished story ---------- */
.paper {
  flex: 1 1 auto;
  overflow: auto;
  width: min(760px, 100%);
  margin: 12px auto 0;
  padding: clamp(18px, 4vw, 34px);
  border-radius: var(--radius);
  background:
    repeating-linear-gradient(
      to bottom,
      transparent 0 37px,
      rgba(108, 63, 209, 0.09) 37px 38px
    ),
    var(--paper);
  box-shadow: var(--shadow-pop);
}
.story {
  font-size: clamp(1.05rem, 3.4vw, 1.35rem);
  line-height: 38px;
  color: var(--ink);
  white-space: pre-wrap;
}
.story p { margin: 0 0 24px; }
.story p:last-child { margin-bottom: 0; }

.fill-word {
  display: inline-block;
  padding: 0 7px;
  border-radius: 8px;
  background: var(--sunshine);
  color: var(--grape-dark);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.12);
  transform: rotate(-1.2deg);
}
.fill-word:nth-of-type(even) { background: var(--mint); transform: rotate(1.4deg); }
.fill-word.is-pop { animation: pop 0.42s cubic-bezier(0.34, 1.56, 0.64, 1) backwards; }
@keyframes pop {
  from { transform: scale(0.2) rotate(-14deg); opacity: 0; }
}
.fill-word.is-speaking { outline: 3px solid var(--bubblegum); }

.confetti {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

/* ---------- phones ---------- */
@media (max-width: 560px) {
  .card-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .pick-card { padding: 14px 12px 12px; }
  .pick-card__blurb { display: none; }
  .pick-card__count { position: static; align-self: flex-start; margin-top: 4px; }
  .controls { gap: 8px; }
  .big-btn { padding: 11px 16px; }
  .story { line-height: 34px; }
  .paper {
    background:
      repeating-linear-gradient(to bottom, transparent 0 33px, rgba(108, 63, 209, 0.09) 33px 34px),
      var(--paper);
  }
}
@media (max-height: 620px) {
  .buddy__speech { display: none; }
  .ask { gap: 4px; }
}

/* ---------- respect reduced-motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
