/* Tales of Courage Coloring (test version)
   UI colors borrow Courage's official colors until the brand colors are confirmed. */
:root {
  --cream: #FDF5E1;      /* Courage: bandana emblem white */
  --blue: #0B52AC;       /* Courage: bandana blue */
  --fur: #F8A647;        /* Courage: fur */
  --mane: #B94218;       /* Courage: mane */
  --ink: #3B0D07;        /* Courage: eyes */
  --card: #FFFFFF;
  --shadow: 0 2px 8px rgba(59, 13, 7, 0.15);
  --font: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- Home ---------- */
#home {
  min-height: 100%;
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
  max-width: 1100px;
  margin: 0 auto;
}
.home-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}
.home-icon {
  width: 64px; height: 64px;
  border-radius: 50%;
  border: 3px solid var(--fur);
  box-shadow: var(--shadow);
}
.home-header h1 {
  margin: 0;
  font-size: clamp(1.5rem, 5vw, 2.2rem);
  color: var(--blue);
  line-height: 1.1;
}
.home-header p { margin: 2px 0 0; font-size: 1rem; color: var(--mane); }

.page-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}
.page-card {
  padding: 6px;
  border: 3px solid transparent;
  border-radius: 18px;
  background: var(--card);
  box-shadow: var(--shadow);
  transition: transform 0.12s ease;
}
.page-card:active { transform: scale(0.96); border-color: var(--fur); }
.page-card img { display: block; width: 100%; height: auto; border-radius: 12px; }

/* ---------- Coloring screen ---------- */
#colorer {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "tools" "art" "palette";
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overflow: hidden;
}
.toolbar {
  grid-area: tools;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
}
.tool {
  width: 52px; height: 52px;
  display: grid; place-items: center;
  border: none;
  border-radius: 16px;
  background: var(--card);
  box-shadow: var(--shadow);
}
.tool:active { transform: scale(0.94); }
.tool:disabled { opacity: 0.35; }
.tool svg, .big-btn svg {
  width: 28px; height: 28px;
  fill: none; stroke: var(--blue); stroke-width: 2.4;
  stroke-linecap: round; stroke-linejoin: round;
}
#btn-zoom { margin-left: auto; }
#btn-zoom .zoom-out, #btn-zoom.zoomed .zoom-in { display: none; }
#btn-zoom.zoomed .zoom-out { display: block; }
#btn-zoom.zoomed { background: var(--blue); }
#btn-zoom.zoomed svg { stroke: #fff; }
.current-color {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--c, #fff);
  border: 4px solid var(--card);
  box-shadow: var(--shadow);
}

.art-wrap {
  grid-area: art;
  position: relative;
  padding: 4px 12px;
  min-height: 0;
  overflow: hidden;
}
#art {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  touch-action: none;
  -webkit-touch-callout: none;
  filter: drop-shadow(0 2px 6px rgba(59, 13, 7, 0.18));
  transform-origin: 0 0;
}
#art.animate-zoom { transition: transform 0.25s ease; }
@media (prefers-reduced-motion: reduce) { #art.animate-zoom { transition: none; } }
.loading {
  position: absolute; inset: 0;
  display: grid; place-items: center;
}
.loading img {
  width: 84px; height: 84px; border-radius: 50%;
  animation: bounce 0.8s ease-in-out infinite alternate;
}
@keyframes bounce { from { transform: translateY(0); } to { transform: translateY(-14px); } }

.palette {
  grid-area: palette;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 10px 10px;
  background: var(--card);
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -2px 10px rgba(59, 13, 7, 0.1);
}
.palette-group { display: flex; align-items: center; gap: 8px; }
.courage-group { padding-bottom: 8px; border-bottom: 2px dashed rgba(248, 166, 71, 0.5); }
.group-icon {
  width: 40px; height: 40px; flex: none;
  border-radius: 50%;
  border: 2px solid var(--fur);
}
.swatches {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 7px;
}
.courage-group .swatches { justify-content: flex-start; }
.swatch {
  width: 40px; height: 40px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid rgba(59, 13, 7, 0.18);
  background: var(--c);
  transition: transform 0.1s ease;
}
.swatch.selected {
  transform: scale(1.12);
  border: 3px solid var(--card);
  box-shadow: 0 0 0 3px var(--blue);
}

/* Tablets and phones turned sideways: colors move to the side */
@media (orientation: landscape) and (min-height: 420px) {
  #colorer {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: "tools palette" "art palette";
  }
  .palette {
    width: min(300px, 34vw);
    border-radius: 22px 0 0 22px;
    overflow-y: auto;
    justify-content: center;
  }
  .palette-group { flex-direction: column; }
  .courage-group .swatches { justify-content: center; }
  .swatch { width: 46px; height: 46px; }
}
@media (min-width: 700px) and (orientation: portrait) {
  .swatch { width: 50px; height: 50px; }
  .group-icon { width: 50px; height: 50px; }
}

/* ---------- Start over? ---------- */
.confirm {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  background: rgba(59, 13, 7, 0.45);
  z-index: 10;
}
.confirm-box {
  background: var(--card);
  border-radius: 26px;
  padding: 18px;
  display: grid;
  gap: 16px;
  justify-items: center;
  box-shadow: var(--shadow);
}
#confirm-thumb { width: 160px; border-radius: 14px; border: 2px solid var(--cream); }
.confirm-buttons { display: flex; gap: 22px; }
.big-btn {
  width: 76px; height: 76px;
  border: none;
  border-radius: 50%;
  display: grid; place-items: center;
}
.big-btn svg { width: 40px; height: 40px; stroke: #fff; stroke-width: 3; }
.big-btn.no { background: #8A8A8A; }
.big-btn.yes { background: #2E9E4F; }

/* ---------- Home menu: pick an activity ---------- */
#menu, #home { min-height: 100%; }
#menu {
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
  max-width: 900px;
  margin: 0 auto;
}
.activity-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 8px;
}
.activity-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 10px 14px;
  border-radius: 22px;
  background: var(--card);
  box-shadow: var(--shadow);
  color: var(--blue);
  text-decoration: none;
  font-weight: 800;
  font-size: clamp(1.05rem, 4.5vw, 1.5rem);
  text-align: center;
  line-height: 1.2;
  border: 3px solid transparent;
  transition: transform 0.12s ease;
}
.activity-card:active { transform: scale(0.96); border-color: var(--fur); }
.activity-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  border-radius: 14px;
}
a.tool { color: inherit; flex: none; }

