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

body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f5f0e8;
  font-family: "Georgia", serif;
  overflow: hidden;
}

/* ── Background layers ── */
.bg-layer {
  position: fixed;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0;
  transition: opacity 2s ease;
  z-index: -1;
}

/* ── Shared typography ── */
h1 {
  font-size: 48px;
  font-weight: normal;
  color: #2e2018;
  line-height: 1.2;
  font-family: "Meow Script", cursive;
}

h2 {
  font-size: 36px;
  font-weight: normal;
  color: #2e2018;
  line-height: 1.2;
  font-family: "Meow Script", cursive;
}

p,
label,
span {
  font-size: 16px;
  color: #2e2018;
  line-height: 1.75;
  font-family: "Source Serif 4", serif;
}

/* ════════════════════════════
   NAME SCREEN
════════════════════════════ */
#nameScreen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
  transition:
    opacity 0.6s ease,
    transform 0.6s ease;
}
#nameScreen.hide {
  opacity: 0;
  transform: scale(0.96);
  pointer-events: none;
}

#nameBox {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  text-align: center;
  width: 100%;
  max-width: 400px;
}

#nameBox h2 {
  font-size: 18px;
  font-family: "Source Serif 4", serif;
}

#nameInput {
  width: 100%;
  padding: 14px 20px;
  font-size: 16px;
  font-family: "Source Serif 4", serif;
  border: 2px solid #a15c7a;
  border-radius: 6px;
  background: #fffdf7;
  color: #2e2018;
  outline: none;
  text-align: center;
  transition: border-color 0.2s ease;
}
#nameInput::placeholder {
  color: rgba(46, 32, 24, 0.35);
}

#nextBtn {
  padding: 13px 40px;
  font-size: 15px;
  font-family: "Source Serif 4", serif;
  background: #a15c7a;
  color: #fffdf7;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  letter-spacing: 1px;
  transition:
    background 0.2s ease,
    transform 0.1s ease;
}
#nextBtn:hover {
  background: #6e3050;
}
#nextBtn:active {
  transform: scale(0.97);
}
#nextBtn:disabled {
  background: #b08898;
  cursor: not-allowed;
}

#errorMsg {
  display: none;
  color: #c0392b;
  font-size: 14px;
  font-style: italic;
  text-align: center;
  line-height: 1.5;
}

/* ════════════════════════════
   ENVELOPE SCREEN
════════════════════════════ */
#envelopeScreen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  padding: 16px;
  transition: opacity 0.7s ease 0.3s;
}
#envelopeScreen.hidden {
  pointer-events: none;
}
#envelopeScreen.visible {
  opacity: 1;
  pointer-events: auto;
}

#scene {
  position: relative;
  width: 95vw;
  height: 180vw;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ════════════════════════════
   CARDS (shared)
════════════════════════════ */
#card,
#themeCard,
#giftsCard,
#thankYouCard,
#noCard {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 92vw;
  height: 125vw;
  background: url("images/brown.png") center/cover;
  border-radius: 4px;
  border: 1px solid rgba(180, 170, 155, 0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px 16px;
  gap: 12px;
}

/* ── Card 1: Invite ── */
#card {
  transform: translate(-50%, -50%) scale(0.2);
  z-index: 1;
  pointer-events: none;
  transition:
    transform 1s cubic-bezier(0.34, 1.15, 0.64, 1),
    opacity 0.4s ease;
}
#card.revealed {
  transform: translate(-50%, -50%) scale(1);
  z-index: 30;
  pointer-events: auto;
}

/* ── Card 2: Theme ── */
#themeCard {
  transform: translate(-50%, -200vh);
  z-index: 32;
  pointer-events: none;
  transition: transform 0.9s cubic-bezier(0.34, 1.2, 0.64, 1);
}
#themeCard.dropped {
  transform: translate(-50%, -50%);
  pointer-events: auto;
}

/* ── Card 2b: No RSVP ── */
#noCard {
  transform: translate(-50%, -200vh);
  z-index: 31;
  pointer-events: none;
  transition: transform 0.9s cubic-bezier(0.34, 1.2, 0.64, 1);
}
#noCard.dropped {
  transform: translate(-50%, -50%);
  pointer-events: auto;
}

/* ── Card 3: Gifts ── */
#giftsCard {
  transform: translate(-50%, -200vh);
  z-index: 33;
  pointer-events: none;
  transition: transform 0.9s cubic-bezier(0.34, 1.2, 0.64, 1);
}
#giftsCard.dropped {
  transform: translate(-50%, -50%);
  pointer-events: auto;
}

/* ── Card 4: Thank You ── */
#thankYouCard {
  transform: translate(-50%, -200vh);
  z-index: 36;
  pointer-events: none;
  transition: transform 0.9s cubic-bezier(0.34, 1.2, 0.64, 1);
}
#thankYouCard.dropped {
  transform: translate(-50%, -50%);
  pointer-events: auto;
}

