:root {
  --paper: #fcf9f2;
  --paper-edge: #f2ebd9;
  --ink: #42342d;
  --ink-soft: #6e5b52;
  --muted: #9c877d;
  --rose: #b86b70;
  --rose-soft: #eecbc7;
  --gold: #bca06c;
  --gold-line: rgba(188, 160, 108, 0.25);
  --shadow: rgba(56, 38, 28, 0.16);
  --spine-shadow: rgba(40, 24, 16, 0.13);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 15% 20%, rgba(255, 255, 255, 0.85), transparent 30%),
    radial-gradient(circle at 85% 75%, rgba(238, 203, 199, 0.25), transparent 28%),
    #eae0d2;
  color: var(--ink);
  font-family: "Noto Sans KR", "Quicksand", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.12;
  background-image: radial-gradient(rgba(66, 52, 45, 0.4) 0.5px, transparent 0.5px);
  background-size: 4px 4px;
  mix-blend-mode: multiply;
  z-index: 1;
}

.ambient {
  position: fixed;
  width: 36vw;
  height: 36vw;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.22;
  pointer-events: none;
  z-index: 0;
}
.ambient-a { background: #f0cac4; left: -10vw; top: 6vh; }
.ambient-b { background: #dec6a7; right: -10vw; bottom: 2vh; }

.scene {
  position: relative;
  z-index: 2;
  width: min(1080px, 94vw);
  min-height: 100vh;
  margin: auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 28px 0 20px;
}

/* 상단 탑바 */
.topbar {
  width: min(960px, 92vw);
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  font-family: "Parisienne", cursive;
  font-size: 28px;
  color: #634f45;
  letter-spacing: 0.02em;
}

.music-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(188, 160, 108, 0.4);
  background: rgba(252, 249, 242, 0.75);
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: all 0.2s ease;
}

.music-btn:hover {
  background: #ffffff;
  border-color: var(--gold);
}

.music-btn.playing {
  border-color: var(--rose);
  color: var(--rose);
}

/* 책 래퍼 및 가름끈 */
.book-wrap {
  position: relative;
  width: min(960px, 92vw);
  aspect-ratio: 1.48 / 1;
  margin: 0 auto;
}

.ribbon {
  position: absolute;
  top: -8px;
  left: calc(50% - 10px);
  width: 20px;
  height: 44px;
  background: linear-gradient(to right, #9a3d42, var(--rose), #872e33);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.22);
  z-index: 25;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 82%, 0 100%);
  pointer-events: none;
}

.book {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--paper-edge);
  border-radius: 12px;
  box-shadow:
    0 28px 60px -16px var(--shadow),
    0 12px 24px -10px rgba(50, 30, 20, 0.1),
    0 0 0 1px rgba(70, 50, 40, 0.08);
}

/* 중앙 접힘선 그림자 */
.book::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 2px;
  transform: translateX(-50%);
  background: linear-gradient(
    to bottom,
    rgba(70, 48, 38, 0.15),
    rgba(70, 48, 38, 0.3) 15%,
    rgba(70, 48, 38, 0.3) 85%,
    rgba(70, 48, 38, 0.15)
  );
  z-index: 15;
  pointer-events: none;
}

/* 페이지 기본 구조 */
.page {
  position: relative;
  height: 100%;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.35), transparent 85%),
    var(--paper);
}

.left-page {
  border-radius: 12px 0 0 12px;
  box-shadow: inset -22px 0 28px -18px var(--spine-shadow);
  border-right: 1px solid rgba(70, 50, 40, 0.05);
}

.right-page {
  border-radius: 0 12px 12px 0;
  box-shadow: inset 22px 0 28px -18px var(--spine-shadow);
  border-left: 1px solid rgba(70, 50, 40, 0.05);
  cursor: pointer;
}