/* ---------- Armor of God ---------- */
#armor {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "tools" "stage" "tray";
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 45%, #FFFFFF 0%, var(--cream) 70%);
}
#armor .toolbar { grid-area: tools; justify-content: space-between; }
.stage-wrap {
  grid-area: stage;
  position: relative;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}
/* Sized by armor.js to fit; centered so it never pushes the layout wider. */
.stage { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); }
.stage img {
  position: absolute;
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
}
.stage .courage { z-index: 1; }
.stage .worn { opacity: 0; }
.stage .worn.on { opacity: 1; }

.piece-name {
  position: absolute;
  top: 4px;
  left: 50%;
  transform: translate(-50%, -12px);
  z-index: 20;
  max-width: calc(100% - 24px);
  padding: 8px 18px;
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  font-weight: 800;
  font-size: clamp(1rem, 4.2vw, 1.4rem);
  text-align: center;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.piece-name.show { opacity: 1; transform: translate(-50%, 0); }

.tray {
  grid-area: tray;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  padding: 10px 10px 12px;
  background: var(--card);
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -2px 10px rgba(59, 13, 7, 0.1);
}
.tray-piece {
  width: 76px; height: 76px;
  padding: 6px;
  border: 3px solid var(--cream);
  border-radius: 18px;
  background: #fff;
  touch-action: none;
  transition: transform 0.12s ease, opacity 0.2s ease;
}
.tray-piece img {
  width: 100%; height: 100%;
  object-fit: contain;
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
}
.tray-piece:active { transform: scale(0.94); }
.tray-piece.lifted img { opacity: 0.25; }
.tray-piece.used { opacity: 0.25; pointer-events: none; }

.ghost, .flyer {
  position: fixed;
  z-index: 50;
  object-fit: contain;
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
}
.ghost { filter: drop-shadow(0 6px 10px rgba(59, 13, 7, 0.3)); }

.sparkle { position: fixed; z-index: 60; width: 0; height: 0; pointer-events: none; }
.sparkle span {
  position: absolute;
  width: 12px; height: 12px;
  margin: -6px 0 0 -6px;
  border-radius: 50%;
  background: #FDD835;
  box-shadow: 0 0 8px #FFF3B0;
  animation: sparkle 0.8s ease-out forwards;
}
@keyframes sparkle {
  from { transform: translate(0, 0) scale(1); opacity: 1; }
  to { transform: translate(var(--dx), var(--dy)) scale(0.2); opacity: 0; }
}

@media (orientation: landscape) and (min-height: 420px) {
  #armor {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: "tools tray" "stage tray";
  }
  .tray {
    width: min(260px, 30vw);
    align-content: center;
    border-radius: 22px 0 0 22px;
    overflow-y: auto;
  }
  .tray-piece { width: 92px; height: 92px; }
}
@media (min-width: 700px) and (orientation: portrait) {
  .tray-piece { width: 96px; height: 96px; }
}

