:root {
  --paper: #f3e9d8;
  --paper-deep: #e8d9bd;
  --ink: #2b1d12;
  --ink-soft: #5a4530;
  --terracotta: #c1654a;
  --terracotta-deep: #9a4530;
  --gold: #b88a4a;
  --gold-soft: #d6b27a;
  --teal: #3d6b6e;
  --sand: #d9b88a;
  --plum: #6b3a4e;
  --rose: #d49a8a;
  --shadow: rgba(43, 29, 18, 0.18);
}

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

html, body {
  background: var(--paper);
  color: var(--ink);
  font-family: 'Spectral', Georgia, serif;
  font-weight: 300;
  line-height: 1.6;
  overflow-x: hidden;
  min-height: 100vh;
  min-height: 100dvh;
}

/* Paper texture overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(193, 101, 74, 0.04) 0%, transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(61, 107, 110, 0.04) 0%, transparent 40%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' seed='5'/><feColorMatrix values='0 0 0 0 0.17, 0 0 0 0 0.11, 0 0 0 0 0.07, 0 0 0 0.08 0'/></filter><rect width='200' height='200' filter='url(%23n)'/></svg>");
  mix-blend-mode: multiply;
  opacity: 0.6;
}

/* ============================================
   PASSWORD GATE
   ============================================ */
#gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #d9b88a 0%, #c1654a 50%, #6b3a4e 100%);
  transition: opacity 1.2s ease, visibility 1.2s ease;
  padding: 20px;
}
#gate::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='400' height='400'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/><feColorMatrix values='0 0 0 0 0, 0 0 0 0 0, 0 0 0 0 0, 0 0 0 0.15 0'/></filter><rect width='400' height='400' filter='url(%23n)'/></svg>");
  opacity: 0.5;
  mix-blend-mode: multiply;
}
#gate.hidden { opacity: 0; visibility: hidden; }

.gate-card {
  position: relative;
  background: var(--paper);
  padding: 60px 50px 50px;
  max-width: 460px;
  width: 90%;
  text-align: center;
  box-shadow: 0 30px 80px rgba(0,0,0,0.35), 0 0 0 1px rgba(255,255,255,0.1);
  z-index: 2;
  border-radius: 2px;
}
.gate-card::before, .gate-card::after {
  content: '';
  position: absolute;
  left: 30px; right: 30px;
  height: 1px;
  background: var(--terracotta);
  opacity: 0.4;
}
.gate-card::before { top: 20px; }
.gate-card::after { bottom: 20px; }

.gate-ornament {
  font-family: 'Caveat', cursive;
  font-size: 28px;
  color: var(--terracotta);
  margin-bottom: 8px;
}
.gate-card h1 {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 400;
  font-style: italic;
  font-size: 36px;
  line-height: 1.15;
  color: var(--ink);
  margin-bottom: 18px;
  letter-spacing: 0.5px;
}
.gate-card p {
  font-size: 15px;
  color: var(--ink-soft);
  margin-bottom: 28px;
  font-style: italic;
}
.gate-card input {
  width: 100%;
  padding: 14px 18px;
  font-family: 'Spectral', serif;
  font-size: 16px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--ink-soft);
  color: var(--ink);
  text-align: center;
  letter-spacing: 2px;
  outline: none;
  transition: border-color 0.3s;
}
.gate-card input:focus { border-bottom-color: var(--terracotta); }
.gate-card input::placeholder { color: var(--ink-soft); opacity: 0.5; letter-spacing: 1px; }
.gate-card button {
  margin-top: 24px;
  padding: 12px 36px;
  background: var(--ink);
  color: var(--paper);
  border: none;
  font-family: 'Cormorant Garamond', serif;
  font-size: 14px;
  letter-spacing: 4px;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.3s, transform 0.2s;
}
.gate-card button:hover { background: var(--terracotta); transform: translateY(-1px); }
#gate-error {
  color: var(--terracotta-deep);
  font-size: 13px;
  font-style: italic;
  margin-top: 14px;
  min-height: 18px;
  opacity: 0;
  transition: opacity 0.3s;
}
#gate-error.show { opacity: 1; }

/* ============================================
   MAIN CONTENT
   ============================================ */
.container { position: relative; z-index: 2; }

