@font-face {
  font-family: "Instrument Serif";
  src: url("/fonts/instrument-serif.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Instrument Serif";
  src: url("/fonts/instrument-serif-italic.woff2") format("woff2");
  font-style: italic;
  font-weight: 400;
  font-display: swap;
}

:root {
  --night-0: #060914;
  --night-1: #0b1228;
  --night-2: #141d3d;
  --ink: #ece9f5;
  --ink-soft: #b9bbd6;
  --ink-mute: #7d82a8;
  --star: #fff6dc;
  --gold: #f3cd85;
  --tulip: #ef7d6b;
  --tulip-soft: rgba(239, 125, 107, 0.16);
  --line: rgba(236, 233, 245, 0.14);
  --glass: rgba(20, 29, 61, 0.62);
  --serif: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.4, 0.64, 1);
}

* { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; }
html { height: 100%; background: var(--night-0); -webkit-text-size-adjust: 100%; }
body {
  min-height: 100%;
  color: var(--ink);
  font: 400 17px/1.45 var(--sans);
  background:
    radial-gradient(120% 70% at 80% -10%, #1b2552 0%, transparent 60%),
    radial-gradient(90% 60% at 0% 110%, #1a1838 0%, transparent 60%),
    linear-gradient(180deg, var(--night-1), var(--night-0));
  background-attachment: fixed;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  height: 100dvh;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; touch-action: manipulation; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; border-radius: 12px; }
img { display: block; max-width: 100%; }

#sky { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
#app { position: relative; z-index: 1; height: 100dvh; }

.serif { font-family: var(--serif); font-weight: 400; letter-spacing: -0.01em; }
.saturn-mark { display: inline-block; width: 22px; height: 29px; color: var(--tulip); }
.saturn-mark svg { width: 100%; height: 100%; display: block; }

.boot { height: 100%; display: grid; place-items: center; }
.boot .saturn-mark { width: 34px; height: 44px; animation: breathe 2.4s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: 0.45; transform: scale(0.94); } }

/* Vues ------------------------------------------------------------------ */
.view {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: calc(var(--safe-t) + 12px) 20px calc(var(--safe-b) + 14px);
  animation: view-in 0.6s var(--ease-out) both;
}
@keyframes view-in { from { opacity: 0; transform: translateY(10px); } }

.top { display: flex; align-items: center; gap: 12px; padding: 4px 4px 0; }
.top__title { font-family: var(--serif); font-style: italic; font-size: 34px; line-height: 1; }
.top__sub { margin-left: auto; font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-mute); }
.top__sub b { color: var(--ink); font-weight: 600; }

.pill {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 22px; border-radius: 999px;
  background: var(--glass); border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  font-size: 15px; font-weight: 500; color: var(--ink);
  transition: transform 0.2s var(--ease-out), background 0.2s;
}
.pill:active { transform: scale(0.96); }
.pill--primary { background: var(--ink); color: var(--night-1); border-color: transparent; }
.pill .count { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--tulip); color: #fff; font-size: 12px; font-weight: 700; display: inline-grid; place-items: center; }
.bottom { display: flex; justify-content: center; padding-top: 8px; }

/* Constellation ---------------------------------------------------------- */
.sky-map { position: relative; flex: 1; margin: 10px -6px 6px; min-height: 0; }
.sky-map svg.links { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.sky-map svg.links polyline { fill: none; stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; stroke-dasharray: 2 5; }
.sky-map svg.links polyline.lit { stroke: rgba(243, 205, 133, 0.45); stroke-dasharray: none; }

.node {
  position: absolute; width: 48px; height: 48px; margin: -24px 0 0 -24px;
  display: grid; place-items: center; border-radius: 50%;
  animation: node-in 0.7s var(--ease-out) both;
  animation-delay: calc(var(--i) * 28ms);
}
@keyframes node-in { from { opacity: 0; transform: scale(0.4); } }
.node__dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ink-mute); opacity: 0.55;
  transition: transform 0.3s var(--ease-spring);
}
.node__num {
  position: absolute; top: 34px; font-size: 11px; font-weight: 600; letter-spacing: 0.04em;
  color: var(--ink-mute); font-variant-numeric: tabular-nums;
}
.node:active .node__dot { transform: scale(1.5); }

.node.is-open .node__dot { width: 9px; height: 9px; background: var(--star); opacity: 1; box-shadow: 0 0 10px 2px rgba(255, 246, 220, 0.45); }
.node.is-open .node__num { color: var(--ink-soft); }