/* ── Card decorations ── */
.card-deco {
  width: 12rem;
  height: auto;
  pointer-events: none;
}

.flowers-img {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80vw;
  height: auto;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
}

/* ════════════════════════════
   CHECKBOXES & PLEDGE
════════════════════════════ */
.rsvp-options {
  display: flex;
  justify-content: center;
  gap: 40px;
}

.rsvp-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.rsvp-label input[type="checkbox"],
.pledge-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #8a4060;
  cursor: pointer;
}

.pledge-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: 90%;
  cursor: pointer;
  user-select: none;
  margin: 0 auto;
}

#pledgeText {
  font-style: italic;
  text-align: center;
}

.card-flowers {
  display: flex;
  justify-content: center;
  gap: 80px;
  margin-top: -20px;
}
.card-flowers img {
  width: auto;
  height: 200px;
  pointer-events: none;
}

/* ════════════════════════════
   DONE BUTTON (shared)
════════════════════════════ */
.done-btn {
  padding: 10px 28px;
  font-size: 14px;
  font-family: "Georgia", serif;
  font-style: italic;
  background: #8a4060;
  color: #fffdf7;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  letter-spacing: 1px;
  transition:
    background 0.2s ease,
    transform 0.1s ease,
    opacity 0.4s ease;
}
.done-btn:hover {
  background: #6e3050;
}
.done-btn:active {
  transform: scale(0.97);
}
.done-btn:disabled {
  background: #b08898;
  cursor: not-allowed;
}

.hidden-btn {
  opacity: 0;
  pointer-events: none;
}
.hidden-btn.show {
  opacity: 1;
  pointer-events: auto;
}

/* ════════════════════════════
   ENVELOPE SVG
════════════════════════════ */
#envWrap {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  perspective: 1200px;
}
#envWrap.dropping {
  animation: envDrop 0.85s cubic-bezier(0.4, 0, 1, 1) forwards;
}
@keyframes envDrop {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
  }
  20% {
    transform: translateY(30px) rotate(-3deg);
    opacity: 1;
  }
  100% {
    transform: translateY(130vh) rotate(-8deg);
    opacity: 0;
  }
}

#flap {
  transform-origin: 50% 0%;
  transform-box: fill-box;
  transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}
#flap.open {
  transform: rotateX(180deg);
}

.paper-fill {
  fill: url(#paperPat);
}
.paper-fill-dark {
  fill: url(#paperPatDark);
}

#sealImg {
  filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.45));
  transition: transform 0.15s ease;
  transform-origin: 360px 240px;
  transform-box: view-box;
  cursor: pointer;
}
#sealImg:hover {
  transform: scale(1.07);
}
#sealImg.falling {
  animation: sealFall 0.85s cubic-bezier(0.4, 0, 1, 1) forwards;
  pointer-events: none;
}
@keyframes sealFall {
  0% {
    transform: translate(0, 0) rotate(0deg);
    opacity: 1;
  }
  25% {
    transform: translate(40px, 60px) rotate(22deg);
    opacity: 1;
  }
  60% {
    transform: translate(70px, 320px) rotate(52deg);
    opacity: 0.5;
  }
  100% {
    transform: translate(90px, 800px) rotate(85deg);
    opacity: 0;
  }
}

/* ════════════════════════════
   CONFETTI
════════════════════════════ */
.cp {
  position: fixed;
  top: -30px;
  pointer-events: none;
  animation: cpFall linear forwards;
}
@keyframes cpFall {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(110vh) rotate(720deg);
    opacity: 0;
  }
}

/* ════════════════════════════
   DESKTOP OVERRIDE
════════════════════════════ */
@media (min-width: 601px) {
  h1 {
    font-size: 64px;
  }
  h2 {
    font-size: 48px;
  }
  p,
  label,
  span {
    font-size: 20px;
  }

  #nameBox {
    max-width: 520px;
  }
  #nameBox h2 {
    font-size: 22px;
  }
  #nameInput {
    font-size: 18px;
  }
  #nextBtn {
    font-size: 17px;
  }

  #scene {
    width: 720px;
    height: 480px;
  }

  #card,
  #themeCard,
  #giftsCard,
  #thankYouCard, 
  #noCard {
    width: 700px;
    height: 520px;
    padding: 48px 60px;
    gap: 20px;
  }

  #top-img,
  #btm-img {
    display: none;
  }

  #top-img2 {
    margin-bottom: 0;
  }
  #btm-img2 {
    margin-top: 0;
  }

  .flowers-img {
    width: 400px;
  }
  .card-flowers img {
    width: 38%;
  }
  .card-deco {
    width: 15rem;
  }

  #card {
    overflow: visible;
  }

  .card-flowers {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(75% + 150px);
    justify-content: space-between;
    gap: 0;
    margin-top: 0;
    pointer-events: none;
  }
  .card-flowers img {
    width: 160px;
    height: auto;
    pointer-events: none;
  }
}