/* ---------- All dressed! ---------- */
.celebrate {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 16px;
  background: radial-gradient(ellipse at 50% 35%, #FFFFFF 0%, var(--cream) 75%);
  overflow-y: auto;
}
.celebrate-box {
  position: relative;
  z-index: 2;
  display: grid;
  justify-items: center;
  gap: 10px;
  max-width: 560px;
  text-align: center;
}
.celebrate-courage {
  width: auto;
  max-width: 80vw;
  max-height: 42vh;
  animation: pop-in 0.7s cubic-bezier(.2, .8, .3, 1.3) both;
}
@keyframes pop-in {
  from { transform: scale(0.3) translateY(40px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}
.courage-says {
  margin: 0;
  color: var(--blue);
  font-weight: 800;
  font-size: clamp(1.2rem, 5vw, 1.7rem);
  line-height: 1.25;
}
.courage-says em { display: block; color: var(--mane); }
.verse { margin: 4px 0 0; color: var(--ink); }
.verse p { margin: 0; font-size: clamp(1rem, 4vw, 1.2rem); font-style: italic; }
.verse cite { display: block; margin-top: 4px; font-style: normal; font-size: 0.9rem; opacity: 0.8; }
.celebrate-buttons { display: flex; gap: 22px; margin-top: 6px; }
a.big-btn { text-decoration: none; }
.big-btn.home { background: var(--blue); }

.confetti { position: fixed; inset: 0; z-index: 1; overflow: hidden; pointer-events: none; }
.confetti span {
  position: absolute;
  top: -20px;
  width: 10px; height: 16px;
  border-radius: 3px;
  animation: confetti-fall linear forwards;
}
@keyframes confetti-fall {
  to { transform: translateY(110vh) rotate(var(--spin)); }
}

@media (prefers-reduced-motion: reduce) {
  .celebrate-courage { animation: none; }
  .piece-name, .tray-piece, .activity-card { transition: none; }
}

/* ---------- Thankful Activities ---------- */
#seasonal, #parents, #verses, #xverses, #thankful-coloring, #christmas-coloring, #learning {
  min-height: 100%;
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
  max-width: 900px;
  margin: 0 auto;
}
.thankful-courage { border-radius: 50%; }
.card-art {
  display: grid;
  place-content: center;
  gap: 2px;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 14px;
}
.verses-art {
  background: linear-gradient(135deg, #FDD835, var(--fur));
  color: var(--ink);
  font-size: clamp(1.1rem, 5vw, 1.8rem);
  line-height: 1.15;
}
.verses-art span:nth-child(2) { color: var(--blue); font-size: 1.25em; }

/* Choose a verse */
.verse-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.verse-pick {
  display: grid;
  gap: 6px;
  padding: 18px 18px 20px;
  border-radius: 20px;
  background: var(--card);
  border-left: 10px solid var(--c);
  box-shadow: var(--shadow);
  color: var(--ink);
  text-decoration: none;
  transition: transform 0.12s ease;
}
.verse-pick:active { transform: scale(0.97); }
.pick-ref { font-weight: 800; font-size: 1.3rem; color: var(--blue); }
.pick-start { font-size: 1.05rem; opacity: 0.85; }

/* Tap to show each word */
#verse-play {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "tools" "card" "done";
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: radial-gradient(ellipse at 50% 40%, #FFFFFF 0%, var(--cream) 75%);
}
.verse-card {
  grid-area: card;
  position: relative;
  margin: 8px 16px 16px;
  padding: 28px 24px 56px;
  border: 6px solid var(--c, var(--fur));
  border-radius: 28px;
  background: var(--card);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
  touch-action: manipulation;
}
.verse-card:disabled { cursor: default; }
.verse-words {
  font-size: clamp(1.7rem, 7.5vw, 3rem);
  font-weight: 700;
  line-height: 1.35;
  color: var(--ink);
}
.verse-word { display: inline-block; animation: word-pop 0.35s cubic-bezier(.2, .8, .3, 1.4) both; }
@keyframes word-pop {
  from { transform: scale(0.4) translateY(10px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}
.lord { font-variant: small-caps; }
.verse-ref {
  margin-top: 14px;
  font-size: clamp(1.1rem, 4.5vw, 1.5rem);
  font-weight: 700;
  color: var(--blue);
  opacity: 0;
  transition: opacity 0.4s ease;
}
.verse-ref.show { opacity: 1; }
.tap-hint {
  position: absolute;
  right: 18px;
  bottom: 14px;
  width: 46px; height: 46px;
  animation: tap-bounce 1s ease-in-out infinite;
}
.tap-hint svg { width: 100%; height: 100%; fill: #fff; stroke: var(--blue); stroke-width: 1.6; stroke-linejoin: round; }
@keyframes tap-bounce { 0%, 100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-6px) scale(0.92); } }
.verse-done {
  grid-area: done;
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 0 16px 18px;
}
.courage-cheer { display: flex; align-items: center; gap: 12px; animation: pop-in 0.6s cubic-bezier(.2, .8, .3, 1.3) both; }
.courage-cheer img { width: 76px; height: 76px; border: 3px solid var(--fur); flex: none; }
.speech {
  margin: 0;
  padding: 12px 16px;
  border-radius: 20px;
  background: var(--blue);
  color: #fff;
  font-weight: 800;
  font-size: clamp(1.05rem, 4.5vw, 1.4rem);
}
@media (prefers-reduced-motion: reduce) {
  .verse-word, .courage-cheer, .tap-hint { animation: none; }
}

/* ---------- Thankful Tree ---------- */
#tree {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "tools" "stage" "tray";
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 40%, #FFFFFF 0%, #FCEBD3 75%);
}
#tree .toolbar { justify-content: space-between; }
#tree .tree-img { z-index: 1; }
#tree .tree-courage { z-index: 3; }
.leaf { position: absolute; z-index: 2; pointer-events: none; }
.stage .leaf .leaf-img {
  position: absolute;
  left: 0; top: 0;
  width: 100%; height: 100%;
  object-fit: contain;
}
.leaf-badge {
  position: absolute;
  left: 18%; top: 22%;
  width: 64%; aspect-ratio: 1;
  display: grid; place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 1px 4px rgba(59, 13, 7, 0.25);
}
.stage .leaf-badge img {
  position: static;
  width: 82%; height: 82%;
  object-fit: contain;
}
@media (orientation: landscape) and (min-height: 420px) {
  #tree {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: "tools tray" "stage tray";
  }
}

/* ---------- Memory Match ---------- */
#match, #xmatch {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "tools" "cards";
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: radial-gradient(ellipse at 50% 40%, #FFFFFF 0%, #FCEBD3 75%);
}
#match .toolbar, #xmatch .toolbar { justify-content: space-between; }
.match-wrap { grid-area: cards; display: grid; place-items: center; min-height: 0; padding: 4px 12px 16px; }
.match-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: min(100%, calc((100dvh - 110px) * 0.72));
}
@media (orientation: landscape) {
  .match-grid { grid-template-columns: repeat(4, 1fr); width: min(100%, calc((100dvh - 110px) * 1.3)); }
}
.mcard {
  aspect-ratio: 1;
  padding: 0;
  border: none;
  background: none;
  perspective: 800px;
}
.mcard-inner {
  position: relative;
  display: block;
  width: 100%; height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.4s ease;
}
.mcard.up .mcard-inner { transform: rotateY(180deg); }
.mcard-face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 16px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: var(--shadow);
}
.mcard-back { background: var(--blue); border: 4px solid #fff; }
.mcard-back img { width: 62%; border-radius: 50%; border: 3px solid var(--fur); }
.mcard-front { background: #fff; border: 4px solid var(--fur); transform: rotateY(180deg); }
.mcard-front img { width: 84%; height: 84%; object-fit: contain; }
.mcard.matched .mcard-front { border-color: #2E9E4F; box-shadow: 0 0 0 4px rgba(46, 158, 79, 0.3); }
@media (prefers-reduced-motion: reduce) { .mcard-inner { transition: none; } }

/* Little picture for the Memory Match button */
.match-art {
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 14px;
  background: #FCEBD3;
}
.match-art .mini {
  display: grid; place-items: center;
  aspect-ratio: 1;
  border-radius: 10px;
  background: var(--blue);
  border: 3px solid #fff;
}
.match-art .mini.up { background: #fff; border-color: var(--fur); }
.activity-card .match-art img { width: 70%; aspect-ratio: auto; border-radius: 50%; }
.activity-card .match-art .mini.up img { border-radius: 0; width: 80%; }

/* Courage in the verse cheer is the full thankful picture */
.courage-cheer img { border: none; border-radius: 0; width: 84px; height: 92px; object-fit: contain; }

/* ---------- Courage's welcome video ---------- */
.welcome {
  position: relative;
  margin: 0 0 14px;
  border-radius: 22px;
  overflow: hidden;
  box-shadow: var(--shadow);
  background: var(--card);
  aspect-ratio: 854 / 492;
}
.welcome video { display: block; width: 100%; height: 100%; object-fit: cover; }
.welcome-sound {
  position: absolute;
  right: 10px; bottom: 10px;
  width: 52px; height: 52px;
  display: grid; place-items: center;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: var(--shadow);
}
.welcome-sound svg { width: 26px; height: 26px; fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.welcome-sound svg path:first-child { fill: #fff; }
.welcome-sound .sound-on, .welcome-sound.on .sound-off { display: none; }
.welcome-sound.on .sound-on { display: block; }
.welcome-sound:not(.on) { animation: tap-bounce 1.6s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .welcome-sound:not(.on) { animation: none; } }

/* Captions for the welcome video */
.welcome-cc {
  position: absolute;
  right: 72px; bottom: 10px;
  height: 52px; min-width: 56px;
  padding: 0 10px;
  border: 3px solid #fff;
  border-radius: 16px;
  background: rgba(59, 13, 7, 0.55);
  color: #fff;
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: 0.05em;
  box-shadow: var(--shadow);
}
.welcome-cc.on { background: var(--blue); }
.welcome-caption {
  min-height: 2.9em;
  margin: -6px 0 14px;
  padding: 8px 14px;
  border-radius: 14px;
  background: var(--card);
  box-shadow: var(--shadow);
  color: var(--ink);
  font-weight: 700;
  font-size: clamp(1rem, 4.3vw, 1.35rem);
  line-height: 1.3;
  text-align: center;
  display: grid;
  place-items: center;
}
.welcome-caption[hidden] { display: none; }

/* ---------- David & Goliath ---------- */
#david {
  min-height: 100%;
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
  max-width: 900px;
  margin: 0 auto;
}
.dg-art, .sling-art {
  position: relative;
  background: linear-gradient(180deg, #BFE3F7 0%, #BFE3F7 45%, #8CC8E8 45%, #5FA8D3 100%);
  grid-auto-flow: column;
  gap: 10px;
}
.sling-art { background: linear-gradient(180deg, #CDEBFA 0%, #E9F6FD 70%, #9CCC65 70%); }
.dg-stone {
  display: block;
  width: 26%;
  aspect-ratio: 10 / 7;
  border-radius: 50%;
  background: radial-gradient(ellipse at 35% 30%, #fff 0 12%, #B4ADA4 13%);
  border: 3px solid #6E6760;
}
.sling-art { place-content: center; }
.sling-arc {
  position: absolute;
  left: 18%; top: 22%;
  width: 64%; height: 50%;
  border-top: 5px dotted var(--blue);
  border-radius: 50% 50% 0 0;
}
.sling-art .dg-stone { position: absolute; right: 12%; top: 58%; width: 16%; }

#stones, #sling {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "tools" "stage";
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overflow: hidden;
  background: var(--cream);
}
#stones .toolbar, #sling .toolbar { justify-content: space-between; }
.stone-count { display: flex; gap: 6px; }
.stone-count .slot {
  width: 30px; height: 21px;
  border-radius: 50%;
  border: 3px dashed #B4ADA4;
  background: #fff;
}
.stone-count .slot.filled { border: 3px solid #6E6760; background: radial-gradient(ellipse at 35% 30%, #fff 0 12%, #B4ADA4 13%); }

.dg-stage { border-radius: 22px; overflow: hidden; box-shadow: var(--shadow); touch-action: none; }
.dg-stage > * { position: absolute; }
.dg-art-piece > svg { width: 100%; height: 100%; display: block; }
.dg-stage img.dg-art-piece { object-fit: contain; }
.stream-bg {
  background: linear-gradient(180deg, #CDEBFA 0%, #E9F6FD 22%, #A5D06F 22%, #8BBE55 48%, #7CC0E3 50%, #4F9FD0 92%, #8BBE55 94%);
}
.valley-bg {
  background:
    radial-gradient(ellipse 60% 30% at 15% 88%, #7FB04A 60%, transparent 61%),
    radial-gradient(ellipse 55% 34% at 85% 90%, #79A946 60%, transparent 61%),
    linear-gradient(180deg, #CDEBFA 0%, #EAF6FD 70%, #A5D06F 70%, #8BBE55 100%);
}
.dg-stone-btn { padding: 0; border: none; background: none; }
.dg-stone-btn > * { width: 100%; height: 100%; pointer-events: none; }
.dg-stone-btn:disabled { pointer-events: none; }
.dg-stone-btn.wiggle { animation: wiggle 0.5s ease; }
@keyframes wiggle {
  0%, 100% { transform: rotate(0); }
  20% { transform: rotate(-12deg); } 40% { transform: rotate(10deg); }
  60% { transform: rotate(-7deg); } 80% { transform: rotate(4deg); }
}

.sling-stage { cursor: grab; }
.sling-aim { left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; z-index: 5; }
.sling-aim circle { fill: #fff; stroke: var(--blue); stroke-width: 3; }
.sling-aim .band { stroke: #6B4A2A; stroke-width: 5; stroke-linecap: round; }
.dg-flying-stone {
  z-index: 6;
  border-radius: 50%;
  background: radial-gradient(ellipse at 35% 30%, #fff 0 14%, #B4ADA4 15%);
  border: 2px solid #6E6760;
  pointer-events: none;
}
.dg-goliath { z-index: 1; transform-origin: 50% 100%; }
.dg-david, .dg-courage { z-index: 2; }
.dg-goliath.wobble { animation: wobble 0.9s ease-in-out; }
@keyframes wobble {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(4deg); } 50% { transform: rotate(-3deg); } 75% { transform: rotate(2deg); }
}
.dg-goliath.topple { transition: transform 0.5s ease-in, opacity 0.5s ease-in; transform: rotate(-28deg); opacity: 0; }
.dg-goliath-fallen { z-index: 1; animation: fade-in 0.4s ease-out both; }
@keyframes fade-in { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: none; } }
.bonk {
  z-index: 7;
  padding: 4px 10px;
  border-radius: 12px;
  background: #FDD835;
  border: 3px solid var(--ink);
  color: var(--ink);
  font-weight: 900;
  font-size: clamp(0.9rem, 3.5vw, 1.6rem);
  animation: pop-in 0.35s cubic-bezier(.2, .8, .3, 1.5) both;
}
.dust {
  z-index: 4;
  width: 40%; height: 18%;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(214, 196, 160, 0.9) 0%, rgba(214, 196, 160, 0) 70%);
  animation: dust 1.2s ease-out forwards;
}
@keyframes dust { from { transform: scale(0.3); opacity: 1; } to { transform: scale(1.4); opacity: 0; } }
.sling-hint {
  position: absolute;
  left: 50%; top: 10px;
  transform: translateX(-50%);
  margin: 0;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  font-weight: 800;
  pointer-events: none;
  z-index: 10;
}
.sling-hint[hidden] { display: none; }
@media (prefers-reduced-motion: reduce) {
  .dg-stone-btn.wiggle, .dg-goliath.wobble, .dust, .bonk { animation: none; }
  .dg-goliath.topple { transition: none; }
}

/* ---------- Logo at the top of the home screen ---------- */
.logo-header { display: grid; place-items: center; margin: 0 0 10px; }
.logo-header h1 { margin: 0; line-height: 0; }
.logo { display: block; width: min(78vw, 380px); height: auto; }

.dg-stage.pic-bg { background-size: cover; background-position: center; }

.sling-stage.pic-bg { background-position: center 72%; }
/* Bigger tap area than the stone itself, for little fingers */
.dg-stone-btn::after { content: ''; position: absolute; inset: -14px -10px; }

/* Sling: Courage starts a little worried, then fades into cheering when Goliath falls */
.dg-courage-nervous, .dg-courage-cheer { transition: opacity 0.6s ease, transform 0.6s ease; }
.dg-courage-cheer { opacity: 0; transform: scale(0.85); }
.cheering .dg-courage-nervous { opacity: 0; }
.cheering .dg-courage-cheer { opacity: 1; transform: scale(1); }

/* ---------- Bible ABCs tracing ---------- */
.abc-art {
  background: linear-gradient(135deg, #FDF5E1, #FCEBD3);
  color: var(--blue);
  font-size: clamp(2rem, 11vw, 3.4rem);
  font-weight: 900;
  letter-spacing: 0.04em;
}
#abc, #shapes {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "tools" "letter" "picker";
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: radial-gradient(ellipse at 50% 45%, #FFFFFF 0%, var(--cream) 75%);
}
#abc .toolbar, #shapes .toolbar { grid-area: tools; }
.abc-picker { grid-area: picker; }
.abc-rule { stroke: #D9E4F2; stroke-width: 0.6; }
.abc-rule.mid { stroke-dasharray: 2 2; }
.abc-word-wrap { margin: 0; display: grid; justify-items: center; gap: 2px; text-align: center; }
.abc-pair { font-size: clamp(2.2rem, 10vw, 3.4rem); font-weight: 900; color: var(--blue); line-height: 1; }
.abc-word { font-size: clamp(1.2rem, 5.5vw, 1.8rem); font-weight: 800; color: var(--mane); }
.abc-wrap { grid-area: letter; position: relative; display: grid; place-items: center; min-height: 0; padding: 4px 12px; }
.abc-svg {
  width: min(100%, calc(100dvh - 210px));
  aspect-ratio: 1;
  background: var(--card);
  border-radius: 26px;
  box-shadow: var(--shadow);
  touch-action: none;
}
.abc-track { fill: none; stroke: #F1EADF; stroke-width: 12; stroke-linecap: round; stroke-linejoin: round; }
.abc-guide { fill: none; stroke: #A99F92; stroke-width: 1.3; stroke-linecap: round; stroke-dasharray: 2.4 2.6; }
.abc-follow.at-start { opacity: 0; }
.abc-ink { fill: none; stroke: var(--fur); stroke-width: 9; stroke-linecap: round; stroke-linejoin: round; }
.abc-start circle { fill: #B9B2A8; }
.abc-start.now circle { fill: #2E9E4F; }
.abc-start text { fill: #fff; font-size: 6px; font-weight: 800; font-family: var(--font); pointer-events: none; }
.abc-arrow path { fill: none; stroke: var(--blue); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.abc-follow { fill: #fff; stroke: var(--blue); stroke-width: 1.4; animation: follow-pulse 1.1s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes follow-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.35); } }
.abc-courage { position: absolute; right: 8px; bottom: 0; width: 22%; max-width: 120px; pointer-events: none; }
.abc-done {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  background: rgba(253, 245, 225, 0.82);
  border-radius: 26px;
}
.abc-done[hidden] { display: none; }
.abc-done img { width: min(40vw, 200px); animation: pop-in 0.6s cubic-bezier(.2, .8, .3, 1.3) both; }
.abc-picker { display: flex; gap: 8px; padding: 10px 12px 14px; overflow-x: auto; scrollbar-width: none; }
.abc-picker::-webkit-scrollbar { display: none; }
.abc-pick {
  flex: none;
  width: 62px; height: 54px;
  border: 3px solid var(--cream);
  border-radius: 16px;
  background: var(--card);
  box-shadow: var(--shadow);
  color: var(--blue);
  font-size: 1.35rem;
  font-weight: 900;
}
.abc-pick.on { background: var(--blue); color: #fff; }
@media (prefers-reduced-motion: reduce) { .abc-follow, .abc-done img { animation: none; } }

/* ---------- Noah's Ark Path ---------- */
#noah {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "tools" "stage";
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overflow: hidden;
  background: var(--cream);
}
#noah .toolbar { grid-area: tools; justify-content: space-between; }
.noah-picks { display: flex; gap: 8px; }
.noah-pick {
  width: 52px; height: 52px;
  border: 3px solid var(--cream);
  border-radius: 16px;
  background: var(--card);
  box-shadow: var(--shadow);
  color: var(--blue);
  font-size: 1.4rem;
  font-weight: 900;
}
.noah-pick.on { background: var(--blue); color: #fff; }
.noah-stage { touch-action: none; }
.noah-svg { left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; }
.noah-edge { fill: none; stroke: rgba(122, 86, 44, 0.35); stroke-width: 66; stroke-linecap: round; stroke-linejoin: round; }
.noah-road { fill: none; stroke: #E9D3A6; stroke-width: 58; stroke-linecap: round; stroke-linejoin: round; }
.noah-trail { fill: none; stroke: #F8A647; stroke-width: 20; stroke-linecap: round; stroke-linejoin: round; opacity: 0.85; }
.noah-dashes { fill: none; stroke: #B8955E; stroke-width: 4; stroke-linecap: round; stroke-dasharray: 2 18; }
.noah-courage { z-index: 3; pointer-events: none; filter: drop-shadow(0 4px 4px rgba(59, 13, 7, 0.3)); }

/* Learning Center button picture */
.learn-art {
  background: linear-gradient(135deg, #E3F2FD, #FDF5E1);
  font-weight: 900;
  line-height: 1.05;
  font-size: clamp(1.7rem, 8vw, 2.8rem);
}
.learn-art span:first-child { color: var(--blue); }
.learn-art span:last-child { color: var(--fur); }

/* ---------- Shapes in God's Creation ---------- */
.shapes-art { background: #FDF5E1; padding: 10px; }
.shapes-art svg { width: 100%; height: 100%; }
.shapes-trace, .shapes-pattern { display: grid; justify-items: center; gap: 8px; width: 100%; }
.shapes-trace[hidden], .shapes-pattern[hidden] { display: none; }
.shapes-name { margin: 0; color: var(--blue); font-weight: 900; font-size: clamp(1.4rem, 6vw, 2rem); }
#shapes .abc-svg { width: min(100%, calc(100dvh - 260px)); }
.shape-pick { padding: 8px; }
.shape-pick svg { width: 100%; height: 100%; }
.pattern-pick { font-size: 1.7rem; }
.pattern-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  width: min(100%, 560px);
  padding: 12px;
  background: var(--card);
  border-radius: 22px;
  box-shadow: var(--shadow);
}
.pattern-cell { aspect-ratio: 1; display: grid; place-items: center; }
.pattern-cell svg { width: 100%; height: 100%; }
.pattern-cell.empty {
  border: 3px dashed #B9B2A8;
  border-radius: 12px;
  color: #B9B2A8;
  font-weight: 900;
  font-size: 1.6rem;
}
.pattern-choices { display: flex; gap: 16px; margin-top: 10px; }
.pattern-choice {
  width: clamp(76px, 22vw, 110px); aspect-ratio: 1;
  padding: 12px;
  border: 3px solid var(--cream);
  border-radius: 22px;
  background: var(--card);
  box-shadow: var(--shadow);
}
.pattern-choice svg { width: 100%; height: 100%; }
.pattern-choice.wiggle { animation: wiggle 0.5s ease; }
.pattern-count { margin: 0; color: #9A8F82; font-weight: 700; }
@media (prefers-reduced-motion: reduce) { .pattern-choice.wiggle { animation: none; } }

/* ---------- Count the Stars ---------- */
#stars {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "tools" "stage";
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overflow: hidden;
  background: #0B1E4F;
}
#stars .toolbar { grid-area: tools; justify-content: space-between; }
#stars .pattern-count { color: #E6ECFF; }
.stars-stage { touch-action: manipulation; }
.star-btn {
  z-index: 2;
  padding: 0;
  border: none;
  background: none;
  animation: twinkle 2.4s ease-in-out infinite;
}
.star-btn::after { content: ''; position: absolute; inset: -30%; }   /* bigger tap area */
.star-btn svg { width: 100%; height: 100%; overflow: visible; }
.star-btn path { fill: #FFF3B0; stroke: #FFE066; stroke-width: 4; stroke-linejoin: round; filter: drop-shadow(0 0 6px rgba(255, 236, 140, 0.8)); }
.star-btn.counted { animation: none; }
.star-btn.counted path { fill: #FFD43B; stroke: #fff; filter: drop-shadow(0 0 12px rgba(255, 212, 59, 1)); }
.star-num {
  position: absolute;
  left: 50%; top: 56%;
  transform: translate(-50%, -50%);
  color: #3B0D07;
  font-weight: 900;
  font-size: clamp(0.8rem, 3.6vw, 1.3rem);
  pointer-events: none;
}
@keyframes twinkle { 0%, 100% { transform: scale(1); opacity: 0.85; } 50% { transform: scale(1.12); opacity: 1; } }
.stars-courage { z-index: 1; pointer-events: none; }
.stars-ask {
  position: absolute;
  left: 50%; bottom: 14px;
  transform: translateX(-50%);
  z-index: 10;
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 12px 18px 16px;
  border-radius: 24px;
  background: var(--card);
  box-shadow: var(--shadow);
}
.stars-ask[hidden] { display: none; }
.stars-ask .pattern-choices { margin-top: 4px; }
.stars-choice {
  width: clamp(64px, 18vw, 88px); aspect-ratio: 1;
  border: 3px solid var(--cream);
  border-radius: 20px;
  background: #FFF7D6;
  color: var(--blue);
  font-size: clamp(1.8rem, 8vw, 2.6rem);
  font-weight: 900;
  box-shadow: var(--shadow);
}
.stars-choice.right { background: #2E9E4F; color: #fff; }
.stars-choice.wiggle { animation: wiggle 0.5s ease; }
@media (prefers-reduced-motion: reduce) { .star-btn, .stars-choice.wiggle { animation: none; } }

/* ---------- Bible Trivia ---------- */
.trivia-art { position: relative; background: linear-gradient(135deg, #E3F2FD, #FDF5E1); padding: 12%; }
.activity-card .trivia-art img { width: 100%; height: 100%; object-fit: contain; aspect-ratio: auto; border-radius: 0; }
.trivia-badge {
  position: absolute;
  right: 8%; top: 8%;
  width: 34%; aspect-ratio: 1;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--blue);
  border: 3px solid #fff;
  color: #FFD43B;
  font-weight: 900;
  font-size: clamp(1.4rem, 7vw, 2.4rem);
  line-height: 1;
}
#trivia {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "tools" "body";
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: radial-gradient(ellipse at 50% 35%, #FFFFFF 0%, var(--cream) 75%);
}
#trivia .toolbar { grid-area: tools; justify-content: space-between; }
.trivia-dots { display: flex; gap: 6px; }
.trivia-dot { width: 12px; height: 12px; border-radius: 50%; background: #E2D8C8; }
.trivia-dot.done { background: #2E9E4F; }
.trivia-dot.now { background: var(--blue); transform: scale(1.25); }
.trivia-body {
  grid-area: body;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 22px;
  padding: 8px 12px 24px;
  min-height: 0;
  overflow-y: auto;
}
.trivia-question {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: min(100%, 640px);
  padding: 12px 12px 12px 8px;
  border-radius: 24px;
  background: var(--card);
  box-shadow: var(--shadow);
}
.trivia-courage { width: clamp(64px, 18vw, 96px); }
.trivia-q { margin: 0; color: var(--blue); font-weight: 900; font-size: clamp(1.3rem, 6vw, 2rem); line-height: 1.2; }
.trivia-say { position: static; }
.trivia-choices {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  width: min(100%, 640px);
}
.trivia-choice {
  aspect-ratio: 1;
  padding: 8px;
  border: 4px solid var(--cream);
  border-radius: 22px;
  background: var(--card);
  box-shadow: var(--shadow);
}
.trivia-choice.right { border-color: #2E9E4F; box-shadow: 0 0 0 5px rgba(46, 158, 79, 0.3); }
.trivia-choice.wiggle { animation: wiggle 0.5s ease; }
.trivia-pic { display: grid; place-items: center; width: 100%; height: 100%; }
.trivia-pic img { width: 100%; height: 100%; object-fit: contain; }
.trivia-choice .trivia-pic.stand-in { font-size: clamp(2rem, 10vw, 4rem); line-height: 1; }
@media (prefers-reduced-motion: reduce) { .trivia-choice.wiggle { animation: none; } }

/* ---------- Seasonal Activities ---------- */
.season + .season { margin-top: 26px; }
.season[hidden], .season-title[hidden] { display: none; }
.season-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0 12px;
  color: var(--mane);
  font-size: clamp(1.4rem, 6vw, 2rem);
  font-weight: 900;
}
.season.now .season-title::after {
  content: 'Now';
  padding: 3px 10px;
  border-radius: 999px;
  background: #2E9E4F;
  color: #fff;
  font-size: 0.55em;
  font-weight: 800;
  letter-spacing: 0.04em;
}

#sling { touch-action: none; }

.big-btn.hear { background: #E8892B; }

/* Sling: the line kids draw for the stone to follow */
.sling-aim .draw-edge { fill: none; stroke: rgba(11, 82, 172, 0.45); stroke-width: 16; stroke-linecap: round; stroke-linejoin: round; }
.sling-aim .draw-line { fill: none; stroke: #fff; stroke-width: 8; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 2 16; }

/* ---------- Advent Calendar ---------- */
#advent {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "tools" "stage";
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overflow: hidden;
  background: #0B1E4F;
}
#advent .toolbar { grid-area: tools; }
.advent-doors {
  position: absolute;
  left: 5%; right: 5%; top: 3.5%; height: 64%;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(5, 1fr);
  gap: 2.4%;
}
.advent-door {
  position: relative;
  border: 3px solid rgba(255, 255, 255, 0.85);
  border-radius: 14px;
  background: var(--c) center / cover no-repeat;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
  color: #fff;
  font-weight: 900;
  font-size: clamp(1.1rem, 6.5vw, 2.2rem);
  padding: 0;
  transform-origin: left center;
}
.advent-door .advent-num { text-shadow: 0 2px 3px rgba(0, 0, 0, 0.45); }
.advent-door.locked { filter: saturate(0.55) brightness(0.8); }
.advent-door.open { border-color: #FFD43B; }
.advent-door.open .advent-num {
  position: absolute; left: 4px; top: 2px;
  font-size: 0.55em;
  padding: 1px 6px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.45);
}
.advent-door.today { animation: door-glow 1.6s ease-in-out infinite; }
@keyframes door-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 212, 59, 0.9); }
  50% { box-shadow: 0 0 0 8px rgba(255, 212, 59, 0); }
}
.advent-door.opening { animation: door-open 0.45s ease-in forwards; }
@keyframes door-open { to { transform: perspective(400px) rotateY(-80deg); opacity: 0.4; } }
.advent-door.wiggle { animation: wiggle 0.5s ease; }
.advent-note {
  position: absolute;
  left: 50%; top: 70%;
  transform: translateX(-50%);
  margin: 0;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  font-weight: 800;
  white-space: nowrap;
}
.advent-note[hidden] { display: none; }
.advent-view .advent-card {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 10px;
  width: min(92vw, 520px);
  max-height: 92dvh;
  overflow-y: auto;
  padding: 16px;
  border-radius: 26px;
  background: var(--card);
  box-shadow: var(--shadow);
}
.advent-day { margin: 0; color: #C62828; font-weight: 900; font-size: 1.3rem; }
.advent-pic { width: 100%; border-radius: 18px; }
.advent-line { margin: 0; color: var(--blue); font-weight: 800; font-size: clamp(1.2rem, 5.5vw, 1.6rem); line-height: 1.3; text-align: center; }
.advent-ref { margin: 0; color: #9A8F82; font-weight: 700; }
@media (prefers-reduced-motion: reduce) { .advent-door.today, .advent-door.opening, .advent-door.wiggle { animation: none; } }

/* ---------- Build the Nativity ---------- */
#nativity {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "tools" "stage" "tray";
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overflow: hidden;
  background: #0B1E4F;
}
#nativity .toolbar { grid-area: tools; justify-content: space-between; }
#nativity .stage-wrap { grid-area: stage; }
.nativity-piece { position: absolute; object-fit: contain; pointer-events: none; filter: drop-shadow(0 4px 5px rgba(0, 0, 0, 0.35)); }
.nativity-piece[hidden] { display: none; }
.nativity-tray {
  grid-area: tray;
  display: flex;
  gap: 8px;
  padding: 8px 12px 12px;
  overflow-x: auto;
  scrollbar-width: none;
}
.nativity-tray::-webkit-scrollbar { display: none; }
.nativity-pick {
  flex: none;
  width: 74px; height: 74px;
  padding: 6px;
  border: 3px solid #FFD43B;
  border-radius: 18px;
  background: var(--card);
  box-shadow: var(--shadow);
}
.nativity-pick img { width: 100%; height: 100%; object-fit: contain; }
.nativity-pick:disabled { opacity: 0.25; border-color: transparent; }

.xverses-art { background: linear-gradient(135deg, #FDECEA, #E8F5E9); }
.xverses-art span:first-child { color: #C62828; }

#advent .toolbar { justify-content: space-between; }
.tool.advent-close-all { width: auto; display: flex; align-items: center; gap: 6px; padding: 0 14px; font-weight: 800; color: var(--blue); }
.advent-door.closing { animation: door-close 0.45s ease-out forwards; }
@keyframes door-close { from { transform: perspective(400px) rotateY(-80deg); opacity: 0.4; } to { transform: none; opacity: 1; } }

.advent-story-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 20px;
  border: none;
  border-radius: 999px;
  background: #C62828;
  color: #fff;
  font-weight: 800;
  font-size: 1.1rem;
  box-shadow: var(--shadow);
}
.advent-story-btn[hidden] { display: none; }
.advent-story-btn svg { width: 26px; height: 26px; fill: none; stroke: #fff; stroke-width: 2; stroke-linejoin: round; }
.advent-story-btn .story-stop { display: none; }
.telling .advent-story-btn { background: #6B4A2A; }
.telling .advent-story-btn .story-play { display: none; }
.telling .advent-story-btn .story-stop { display: inline; }

/* ---------- Spoken hints ---------- */
.hint-bubble {
  position: fixed;
  left: 50%; top: calc(env(safe-area-inset-top) + 74px);
  transform: translateX(-50%);
  z-index: 50;
  display: flex; align-items: center; gap: 10px;
  max-width: calc(100vw - 32px);
  padding: 10px 18px 10px 12px;
  border: 3px solid #fff;
  border-radius: 22px;
  background: var(--blue);
  color: #fff;
  font-weight: 800;
  font-size: clamp(1rem, 4.6vw, 1.25rem);
  text-align: left;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
  animation: pop-in 0.4s cubic-bezier(.2, .8, .3, 1.3) both;
}
.hint-bubble[hidden] { display: none; }
.hint-bubble svg { flex: none; width: 26px; height: 26px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- For Parents ---------- */
.parents-link {
  display: block;
  width: fit-content;
  margin: 22px auto 6px;
  padding: 10px 22px;
  border-radius: 999px;
  background: var(--card);
  box-shadow: var(--shadow);
  color: var(--blue);
  font-weight: 800;
  text-decoration: none;
}
.parents-text {
  max-width: 640px;
  padding: 4px 6px 30px;
  color: var(--ink);
  font-size: 1.05rem;
  line-height: 1.55;
}
.parents-text h2 { margin: 18px 0 6px; color: var(--mane); font-size: 1.3rem; }
.parents-text a { color: var(--blue); font-weight: 800; }
.parents-books { margin: 0; padding-left: 22px; }
.parents-text .niv-notice { font-size: 0.85rem; opacity: 0.8; margin-top: -4px; }
.parents-text .legal-links { text-align: center; font-size: 0.95rem; margin-top: 18px; }

/* ---------- Advent Wreath ---------- */
#wreath {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "tools" "stage" "card";
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overflow: hidden;
  background: #4A2E1A;
}
#wreath .toolbar { justify-content: space-between; }
.wreath-note { top: 18%; }
.wreath-candle {
  padding: 0;
  border: none;
  border-radius: 24px;
  background: transparent;
  -webkit-tap-highlight-color: transparent;
}
.wreath-candle.next { animation: candle-glow 1.6s ease-in-out infinite; }
.wreath-candle.hey { animation: candle-hey 0.45s ease-in-out 3; }
.wreath-candle.nope { animation: candle-nope 0.5s ease; }
@keyframes candle-glow {
  0%, 100% { box-shadow: inset 0 0 0 3px rgba(255, 212, 59, 0.85), 0 0 6px 2px rgba(255, 212, 59, 0.3); background: rgba(255, 230, 140, 0.05); }
  50% { box-shadow: inset 0 0 0 4px rgba(255, 212, 59, 1), 0 0 26px 10px rgba(255, 212, 59, 0.6); background: rgba(255, 230, 140, 0.22); }
}
@keyframes candle-hey {
  0%, 100% { box-shadow: inset 0 0 0 4px #FFD43B, 0 0 10px 4px rgba(255, 212, 59, 0.5); }
  50% { box-shadow: inset 0 0 0 6px #FFD43B, 0 0 34px 16px rgba(255, 212, 59, 0.9); background: rgba(255, 230, 140, 0.3); }
}
@keyframes candle-nope {
  0%, 100% { transform: translateX(0); box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.5); }
  25% { transform: translateX(-5px); } 75% { transform: translateX(5px); }
}
.wreath-flame {
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  transform: scale(0.1);
  transform-origin: 50% 100%;
  transition: opacity 0.35s ease, transform 0.5s cubic-bezier(.2, .8, .3, 1.4);
}
.wreath-flame.lit { opacity: 1; transform: scale(1); }
.wreath-flame.out { opacity: 0; transform: scale(0.1) translateY(-20%); transition-duration: 0.4s; }
.wreath-flame::before {   /* warm glow around the flame */
  content: '';
  position: absolute;
  left: 50%; top: 50%;
  width: 380%; height: 230%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 220, 120, 0.6), rgba(255, 190, 80, 0.2) 60%, rgba(255, 180, 60, 0));
}
.wreath-flame::after {    /* the flame */
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50% 50% 46% 46% / 64% 64% 36% 36%;
  background: radial-gradient(ellipse at 50% 74%, #FFFFF0 0 16%, #FFE57F 30%, #FFB300 58%, #F4511E 88%);
  box-shadow: 0 0 10px 3px rgba(255, 196, 70, 0.7);
  transform-origin: 50% 100%;
  animation: flicker 0.9s ease-in-out infinite alternate;
}
@keyframes flicker {
  0% { transform: scale(1, 1) skewX(0deg); }
  30% { transform: scale(0.96, 1.07) skewX(2deg); }
  65% { transform: scale(1.03, 0.95) skewX(-2deg); }
  100% { transform: scale(0.98, 1.04) skewX(1deg); }
}
.wreath-card {
  grid-area: card;
  position: relative;
  z-index: 6;
  display: grid;
  justify-items: center;
  gap: 4px;
  margin: 0 12px 12px;
  padding: 12px 16px 14px;
  max-height: 46dvh;
  overflow-y: auto;
  border-radius: 24px;
  background: var(--card);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
  text-align: center;
  animation: pop-in 0.45s cubic-bezier(.2, .8, .3, 1.3) both;
}
.wreath-card[hidden] { display: none; }
.wreath-week { margin: 0; color: #C62828; font-weight: 900; font-size: 1rem; }
.wreath-theme { margin: 0; color: var(--blue); font-weight: 900; font-size: clamp(1.8rem, 9vw, 2.4rem); line-height: 1.1; }
.wreath-card.christ .wreath-theme { font-size: clamp(1.4rem, 7vw, 2rem); }
.wreath-lead { display: block; font-weight: 800; color: var(--mane); }
.wreath-lead[hidden] { display: none; }
.wreath-buttons { display: flex; gap: 22px; margin-top: 6px; }
.wreath-buttons .big-btn { width: 64px; height: 64px; }
.wreath-buttons .big-btn svg { width: 34px; height: 34px; }
#wreath .confetti { z-index: 7; }
@media (prefers-reduced-motion: reduce) {
  .wreath-candle.next, .wreath-candle.hey, .wreath-candle.nope, .wreath-flame::after, .wreath-card { animation: none; }
}

/* ---------- For Parents: Your plan (paid app only) ---------- */
.my-plan { background: var(--card); border-radius: 16px; box-shadow: var(--shadow); padding: 4px 16px 12px; margin-bottom: 8px; }
.my-plan h2 { margin-top: 12px; }
.my-plan p { margin: 6px 0; }
.my-plan-button {
  display: block; width: 100%; margin: 12px 0 6px; border: 0; border-radius: 99px; padding: 13px 18px;
  background: var(--blue); color: #fff; font-weight: 800; font-size: 1.1rem; box-shadow: var(--shadow);
}
.my-plan-button[disabled] { opacity: 0.6; cursor: wait; }
.my-plan-fine { font-size: 0.95rem; opacity: 0.85; }
.my-plan-error { color: #B3261E; font-weight: 700; }
.my-plan-error:empty { display: none; }
.my-plan-links { font-size: 0.95rem; }
.linkish { background: none; border: 0; padding: 0; color: var(--blue); font-weight: 800; text-decoration: underline; }