.node.is-late .node__dot { width: 11px; height: 11px; background: var(--gold); opacity: 1; box-shadow: 0 0 14px 3px rgba(243, 205, 133, 0.55); }
.node.is-late .node__num { color: var(--gold); }
.node.is-late::after {
  content: ""; position: absolute; inset: 8px; border-radius: 50%;
  border: 1px solid rgba(243, 205, 133, 0.5);
  animation: ping 2.4s var(--ease-out) infinite;
}

.node.is-today .node__dot { width: 14px; height: 14px; background: var(--star); opacity: 1; box-shadow: 0 0 18px 6px rgba(255, 246, 220, 0.6); }
.node.is-today .node__num { color: var(--ink); top: 36px; font-size: 12px; }
.node.is-today::before, .node.is-today::after {
  content: ""; position: absolute; inset: 6px; border-radius: 50%;
  border: 1px solid rgba(255, 246, 220, 0.55);
  animation: ping 2.6s var(--ease-out) infinite;
}
.node.is-today::after { animation-delay: 1.3s; }
.node.is-today.is-open::before, .node.is-today.is-open::after { display: none; }
@keyframes ping { from { transform: scale(0.6); opacity: 1; } to { transform: scale(1.9); opacity: 0; } }

.node--final .node__dot { width: 12px; height: 12px; }
.node--final.is-locked .node__dot { background: transparent; border: 1px solid var(--ink-mute); }

.legend { display: flex; justify-content: center; gap: 16px; font-size: 12px; color: var(--ink-mute); }
.legend i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.legend .l-late { background: var(--gold); }
.legend .l-open { background: var(--star); }

/* Attente --------------------------------------------------------------- */
.waiting { justify-content: center; text-align: center; gap: 22px; }
.waiting .saturn-mark { width: 40px; height: 52px; margin: 0 auto; }
.waiting h1 { font-family: var(--serif); font-style: italic; font-weight: 400; font-size: 56px; line-height: 1; }
.waiting p { color: var(--ink-soft); max-width: 290px; margin: 0 auto; }
.clock { display: flex; justify-content: center; gap: 14px; font-variant-numeric: tabular-nums; }
.clock div { min-width: 62px; }
.clock b { display: block; font-family: var(--serif); font-size: 44px; font-weight: 400; line-height: 1; }
.clock span { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-mute); }

/* Erreur réseau --------------------------------------------------------- */
.offline { justify-content: center; align-items: center; text-align: center; gap: 18px; }
.offline h2 { font-family: var(--serif); font-style: italic; font-weight: 400; font-size: 36px; }
.offline p { color: var(--ink-soft); }

