:root {
  color-scheme: light;
  --ink: #372824;
  --paper: #fffaf7;
  --muted: #8a6860;
  --rose: #de7c78;
  --rose-deep: #a94a4e;
  --peach: #f5b095;
  --gold: #f4c77e;
  --shadow: 0 22px 70px rgba(55, 40, 36, 0.26);
  --font-body: "Songti SC", "STSong", "SimSun", "Noto Serif CJK SC", serif;
  --font-display: "STKaiti", "KaiTi", "Kaiti SC", "Songti SC", "STSong", "SimSun", serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  font-family: var(--font-body);
  color: var(--ink);
  background: #1e1515;
}

button {
  font: inherit;
}

.show,
.stage {
  width: 100%;
  height: 100%;
}

.stage {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  place-items: stretch center;
  gap: 14px;
  padding: 46px clamp(16px, 3.5vw, 42px) 24px;
  isolation: isolate;
}

.stage-bg,
.stage-shade {
  position: absolute;
  inset: 0;
  z-index: -3;
}

.stage-bg {
  background-position: center;
  background-size: cover;
  transform: scale(1.08);
  filter: blur(20px) saturate(1.08);
  opacity: 0.64;
  transition: background-image 0.5s ease, opacity 0.5s ease;
}

.stage-shade {
  z-index: -2;
  background:
    radial-gradient(circle at 18% 16%, rgba(255, 236, 219, 0.38), transparent 28%),
    radial-gradient(circle at 78% 28%, rgba(244, 199, 126, 0.2), transparent 30%),
    linear-gradient(90deg, rgba(24, 13, 14, 0.76), rgba(45, 25, 25, 0.28) 48%, rgba(24, 13, 14, 0.68));
}

.stage-media {
  grid-row: 1;
  width: min(1180px, 94vw);
  height: 100%;
  max-height: calc(100vh - 238px);
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.22fr) minmax(270px, 0.78fr);
  gap: 18px;
  align-items: stretch;
  margin: 0;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.photo-main,
.photo-grid,
.places-board,
.heart-wrap {
  min-width: 0;
}

.opening-frame {
  position: relative;
  grid-column: 1 / -1;
  align-self: center;
  justify-self: center;
  width: min(620px, 76vw);
  aspect-ratio: 16 / 9;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 246, 240, 0.28);
  border-radius: 28px;
  color: rgba(255, 250, 247, 0.72);
  background:
    radial-gradient(circle at 50% 46%, rgba(255, 220, 210, 0.14), transparent 34%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02));
  box-shadow: 0 28px 80px rgba(18, 8, 8, 0.22);
  backdrop-filter: blur(8px);
}

.opening-frame span {
  position: absolute;
  display: none;
  font-family: var(--font-display);
  font-size: clamp(7rem, 20vw, 16rem);
  line-height: 1;
  opacity: 0.08;
}

.opening-frame strong {
  display: none;
  font-family: var(--font-display);
  font-size: clamp(1.3rem, 3vw, 2.3rem);
  font-weight: 400;
  letter-spacing: 0;
}

.photo-main {
  position: relative;
  overflow: hidden;
  border-radius: 24px;
  box-shadow: var(--shadow);
  background: rgba(255, 250, 247, 0.18);
  outline: 1px solid rgba(255, 255, 255, 0.2);
}

.photo-main img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.photo-main::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 1px solid rgba(255, 255, 255, 0.36);
  border-radius: inherit;
  box-shadow: inset 0 -120px 120px rgba(20, 10, 10, 0.16);
  pointer-events: none;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: 1fr;
  gap: 12px;
}

.photo-grid img,
.place-gallery img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.photo-grid figure {
  position: relative;
  margin: 0;
  overflow: hidden;
  border-radius: 16px;
  background: rgba(255, 250, 247, 0.16);
  box-shadow: 0 14px 32px rgba(18, 8, 8, 0.22);
  outline: 1px solid rgba(255, 255, 255, 0.18);
}

.photo-grid figure:nth-child(1),
.photo-grid figure:nth-child(4) {
  transform: translateY(12px);
}

.places-board {
  grid-column: 1 / -1;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-flow: dense;
  align-content: start;
  gap: 12px;
  overflow: auto;
  padding: 4px 6px 10px;
  scrollbar-width: thin;
}

.place-group {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border-radius: 18px;
  background: rgba(255, 250, 247, 0.9);
  box-shadow: 0 18px 44px rgba(18, 8, 8, 0.18);
}

.place-group.is-wide {
  grid-column: span 2;
}

.place-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  color: #4a302d;
}

.place-head strong {
  min-width: 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.place-head span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.8rem;
}

.place-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(46px, 1fr));
  gap: 5px;
}

.place-gallery figure {
  margin: 0;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 8px;
  background: #ead6cc;
}

.heart-wrap {
  grid-column: 1 / -1;
  position: relative;
  display: grid;
  place-items: center;
  height: 100%;
  border-radius: 28px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 45%, rgba(255, 235, 228, 0.22), transparent 44%),
    linear-gradient(135deg, rgba(77, 29, 34, 0.72), rgba(23, 13, 16, 0.82));
  box-shadow: var(--shadow);
}

