/* Main interface. Load activities.css after this file for activity internals. */
[hidden] { display: none !important; }

:root {
  color-scheme: light;
  --paper: #fbf7ee;
  --white: #fffef9;
  --ink: #294639;
  --green: #345847;
  --green-dark: #203d2f;
  --light-green: #e8efdf;
  --gold: #d79e36;
  --gold-light: #fff0cd;
  --muted: #5f7064;
  --line: #e1e5d8;
  --round: 28px;
  --shadow: 0 10px 30px rgb(41 70 57 / 8%);
  --font: "Avenir Next", "Trebuchet MS", ui-rounded, system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 18px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

button, input, select, textarea { font: inherit; }
button {
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
}
button:disabled { cursor: default; }
button, a { -webkit-touch-callout: none; }
button:focus-visible, a:focus-visible, [tabindex]:focus-visible {
  outline: 4px solid var(--gold);
  outline-offset: 5px;
}
main:focus { outline: none; }
img { display: block; max-width: 100%; height: auto; }
svg {
  display: block;
  width: 1.25em;
  height: 1.25em;
  max-width: 100%;
  flex: none;
}
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { font-weight: 800; text-wrap: balance; }
h1 {
  margin-bottom: 18px;
  font-size: clamp(32px, 3.6vw, 48px);
  line-height: 1.14;
  letter-spacing: -1.5px;
}
h2 { font-size: 28px; line-height: 1.22; letter-spacing: -.7px; }
p { margin-bottom: 20px; }

.app-shell {
  width: 100%;
  max-width: 1440px;
  margin-inline: auto;
  padding-top: env(safe-area-inset-top, 0px);
  padding-left: max(clamp(20px, 4vw, 56px), env(safe-area-inset-left, 0px));
  padding-right: max(clamp(20px, 4vw, 56px), env(safe-area-inset-right, 0px));
}
.site-header {
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 106px;
  border-bottom: 1px solid var(--line);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  flex: none;
  padding: 8px 0;
  border: 0;
  background: transparent;
  text-align: left;
  font-size: 21px;
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: -.6px;
}
.brand strong { font-weight: 850; }
.brand-icon { display: block; width: 48px; height: 48px; flex: none; }
.brand-icon > svg { width: 100%; height: 100%; }
.site-header nav {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-left: auto;
}
.round-button {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 48px;
  height: 48px;
  padding: 12px;
  border: 1px solid #d7dfce;
  border-radius: 50%;
  background: var(--white);
}
.round-button > span { display: block; width: 22px; height: 22px; }
.round-button svg { width: 22px; height: 22px; }
.round-button[aria-pressed="false"] { background: #f0f0e7; color: var(--muted); }
.parent-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 14px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  font-size: 15px;
  font-weight: 750;
}
.parent-button > span:first-child:has(svg) { width: 20px; height: 20px; }
.parent-button svg { width: 20px; height: 20px; }

#main {
  min-height: calc(100svh - 180px);
  padding-bottom: max(44px, calc(env(safe-area-inset-bottom, 0px) + 20px));
}
.library { padding-top: clamp(28px, 4vw, 48px); }
.library-heading { margin-bottom: 28px; }
.library-heading h1 { margin: 0; }
.story-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
  gap: 28px;
}
.story-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--round);
  background: var(--white);
  text-align: left;
  box-shadow: var(--shadow);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.cover-wrap {
  position: relative;
  flex: none;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--light-green);
}
.cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 46%;
}
.cover-play {
  position: absolute;
  right: 20px;
  bottom: 20px;
  display: grid;
  place-items: center;
  width: 66px;
  height: 66px;
  border: 3px solid rgb(255 255 255 / 90%);
  border-radius: 50%;
  background: var(--white);
  color: var(--green);
  box-shadow: 0 5px 18px rgb(30 50 30 / 20%);
}
.cover-play > svg { width: 28px; height: 28px; margin-left: 3px; }
.card-check {
  position: absolute;
  top: 16px;
  right: 16px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 2px solid var(--white);
  border-radius: 50%;
  background: var(--green);
  color: white;
  font-weight: 800;
  box-shadow: 0 3px 10px rgb(30 50 30 / 15%);
}
.card-check svg { width: 20px; height: 20px; }
.card-copy {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 1;
  gap: 18px;
  padding: 22px 26px;
}
.card-copy h2 { margin: 0; font-size: clamp(23px, 2.25vw, 30px); }
.card-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
  color: var(--muted);
  font-size: 16px;
  font-weight: 650;
  white-space: nowrap;
}
.card-meta > span, .detail-meta > span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.card-meta svg { width: 17px; height: 17px; }

