:root {
  --bg-1: #6d1538;
  --bg-2: #2a0714;
  --bg-3: #14030a;
  --rose: #ff4d6d;
  --rose-2: #ff8fa3;
  --rose-deep: #c9184a;
  --gold: #f4c27a;
  --cream: #fff4ea;
  --ink: #3a0d1c;
  --paper: #fffaf3;
  --script: 'Dancing Script', cursive;
  --serif: 'Cormorant Garamond', Georgia, serif;
  --sans: 'Quicksand', system-ui, -apple-system, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; }

body {
  min-height: 100dvh;
  background-color: var(--bg-2);
  background-image: radial-gradient(120% 80% at 50% 0%, var(--bg-1), var(--bg-2) 55%, var(--bg-3));
  background-attachment: fixed;
  color: var(--cream);
  font-family: var(--sans);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

button { font: inherit; color: inherit; }

/* ---------- Décor ---------- */
#bg-hearts { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
#bg-hearts span {
  position: absolute;
  bottom: -40px;
  color: var(--rose);
  animation: floatUp linear infinite;
  text-shadow: 0 0 12px rgba(255, 77, 109, .7);
}
@keyframes floatUp {
  0%   { transform: translate(0, 0) rotate(-12deg); }
  50%  { transform: translate(22px, -55vh) rotate(12deg); }
  100% { transform: translate(-10px, -115vh) rotate(-12deg); }
}

#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 50; }

main {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(28px, env(safe-area-inset-top)) 16px max(28px, env(safe-area-inset-bottom));
}

