/* =========================================================
   Carlie's Quest — daily challenges for a 6th grader.
   Same storybook world as carlieandcaiden.com, but hers:
   where Caiden's Corner is a bright cyan morning, Carlie's
   Quest is a berry-dusk sky with the book's rainbow arcing
   over everything. Bricolage Grotesque + Nunito — playful
   but definitely not babyish.
   ========================================================= */

:root {
  --dusk-deep:   #23091A;
  --dusk-mid:    #3D1129;
  --dusk-warm:   #5C1A38;
  --berry:       #8E2247;
  --rose:        #E84D6F;
  --rose-deep:   #B72E52;
  --rose-shadow: #7A1834;
  --gold:        #F5B830;
  --gold-dark:   #C8881A;
  --gold-glow:   rgba(245, 184, 48, 0.35);
  --cream:       #FFF6EC;
  --cream-dim:   #F7E7D8;
  --ink:         #2A1220;
  --ink-soft:    #6B4A5C;
  --mint:        #2FA878;
  --mint-dark:   #1E7A55;
  --amber:       #E8890C;
  --amber-dark:  #B56A05;

  --rainbow: linear-gradient(90deg, #FF5757, #FF9A3C, #FFD53C, #4CD97B, #4CBBFF, #9C6BFF);

  --font-display: 'Bricolage Grotesque', 'Georgia', sans-serif;
  --font-body:    'Nunito', system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-weight: 700;
  color: var(--cream);
  background: linear-gradient(172deg, var(--dusk-deep) 0%, var(--dusk-mid) 48%, var(--dusk-warm) 100%);
  background-attachment: fixed;
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
/* Star field over the dusk sky */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    radial-gradient(1.5px 1.5px at 12% 18%, rgba(255,246,236,0.8) 50%, transparent 51%),
    radial-gradient(1px 1px at 28% 8%, rgba(255,246,236,0.6) 50%, transparent 51%),
    radial-gradient(2px 2px at 44% 24%, rgba(245,184,48,0.7) 50%, transparent 51%),
    radial-gradient(1px 1px at 61% 12%, rgba(255,246,236,0.7) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 76% 28%, rgba(255,246,236,0.55) 50%, transparent 51%),
    radial-gradient(1px 1px at 88% 9%, rgba(245,184,48,0.6) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 7% 52%, rgba(255,246,236,0.4) 50%, transparent 51%),
    radial-gradient(1px 1px at 93% 47%, rgba(255,246,236,0.45) 50%, transparent 51%);
}
a { color: inherit; text-decoration: none; }
button {
  font-family: inherit;
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* The book's rainbow, arcing over the whole page */
.rainbow-arc {
  position: fixed;
  left: 50%;
  top: 0;
  transform: translate(-50%, -68%);
  width: min(1500px, 165vw);
  aspect-ratio: 1;
  border-radius: 50%;
  background: conic-gradient(from 130deg,
    #9C6BFF, #4CBBFF, #4CD97B, #FFD53C, #FF9A3C, #FF5757,
    #FF5757, #FF9A3C, #FFD53C, #4CD97B, #4CBBFF, #9C6BFF);
  -webkit-mask: radial-gradient(closest-side, transparent 88%, #000 88.5% 97.5%, transparent 98%);
  mask: radial-gradient(closest-side, transparent 88%, #000 88.5% 97.5%, transparent 98%);
  opacity: 0.5;
  filter: blur(1.5px) saturate(1.15);
  pointer-events: none;
  z-index: 0;
  animation: arc-glow 7s ease-in-out infinite;
}
@keyframes arc-glow {
  0%, 100% { opacity: 0.42; }
  50% { opacity: 0.6; }
}

/* ---------- Top bar ---------- */
.corner-top {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.25rem;
}
.corner-home {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
  color: var(--cream);
  background: rgba(35, 9, 26, 0.55);
  padding: 0.55rem 1.15rem;
  border-radius: 999px;
  border: 2px solid rgba(255, 246, 236, 0.25);
  min-height: 48px;
  transition: border-color 0.2s ease;
}
.corner-home:hover { border-color: var(--gold); }
.corner-home .spark { color: var(--gold); font-size: 1.1rem; }

/* ---------- Daily quest badge strip ---------- */
.quest-strip {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: center;
  gap: 0.65rem;
  flex-wrap: wrap;
  padding: 0.25rem 1rem 0.85rem;
}
.qbadge { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.qring {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  padding: 5px;
  /* Golden ring fills one segment per finished question — like a charm
     on one of the magical wristbands from the book */
  background: conic-gradient(var(--gold) var(--fill, 0%), rgba(255, 246, 236, 0.18) var(--fill, 0%));
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s ease;
}
.qring span {
  width: 100%;
  height: 100%;
  background: var(--dusk-deep);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  filter: grayscale(1);
  opacity: 0.5;
  transition: filter 0.4s ease, opacity 0.4s ease;
}
.qbadge.done .qring {
  box-shadow: 0 0 18px var(--gold-glow), 0 0 5px var(--gold);
}
.qbadge.done .qring span {
  filter: none;
  opacity: 1;
  animation: pop 0.5s ease;
}
.qbadge.active .qring { outline: 3px solid rgba(255, 246, 236, 0.85); outline-offset: 2px; }
.qcount {
  font-size: 0.72rem;
  font-weight: 800;
  color: rgba(255, 246, 236, 0.8);
}
.qbadge.done .qcount { color: var(--gold); }

/* ---------- Hub hero ---------- */
.quest-hero {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 1.75rem 1.25rem 0.75rem;
}
.quest-hero h1 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.5rem, 8vw, 4.2rem);
  letter-spacing: -0.02em;
  line-height: 1.05;
  margin: 0 0 0.65rem;
  color: var(--cream);
  text-shadow: 0 4px 24px rgba(0, 0, 0, 0.45);
}
.quest-hero h1 .shine {
  background: linear-gradient(100deg, var(--gold) 20%, #FFE9AC 50%, var(--gold) 80%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero-rainbow-bar {
  width: min(280px, 60vw);
  height: 6px;
  border-radius: 999px;
  background: var(--rainbow);
  margin: 0 auto 0.8rem;
  box-shadow: 0 0 16px rgba(255, 154, 60, 0.4);
}
.quest-hero p {
  font-size: 1.15rem;
  font-weight: 800;
  margin: 0;
  color: var(--cream-dim);
}

/* Hub start button */
.quest-start-wrap { text-align: center; position: relative; z-index: 2; margin: 1rem 0 0.5rem; }
.quest-start {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.3rem;
  color: var(--cream);
  background: linear-gradient(135deg, var(--rose) 0%, var(--rose-deep) 100%);
  padding: 0.9rem 2.1rem;
  border-radius: 999px;
  border: 3px solid rgba(255, 246, 236, 0.25);
  box-shadow: 0 6px 0 var(--rose-shadow), 0 12px 30px rgba(232, 77, 111, 0.35);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  min-height: 56px;
}
.quest-start:hover { transform: translateY(-2px); }
.quest-start:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--rose-shadow); }
.quest-start.alldone {
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%);
  box-shadow: 0 6px 0 #9A6812, 0 0 30px var(--gold-glow);
  cursor: default;
}

/* Appears under the trophy once every badge is earned */
.quest-unlock {
  display: none;
  align-items: center;
  gap: 0.5rem;
  margin: 0.9rem auto 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--gold);
  background: rgba(35, 9, 26, 0.55);
  padding: 0.75rem 1.7rem;
  border-radius: 999px;
  border: 3px dashed var(--gold);
  box-shadow: 0 0 22px var(--gold-glow);
  min-height: 52px;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  animation: pop 0.5s ease backwards;
}
/* display:flex makes it block-level, so it stacks under the trophy
   and the auto margins center it */
.quest-unlock.show { display: flex; width: fit-content; }
.quest-unlock:hover { transform: translateY(-2px); box-shadow: 0 0 30px var(--gold-glow); }
.quest-unlock:active { transform: translateY(2px); }

/* ---------- Hub challenge grid ---------- */
.activity-grid {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.25rem;
  max-width: 940px;
  margin: 1.75rem auto 3rem;
  padding: 0 1.25rem;
}
.activity-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.3rem;
  background: var(--cream);
  border-radius: 22px;
  padding: 1.5rem 1.4rem 1.4rem;
  overflow: hidden;
  box-shadow: 0 8px 0 rgba(35, 9, 26, 0.5), 0 18px 40px rgba(0, 0, 0, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  text-align: left;
  color: var(--ink);
}
/* Each card wears a slice of the rainbow along its top edge */
.activity-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 7px;
  background: var(--card-stripe, var(--rainbow));
}
.activity-card:hover, .activity-card:focus-visible {
  transform: translateY(-4px) rotate(-0.4deg);
  box-shadow: 0 12px 0 rgba(35, 9, 26, 0.5), 0 24px 50px rgba(0, 0, 0, 0.4);
}
.activity-card:active { transform: translateY(3px); box-shadow: 0 4px 0 rgba(35,9,26,0.5), 0 10px 24px rgba(0,0,0,0.35); }
.activity-emoji { font-size: 2.8rem; line-height: 1; }
.activity-card h2 {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -0.01em;
  font-size: 1.45rem;
  margin: 0.35rem 0 0;
  color: var(--berry);
}
.activity-card p { margin: 0; font-size: 0.95rem; font-weight: 700; color: var(--ink-soft); }

