* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: linear-gradient(180deg, #07101f 0%, #0d1d34 40%, #13233b 100%);
  color: #fff;
  font-family: Arial, Helvetica, sans-serif;
}
.story { width: 100%; }
.panel {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 5vh 2vw;
}
.panel img {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 80vh;
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}
.panel.end {
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  font-weight: 700;
  text-align: center;
}
.end-text {
  background: rgba(255, 255, 255, 0.08);
  padding: 1.5rem 2.5rem;
  border-radius: 16px;
}

/* LSQS-STORY-TEXT-001: per-page narrative caption.
   When the story spec carries a per-page `text` field, the
   packager emits a <p class="page-text"> beneath the image.
   The caption is age-appropriate (large, calm, high-contrast on a
   translucent backdrop) and reads aloud well. The default font
   (Arial) is the parent body's font — no extra asset is loaded.
   The block is optional: stories without per-page text do not
   render the element, so legacy / audio-only stories are
   visually unchanged. */
.page-text {
  margin: 1.5rem auto 0;
  max-width: 38rem;
  padding: 1rem 1.5rem;
  background: rgba(255, 255, 255, 0.10);
  border-radius: 14px;
  font-size: clamp(1.05rem, 2.4vw, 1.4rem);
  line-height: 1.5;
  text-align: center;
  color: #fff;
  font-weight: 500;
  letter-spacing: 0.01em;
  text-wrap: balance;
  /* Soften the caption's backdrop so the image behind it stays
     the focal element on small screens. */
  backdrop-filter: blur(2px);
}
.page-text--missing {
  /* Defensive fallback for legacy stories that previously
     published page text into the prompt bundle but whose new
     run dropped the field. The packager itself NEVER emits
     .page-text--missing; only a downstream consumer (manual
     fix-up, future gate) should inject it. */
  font-style: italic;
  color: rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.04);
}

/* LSQS-094 / LSQS-VOICE-002b AC4: per-page narration controls. */
.audio-control {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
  padding: 0.5rem 0.75rem;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  backdrop-filter: blur(4px);
}
.audio-control audio { display: none; }
.audio-control .audio-play {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  font-size: 0.9rem;
  cursor: pointer;
  line-height: 1;
}
.audio-control .audio-play:hover {
  background: rgba(255, 255, 255, 0.32);
}
.audio-control .audio-volume {
  width: 8rem;
  accent-color: #fff;
  cursor: pointer;
}
.audio-control--missing {
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.85rem;
  font-style: italic;
}
.audio-control--missing .audio-missing-label {
  padding: 0 0.25rem;
}
