/* ---------- Reset & base ---------- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  min-height: 100%;
  overflow-x: hidden;
}

body {
  font-family: 'Quicksand', sans-serif;
  background: linear-gradient(120deg, #ffd6e8, #ffe9c7, #d9c6f5, #ffd6e8);
  background-size: 300% 300%;
  animation: gradientShift 18s ease infinite;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  color: #5a4a42;
}

@keyframes gradientShift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.sky-glow {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 15% 20%, rgba(255,255,255,0.55), transparent 40%),
    radial-gradient(circle at 85% 75%, rgba(255,255,255,0.4), transparent 45%);
  pointer-events: none;
  z-index: 0;
}

/* ---------- Floating decor ---------- */
.floaters {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 1;
}

.balloon, .heart {
  position: absolute;
  bottom: -10vh;
  font-size: 2.6rem;
  opacity: 0.85;
  animation-name: floatUp, sway;
  animation-timing-function: linear, ease-in-out;
  animation-iteration-count: infinite, infinite;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,0.08));
}

.balloon--1 { left: 6%;  font-size: 3.2rem; animation-duration: 16s, 4s; animation-delay: 0s, 0s; }
.balloon--2 { left: 22%; font-size: 2.4rem; animation-duration: 21s, 5s; animation-delay: 2s, 0.3s; }
.balloon--3 { left: 48%; font-size: 3rem;   animation-duration: 18s, 4.5s; animation-delay: 5s, 0.6s; }
.balloon--4 { left: 72%; font-size: 2.6rem; animation-duration: 23s, 6s; animation-delay: 1s, 0.2s; }
.balloon--5 { left: 88%; font-size: 3.4rem; animation-duration: 19s, 5.5s; animation-delay: 3.5s, 0.4s; }

.heart--1 { left: 12%; font-size: 1.6rem; animation-duration: 14s, 3s; animation-delay: 1s, 0s; opacity: 0.5; }
.heart--2 { left: 38%; font-size: 1.3rem; animation-duration: 17s, 3.4s; animation-delay: 4s, 0.5s; opacity: 0.45; }
.heart--3 { left: 63%; font-size: 1.8rem; animation-duration: 15s, 3.8s; animation-delay: 2.5s, 0.2s; opacity: 0.5; }
.heart--4 { left: 82%; font-size: 1.4rem; animation-duration: 20s, 3.2s; animation-delay: 6s, 0.7s; opacity: 0.4; }

@keyframes floatUp {
  0%   { bottom: -10vh; }
  100% { bottom: 110vh; }
}

@keyframes sway {
  0%, 100% { transform: translateX(0) rotate(-4deg); }
  50%      { transform: translateX(18px) rotate(4deg); }
}

/* ---------- Stage ---------- */
.stage {
  position: relative;
  z-index: 2;
  width: 100%;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

/* ---------- Envelope ---------- */
.envelope-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  animation: appear 1s ease both;
}

