:root {
  --bg: #04010c;
  --ink: #f6efe6;
  --muted: rgba(246, 239, 230, 0.78);
  --gold: #e8c99a;
  --gold-soft: rgba(232, 201, 154, 0.9);
  --rose: #e8a0b4;
  --rose-deep: #9a3d58;
  --cream: #f7efe6;
  --panel: rgba(6, 2, 14, 0.72);
  font-synthesis: none;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Cormorant Garamond", Georgia, serif;
}

html {
  height: 100%;
  overflow: hidden;
}

body {
  min-height: 100%;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

html.unlocked {
  height: auto;
  overflow-x: hidden;
  overflow-y: scroll;
}

html.unlocked body {
  height: auto;
  min-height: 100%;
  overflow: visible;
}

#world {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  display: block;
}

.grain,
.vignette,
.bloom {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 4;
}

.grain {
  opacity: 0.06;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

.vignette {
  background: radial-gradient(
    ellipse at center,
    transparent 38%,
    rgba(4, 1, 12, 0.62) 100%
  );
}

.bloom {
  background: radial-gradient(
    ellipse 70% 50% at 50% 56%,
    rgba(232, 160, 180, 0.1),
    transparent 64%
  );
  opacity: 0;
  transition: opacity 1.4s ease;
}

body.near-heart .bloom {
  opacity: 1;
}

#progress {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  top: 50%;
  transform: translateY(-50%);
  z-index: 8;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.8s ease;
}

html.unlocked #progress {
  opacity: 1;
}

.progress-track {
  width: 1px;
  height: 28vh;
  background: rgba(232, 201, 154, 0.2);
  position: relative;
  overflow: hidden;
}

.progress-bar {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 0%;
  background: linear-gradient(to bottom, var(--gold), var(--rose));
}

.progress-eight {
  font-family: "Cinzel", serif;
  font-size: 13px;
  color: var(--gold);
  letter-spacing: 0.12em;
}

#gate {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  background: radial-gradient(ellipse at 50% 40%, #14081c 0%, #04010c 72%);
  transition: opacity 1.6s ease, visibility 1.6s ease;
}

#gate.gone {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.gate-inner {
  text-align: center;
  padding: 32px 24px 48px;
  max-width: 640px;
  position: relative;
  z-index: 1;
}

.eyebrow {
  font-family: "Cinzel", serif;
  font-size: 11px;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--gold-soft);
  margin-bottom: 18px;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.85);
}

.souls-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 48px;
  margin-bottom: 8px;
}

.soul {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: block;
  box-shadow: 0 0 18px 6px currentColor;
}

.soul-her {
  background: #ffb3c6;
  color: #ffb3c6;
  animation: pulse-her 3.6s ease-in-out infinite;
}

.soul-him {
  background: #f0d0a0;
  color: #f0d0a0;
  animation: pulse-him 3.6s ease-in-out infinite 0.6s;
}

.soul-thread {
  width: 52px;
  height: 1px;
  background: linear-gradient(90deg, #ffb3c6, #f0d0a0);
  opacity: 0.7;
  position: relative;
}

.soul-thread::after {
  content: "∞";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -54%);
  font-size: 13px;
  color: var(--gold);
  background: #04010c;
  padding: 0 4px;
}

@keyframes pulse-her {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.85;
  }
  50% {
    transform: scale(1.18);
    opacity: 1;
  }
}

@keyframes pulse-him {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.85;
  }
  50% {
    transform: scale(1.18);
    opacity: 1;
  }
}

#gate h1,
.chapter h2.heart-name {
  font-family: "Great Vibes", cursive;
  font-weight: 400;
  font-size: clamp(3.4rem, 9vw, 6.4rem);
  line-height: 1.05;
  color: var(--cream);
  text-shadow: 0 4px 28px rgba(0, 0, 0, 0.7);
}

#gate h1 {
  margin: 4px 0 14px;
}

.gate-dates {
  font-family: "Cinzel", serif;
  font-size: 12px;
  letter-spacing: 0.28em;
  color: var(--gold);
  margin-bottom: 22px;
}

.gate-line {
  font-size: clamp(1.15rem, 2.4vw, 1.45rem);
  font-style: italic;
  line-height: 1.55;
  color: var(--ink);
  margin-bottom: 32px;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.8);
}

#begin {
  appearance: none;
  border: 1px solid rgba(232, 201, 154, 0.45);
  background: rgba(10, 4, 18, 0.35);
  color: var(--gold);
  font-family: "Cinzel", serif;
  font-size: 11px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  padding: 14px 28px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
}