/* ---------- Game shell ---------- */
.game-wrap {
  position: relative;
  z-index: 2;
  max-width: 720px;
  margin: 0 auto;
  padding: 0.5rem 1rem 3rem;
}
.game-card {
  position: relative;
  background: var(--cream);
  border-radius: 26px;
  padding: 1.6rem 1.5rem 2rem;
  overflow: hidden;
  box-shadow: 0 10px 0 rgba(35, 9, 26, 0.5), 0 24px 60px rgba(0, 0, 0, 0.4);
  text-align: center;
  color: var(--ink);
}
.game-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 7px;
  background: var(--rainbow);
}
.game-title {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -0.01em;
  font-size: 1.55rem;
  color: var(--berry);
  margin: 0.25rem 0 0.1rem;
}
.game-level {
  font-size: 0.85rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gold-dark);
  margin: 0 0 0.5rem;
}

/* Streak stars — 3 in a row levels you up */
.streak {
  display: flex;
  justify-content: center;
  gap: 0.4rem;
  font-size: 1.5rem;
  min-height: 1.9rem;
  margin-bottom: 0.6rem;
}
.streak span { opacity: 0.22; transition: opacity 0.2s, transform 0.2s; }
.streak span.lit { opacity: 1; animation: pop 0.35s ease; }
@keyframes pop {
  0% { transform: scale(0.4); }
  60% { transform: scale(1.4); }
  100% { transform: scale(1); }
}

