:root {
  --night: #0b0614;
  --night-2: #1a0b2e;
  --red: #e30613;
  --red-deep: #8f0010;
  --gold: #ffd27a;
  --pink: #ff6b9a;
  --cream: #fbf3e4;
  --ink: #2a1a12;
  --white: #ffffff;
  --muted: rgba(255, 255, 255, .65);
  --f-sans: "Montserrat", system-ui, sans-serif;
  --f-serif: "Playfair Display", Georgia, serif;
  --f-hand: "Caveat", cursive;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--night);
  color: var(--white);
  font-family: var(--f-sans);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
body.is-locked, body.is-intro { overflow: hidden; height: 100svh; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
img { display: block; max-width: 100%; }

.scene {
  position: relative;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 16px;
  overflow: hidden;
  text-align: center;
}
.kicker {
  font-size: .75rem; letter-spacing: .35em; text-transform: uppercase;
  color: var(--gold); font-weight: 600; margin-bottom: 10px;
}
.section-title {
  font-family: var(--f-serif); font-weight: 700;
  font-size: clamp(1.6rem, 6vw, 2.8rem); line-height: 1.15; max-width: 18ch;
}
.btn {
  margin-top: 28px; padding: 14px 26px; border-radius: 999px;
  background: linear-gradient(135deg, var(--red), var(--pink));
  font-weight: 800; letter-spacing: .02em; box-shadow: 0 10px 30px rgba(227, 6, 19, .45);
  transition: transform .2s;
}
.btn:active { transform: scale(.95); }
.btn.ghost { background: rgba(255,255,255,.1); box-shadow: none; border: 1px solid rgba(255,255,255,.3); }

/* ============ OVERLAYS ============ */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  display: none; align-items: center; justify-content: center; text-align: center;
  padding: 16px;
  background: radial-gradient(ellipse at 50% 40%, #2b1145 0%, var(--night) 70%);
}
body.is-locked #lock { display: flex; }
body.is-intro #intro { display: flex; }

.lock-icon { font-size: 3rem; animation: wiggle 2.4s ease-in-out infinite; }
.lock-kicker { margin-top: 14px; color: var(--gold); letter-spacing: .3em; text-transform: uppercase; font-size: .72rem; font-weight: 600; }
.lock-title { font-family: var(--f-serif); font-size: clamp(1.6rem, 7vw, 2.6rem); margin: 10px 0 26px; }
.countdown { display: flex; gap: 10px; justify-content: center; }
.countdown div {
  width: 72px; padding: 14px 0; border-radius: 16px;
  background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.14);
  backdrop-filter: blur(6px);
}
.countdown b { display: block; font-size: 1.9rem; font-weight: 900; font-variant-numeric: tabular-nums; }
.countdown span { font-size: .68rem; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }
.lock-hint { margin-top: 26px; color: var(--muted); font-size: .9rem; }

