@font-face {
  font-family: Nunito;
  src: url("fonts/nunito-latin.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: Nunito;
  src: url("fonts/nunito-latin-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #f6efe4;
  --paper: #fffaf3;
  --ink: #3a2a22;
  --muted: #6b5348;
  --berry: #b5343e;
  --berry-dark: #8e2a32;
  --gold: #c9922a;
  --pine: #2f5d4a;
  --shadow: 0 10px 30px rgba(58, 42, 34, 0.12);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 600px at 50% -10%, #fff8ea, transparent 60%),
    var(--bg);
  color: var(--ink);
  font-family: Nunito, "Segoe UI", "Helvetica Neue", sans-serif;
}

body {
  min-height: 100dvh;
}

.book {
  width: min(560px, 100%);
  margin: 0 auto;
  min-height: 100dvh;
  padding: calc(12px + var(--safe-t)) 18px calc(16px + var(--safe-b));
  display: flex;
  flex-direction: column;
  align-items: center;
}

.top {
  text-align: center;
  min-height: 2.4rem;
  margin: 0 0 10px;
}

.kicker {
  margin: 0;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

.cover-title {
  display: none;
  margin: 4px 0 0;
  font-size: clamp(1.45rem, 5.6vw, 1.9rem);
  line-height: 1.15;
  font-weight: 700;
  color: var(--berry-dark);
}

.book.is-cover .cover-title { display: block; }
.book.is-cover .kicker { margin-bottom: 2px; }
.book:not(.is-cover) .kicker { opacity: 0.7; }

.stage {
  margin: 0;
  width: 100%;
  max-width: 520px;
  aspect-ratio: 1 / 1;
  max-height: min(52dvh, 520px);
  border-radius: 22px;
  overflow: hidden;
  box-shadow: var(--shadow);
  background: #e8dfd2;
  touch-action: pan-y;
  user-select: none;
}

.stage img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 220ms ease;
}

.stage img.is-fading { opacity: 0; }

.story {
  width: 100%;
  max-width: 520px;
  margin: 14px 0 0;
  font-size: clamp(1.05rem, 4.3vw, 1.22rem);
  line-height: 1.45;
  text-align: center;
  min-height: 5.6em;
  color: var(--ink);
}

.book.is-cover .story { 
  min-height: 0;
  height: 0;
  overflow: hidden;
  margin: 0;
}

.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin-top: 8px;
}

.nav-btn, .play-btn, .auto-btn {
  font-family: inherit;
  border: 0;
  cursor: pointer;
}

.nav-btn, .play-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--paper);
  background: var(--pine);
  box-shadow: 0 6px 16px rgba(47, 93, 74, 0.25);
}

.play-btn {
  width: 72px;
  height: 72px;
  background: var(--berry);
  box-shadow: 0 8px 20px rgba(181, 52, 62, 0.28);
}

.nav-btn svg, .play-btn svg { width: 28px; height: 28px; }
.play-btn svg { width: 34px; height: 34px; }

.play-btn .icon-pause { display: none; }
.play-btn.is-playing .icon-play { display: none; }
.play-btn.is-playing .icon-pause { display: block; }

.nav-btn:disabled {
  opacity: 0.35;
  box-shadow: none;
  cursor: default;
}

.nav-btn:not(:disabled):active,
.play-btn:active,
.auto-btn:active { transform: scale(0.96); }

.auto-btn {
  margin-top: 12px;
  width: min(100%, 280px);
  min-height: 48px;
  border-radius: 999px;
  background: #efe4d4;
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 700;
  border: 2px solid rgba(58, 42, 34, 0.12);
}

.auto-btn[aria-pressed="true"] {
  background: var(--gold);
  color: #2a1d14;
  border-color: transparent;
}

.dots {
  list-style: none;
  display: flex;
  gap: 8px;
  padding: 0;
  margin: 14px 0 0;
}

.dots button {
  width: 9px;
  height: 9px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(58, 42, 34, 0.22);
  cursor: pointer;
}

.dots button[aria-current="true"] {
  background: var(--berry);
  width: 22px;
  border-radius: 999px;
}

.end-note {
  margin: 8px 0 0;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.95rem;
}

footer {
  margin-top: auto;
  padding-top: 14px;
  font-size: 0.72rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.3;
}

@media (min-width: 700px) {
  .book {
    padding-top: 28px;
    padding-bottom: 28px;
  }
  .stage { max-height: 560px; }
}

@media (prefers-reduced-motion: reduce) {
  .stage img { transition: none; }
}
