:root {
  --page-width: 600px;
  --page-height: 700px;  /* Erhöht von 400px auf 600px */
}

body {
  margin: 0;
  padding: 16px;
  background: #d9d2c3;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-family: "Georgia", serif;
}

.center-row {
  width: 100%;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 0;
  transition: opacity 0.8s ease, transform 0.8s ease;
}

.center-row.hide {
  opacity: 0;
  transform: scale(0.9);
  pointer-events: none;
}

/* --------- Briefkasten --------- */

.mailbox-wrapper {
  perspective: 800px;
}

.mailbox {
  width: 180px;
  height: 135px;
  background: linear-gradient(135deg, #d32f2f 0%, #b71c1c 50%, #8b0000 100%);
  border-radius: 18px 18px 10px 10px;
  position: relative;
  box-shadow:
    0 2px 8px rgba(0,0,0,0.15),
    0 8px 24px rgba(0,0,0,0.25),
    0 16px 48px rgba(0,0,0,0.20),
    inset 0 2px 0 rgba(255,255,255,0.15),
    inset 0 -2px 6px rgba(0,0,0,0.3);
  transform-style: preserve-3d;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(139,0,0,0.6);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.mailbox::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, 
    transparent 0%, 
    rgba(255,255,255,0.1) 45%, 
    rgba(255,255,255,0.2) 50%, 
    rgba(255,255,255,0.1) 55%, 
    transparent 100%);
  border-radius: 18px 18px 10px 10px;
  pointer-events: none;
}

.mailbox:hover {
  transform: translateY(-4px);
  box-shadow:
    0 4px 12px rgba(0,0,0,0.18),
    0 12px 32px rgba(0,0,0,0.30),
    0 20px 56px rgba(0,0,0,0.25),
    inset 0 2px 0 rgba(255,255,255,0.2),
    inset 0 -2px 6px rgba(0,0,0,0.3);
}

.mailbox-slot {
  position: absolute;
  left: 50%;
  top: 45%;
  width: 75%;
  height: 8px;
  transform: translateX(-50%);
  background: linear-gradient(180deg, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.6) 100%);
  border-radius: 4px;
  box-shadow:
    inset 0 2px 4px rgba(0,0,0,0.8),
    inset 0 -1px 2px rgba(0,0,0,0.5),
    0 1px 0 rgba(255,255,255,0.1);
  border: 1px solid rgba(0,0,0,0.5);
}

.mailbox-flag {
  position: absolute;
  right: -18px;
  top: 22px;
  width: 12px;
  height: 45px;
  background: linear-gradient(135deg, #ffd700 0%, #ffb300 50%, #ff8f00 100%);
  border-radius: 3px;
  box-shadow:
    0 3px 8px rgba(0,0,0,0.35),
    inset 0 1px 0 rgba(255,255,255,0.4),
    inset 0 -1px 2px rgba(0,0,0,0.2);
  border: 1px solid rgba(139,101,0,0.4);
}

.mailbox-flag::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  right: 2px;
  height: 40%;
  background: linear-gradient(180deg, rgba(255,255,255,0.3) 0%, transparent 100%);
  border-radius: 2px;
  pointer-events: none;
}

.mailbox-lid {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 45px;
  background: linear-gradient(135deg, #e57373 0%, #d32f2f 50%, #c62828 100%);
  border-radius: 18px 18px 0 0;
  transform-origin: top center;
  transform: rotateX(0deg);
  transition: transform 0.6s ease;
  box-shadow:
    0 3px 10px rgba(0,0,0,0.3),
    inset 0 2px 0 rgba(255,255,255,0.2),
    inset 0 -2px 4px rgba(0,0,0,0.25);
  border: 1px solid rgba(139,0,0,0.5);
  border-bottom: none;
}

.mailbox-lid::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, 
    transparent 0%, 
    rgba(255,255,255,0.08) 45%, 
    rgba(255,255,255,0.15) 50%, 
    rgba(255,255,255,0.08) 55%, 
    transparent 100%);
  border-radius: 18px 18px 0 0;
  pointer-events: none;
}