/* Bandeau écran d'accueil ---------------------------------------------- */
.a2hs {
  position: fixed; z-index: 5; left: 14px; right: 14px; bottom: calc(var(--safe-b) + 12px);
  padding: 18px 18px 14px; border-radius: 22px;
  background: rgba(16, 23, 50, 0.92); border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  animation: rise 0.6s var(--ease-out) 0.8s both;
}
.a2hs h3 { font-family: var(--serif); font-weight: 400; font-size: 24px; line-height: 1.1; margin-bottom: 6px; }
.a2hs p { font-size: 14px; color: var(--ink-soft); }
.a2hs .share { display: inline-block; width: 16px; height: 18px; vertical-align: -3px; color: #5aa7ff; }
.a2hs .row { display: flex; justify-content: flex-end; margin-top: 10px; }
.a2hs .row button { min-height: 40px; padding: 0 12px; font-size: 14px; color: var(--ink-mute); }
@keyframes rise { from { opacity: 0; transform: translateY(24px); } }

/* Toast ----------------------------------------------------------------- */
.toast {
  position: fixed; z-index: 20; left: 50%; top: calc(var(--safe-t) + 14px);
  transform: translate(-50%, -16px); opacity: 0; pointer-events: none;
  padding: 10px 18px; border-radius: 999px; font-size: 14px; white-space: nowrap;
  background: rgba(16, 23, 50, 0.92); border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  transition: opacity 0.25s, transform 0.35s var(--ease-out);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Feuille d'ouverture --------------------------------------------------- */
.sheet { position: fixed; inset: 0; z-index: 10; }
.sheet::before {
  content: ""; position: absolute; inset: 0; background: rgba(3, 5, 12, 0.6);
  opacity: 0; transition: opacity 0.35s;
}
.sheet.open::before { opacity: 1; }
.sheet__panel {
  position: absolute; left: 0; right: 0; bottom: 0; top: calc(var(--safe-t) + 18px);
  display: flex; flex-direction: column;
  border-radius: 30px 30px 0 0;
  background: linear-gradient(180deg, #121a38 0%, #0b1129 100%);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.5);
  transform: translateY(104%);
  transition: transform 0.5s var(--ease-out);
  will-change: transform;
  overflow: hidden;
}
.sheet.open .sheet__panel { transform: none; }
.sheet.dragging .sheet__panel { transition: none; }
.sheet__grab { width: 38px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.18); margin: 9px auto 0; flex: none; }
.sheet__close {
  position: absolute; z-index: 2; top: 14px; right: 14px; width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
}
.sheet__close::before, .sheet__close::after {
  content: ""; position: absolute; left: 11px; right: 11px; top: 17px; height: 2px; border-radius: 1px; background: var(--ink-soft);
  transform: rotate(45deg);
}
.sheet__close::after { transform: rotate(-45deg); }
.sheet__body {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding: 26px 26px calc(var(--safe-b) + 34px);
}

/* Contenu des cases ----------------------------------------------------- */
.case > * { animation: line-in 0.7s var(--ease-out) both; }
.case > *:nth-child(1) { animation-delay: 0.18s; }
.case > *:nth-child(2) { animation-delay: 0.28s; }
.case > *:nth-child(3) { animation-delay: 0.38s; }
.case > *:nth-child(4) { animation-delay: 0.48s; }
.case > *:nth-child(n+5) { animation-delay: 0.56s; }
@keyframes line-in { from { opacity: 0; transform: translateY(12px); } }

.case__day { font-size: 12px; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-mute); margin-bottom: 14px; }
.case__day em { font-style: normal; color: var(--gold); margin-left: 8px; }
.case__title { font-family: var(--serif); font-weight: 400; font-size: 44px; line-height: 1.02; letter-spacing: -0.015em; margin-bottom: 20px; }
.case__text { font-size: 19px; line-height: 1.55; color: var(--ink-soft); white-space: pre-line; overflow-wrap: anywhere; }
.case__text + .case__text { margin-top: 14px; }
.case__photo { margin-top: 24px; border-radius: 20px; overflow: hidden; background: var(--night-2); aspect-ratio: 4 / 5; }
.case__photo img { width: 100%; height: 100%; object-fit: cover; }
.case__actions { margin-top: 30px; display: flex; flex-direction: column; gap: 12px; }
.case__actions .pill { width: 100%; }

/* Bon */
.ticket {
  position: relative; margin-top: 26px; padding: 22px 22px 20px;
  border-radius: 20px; background: linear-gradient(140deg, #1d2650, #151c3d);
  border: 1px solid rgba(239, 125, 107, 0.35);
  overflow: hidden;
}
.ticket::before, .ticket::after {
  content: ""; position: absolute; top: 50%; width: 22px; height: 22px; margin-top: -11px; border-radius: 50%;
  background: #0f1631;
}
.ticket::before { left: -12px; }
.ticket::after { right: -12px; }
.ticket__label { font-size: 11px; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase; color: var(--tulip); }
.ticket__name { font-family: var(--serif); font-size: 30px; line-height: 1.1; margin-top: 6px; }
.ticket__tulip { position: absolute; right: 16px; bottom: 12px; width: 34px; height: 44px; color: var(--tulip); opacity: 0.9; }
.ticket__note { margin-top: 12px; font-size: 13px; color: var(--ink-mute); }

/* Quiz */
.quiz__progress { display: flex; gap: 6px; margin-bottom: 18px; }
.quiz__progress i { flex: 1; height: 3px; border-radius: 2px; background: var(--line); transition: background 0.3s; }
.quiz__progress i.done { background: var(--gold); }
.quiz__q { font-family: var(--serif); font-size: 30px; line-height: 1.15; margin-bottom: 20px; }
.quiz__choices { display: flex; flex-direction: column; gap: 10px; }
.choice {
  min-height: 56px; padding: 14px 18px; border-radius: 16px; text-align: left; font-size: 17px;
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line);
  transition: background 0.25s, border-color 0.25s, transform 0.15s, opacity 0.25s;
}
.choice:active { transform: scale(0.98); }
.choice.right { background: rgba(243, 205, 133, 0.16); border-color: var(--gold); }
.choice.wrong { background: var(--tulip-soft); border-color: var(--tulip); }
.choice.dim { opacity: 0.4; }
.quiz__react { min-height: 28px; margin-top: 16px; font-size: 17px; color: var(--gold); }

/* Countdown inline (jour 23) */
.case .clock { justify-content: flex-start; margin-top: 26px; }

/* Mes bons -------------------------------------------------------------- */
.vouchers .list { flex: 1; overflow-y: auto; margin: 18px -20px 0; padding: 0 20px 20px; display: flex; flex-direction: column; gap: 12px; }
.vouchers h1 { font-family: var(--serif); font-style: italic; font-weight: 400; font-size: 44px; line-height: 1; }
.vouchers .hint { color: var(--ink-mute); font-size: 14px; margin-top: 6px; }
.vouchers .ticket { margin-top: 0; text-align: left; width: 100%; transition: opacity 0.3s, transform 0.2s; }
.vouchers .ticket:active { transform: scale(0.98); }
.vouchers .ticket.used { opacity: 0.4; }
.vouchers .ticket.used .ticket__name { text-decoration: line-through; text-decoration-thickness: 1px; }
.vouchers .empty { margin: auto; text-align: center; color: var(--ink-mute); }
.back { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; color: var(--ink-soft); font-size: 15px; }

/* Jour 12 */
.reveal-after { margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--line); animation: line-in 0.8s var(--ease-out) both; }