.primary-button, .secondary-button, .listen-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 56px;
  padding: 14px 24px;
  border-radius: 17px;
  font-size: 18px;
  font-weight: 800;
  line-height: 1.25;
  text-align: center;
  transition: background .15s ease, transform .15s ease;
}
.primary-button {
  border: 0;
  border-bottom: 4px solid var(--green-dark);
  background: var(--green);
  color: white;
  box-shadow: 0 4px 12px rgb(41 70 57 / 9%);
}
.secondary-button, .listen-button {
  border: 1px solid #d4ddca;
  background: var(--white);
  color: var(--green);
}
.primary-button svg, .secondary-button svg, .listen-button svg {
  width: 22px;
  height: 22px;
}
.primary-button:active:not(:disabled), .secondary-button:active:not(:disabled),
.listen-button:active:not(:disabled) { transform: translateY(2px); }
.primary-button:disabled, .secondary-button:disabled { opacity: .6; }
.listen-button[aria-pressed="true"] { background: var(--light-green); }
.text-button {
  min-height: 44px;
  padding: 10px 4px;
  border: 0;
  background: transparent;
  font-size: 15px;
  font-weight: 750;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.stage { max-width: 1200px; margin-inline: auto; padding-top: 26px; }
.stage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}
.back-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: none;
  min-height: 48px;
  padding: 10px 0;
  border: 0;
  background: transparent;
  font-size: 16px;
  font-weight: 750;
}
.back-button svg { width: 20px; height: 20px; }
.stage-title { color: var(--muted); font-size: 15px; font-weight: 650; text-align: right; }
.detail-layout, .story-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(280px, .9fr);
  align-items: center;
  gap: clamp(28px, 4vw, 52px);
}
.detail-art, .story-art {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  border-radius: var(--round);
  background: var(--light-green);
  object-fit: cover;
  box-shadow: var(--shadow);
}
.detail-art > img, .story-art > img { width: 100%; height: 100%; object-fit: cover; }
.detail-copy, .story-copy { min-width: 0; }
.detail-copy h1, .story-copy h1 { font-size: clamp(34px, 3.5vw, 48px); }
.learn-line, .story-copy > p {
  max-width: 34ch;
  margin-bottom: 24px;
  color: var(--muted);
  font-size: 20px;
  line-height: 1.6;
  text-wrap: pretty;
}
.detail-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 28px;
  color: var(--muted);
  font-size: 16px;
}
.detail-meta svg { width: 19px; height: 19px; }
.detail-copy .primary-button { min-width: 190px; }
.story-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-top: 28px; }
.story-controls .primary-button { min-width: 160px; }

.game-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  column-gap: 24px;
  row-gap: 4px;
  margin-bottom: 24px;
}
.game-heading > h1 { grid-column: 1; grid-row: 1; margin-bottom: 4px; font-size: clamp(30px, 3vw, 40px); }
.game-heading > p { grid-column: 1; grid-row: 2; }
.game-heading > div:not(.game-progress) { grid-column: 1; grid-row: 1 / span 2; }
.game-heading h1 { margin-bottom: 8px; }
.game-heading p { margin: 0; color: var(--muted); font-size: 18px; line-height: 1.5; }
.game-progress {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  min-width: 140px;
  padding-block: 4px;
  text-align: right;
}
.game-progress strong { font-size: 17px; }
.progress-track {
  width: clamp(140px, 16vw, 190px);
  max-width: 100%;
  height: 10px;
  margin-top: 10px;
  margin-left: auto;
  overflow: hidden;
  border-radius: 20px;
  background: #e2e8d8;
}
.progress-fill { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--gold); transition: width .3s ease; }
.activity-shell {
  min-width: 0;
  padding: clamp(16px, 2.2vw, 28px);
  border: 1px solid var(--line);
  border-radius: var(--round);
  background: var(--white);
  box-shadow: var(--shadow);
}
.game-feedback {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 62px;
  margin-top: 10px;
  padding: 12px 4px;
  font-size: 18px;
  font-weight: 750;
  line-height: 1.5;
  text-align: center;
}
.game-feedback svg { width: 23px; height: 23px; }
.next-row { display: flex; align-items: center; justify-content: center; gap: 12px; padding-top: 10px; }
.next-row .primary-button { min-width: 180px; }