.letter {
  position: absolute;
  left: 50%;
  bottom: -60px;
  width: 85%;
  height: 75px;
  transform: translateX(-50%) translateY(20px);
  background: linear-gradient(135deg, #fefdfb 0%, #f9f7f4 50%, #f5f3ef 100%);
  border-radius: 4px;
  box-shadow:
    0 6px 18px rgba(0,0,0,0.25),
    0 12px 36px rgba(0,0,0,0.15),
    inset 0 1px 0 rgba(255,255,255,0.9),
    inset 0 -1px 3px rgba(0,0,0,0.08);
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 500;
  color: #5a4a3a;
  transition: transform 0.6s ease 0.2s, box-shadow 0.3s ease;
  overflow: visible;
  cursor: pointer;
  border: 1px solid rgba(139,117,89,0.15);
  position: relative;
}

/* Umschlag-Klappe oben */
.letter::before {
  content: '';
  position: absolute;
  top: 0px;
  left: -2px;
  right: -2px;
  height: 45px;
  background: linear-gradient(135deg, #d4c4ad 0%, #c4b39c 40%, #b5a48d 100%);
  clip-path: polygon(0 0, 50% 100%, 100% 0);
  box-shadow:
    0 5px 15px rgba(0,0,0,0.35),
    0 8px 25px rgba(0,0,0,0.20),
    inset 0 2px 4px rgba(255,255,255,0.25),
    inset 0 -3px 6px rgba(0,0,0,0.25);
  border-left: 2px solid rgba(139,117,89,0.35);
  border-right: 2px solid rgba(139,117,89,0.35);
  border-bottom: 1px solid rgba(139,117,89,0.2);
  transform-origin: 50% 0%;
  transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1;
}

/* Geöffnete Umschlag-Klappe */
.letter.opening::before {
  transform: rotateX(180deg);
  opacity: 1;
}

/* Wachs-Siegel */
.letter::after {
  content: '♥';
  position: absolute;
  top: 33px;
  left: 50%;
  transform: translateX(-50%);
  transform-origin: 50% -33px;
  width: 24px;
  height: 24px;
  background: radial-gradient(circle, #d32f2f 0%, #b71c1c 70%, #8b0000 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: rgba(255,255,255,0.9);
  box-shadow:
    0 2px 6px rgba(0,0,0,0.4),
    inset 0 1px 2px rgba(255,255,255,0.3),
    inset 0 -1px 2px rgba(0,0,0,0.4);
  border: 1px solid rgba(139,0,0,0.6);
  z-index: 10;
  transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Wachssiegel hinter gelbes Blatt beim geöffneten Brief */
.letter.opened::after {
  z-index: 1;
}

/* Geöffnetes Siegel */
.letter.opening::after {
  transform: translateX(-50%) rotateX(180deg);
  opacity: 1;
}

/* Gelbes Blatt im Brief */
.yellow-paper {
  position: absolute;
  top: 5px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 4px);
  height: 120px;
  background: linear-gradient(135deg, #f5d28b, #e0b45f);
  border-radius: 2px;
  box-shadow:
    0 2px 8px rgba(0,0,0,0.15),
    inset 0 1px 0 rgba(255,255,255,0.4),
    inset 0 -1px 2px rgba(0,0,0,0.1);
  opacity: 0;
  z-index: 2;
  transition: all 1.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  border: 1px solid rgba(204,153,0,0.3);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  color: #2b1c0d;
}

.yellow-paper h1 {
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 4px 0;
  font-family: "Old Standard TT", serif;
}

.yellow-paper h2 {
  font-size: 10px;
  font-weight: 400;
  margin: 0;
  font-family: "Old Standard TT", serif;
  font-style: italic;
}

.yellow-paper-seal {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 35px;
  height: 35px;
  object-fit: cover;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.35));
  opacity: 1;
  pointer-events: none;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid rgba(255, 245, 220, 0.92);
  transform: rotate(-6deg);
}

/* Gelbes Blatt fliegt heraus */
.letter.opening .yellow-paper {
  opacity: 1;
  transform: translateX(-50%) translateY(-180px) rotate(-5deg) scale(1);
  transition-delay: 0.4s;
}

/* Zwischenzustand: Brief vergrößert sich und wird zentral angezeigt */
.letter.opened {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(1.8);
  z-index: 1000;
  width: 320px;
  height: 220px;
  box-shadow:
    0 20px 60px rgba(0,0,0,0.40),
    0 40px 100px rgba(0,0,0,0.30),
    inset 0 1px 0 rgba(255,255,255,0.95),
    inset 0 -1px 3px rgba(0,0,0,0.10);
  transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.letter.opened p {
  font-size: 18px;
  padding: 20px;
}

/* Gelbes Blatt skaliert mit dem Brief */
.letter.opened .yellow-paper {
  transform: translateX(-50%) translateY(-180px) rotate(-5deg) scaleY(1.4);
}

.letter:hover {
  box-shadow:
    0 8px 24px rgba(0,0,0,0.30),
    0 16px 48px rgba(0,0,0,0.20),
    inset 0 1px 0 rgba(255,255,255,0.95),
    inset 0 -1px 3px rgba(0,0,0,0.10);
  transform: translateX(-50%) translateY(18px);
}

.letter p {
  margin: 0;
  padding: 0 12px;
  text-align: center;
  font-family: 'Old Standard TT', Georgia, serif;
  font-style: italic;
  letter-spacing: 0.02em;
  text-shadow: 0 1px 1px rgba(255,255,255,0.8);
  line-height: 1.4;
  position: relative;
  z-index: 1;
}

/* Zustand 1: pulsierender Kasten ohne Klappe/Brief */
.state-pulse .mailbox-lid,
.state-pulse .letter {
  display: none;
}

.pulse-glow {
  animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(255, 82, 120, 0.7);
  }
  50% {
    transform: scale(1.08);
    box-shadow: 0 0 0 18px rgba(255, 82, 120, 0);
  }
}

/* Zustand 2: Briefkasten mit Brief (kein Puls mehr) */
.state-letter .mailbox-lid,
.state-letter .letter {
  display: flex;
}

.state-letter .mailbox {
  animation: none;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.state-letter .letter {
  transform: translateX(-50%) translateY(-85px);
}

/* Label auf dem Briefkasten */
.mailbox-label {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: #ffffff;
  background: linear-gradient(180deg, rgba(0,0,0,0.4) 0%, rgba(0,0,0,0.55) 100%);
  border-radius: 999px;
  white-space: nowrap;
  pointer-events: none;
  box-shadow:
    0 2px 6px rgba(0,0,0,0.4),
    inset 0 1px 0 rgba(255,255,255,0.15);
  border: 1px solid rgba(0,0,0,0.3);
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.state-letter .mailbox-label {
  opacity: 0.4;
}

/* --------- Buchlayout (dritter Zustand) --------- */

.book-wrapper {
  width: 100%;
  max-width: var(--page-width);
  height: var(--page-height);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  perspective: 1200px;
  margin: 0 auto;
  padding: 0;
}

.book-wrapper.visible {
  display: flex;
}

/* Buch fliegt aus Brief heraus */
.book-wrapper.flying-out {
  animation: fly-out-of-letter 3.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes fly-out-of-letter {
  0% {
    opacity: 0;
    transform: translate(0, 100vh) scale(0.1) rotate(-5deg);
  }
  20% {
    opacity: 0.5;
    transform: translate(0, 60vh) scale(0.3) rotate(-3deg);
  }
  50% {
    opacity: 0.8;
    transform: translate(0, 30vh) scale(0.6) rotate(-1deg);
  }
  100% {
    opacity: 1;
    transform: translate(0, 0) scale(1) rotate(0deg);
  }
}

.book-shell {
  position: relative;
  width: 100%;
  max-width: var(--page-width);
  height: var(--page-height);
}

.book-back {
  position: absolute;
  top: 0;
  right: 10px;
  width: 120px;
  height: 100%;
  background: #c59b5b;
  border-radius: 0 14px 14px 0;
  box-shadow: -8px 0 18px rgba(0,0,0,0.45);
  transform: rotateY(-18deg) rotateX(6deg);
  transform-origin: left center;
  z-index: 0;
}

.book-page {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: var(--page-width);
  height: 100%;
  background: #fdfaf5;
  border-radius: 4px 14px 14px 4px;
  box-shadow:
    0 26px 55px rgba(0,0,0,0.55),
    0 8px 18px rgba(0,0,0,0.35),
    0 0 0 1px rgba(0,0,0,0.10);
  padding: 20px 26px 36px 40px;
  box-sizing: border-box;
  transform: rotateY(-18deg) rotateX(6deg);
  transform-origin: left center;
  overflow-y: auto;
}

/* Innenkanten */
.book-page::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 20px;
  border-radius: 3px 0 0 3px;
  background: linear-gradient(
    to right,
    rgba(0,0,0,0.25),
    rgba(0,0,0,0.05)
  );
}

.book-page::after {
  content: "";
  position: absolute;
  right: -12px;
  top: 6px;
  bottom: 0;
  width: 10px;
  background-image: repeating-linear-gradient(
    to bottom,
    #f5efe4 0px,
    #f5efe4 2px,
    #ece4d8 3px,
    #f7f1e8 4px
  );
  border-radius: 0 10px 10px 0;
  box-shadow:
    inset 1px 0 0 rgba(0,0,0,0.18),
    inset 0 0 0 rgba(255,255,255,0.9);
}

/* Cover-Seite */
.book-page.cover, .book-page.is-cover {
  background: linear-gradient(135deg, #f5d28b, #e0b45f);
  color: #2b1c0d;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}

/* Kopfzeile: Titel links, Pfeile rechts */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 8px;
}

.page-title-block h1 {
  margin: 0;
}

.page-title-block h2 {
  margin: 4px 0 0 0;
  font-family: "Style Script", "Brush Script MT", cursive;
  font-size: 1.6rem;
}

/* Pfeile rechts nebeneinander */
.page-arrows {
  display: flex;
  gap: 8px;
}

.page-arrow {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2px solid rgba(43,28,13,0.12);
  background: linear-gradient(180deg, #fff6e6, #f1dbbd);
  color: #5a3e2b;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow:
    0 6px 18px rgba(0,0,0,0.22),
    0 20px 45px rgba(0,0,0,0.10),
    inset 0 2px 0 rgba(255,255,255,0.65);
  transition: transform 200ms cubic-bezier(.2,.9,.3,1), box-shadow 200ms cubic-bezier(.2,.9,.3,1);
}

.page-arrow:hover:not(:disabled) {
  transform: translateY(-4px) scale(1.05);
  box-shadow:
    0 10px 28px rgba(0,0,0,0.26),
    0 30px 60px rgba(0,0,0,0.14),
    inset 0 3px 0 rgba(255,255,255,0.70);
}

.page-arrow:active:not(:disabled) {
  transform: translateY(-1px) scale(0.98);
  box-shadow:
    0 3px 8px rgba(0,0,0,0.16),
    0 10px 25px rgba(0,0,0,0.08);
}

.page-arrow:disabled {
  opacity: 0.4;
  cursor: default;
  background: linear-gradient(180deg, #f5f2ed, #e8e3d9);
  color: rgba(43,28,13,0.3);
}
	
.book-page {
  position: relative;
}

/* Siegel unten rechts auf dem Cover */
.cover-seal {
  position: absolute;
  right: 2rem;
  bottom: 1.8rem;
  width: 110px;
  height: 110px;
  display: block;
  object-fit: cover;
  filter: drop-shadow(0 10px 30px rgba(0,0,0,0.45));
  opacity: 1;
  pointer-events: none;
  border-radius: 50%;
  overflow: hidden;
  border: 4px solid rgba(255, 245, 220, 0.92);
  transform: rotate(-6deg);
}


/* Nur auf Seite 1 anzeigen (falls du per JS id="page-1" setzt) */
.book-page:not(.is-cover) .cover-seal {
  display: none;
}
	
/* Wasserzeichen-Siegel: wie Stempel unten rechts, nur transparent */
.page-watermark {
  position: absolute;
  right: 2.5rem;
  bottom: 2rem;
  pointer-events: none;
  z-index: 0;
}

.page-watermark img {
  width: 90px;         /* wie .cover-seal */
  height: auto;
  opacity: 0.15;       /* transparenter machen, z.B. 0.1–0.2 testen */
  filter: grayscale(1);
}

#page-content {
  position: relative;
  z-index: 1;
}


/* Seitenzähler unter der Kopfzeile */
.page-indicator {
  font-size: 0.75rem;
  color: #7a6a53;
  margin-bottom: 12px;
}

.gift-button {
  display: inline-flex;
  margin: 18px 8px 8px;
  width: 96px;
  height: 96px;
  padding: 0;
  font-size: 2.4rem;
  line-height: normal;
  text-align: center;
  border-radius: 50%;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  /* stronger contrast: subtle light border and deeper shadow */
  border: 2px solid rgba(43,28,13,0.10);
  background: linear-gradient(180deg, #fff6e6, #f1dbbd);
  color: #2b1c0d;
  box-shadow:
    0 8px 24px rgba(0,0,0,0.28),
    0 30px 60px rgba(0,0,0,0.14),
    inset 0 3px 0 rgba(255,255,255,0.7);
  transition: transform 220ms cubic-bezier(.2,.9,.3,1), box-shadow 220ms cubic-bezier(.2,.9,.3,1);
  animation: gift-pulse 1.6s ease-in-out infinite;
}

/* Row wrapper for multiple surprise buttons */
.surprise-buttons-row {
  text-align: center; /* center the inline buttons */
  margin-top: 6px;
}

.surprise-buttons-row .surprise-button {
  vertical-align: middle;
}

.gift-button:hover {
  transform: translateY(-8px) scale(1.04);
  box-shadow:
    0 18px 40px rgba(0,0,0,0.30),
    0 44px 90px rgba(0,0,0,0.20),
    inset 0 4px 0 rgba(255,255,255,0.75);
}

.gift-button:active {
  transform: translateY(-2px) scale(0.98);
  box-shadow:
    0 4px 10px rgba(0,0,0,0.18),
    0 12px 30px rgba(0,0,0,0.12);
}

@media (max-width: 480px) {
  .gift-button {
    width: 72px;
    height: 72px;
    font-size: 1.8rem;
    line-height: normal;
  }
}

/* subtle pulse animation for the gift button */
@keyframes gift-pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}



.surprise {
  position: absolute;
  left: 50%;
  top: 45%;
  transform: translate(-50%, -45%) scale(0.994);
  width: min(86%, 520px);
  max-height: 80vh;
  overflow-y: auto;
  background: linear-gradient(180deg, #ffffff 0%, #fffaf4 100%);
  color: #2b1c0d;
  padding: 16px 16px 14px 16px;
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,0.035);
  overflow: visible; /* allow decorative frame outside */
  box-shadow: 0 8px 20px rgba(0,0,0,0.16), inset 0 0.5px 0 rgba(255,255,255,0.8);
  opacity: 0;
  visibility: hidden;
  transition: opacity 180ms ease, transform 180ms cubic-bezier(.2,.9,.3,1), visibility 180ms, box-shadow 180ms ease;
  z-index: 60;
  pointer-events: none;
}

.surprise.open {
  opacity: 1;
  visibility: visible;
  /* very gentle lift */
  transform: translate(-50%, -45%) scale(1) translateY(-2px);
  box-shadow: 0 14px 32px rgba(0,0,0,0.20), inset 0 3px 6px rgba(255,255,255,0.6);
  pointer-events: auto;
}

/* golden decorative frame behind the panel */

.surprise::before {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 12px;
  /* even subtler gold gradient */
  background: linear-gradient(180deg, #fff8e9 0%, #fff0c9 36%, #e6c691 70%, #cfa26a 100%);
  box-shadow:
    0 6px 14px rgba(166,111,32,0.10),
    0 3px 8px rgba(0,0,0,0.10),
    inset 0 1px 2px rgba(255,255,255,0.42),
    inset 0 -2px 4px rgba(0,0,0,0.05);
  z-index: -1;
  pointer-events: none;
  transition: transform 180ms cubic-bezier(.2,.9,.3,1), box-shadow 180ms ease, opacity 180ms ease;
}

/* thin inner highlight to suggest bevel (behind content) */
.surprise::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(255,255,255,0.12), rgba(255,255,255,0));
  z-index: -1;
  pointer-events: none;
}

.surprise.open::before {
  transform: translateY(-2px) scale(1.002);
  box-shadow:
    0 12px 26px rgba(166,111,32,0.10),
    0 6px 14px rgba(0,0,0,0.12),
    inset 0 1px 4px rgba(255,255,255,0.42);
}

/* press state: push the panel down slightly */
.surprise:active,
.surprise.open:active {
  transform: translate(-50%, -45%) scale(0.995) translateY(-4px);
  box-shadow: 0 18px 40px rgba(0,0,0,0.28), inset 0 1px 0 rgba(255,255,255,0.7);
}

.surprise .close-surprise {
  position: absolute;
  right: 10px;
  top: 8px;
  border: none;
  background: transparent;
  font-size: 1.1rem;
  cursor: pointer;
  color: #6b5a49;
}

.surprise .surprise-content {
  margin-top: 8px;
  font-size: 0.97rem;
  line-height: 1.4;
}

.surprise-image {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 0 12px;
  border-radius: 8px;
}

/* Locked Chapter Modal */
.locked-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(3px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 0;
  animation: fadeIn 0.3s ease forwards;
}

@keyframes fadeIn {
  to { opacity: 1; }
}

.locked-modal {
  background: linear-gradient(135deg, #fff9f0 0%, #fef6e8 100%);
  border-radius: 16px;
  padding: 32px 28px;
  max-width: 420px;
  width: 90%;
  box-shadow: 
    0 20px 60px rgba(0,0,0,0.3),
    0 8px 20px rgba(0,0,0,0.2),
    inset 0 1px 0 rgba(255,255,255,0.8);
  border: 2px solid rgba(218,165,32,0.3);
  text-align: center;
  position: relative;
  transform: scale(0.9);
  animation: modalPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes modalPop {
  to { transform: scale(1); }
}

.locked-modal::before {
  content: '';
  position: absolute;
  inset: -6px;
  background: linear-gradient(135deg, #f8d98f 0%, #e0b063 50%, #c0912f 100%);
  border-radius: 18px;
  z-index: -1;
  box-shadow: 0 0 20px rgba(218,165,32,0.4);
}

.locked-modal-icon {
  font-size: 3.5rem;
  margin-bottom: 12px;
  display: block;
  animation: swing 1s ease-in-out infinite;
}

@keyframes swing {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-8deg); }
  75% { transform: rotate(8deg); }
}

.locked-modal-title {
  font-size: 1.5rem;
  color: #2b1608;
  margin: 0 0 16px;
  font-family: Georgia, serif;
  font-weight: bold;
}

.locked-modal-message {
  font-size: 1.05rem;
  color: #5a4a3a;
  line-height: 1.6;
  margin-bottom: 24px;
}

.locked-modal-date {
  display: inline-block;
  background: linear-gradient(135deg, #ffd700 0%, #ffb300 100%);
  color: #2b1608;
  padding: 8px 20px;
  border-radius: 20px;
  font-weight: bold;
  font-size: 1.1rem;
  margin: 8px 0 20px;
  box-shadow: 0 4px 12px rgba(255,215,0,0.4);
}

.locked-modal-button {
  background: linear-gradient(135deg, #e0b063 0%, #c0912f 100%);
  color: #fff;
  border: none;
  padding: 12px 32px;
  border-radius: 25px;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(0,0,0,0.2);
  transition: all 0.2s ease;
  font-family: Georgia, serif;
}

.locked-modal-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.25);
  background: linear-gradient(135deg, #d4a557 0%, #b58628 100%);
}

.locked-modal-button:active {
  transform: translateY(0);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

@media (max-width: 600px) {
  body { padding: 8px; }
  .book-wrapper {
    height: auto;
  }
  .book-shell {
    height: 75vh;
  }
  .book-back {
    height: 75vh;
  }
  .book-page {
    height: 75vh;
    padding: 18px 14px 26px 16px;
    transform: none;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
  }
  h1 { font-size: 1.4rem; }
  h2 { font-size: 1.1rem; }
  p  { font-size: 0.95rem; }
}

/* --- Cover: ensure centering when JS adds "is-cover" --- */
.book-page.cover,
.book-page.is-cover {
  /* richer golden gradient with subtle sheen */
  background: radial-gradient(circle at 10% 10%, rgba(255,255,255,0.06), transparent 8%),
              linear-gradient(135deg, #f8d98f 0%, #e0b063 45%, #c0912f 100%);
  color: #2b1608;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 26px 30px 40px 30px;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.18),
    0 34px 72px rgba(0,0,0,0.5);
  border: 1px solid rgba(0,0,0,0.06);
  position: relative;
}

/* Header on cover: column and centered */
.book-page.is-cover .page-header,
.book-page.cover .page-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 0;
  width: 100%;
}

/* arrows remain visible on cover (no hiding) */

/* title/subtitle spacing tweaks */
.book-page.is-cover .page-title-block h1,
.book-page.cover .page-title-block h1 {
  margin: 0;
  line-height: 1.05;
  font-size: 2.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #35210f;
  text-shadow: 0 1px 0 rgba(255,255,255,0.55), 0 10px 30px rgba(0,0,0,0.26);
}
.book-page.is-cover .page-title-block h2,
.book-page.cover .page-title-block h2 {
  margin: 8px 0 0 0;
  font-size: 1.1rem;
  font-weight: 400;
  color: rgba(43,28,13,0.85);
}

/* --- Elegant paper styling for regular pages --- */
.book-page:not(.is-cover) {
  background: linear-gradient(180deg, #fbf7f0 0%, #fbf6f2 100%);
  border: 1px solid rgba(0,0,0,0.04);
  box-shadow: 0 18px 40px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.6);
  color: #3b3328;
}

.book-page:not(.is-cover) .page-header {
  padding: 6px 0 8px 0;
}

.book-page:not(.is-cover) .page-title-block h1 {
  font-size: 1.25rem;
  margin: 0 0 6px 0;
  color: #2e2419;
}

.book-page:not(.is-cover) .page-title-block h2 {
  font-size: 1rem;
  margin: 0 0 8px 0;
  color: rgba(43,28,13,0.7);
}

.book-page:not(.is-cover) p {
  color: #3b3229;
  font-size: 1rem;
  line-height: 1.65;
  margin: 0 0 1.05rem 0;
}

/* decorative first-letter (drop cap) for the first paragraph */
.book-page:not(.is-cover) #page-content p:first-of-type::first-letter {
  float: left;
  font-size: 3.2rem;
  line-height: 1;
  margin-right: 0.45rem;
  font-weight: 700;
  color: #8a5a2b;
  font-family: Georgia, serif;
}

.book-page:not(.is-cover) .surprise {
  box-shadow: 0 26px 66px rgba(0,0,0,0.28);
}

/* TOC badge grid styles (first non-cover page) */
.toc {
  margin: 12px 0 18px 0;
  padding: 8px 6px;
}
.toc h3 {
  margin: 0 0 8px 0;
  font-size: 1.05rem;
  color: #2e2419;
}
.toc-badge-grid {
  display: grid;
  /* 4 columns x 3 rows (total 12 slots) */
  grid-template-columns: repeat(4, 2cm);
  grid-auto-rows: 2cm;
  gap: 12px;
  justify-content: center;
  align-items: center;
  margin-bottom: 12px;
}
.toc-badge-slot {
  width: 2cm;
  height: 2cm;
  min-width: 2cm;
  min-height: 2cm;
  border-radius: 50%;
  /* match the gift-button's refined look */
  background: linear-gradient(180deg, #fff6e6, #f1dbbd);
  border: 2px solid rgba(43,28,13,0.10);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 8px 24px rgba(0,0,0,0.22),
    0 30px 60px rgba(0,0,0,0.12),
    inset 0 3px 0 rgba(255,255,255,0.7);
  transition: transform 220ms cubic-bezier(.2,.9,.3,1), box-shadow 220ms cubic-bezier(.2,.9,.3,1);
}

.toc-badge-slot:hover {
  transform: translateY(-6px) scale(1.03);
  box-shadow:
    0 18px 40px rgba(0,0,0,0.30),
    0 44px 90px rgba(0,0,0,0.20),
    inset 0 4px 0 rgba(255,255,255,0.75);
}

/* active badge: golden shimmer with serrated 3D border */
.toc-badge-slot.active {
  border-color: rgba(218,165,32,0.35);
  box-shadow:
    0 10px 28px rgba(184,134,11,0.15),
    0 28px 60px rgba(184,134,11,0.08),
    0 4px 10px rgba(218,165,32,0.22),
    inset 0 4px 10px rgba(255,255,255,0.7);
  transform: translateY(-3px);
  position: relative;
  z-index: 10;
}

/* round golden glowing border behind the active badge */
.toc-badge-slot.active::before {
  content: '';
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: calc(100% + 12px);
  height: calc(100% + 12px);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(218,165,32,0.45) 0%, rgba(184,134,11,0.30) 60%, transparent 100%);
  filter: blur(2px);
  opacity: 0.45;
  z-index: -1;
  pointer-events: none;
  animation: starburst-pulse 2.2s ease-in-out infinite;
}

.toc-badge-slot.active::after {
  content: '';
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: calc(100% + 8px);
  height: calc(100% + 8px);
  border-radius: 50%;
  box-shadow: 
    0 0 16px rgba(218,165,32,0.35),
    0 0 28px rgba(184,134,11,0.18);
  opacity: 0.55;
  animation: badge-glow 1.6s ease-in-out infinite;
  pointer-events: none;
  z-index: -1;
}

@keyframes badge-glow {
  0% { opacity: 0.5; transform: translate(-50%, -50%) scale(0.98); }
  50% { opacity: 1.0; transform: translate(-50%, -50%) scale(1.04); }
  100% { opacity: 0.5; transform: translate(-50%, -50%) scale(0.98); }
}

@keyframes starburst-pulse {
  0% { opacity: 0.35; transform: translate(-50%, -50%) scale(0.96) rotate(0deg); }
  50% { opacity: 0.60; transform: translate(-50%, -50%) scale(1.03) rotate(3deg); }
  100% { opacity: 0.6; transform: translate(-50%, -50%) scale(0.95) rotate(0deg); }
}
.toc-badge-slot.empty {
  background: linear-gradient(180deg, #faf7f2, #f6f1e8);
  opacity: 0.65;
}

@media (max-width: 560px) {
  .toc-badge-grid {
    grid-template-columns: repeat(3, 2cm);
    gap: 10px;
  }
}
.toc-badge-img {
  width: calc(2cm - 10px);
  height: calc(2cm - 10px);
  border-radius: 50%;
  display: block;
  border-radius: 50%;
  box-shadow: inset 0 3px 6px rgba(255,255,255,0.6);
  object-fit: cover;
}
.toc-badge { font-size: 0.9rem; }
.toc-list { list-style: none; padding: 0; margin: 0; }
.toc-item { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.toc-text-wrap { display: flex; flex-direction: column; align-items: flex-start; }
.toc-title { font-size: 0.98rem; color: #2e2419; }
.toc-sub { font-size: 0.78rem; color: rgba(43,28,13,0.6); }
.toc-meta { margin-left: auto; font-size: 0.78rem; color: rgba(43,28,13,0.55); }

/* Copyright Footer */
.copyright-footer {
  width: 100%;
  text-align: center;
  padding: 20px 16px;
  background: transparent;
  color: #6b5a49;
  font-size: 0.85rem;
  font-family: "Georgia", serif;
  margin-top: 40px;
}

.copyright-footer p {
  margin: 0;
  opacity: 0.7;
}

@media (max-width: 600px) {
  .copyright-footer {
    font-size: 0.75rem;
    padding: 16px 8px;
    margin-top: 20px;
  }
}