.heart-wrap canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.heart-caption {
  position: absolute;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  padding: 8px 14px;
  border-radius: 999px;
  color: #fff;
  background: rgba(34, 18, 18, 0.58);
  backdrop-filter: blur(8px);
  font-size: 0.95rem;
}

.lyric-panel {
  grid-row: 2;
  position: relative;
  width: min(1040px, 94vw);
  padding: 12px 22px 14px;
  border-top: 1px solid rgba(255, 229, 221, 0.45);
  border-radius: 24px;
  color: #fff;
  background: linear-gradient(180deg, rgba(34, 18, 18, 0.34), rgba(34, 18, 18, 0.2));
  backdrop-filter: blur(10px);
  text-shadow: 0 3px 20px rgba(0, 0, 0, 0.48);
  text-align: center;
}

.slide-meta {
  display: none;
  align-items: center;
  gap: 9px;
  padding: 7px 11px;
  border-radius: 999px;
  background: rgba(38, 22, 20, 0.48);
  backdrop-filter: blur(8px);
  font-size: 0.86rem;
  color: rgba(255, 250, 247, 0.9);
}

.slide-meta span + span::before {
  content: "/";
  margin-right: 9px;
  color: rgba(255, 255, 255, 0.55);
}

.lyric-panel h1 {
  margin: 10px auto 6px;
  max-width: min(980px, 92vw);
  font-family: var(--font-display);
  font-size: clamp(2rem, 4.8vw, 4.7rem);
  line-height: 1.12;
  letter-spacing: 0;
  text-wrap: balance;
  word-break: keep-all;
  overflow-wrap: normal;
}

.lyric-chunk {
  display: inline-block;
  margin: 0 0.07em;
  white-space: nowrap;
}

.lyric-panel p {
  display: none;
  margin: 0 auto;
  max-width: 38em;
  font-size: clamp(0.95rem, 1.8vw, 1.15rem);
  line-height: 1.8;
  color: rgba(255, 248, 245, 0.86);
}

.stage.is-text-only .stage-bg {
  opacity: 0;
}

.stage.is-text-only .stage-media {
  opacity: 1;
  transform: none;
}

.stage.is-text-only .slide-meta {
  background: rgba(255, 250, 247, 0.12);
}

.stage.is-text-only .lyric-panel h1 {
  max-width: none;
  font-size: clamp(2.15rem, 5.3vw, 5.2rem);
}

.stage.is-places .stage-media,
.stage.is-heart .stage-media {
  max-height: calc(100vh - 238px);
}

.controls {
  grid-row: 3;
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  z-index: 4;
}

.control-btn {
  min-width: 76px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 999px;
  padding: 8px 15px;
  color: #fff;
  background: rgba(38, 22, 20, 0.38);
  box-shadow: 0 10px 22px rgba(18, 8, 8, 0.22);
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: transform 0.18s ease, background 0.18s ease;
}

.control-btn:hover {
  transform: translateY(-1px);
  background: rgba(74, 38, 36, 0.62);
}

.control-btn.is-primary {
  color: #3a2221;
  border-color: transparent;
  background: linear-gradient(135deg, #fff3e4, #f3b2a8);
}

.progress-wrap {
  position: absolute;
  left: clamp(18px, 5vw, 72px);
  right: clamp(18px, 5vw, 72px);
  bottom: 8px;
  height: 3px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.24);
}

.progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold), #fff5ed, var(--rose));
  transition: width 0.2s linear;
}

.chapter-dots {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  width: min(860px, calc(100vw - 32px));
  display: flex;
  justify-content: center;
  gap: 6px;
  z-index: 4;
}

.chapter-dots button {
  width: 20px;
  height: 6px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.32);
  cursor: pointer;
  transition: width 0.2s ease, background 0.2s ease;
}

.chapter-dots button.is-active {
  width: 42px;
  background: #fff7ef;
}

@media (max-width: 820px) {
  .stage {
    gap: 10px;
    padding: 42px 14px 22px;
  }

  .stage-media {
    width: 100%;
    height: 100%;
    max-height: calc(100vh - 238px);
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) 88px;
    gap: 10px;
  }

  .photo-main {
    min-height: 0;
  }

  .photo-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    min-height: 96px;
  }

  .photo-grid figure:nth-child(n + 5) {
    display: none;
  }

  .places-board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .place-group.is-wide {
    grid-column: span 1;
  }

  .place-gallery {
    grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  }

  .lyric-panel {
    width: 100%;
    padding: 10px 12px 12px;
  }

  .lyric-panel h1 {
    max-width: 100%;
    font-size: clamp(1.7rem, 7.8vw, 3.2rem);
  }

  .controls {
    width: 100%;
    justify-content: space-between;
  }

  .control-btn {
    min-width: 0;
    flex: 1;
    padding: 10px 12px;
  }
}

@media (max-width: 520px) {
  .stage-media {
    max-height: calc(100vh - 220px);
    grid-template-rows: minmax(0, 1fr);
  }

  .photo-grid {
    display: none;
  }

  .places-board {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .place-gallery {
    grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
  }

  .heart-caption {
    bottom: 16px;
    font-size: 0.84rem;
  }

  .chapter-dots button {
    width: 12px;
  }

  .chapter-dots button.is-active {
    width: 28px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .stage-bg,
  .control-btn,
  .chapter-dots button,
  .progress-bar {
    transition: none;
  }
}
