:root {
  --pink: #f8d7e0;
  --blush: #fbe9ee;
  --white: #fffafb;
  --red: #9e1b32;
  --green: #2e7d4f;
  --ink: #5a2433;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --grow: 1;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--pink); color: var(--ink); font-family: var(--serif); -webkit-tap-highlight-color: transparent; }
main { position: relative; z-index: 1; }

.screen {
  min-height: 100dvh;
  padding: max(1.5rem, env(safe-area-inset-top)) 1.25rem max(2rem, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; opacity: 0; transition: opacity .7s ease;
}
.screen.is-active { opacity: 1; }
.screen[hidden] { display: none; }
#s-final { background: linear-gradient(180deg, var(--blush), var(--white)); justify-content: flex-start; gap: 1.6rem; }

/* Screen 1 */
.question { font-size: clamp(1.9rem, 7vw, 3.4rem); font-weight: 400; font-style: italic; line-height: 1.2; max-width: 14em; margin: 0 0 2rem; }
.actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 1rem; width: 100%; }
.btn {
  font-family: var(--serif); font-size: 1.1rem; letter-spacing: .08em;
  background: var(--white); border: 1.5px solid currentColor; border-radius: 999px;
  padding: .8em 2em; cursor: pointer; touch-action: manipulation;
  transition: transform .2s ease, box-shadow .2s ease;
}
.btn:hover { box-shadow: 0 6px 18px rgba(158, 27, 50, .15); }
.btn:active { transform: scale(.97); }
:is(.btn, .gift, .play, input):focus-visible { outline: 3px solid var(--ink); outline-offset: 4px; }
.btn-no { color: var(--red); }
.btn-yes {
  color: var(--green); font-size: calc(1.05rem * var(--grow)); padding: .7em 1.4em; max-width: 100%;
  transition: font-size .5s cubic-bezier(.3, 1.4, .5, 1), transform .2s ease, box-shadow .2s ease;
}

/* Screen 2: gift */
.gift { background: none; border: 0; padding: 0; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 1.4rem; color: var(--red); font-family: var(--serif); }
.gift svg { width: min(64vw, 15rem); height: auto; overflow: visible; transform-origin: 50% 95%; animation: shake 3.8s ease-in-out infinite; }
.gift-label { font-size: 1.5rem; font-style: italic; letter-spacing: .05em; padding: .3em 1.3em; border: 1.5px solid currentColor; border-radius: 999px; background: var(--white); transition: opacity .4s ease; }
.lid { transform-box: fill-box; transform-origin: 15% 100%; transition: transform .8s cubic-bezier(.3, 1.3, .5, 1); }
.gift.is-open svg { animation: none; }
.gift.is-open .lid { transform: translate(-8px, -72px) rotate(-18deg); }
.gift.is-open .gift-label { opacity: 0; }
@keyframes shake {
  0%, 72%, 100% { transform: rotate(0); }
  76% { transform: rotate(-4deg); } 80% { transform: rotate(4deg); }
  84% { transform: rotate(-3deg); } 88% { transform: rotate(2deg); } 92% { transform: rotate(0); }
}

/* Screen 3 */
.heading { font-size: clamp(1.8rem, 6vw, 2.8rem); font-weight: 400; font-style: italic; margin: 1rem 0 0; }
.polaroid { margin: 0; background: #fff; padding: .8rem .8rem 3rem; width: min(86vw, 22rem); transform: rotate(-2deg); box-shadow: 0 14px 34px rgba(90, 36, 51, .18); }
.photo { position: relative; background: var(--blush); min-height: 12rem; }
.photo img { display: block; width: 100%; height: auto; }
.photo-empty { display: none; position: absolute; inset: 0; align-items: center; justify-content: center; font-style: italic; opacity: .6; }
.photo.is-empty { aspect-ratio: 1; }
.photo.is-empty img { display: none; }
.photo.is-empty .photo-empty { display: flex; }
.letter { max-width: 32rem; font-size: 1.15rem; line-height: 1.8; margin: .4rem 0 0; white-space: pre-line; }

.is-active .reveal { animation: rise .9s ease both; }
.is-active .reveal:nth-child(2) { animation-delay: .25s; }
.is-active .reveal:nth-child(3) { animation-delay: .5s; }
.is-active .reveal:nth-child(4) { animation-delay: .75s; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
.polaroid.reveal { animation-name: rise-tilt; }
@keyframes rise-tilt { from { opacity: 0; transform: translateY(14px) rotate(-2deg); } to { opacity: 1; transform: rotate(-2deg); } }

/* Audio player */
.player { display: grid; grid-template-columns: auto 1fr; gap: .75rem 1rem; align-items: center; width: min(100%, 26rem); padding: 1rem 1.1rem; background: #fff; border-radius: 1.2rem; box-shadow: 0 8px 24px rgba(90, 36, 51, .12); }
.play { width: 3rem; height: 3rem; border-radius: 50%; border: 0; cursor: pointer; background: var(--red); color: #fff; display: grid; place-items: center; }
.play svg { fill: currentColor; }
.play.needs-tap { animation: pulse 1.6s ease-in-out infinite; }
.track input, .vol { width: 100%; accent-color: var(--red); }
.times { display: flex; justify-content: space-between; font-size: .8rem; opacity: .7; font-variant-numeric: tabular-nums; }
.vol { grid-column: 1 / -1; }
.player-note { grid-column: 1 / -1; margin: 0; font-size: .85rem; font-style: italic; }
.player.is-disabled { opacity: .55; pointer-events: none; }
@keyframes pulse { 50% { transform: scale(1.1); box-shadow: 0 0 0 .6rem rgba(158, 27, 50, .15); } }

/* Background hearts and rose petals */
.hearts, .petals { position: fixed; inset: 0; overflow: hidden; pointer-events: none; }
.hearts { z-index: 0; }
.petals { z-index: 5; }
.heart { position: absolute; bottom: -2rem; color: var(--red); opacity: 0; animation: float linear infinite; }
@keyframes float { 0% { transform: translateY(0) scale(.8); opacity: 0; } 10% { opacity: .25; } 100% { transform: translateY(-115vh) scale(1.1); opacity: 0; } }
.petal {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  will-change: transform, opacity;
  transform-origin: center;
  filter: drop-shadow(0 2px 3px rgba(70, 0, 12, 0.25));
}

@media (prefers-reduced-motion: reduce) {
  .screen, .btn-yes, .lid { transition: none; }
  .gift svg, .heart, .play.needs-tap, .is-active .reveal { animation: none; }
  .hearts { display: none; }
}
