/* Basic reset */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: radial-gradient(1200px 720px at 50% 30%, #ffe8ef 0%, #ffd3e0 45%, #f7b8cc 100%);
  color: #1f1f1f;
  overflow-x: hidden;
}

.stage {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}

/* Cursor trail layer */
.trail-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
}

.trail-emoji {
  position: absolute;
  font-size: 22px;
  transform: translate(-50%, -50%);
  will-change: transform, opacity, filter;
  animation: trailFloat 900ms ease-out forwards;
  filter: drop-shadow(0 8px 12px rgba(0,0,0,0.18));
}

@keyframes trailFloat {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.7); }
  10%  { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, calc(-50% - 46px)) scale(1.25); }
}

/* Envelope */
.envelope-wrap {
  width: min(760px, 96vw);
}

.envelope {
  all: unset;
  cursor: pointer;
  width: 100%;
  display: grid;
  gap: 14px;
  justify-items: center;
  position: relative;
  user-select: none;
  transition: transform 520ms cubic-bezier(.2,.9,.2,1);
  transform: scale(1);
}

.env-shadow {
  width: 82%;
  height: 22px;
  background: rgba(0,0,0,0.15);
  filter: blur(12px);
  border-radius: 999px;
  transform: translateY(32px);
}

.env-body {
  width: 100%;
  aspect-ratio: 16 / 9;
  position: relative;
  border-radius: 22px;
}

/* Layer ordering */
.env-back { z-index: 1; }
.env-paper { z-index: 2; }
.env-front { z-index: 4; }
.env-flap  { z-index: 5; }
.env-heart { z-index: 6; }

.env-back, .env-front, .env-flap {
  position: absolute;
  inset: 0;
  border-radius: 22px;
}

/* Paper (starts inside) */
.env-paper {
  position: absolute;
  left: 18px;
  right: 18px;
  top: 16px;
  bottom: 16px;
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff 0%, #fff7fa 100%);
  border: 1px solid rgba(0,0,0,0.10);
  box-shadow: 0 18px 30px rgba(0,0,0,0.12);
  transform: translateY(28%) scale(0.92);
  opacity: 0;
}

.env-paper-inner {
  height: 100%;
  padding: 18px;
  position: relative;
}

.env-paper-line {
  height: 10px;
  border-radius: 999px;
  background: rgba(0,0,0,0.08);
  margin-top: 14px;
  width: 78%;
}

.env-paper-line:nth-child(2) { width: 60%; }

.env-paper-stamp {
  position: absolute;
  right: 18px;
  bottom: 18px;
  width: 54px;
  height: 54px;
  border-radius: 16px;
  background: #ff4d73;
  color: white;
  display: grid;
  place-items: center;
  font-size: 26px;
  box-shadow: 0 14px 24px rgba(0,0,0,0.14);
}

.env-back {
  background: linear-gradient(180deg, #fff 0%, #ffe7ef 100%);
  border: 2px solid rgba(0,0,0,0.12);
}

.env-front {
  background:
    linear-gradient(135deg, transparent 49%, rgba(0,0,0,0.08) 50%, transparent 55%),
    linear-gradient(225deg, transparent 49%, rgba(0,0,0,0.08) 50%, transparent 55%),
    linear-gradient(180deg, #fff 0%, #ffe7ef 100%);
  clip-path: polygon(0% 0%, 100% 0%, 100% 85%, 50% 56%, 0% 85%);
  border: 2px solid rgba(0,0,0,0.12);
}

.env-flap {
  background: linear-gradient(180deg, #fff 0%, #ffdbe6 100%);
  clip-path: polygon(0% 0%, 100% 0%, 50% 58%);
  transform-origin: 50% 0%;
  transform: rotateX(0deg);
  border: 2px solid rgba(0,0,0,0.10);
  border-bottom: none;
  transition: transform 600ms cubic-bezier(.2,.9,.2,1);
}

/* Heart seal (not inset-based to avoid "everything moved") */
.env-heart {
  position: absolute;
  left: 50%;
  top: 66%;
  transform: translate(-50%, -50%);
  width: 104px;
  height: 104px;
  display: grid;
  place-items: center;
  font-size: 46px;
  background: #ff4d73;
  color: white;
  border-radius: 28px;
  box-shadow: 0 18px 30px rgba(0,0,0,0.18);
  border: 2px solid rgba(255,255,255,0.5);
  transition: transform 250ms ease, box-shadow 250ms ease;
}

.envelope:hover .env-heart {
  transform: translate(-50%, -50%) scale(1.05);
  box-shadow: 0 22px 40px rgba(0,0,0,0.22);
}

.env-labels {
  width: 100%;
  display: flex;
  justify-content: space-between;
  padding: 0 12px;
  font-weight: 800;
  letter-spacing: 0.2px;
}

.env-labels .to {
  background: rgba(255,255,255,0.58);
  padding: 10px 14px;
  border-radius: 16px;
  border: 1px solid rgba(0,0,0,0.08);
}

.env-labels .from {
  background: rgba(255,255,255,0.38);
  padding: 10px 14px;
  border-radius: 16px;
  border: 1px solid rgba(0,0,0,0.08);
}

.hint {
  opacity: 0.85;
  font-size: 14px;
}

/* Open animation */

/* Fix stacking so the paper is in front of the opened flap (but still behind the front of envelope) */
.envelope.is-open .env-flap { z-index: 2; }
.envelope.is-open .env-paper { z-index: 3; }

@keyframes paperFlyOut {
  0%   { transform: translateY(28%) scale(0.92); opacity: 0; }
  15%  { opacity: 1; }
  100% { transform: translateY(-30%) scale(1); opacity: 1; }
}

.envelope.is-open { transform: scale(0.86); }
.envelope.is-open .env-flap { transform: rotateX(170deg); }
.envelope.is-open .env-paper { animation: paperFlyOut 720ms cubic-bezier(.2,.9,.2,1) forwards; }
.envelope.is-open .env-heart { transform: translate(-50%, -62%) scale(0.92); }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 22px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
  z-index: 60;
}

.modal.is-open {
  opacity: 1;
  pointer-events: auto;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.35);
  backdrop-filter: blur(4px);
}

.card {
  position: relative;
  width: min(560px, 94vw);
  background: rgba(255,255,255,0.92);
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 22px;
  box-shadow: 0 30px 70px rgba(0,0,0,0.25);
  padding: 18px;
  z-index: 2;
  transform: translateY(8px) scale(0.98);
  transition: transform 220ms ease;
}

.modal.is-open .card {
  transform: translateY(0) scale(1);
}

.close {
  position: absolute;
  right: 10px;
  top: 10px;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,0.12);
  background: rgba(255,255,255,0.7);
  cursor: pointer;
  font-size: 16px;
}

