:root {
  --bg: linear-gradient(135deg, #ffd6e8, #ffe5f1, #ffe8f6);
  --pink: #ff6fa9;
  --pink-dark: #e0538c;
  --paper: #fffaf5;
  --text: #402b3a;
  --shadow: 0 15px 40px rgba(0,0,0,0.12);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Poppins", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
  font-size: clamp(16px, 3.6vw, 18px);
  padding: 12px;
}

.scene {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 12px;
  gap: 12px;
}

.envelope {
  position: relative;
  width: 320px;
  height: 200px;
  cursor: pointer;
  transition: transform 0.45s ease, filter 0.3s ease;
  filter: drop-shadow(0 16px 30px rgba(0,0,0,0.12));
  perspective: 900px;
  overflow: hidden;
  border-radius: 14px;
}
.envelope:hover { transform: translateY(-4px) scale(1.02); }
.envelope-bottom, .envelope-top, .envelope-letter {
  position: absolute; inset: 0;
  border-radius: 14px;
}
.envelope {
  background:
    linear-gradient(145deg, rgba(255,255,255,0.68), rgba(255,255,255,0.22)),
    repeating-linear-gradient(45deg, rgba(0,0,0,0.025) 0 1px, rgba(255,255,255,0.02) 1px 2px),
    #f6eadd;
  box-shadow:
    inset 0 9px 12px rgba(255,255,255,0.42),
    inset 0 -10px 16px rgba(0,0,0,0.045),
    0 16px 30px rgba(0,0,0,0.12);
}
.envelope-bottom {
  background:
    linear-gradient(180deg, rgba(0,0,0,0.065), transparent 40%),
    linear-gradient(145deg, #f4e4d5 0%, #edd8c8 40%, #e7cdbd 100%);
  box-shadow:
    inset 0 10px 14px rgba(255,255,255,0.45),
    inset 0 -12px 18px rgba(0,0,0,0.05);
  overflow: hidden;
}
.envelope-bottom::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(0,0,0,0.04) 49.5%, rgba(0,0,0,0.0) 50.5%),
    radial-gradient(circle at 30% 20%, rgba(255,255,255,0.2), transparent 38%),
    radial-gradient(circle at 80% 30%, rgba(0,0,0,0.03), transparent 45%);
  clip-path: polygon(0 0, 50% 55%, 100% 0, 100% 100%, 0 100%);
  opacity: 0.65;
  pointer-events: none;
}
.envelope-bottom::after {
  content: "";
  position: absolute;
  inset: 0;
  clip-path: polygon(10% 100%, 50% 55%, 90% 100%);
  background: linear-gradient(180deg, rgba(0,0,0,0.08), rgba(0,0,0,0.0));
  opacity: 0.55;
  pointer-events: none;
}
.envelope-top {
  height: 58%;
  top: 0;
  background: linear-gradient(140deg, #f6e7d7 0%, #eed9c6 55%, #e8cebc 100%);
  box-shadow:
    inset 0 10px 15px rgba(255,255,255,0.65),
    inset 0 -8px 12px rgba(0,0,0,0.06),
    0 8px 18px rgba(0,0,0,0.08);
  clip-path: polygon(0 0, 50% 62%, 100% 0, 100% 100%, 0 100%);
  transform-origin: top;
  transition: transform 0.6s ease;
}
.envelope-letter {
  inset: 12px;
  background: #fdf2e5;
  border-radius: 12px;
  box-shadow:
    0 12px 24px rgba(0,0,0,0.12),
    inset 0 1px 0 rgba(255,255,255,0.85);
  transform: translateY(12%);
  opacity: 0;
  transition: transform 0.6s ease, opacity 0.6s ease;
}
.envelope.opened .envelope-top { transform: rotateX(180deg); }
.envelope.opened .envelope-letter {
  transform: translateY(-140%);
  opacity: 1;
}

.envelope-hint {
  margin: 0;
  font-weight: 700;
  color: var(--pink-dark);
  text-align: center;
  font-size: 1.4rem;
  text-shadow: 0 2px 8px rgba(255,111,169,0.25);
}

.letter-container {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 12px;
  background: rgba(255, 231, 242, 0.6);
  backdrop-filter: blur(6px);
  transition: opacity 0.5s ease, visibility 0.5s ease;
}
.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.show { opacity: 1; visibility: visible; pointer-events: auto; }

.paper {
  width: 100%;
  max-width: 520px;
  background: 
    repeating-linear-gradient(0deg, rgba(0,0,0,0.01) 0px, transparent 1px, transparent 2px),
    repeating-linear-gradient(90deg, rgba(0,0,0,0.008) 0px, transparent 1px, transparent 2px),
    linear-gradient(135deg, #fffbf5 0%, #fff8f0 40%, #fffaf3 100%);
  border-radius: 16px;
  box-shadow: 
    0 20px 45px rgba(0,0,0,0.15),
    0 8px 16px rgba(0,0,0,0.08),
    inset 0 1px 0 rgba(255,255,255,0.9),
    inset 0 -1px 0 rgba(0,0,0,0.03);
  padding: 20px 18px 22px;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(139,69,19,0.08);
}
.paper::before {
  content: "";
  position: absolute;
  inset: 0;
  background: 
    radial-gradient(circle at 20% 20%, rgba(255, 111, 169, 0.06), transparent 45%),
    radial-gradient(circle at 80% 10%, rgba(255, 175, 203, 0.06), transparent 45%),
    radial-gradient(ellipse at 15% 80%, rgba(139,69,19,0.03), transparent 40%),
    radial-gradient(ellipse at 85% 75%, rgba(139,69,19,0.02), transparent 35%),
    repeating-linear-gradient(45deg, transparent 0, transparent 2px, rgba(0,0,0,0.01) 2px, rgba(0,0,0,0.01) 3px);
  pointer-events: none;
  opacity: 0.7;
}
.paper::after {
  content: "";
  position: absolute;
  inset: 0;
  background: 
    linear-gradient(165deg, transparent 48%, rgba(0,0,0,0.015) 49%, rgba(0,0,0,0.015) 51%, transparent 52%),
    linear-gradient(15deg, transparent 48%, rgba(0,0,0,0.012) 49%, rgba(0,0,0,0.012) 51%, transparent 52%);
  pointer-events: none;
  mix-blend-mode: multiply;
  opacity: 0.4;
}
.paper h1 { 
  margin: 0 0 12px; 
  letter-spacing: 0.5px; 
  position: relative;
  z-index: 1;
  text-shadow: 0 1px 2px rgba(255,255,255,0.8);
}
.paper p { 
  margin: 10px 0; 
  line-height: 1.6; 
  position: relative;
  z-index: 1;
  text-shadow: 0 0.5px 1px rgba(255,255,255,0.5);
}
.final-question { font-size: 1.2rem; font-weight: 700; color: var(--pink-dark); }

.btn-row {
  display: flex;
  flex-direction: column;
  width: 100%;
  gap: 10px;
  margin: 18px 0 8px;
}
.btn {
  border: none;
  border-radius: 999px;
  padding: 16px 18px;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}
.btn.yes { background: var(--pink); color: white; box-shadow: 0 8px 16px rgba(255, 111, 169, 0.35); }
.btn.no { background: #ffd1e4; color: #c73877; box-shadow: 0 8px 16px rgba(0,0,0,0.12); }
.btn:hover { transform: translateY(-3px) scale(1.02); }
.btn:active { transform: translateY(0) scale(0.98); }

.pulse { animation: pulse 0.8s ease infinite; }
.shake { animation: shake 0.4s ease; }

.tiny { font-size: 0.9rem; color: #955; min-height: 22px; }
.final-msg { font-size: 1.4rem; font-weight: 800; color: var(--pink-dark); margin-top: 14px; }

.confetti-layer, .hearts-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
}
.confetti-layer { z-index: 5; }
.hearts-layer { z-index: 4; overflow: hidden; }

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}
@keyframes heartFall {
  0% { transform: translateY(-10%) scale(0.8) rotate(0deg); opacity: 0; }
  10% { opacity: 1; }
  100% { transform: translateY(110vh) scale(1.1) rotate(360deg); opacity: 0; }
}

/* Responsive */
@media (max-width: 600px) {
  .paper { padding: 24px 18px; }
  .btn-row { width: 100%; }
  .btn { width: 100%; font-size: 1.05rem; }
  .envelope { width: 260px; height: 165px; }
  .envelope::after {
    content: "C";
    position: absolute;
    left: 50%;
    top: 48%;
    width: 42px;
    height: 42px;
    transform: translate(-50%, -50%);
    background:
      radial-gradient(circle at 30% 28%, rgba(255,255,255,0.5), transparent 50%),
      radial-gradient(circle at 70% 65%, rgba(180,40,40,0.6), transparent 52%),
      radial-gradient(circle at 50% 50%, #d32f2f 0%, #b71c1c 45%, #8b0000 100%);
    border-radius: 58% 72% 60% 70%;
    box-shadow:
      inset 0 3px 5px rgba(255,255,255,0.5),
      inset 0 -4px 7px rgba(0,0,0,0.25),
      0 6px 12px rgba(0,0,0,0.18);
    filter: drop-shadow(0 5px 8px rgba(0,0,0,0.14));
    display: grid;
    place-items: center;
    font-family: "Georgia", "Times New Roman", serif;
    font-size: 1.3rem;
    font-weight: 700;
    color: rgba(139,0,0,0.75);
    text-shadow: 0 1px 2px rgba(0,0,0,0.3),
    inset 0 -1px 1px rgba(255,255,255,0.2);
    pointer-events: none;
    z-index: 3;
    transition: transform 2s cubic-bezier(0.5, 0.1, 0.3, 1.2), opacity 2s ease;
  }
  .envelope.opened::after {
    transform: translate(-50%, 150vh) rotate(180deg);
    opacity: 0;
  }
  .envelope-hint { font-size: 1.25rem; }
}

.popup {
  position: fixed;
  top: 4vh;
  left: 50%;
  transform: translateX(-50%) translateY(-12px);
  background: white;
  color: var(--pink-dark);
  padding: 16px 20px;
  border-radius: 16px;
  box-shadow: var(--shadow);
  font-weight: 800;
  font-size: clamp(1.1rem, 4.4vw, 1.35rem);
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 7;
  min-width: min(90vw, 520px);
  text-align: center;
}
.popup.show-popup {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.disclaimer-popup {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  padding: 20px;
}
.disclaimer-popup.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.disclaimer-content {
  background: white;
  padding: 30px 24px;
  border-radius: 20px;
  box-shadow: var(--shadow);
  max-width: 450px;
  text-align: center;
}
.disclaimer-content p {
  margin: 0 0 20px;
  font-size: 1.1rem;
  line-height: 1.6;
  color: var(--text);
}
.disclaimer-btn {
  background: var(--pink);
  color: white;
  border: none;
  border-radius: 999px;
  padding: 14px 32px;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 16px rgba(255, 111, 169, 0.35);
  transition: transform 0.25s ease;
}
.disclaimer-btn:hover {
  transform: translateY(-2px) scale(1.02);
}
.disclaimer-btn:active {
  transform: translateY(0) scale(0.98);
}

.footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 12px 20px;
  text-align: center;
  background: linear-gradient(to top, rgba(255, 214, 232, 0.8), transparent);
  backdrop-filter: blur(4px);
  z-index: 1;
}
.footer p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--pink-dark);
  font-style: italic;
  opacity: 0.8;
}

@media (min-width: 700px) {
  .scene { padding: 20px; }
  .paper { padding: 28px 24px; }
  .btn-row {
    flex-direction: row;
    width: auto;
    gap: 12px;
  }
  .btn { width: auto; padding: 12px 22px; font-size: 1rem; }
  .envelope { width: 340px; height: 215px; }
}