#begin:hover,
#begin:focus-visible {
  background: rgba(232, 201, 154, 0.12);
  transform: translateY(-1px);
  box-shadow: 0 8px 32px rgba(232, 160, 180, 0.18);
  outline: none;
}

.gate-hint {
  margin-top: 18px;
  font-family: "Cinzel", serif;
  font-size: 10px;
  letter-spacing: 0.36em;
  text-transform: uppercase;
  color: rgba(246, 239, 230, 0.45);
}

#scroll-space {
  height: 920vh;
  pointer-events: none;
}

#scroll-root {
  position: relative;
  z-index: 5;
}

#story {
  position: relative;
  min-height: 100vh;
}

.chapter {
  position: fixed;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  width: min(88vw, 36rem);
  text-align: center;
  opacity: 0;
  pointer-events: none;
  z-index: 6;
  padding: 24px 24px 26px;
  border-radius: 22px;
  background: linear-gradient(
    180deg,
    rgba(8, 3, 16, 0.62),
    rgba(6, 2, 14, 0.55)
  );
  border: 1px solid rgba(232, 201, 154, 0.12);
  box-shadow:
    0 18px 60px rgba(0, 0, 0, 0.38),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: none;
}

.chapter.is-on {
  pointer-events: auto;
}

.chapter h2 {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 500;
  font-size: clamp(1.7rem, 4.2vw, 2.45rem);
  line-height: 1.22;
  margin: 0 0 14px;
  color: var(--cream);
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.7);
}

.chapter p {
  font-size: clamp(1.08rem, 2.2vw, 1.28rem);
  line-height: 1.65;
  color: var(--muted);
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.75);
}

.chapter-dates .date-pair {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin: 8px 0 20px;
  flex-wrap: wrap;
}

.date-pair span {
  display: block;
  font-family: "Cinzel", serif;
  font-size: 10px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 6px;
}

.date-pair strong {
  display: block;
  font-family: "Cinzel", serif;
  font-weight: 500;
  font-size: clamp(0.95rem, 2.4vw, 1.15rem);
  letter-spacing: 0.12em;
  color: var(--cream);
}

.date-pair em {
  font-style: normal;
  font-size: 1.4rem;
  color: var(--gold);
  opacity: 0.9;
}

.chapter-final {
  top: auto;
  bottom: max(56px, calc(env(safe-area-inset-bottom) + 44px));
  width: min(90vw, 34rem);
  padding: 16px 18px 18px;
  background: linear-gradient(
    180deg,
    rgba(8, 3, 16, 0.28),
    rgba(6, 2, 14, 0.58)
  );
  border: 1px solid rgba(232, 201, 154, 0.1);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

.chapter-final .heart-name {
  min-height: 0.9em;
  margin-bottom: 6px;
  font-size: clamp(2.6rem, 7vw, 4.6rem);
}

.chapter-final .vow {
  max-width: 28rem;
  margin: 0 auto 18px;
}

.seal {
  font-family: "Great Vibes", cursive;
  font-size: clamp(1.5rem, 3.4vw, 2rem);
  color: var(--gold);
  margin-bottom: 6px;
}

.from {
  font-family: "Cinzel", serif;
  font-size: 11px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: rgba(232, 201, 154, 0.7);
}

#scroll-cue {
  position: fixed;
  left: 50%;
  bottom: max(22px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 8;
  font-family: "Cinzel", serif;
  font-size: 10px;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: rgba(246, 239, 230, 0.5);
  opacity: 0;
  pointer-events: none;
  animation: cue 2.8s ease-in-out infinite;
}

html.unlocked #scroll-cue.visible {
  opacity: 1;
}

html.unlocked.finale #scroll-cue {
  opacity: 0;
}

@keyframes cue {
  0%,
  100% {
    transform: translateX(-50%) translateY(0);
  }
  50% {
    transform: translateX(-50%) translateY(6px);
  }
}

#mute {
  position: fixed;
  left: max(16px, env(safe-area-inset-left));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 12;
  appearance: none;
  border: 1px solid rgba(232, 201, 154, 0.3);
  background: rgba(8, 3, 16, 0.55);
  color: var(--gold);
  font-family: "Cinzel", serif;
  font-size: 10px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  padding: 10px 14px;
  border-radius: 999px;
  cursor: pointer;
}

#mute[hidden] {
  display: none;
}

@media (max-width: 720px) {
  .chapter {
    width: min(92vw, 38rem);
    padding: 18px 16px 20px;
    top: 30%;
  }

  .chapter-final {
    top: auto;
    bottom: max(64px, calc(env(safe-area-inset-bottom) + 52px));
  }

  #progress {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .soul-her,
  .soul-him,
  #scroll-cue {
    animation: none;
  }
}