.card-content {
  display: grid;
  gap: 14px;
  justify-items: center;
  padding: 10px 8px 6px;
}

.photo {
  width: 100%;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(0,0,0,0.12);
  background: #fff;
}

.photo img {
  display: block;
  width: 100%;
  height: 280px;
  object-fit: cover;
}

.question {
  margin: 0;
  font-size: 34px;
  letter-spacing: 0.2px;
}

.actions {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.btn {
  padding: 14px 14px;
  border-radius: 16px;
  border: 1px solid rgba(0,0,0,0.12);
  cursor: pointer;
  font-weight: 800;
  font-size: 16px;
}

.btn.yes { background: #37d67a; }
.btn.no  { background: #ffb3c2; }

.result {
  min-height: 22px;
  margin: 0;
  font-weight: 700;
  opacity: 0.9;
}

@media (max-width: 420px) {
  .question { font-size: 28px; }
  .photo img { height: 230px; }
  .env-heart { width: 92px; height: 92px; font-size: 42px; }
}


/* Full-screen emoji burst */
.burst-layer{
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 80;
  overflow: hidden;
}

.burst-emoji{
  position: absolute;
  left: var(--x);
  top: var(--y);
  font-size: var(--s, 28px);
  transform: translate(-50%, -50%) scale(0.8);
  opacity: 0;
  will-change: transform, opacity;
  animation: burstPop var(--d, 1200ms) cubic-bezier(.2,.9,.2,1) forwards;
  filter: drop-shadow(0 10px 14px rgba(0,0,0,0.18));
}

@keyframes burstPop{
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
  10%  { opacity: 1; }
  100% { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.25) rotate(var(--r, 20deg)); }
}








/* Handwritten font */
@import url('https://fonts.googleapis.com/css2?family=Dancing+Script:wght@600;700&display=swap');

/* Paper texture effect inside envelope */
.env-back{
  background:
    linear-gradient(180deg,#fff 0%,#ffe7ef 100%),
    repeating-linear-gradient(
      45deg,
      rgba(0,0,0,0.02) 0px,
      rgba(0,0,0,0.02) 2px,
      transparent 2px,
      transparent 6px
    );
  background-blend-mode: multiply;
}

/* Valentine corner text */
.env-valentine-text{
  position:absolute;
  inset:0;
  pointer-events:none;
  z-index:7;
  font-family:'Dancing Script', cursive;
  font-weight:700;
}

.val-to{
  position:absolute;
  left:28px;
  bottom:22px;
  font-size:28px;
  color:#d6336c;
  text-shadow:0 2px 6px rgba(0,0,0,0.18);
}

.val-from{
  position:absolute;
  right:28px;
  bottom:22px;
  font-size:24px;
  color:#b0255c;
  text-shadow:0 2px 6px rgba(0,0,0,0.18);
}

/* Remove any centering flex from previous versions */
.env-valentine-text{
  display:block;
}


/* Paper effect for card */
.card{
  background:
    linear-gradient(180deg,#ffffff 0%,#fff7fa 100%),
    repeating-linear-gradient(
      45deg,
      rgba(0,0,0,0.02) 0px,
      rgba(0,0,0,0.02) 2px,
      transparent 2px,
      transparent 6px
    );
  background-blend-mode:multiply;
  border:1px solid rgba(0,0,0,0.12);
}

/* Final message text style */
.final-message{
  margin-top:14px;
  font-family:'Dancing Script', cursive;
  font-size:20px;
  color:#b0255c;
  text-align:center;
  line-height:1.4;
  opacity:0.95;
}