.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 22px;
  width: 100%;
  max-width: 520px;
}
.screen.active { display: flex; animation: screenIn .8s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes screenIn {
  from { opacity: 0; transform: translateY(18px) scale(.98); }
  to   { opacity: 1; transform: none; }
}

.kicker {
  letter-spacing: .28em;
  text-transform: uppercase;
  font-size: .78rem;
  font-weight: 700;
  color: var(--gold);
}

h1 {
  font-family: var(--script);
  font-weight: 700;
  font-size: clamp(2.2rem, 9vw, 3.4rem);
  line-height: 1.1;
  text-shadow: 0 2px 28px rgba(255, 77, 109, .5);
}

.envelope.open + .hint { visibility: hidden; }
.hint { opacity: .7; font-size: .92rem; animation: pulse 2.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* ---------- Enveloppe ---------- */
.envelope {
  position: relative;
  width: min(300px, 78vw);
  aspect-ratio: 3 / 2;
  margin-top: 120px;
  border: 0;
  background: none;
  cursor: pointer;
  perspective: 900px;
  animation: hover 3s ease-in-out infinite;
  filter: drop-shadow(0 24px 40px rgba(0, 0, 0, .5));
}
.envelope.open { animation: none; cursor: default; }
@keyframes hover { 50% { transform: translateY(-10px) rotate(-1.5deg); } }

.envelope > span { position: absolute; display: block; }
.env-back  { inset: 0; background: #b3123f; border-radius: 10px; }
.env-letter {
  left: 7%; right: 7%; top: 8%; bottom: 8%;
  z-index: 1;
  background: var(--paper);
  border-radius: 6px;
  display: grid;
  place-items: center;
  color: var(--rose-deep);
  font-family: var(--script);
  font-size: 1.7rem;
  transition: transform .9s cubic-bezier(.3, 1.3, .5, 1) .45s;
}
.env-letter b { font-weight: 700; }
.env-front {
  inset: 0;
  z-index: 2;
  background: linear-gradient(160deg, #ff4d6d, #d6205a);
  border-radius: 10px;
  clip-path: polygon(0 0, 50% 56%, 100% 0, 100% 100%, 0 100%);
}
.env-flap {
  left: 0; right: 0; top: 0;
  height: 62%;
  z-index: 3;
  background: linear-gradient(180deg, #ff6f8a, #e8356a);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top;
  transition: transform .6s ease-in, z-index 0s .3s;
}
.env-seal {
  left: 50%; top: 56%;
  z-index: 4;
  width: 46px; height: 46px;
  margin: -23px 0 0 -23px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #f7d59d, #c8913e);
  color: #8a1238;
  display: grid !important;
  place-items: center;
  font-size: 22px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, .35);
  transition: transform .35s, opacity .35s;
}
.envelope.open .env-seal   { transform: scale(0) rotate(90deg); opacity: 0; }
.envelope.open .env-flap   { transform: rotateX(180deg); z-index: 0; }
.envelope.open .env-letter { transform: translateY(-62%); }

/* ---------- Question ---------- */
.buddy {
  width: min(170px, 42vw);
  height: auto;
  overflow: visible;
  filter: drop-shadow(0 12px 30px rgba(255, 77, 109, .45));
  animation: bob 3s ease-in-out infinite;
}
.buddy.shake { animation: shake .5s; }
.buddy.happy { animation: jump .6s ease-in-out infinite; }
@keyframes bob   { 50% { transform: translateY(-8px); } }
@keyframes shake { 20%, 60% { transform: translateX(-10px) rotate(-6deg); } 40%, 80% { transform: translateX(10px) rotate(6deg); } }
@keyframes jump  { 50% { transform: translateY(-22px) scale(1.06); } }

.brow { opacity: 0; transform-box: fill-box; transform-origin: center; transition: transform .35s, opacity .35s; }
.tear { opacity: 0; transform-box: fill-box; }
.buddy.crying .tear { animation: tear 1.3s ease-in infinite; }
.buddy.crying .tear-2 { animation-delay: .65s; }
@keyframes tear {
  0%   { opacity: 0; transform: translateY(0); }
  20%  { opacity: 1; }
  100% { opacity: 0; transform: translateY(46px); }
}

.plea { min-height: 1.4em; opacity: .85; font-size: 1rem; transition: opacity .3s; }

.choices {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 16px;
  width: 100%;
  min-height: 130px;
}

.btn {
  display: inline-block;
  border: 0;
  border-radius: 999px;
  padding: .6em 1.4em;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: font-size .4s cubic-bezier(.3, 1.6, .5, 1), opacity .35s, transform .35s, background .2s;
}
.yes {
  --grow: 0;
  font-size: min(calc(1.3rem + var(--grow) * .6rem), 15vw);
  color: #fff;
  background: linear-gradient(135deg, var(--rose), var(--rose-deep));
  box-shadow: 0 10px 34px rgba(255, 77, 109, .55), inset 0 1px 0 rgba(255, 255, 255, .35);
  animation: heartbeat 1.6s ease-in-out infinite;
}
@keyframes heartbeat {
  0%, 30%, 100% { transform: scale(1); }
  15% { transform: scale(1.06); }
  45% { transform: scale(1.03); }
}
.no {
  --shrink: 1;
  font-size: calc(1.15rem * var(--shrink));
  background: rgba(255, 244, 234, .06);
  border: 1.5px solid rgba(255, 244, 234, .45);
}
.no.gone { opacity: 0; transform: scale(0) rotate(-25deg); pointer-events: none; }

/* ---------- Lettre ---------- */
.letter {
  position: relative;
  width: 100%;
  padding: 34px 26px 22px;
  background: var(--paper);
  color: var(--ink);
  border-radius: 8px;
  text-align: left;
  font-family: var(--serif);
  font-size: 1.22rem;
  line-height: 1.5;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .45);
  transform: rotate(-1deg);
  cursor: pointer;
}
.letter::before {
  content: '❤';
  position: absolute;
  top: -18px; left: 50%;
  width: 38px; height: 38px;
  margin-left: -19px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ff7a95, var(--rose-deep));
  color: #fff;
  font-size: 17px;
  box-shadow: 0 4px 12px rgba(201, 24, 74, .5);
}
#love-text { white-space: pre-line; min-height: 8em; }
#love-text.typing::after { content: '|'; color: var(--rose-deep); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.signature {
  margin-top: 12px;
  text-align: right;
  font-family: var(--script);
  font-size: 1.7rem;
  color: var(--rose-deep);
}

/* ---------- Ticket ---------- */
.ticket {
  --cut: 74px;
  width: 100%;
  opacity: 0;
  transform: translateY(30px) rotate(1deg);
  transition: opacity .9s, transform .9s cubic-bezier(.2, 1.4, .4, 1);
  pointer-events: none;
  filter: drop-shadow(0 20px 40px rgba(0, 0, 0, .5));
}
.ticket.show { opacity: 1; transform: rotate(.6deg); pointer-events: auto; }
.ticket-inner {
  background: linear-gradient(160deg, #fff7ec, #fde3c8);
  color: var(--ink);
  border-radius: 18px;
  -webkit-mask:
    radial-gradient(circle 13px at 0 var(--cut), #0000 97%, #000) left / 51% 100% no-repeat,
    radial-gradient(circle 13px at 100% var(--cut), #0000 97%, #000) right / 51% 100% no-repeat;
          mask:
    radial-gradient(circle 13px at 0 var(--cut), #0000 97%, #000) left / 51% 100% no-repeat,
    radial-gradient(circle 13px at 100% var(--cut), #0000 97%, #000) right / 51% 100% no-repeat;
}
.ticket-head {
  height: var(--cut);
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-bottom: 2px dashed rgba(58, 13, 28, .25);
  background: linear-gradient(135deg, var(--rose), var(--rose-deep));
  color: #fff;
}
.ticket-head span { font-size: .72rem; letter-spacing: .3em; text-transform: uppercase; opacity: .85; }
.ticket-head b { font-family: var(--script); font-size: 1.7rem; }

.ticket-body { padding: 20px 18px 22px; display: flex; flex-direction: column; align-items: center; gap: 14px; }

.scratch-wrap { position: relative; width: 100%; border-radius: 12px; overflow: hidden; }
.ticket-info { padding: 16px 12px 18px; }
.resto { font-family: var(--script); font-size: 2.1rem; font-weight: 700; color: var(--rose-deep); line-height: 1.1; margin-bottom: 12px; }
.ticket-info ul { list-style: none; display: grid; gap: 8px; text-align: left; max-width: 320px; margin: 0 auto; }
.ticket-info li { display: flex; gap: 10px; align-items: baseline; font-size: 1rem; }
.ticket-info li b { font-weight: 700; }
.ticket-info li b::first-letter { text-transform: uppercase; }

#scratch { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; transition: opacity .7s; }
#scratch.fade { opacity: 0; pointer-events: none; }

.link { background: none; border: 0; cursor: pointer; font-size: .85rem; text-decoration: underline; text-underline-offset: 3px; opacity: .65; }
.ticket .link { color: var(--ink); }
.scratch-wrap.revealed ~ .link { display: none; }
.replay { color: var(--cream); margin-top: 6px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