.page-inner {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/* 책등 방향 여백 확보 */
.left-page .page-inner {
  padding: 40px 48px 36px 48px;
}

.right-page .page-inner {
  padding: 40px 48px 36px 48px;
}

/* 테두리 프레임 장식 */
.page-frame {
  position: absolute;
  inset: 16px;
  border: 1px solid var(--gold-line);
  border-radius: 4px;
  pointer-events: none;
  opacity: 0.7;
}

.left-page .page-frame {
  left: 20px;
  right: 18px;
}

.right-page .page-frame {
  left: 18px;
  right: 20px;
}

/* 헤더 및 페이지 번호 */
.running-header {
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
  z-index: 5;
}

.running-header.left { text-align: left; }
.running-header.right { text-align: right; }

.page-number {
  font-family: "Cormorant Garamond", serif;
  font-size: 13px;
  letter-spacing: 0.15em;
  color: var(--muted);
  font-weight: 600;
  z-index: 5;
}

.left-num { text-align: left; }
.right-num { text-align: right; }

/* 본문 영역 컨테이너 */
.page-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  z-index: 5;
  transition: opacity 0.26s ease, transform 0.26s ease;
}

.page-content {
  width: 100%;
}

.center {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}

/* 타이포그래피 */
.kicker {
  font-family: "Noto Sans KR", sans-serif;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--rose);
  margin-bottom: 12px;
  word-break: keep-all;
}

h1, h2 {
  font-family: "Noto Serif KR", "Cormorant Garamond", serif;
  font-weight: 600;
  margin: 0;
  line-height: 1.18;
  word-break: keep-all;
  color: var(--ink);
}

h1 {
  font-size: clamp(40px, 4.8vw, 64px);
  letter-spacing: -0.02em;
}

h2 {
  font-size: clamp(28px, 3.4vw, 42px);
  letter-spacing: -0.015em;
}

.script {
  font-family: "Parisienne", "Noto Serif KR", cursive;
  font-size: clamp(34px, 4.2vw, 48px);
  font-weight: 500;
  color: var(--rose);
  line-height: 1.25;
  margin: 4px 0;
  word-break: keep-all;
}

p {
  font-family: "Noto Serif KR", serif;
  font-size: clamp(15px, 1.5vw, 18px);
  line-height: 1.8;
  letter-spacing: -0.015em;
  word-break: keep-all;
  margin: 12px 0;
  max-width: 380px;
}

.small {
  font-family: "Noto Sans KR", "Quicksand", sans-serif;
  font-size: 13px;
  line-height: 1.75;
  color: var(--ink-soft);
  word-break: keep-all;
  max-width: 360px;
}

.divider {
  width: 54px;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--gold), transparent);
  margin: 16px auto;
}

.cover-flower {
  font-size: 36px;
  margin-bottom: 10px;
  color: var(--rose);
  animation: float 4s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-5px) rotate(3deg); }
}

.heart {
  color: var(--rose);
  font-size: 26px;
  margin-top: 10px;
}

.note-card {
  border: 1px solid rgba(188, 160, 108, 0.35);
  background: rgba(255, 255, 255, 0.6);
  padding: 20px;
  margin-top: 16px;
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(50, 30, 20, 0.04);
}

.signature {
  font-family: "Parisienne", cursive;
  color: var(--rose);
  font-size: 32px;
  margin-top: 18px;
}

/* 추억 사진 4장 그리드 (폴라로이드 스타일) */
.memory-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  align-content: center;
  max-width: 380px;
  margin: 0 auto;
}

.memory-grid img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  padding: 6px 6px 12px;
  background: #ffffff;
  box-shadow: 0 8px 18px rgba(50, 30, 20, 0.12);
  border-radius: 2px;
  transition: transform 0.2s ease;
}

.memory-grid img:hover {
  transform: scale(1.05) rotate(0deg) !important;
  z-index: 5;
}

.memory-grid img:nth-child(1) { transform: rotate(-2.5deg); }
.memory-grid img:nth-child(2) { transform: rotate(2deg); }
.memory-grid img:nth-child(3) { transform: rotate(1.8deg); }
.memory-grid img:nth-child(4) { transform: rotate(-2deg); }

