/* The Gammy Valhalla Saga — flip-book prototype
   Self-contained. Cerise highlight: #DE3163 */
:root {
  --paper: #f6efe3;
  --paper-deep: #efe4d2;
  --ink: #241c16;
  --ink-soft: #5a4a3c;
  --cerise: #de3163;
  --cerise-soft: #f7d5e0;
  --gold: #c9a24a;
  --rule: #d9cbb6;
  --shadow: 0 18px 50px rgba(40, 24, 16, 0.28);
  --bar-h: 72px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: #2a1f18;
  color: var(--ink);
  font-family: "Lora", Georgia, serif;
  min-height: 100%;
}
body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.stage {
  flex: 1;
  width: 100%;
  max-width: 720px;
  display: flex;
  flex-direction: column;
  padding: 0 0 calc(var(--bar-h) + var(--safe-bottom));
  position: relative;
}
.book {
  flex: 1;
  position: relative;
  width: 100%;
  min-height: 0;
  perspective: 1200px;
}
.page {
  position: absolute;
  inset: 0;
  overflow: auto;
  background: var(--paper);
  color: var(--ink);
  -webkit-overflow-scrolling: touch;
  transform-origin: left center;
  backface-visibility: hidden;
  opacity: 0;
  pointer-events: none;
  z-index: 0;
}
.page.current {
  opacity: 1;
  pointer-events: auto;
  z-index: 2;
  box-shadow: var(--shadow);
}
.page.exit-next {
  z-index: 3;
  animation: flipOut 0.55s ease forwards;
}
.page.enter-next { animation: fadeIn 0.45s ease forwards; }
.page.exit-prev { z-index: 3; animation: fadeOut 0.3s ease forwards; }
.page.enter-prev { animation: flipIn 0.55s ease forwards; }
@keyframes flipOut {
  to { transform: rotateY(-85deg); opacity: 0; }
}
@keyframes flipIn {
  from { transform: rotateY(70deg); opacity: 0; }
  to { transform: none; opacity: 1; }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; } }

/* Cover & dividers */
.hero {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  background: #1a120c;
  color: #fff8ee;
  position: relative;
  overflow: hidden;
}
.hero-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
  pointer-events: none;
}
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(20, 12, 8, 0.92) 0%, rgba(20, 12, 8, 0.45) 42%, rgba(20, 12, 8, 0.15) 70%, rgba(20, 12, 8, 0.2) 100%);
  pointer-events: none;
}
.hero-inner {
  position: relative;
  z-index: 1;
  padding: 28px 24px 32px;
}
.kicker {
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 600;
  color: #f3d9a4;
  margin: 0 0 8px;
}
h1.saga-title {
  font-family: "Playfair Display", Georgia, serif;
  font-weight: 700;
  font-size: clamp(2rem, 7vw, 3.2rem);
  line-height: 1.05;
  margin: 0 0 8px;
  text-shadow: 0 2px 18px rgba(0,0,0,0.45);
}
.parts-line {
  font-family: "Playfair Display", Georgia, serif;
  font-style: italic;
  font-weight: 600;
  font-size: 1.35rem;
  color: #f3d9a4;
  margin: 0 0 18px;
}
.credits {
  font-size: 0.92rem;
  line-height: 1.45;
  color: #f3eadc;
  margin: 0 0 8px;
  max-width: 36em;
}
.credits strong { color: #fff; font-weight: 600; }
.fine {
  font-size: 0.78rem;
  color: #d8cbb8;
  line-height: 1.4;
  margin: 10px 0 0;
}
.free-tag {
  display: inline-block;
  margin-top: 14px;
  border: 1px solid rgba(243, 217, 164, 0.55);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  color: #f3d9a4;
}
.divider-num {
  font-family: "Playfair Display", Georgia, serif;
  font-size: clamp(2.4rem, 8vw, 3.6rem);
  margin: 0 0 4px;
  line-height: 1;
}
.accuracy-box {
  margin-top: 16px;
  background: rgba(255,248,238,0.1);
  border: 1px solid rgba(243,217,164,0.25);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.8rem;
  color: #f0e6d6;
}

/* Lyric pages */
.lyric-page {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  background: var(--paper);
}
.scene {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
  background: #3a2a20;
}
.lyric-body { padding: 14px 18px 48px; }
.part-label {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 2px;
}
.page-title {
  font-family: "Playfair Display", Georgia, serif;
  font-size: 1.45rem;
  margin: 0 0 4px;
}
.simple-note {
  font-size: 0.75rem;
  color: var(--ink-soft);
  margin: 0 0 14px;
  font-style: italic;
}
.lyric-block {
  margin: 0 0 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--rule);
}
.lyric-block:last-of-type { border-bottom: 0; }
.lyric-sentence {
  font-size: 1.05rem;
  line-height: 1.45;
  margin: 0 0 6px;
}
.lyric-sentence .syl {
  display: inline;
  border-radius: 3px;
  padding: 0 1px;
  transition: color 0.08s, background 0.08s;
  cursor: pointer;
}
.lyric-sentence .syl.on {
  color: var(--cerise);
  background: var(--cerise-soft);
  font-weight: 700;
}
.staff-host {
  width: 100%;
  overflow-x: auto;
  position: relative;
}
.staff-host svg { display: block; }
.syl-rail, .name-rail {
  position: relative;
  height: 22px;
  margin: 0 0 0;
  font-size: 11px;
  color: var(--ink-soft);
}
.name-rail { height: 18px; font-size: 10px; letter-spacing: 0.02em; font-family: "Lora", serif; }
.name-rail[hidden], .syl-rail.hidden { display: none; }
.syl-rail span, .name-rail span {
  position: absolute;
  transform: translateX(-50%);
  white-space: nowrap;
  top: 0;
  pointer-events: none;
}
.syl-rail span.on, .name-rail span.on { color: var(--cerise); font-weight: 700; }
.hint {
  font-size: 0.75rem;
  color: var(--ink-soft);
  margin: 8px 0 0;
}