/* Jour 24 --------------------------------------------------------------- */
.final { position: fixed; inset: 0; z-index: 15; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: calc(var(--safe-t) + 30px) 30px calc(var(--safe-b) + 30px); }
.final::before { content: ""; position: absolute; inset: 0; background: radial-gradient(70% 50% at 50% 45%, rgba(20, 29, 61, 0.3), rgba(3, 5, 12, 0.92)); opacity: 0; transition: opacity 1.4s; }
.final.dark::before { opacity: 1; }
.final > * { position: relative; }
.final__q { margin-top: 12vh; font-family: var(--serif); font-weight: 400; font-size: 52px; line-height: 1.02; letter-spacing: -0.02em; opacity: 0; transform: translateY(14px) scale(0.98); transition: opacity 1.6s var(--ease-out), transform 1.6s var(--ease-out); }
.final__q.show { opacity: 1; transform: none; }
.final__yes { margin-top: 44px; min-width: 160px; min-height: 56px; font-size: 18px; opacity: 0; transform: translateY(10px); transition: opacity 0.9s var(--ease-out), transform 0.9s var(--ease-out); }
.final__yes.show { opacity: 1; transform: none; }
.final__reveal { font-family: var(--serif); font-style: italic; font-size: 34px; line-height: 1.15; max-width: 320px; opacity: 0; transition: opacity 1.4s var(--ease-out); }
.final__reveal.show { opacity: 1; }
.final__more { margin-top: 26px; max-width: 340px; color: var(--ink-soft); font-size: 18px; white-space: pre-line; opacity: 0; transition: opacity 1.2s var(--ease-out) 0.6s; }
.final__more.show { opacity: 1; }
.final__more .case__photo { margin-top: 20px; }
.final__close { position: absolute; bottom: calc(var(--safe-b) + 24px); left: 50%; transform: translateX(-50%); opacity: 0; transition: opacity 1s 1.6s; }
.final__close.show { opacity: 1; }
.final.scroll { justify-content: flex-start; overflow-y: auto; padding-top: calc(var(--safe-t) + 70px); padding-bottom: calc(var(--safe-b) + 110px); }

.petal { position: fixed; z-index: 16; top: -60px; width: 26px; height: 34px; color: var(--tulip); pointer-events: none; will-change: transform; animation: fall var(--dur, 3.2s) linear forwards; }
@keyframes fall {
  0% { transform: translate3d(0, 0, 0) rotate(var(--r0, 0deg)); opacity: 0; }
  10% { opacity: 1; }
  85% { opacity: 1; }
  100% { transform: translate3d(var(--dx, 0px), calc(100dvh + 120px), 0) rotate(var(--r1, 180deg)); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.2s !important; }
  .petal { display: none; }
}

/* Petits écrans (SE) et grands écrans */
@media (max-height: 700px) { .case__title { font-size: 38px; } .final__q { font-size: 44px; } }
@media (min-width: 600px) { #app, .sheet__panel { max-width: 460px; margin-inline: auto; } .sheet__panel { left: 50%; transform: translate(-50%, 104%); width: 460px; } .sheet.open .sheet__panel { transform: translate(-50%, 0); } }

body.has-a2hs .view { padding-bottom: calc(var(--safe-b) + 176px); }
.final__close:not(.show) { pointer-events: none; }
