:root {
  --bg: #160d2b;
  --bg-2: #2b1446;
  --ink: #fbeff4;
  --ink-soft: #d4c0d6;
  --muted: #a28eac;
  --rose: #ff6f91;
  --rose-deep: #e0466e;
  --peach: #ff9a7a;
  --gold: #ffcb6b;
  --card: rgba(255, 255, 255, .06);
  --card-line: rgba(255, 255, 255, .13);
  --paper: #fff8ee;
  --paper-ink: #3b2431;
  --paper-line: #f0dccb;
  --font-head: "Playfair Display", Georgia, serif;
  --font-body: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-hand: "Caveat", "Segoe Print", cursive;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.6 var(--font-body);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
body.locked { overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- небо ---------- */
.sky {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background:
    radial-gradient(900px 600px at 50% -10%, #4a1f6b 0%, transparent 65%),
    radial-gradient(700px 500px at 100% 100%, rgba(224, 70, 110, .18) 0%, transparent 70%),
    linear-gradient(180deg, var(--bg-2) 0%, var(--bg) 45%, #0e0720 100%);
}
.sky i {
  position: absolute;
  width: var(--s, 2px);
  height: var(--s, 2px);
  border-radius: 50%;
  background: #fff;
  opacity: .25;
  animation: twinkle var(--d, 4s) ease-in-out infinite;
  animation-delay: var(--delay, 0s);
}
@keyframes twinkle { 50% { opacity: .95; } }

.shooting {
  position: absolute;
  width: 140px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, rgba(255, 255, 255, .95), transparent);
  transform: rotate(-28deg);
  animation: shoot 1.3s ease-out forwards;
  pointer-events: none;
}
.shooting.big {
  position: fixed;
  z-index: 90;
  width: 260px;
  height: 3px;
  background: linear-gradient(90deg, #fff, var(--gold) 30%, transparent);
  filter: drop-shadow(0 0 8px var(--gold));
}
@keyframes shoot {
  from { opacity: 0; translate: 0 0; }
  15% { opacity: 1; }
  to { opacity: 0; translate: -420px 220px; }
}

/* ---------- заставка и вход ---------- */
.splash {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: var(--bg);
  transition: opacity .6s ease, visibility .6s;
}
.splash.hide { opacity: 0; visibility: hidden; }
.splash-heart { font-size: 56px; animation: beat 1s ease-in-out infinite; }
@keyframes beat { 0%, 100% { transform: scale(1); } 30% { transform: scale(1.18); } 50% { transform: scale(.96); } }

.gate {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(14, 7, 32, .82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.gate-card {
  width: 100%;
  max-width: 420px;
  padding: 32px 24px;
  border: 1px solid var(--card-line);
  border-radius: 24px;
  background: rgba(43, 20, 70, .85);
  text-align: center;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .5);
}
.gate-title { margin: 0 0 8px; font: italic 600 34px/1.2 var(--font-head); }
.gate-text { margin: 0 0 24px; color: var(--ink-soft); }
.gate-question { display: block; margin-bottom: 10px; font-weight: 800; }
.gate-error { min-height: 1.6em; margin: 10px 0 14px; color: var(--gold); font-weight: 600; }
.shake { animation: shake .45s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

/* ---------- общие ---------- */
.section {
  max-width: 760px;
  margin: 0 auto;
  padding: 80px 16px;
}
.kicker {
  margin: 0 0 6px;
  color: var(--gold);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
  text-align: center;
}
h2 {
  margin: 0 0 32px;
  font: italic 600 clamp(34px, 8vw, 48px)/1.15 var(--font-head);
  text-align: center;
}
h3 { margin: 0 0 16px; font: italic 600 26px/1.2 var(--font-head); text-align: center; }
.section-intro { margin: -12px auto 32px; max-width: 520px; color: var(--ink-soft); text-align: center; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 50px;
  padding: 12px 26px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--rose), var(--peach));
  color: #fff;
  font-weight: 800;
  font-size: 17px;
  text-decoration: none;
  box-shadow: 0 10px 30px rgba(255, 111, 145, .35);
  transition: transform .15s ease, box-shadow .2s ease, background .3s ease;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .7; cursor: default; }
.btn.ghost {
  background: transparent;
  border: 1px solid var(--card-line);
  color: var(--ink-soft);
  box-shadow: none;
}
.btn.armed {
  background: linear-gradient(135deg, var(--gold), var(--peach));
  color: var(--paper-ink);
  animation: pulse 1s ease-in-out infinite;
}
@keyframes pulse { 50% { box-shadow: 0 0 0 8px rgba(255, 203, 107, .2), 0 10px 30px rgba(255, 203, 107, .35); } }

.input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--card-line);
  border-radius: 14px;
  background: rgba(0, 0, 0, .28);
  color: var(--ink);
  font: inherit;
  font-size: 17px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.input::placeholder { color: var(--muted); }
.input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(255, 203, 107, .2); }
textarea.input { min-height: 104px; resize: vertical; }

.paper {
  position: relative;
  padding: 36px 24px 36px 28px;
  border-radius: 6px;
  background-color: var(--paper);
  background-image: repeating-linear-gradient(transparent 0 35px, var(--paper-line) 35px 36px);
  background-position: 0 31px;
  color: var(--paper-ink);
  font: 500 25px/36px var(--font-hand);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .45);
}
.paper p { margin: 0 0 36px; }
.paper p:last-child { margin-bottom: 0; }

.js .reveal { opacity: 0; transform: translateY(26px); transition: opacity .9s ease, transform .9s ease; }
.js .reveal.in { opacity: 1; transform: none; }

/* ---------- hero ---------- */
.hero {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 56px 16px 72px;
  text-align: center;
  position: relative;
}
.hero-title {
  margin: 4px 0 12px;
  font: italic 600 clamp(40px, 11vw, 72px)/1.08 var(--font-head);
  background: linear-gradient(90deg, #fff 0%, #ffd6e0 40%, var(--gold) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-subtitle { max-width: 420px; margin: 0 0 18px; color: var(--ink-soft); font-size: 18px; }
.hero-title, .hero-subtitle { transition: opacity .35s ease; }
.hero .swap { opacity: 0; }

.cake-btn { padding: 0; border: 0; background: none; -webkit-user-select: none; user-select: none; }
.cake { display: block; width: min(300px, 76vw); height: auto; overflow: visible; }
.cake-glow { transition: opacity 1.2s ease; animation: glow 2.4s ease-in-out infinite; }
@keyframes glow { 50% { opacity: .75; } }

.flame, .flame-body, .flame-glow { transform-box: fill-box; transform-origin: 50% 100%; }
.flame {
  transform: skewX(calc(var(--wind, 0) * -28deg)) scaleY(calc(1 - var(--wind, 0) * .35));
  transition: transform .08s linear, opacity .3s ease;
}
.flame-body { animation: flicker .14s ease-in-out infinite alternate; }
@keyframes flicker { to { transform: scale(.94, 1.06) translateX(.4px); } }
.flame-glow { transform-origin: 50% 50%; transition: opacity .4s ease; animation: glow 1.6s ease-in-out infinite; }
.smoke { opacity: 0; transform-box: fill-box; transform-origin: 50% 100%; }

.blown .flame { opacity: 0; transform: scale(0); transition: transform .25s ease-in, opacity .25s ease-in; }
.blown .flame-glow, .blown .cake-glow { opacity: 0; animation: none; }
.blown .smoke { animation: smoke 2.2s ease-out .15s forwards; }
@keyframes smoke {
  0% { opacity: 0; transform: translateY(0) scale(.7); }
  25% { opacity: .7; }
  100% { opacity: 0; transform: translateY(-28px) scale(1.2); }
}

.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-top: 22px; }
.blown .hero-actions { display: none; }
.scroll-hint {
  position: absolute;
  bottom: 22px;
  left: 50%;
  translate: -50% 0;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--card-line);
  border-radius: 50%;
  color: var(--ink);
  font-size: 20px;
  text-decoration: none;
  opacity: 0;
  pointer-events: none;
  transition: opacity .6s ease .6s;
}
.blown .scroll-hint { opacity: 1; pointer-events: auto; animation: bounce 1.8s ease-in-out 1.2s infinite; }
@keyframes bounce { 50% { transform: translateY(8px); } }

/* ---------- письмо ---------- */
.letter { rotate: -1deg; }
.letter-greeting { font-weight: 700; }
.letter-signoff { margin-top: 0; }
.letter-signature { text-align: right; font-weight: 700; font-size: 30px; }

/* ---------- фото ---------- */
.photos { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px 14px; }
.polaroid {
  margin: 0;
  padding: 8px 8px 0;
  border: 0;
  border-radius: 4px;
  background: #fff;
  color: var(--paper-ink);
  text-align: center;
  box-shadow: 0 14px 34px rgba(0, 0, 0, .4);
  rotate: var(--r, 0deg);
  transition: rotate .3s ease, scale .3s ease;
}
.polaroid:hover { rotate: 0deg; scale: 1.03; }
.js .polaroid.reveal, .js .envelope.reveal { transition: opacity .9s ease, transform .9s ease, rotate .3s ease, scale .3s ease, translate .25s ease; }
.polaroid img, .polaroid .ph {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 2px;
  background: #eee;
}
.polaroid .ph {
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #ffd6e0, #e7d4ff);
  font-size: 34px;
}
.polaroid figcaption { padding: 6px 4px 10px; font: 600 19px/1.15 var(--font-hand); }

/* ---------- причины ---------- */
.reasons { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.flip { padding: 0; border: 0; background: none; text-align: left; perspective: 900px; }
.flip-inner {
  display: grid;
  min-height: 150px;
  transform-style: preserve-3d;
  transition: transform .7s cubic-bezier(.3, 1.4, .5, 1);
}
.flip.flipped .flip-inner { transform: rotateY(180deg); }
.face {
  grid-area: 1 / 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 18px 16px;
  border-radius: 18px;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}
.face.front {
  align-items: center;
  border: 1px solid var(--card-line);
  background: var(--card);
  text-align: center;
}
.face.front b { font: italic 600 22px/1.2 var(--font-head); }
.face.front span { margin-top: 6px; font-size: 26px; }
.face.back {
  transform: rotateY(180deg);
  background: linear-gradient(145deg, var(--rose), #ff9a7a);
  color: #fff;
  font-weight: 600;
  font-size: 15.5px;
  line-height: 1.45;
}

/* ---------- сертификат ---------- */
.cert {
  position: relative;
  padding: 32px 20px 40px;
  border: 1px solid rgba(255, 203, 107, .45);
  border-radius: 26px;
  background:
    linear-gradient(160deg, rgba(255, 203, 107, .1), rgba(255, 111, 145, .08) 60%, rgba(255, 255, 255, .03)),
    rgba(30, 14, 52, .6);
  box-shadow: inset 0 0 0 6px rgba(255, 203, 107, .05), 0 30px 80px rgba(0, 0, 0, .35);
}
.cert-corner { position: absolute; color: var(--gold); font-size: 16px; opacity: .8; }
.cert-corner.tl { top: 12px; left: 16px; }
.cert-corner.tr { top: 12px; right: 16px; }
.cert-corner.bl { bottom: 12px; left: 16px; }
.cert-corner.br { bottom: 12px; right: 16px; }
.cert-intro { margin: 0 auto 20px; max-width: 520px; text-align: center; color: var(--ink-soft); }
.cert-meta {
  display: flex;
  justify-content: center;
  gap: 12px 28px;
  flex-wrap: wrap;
  margin: 0 0 24px;
  padding: 12px 0;
  border-top: 1px dashed rgba(255, 203, 107, .35);
  border-bottom: 1px dashed rgba(255, 203, 107, .35);
  text-align: center;
}
.cert-meta dt { color: var(--muted); font-size: 12px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.cert-meta dd { margin: 2px 0 0; font: italic 600 19px/1.3 var(--font-head); }

.stars { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px 6px; margin-bottom: 6px; }
.star {
  font-size: 28px;
  line-height: 1;
  color: var(--gold);
  text-shadow: 0 0 14px rgba(255, 203, 107, .8);
  transition: color .6s ease, text-shadow .6s ease, transform .6s ease;
}
.star.used { color: rgba(255, 255, 255, .16); text-shadow: none; transform: scale(.85); }
.star.pop { animation: pop .8s ease; }
@keyframes pop { 30% { transform: scale(1.6) rotate(20deg); } }
.wish-counter { margin: 0 0 20px; text-align: center; color: var(--ink-soft); font-weight: 600; }

.wish-form { display: grid; gap: 10px; }
.presets-title { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 7px 13px;
  border: 1px dashed rgba(255, 255, 255, .3);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 14px;
  transition: background .2s, border-color .2s, color .2s;
}
.chip:hover, .chip:focus-visible { border-color: var(--gold); color: var(--ink); background: rgba(255, 203, 107, .08); }
.wish-submit { justify-self: center; margin-top: 10px; min-width: 220px; }
.all-used, .wish-error { margin: 8px 0 0; text-align: center; font-weight: 700; }
.all-used { color: var(--gold); font-size: 18px; }
.wish-error { color: var(--ink-soft); font-weight: 600; }

.rules { margin-top: 22px; color: var(--muted); font-size: 14px; }
.rules summary { cursor: pointer; text-align: center; font-weight: 700; list-style: none; }
.rules summary::-webkit-details-marker { display: none; }
.rules summary::after { content: " ▾"; }
.rules[open] summary::after { content: " ▴"; }
.rules ol { margin: 12px 0 0; padding-left: 22px; }
.rules li { margin-bottom: 6px; }

.wish-list-wrap { margin-top: 40px; }
.wish-list { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.wish {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 14px;
  align-items: start;
  padding: 14px 16px;
  border: 1px solid var(--card-line);
  border-radius: 16px;
  background: var(--card);
}
.wish-n {
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 203, 107, .14);
  color: var(--gold);
  font-weight: 800;
}
.wish-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.wish-status { color: var(--muted); font-size: 14px; font-weight: 700; }
.wish.done { border-color: rgba(255, 203, 107, .4); }
.wish.done .wish-status { color: var(--gold); }
.wish.fresh { animation: fresh 1.2s ease; }
@keyframes fresh { from { background: rgba(255, 203, 107, .3); transform: scale(1.03); } }

/* ---------- «открой, когда» ---------- */
.envelopes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px 14px; }
.envelope {
  position: relative;
  aspect-ratio: 5 / 4;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(180deg, #f7e6d4, #efd5bd);
  color: #5a3a40;
  box-shadow: 0 14px 30px rgba(0, 0, 0, .35);
  overflow: hidden;
}
.envelope:hover { translate: 0 -3px; rotate: -1deg; }
.envelope::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 50%;
  background: linear-gradient(180deg, #ecd0b4, #e3c09f);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top;
  transition: transform .4s ease;
}
.envelope .seal {
  position: absolute;
  top: 36%;
  left: 50%;
  translate: -50% -50%;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ff7f9c, #c42d55);
  color: #fff;
  font-size: 16px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, .25);
}
.envelope .label {
  position: absolute;
  inset: auto 8px 10px;
  font: 700 20px/1.05 var(--font-hand);
}
.envelope.opened::before { transform: scaleY(-1); opacity: .6; }
.envelope.opened .seal { display: none; }
.envelope .read-mark {
  position: absolute;
  top: 8px;
  right: 10px;
  font-size: 12px;
  font-weight: 800;
  opacity: .55;
}

/* ---------- модалка ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(10, 5, 22, .72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  transition: opacity .3s ease, visibility .3s;
}
.modal.open { opacity: 1; visibility: visible; }
.modal-box {
  position: relative;
  width: 100%;
  max-width: 540px;
  max-height: 86vh;
  overflow: auto;
  transform: translateY(24px) scale(.97);
  transition: transform .35s ease;
}
.modal.open .modal-box { transform: none; }
.modal-close {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(59, 36, 49, .12);
  color: var(--paper-ink);
  font-size: 26px;
  line-height: 1;
}
.modal-letter h3 { margin: 0 0 18px; padding-right: 36px; font: 700 32px/1.1 var(--font-hand); text-align: left; }
.modal-photo { margin: 0; padding: 10px 10px 0; background: #fff; border-radius: 6px; color: var(--paper-ink); text-align: center; }
.modal-photo img { display: block; width: 100%; max-height: 70vh; object-fit: contain; border-radius: 3px; }
.modal-photo figcaption { padding: 8px 4px 12px; font: 600 24px/1.2 var(--font-hand); }

/* ---------- прочее ---------- */
.footer { padding: 40px 16px 120px; text-align: center; color: var(--muted); }
.footer p { margin: 0; }
.footer-signature { margin-top: 6px !important; color: var(--ink); font: 700 28px/1.2 var(--font-hand); }

.fab {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 40;
  padding: 12px 18px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--gold), var(--peach));
  color: var(--paper-ink);
  font-weight: 800;
  text-decoration: none;
  box-shadow: 0 10px 30px rgba(255, 154, 122, .4);
  transform: translateY(120px);
  transition: transform .4s ease;
}
.fab.show { transform: none; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom));
  z-index: 90;
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  border: 1px solid var(--card-line);
  border-radius: 14px;
  background: rgba(36, 18, 60, .96);
  color: var(--ink);
  font-weight: 600;
  text-align: center;
  box-shadow: 0 16px 40px rgba(0, 0, 0, .4);
  opacity: 0;
  translate: -50% 16px;
  pointer-events: none;
  transition: opacity .3s ease, translate .3s ease;
}
.toast.show { opacity: 1; translate: -50% 0; }

.confetti { position: fixed; inset: 0; z-index: 85; width: 100%; height: 100%; pointer-events: none; }

@media (min-width: 640px) {
  .section { padding: 110px 24px; }
  .photos { grid-template-columns: repeat(3, 1fr); gap: 26px 20px; }
  .reasons { grid-template-columns: repeat(3, 1fr); gap: 16px; }
  .envelopes { grid-template-columns: repeat(3, 1fr); }
  .paper { padding: 44px 48px 44px 52px; font-size: 27px; }
  .cert { padding: 44px 40px 48px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  html { scroll-behavior: auto; }
  .js .reveal { opacity: 1; transform: none; }
}
