:root {
  --bg: #FFF4F6;
  --card: #FFFFFF;
  --rose: #E0567A;
  --rose-2: #F28FA7;
  --rose-soft: #FCE1E8;
  --deep: #7B1E3F;
  --ink: #3B1624;
  --muted: #8C5A6A;
  --line: rgba(123, 30, 63, 0.12);
  --shadow: 0 18px 40px -22px rgba(123, 30, 63, 0.45);
  --serif: "Cormorant Garamond", Georgia, serif;
  --sans: "DM Sans", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  min-height: 100dvh;
  background:
    radial-gradient(120% 60% at 50% -10%, #FFE0E8 0%, transparent 60%),
    var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
img { display: block; max-width: 100%; }

.serif { font-family: var(--serif); font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center-text { text-align: center; }
.kicker {
  font-size: 12px; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--rose); font-weight: 600; margin: 0 0 6px;
}

/* ---------- Écrans plein format ---------- */
.screen {
  min-height: 100dvh; max-width: 480px; margin: 0 auto;
  padding: 32px 24px; display: flex; flex-direction: column;
}
.screen.center { align-items: center; justify-content: center; text-align: center; }
.big { font-size: 64px; margin: 0; line-height: 1; color: var(--deep); font-style: italic; }
.countdown {
  font-family: var(--serif); font-size: 48px; font-weight: 600; color: var(--rose);
  font-variant-numeric: tabular-nums; margin: 18px 0 6px;
}

/* ---------- Verrou ---------- */
.lock-heart {
  font-size: 54px; color: var(--rose); line-height: 1; margin-bottom: 18px;
  animation: beat 1.6s ease-in-out infinite;
}
@keyframes beat { 0%,100% { transform: scale(1); } 15% { transform: scale(1.18); } 30% { transform: scale(1); } 45% { transform: scale(1.1); } }
.lock-q { font-size: 34px; line-height: 1.15; margin: 4px 0 26px; color: var(--deep); }
.lock-form { width: 100%; display: flex; flex-direction: column; gap: 12px; }
.lock-form input {
  width: 100%; padding: 16px 18px; font: inherit; font-size: 18px; text-align: center;
  border: 1.5px solid var(--line); border-radius: 16px; background: var(--card); color: var(--ink);
  outline: none; transition: border-color .2s, box-shadow .2s;
}
.lock-form input:focus { border-color: var(--rose); box-shadow: 0 0 0 4px var(--rose-soft); }
.hint { min-height: 24px; color: var(--muted); font-size: 14px; margin-top: 14px; }
.shake { animation: shake .45s; }
@keyframes shake { 20%,60% { transform: translateX(-9px); } 40%,80% { transform: translateX(9px); } }
.unlocking { animation: unlockOut .6s ease forwards; }
@keyframes unlockOut { to { opacity: 0; transform: scale(1.06); filter: blur(6px); } }

/* ---------- Boutons ---------- */
.btn {
  border: 0; border-radius: 16px; padding: 15px 22px; font-weight: 600; font-size: 16px;
  background: linear-gradient(135deg, var(--rose) 0%, #C83D65 100%); color: #fff;
  box-shadow: 0 12px 24px -12px rgba(224, 86, 122, 0.8);
  transition: transform .15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-ghost { background: var(--card); color: var(--deep); border: 1.5px solid var(--line); box-shadow: none; }
.btn-small { padding: 9px 14px; font-size: 14px; border-radius: 12px; }

/* ---------- App ---------- */
#app { max-width: 480px; margin: 0 auto; animation: fadeIn .6s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.content { padding: 20px 18px calc(96px + env(safe-area-inset-bottom)); }
.tab { animation: fadeIn .35s ease; }
.tab-title { font-size: 40px; text-align: center; margin: 6px 0 4px; color: var(--deep); font-style: italic; }
.title { font-size: 38px; line-height: 1.1; margin: 4px 0 18px; color: var(--deep); }
.title em { color: var(--rose); }

.hero { position: relative; margin: 0 0 18px; border-radius: 28px; overflow: hidden; box-shadow: var(--shadow); }
.hero img { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; }
.hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, rgba(59,22,36,.55), transparent 45%); }
.hero-badge {
  position: absolute; left: 18px; bottom: 16px; z-index: 1; color: #fff;
  font-family: var(--serif); font-size: 22px; font-style: italic; display: flex; align-items: baseline; gap: 8px;
}
.hero-badge span { font-size: 72px; line-height: 0.9; font-weight: 600; }

.counter { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 0 0 12px; }
.counter div {
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  padding: 12px 4px; text-align: center; box-shadow: 0 8px 20px -16px rgba(123,30,63,.5);
}
.counter b { display: block; font-family: var(--serif); font-size: 30px; line-height: 1.1; color: var(--rose); font-variant-numeric: tabular-nums; }
.counter span { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

.home-links { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 22px 0; }
.card-link {
  text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 20px;
  padding: 16px; display: flex; flex-direction: column; gap: 2px;
}
.card-link span { font-size: 24px; color: var(--rose); }
.card-link b { font-size: 16px; color: var(--deep); }
.card-link small { color: var(--muted); font-size: 13px; }
.btn-final { width: 100%; margin-top: 4px; }

/* ---------- Lettre ---------- */
.envelope {
  position: relative; width: 100%; max-width: 340px; aspect-ratio: 3 / 2; margin: 40px auto 60px;
  cursor: pointer; perspective: 1200px;
}
.env-back, .env-front { position: absolute; inset: 0; border-radius: 12px; }
.env-back { background: #F7C3D0; }
.env-front {
  background:
    linear-gradient(to top right, #F9CFDA 50%, transparent 50.5%) left / 50% 100% no-repeat,
    linear-gradient(to top left, #F9CFDA 50%, transparent 50.5%) right / 50% 100% no-repeat,
    linear-gradient(to top, #FBD8E1 45%, transparent 45%);
  z-index: 3;
}
.env-flap {
  position: absolute; left: 0; right: 0; top: 0; height: 58%; z-index: 4;
  background: linear-gradient(to bottom, #EFA7BA, #F4B7C6);
  clip-path: polygon(0 0, 100% 0, 50% 100%); transform-origin: top;
  transition: transform .6s ease, z-index 0s .3s;
}
.env-letter {
  position: absolute; left: 7%; right: 7%; top: 10%; bottom: 8%; z-index: 2;
  background: #fff; border-radius: 6px; padding: 16px; color: var(--deep); font-size: 24px;
  transition: transform .7s ease .35s;
}
.env-seal {
  position: absolute; left: 50%; top: 52%; transform: translate(-50%, -50%); z-index: 5;
  width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, #F26B8E, #B8254F); color: #fff; font-size: 22px;
  box-shadow: 0 6px 14px rgba(123,30,63,.35); transition: opacity .3s;
}
.env-hint { position: absolute; left: 0; right: 0; bottom: -40px; text-align: center; color: var(--muted); font-size: 14px; margin: 0; }
.envelope.open .env-flap { transform: rotateX(180deg); z-index: 1; }
.envelope.open .env-seal { opacity: 0; }
.envelope.open .env-letter { transform: translateY(-55%); }
.envelope.open .env-hint { opacity: 0; }

.letter {
  background: var(--card); border-radius: 22px; padding: 28px 24px; box-shadow: var(--shadow);
  border: 1px solid var(--line); animation: fadeIn .7s ease; margin-top: 12px;
}
.letter p { margin: 0 0 14px; }
.letter .opening { font-family: var(--serif); font-size: 30px; font-style: italic; color: var(--deep); margin-bottom: 18px; }
.letter .sign { font-family: var(--serif); font-size: 26px; font-style: italic; color: var(--rose); text-align: right; margin-top: 22px; }

/* ---------- 100 raisons ---------- */
.reasons-bar { display: flex; align-items: center; justify-content: space-between; margin: 16px 0 14px; font-size: 14px; color: var(--muted); }
.reasons-bar b { color: var(--rose); font-size: 18px; }
.grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.grid button {
  aspect-ratio: 1; border: 1px solid var(--line); border-radius: 14px; background: var(--card);
  font-family: var(--serif); font-size: 20px; font-weight: 600; color: var(--deep);
  transition: transform .15s, background .2s;
}
.grid button:active { transform: scale(0.94); }
.grid button.seen { background: linear-gradient(135deg, var(--rose-2), var(--rose)); color: #fff; border-color: transparent; }

/* ---------- Timeline ---------- */
.timeline { list-style: none; margin: 22px 0 0; padding: 0 0 0 22px; position: relative; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 8px; bottom: 8px; width: 2px; background: linear-gradient(var(--rose-2), var(--rose-soft)); }
.timeline li { position: relative; margin: 0 0 30px; }
.timeline li::before {
  content: ""; position: absolute; left: -22px; top: 6px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--rose); box-shadow: 0 0 0 4px var(--rose-soft);
}
.tl-date { font-size: 12px; letter-spacing: .16em; text-transform: uppercase; color: var(--rose); font-weight: 600; }
.tl-title { font-family: var(--serif); font-size: 28px; font-weight: 600; color: var(--deep); margin: 0 0 10px; line-height: 1.1; }
.tl-photo { border-radius: 20px; overflow: hidden; box-shadow: var(--shadow); margin-bottom: 10px; }
.tl-photo img { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; }
.tl-text { margin: 0; }

/* ---------- Playlist ---------- */
.playlist { list-style: none; padding: 0; margin: 20px 0 0; display: flex; flex-direction: column; gap: 10px; }
.playlist a, .playlist .pl-item {
  display: flex; align-items: center; gap: 14px; text-decoration: none; color: inherit;
  background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 14px 16px;
  width: 100%; text-align: left; transition: background .2s, border-color .2s;
}
.playlist .pl-item.is-current { background: var(--rose-soft); border-color: var(--rose-2); }
.playlist .pl-item.is-current .pl-num { background: var(--rose); color: #fff; }
.playlist a .pl-play { color: var(--muted); font-size: 18px; }
.pl-num { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--rose-soft); color: var(--rose); font-weight: 600; flex: none; }
.pl-info { flex: 1; min-width: 0; }
.pl-info b { display: block; color: var(--deep); }
.pl-info span { color: var(--muted); font-size: 14px; }
.pl-play { color: var(--rose); font-size: 20px; }

/* ---------- Défilé photos ---------- */
.reel-head { text-align: center; margin: 34px 0 12px; }
.reel-head p { margin: 0; }
.marquee {
  margin: 0 -18px; overflow: hidden;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 7%, #000 93%, transparent);
          mask-image: linear-gradient(to right, transparent, #000 7%, #000 93%, transparent);
}
/* padding-right = gap : ainsi -50% correspond exactement à une copie de la liste (boucle sans saut) */
.marquee-track {
  display: flex; gap: 10px; padding: 6px 10px 14px 0; width: max-content;
  animation: marquee var(--dur, 200s) linear infinite;
}
.marquee:hover .marquee-track { animation-play-state: paused; }
@keyframes marquee { from { transform: translateX(0); } to { transform: translateX(-50%); } }
.reel-item {
  position: relative; flex: none; width: 150px; padding: 0; border: 0; background: var(--rose-soft);
  border-radius: 16px; overflow: hidden; box-shadow: 0 10px 22px -14px rgba(123, 30, 63, 0.55);
}
.reel-item img { width: 150px; height: 188px; object-fit: cover; }
.reel-item span {
  position: absolute; left: 8px; bottom: 8px; background: rgba(255, 255, 255, 0.92); color: var(--deep);
  font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px;
}

/* ---------- Photo plein écran ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 45; padding: 20px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: rgba(20, 6, 12, 0.94); animation: fadeIn .2s ease;
}
.lightbox img { max-width: 100%; max-height: 78dvh; border-radius: 16px; object-fit: contain; }
.lb-caption { color: #fff; opacity: .85; font-size: 14px; margin: 14px 0 0; }
.lb-close, .lb-nav {
  position: absolute; border: 0; border-radius: 50%; background: rgba(255, 255, 255, 0.16); color: #fff;
  width: 44px; height: 44px; display: grid; place-items: center; line-height: 1; padding: 0;
}
.lb-close { top: max(16px, env(safe-area-inset-top)); right: 16px; font-size: 28px; }
.lb-nav { top: 50%; transform: translateY(-50%); font-size: 30px; }
.lb-prev { left: 10px; }
.lb-next { right: 10px; }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; z-index: 20;
  width: 100%; max-width: 480px; display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: rgba(255, 244, 246, 0.88); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.tabbar button { background: none; border: 0; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0; color: var(--muted); font-size: 11px; font-weight: 500; }
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar button.active { color: var(--rose); }
.tabbar button.active svg { fill: var(--rose-soft); }

.music-btn {
  position: fixed; right: max(16px, calc(50% - 224px)); bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 21;
  width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--card); color: var(--rose);
  font-size: 20px; box-shadow: var(--shadow);
}
.music-btn.playing { animation: beat 1.6s ease-in-out infinite; }

/* ---------- Mini-lecteur ---------- */
.player {
  position: fixed; z-index: 22; right: max(16px, calc(50% - 224px));
  bottom: calc(138px + env(safe-area-inset-bottom)); width: min(280px, calc(100vw - 32px));
  background: var(--card); border-radius: 22px; padding: 16px; box-shadow: 0 24px 50px -18px rgba(59,22,36,.45);
  border: 1px solid var(--line); animation: pop .3s cubic-bezier(.2,.9,.3,1.3); transform-origin: bottom right;
}
.player-top { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; }
.player-cover {
  width: 52px; height: 52px; border-radius: 14px; flex: none; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--rose-2), #C83D65); color: #fff; font-size: 22px;
}
.player-info { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.player-kicker { font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: var(--rose); font-weight: 600; }
.player-info b { font-family: var(--serif); font-size: 22px; color: var(--deep); }
.player-info span:last-child { font-size: 14px; color: var(--muted); }
.player-bar { height: 6px; border-radius: 6px; background: var(--rose-soft); cursor: pointer; position: relative; overflow: hidden; }
.player-bar::before { content: ""; position: absolute; inset: -10px 0; } /* zone tactile plus large */
#pProgress { height: 100%; width: 0; background: var(--rose); border-radius: 6px; }
.player-times { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin: 6px 0 10px; font-variant-numeric: tabular-nums; }
.player-controls { display: flex; justify-content: center; align-items: center; gap: 18px; }
.p-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--card);
  color: var(--deep); display: grid; place-items: center; padding: 0;
}
.p-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.p-main { width: 56px; height: 56px; border: 0; background: linear-gradient(135deg, var(--rose), #C83D65); color: #fff; box-shadow: 0 10px 22px -10px rgba(224,86,122,.8); }
.p-main svg { width: 24px; height: 24px; fill: currentColor; stroke: none; }
.p-main .i-pause { display: none; }
.p-main.is-playing .i-play { display: none; }
.p-main.is-playing .i-pause { display: block; }

/* ---------- Modales ---------- */
.modal {
  position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 24px;
  background: rgba(59, 22, 36, 0.45); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  animation: fadeIn .25s ease;
}
.modal-card {
  width: 100%; max-width: 400px; background: var(--card); border-radius: 26px; padding: 28px 24px 22px;
  text-align: center; box-shadow: 0 30px 60px -20px rgba(59,22,36,.5); animation: pop .35s cubic-bezier(.2,.9,.3,1.3);
}
@keyframes pop { from { transform: scale(.9); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-num { font-family: var(--serif); font-size: 44px; font-style: italic; color: var(--rose); margin: 0; line-height: 1; }
.modal-text { font-size: 28px; line-height: 1.25; color: var(--deep); margin: 16px 0 24px; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; padding-left: 10px; padding-right: 10px; white-space: nowrap; }
.modal-card { position: relative; }
.modal-x {
  position: absolute; top: 12px; right: 12px; width: 36px; height: 36px; border-radius: 50%;
  border: 0; background: var(--rose-soft); color: var(--deep); font-size: 22px; line-height: 1;
  display: grid; place-items: center;
}

.final-card { position: relative; }
.final-q { font-size: 32px; line-height: 1.15; color: var(--deep); margin: 6px 0 24px; }
.final-q em { color: var(--rose); }
.final-actions { display: flex; gap: 12px; justify-content: center; position: relative; min-height: 56px; }
.final-actions .btn { min-width: 120px; }
#noBtn.running { position: fixed; transition: left .25s ease, top .25s ease; z-index: 50; }
.final-score { font-family: var(--serif); font-size: 96px; line-height: 1; font-weight: 600; color: var(--rose); margin: 0; }
.final-score span { font-size: 40px; color: var(--muted); }
#finalYes p { margin: 0 0 20px; font-size: 17px; }

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

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .marquee { overflow-x: auto; } /* sans animation, le défilé se fait au doigt */
}
