:root {
  --bg-1: #fff1f5;
  --bg-2: #fde2e9;
  --card: #ffffff;
  --ink: #2f2431;
  --muted: #6e5665;
  --accent: #ff4d6d;
  --accent-dark: #d62b55;
  --accent-soft: #ffe1e9;
  --shadow: 0 20px 60px rgba(255, 77, 109, 0.18);
  --radius: 28px;
  --font-head: "Playfair Display", "Times New Roman", serif;
  --font-body: "Space Grotesk", "Helvetica Neue", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--ink);
  background: #120f14;
  display: grid;
  place-items: center;
  padding: 24px 24px 40px;
  overflow: hidden;
}

.collage-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  grid-auto-rows: 120px;
  grid-auto-flow: dense;
  gap: 8px;
  padding: 10px;
  filter: blur(10px) saturate(0.95);
  transform: scale(1.04);
  transition: filter 0.7s ease, transform 0.7s ease;
}

body.proposal-open .collage-bg {
  filter: blur(0);
  transform: scale(1);
}

.collage-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(20, 15, 22, 0.5), rgba(20, 15, 22, 0.68));
  pointer-events: none;
}

.collage-tile {
  border-radius: 14px;
  background: rgba(13, 11, 16, 0.88);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
  transform: rotate(var(--r, 0deg)) scale(var(--s, 1));
  opacity: 0;
  animation: tileIn 0.55s ease forwards;
}

.collage-tile img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
}

@keyframes tileIn {
  from {
    opacity: 0;
    transform: rotate(var(--r, 0deg)) scale(1.08);
  }
  to {
    opacity: 1;
    transform: rotate(var(--r, 0deg)) scale(var(--s, 1));
  }
}

.bg-glow {
  position: fixed;
  inset: -20% 0 0;
  background: radial-gradient(circle at 30% 10%, rgba(255, 77, 109, 0.2), transparent 50%),
    radial-gradient(circle at 70% 0%, rgba(255, 196, 206, 0.5), transparent 55%);
  filter: blur(6px);
  z-index: 1;
}

.app {
  position: relative;
  z-index: 2;
  width: min(520px, 92vw);
  transform: translateY(-36px);
}

.card {
  position: relative;
  background: var(--card);
  padding: 42px 36px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 77, 109, 0.12);
  overflow: hidden;
  text-align: center;
  backdrop-filter: blur(4px);
}

.card.final-state {
  padding-top: 24px;
}

.card.final-state h1 {
  margin-bottom: 6px;
}

.card.final-state #subtitle {
  margin-top: 0;
}

.envelope {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  text-align: center;
  padding: 24px 18px 18px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(255, 77, 109, 0.2);
  border-radius: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(4px);
}

.envelope-text {
  margin: 0;
  font-weight: 500;
  color: var(--muted);
}

.envelope-art {
  position: relative;
  width: 240px;
  height: 160px;
  perspective: 800px;
}

.env-back {
  position: absolute;
  inset: 0;
  border-radius: 18px;
  background:
    linear-gradient(135deg, transparent 47%, rgba(255, 143, 163, 0.4) 48%, rgba(255, 143, 163, 0.4) 52%, transparent 53%),
    linear-gradient(45deg, transparent 47%, rgba(255, 143, 163, 0.4) 48%, rgba(255, 143, 163, 0.4) 52%, transparent 53%),
    #fff7f9;
  border: 2px solid rgba(255, 77, 109, 0.2);
  box-shadow: 0 14px 30px rgba(255, 77, 109, 0.16);
}

.env-letter {
  position: absolute;
  left: 18px;
  right: 18px;
  top: 22px;
  height: 92px;
  background: white;
  border-radius: 12px;
  border: 1px solid rgba(255, 77, 109, 0.2);
  transform: translateY(12px);
  opacity: 0;
  transition: transform 0.6s ease, opacity 0.4s ease;
  z-index: 1;
}

.env-front {
  display: none;
}

.env-flap {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  width: 0;
  height: 0;
  margin: 0 auto;
  border-left: 120px solid transparent;
  border-right: 120px solid transparent;
  border-bottom: 90px solid #ff9bb0;
  transform-origin: top center;
  transform: rotateX(0deg);
  transition: transform 0.6s ease;
  z-index: 3;
}

