:root {
  --bg: #140c2b;
  --card: rgba(255, 255, 255, 0.07);
  --card-border: rgba(255, 255, 255, 0.14);
  --text: #fbf7ff;
  --muted: #c9bde6;
  --pink: #ff4fa3;
  --violet: #8b5cf6;
  --rainbow: linear-gradient(90deg, #ff3b3b, #ff9f1c, #ffe14d, #3ddc84, #3ea8ff, #a259ff, #ff4fa3, #ff3b3b);
  --radius: 22px;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
}

body.disco { animation: disco 2s linear infinite; }
@keyframes disco { to { filter: hue-rotate(360deg); } }

/* ---------- Fond animé ---------- */
.blobs { position: fixed; inset: 0; z-index: -1; overflow: hidden; filter: blur(70px); opacity: .55; }
.blobs span {
  position: absolute; width: 45vmax; height: 45vmax; border-radius: 50%;
  animation: float 18s ease-in-out infinite alternate;
}
.blobs span:nth-child(1) { background: #ff3b7f; top: -15%; left: -10%; }
.blobs span:nth-child(2) { background: #7c3aed; top: 40%; right: -20%; animation-delay: -4s; }
.blobs span:nth-child(3) { background: #ff9f1c; bottom: -25%; left: 10%; animation-delay: -8s; width: 35vmax; height: 35vmax; }
.blobs span:nth-child(4) { background: #3ea8ff; top: 10%; right: 20%; animation-delay: -12s; width: 25vmax; height: 25vmax; }
.blobs span:nth-child(5) { background: #3ddc84; bottom: 5%; right: 30%; animation-delay: -16s; width: 20vmax; height: 20vmax; }
@keyframes float {
  0%   { transform: translate(0, 0) scale(1); }
  50%  { transform: translate(8vw, 6vh) scale(1.15); }
  100% { transform: translate(-6vw, -4vh) scale(.9); }
}

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

/* ---------- Layout ---------- */
#app {
  width: min(680px, calc(100% - 32px));
  margin: 40px 0 20px;
  flex: 1;
}

.screen {
  display: none;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: clamp(22px, 5vw, 44px);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
  text-align: center;
}
.screen.active { display: block; animation: pop .45s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes pop { from { opacity: 0; transform: translateY(16px) scale(.97); } }

/* ---------- Typo ---------- */
.rainbow-text {
  background: var(--rainbow);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shine 4s linear infinite;
}
@keyframes shine { to { background-position: 200% center; } }

h1 {
  font-size: clamp(2.8rem, 11vw, 5.2rem);
  line-height: 1;
  margin: 12px 0 18px;
  font-weight: 900;
  letter-spacing: -0.03em;
  cursor: pointer;
  user-select: none;
}
h2 { font-size: clamp(1.3rem, 4.5vw, 1.8rem); line-height: 1.25; margin: 10px 0 20px; }
.lead { font-size: 1.1rem; color: var(--muted); margin: 0 auto 24px; max-width: 34em; }
.lead strong { color: var(--text); }

.badge {
  display: inline-block; margin: 0;
  padding: 6px 14px; border-radius: 999px;
  background: rgba(255, 255, 255, .1); border: 1px solid var(--card-border);
  font-size: .85rem; color: var(--muted);
}

.fineprint { font-size: .78rem; color: var(--muted); opacity: .8; margin: 16px 0 0; }

/* ---------- Stats ---------- */
.stats { list-style: none; padding: 0; margin: 0 0 26px; display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }
.stats li {
  background: rgba(255, 255, 255, .06); border: 1px solid var(--card-border);
  border-radius: 16px; padding: 10px 16px; min-width: 96px;
}
.stats b { display: block; font-size: 1.4rem; }
.stats span { font-size: .8rem; color: var(--muted); }

/* ---------- Champ prénom ---------- */
.name-field { display: block; text-align: left; max-width: 360px; margin: 0 auto 22px; }
.name-field span { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 6px; }
.name-field input {
  width: 100%; padding: 14px 16px; border-radius: 14px;
  border: 1px solid var(--card-border); background: rgba(0, 0, 0, .25);
  color: var(--text); font: inherit; font-size: 1.05rem; outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.name-field input:focus { border-color: var(--pink); box-shadow: 0 0 0 4px rgba(255, 79, 163, .25); }

/* ---------- Boutons ---------- */
.actions { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-top: 8px; }
.btn {
  font: inherit; font-weight: 800; font-size: 1.05rem;
  border: 0; border-radius: 999px; padding: 15px 28px; cursor: pointer;
  color: var(--text); transition: transform .15s, box-shadow .2s, opacity .2s;
  max-width: 100%;
}
.btn:hover { transform: translateY(-2px) scale(1.03); }
.btn:active { transform: scale(.97); }
.btn:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.btn-primary {
  background: linear-gradient(135deg, var(--pink), var(--violet));
  box-shadow: 0 10px 30px rgba(255, 79, 163, .45);
  min-width: 260px;
}
.btn-secondary { background: rgba(255, 255, 255, .14); border: 1px solid var(--card-border); min-width: 260px; }
.btn-ghost { background: transparent; color: var(--muted); font-weight: 600; font-size: .95rem; text-decoration: underline; text-underline-offset: 3px; }

.runaway { position: fixed !important; z-index: 40; transition: left .25s ease, top .25s ease, transform .2s; }

/* ---------- Quiz ---------- */
.quiz-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; color: var(--muted); font-weight: 700; }
.gauge { display: flex; flex-direction: column; align-items: center; font-size: .7rem; text-transform: uppercase; letter-spacing: .1em; }
.gauge svg { width: 96px; height: 56px; overflow: visible; }
#needle { transform-origin: 60px 62px; transform: rotate(-90deg); transition: transform .8s cubic-bezier(.3, 1.6, .5, 1); }

.progress { height: 10px; border-radius: 999px; background: rgba(255, 255, 255, .1); overflow: hidden; }
.progress > div { height: 100%; width: 0; background: var(--rainbow); background-size: 200% auto; border-radius: inherit; transition: width .5s ease; animation: shine 3s linear infinite; }
.progress.big { height: 16px; margin: 6px 0 24px; }

.q-emoji { font-size: 4rem; margin: 22px 0 0; animation: wobble 2.5s ease-in-out infinite; display: inline-block; }
@keyframes wobble { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg) scale(1.08); } }
.q-text { min-height: 2.5em; }

.answers { display: grid; gap: 12px; }
@media (min-width: 560px) { .answers { grid-template-columns: 1fr 1fr; } }
.answer {
  font: inherit; font-size: 1rem; font-weight: 700; text-align: left;
  padding: 16px 18px; border-radius: 16px; cursor: pointer;
  background: rgba(255, 255, 255, .08); color: var(--text);
  border: 1px solid var(--card-border);
  transition: transform .15s, background .2s, border-color .2s;
}
.answer:hover { background: rgba(255, 79, 163, .2); border-color: var(--pink); transform: translateY(-2px); }
.answer:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.answer.picked { background: linear-gradient(135deg, var(--pink), var(--violet)); border-color: transparent; }
.answers.locked .answer { pointer-events: none; }
.answer.grow { transition: transform .3s; }

/* ---------- Analyse ---------- */
.radar {
  width: 170px; height: 170px; margin: 0 auto 10px; border-radius: 50%; position: relative; overflow: hidden;
  background:
    repeating-radial-gradient(circle, transparent 0 24px, rgba(255, 255, 255, .15) 25px 26px),
    radial-gradient(circle, rgba(139, 92, 246, .35), rgba(20, 12, 43, .6));
  border: 2px solid rgba(255, 255, 255, .25);
}
.sweep {
  position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0 70%, rgba(255, 79, 163, .85) 100%);
  animation: spin 1.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.radar .dot {
  position: absolute; width: 12px; height: 12px; border-radius: 50%; background: #ffe14d;
  top: 38%; left: 62%; box-shadow: 0 0 14px #ffe14d; animation: blink 1.6s infinite;
}
@keyframes blink { 0%, 100% { opacity: .2; } 30% { opacity: 1; } }

.scan-log { list-style: none; padding: 0; margin: 0 0 20px; text-align: left; min-height: 13em; }
.scan-log li { padding: 6px 0; color: var(--muted); animation: pop .3s ease; }
.scan-log li.done { color: var(--text); }
.scan-log li::before { content: "⏳ "; }
.scan-log li.done::before { content: "✅ "; }

/* ---------- Résultat ---------- */
.r-intro { color: var(--muted); font-size: 1.15rem; margin: 0; }
.r-percent { font-size: clamp(4.5rem, 22vw, 8rem); font-weight: 900; line-height: 1.05; letter-spacing: -0.04em; }
.r-emoji { font-size: 3.4rem; animation: wobble 2s ease-in-out infinite; display: inline-block; }
.r-tier h2 { margin: 6px 0 8px; }
.r-tier p { color: var(--muted); max-width: 32em; margin: 0 auto 26px; }

.certificate {
  position: relative; text-align: left;
  background: #fffaf0; color: #2b1d0e; border-radius: 14px;
  padding: 22px 24px; margin: 0 0 24px;
  border: 6px double #c9a227;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
  font-family: Georgia, "Times New Roman", serif;
}
.c-head { text-align: center; font-size: 1.15rem; font-weight: bold; letter-spacing: .05em; text-transform: uppercase; margin: 0 0 12px; color: #7a5a00; }
.c-body { margin: 0 0 16px; font-size: 1.05rem; }
.c-foot { display: flex; justify-content: space-between; align-items: flex-end; font-size: .85rem; gap: 12px; }
.c-sign { font-style: italic; text-align: right; font-family: "Brush Script MT", "Segoe Script", cursive; font-size: 1.2rem; }
.c-sign small { font-family: Georgia, serif; font-style: normal; font-size: .7rem; }
.stamp {
  position: absolute; right: 18px; top: 46%;
  transform: rotate(-14deg); border: 3px solid #e0115f; color: #e0115f;
  border-radius: 10px; padding: 4px 10px; font-weight: 900; font-family: system-ui, sans-serif;
  text-align: center; line-height: 1.1; opacity: .8; font-size: .85rem;
  pointer-events: none;
}

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 140%);
  background: rgba(20, 12, 43, .95); border: 1px solid var(--pink);
  padding: 12px 20px; border-radius: 16px; max-width: calc(100% - 32px);
  font-weight: 700; z-index: 60; transition: transform .35s cubic-bezier(.2, 1.4, .4, 1);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .4); text-align: center;
}
#toast.show { transform: translate(-50%, 0); }

/* ---------- Footer ---------- */
footer { width: min(680px, calc(100% - 32px)); text-align: center; font-size: .85rem; color: var(--muted); padding: 10px 0 30px; }
footer p { margin: 6px 0; }
footer a { color: var(--text); }

/* ---------- Accessibilité ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Sur mobile, le tampon passe sous le texte au lieu de le chevaucher */
@media (max-width: 560px) {
  .stamp { position: static; display: block; width: fit-content; margin: 14px auto 0; transform: rotate(-6deg); }
}