/* Prompt area */
.prompt-zone {
  min-height: 96px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.9rem, 7vw, 2.8rem);
  letter-spacing: -0.01em;
  line-height: 1.2;
  color: var(--ink);
  margin: 0.4rem 0 0.75rem;
}
.prompt-zone .big-word { color: var(--berry); }
.prompt-zone .math-expr { font-variant-numeric: tabular-nums; }
.prompt-question {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--ink-soft);
  margin: 0 0 1.1rem;
}

/* Answer buttons — short numeric answers */
.answers {
  display: flex;
  justify-content: center;
  gap: 0.85rem;
  flex-wrap: wrap;
}
.answer-btn {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.7rem;
  color: var(--cream);
  background: linear-gradient(135deg, var(--berry) 0%, #6E1B39 100%);
  min-width: 88px;
  min-height: 72px;
  padding: 0.5rem 1.3rem;
  border-radius: 18px;
  box-shadow: 0 5px 0 #4A1226, 0 10px 24px rgba(0, 0, 0, 0.25);
  transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.2s;
}
.answer-btn:hover { transform: translateY(-3px); }
.answer-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #4A1226; }

/* Long text answers (definitions, sentences) stack full-width */
.answers.stack { flex-direction: column; align-items: stretch; gap: 0.7rem; }
.answers.stack .answer-btn {
  font-family: var(--font-body);
  font-weight: 800;
  font-size: 1.05rem;
  line-height: 1.4;
  text-align: left;
  min-height: 58px;
  padding: 0.8rem 1.2rem;
  letter-spacing: 0;
}

.answer-btn.right {
  background: linear-gradient(135deg, var(--mint) 0%, var(--mint-dark) 100%);
  box-shadow: 0 5px 0 #14543A, 0 10px 24px rgba(47, 168, 120, 0.4);
  animation: bounce-yes 0.5s ease;
}
.answer-btn.wrong {
  background: linear-gradient(135deg, var(--amber) 0%, var(--amber-dark) 100%);
  box-shadow: 0 5px 0 #7E4A02, 0 10px 24px rgba(232, 137, 12, 0.35);
  animation: shake-no 0.4s ease;
}
.answer-btn.dim { opacity: 0.45; }
@keyframes bounce-yes {
  0%, 100% { transform: translateY(0); }
  35% { transform: translateY(-12px) scale(1.05); }
  70% { transform: translateY(2px); }
}
@keyframes shake-no {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  50% { transform: translateX(8px); }
  75% { transform: translateX(-4px); }
}

/* ---------- Spelling Bee ---------- */
.bee-icon { font-size: 3.4rem; line-height: 1; margin: 0.25rem 0 0.4rem; }
.hear-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--dusk-deep);
  background: linear-gradient(135deg, var(--gold) 0%, #E9A81F 100%);
  padding: 0.7rem 1.5rem;
  border-radius: 999px;
  box-shadow: 0 5px 0 #9A6812, 0 8px 20px var(--gold-glow);
  margin-bottom: 1rem;
  min-height: 52px;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.hear-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #9A6812; }
.spell-clue {
  background: var(--cream-dim);
  border-radius: 16px;
  padding: 1rem 1.25rem;
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--ink);
  text-align: left;
  margin: 0 0 1.1rem;
}
.spell-clue .lbl {
  display: block;
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--gold-dark);
  margin-bottom: 0.15rem;
}
.spell-clue .blank { color: var(--berry); letter-spacing: 0.08em; }
.spell-row { display: flex; gap: 0.6rem; justify-content: center; flex-wrap: wrap; }
.spell-input {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.5rem;
  text-align: center;
  letter-spacing: 0.06em;
  color: var(--ink);
  background: #FFF;
  border: 3px solid rgba(142, 34, 71, 0.35);
  border-radius: 16px;
  padding: 0.6rem 1rem;
  width: min(360px, 100%);
  min-height: 64px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.spell-input:focus { border-color: var(--rose); box-shadow: 0 0 0 4px rgba(232, 77, 111, 0.2); }
.spell-input.wrong { border-color: var(--amber); animation: shake-no 0.4s ease; }
.spell-input.right { border-color: var(--mint); }
.spell-check {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.2rem;
  color: var(--cream);
  background: linear-gradient(135deg, var(--rose) 0%, var(--rose-deep) 100%);
  border-radius: 16px;
  padding: 0.6rem 1.6rem;
  min-height: 64px;
  box-shadow: 0 5px 0 var(--rose-shadow);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.spell-check:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--rose-shadow); }