.seal-btn {
  position: absolute;
  left: 50%;
  top: 58%;
  transform: translate(-50%, -50%) rotate(-45deg);
  width: 36px;
  height: 36px;
  background: #d7263d;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  box-shadow: 0 10px 18px rgba(215, 38, 61, 0.35);
  z-index: 4;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.seal-btn::before,
.seal-btn::after {
  content: "";
  position: absolute;
  width: 36px;
  height: 36px;
  background: #d7263d;
  border-radius: 50%;
}

.seal-btn::before {
  top: -18px;
  left: 0;
}

.seal-btn::after {
  left: 18px;
  top: 0;
}

.seal-btn:focus-visible {
  outline: 3px solid rgba(255, 77, 109, 0.35);
  outline-offset: 6px;
}

.seal-btn:hover {
  transform: translate(-50%, -50%) rotate(-45deg) scale(1.05);
  box-shadow: 0 14px 24px rgba(215, 38, 61, 0.4);
}

.envelope.opening .env-flap {
  transform: rotateX(180deg);
}

.envelope.opening .env-letter {
  transform: translateY(-8px);
  opacity: 1;
}

.envelope.opening {
  animation: envelopeFade 0.6s ease forwards;
}

@keyframes envelopeFade {
  0% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateY(-8px);
  }
}

.card::after {
  content: "";
  position: absolute;
  inset: 16px;
  border-radius: 22px;
  border: 1px dashed rgba(255, 77, 109, 0.2);
  pointer-events: none;
}

.stamp {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: 0.03em;
  margin-bottom: 18px;
  justify-content: center;
}

h1 {
  margin: 0 0 12px;
  font-family: var(--font-head);
  font-size: clamp(2rem, 3.2vw, 2.6rem);
}

p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
  font-size: 1.05rem;
}

.actions {
  position: relative;
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: center;
  margin-top: 28px;
  min-height: 72px;
}

.btn {
  border: none;
  padding: 12px 28px;
  border-radius: 999px;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn:focus-visible {
  outline: 3px solid rgba(255, 77, 109, 0.35);
  outline-offset: 3px;
}

.btn-yes {
  background: var(--accent);
  color: white;
  box-shadow: 0 12px 28px rgba(255, 77, 109, 0.3);
}

.btn-yes:hover {
  transform: translateY(-2px) scale(1.02);
}

.btn-no {
  background: #f3f3f6;
  color: var(--ink);
}

.btn-secondary {
  background: #fff0f4;
  color: var(--accent-dark);
}

.result {
  margin-top: 20px;
  padding: 18px 20px;
  border-radius: 18px;
  background: #fff7f9;
  border: 1px solid rgba(255, 77, 109, 0.16);
  text-align: center;
}

.final-gif {
  width: min(100%, 300px);
  max-height: 220px;
  object-fit: contain;
  border-radius: 14px;
  margin: 14px auto 0;
  display: block;
}

.result h2 {
  font-family: var(--font-head);
  margin: 0 0 8px;
}

.hearts {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.heart {
  position: absolute;
  width: 18px;
  height: 18px;
  background: var(--accent);
  transform: rotate(45deg);
  animation: float 2.6s ease-out forwards;
}

.heart::before,
.heart::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
}

.heart::before {
  left: -9px;
}

.heart::after {
  top: -9px;
}

@keyframes float {
  0% {
    transform: translate(0, 0) rotate(45deg) scale(0.9);
    opacity: 0;
  }
  20% {
    opacity: 1;
  }
  100% {
    transform: translate(var(--x, 0px), var(--y, -140px)) rotate(45deg) scale(1.2);
    opacity: 0;
  }
}

@media (max-width: 520px) {
  .collage-bg {
    grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
    grid-auto-rows: 92px;
    gap: 6px;
    padding: 8px;
  }

  .envelope-art {
    width: 200px;
    height: 140px;
  }

  .env-front {
    border-left-width: 100px;
    border-right-width: 100px;
    border-top-width: 70px;
  }

  .env-flap {
    border-left-width: 100px;
    border-right-width: 100px;
    border-bottom-width: 80px;
  }

  .seal-btn {
    width: 30px;
    height: 30px;
  }

  .seal-btn::before,
  .seal-btn::after {
    width: 30px;
    height: 30px;
  }

  .seal-btn::before {
    top: -15px;
    left: 0;
  }

  .seal-btn::after {
    left: 15px;
    top: 0;
  }

  .app {
    transform: translateY(-20px);
  }

  .card {
    padding: 34px 24px;
  }

  .actions {
    flex-direction: column;
  }

  .btn {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .btn,
  .heart {
    transition: none;
    animation: none;
  }
}