.intro-kicker { font-family: var(--f-serif); font-style: italic; font-size: clamp(1.5rem, 6vw, 2.3rem); margin-bottom: 40px; }
.intro-hint { margin-top: 40px; color: var(--muted); font-size: .85rem; letter-spacing: .05em; }
.gift { position: relative; width: 150px; height: 150px; animation: bounce 1.6s ease-in-out infinite; }
.gift-box {
  position: absolute; left: 10px; right: 10px; bottom: 0; height: 100px; border-radius: 8px;
  background: linear-gradient(135deg, var(--red), var(--red-deep));
  box-shadow: 0 20px 50px rgba(227,6,19,.5);
}
.gift-lid {
  position: absolute; left: 0; right: 0; top: 30px; height: 30px; border-radius: 6px; z-index: 2;
  background: linear-gradient(135deg, #ff3344, var(--red));
  transition: transform .5s cubic-bezier(.5,-0.5,.5,1.5);
}
.gift-lid::before, .gift-lid::after {
  content: ""; position: absolute; top: -28px; width: 36px; height: 30px;
  border: 7px solid var(--gold); border-radius: 50% 50% 0 50%;
}
.gift-lid::before { left: 38px; transform: rotate(-20deg); }
.gift-lid::after { right: 38px; transform: scaleX(-1) rotate(-20deg); }
.gift-ribbon { position: absolute; left: 50%; top: 30px; bottom: 0; width: 18px; margin-left: -9px; background: var(--gold); z-index: 3; }
.gift.open .gift-lid { transform: translateY(-60px) rotate(-25deg); }

#flash { position: fixed; inset: 0; background: #fff; opacity: 0; pointer-events: none; z-index: 60; }

.music-btn {
  position: fixed; right: 14px; bottom: calc(14px + env(safe-area-inset-bottom)); z-index: 40;
  width: 46px; height: 46px; border-radius: 50%;
  background: rgba(20,10,30,.6); border: 1px solid rgba(255,255,255,.25); backdrop-filter: blur(8px);
  font-size: 1.3rem; display: none;
}
.music-btn.on { animation: spin 4s linear infinite; }
body.is-open .music-btn { display: block; }

/* ============ 1. HERO ============ */
#hero { background: radial-gradient(ellipse at 50% 30%, #3a1257 0%, var(--night) 65%); }
.hero-bg {
  position: absolute; inset: 0; opacity: .18; background-size: cover; background-position: center;
  filter: blur(6px) saturate(1.3); transform: scale(1.1);
}
.hero-kicker {
  position: relative; font-family: var(--f-serif); font-style: italic;
  font-size: clamp(1.4rem, 6vw, 2.4rem); color: var(--gold);
}
.big18 {
  position: relative;
  font-weight: 900; line-height: .85; letter-spacing: -.04em;
  font-size: clamp(11rem, 62vw, 28rem);
  background-color: var(--red);
  background-image: linear-gradient(135deg, var(--red), var(--pink), var(--gold));
  background-size: cover; background-position: 50% 50%;
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
  filter: drop-shadow(0 10px 40px rgba(255, 60, 110, .35));
}
.hero-name {
  position: relative; font-family: var(--f-hand); font-weight: 700;
  font-size: clamp(3rem, 14vw, 6rem); line-height: 1; margin-top: -.1em;
}
.hero-sub { position: relative; margin-top: 16px; color: var(--muted); max-width: 30ch; line-height: 1.5; }
.scroll-hint {
  position: absolute; bottom: calc(24px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  font-size: .7rem; letter-spacing: .25em; text-transform: uppercase; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.scroll-hint span { width: 22px; height: 36px; border: 2px solid var(--muted); border-radius: 12px; position: relative; }
.scroll-hint span::after {
  content: ""; position: absolute; left: 50%; top: 6px; width: 4px; height: 8px; margin-left: -2px;
  border-radius: 2px; background: var(--white); animation: scrolldot 1.6s infinite;
}

/* ============ 2. ФОТОГРАФИЯ ============ */
#photo { padding: 0; justify-content: flex-start; background: linear-gradient(var(--night), #120a1c 30%, #1c1210); }
.viewfinder {
  position: relative; width: 100%; height: 100svh;
  display: flex; align-items: center; justify-content: center;
}
.vf-c { position: absolute; width: 40px; height: 40px; border: 3px solid var(--white); opacity: .85; }
.vf-c.tl { top: 24px; left: 16px; border-right: 0; border-bottom: 0; }
.vf-c.tr { top: 24px; right: 16px; border-left: 0; border-bottom: 0; }
.vf-c.bl { bottom: 24px; left: 16px; border-right: 0; border-top: 0; }
.vf-c.br { bottom: 24px; right: 16px; border-left: 0; border-top: 0; }
.vf-rec { position: absolute; top: 36px; left: 64px; font-weight: 800; font-size: .8rem; letter-spacing: .1em; display: flex; align-items: center; gap: 6px; }
.vf-rec span { width: 10px; height: 10px; border-radius: 50%; background: var(--red); animation: blink 1s infinite; }
.vf-info { position: absolute; bottom: 36px; left: 0; right: 0; font-size: .72rem; letter-spacing: .15em; color: var(--muted); font-variant-numeric: tabular-nums; }
.vf-focus {
  position: absolute; width: 90px; height: 90px; border: 2px solid var(--gold); border-radius: 4px;
  top: 50%; left: 50%; transform: translate(-50%, -50%) scale(1.6); opacity: 0;
}
.vf-text { position: relative; max-width: 22ch; }
.vf-text p { color: var(--muted); font-size: 1.05rem; margin-bottom: 8px; }
.vf-text h3 { font-family: var(--f-serif); font-size: clamp(1.7rem, 7vw, 3rem); line-height: 1.15; }

.table {
  position: relative; width: 100%; height: 125svh; max-width: 1100px;
  touch-action: pan-y;
}
.table-hint {
  position: absolute; top: 10px; left: 0; right: 0; font-family: var(--f-hand); font-size: 1.6rem; color: var(--gold);
}
.polaroid {
  position: absolute; width: min(44vw, 230px);
  background: #fdfdf8; padding: 8px 8px 0; border-radius: 3px;
  box-shadow: 0 14px 30px rgba(0,0,0,.5);
  cursor: grab; touch-action: none; will-change: transform;
}
.polaroid img { width: 100%; aspect-ratio: 1; object-fit: cover; pointer-events: none; user-select: none; -webkit-user-drag: none; }
.polaroid figcaption { font-family: var(--f-hand); color: var(--ink); font-size: 1.25rem; padding: 6px 2px 10px; text-align: center; }
.polaroid.dragging { cursor: grabbing; box-shadow: 0 30px 60px rgba(0,0,0,.6); }

.filmstrip {
  width: 100%; padding: 14px 0; margin: 20px 0 70px;
  background: #111;
  border-top: 14px dotted #eee5; border-bottom: 14px dotted #eee5;
  overflow: hidden; transform: rotate(-3deg) scale(1.08);
}
.film-track { display: flex; gap: 10px; width: max-content; animation: marquee 40s linear infinite; }
.film-track img { height: 120px; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 3px; filter: sepia(.25) saturate(1.2); }

/* ============ 3. КАРТА ============ */
#walks { padding: 0; display: block; background: linear-gradient(#1c1210, #0f1a24 20%, #0d1420); }
.walks-head { padding: 80px 16px 10px; }
.map-pin-wrap { height: 100svh; display: flex; align-items: center; justify-content: center; padding: 0 8px; }
.map-wrap { position: relative; width: 100%; max-width: 980px; }
#map { width: 100%; height: auto; overflow: hidden; }
#map .land { fill: rgba(255,255,255,.06); stroke: rgba(255,255,255,.35); stroke-width: 2; stroke-linejoin: round; }
#map .sea-label { fill: rgba(140,190,255,.35); font: italic 600 22px var(--f-serif); }
#map .route { fill: none; stroke: var(--gold); stroke-width: 4; stroke-linecap: round; stroke-dasharray: 2 12; }
#map .route-glow { fill: none; stroke: var(--pink); stroke-width: 10; stroke-linecap: round; opacity: .25; filter: blur(4px); }
#map .pin circle.dot { fill: var(--red); stroke: #fff; stroke-width: 4; }
#map .pin circle.pulse { fill: none; stroke: var(--pink); stroke-width: 3; transform-box: fill-box; transform-origin: center; animation: pulse 2s ease-out infinite; }
#map .pin text { fill: #fff; font: 700 24px var(--f-sans); paint-order: stroke; stroke: rgba(0,0,0,.6); stroke-width: 5px; }
#map .walker { font-size: 40px; }
#map .land.far { fill: rgba(140, 170, 255, .07); stroke: rgba(160, 190, 255, .35); }
#map .graticule line { stroke: rgba(255,255,255,.18); stroke-width: 1; stroke-dasharray: 2 6; }
#map .graticule { opacity: 0; }
#map .eiffel { fill: none; stroke: var(--gold); stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 0 6px rgba(255,210,122,.8)); }
#map .pin circle.dot.gold { fill: var(--gold); }

.map-cards { position: relative; height: 112px; margin-top: 14px; pointer-events: none; }
.map-card {
  position: absolute; left: 50%; top: 0; transform: translateX(-50%);
  width: min(92vw, 360px); display: flex; gap: 12px; align-items: center; text-align: left;
  background: rgba(15, 10, 25, .85); border: 1px solid rgba(255,255,255,.15); backdrop-filter: blur(10px);
  border-radius: 18px; padding: 10px; opacity: 0;
  box-shadow: 0 20px 40px rgba(0,0,0,.5);
}
.map-card img { width: 86px; height: 86px; object-fit: cover; border-radius: 12px; flex: none; }
.map-card h4 { font-size: 1rem; margin-bottom: 4px; }
.map-card p { font-size: .85rem; color: var(--muted); line-height: 1.4; }
.map-card.ring { border-color: var(--gold); box-shadow: 0 0 40px rgba(255, 210, 122, .35); }
.map-card.ring h4 { color: var(--gold); }

/* ============ 4. МЕЧТА ============ */
#dream { background: radial-gradient(ellipse at 50% 120%, #2a1650 0%, #090414 60%); min-height: 120svh; }
#sky { position: absolute; inset: 0; width: 100%; height: 100%; }
#dream::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 28%; z-index: 1;
  background: linear-gradient(transparent, var(--night)); pointer-events: none;
}
.dream-text, .dream-hint, .dream-final { z-index: 2; }
.dream-text { position: absolute; top: 12%; left: 16px; right: 16px; pointer-events: none; }
.dream-text p { font-family: var(--f-serif); font-style: italic; font-size: clamp(1.15rem, 4.6vw, 1.7rem); line-height: 1.5; opacity: 0; }
.dream-hint {
  position: absolute; bottom: 14%; left: 0; right: 0; font-family: var(--f-hand); font-size: 1.7rem; color: var(--gold);
  pointer-events: none; animation: breathe 2s ease-in-out infinite; opacity: 0;
}
.dream-final { position: absolute; bottom: 10%; left: 16px; right: 16px; pointer-events: none; opacity: 0; }
.dream-final h3 {
  font-family: var(--f-hand); font-size: clamp(2.6rem, 11vw, 4.6rem); line-height: 1.05;
  background: linear-gradient(90deg, var(--gold), #fff, var(--pink));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 20px rgba(255, 210, 122, .5));
}
.dream-date { margin-top: 10px; letter-spacing: .6em; font-weight: 800; color: var(--muted); font-size: .9rem; }

/* ============ 5. ТОРТА ============ */
#cake-scene { background: radial-gradient(ellipse at 50% 70%, #3a1640 0%, var(--night) 70%); }
.cake { position: relative; width: 280px; height: 270px; margin-top: 110px; }
.tier { position: absolute; left: 50%; transform: translateX(-50%); border-radius: 14px 14px 10px 10px; }
.tier.t1 { bottom: 120px; width: 200px; height: 80px; background: linear-gradient(#ffd1dc, #ff9fb8); }
.tier.t2 { bottom: 20px; width: 260px; height: 100px; background: linear-gradient(#fff2f5, #ffc2d1); display: flex; align-items: center; justify-content: center; }
.tier em { font-family: var(--f-hand); font-style: normal; color: var(--red); font-size: 2rem; font-weight: 700; margin-top: 16px; }
.drip {
  position: absolute; top: -2px; left: 0; right: 0; height: 26px; border-radius: 14px 14px 0 0;
  background: radial-gradient(circle at 10px 18px, var(--red) 9px, transparent 10px) 0 0 / 28px 30px repeat-x, var(--red);
  -webkit-mask: linear-gradient(#000 0 0) top / 100% 12px no-repeat, radial-gradient(circle at 14px 12px, #000 9px, transparent 10px) 0 0 / 28px 30px repeat-x;
          mask: linear-gradient(#000 0 0) top / 100% 12px no-repeat, radial-gradient(circle at 14px 12px, #000 9px, transparent 10px) 0 0 / 28px 30px repeat-x;
}
.plate { position: absolute; bottom: 4px; left: 50%; width: 300px; height: 22px; margin-left: -150px; border-radius: 50%; background: linear-gradient(#eee, #aaa); }
.candles {
  position: absolute; bottom: 196px; left: 50%; transform: translateX(-50%);
  width: 196px; display: flex; flex-wrap: wrap; justify-content: center; gap: 28px 6px;
}
.candle {
  position: relative; width: 12px; height: 34px; border-radius: 3px;
  background: repeating-linear-gradient(-45deg, #fff 0 4px, var(--red) 4px 8px);
}
.candle:nth-child(n+10) { height: 26px; }
.candle::before { content: ""; position: absolute; top: -6px; left: 5px; width: 2px; height: 7px; background: #333; }
.flame {
  position: absolute; left: 50%; top: -24px; width: 12px; height: 20px; margin-left: -6px;
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  background: radial-gradient(ellipse at 50% 70%, #fff 0 20%, #ffd54a 40%, #ff7b00 75%, transparent 76%);
  box-shadow: 0 0 18px 6px rgba(255, 170, 40, .55);
  animation: flicker .25s ease-in-out infinite alternate; transform-origin: 50% 100%;
}
.candle.out .flame { opacity: 0; transform: scale(.2); transition: all .3s; }
.smoke {
  position: absolute; left: 50%; top: -20px; width: 6px; height: 6px; margin-left: -3px; border-radius: 50%;
  background: rgba(220,220,220,.7); opacity: 0; pointer-events: none;
}
.candle.out .smoke { animation: smoke 1.6s ease-out forwards; }
.cake-hint { margin-top: 14px; color: var(--muted); font-size: .85rem; }

/* ============ 6. ПИСМО ============ */
#letter-scene { background: linear-gradient(var(--night), #24121c); }
.envelope { width: min(100%, 560px); perspective: 1200px; }
.paper {
  background:
    repeating-linear-gradient(transparent 0 35px, rgba(120, 90, 200, .18) 35px 36px),
    var(--cream);
  color: var(--ink); text-align: left; border-radius: 6px;
  padding: 36px 26px 30px; min-height: 60svh;
  box-shadow: 0 30px 60px rgba(0,0,0,.6);
  transform-origin: 50% 0;
}
.letter { font-family: var(--f-hand); font-size: 1.55rem; line-height: 36px; white-space: pre-wrap; min-height: 2em; }
.letter .caret { display: inline-block; width: 2px; height: 1.1em; background: var(--ink); vertical-align: -3px; animation: blink .8s infinite; }
.signature { font-family: var(--f-hand); font-size: 2rem; color: var(--red); text-align: right; margin-top: 18px; opacity: 0; }

/* ============ 7. ФИНАЛ ============ */
#finale { background: radial-gradient(ellipse at 50% 50%, #4a0f2a 0%, var(--night) 70%); }
#fireworks { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.heart-photos { position: relative; width: min(92vw, 520px); aspect-ratio: 1 / .92; }
.heart-photos img {
  position: absolute; width: 15%; aspect-ratio: 1; object-fit: cover; border-radius: 50%;
  border: 2px solid #fff; box-shadow: 0 6px 16px rgba(0,0,0,.5); transform: translate(-50%, -50%);
}
.finale-text { position: relative; margin-top: 10px; }
.finale-text h2 {
  font-family: var(--f-hand); font-size: clamp(3.5rem, 16vw, 7rem); line-height: 1;
  color: #fff; text-shadow: 0 0 30px rgba(255, 80, 130, .8);
}
.finale-text p { color: var(--muted); font-size: 1.05rem; margin-top: 6px; }

/* ============ АНИМАЦИИ ============ */
@keyframes bounce { 0%,100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-14px) rotate(2deg); } }
@keyframes wiggle { 0%,90%,100% { transform: rotate(0); } 93% { transform: rotate(-12deg); } 96% { transform: rotate(12deg); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes blink { 50% { opacity: 0; } }
@keyframes scrolldot { 0% { transform: translateY(0); opacity: 1; } 100% { transform: translateY(14px); opacity: 0; } }
@keyframes marquee { to { transform: translateX(-50%); } }
@keyframes pulse { 0% { transform: scale(.6); opacity: 1; } 100% { transform: scale(2.4); opacity: 0; } }
@keyframes breathe { 50% { transform: scale(1.06); } }
@keyframes flicker { from { transform: scale(1, 1) rotate(-2deg); } to { transform: scale(.92, 1.08) rotate(2deg); } }
@keyframes smoke { 0% { opacity: .8; transform: translate(0,0) scale(1); } 100% { opacity: 0; transform: translate(6px,-50px) scale(4); } }

@media (max-width: 700px) {
  #map .pin text { font-size: 40px; stroke-width: 7px; }
  #map .walker { font-size: 60px; }
  #map .route { stroke-width: 6; }
  #map .sea-label { font-size: 30px; }
}
@media (min-width: 800px) {
  .polaroid { width: 230px; }
  .film-track img { height: 160px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
