:root {
  --paper: #f7f0ff;
  --ink: #2a1933;
  --accent: #b46be3;
  --accent-dark: #8d4cc8;
  --teal: #6a3c9b;
  --shadow: rgba(52, 25, 84, 0.18);
  --bg-1: #d9c2f1;
  --bg-2: #e7d7f8;
  --bg-3: #f7f0ff;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "IBM Plex Mono", monospace;
  color: var(--ink);
  min-height: 100svh;
  background: radial-gradient(circle at top, var(--bg-3), var(--bg-2) 55%, var(--bg-1));
  display: grid;
  place-items: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
    env(safe-area-inset-bottom) env(safe-area-inset-left);
  overflow-x: hidden;
  overflow-y: auto;
}

.page {
  width: min(900px, 100%);
  height: auto;
  display: grid;
  place-items: center;
  gap: 24px;
  min-height: 100svh;
  align-content: center;
  padding: clamp(16px, 4vw, 32px) 16px calc(24px + env(safe-area-inset-bottom));
}

@supports (height: 100dvh) {
  body,
  .page {
    min-height: 100dvh;
  }
}

.hero {
  width: 100%;
  height: auto;
  display: grid;
  place-items: center;
  gap: 32px;
  min-height: auto;
  align-content: center;
  transform: translateY(0);
  margin-top: 0;
}

.envelope {
  position: relative;
  width: min(360px, 80vw);
  height: min(240px, 54vw);
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform 0.6s ease;
}

.envelope:focus-visible {
  outline: 3px dashed var(--accent);
  outline-offset: 6px;
}

.envelope-back,
.envelope-front {
  position: absolute;
  inset: 0;
  border-radius: 16px;
}

.envelope-back {
  background: #d9c2f1;
  box-shadow: 0 20px 40px var(--shadow);
}

.envelope-front {
  background: #ede3fb;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
}

.envelope-flap {
  position: absolute;
  inset: 0;
  background: #c9a8ee;
  clip-path: polygon(0 0, 100% 0, 50% 60%);
  transform-origin: top center;
  transition: transform 0.8s ease;
  border-radius: 16px 16px 8px 8px;
}

.envelope-message {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 24px;
  font-family: "Playfair Display", serif;
  color: var(--ink);
  z-index: 2;
}

.envelope-message p {
  font-size: clamp(1.2rem, 2.8vw, 1.8rem);
}

.envelope-message span {
  margin-top: 8px;
  font-size: 0.9rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-dark);
}

.envelope.open {
  transform: translateY(-8px);
}

.envelope.hide {
  opacity: 0;
  transform: translateY(-20px) scale(0.9);
  pointer-events: none;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.envelope.gone {
  position: absolute;
  width: 0;
  height: 0;
  margin: 0;
  padding: 0;
  opacity: 0;
  overflow: hidden;
}

.envelope.open .envelope-flap {
  transform: rotateX(160deg);
}

.note {
  width: min(520px, 92vw);
  background: repeating-linear-gradient(
    to bottom,
    var(--paper) 0,
    var(--paper) 24px,
    #e7d7f8 25px
  );
  border-radius: 18px;
  padding: 28px 24px 32px;
  box-shadow: 0 24px 40px var(--shadow);
  text-align: center;
  opacity: 0;
  transform: translateY(30px) scale(0.98);
  transition: opacity 0.6s ease, transform 0.6s ease;
  display: grid;
  gap: 20px;
}

.note.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.note h1 {
  font-family: "Playfair Display", serif;
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  color: var(--teal);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.note h1.fade {
  opacity: 0;
  transform: translateY(6px);
}

.note-body img {
  width: min(240px, 64vw);
  height: auto;
  border-radius: 16px;
  border: 3px solid #dcc3f3;
  box-shadow: 0 16px 24px var(--shadow);
}

.note-actions {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 12px 28px;
  font-size: 1rem;
  font-weight: 600;
  font-family: "IBM Plex Mono", monospace;
  cursor: pointer;
  transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}

.btn.yes {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 12px 20px rgba(180, 107, 227, 0.35);
}

.btn.no {
  background: #f4eefb;
  color: var(--ink);
  border: 2px solid #d4bff0;
}

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

.btn:active {
  transform: translateY(1px) scale(0.98);
}

.btn.large {
  transform: scale(1.12);
}

.btn.small {
  transform: scale(0.85);
}

.celebration {
  position: fixed;
  inset: 0;
  background: rgba(226, 208, 248, 0.75);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
  padding: 24px;
}

.celebration.show {
  opacity: 1;
  pointer-events: auto;
}

.celebration-card {
  background: #fff;
  border-radius: 24px;
  padding: 32px 26px;
  display: grid;
  gap: 20px;
  text-align: center;
  box-shadow: 0 24px 40px var(--shadow);
  width: min(520px, 92vw);
  transform: translateY(0);
}

.celebration-card h2 {
  font-family: "Playfair Display", serif;
  font-size: clamp(1.6rem, 4vw, 2.3rem);
  color: var(--accent-dark);
}

.celebration-card img {
  width: min(280px, 70vw);
  height: auto;
  margin: 0 auto;
}

.love-text {
  font-family: "Playfair Display", serif;
  font-size: clamp(1.6rem, 4vw, 2.3rem);
  color: var(--accent-dark);
}

@media (max-width: 600px) {
  .page {
    padding: 28px 12px 24px;
  }

  .hero {
    margin-top: 0;
  }

  .hero {
    transform: translateY(0);
    margin-top: 0;
  }

  .celebration-card {
    transform: translateY(0);
  }

  .note {
    padding: 22px 18px 28px;
  }

  .btn {
    width: 100%;
  }
}

@media (max-height: 760px) {
  .hero {
    gap: 16px;
    margin-top: 0;
  }

  .note {
    padding: 20px 18px 24px;
    gap: 16px;
  }

  .note-body img {
    width: min(210px, 58vw);
  }

  .note-actions {
    gap: 10px;
  }

  .btn {
    padding: 10px 24px;
  }
}
