/* Quiz d'anniversaire — feuille de style commune (quiz + admin) */
:root {
  --bg: #fbf4ee;
  --bg-2: #f3e4d8;
  --surface: #ffffff;
  --paper: #fffdfa;
  --ink: #2a1b22;
  --ink-2: #6f5a63;
  --ink-3: #a08e95;
  --line: #ead9cf;
  --accent: #c23b68;
  --accent-ink: #ffffff;
  --accent-soft: #f8dbe4;
  --gold: #e8a453;
  --ok: #2c8a5d;
  --ok-soft: #dcf1e6;
  --ko: #c24034;
  --ko-soft: #f8e0dc;
  --shadow: 0 1px 2px rgb(60 20 35 / 6%), 0 10px 30px -10px rgb(60 20 35 / 22%);
  --radius: 16px;
  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-hand: 'Caveat', 'Segoe Print', cursive;
  --font-ui: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1216;
    --bg-2: #261a20;
    --surface: #2a1d24;
    --paper: #fbf6f1;
    --ink: #f6eaef;
    --ink-2: #c9b4bd;
    --ink-3: #8f7a83;
    --line: #3e2c35;
    --accent: #ec6f97;
    --accent-ink: #2a0f1b;
    --accent-soft: #4a2333;
    --ok: #5cc993;
    --ok-soft: #1d3a2c;
    --ko: #f0806f;
    --ko-soft: #42211d;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 12px 32px -12px rgb(0 0 0 / 60%);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
body::before {
  /* Halo doux en fond */
  content: '';
  position: fixed;
  inset: -20vmax;
  z-index: -1;
  background:
    radial-gradient(40vmax 40vmax at 15% 10%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 70%),
    radial-gradient(45vmax 45vmax at 90% 85%, color-mix(in srgb, var(--gold) 18%, transparent), transparent 70%);
  pointer-events: none;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* --- Boutons ---------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  min-height: 48px; padding: 0 1.4em;
  border: 0; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink);
  font-weight: 600; letter-spacing: .01em;
  box-shadow: 0 6px 18px -8px color-mix(in srgb, var(--accent) 70%, transparent);
  transition: transform .15s ease, box-shadow .15s ease, opacity .15s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: default; box-shadow: none; }
.btn-ghost {
  background: transparent; color: var(--ink-2); box-shadow: none;
  border: 1px solid var(--line);
}
.btn-sm { min-height: 36px; padding: 0 1em; font-size: .9rem; }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
}
.icon-btn:disabled { opacity: .35; cursor: default; }
.link { background: none; border: 0; padding: 0; color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; }

/* --- Connexion ---------------------------------------------------------------------- */
.login {
  min-height: 100%; display: grid; place-items: center; padding: 24px 16px;
}
.login-card {
  width: min(400px, 100%);
  background: var(--surface); border-radius: 24px; box-shadow: var(--shadow);
  padding: 36px 28px 28px; text-align: center;
}
.login-card .gift { font-size: 48px; line-height: 1; margin-bottom: 8px; }
.login-card h1 { font: 600 1.9rem/1.15 var(--font-display); margin: 0 0 6px; }
.login-card p { color: var(--ink-2); margin: 0 0 24px; }
.field { display: grid; gap: 6px; text-align: left; margin-bottom: 14px; }
.field span { font-size: .85rem; font-weight: 500; color: var(--ink-2); }
.input, .textarea, .select {
  width: 100%; min-height: 48px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--bg); color: var(--ink);
}
.textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
.input:focus, .textarea:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.login-card .btn { width: 100%; margin-top: 8px; }
.error { color: var(--ko); font-size: .9rem; min-height: 1.4em; margin: 10px 0 0; }

/* --- Quiz : structure ----------------------------------------------------------------- */
.quiz { height: 100%; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
}
.topbar .title { font: 600 1rem/1.2 var(--font-display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.topbar a { color: var(--ink-2); font-size: .85rem; }
.progress { display: flex; gap: 4px; padding: 0 16px 6px; }
.progress .seg { flex: 1; height: 5px; border-radius: 99px; background: color-mix(in srgb, var(--ink) 9%, transparent); overflow: hidden; }
.progress .seg i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--gold)); border-radius: inherit; transition: width .4s ease; }
.progress .seg.current { background: color-mix(in srgb, var(--accent) 18%, transparent); }

.viewport { flex: 1; position: relative; overflow: hidden; touch-action: pan-y; }
.track { display: flex; height: 100%; transition: transform .45s cubic-bezier(.2,.8,.2,1); will-change: transform; }
.slide {
  flex: 0 0 100%; height: 100%;
  overflow-y: auto; overscroll-behavior: contain;
  padding: 12px 16px 24px;
  display: flex; flex-direction: column; align-items: center;
}
.slide > .inner { width: min(560px, 100%); margin: auto 0; display: flex; flex-direction: column; align-items: center; }