/* HERO */
.hero {
  min-height: 100vh;
  min-height: 100dvh;
  padding: 60px 24px 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  position: relative;
}
.hero-ornament {
  font-family: 'Caveat', cursive;
  font-size: 22px;
  color: var(--terracotta);
  margin-bottom: 12px;
  opacity: 0;
  animation: fadeUp 1s ease 0.3s forwards;
}
.hero h1 {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 300;
  font-size: clamp(48px, 9vw, 120px);
  line-height: 0.95;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin-bottom: 8px;
  opacity: 0;
  animation: fadeUp 1.2s ease 0.5s forwards;
}
.hero h1 em {
  font-style: italic;
  color: var(--terracotta-deep);
  font-weight: 400;
}
.hero h2 {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-weight: 300;
  font-size: clamp(20px, 3vw, 28px);
  color: var(--ink-soft);
  margin: 14px 0 24px;
  max-width: 600px;
  opacity: 0;
  animation: fadeUp 1.2s ease 0.8s forwards;
}
.hero-couple {
  font-family: 'Caveat', cursive;
  font-size: clamp(28px, 5vw, 42px);
  color: var(--terracotta);
  margin: 18px 0;
  opacity: 0;
  animation: fadeUp 1.2s ease 1.1s forwards;
}
.hero-divider {
  width: 80px;
  height: 1px;
  background: var(--gold);
  margin: 20px auto;
  position: relative;
  opacity: 0;
  animation: fadeUp 1.2s ease 1.3s forwards;
}
.hero-divider::before {
  content: '✺';
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--gold);
  background: var(--paper);
  padding: 0 8px;
  font-size: 14px;
}
.hero-scroll {
  margin-top: 60px;
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 14px;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--ink-soft);
  opacity: 0;
  animation: fadeUp 1.2s ease 1.6s forwards;
}
.hero-scroll span {
  display: inline-block;
  animation: bob 2s ease-in-out infinite;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(6px); }
}

/* SECTIONS */
section { padding: 80px 24px; position: relative; }
.section-inner { max-width: 1100px; margin: 0 auto; }
.section-label {
  font-family: 'Caveat', cursive;
  color: var(--terracotta);
  font-size: 22px;
  margin-bottom: 8px;
  display: block;
}
.section-title {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 300;
  font-size: clamp(36px, 6vw, 64px);
  line-height: 1;
  margin-bottom: 24px;
  color: var(--ink);
}
.section-title em { font-style: italic; color: var(--terracotta-deep); }
.section-intro {
  font-family: 'Spectral', serif;
  font-style: italic;
  font-size: 18px;
  color: var(--ink-soft);
  max-width: 620px;
  margin-bottom: 50px;
}

/* THE JOURNEY MAP */
.journey-map {
  background: var(--paper-deep);
  padding: 60px 30px;
  position: relative;
  border: 1px solid rgba(184, 138, 74, 0.3);
}
.journey-map::before, .journey-map::after {
  content: '';
  position: absolute;
  width: 60px; height: 60px;
  border: 1px solid var(--gold);
}
.journey-map::before { top: 12px; left: 12px; border-right: none; border-bottom: none; }
.journey-map::after { bottom: 12px; right: 12px; border-left: none; border-top: none; }

.map-svg-wrap {
  position: relative;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
}
.map-svg { width: 100%; height: auto; display: block; }