.spell-hint {
  min-height: 1.8rem;
  font-size: 1rem;
  font-weight: 800;
  color: var(--amber-dark);
  margin: 0.75rem 0 0;
}
.spell-hint .reveal {
  font-family: var(--font-display);
  font-size: 1.25rem;
  color: var(--berry);
  letter-spacing: 0.1em;
}

/* ---------- Celebration overlay ---------- */
.celebrate {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(35, 9, 26, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.celebrate.show { opacity: 1; pointer-events: auto; }
.celebrate-text {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -0.02em;
  font-size: clamp(2.3rem, 9vw, 4rem);
  color: var(--cream);
  text-shadow: 0 0 40px var(--gold-glow), 0 4px 20px rgba(0, 0, 0, 0.5);
  animation: bounce-yes 0.8s ease infinite;
  text-align: center;
  padding: 0 1rem;
}
.celebrate-sub {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--gold);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  margin-top: 0.5rem;
}
.confetti {
  position: absolute;
  top: -10%;
  font-size: 2rem;
  animation: confetti-fall linear forwards;
  pointer-events: none;
}
@keyframes confetti-fall {
  to { transform: translateY(120vh) rotate(720deg); }
}

/* Level-up banner */
.level-banner {
  position: fixed;
  top: 14px;
  left: 50%;
  /* Park it far enough up that its gold glow can't peek over the top
     edge — the glow is invisible on Caiden's light page but not here */
  transform: translateX(-50%) translateY(-320%);
  z-index: 60;
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%);
  color: var(--dusk-deep);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.2rem;
  padding: 0.8rem 1.8rem;
  border-radius: 999px;
  box-shadow: 0 8px 30px var(--gold-glow), 0 4px 0 #9A6812;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  white-space: nowrap;
}
.level-banner.show { transform: translateX(-50%) translateY(0); }

@media (max-width: 480px) {
  .answer-btn { font-size: 1.5rem; min-width: 76px; min-height: 64px; }
  .quest-hero h1 { font-size: 2.3rem; }
}

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