.controls {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 16px calc(env(safe-area-inset-bottom) + 12px);
}
.controls .count { font-size: .85rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.lock-hint { font-size: .78rem; color: var(--ink-3); text-align: center; flex: 1; }

/* --- Écrans d'accueil / chapitre / fin -------------------------------------------------- */
.hero { text-align: center; padding: 12px 4px; }
.hero .big { font-size: 64px; line-height: 1; margin-bottom: 14px; }
.hero .kicker { font-size: .78rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); margin: 0 0 8px; }
.hero h1, .hero h2 { font: 600 clamp(2rem, 8vw, 2.8rem)/1.08 var(--font-display); margin: 0 0 14px; letter-spacing: -.01em; }
.hero p { color: var(--ink-2); font-size: 1.05rem; margin: 0 auto 26px; max-width: 34ch; white-space: pre-line; }
.hero .meta { font-size: .85rem; color: var(--ink-3); margin: -12px 0 26px; }
.chapter-dots { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin: 0 0 28px; font-size: 22px; }
.score {
  font: 600 3.4rem/1.15 var(--font-display); margin: 4px 0 2px; padding: 0 .1em;
  background: linear-gradient(120deg, var(--accent), var(--gold)); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero .score-label { font-size: .85rem; color: var(--ink-3); margin: 0 0 18px; }
.finale-msg {
  font: 500 2rem/1.25 var(--font-hand); color: var(--ink); white-space: pre-line;
  margin: 18px auto 28px; max-width: 26ch;
}

/* --- Photo façon polaroid ---------------------------------------------------------------- */
.polaroid {
  background: var(--paper); padding: 10px 10px 0; border-radius: 4px;
  box-shadow: var(--shadow);
  transform: rotate(var(--tilt, -1.2deg));
  margin: 4px 0 18px;
  max-width: 100%;
}
.polaroid img {
  display: block; max-width: 100%; height: auto; border-radius: 2px;
  background: #eadfd6; object-fit: cover;
}
.polaroid figcaption {
  font: 600 1.35rem/1 var(--font-hand); color: #5b4750; text-align: center;
  padding: 10px 4px 12px;
}
.question { font: 600 clamp(1.25rem, 5vw, 1.5rem)/1.25 var(--font-display); text-align: center; margin: 0 0 16px; max-width: 30ch; }

.options { display: grid; gap: 10px; width: 100%; }
.option {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 54px;
  padding: 10px 14px; text-align: left;
  border: 1.5px solid var(--line); border-radius: 14px; background: var(--surface);
  transition: border-color .15s, background .15s, transform .15s;
}
.option:not(:disabled):hover { border-color: var(--accent); }
.option:not(:disabled):active { transform: scale(.985); }
.option .letter {
  flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  background: var(--bg-2); font-weight: 600; font-size: .85rem; color: var(--ink-2);
}
.option .mark { margin-left: auto; font-weight: 700; }
.option:disabled { cursor: default; }
.option.is-correct { border-color: var(--ok); background: var(--ok-soft); }
.option.is-correct .letter { background: var(--ok); color: #fff; }
.option.is-wrong { border-color: var(--ko); background: var(--ko-soft); }
.option.is-wrong .letter { background: var(--ko); color: #fff; }
.option.is-dim { opacity: .55; }

.free { width: 100%; display: grid; gap: 10px; }
.free .row { display: flex; gap: 10px; align-items: center; justify-content: flex-end; }
.saved { font-size: .85rem; color: var(--ok); }

.feedback { width: 100%; text-align: center; margin-top: 16px; animation: pop .35s ease; }
.feedback .verdict { font: 600 1.25rem/1.3 var(--font-display); margin: 0 0 6px; }
.feedback .verdict.ok { color: var(--ok); }
.feedback .verdict.ko { color: var(--ko); }
.reveal {
  background: var(--surface); border: 1px dashed var(--line); border-radius: 14px;
  padding: 12px 14px; margin: 12px 0 0; color: var(--ink-2); text-align: left; white-space: pre-line;
}
.next-btn { margin-top: 18px; }

@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }

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

.empty { text-align: center; color: var(--ink-2); padding: 40px 16px; }

@media (prefers-reduced-motion: reduce) {
  .track { transition: none; }
  .feedback { animation: none; }
}

.controls .lock-hint-wrap { flex: 1; text-align: center; line-height: 1.3; }
.controls .lock-hint { flex: none; }