.quiz-wrap, .result-wrap { max-width: 860px; margin: 12px auto 0; text-align: center; }
.quiz-wrap > h1, .result-wrap > h1 { font-size: clamp(32px, 3.5vw, 44px); }
.quiz-wrap > p, .result-wrap > p {
  max-width: 40ch;
  margin: 0 auto 22px;
  color: var(--muted);
  font-size: 19px;
  line-height: 1.55;
}
.quiz-wrap > .listen-button { margin-bottom: 4px; }
.quiz-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 20px;
  margin-top: 28px;
}
.quiz-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  min-width: 0;
  min-height: 230px;
  padding: 24px 18px;
  border: 2px solid #dae2ce;
  border-bottom: 5px solid #ccd8be;
  border-radius: 24px;
  background: var(--white);
  font-size: 19px;
  font-weight: 800;
  line-height: 1.35;
  text-align: center;
  transition: background .15s ease, border-color .15s ease, transform .15s ease;
}
.quiz-option.selected, .quiz-option[aria-pressed="true"] { border-color: var(--gold); background: var(--gold-light); }
.quiz-option.correct { border-color: var(--green); background: var(--light-green); }
.quiz-option.wrong { border-color: #a36749; background: #fff0e6; }
.quiz-option:disabled { opacity: 1; }
.option-art {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 126px;
  gap: 8px;
}
.option-art > img, .option-art > svg { width: auto; max-width: 100%; height: 100%; object-fit: contain; }
.option-art > svg { width: 144px; }
.quiz-feedback { min-height: 58px; margin-top: 20px; font-size: 18px; font-weight: 750; line-height: 1.5; }
.quiz-next { display: flex; justify-content: center; padding-top: 8px; }
.result-art {
  display: grid;
  place-items: center;
  width: min(100%, 300px);
  height: 190px;
  margin: 0 auto 26px;
}
.result-art > img, .result-art > svg { width: auto; max-width: 100%; height: 100%; object-fit: contain; }
.result-art > svg { width: 260px; }
.lesson-card {
  max-width: 670px;
  margin: 20px auto;
  padding: 24px 28px;
  border: 1px solid #dbe3cd;
  border-radius: 24px;
  background: var(--light-green);
  text-align: left;
}
.lesson-card + .lesson-card { border-color: #eadbb8; background: #fff1d7; }
.lesson-card h2 { margin-bottom: 10px; font-size: 23px; }
.lesson-card p { margin: 0; color: #4c6453; font-size: 18px; line-height: 1.6; }
.result-buttons { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 12px; margin-top: 28px; }

footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 0 max(22px, env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}
footer > span:last-child { display: flex; align-items: center; gap: 7px; }
footer svg { width: 16px; height: 16px; color: var(--gold); }

dialog {
  position: fixed;
  inset: 0;
  width: calc(100% - 36px);
  max-width: 640px;
  max-height: min(85dvh, 820px);
  margin: auto;
  padding: 38px;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line);
  border-radius: var(--round);
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 24px 80px rgb(22 43 31 / 25%);
}
dialog::backdrop { background: rgb(28 48 35 / 48%); backdrop-filter: blur(4px); }
dialog h2 { margin-bottom: 18px; padding-right: 30px; font-size: 30px; }
dialog > p { color: var(--muted); font-size: 17px; line-height: 1.65; }
.dialog-close { position: absolute; top: 14px; right: 14px; }
.parent-note { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--line); }
.parent-note strong, .parent-note h3 { font-size: 17px; font-weight: 800; }
.parent-note p { margin: 8px 0 0; color: var(--muted); font-size: 16px; line-height: 1.65; }
.small-print { margin-top: 22px; font-size: 13px !important; line-height: 1.65 !important; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 26px; }
.dialog-actions > button { flex: 1; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  border: 0;
  white-space: nowrap;
}
.fade-in { animation: enter .24s ease-out; }
@keyframes enter { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

@media (hover: hover) and (pointer: fine) {
  .story-card:hover { transform: translateY(-3px); border-color: #b2c6a2; box-shadow: 0 14px 34px rgb(41 70 57 / 12%); }
  .primary-button:hover:not(:disabled) { background: #406850; }
  .secondary-button:hover:not(:disabled), .listen-button:hover:not(:disabled), .round-button:hover { background: #edf2e5; }
  .parent-button:hover { background: #edf2e5; }
  .quiz-option:hover:not(:disabled) { transform: translateY(-2px); border-color: #9eb88b; background: #f2f5e9; }
  .quiz-option.selected:hover { background: var(--gold-light); border-color: var(--gold); }
}

@media (max-width: 1000px) {
  .story-grid { gap: 22px; }
  .card-copy { padding: 19px 20px; gap: 12px; }
  .card-meta { font-size: 14px; }
  .detail-layout, .story-layout { grid-template-columns: minmax(0, 1.15fr) minmax(260px, .95fr); gap: 28px; }
  .learn-line, .story-copy > p { font-size: 18px; }
  .detail-copy h1, .story-copy h1 { font-size: 36px; }
}

@media (max-width: 720px) {
  .app-shell {
    padding-left: max(18px, env(safe-area-inset-left, 0px));
    padding-right: max(18px, env(safe-area-inset-right, 0px));
  }
  .site-header { min-height: 88px; gap: 12px; }
  .brand { gap: 9px; font-size: 18px; }
  .brand-icon { width: 41px; height: 41px; }
  .site-header nav { gap: 7px; }
  .round-button { width: 44px; height: 44px; padding: 10px; }
  .parent-button { min-height: 44px; padding: 10px 6px; gap: 6px; font-size: 14px; }
  .parent-button svg { width: 18px; height: 18px; }
  h1 { letter-spacing: -.9px; }
  .library { padding-top: 26px; }
  .library-heading { margin-bottom: 22px; }
  .library-heading h1 { font-size: 32px; }
  .story-grid { grid-template-columns: minmax(0, 1fr); gap: 22px; }
  .story-card { border-radius: 24px; }
  .cover-wrap { aspect-ratio: 3 / 2; }
  .cover-play { width: 60px; height: 60px; right: 16px; bottom: 16px; }
  .cover-play svg { width: 25px; height: 25px; }
  .card-copy { padding: 19px 20px; }
  .card-copy h2 { font-size: 26px; }
  .card-meta { font-size: 14px; }
  .stage { padding-top: 18px; }
  .stage-header { margin-bottom: 18px; gap: 12px; }
  .back-button { font-size: 15px; }
  .stage-title { font-size: 13px; }
  .detail-layout, .story-layout { grid-template-columns: minmax(0, 1fr); gap: 26px; }
  .detail-art, .story-art { border-radius: 24px; }
  .detail-copy, .story-copy { width: 100%; max-width: 560px; }
  .detail-copy h1, .story-copy h1 { font-size: 35px; margin-bottom: 16px; }
  .learn-line, .story-copy > p { max-width: none; font-size: 19px; line-height: 1.55; margin-bottom: 22px; }
  .detail-meta { margin-bottom: 24px; font-size: 15px; }
  .story-controls { margin-top: 24px; }
  .game-heading { grid-template-columns: minmax(0, 1fr); gap: 10px; margin-bottom: 20px; }
  .game-heading > h1 { font-size: 31px; }
  .game-heading p { font-size: 17px; }
  .game-progress { grid-column: 1; grid-row: auto; display: flex; align-items: center; gap: 12px; min-width: 0; padding: 4px 0 0; text-align: left; }
  .game-progress strong { flex: none; font-size: 15px; }
  .progress-track { flex: 1; max-width: 220px; width: auto; height: 9px; margin: 0; }
  .activity-shell { padding: 16px; border-radius: 24px; }
  .game-feedback { font-size: 17px; }
  .quiz-wrap, .result-wrap { margin-top: 6px; }
  .quiz-wrap > h1, .result-wrap > h1 { font-size: 33px; }
  .quiz-wrap > p, .result-wrap > p { font-size: 18px; }
  .quiz-options { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-top: 24px; }
  .quiz-option { min-height: 192px; padding: 18px 10px; gap: 14px; border-radius: 20px; font-size: 17px; }
  .option-art { height: 105px; }
  .quiz-feedback { font-size: 17px; }
  .result-art { width: 250px; height: 165px; }
  .lesson-card { padding: 21px 22px; border-radius: 22px; }
  .lesson-card h2 { font-size: 22px; }
  .lesson-card p { font-size: 17px; }
  .result-buttons { gap: 10px; }
  footer { align-items: flex-start; font-size: 12px; }
  footer > span:last-child { max-width: 170px; text-align: right; }
  dialog { width: calc(100% - 28px); max-height: 88dvh; padding: 34px 24px 26px; border-radius: 24px; }
  dialog h2 { font-size: 27px; }
  .dialog-close { right: 10px; top: 10px; }
  .dialog-actions { flex-direction: column; }
  .dialog-actions > button { width: 100%; }
}

@media (max-width: 380px) {
  .app-shell { padding-left: max(14px, env(safe-area-inset-left, 0px)); padding-right: max(14px, env(safe-area-inset-right, 0px)); }
  .site-header { gap: 8px; }
  .brand { font-size: 16px; gap: 7px; }
  .brand-icon { width: 36px; height: 36px; }
  .parent-button { font-size: 13px; padding-inline: 4px; }
  .parent-button > span:first-child:has(svg) { display: none; }
  .parent-button > svg { display: none; }
  .site-header nav { gap: 4px; }
  .library-heading h1 { font-size: 29px; }
  .card-copy { padding: 17px 16px; gap: 10px; }
  .card-copy h2 { font-size: 23px; }
  .card-meta { font-size: 13px; }
  .card-meta svg { width: 15px; height: 15px; }
  .cover-play { width: 54px; height: 54px; }
  .primary-button, .secondary-button, .listen-button { min-height: 54px; padding: 13px 19px; font-size: 17px; }
  .quiz-options { grid-template-columns: repeat(auto-fit, minmax(124px, 1fr)); }
  .quiz-option { font-size: 16px; min-height: 178px; }
  .option-art { height: 96px; }
  .story-controls { gap: 10px; }
  .story-controls .primary-button { min-width: 140px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

#main:focus{outline:none;box-shadow:none}

/* Read one illustrated scene at a time, in the child's own rhythm. */
.storybook .story-art { object-fit: contain; }
.scene-counter { display: flex; align-items: center; justify-content: space-between; gap: 18px; max-width: 450px; margin-bottom: 20px; font-size: 15px; font-weight: 750; color: var(--muted); }
.scene-dots { display: flex; gap: 7px; align-items: center; }
.scene-dots i { display: block; width: 9px; height: 9px; border-radius: 50%; background: #dce4d3; }
.scene-dots i.seen { background: #a0b693; }
.scene-dots i.current { background: var(--green); width: 22px; border-radius: 8px; }
.word-card { max-width: 450px; margin-top: 22px; padding: 17px 20px; border-radius: 19px; border: 1px solid #ecddb9; background: #fff3d9; }
.word-card strong { display: block; margin-bottom: 5px; color: #6d542c; font-size: 18px; }
.word-card p { margin: 0; color: #6b6048; font-size: 16px; line-height: 1.55; }
.storybook .story-copy > p { color: var(--ink); }
.storybook .story-controls { flex-wrap: wrap; gap: 10px; }
.storybook .story-controls .primary-button { min-width: 160px; }
.storybook .story-controls .secondary-button { padding-inline: 17px; }
.storybook .story-controls .secondary-button:disabled { opacity: .42; }
.activity-label { color: var(--muted); font-size: 15px; font-weight: 750; margin-bottom: 14px; }
@media (max-width: 720px) {
  .storybook .story-layout { gap: 23px; }
  .scene-counter { margin-bottom: 14px; font-size: 14px; }
  .word-card { max-width: none; padding: 15px 17px; margin-top: 18px; }
  .word-card strong { font-size: 17px; }
  .word-card p { font-size: 16px; }
  .storybook .story-copy h1 { font-size: 32px; }
  .storybook .story-controls { margin-top: 22px; }
  .storybook .story-controls .primary-button { flex: 1; min-width: 0; }
  .storybook .story-controls .secondary-button { padding-inline: 14px; font-size: 16px; }
}

.video-stage { text-align: center; }
.video-stage .stage-header { text-align: left; }
.video-stage h1 { margin: 20px 0 22px; }
.intro-video-frame { width: fit-content; max-width: 100%; margin: 0 auto; border-radius: 26px; overflow: hidden; background: #e8efdf; box-shadow: var(--shadow); }
.intro-video-frame video { display: block; width: auto; max-width: min(100%, 380px); height: min(63vh, 620px); aspect-ratio: 480/854; object-fit: contain; }
.video-stage .next-row { justify-content: center; margin-top: 22px; }
@media(max-width:600px) { .intro-video-frame { border-radius: 20px; } .intro-video-frame video { height: min(60vh, 540px); max-width: 100%; } .video-stage h1 { font-size: 30px; } }

.brand { padding-block: 6px; }
.brand-logo { display: block; width: 166px; height: auto; object-fit: contain; }
@media(max-width:600px) { .brand-logo { width: 135px; } .brand { padding-block: 5px; } }

/* =====================================================================
   v4 — interface para pré-leitores: cabeçalho compacto, barra de ações fixa,
   botões-ícone grandes, tela sem rolagem nas cenas e brincadeiras.
   ===================================================================== */
:root { --bar-h: 92px; --head-h: 64px; --pulse: #f4bf4e; }
body:not([data-screen="home"]) .site-header { min-height: var(--head-h); }
body:not([data-screen="home"]) .brand-logo { width: 112px; }
#main { min-height: 0; padding-bottom: calc(var(--bar-h) + env(safe-area-inset-bottom, 0px) + 12px); }
body[data-screen="home"] #main { padding-bottom: 32px; }

.stage { padding-top: 10px; }
.stage-header { margin-bottom: 8px; min-height: 44px; }
.back-button { min-height: 44px; padding: 6px 10px 6px 0; }

/* ----- Barra de ações fixa ----- */
.action-bar {
  position: fixed; z-index: 30; left: 0; right: 0; bottom: 0;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 14px;
  padding: 10px max(18px, env(safe-area-inset-left, 0px)) calc(10px + env(safe-area-inset-bottom, 0px)) max(18px, env(safe-area-inset-right, 0px));
  background: color-mix(in srgb, var(--paper) 94%, transparent);
  border-top: 1px solid var(--line);
  box-shadow: 0 -6px 20px rgb(41 70 57 / 7%);
  backdrop-filter: blur(6px);
}
.action-bar > :first-child { justify-self: start; }
.action-bar > :last-child { justify-self: end; }
.prev-small, .listen-big, .next-big {
  display: inline-grid; place-items: center; border: 0; border-radius: 999px; padding: 0;
  transition: transform .12s ease, background .15s ease, opacity .15s ease;
}
.prev-small { width: 58px; height: 58px; background: var(--white); border: 2px solid #d4ddca; color: var(--green); }
.prev-small svg { width: 28px; height: 28px; }
.prev-small:disabled { opacity: .3; }
.listen-big { position: relative; width: 66px; height: 66px; background: var(--gold-light); border: 2px solid #ecd39b; color: #8a5f12; }
.listen-big svg { width: 32px; height: 32px; }
.listen-big[aria-pressed="true"]::after {
  content: ""; position: absolute; inset: -7px; border-radius: inherit; border: 3px solid var(--gold);
  animation: ring 1.2s ease-out infinite;
}
@keyframes ring { from { opacity: .9; transform: scale(.92); } to { opacity: 0; transform: scale(1.18); } }
.next-big {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-width: 84px; height: 76px; padding: 0 22px;
  background: var(--green); color: #fff; border-bottom: 5px solid var(--green-dark);
  font-size: 18px; font-weight: 800;
  box-shadow: 0 6px 16px rgb(41 70 57 / 22%);
}
.next-big svg { width: 38px; height: 38px; }
.next-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (min-width: 720px) and (min-height: 560px) { .next-label { position: static; width: auto; height: auto; overflow: visible; clip: auto; } }
.prev-small:active:not(:disabled), .listen-big:active, .next-big:active { transform: scale(.94); }
.narration-done .next-big:not([hidden]), .sound-off .next-big:not([hidden]) { animation: nudge 1.6s ease-in-out infinite; }
#reviewButton:not([hidden]), #quizNext:not([hidden]) { animation: nudge 1.6s ease-in-out infinite; }
@keyframes nudge {
  0%, 100% { transform: scale(1); box-shadow: 0 6px 16px rgb(41 70 57 / 22%), 0 0 0 0 rgb(244 191 78 / 0%); }
  50% { transform: scale(1.07); box-shadow: 0 6px 16px rgb(41 70 57 / 22%), 0 0 0 10px rgb(244 191 78 / 55%); }
}

/* ----- Ler junto (texto completo para o adulto) ----- */
.read-along { margin-top: 10px; max-width: 520px; }
.read-along summary {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 14px;
  border-radius: 999px; border: 1px solid #d4ddca; background: var(--white); color: var(--green);
  font-size: 15px; font-weight: 800; cursor: pointer; list-style: none;
}
.read-along summary::-webkit-details-marker { display: none; }
.read-along summary svg { width: 20px; height: 20px; }
.read-along.suggest summary { border-color: var(--gold); background: var(--gold-light); }
.read-along-body { margin-top: 10px; padding: 14px 16px; border-radius: 18px; background: var(--white); border: 1px solid var(--line); }
.read-along-body > p { margin: 0; font-size: 17px; line-height: 1.6; color: var(--ink); }
.read-along .word-card { margin-top: 12px; }
.audio-status { margin: 8px 0 0; color: var(--muted); font-size: 14px; }

/* ----- Detalhe ----- */
.detail-art-button { position: relative; display: block; padding: 0; border: 0; background: none; border-radius: var(--round); }
.detail-art-button .detail-art { width: 100%; }
.detail-play {
  position: absolute; right: 18px; bottom: 18px; display: grid; place-items: center; width: 84px; height: 84px;
  border-radius: 50%; background: var(--green); color: #fff; border: 4px solid #fff; box-shadow: 0 6px 18px rgb(30 50 30 / 28%);
  animation: nudge 1.8s ease-in-out infinite;
}
.detail-play svg { width: 38px; height: 38px; margin-left: 5px; }
.detail-copy .learn-line { font-size: 19px; }

/* ----- Cena da história ----- */
.storybook .story-layout { align-items: start; gap: clamp(14px, 3vw, 40px); }
.story-figure { min-width: 0; }
.storybook .story-art { width: 100%; height: auto; max-height: calc(100dvh - var(--head-h) - var(--bar-h) - 230px); min-height: 180px; object-fit: cover; aspect-ratio: 3 / 2; }
.scene-counter { margin-bottom: 8px; max-width: none; }
.storybook .story-copy h1 { margin-bottom: 6px; font-size: clamp(26px, 3.2vw, 42px); }
.story-caption { margin: 0; font-size: clamp(21px, 2.2vw, 26px); line-height: 1.4; font-weight: 700; color: var(--ink); max-width: 30ch; text-wrap: balance; }
.storybook .story-copy > p.story-caption { color: var(--ink); }

/* ----- Brincadeira ----- */
.game-stage { display: flex; flex-direction: column; height: calc(100dvh - var(--head-h) - var(--bar-h) - env(safe-area-inset-bottom, 0px) - env(safe-area-inset-top, 0px) - 12px); min-height: 380px; }
.game-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.game-title { margin: 0; font-size: clamp(22px, 2.6vw, 32px); letter-spacing: -.5px; }
.game-stage .progress-track { width: 100%; max-width: none; height: 8px; margin: 8px 0 10px; }
.game-stage .activity-shell { flex: 1; min-height: 0; padding: clamp(8px, 1.6vw, 20px); overflow: auto; display: flex; flex-direction: column; }
.game-stage .activity-shell > * { flex: 1; min-height: 0; }
.game-feedback { min-height: 34px; margin: 6px 0 0; padding: 2px 4px; font-size: 17px; font-weight: 800; color: var(--green); }
.game-feedback.pop { animation: pop .35s ease-out; }
@keyframes pop { 0% { transform: scale(.92); opacity: .4; } 100% { transform: scale(1); opacity: 1; } }

/* ----- Perguntas ----- */
.quiz-wrap { margin-top: 0; }
.quiz-wrap .scene-dots { justify-content: center; margin-bottom: 8px; }
.quiz-wrap > h1 { margin-bottom: 14px; font-size: clamp(25px, 3vw, 40px); }
.quiz-options { margin-top: 6px; gap: 12px; }
.quiz-options.count-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.quiz-options.count-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.quiz-option { min-height: 0; padding: 14px 8px; gap: 10px; }
.option-art { height: clamp(90px, 22dvh, 170px); }
.option-label { font-size: 17px; line-height: 1.25; }
.quiz-option.wrong { animation: shake .4s ease; }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
.quiz-feedback { min-height: 30px; margin-top: 10px; }
.loose-group { display: flex; align-items: center; justify-content: center; gap: 4px; width: 100%; height: 100%; }
.loose-group img { height: 100%; width: auto; max-width: 33%; object-fit: contain; }
.loose-group.count-1 img { max-width: 80%; }
.sprite-loose { width: 100%; height: 100%; object-fit: contain; }
.sprite-flip { transform: scaleX(-1); }

/* ----- Resultado ----- */
.result-art { position: relative; height: 150px; margin-bottom: 8px; }
.result-star { position: absolute; top: -6px; right: 12%; width: 54px; height: 54px; display: grid; place-items: center; border-radius: 50%; background: var(--gold); color: #fff; box-shadow: 0 4px 12px rgb(0 0 0 / 15%); animation: pop .6s ease-out; }
.result-star svg { width: 32px; height: 32px; fill: currentColor; }
.result-wrap > h1 { margin-bottom: 10px; }
.lesson-card { margin: 12px auto; }
.lesson-card p + p { margin-top: 10px; }
.lesson-attitude { font-weight: 800; color: var(--green) !important; }
.prayer-card {
  display: flex; align-items: center; gap: 14px; width: 100%; max-width: 670px; margin: 12px auto; padding: 16px 20px;
  border: 2px solid #ecd39b; border-radius: 24px; background: var(--gold-light); text-align: left; color: var(--ink);
}
.prayer-card strong { display: block; font-size: 19px; }
.prayer-card span span { display: block; color: #6b5a33; font-size: 16px; line-height: 1.5; }
.prayer-icon { flex: none; display: grid; place-items: center; width: 58px; height: 58px; border-radius: 50%; background: #fff; color: #8a5f12; }
.prayer-icon svg { width: 34px; height: 34px; }
.talk-card { max-width: 670px; margin: 12px auto; padding: 16px 20px; border-radius: 22px; border: 1px dashed #c9d4bd; text-align: left; }
.talk-card h2 { margin: 0 0 6px; font-size: 17px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.talk-card p { margin: 0; font-size: 17px; line-height: 1.55; }
.talk-card .small-print { margin-top: 8px; color: var(--muted); }

/* ----- Início ----- */
.card-copy { justify-content: center; }
.story-card.is-complete .card-check { background: var(--gold); width: 46px; height: 46px; }
.story-card.is-complete .card-check svg { width: 28px; height: 28px; fill: #fff; }

/* ----- Vídeo ----- */
.intro-video-frame { position: relative; }
.intro-video-frame video { height: calc(100dvh - var(--head-h) - var(--bar-h) - 90px); max-height: 640px; min-height: 220px; }
.video-play { position: absolute; inset: 0; margin: auto; width: 96px; height: 96px; border-radius: 50%; border: 4px solid #fff; background: rgb(52 88 71 / 88%); color: #fff; display: grid; place-items: center; }
.video-play svg { width: 44px; height: 44px; margin-left: 6px; }

/* ----- Responsáveis: segurar para abrir ----- */
.parent-button { position: relative; overflow: hidden; -webkit-user-select: none; user-select: none; }
.parent-button .hold-hint { position: absolute; inset: 0; display: grid; place-items: center; background: var(--ink); color: #fff; font-size: 12px; border-radius: inherit; opacity: 0; pointer-events: none; transition: opacity .2s; }
.parent-button.hint .hold-hint { opacity: 1; }
.parent-button .hold-fill { position: absolute; left: 0; bottom: 0; height: 4px; width: 0; background: var(--gold); }
.parent-button.holding .hold-fill { width: 100%; transition: width 1.5s linear; }

/* ----- Confete ----- */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.confetti i { position: absolute; width: 10px; height: 14px; border-radius: 3px; animation: burst 1.2s cubic-bezier(.2,.7,.3,1) forwards; }
.confetti-big i { width: 12px; height: 16px; }
@keyframes burst {
  0% { transform: translate(-50%, -50%) rotate(0); opacity: 1; }
  80% { opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy) + 120px)) rotate(var(--r)); opacity: 0; }
}

/* ----- Celular em pé ----- */
@media (max-width: 720px) {
  :root { --head-h: 58px; --bar-h: 88px; }
  body:not([data-screen="home"]) .site-header { min-height: var(--head-h); }
  body:not([data-screen="home"]) .brand-logo { width: 96px; }
  .stage { padding-top: 4px; }
  .storybook .story-layout { gap: 10px; }
  .storybook .story-art { border-radius: 20px; }
  .storybook .story-copy h1 { font-size: 25px; }
  .story-caption { font-size: 20px; }
  .detail-layout { gap: 14px; }
  .detail-copy h1 { font-size: 30px; margin-bottom: 8px; }
  .quiz-option { padding: 10px 6px; border-radius: 18px; }
  .option-label { font-size: 15px; }
  .result-art { height: 120px; }
}

/* ----- Celular deitado: barra de ações vira coluna à direita ----- */
@media (orientation: landscape) and (max-height: 520px) {
  :root { --head-h: 46px; --bar-h: 0px; --side-w: 104px; }
  body:not([data-screen="home"]) .site-header { min-height: var(--head-h); }
  body:not([data-screen="home"]) .brand-logo { width: 78px; }
  body:not([data-screen="home"]) .app-shell { padding-right: calc(var(--side-w) + env(safe-area-inset-right, 0px)); }
  #main { padding-bottom: 10px; }
  body[data-screen="home"] #main { padding-bottom: 20px; }
  .action-bar {
    top: 0; left: auto; width: calc(var(--side-w) + env(safe-area-inset-right, 0px));
    grid-template-columns: 1fr; grid-template-rows: 1fr auto 1fr; justify-items: center;
    padding: calc(10px + env(safe-area-inset-top, 0px)) env(safe-area-inset-right, 0px) calc(10px + env(safe-area-inset-bottom, 0px)) 0;
    border-top: 0; border-left: 1px solid var(--line); box-shadow: -6px 0 20px rgb(41 70 57 / 7%);
  }
  /* Linhas fixas (não 'order'): a seta escondida não pode fazer o alto-falante pular de lugar. */
  .action-bar > :first-child { justify-self: center; align-self: end; grid-row: 3; }
  .action-bar > :nth-child(2) { grid-row: 2; }
  .action-bar > :last-child { justify-self: center; align-self: start; grid-row: 1; }
  .next-big { min-width: 78px; height: 78px; padding: 0; }
  .stage { padding-top: 0; }
  .stage-header { margin-bottom: 4px; min-height: 38px; }
  .storybook .story-layout, .detail-layout { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 16px; align-items: start; }
  .storybook .story-art { max-height: calc(100dvh - var(--head-h) - 60px); min-height: 0; }
  .storybook .story-copy h1 { font-size: 22px; }
  .story-caption { font-size: 18px; }
  .detail-art { max-height: calc(100dvh - var(--head-h) - 60px); object-fit: cover; }
  .detail-copy h1 { font-size: 26px; }
  .game-stage { height: calc(100dvh - var(--head-h) - 12px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)); min-height: 0; }
  .game-title { font-size: 20px; }
  .game-stage .progress-track { margin: 4px 0 6px; }
  .game-feedback { min-height: 24px; font-size: 15px; margin-top: 2px; }
  .quiz-wrap > h1 { font-size: 22px; margin-bottom: 8px; }
  .option-art { height: clamp(48px, calc(100dvh - 270px), 130px); }
  .quiz-wrap .scene-dots { margin-bottom: 4px; }
  .quiz-wrap > h1 { margin-bottom: 6px; }
  .quiz-feedback { min-height: 22px; margin-top: 4px; font-size: 15px; line-height: 1.35; }
  .intro-video-frame video { height: calc(100dvh - var(--head-h) - 60px); }
}

/* ----- Tablet em pé: uma coluna, figura grande (antes ficava pequena e sobrava meia tela vazia) ----- */
@media (orientation: portrait) and (min-width: 721px) {
  .storybook .story-layout, .detail-layout { grid-template-columns: minmax(0, 1fr); gap: 18px; max-width: 900px; margin-inline: auto; }
  .storybook .story-art { max-height: calc(100dvh - var(--head-h) - var(--bar-h) - 330px); }
  .detail-art { max-height: calc(100dvh - var(--head-h) - var(--bar-h) - 330px); }
  .story-caption { max-width: none; }
}

/* v4 — ajustes de integração */
body:not([data-screen="home"]) .site-header { height: var(--head-h); min-height: 0; overflow: hidden; }
.game-stage > .progress-track { flex: none; }
.game-feedback { height: 30px; min-height: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
/* O texto fica num <span> (item flex): sem isto a frase longa saía cortada dos dois lados. */
.game-feedback > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.game-stage .audio-status { display: none; }
/* Aviso de áudio indisponível: discreto (é para o adulto) e sem empurrar a tela para rolar. */
#main .audio-status { margin: 6px auto 0; max-width: none; font-size: 14px; line-height: 1.35; color: var(--muted); }
@media (orientation: landscape) and (max-height: 520px) {
  .game-top { display: none; }
  .game-feedback { height: 24px; }
}
/* v4.1 — imagem do resultado não pode passar da área (percentual de altura não resolve em grid) */
.result-art { display: flex; align-items: center; justify-content: center; }
.result-art > img { height: 150px; width: auto; max-width: 100%; object-fit: contain; border-radius: 18px; }
.result-art > svg { height: 150px; }
@media (max-width: 720px) { .result-art > img, .result-art > svg { height: 120px; } }
/* v4.2 — logo nova (horizontal): tamanho pela altura */
.brand-logo { width: auto !important; height: 64px; max-width: 46vw; object-fit: contain; }
body:not([data-screen="home"]) .brand-logo { height: 46px; }
@media (max-width: 720px) { .brand-logo { height: 50px; } body:not([data-screen="home"]) .brand-logo { height: 40px; } }
@media (orientation: landscape) and (max-height: 520px) { body:not([data-screen="home"]) .brand-logo { height: 34px; } }