@keyframes appear {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

.to-label {
  font-size: 1.15rem;
  font-weight: 600;
  color: #8a4b6b;
  letter-spacing: 0.02em;
  text-align: center;
}

.envelope {
  position: relative;
  width: min(320px, 78vw);
  height: min(210px, 51vw);
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  perspective: 1200px;
  filter: drop-shadow(0 18px 30px rgba(120, 70, 90, 0.28));
  transition: transform 0.35s ease;
}

.envelope:hover {
  transform: translateY(-4px) scale(1.015);
}

.envelope:active {
  transform: translateY(0) scale(0.99);
}

.envelope__back {
  position: absolute;
  inset: 0;
  background: linear-gradient(155deg, #fff4e6, #ffe3ef);
  border-radius: 14px;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.6);
}

.envelope__back::before,
.envelope__back::after {
  content: "";
  position: absolute;
  top: 0;
  width: 0;
  height: 0;
  border-style: solid;
}

.envelope__back::before {
  left: 0;
  border-width: 0 0 100% 50%;
  border-color: transparent transparent rgba(255, 214, 232, 0.9) transparent;
}

.envelope__back::after {
  right: 0;
  border-width: 100% 50% 0 0;
  border-color: transparent transparent transparent rgba(255, 233, 199, 0.9);
}

.letter-peek {
  position: absolute;
  left: 10%;
  right: 10%;
  bottom: 8%;
  top: 20%;
  background: #fffdf8;
  border-radius: 10px 10px 4px 4px;
  box-shadow: 0 -4px 14px rgba(150, 100, 90, 0.12);
  display: flex;
  flex-direction: column;
  gap: 10%;
  align-items: center;
  padding-top: 18%;
  transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 1;
}

.letter-peek__line {
  width: 70%;
  height: 6%;
  background: linear-gradient(90deg, #ffd3e0, #ffe3c2);
  border-radius: 4px;
}

.letter-peek__line:nth-child(2) { width: 55%; }

.envelope__flap {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 58%;
  background: linear-gradient(155deg, #ffdcea, #ffd9b3);
  clip-path: polygon(0 0, 100% 0, 50% 68%);
  border-radius: 14px 14px 0 0;
  transform-origin: top center;
  transform-style: preserve-3d;
  transition: transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 3;
  box-shadow: 0 2px 6px rgba(150, 90, 90, 0.12);
}

.envelope__seal {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.9rem;
  z-index: 4;
  filter: drop-shadow(0 3px 6px rgba(150, 90, 40, 0.35));
  transition: opacity 0.3s ease, transform 0.3s ease;
  animation: pulse 2.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50%      { transform: translate(-50%, -50%) scale(1.12); }
}

.hint {
  font-size: 0.95rem;
  color: #9a6b86;
  opacity: 0.85;
  animation: pulseText 2.2s ease-in-out infinite;
}

@keyframes pulseText {
  0%, 100% { opacity: 0.55; }
  50%      { opacity: 1; }
}

/* Envelope open state */
.envelope-wrap.is-open .envelope__flap {
  transform: rotateX(180deg);
  z-index: 1;
}

.envelope-wrap.is-open .envelope__seal {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.5);
}

.envelope-wrap.is-open .letter-peek {
  transform: translateY(-92%) scale(1.04);
}

.envelope-wrap.is-open .hint {
  opacity: 0;
}

.envelope-wrap.is-hidden {
  opacity: 0;
  transform: scale(0.92);
  transition: opacity 0.5s ease, transform 0.5s ease;
  pointer-events: none;
}

/* ---------- Card overlay ---------- */
.card-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(circle at 50% 40%, rgba(255, 233, 214, 0.55), rgba(120, 80, 110, 0.35));
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease;
  backdrop-filter: blur(2px);
}

.card-overlay.is-visible {
  opacity: 1;
  visibility: visible;
}

.card {
  position: relative;
  width: min(560px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  background: #fffaf2;
  border-radius: 26px;
  padding: 42px 38px 34px;
  text-align: center;
  box-shadow:
    0 30px 60px rgba(120, 60, 90, 0.28),
    inset 0 0 0 1px rgba(255, 214, 168, 0.5);
  transform: scale(0.7) translateY(40px);
  opacity: 0;
  transition: transform 0.55s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.5s ease;
}

.card::before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1.5px dashed #f3c7d8;
  border-radius: 20px;
  pointer-events: none;
}

.card-overlay.is-visible .card {
  transform: scale(1) translateY(0);
  opacity: 1;
}

.close-btn {
  position: absolute;
  top: 16px;
  right: 18px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: #ffe3ea;
  color: #a2536f;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.25s ease, transform 0.25s ease;
  z-index: 2;
}

.close-btn:hover {
  background: #ffcdd9;
  transform: rotate(90deg);
}

.card__sparkles {
  font-size: 1.6rem;
  animation: spin 5s linear infinite;
  margin-bottom: 4px;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.card__eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  color: #c48ba0;
  font-weight: 700;
  margin-bottom: 6px;
}

.card__title {
  font-family: 'Great Vibes', cursive;
  font-size: 3rem;
  line-height: 1;
  color: #d9668c;
  margin-bottom: -6px;
}

.card__name {
  font-family: 'Great Vibes', cursive;
  font-size: 3.6rem;
  color: #c9973f;
  margin-bottom: 6px;
  text-shadow: 0 2px 10px rgba(201, 151, 63, 0.25);
}

.divider {
  font-size: 1.3rem;
  margin: 6px 0 18px;
  letter-spacing: 4px;
}

.card__body {
  text-align: left;
  font-size: 1.02rem;
  line-height: 1.65;
  color: #5a4a42;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card__body strong {
  color: #c9557e;
  font-weight: 700;
}

.card__highlight {
  text-align: center;
  font-weight: 700;
  color: #b3742f;
  font-size: 1.08rem;
  margin-top: 4px;
}

.signature {
  margin-top: 26px;
  font-size: 1rem;
  color: #8a4b6b;
  font-style: italic;
  line-height: 1.5;
}

.signature span {
  font-family: 'Great Vibes', cursive;
  font-size: 1.6rem;
  font-style: normal;
  color: #d9668c;
  display: inline-block;
  margin-top: 4px;
}

.again-btn {
  margin-top: 26px;
  border: none;
  background: linear-gradient(135deg, #ff9ec1, #ffc98b);
  color: #fff;
  font-family: 'Quicksand', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 12px 26px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(255, 130, 160, 0.4);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.again-btn:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 14px 26px rgba(255, 130, 160, 0.5);
}

/* ---------- Confetti ---------- */
.confetti {
  position: fixed;
  top: -12px;
  width: 9px;
  height: 14px;
  z-index: 20;
  pointer-events: none;
  opacity: 0.95;
  animation: confettiFall linear forwards;
}

@keyframes confettiFall {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(105vh) rotate(600deg);
    opacity: 0.9;
  }
}

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
  .card {
    padding: 34px 22px 28px;
    border-radius: 20px;
  }
  .card__title { font-size: 2.4rem; }
  .card__name { font-size: 3rem; }
  .card__body { font-size: 0.96rem; }
  .to-label { font-size: 1rem; }
}

/* ---------- Scrollbar polish ---------- */
.card::-webkit-scrollbar {
  width: 8px;
}
.card::-webkit-scrollbar-thumb {
  background: #ffd9e4;
  border-radius: 8px;
}