/* Toolbar */
.bar {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: 720px;
  background: #f6efe3;
  border-top: 1px solid var(--rule);
  padding: 8px 12px calc(8px + var(--safe-bottom));
  z-index: 10;
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-rows: auto auto;
  gap: 6px 10px;
  align-items: center;
}
.nav {
  display: flex;
  align-items: center;
  gap: 8px;
  grid-column: 1 / -1;
  justify-content: space-between;
}
button {
  font-family: "Lora", Georgia, serif;
  background: #241c16;
  color: #f6efe3;
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.9rem;
  cursor: pointer;
}
button:disabled { opacity: 0.35; cursor: default; }
button.play {
  background: var(--cerise);
  min-width: 96px;
  font-weight: 700;
}
button.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--rule);
}
.page-ind { font-size: 0.85rem; color: var(--ink-soft); min-width: 4.5em; text-align: center; }
.progress {
  height: 6px;
  background: #e2d5c2;
  border-radius: 99px;
  overflow: hidden;
  grid-column: 1 / -1;
  cursor: pointer;
}
.progress > span {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--cerise);
  border-radius: 99px;
}
.toggles {
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 0.75rem;
  color: var(--ink-soft);
  grid-column: 1 / -1;
}
.toggles label { display: flex; align-items: center; gap: 6px; cursor: pointer; }

/* Note-learning pop */
.pop {
  position: fixed;
  z-index: 20;
  background: #fffaf3;
  color: var(--ink);
  border: 2px solid var(--cerise);
  border-radius: 16px;
  padding: 12px 16px;
  box-shadow: var(--shadow);
  text-align: center;
  min-width: 120px;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 8px);
  transition: opacity 0.15s, transform 0.15s;
}
.pop.show { opacity: 1; transform: translate(-50%, 0); }
.pop .big {
  font-family: "Playfair Display", Georgia, serif;
  font-size: 2.4rem;
  color: var(--cerise);
  line-height: 1;
}
.pop .sub { font-size: 0.8rem; color: var(--ink-soft); }

.prototype-banner {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  background: rgba(20,12,8,0.55);
  color: #fff8ee;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 999px;
}

/* Dedication */
.dedication.hero { justify-content: flex-end; }
.dedication-quote {
  font-family: "Playfair Display", Georgia, serif;
  font-style: italic;
  font-weight: 600;
  font-size: clamp(1.45rem, 5.4vw, 2.15rem);
  line-height: 1.35;
  margin: 0 0 18px;
  text-shadow: 0 2px 18px rgba(0,0,0,0.45);
  max-width: 22em;
}
.bookaroke-hint {
  font-size: 0.72rem;
  color: var(--ink-soft);
  margin: 0;
}
.toggles label strong { font-weight: 700; color: var(--ink); }