.map-dot {
  cursor: pointer;
  pointer-events: bounding-box;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.map-dot * {
  pointer-events: none;
}
.map-dot circle.hit {
  fill: transparent;
  pointer-events: all;
}
.map-dot circle.pulse {
  fill: var(--terracotta);
  opacity: 0;
  transform-origin: center;
  transform-box: fill-box;
  animation: pulse 2.8s ease-out infinite;
  will-change: transform, opacity;
}
.map-dot circle.core {
  fill: var(--terracotta-deep);
  stroke: var(--paper);
  stroke-width: 2;
  transition: fill 0.3s;
}
.map-dot:hover circle.core { fill: var(--ink); }
.map-dot:focus { outline: none; }
.map-dot:focus-visible circle.core { fill: var(--ink); stroke: var(--gold); stroke-width: 3; }
.map-dot text {
  font-family: 'Caveat', cursive;
  font-size: 20px;
  fill: var(--ink);
  font-weight: 600;
}

@keyframes pulse {
  0% { transform: scale(0.5); opacity: 0.5; }
  80% { opacity: 0; }
  100% { transform: scale(2.2); opacity: 0; }
}

.map-instruction {
  text-align: center;
  font-family: 'Caveat', cursive;
  color: var(--terracotta);
  font-size: 24px;
  margin-top: 20px;
}
.map-instruction span {
  display: inline-block;
  transform: rotate(-3deg);
}

/* ============================================
   CHAPTER MODALS
   ============================================ */
.chapter-overlay {
  position: fixed;
  inset: 0;
  background: rgba(43, 29, 18, 0.85);
  z-index: 50;
  display: none;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 30px 16px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.chapter-overlay.active {
  display: flex;
  animation: fadeIn 0.4s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.chapter {
  background: var(--paper);
  max-width: 760px;
  width: 100%;
  padding: 50px 40px 60px;
  position: relative;
  box-shadow: 0 40px 100px rgba(0,0,0,0.5);
  margin: auto;
  animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(40px); }
  to { opacity: 1; transform: translateY(0); }
}
.chapter-close {
  position: absolute;
  top: 20px; right: 24px;
  background: none;
  border: none;
  font-size: 30px;
  color: var(--ink-soft);
  cursor: pointer;
  line-height: 1;
  font-family: 'Cormorant Garamond', serif;
  transition: color 0.3s, transform 0.3s;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.chapter-close:hover { color: var(--terracotta); transform: rotate(90deg); }

.chapter-eyebrow {
  font-family: 'Caveat', cursive;
  color: var(--terracotta);
  font-size: 22px;
  margin-bottom: 4px;
}
.chapter-title {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 300;
  font-size: clamp(36px, 6vw, 56px);
  line-height: 1;
  color: var(--ink);
  margin-bottom: 8px;
}
.chapter-title em { font-style: italic; color: var(--terracotta-deep); }
.chapter-meta {
  font-family: 'Spectral', serif;
  font-style: italic;
  color: var(--ink-soft);
  font-size: 16px;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--gold-soft);
}
.chapter-prose {
  font-size: 17px;
  color: var(--ink);
  margin-bottom: 36px;
  line-height: 1.7;
}
.chapter-prose p + p { margin-top: 14px; }

.game-prompt {
  text-align: center;
  margin: 30px 0 24px;
}
.game-prompt-label {
  font-family: 'Caveat', cursive;
  color: var(--terracotta);
  font-size: 26px;
  margin-bottom: 4px;
}
.game-prompt-instruction {
  font-family: 'Spectral', serif;
  font-style: italic;
  color: var(--ink-soft);
  font-size: 14px;
}

/* CARD FLIP GAME */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.flip-card {
  aspect-ratio: 3 / 4;
  -webkit-perspective: 1000px;
  perspective: 1000px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.flip-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  -webkit-transition: -webkit-transform 0.7s cubic-bezier(0.4, 0.2, 0.2, 1);
  transition: transform 0.7s cubic-bezier(0.4, 0.2, 0.2, 1);
  -webkit-transform-style: preserve-3d;
  transform-style: preserve-3d;
}
.flip-card.flipped .flip-card-inner {
  -webkit-transform: rotateY(180deg);
  transform: rotateY(180deg);
}

.flip-face {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  -webkit-transform: rotateY(0deg);
  transform: rotateY(0deg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  text-align: center;
  box-shadow: 0 4px 14px var(--shadow);
}

.flip-front {
  background: linear-gradient(135deg, var(--terracotta) 0%, var(--terracotta-deep) 100%);
  color: var(--paper);
  flex-direction: column;
  overflow: hidden;
}
.flip-front::before {
  content: '';
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(255, 233, 200, 0.4);
}
.flip-front-symbol {
  font-family: 'Cormorant Garamond', serif;
  font-size: 48px;
  line-height: 1;
  margin-bottom: 8px;
  font-style: italic;
  opacity: 0.95;
}
.flip-front-label {
  font-family: 'Caveat', cursive;
  font-size: 18px;
  letter-spacing: 1px;
  z-index: 1;
}
.flip-front-num {
  position: absolute;
  top: 12px;
  left: 14px;
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 14px;
  opacity: 0.7;
}

.flip-back {
  background: var(--paper);
  -webkit-transform: rotateY(180deg);
  transform: rotateY(180deg);
  flex-direction: column;
  border: 1px solid var(--gold-soft);
  padding: 14px;
}
.flip-back-title {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  color: var(--terracotta-deep);
  font-size: 14px;
  margin-bottom: 8px;
  letter-spacing: 0.5px;
}
.flip-back-text {
  font-family: 'Spectral', serif;
  color: var(--ink);
  font-size: 12.5px;
  line-height: 1.45;
}

/* THE GIFT REVEAL */
.gift-section {
  background: linear-gradient(180deg, var(--paper) 0%, var(--paper-deep) 100%);
  padding: 100px 24px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.gift-section::before {
  content: '';
  position: absolute;
  top: -50px; left: 50%;
  transform: translateX(-50%);
  width: 1px; height: 100px;
  background: var(--gold);
}
.gift-section::after {
  content: '✺';
  position: absolute;
  top: 40px; left: 50%;
  transform: translateX(-50%);
  color: var(--gold);
  font-size: 18px;
}

.gift-inner {
  max-width: 720px;
  margin: 0 auto;
  position: relative;
}
.gift-label {
  font-family: 'Caveat', cursive;
  color: var(--terracotta);
  font-size: 26px;
  margin-bottom: 6px;
}
.gift-section h2 {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 300;
  font-size: clamp(40px, 7vw, 72px);
  line-height: 1.05;
  color: var(--ink);
  margin-bottom: 24px;
}
.gift-section h2 em { font-style: italic; color: var(--terracotta-deep); }

.gift-envelope {
  background: var(--paper);
  padding: 50px 40px;
  margin: 30px auto;
  max-width: 580px;
  position: relative;
  box-shadow: 0 20px 50px var(--shadow);
  border: 1px solid var(--gold-soft);
}
.gift-envelope::before {
  content: '';
  position: absolute;
  inset: 10px;
  border: 1px dashed var(--gold);
  pointer-events: none;
}

.gift-restaurant {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: clamp(28px, 6vw, 38px);
  color: var(--terracotta-deep);
  margin: 8px 0 4px;
  position: relative;
  z-index: 1;
}
.gift-where {
  font-family: 'Spectral', serif;
  font-style: italic;
  color: var(--ink-soft);
  margin-bottom: 20px;
  font-size: 15px;
  position: relative;
  z-index: 1;
}
.gift-description {
  font-size: 16px;
  color: var(--ink);
  line-height: 1.7;
  margin-bottom: 18px;
  position: relative;
  z-index: 1;
}
.gift-choice {
  font-family: 'Spectral', serif;
  font-size: 15px;
  color: var(--ink-soft);
  margin-bottom: 10px;
  line-height: 1.6;
  position: relative;
  z-index: 1;
}
.gift-tip {
  font-family: 'Spectral', serif;
  font-size: 14px;
  color: var(--ink);
  margin-bottom: 24px;
  line-height: 1.6;
  position: relative;
  z-index: 1;
}
.gift-tip-label {
  font-family: 'Caveat', cursive;
  color: var(--terracotta);
  font-size: 18px;
  margin-right: 6px;
}
.gift-tip em {
  font-style: italic;
  color: var(--terracotta-deep);
}
.gift-envelope a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dashed var(--gold);
  transition: color 0.3s ease, border-bottom-color 0.3s ease;
  padding-bottom: 1px;
}
.gift-envelope a:hover,
.gift-envelope a:focus-visible {
  color: var(--terracotta);
  border-bottom-color: var(--terracotta);
  outline: none;
}
.gift-restaurant a {
  border-bottom-style: dotted;
  border-bottom-color: var(--gold-soft);
}
.gift-details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
  padding-top: 24px;
  border-top: 1px solid var(--gold-soft);
  position: relative;
  z-index: 1;
}
.gift-detail-label {
  font-family: 'Caveat', cursive;
  color: var(--terracotta);
  font-size: 18px;
  display: block;
  margin-bottom: 2px;
}
.gift-detail-value {
  font-family: 'Cormorant Garamond', serif;
  color: var(--ink);
  font-size: 16px;
  font-style: italic;
}

.gift-cta {
  display: inline-block;
  margin-top: 30px;
  padding: 14px 40px;
  background: var(--ink);
  color: var(--paper);
  font-family: 'Cormorant Garamond', serif;
  font-size: 14px;
  letter-spacing: 4px;
  text-transform: uppercase;
  text-decoration: none;
  transition: background 0.3s, transform 0.2s;
  border: none;
  cursor: pointer;
}
.gift-cta:hover { background: var(--terracotta); transform: translateY(-2px); }

/* FOOTER */
footer {
  padding: 60px 24px 40px;
  text-align: center;
  color: var(--ink-soft);
}
.footer-quote {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 22px;
  max-width: 540px;
  margin: 0 auto 16px;
  line-height: 1.4;
}
.footer-sig {
  font-family: 'Caveat', cursive;
  font-size: 24px;
  color: var(--terracotta);
  margin-top: 24px;
}

/* Mobile tweaks */
@media (max-width: 640px) {
  .chapter { padding: 40px 20px 50px; }
  .cards-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .gift-envelope { padding: 36px 20px; }
  section { padding: 60px 20px; }
  .journey-map { padding: 40px 16px; }
  .gate-card { padding: 50px 28px 40px; }
  .gate-card h1 { font-size: 30px; }
  .flip-front-symbol { font-size: 38px; }
  .flip-front-label { font-size: 16px; }
}

@media (max-width: 380px) {
  .cards-grid { gap: 10px; }
  .flip-face { padding: 10px; }
  .flip-back { padding: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