/* 마지막 페이지 꽃잎 애니메이션 */
.final {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  flex-direction: column;
  position: relative;
}

.final .petals span {
  position: absolute;
  font-size: 20px;
  opacity: 0;
  animation: petal 4.8s ease-in infinite;
  pointer-events: none;
}

.final .petals span:nth-child(1) { left: 10%; animation-delay: 0.2s; }
.final .petals span:nth-child(2) { left: 30%; animation-delay: 1.2s; }
.final .petals span:nth-child(3) { left: 52%; animation-delay: 0.5s; }
.final .petals span:nth-child(4) { left: 74%; animation-delay: 1.8s; }
.final .petals span:nth-child(5) { left: 88%; animation-delay: 2.4s; }

@keyframes petal {
  0% { top: -10%; opacity: 0; transform: rotate(0); }
  15% { opacity: 0.7; }
  100% { top: 105%; opacity: 0; transform: rotate(220deg) translateX(35px); }
}

/* 네비게이션 버튼 */
.nav {
  position: absolute;
  top: 50%;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(188, 160, 108, 0.35);
  border-radius: 50%;
  background: rgba(252, 249, 242, 0.85);
  color: var(--ink);
  font-size: 32px;
  line-height: 38px;
  cursor: pointer;
  z-index: 30;
  transform: translateY(-50%);
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 14px rgba(50, 30, 20, 0.08);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav:hover:not(:disabled) {
  background: #ffffff;
  transform: translateY(-50%) scale(1.08);
}

.nav.prev { left: -64px; }
.nav.next { right: -64px; }
.nav:disabled { opacity: 0.22; cursor: default; }

/* 하단 닷 인디케이터 */
.controls {
  width: min(960px, 92vw);
  margin: 16px auto 0;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  gap: 10px;
}

.hint {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.dots { display: flex; gap: 8px; }

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #cfbeaf;
  transition: all 0.25s ease;
  cursor: pointer;
}

.dot.active {
  width: 20px;
  border-radius: 5px;
  background: var(--rose);
}

/* 페이지 전환 애니메이션 */
.book.changing .left-page .page-body {
  opacity: 0;
  transform: translateX(-10px);
}

.book.changing .right-page .page-body {
  opacity: 0;
  transform: translateX(10px);
}

.book.changing.reverse .left-page .page-body {
  opacity: 0;
  transform: translateX(10px);
}

.book.changing.reverse .right-page .page-body {
  opacity: 0;
  transform: translateX(-10px);
}

/* 모바일 반응형 (760px 이하) */
@media (max-width: 760px) {
  .scene { padding: 16px 0; }
  .topbar { margin-bottom: 12px; }
  .brand { font-size: 24px; }

  .book-wrap {
    width: 92vw;
    aspect-ratio: auto;
  }

  .ribbon { display: none; }

  /* 모바일에서 왼쪽 페이지가 숨겨지지 않고 세로로 자연스럽게 배치되도록 수정 */
  .book {
    grid-template-columns: 1fr;
    gap: 14px;
    background: transparent;
    box-shadow: none;
  }

  .book::after { display: none; }

  .page {
    border-radius: 12px;
    box-shadow: 0 8px 22px var(--shadow);
    min-height: 380px;
  }

  .left-page, .right-page {
    border-radius: 12px;
  }

  .left-page .page-inner,
  .right-page .page-inner {
    padding: 34px 24px 28px;
  }

  .page-frame { inset: 12px !important; }

  .nav {
    position: fixed;
    bottom: 20px;
    top: auto;
    transform: none;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
    background: rgba(252, 249, 242, 0.95);
  }

  .nav.prev { left: 18px; }
  .nav.next { right: 18px; }
  .nav:hover:not(:disabled) { transform: scale(1.05); }

  .controls { margin-bottom: 46px; }

  h1 { font-size: 38px; }
  h2 { font-size: 28px; }
  .script { font-size: 32px; }
}