:root {
  --violet: #5b3df5;
  --violet-fonce: #3a22b8;
  --rose: #ff5fa2;
  --jaune: #ffc93c;
  --encre: #1f1b3a;
  --gris: #6b6889;
  --fond-carte: #ffffff;
  --n1: #ff6b6b;
  --n2: #ffa94d;
  --n3: #4dabf7;
  --n4: #38d9a9;
  --rayon: 26px;
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  background: linear-gradient(135deg, #6a4cff 0%, #8f3dff 45%, #ff5fa2 100%);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Nunito", system-ui, sans-serif;
  color: var(--encre);
  background: transparent;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px 40px;
}

h1, h2, h3, .bouton, .pct, .niveau, .tuile-valeur { font-family: "Baloo 2", "Nunito", sans-serif; }

/* Bulles flottantes décoratives */
.bulles { position: fixed; inset: 0; z-index: -1; pointer-events: none; }
.bulles span {
  position: absolute; bottom: -120px; border-radius: 50%;
  background: rgba(255, 255, 255, .14);
  animation: monter 18s linear infinite;
}
.bulles span:nth-child(1) { left: 8%;  width: 80px;  height: 80px;  animation-duration: 16s; }
.bulles span:nth-child(2) { left: 25%; width: 40px;  height: 40px;  animation-duration: 12s; animation-delay: 3s; }
.bulles span:nth-child(3) { left: 48%; width: 120px; height: 120px; animation-duration: 22s; animation-delay: 1s; }
.bulles span:nth-child(4) { left: 68%; width: 55px;  height: 55px;  animation-duration: 14s; animation-delay: 6s; }
.bulles span:nth-child(5) { left: 85%; width: 95px;  height: 95px;  animation-duration: 19s; animation-delay: 2s; }
.bulles span:nth-child(6) { left: 38%; width: 28px;  height: 28px;  animation-duration: 10s; animation-delay: 8s; }
@keyframes monter {
  to { transform: translateY(-115vh) rotate(360deg); opacity: .2; }
}

/* En-tête */
.entete { display: flex; align-items: center; gap: 14px; color: #fff; margin-bottom: 18px; text-align: left; }
.logo {
  width: 58px; height: 58px; border-radius: 18px; display: grid; place-items: center;
  font-size: 30px; background: rgba(255, 255, 255, .2); backdrop-filter: blur(6px);
  animation: flotter 3s ease-in-out infinite;
}
.etab { margin: 0; font-size: .85rem; opacity: .9; }
.entete h1 { margin: 0; font-size: clamp(1.4rem, 4vw, 2rem); line-height: 1.1; }

/* Étapes */
.etapes { list-style: none; display: flex; gap: 6px; padding: 0; margin: 0 0 44px; }
.etapes li {
  display: flex; align-items: center; gap: 8px; padding: 6px 14px 6px 6px;
  border-radius: 999px; background: rgba(255, 255, 255, .16); color: #fff; font-weight: 700; font-size: .9rem;
}
.etapes .pastille {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(255, 255, 255, .25);
}
.etapes li.active { background: #fff; color: var(--violet); box-shadow: 0 6px 18px rgba(0, 0, 0, .15); }
.etapes li.active .pastille { background: var(--violet); color: #fff; }
.etapes li.faite .pastille { background: var(--n4); }
@media (max-width: 520px) { .etapes .nom { display: none; } .etapes li { padding: 6px; } }

main { width: 100%; display: flex; justify-content: center; }

/* Carte */
.carte {
  width: 100%; max-width: 440px; background: var(--fond-carte); border-radius: var(--rayon);
  padding: 34px 30px 30px; box-shadow: 0 24px 60px rgba(40, 10, 120, .35); text-align: center; position: relative;
}
.carte.large { max-width: 620px; }
.apparition { animation: apparaitre .6s cubic-bezier(.2, 1.4, .4, 1) both; }
@keyframes apparaitre { from { opacity: 0; transform: translateY(30px) scale(.96); } }

.mascotte { font-size: 54px; line-height: 1; margin-top: -70px; margin-bottom: 8px; animation: flotter 3s ease-in-out infinite; }
@keyframes flotter { 50% { transform: translateY(-8px) rotate(-4deg); } }

.carte h2 { margin: 6px 0 4px; font-size: 1.8rem; color: var(--violet-fonce); }
.intro { color: var(--gris); margin: 0 0 22px; }

.badge {
  display: inline-block; padding: 2px 12px; border-radius: 999px; font-weight: 800;
  background: linear-gradient(90deg, var(--violet), var(--rose)); color: #fff;
}
.lien-discret { color: var(--gris); font-size: .85rem; margin-left: 6px; }

/* Formulaire */
.formulaire { display: flex; flex-direction: column; gap: 8px; text-align: left; }
.formulaire label { font-weight: 700; margin-top: 8px; }

select, input[type="text"], input[type="date"] {
  width: 100%; font: inherit; font-size: 1.05rem; padding: 14px 16px; border-radius: 16px;
  border: 2px solid #e4e0ff; background: #f7f5ff; color: var(--encre); transition: border-color .2s, box-shadow .2s, transform .2s;
}
select:focus, input:focus { outline: none; border-color: var(--violet); box-shadow: 0 0 0 5px rgba(91, 61, 245, .15); transform: translateY(-1px); }

.select-ludique { position: relative; }
.select-ludique select { appearance: none; padding-right: 48px; cursor: pointer; font-weight: 700; }
.select-ludique::after {
  content: "▾"; position: absolute; right: 18px; top: 50%; transform: translateY(-50%);
  color: var(--violet); font-size: 1.3rem; pointer-events: none;
}

.champ { position: relative; }
.champ .icone { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); font-size: 1.25rem; }
.champ input { padding-left: 48px; }

.bouton {
  margin-top: 18px; border: 0; cursor: pointer; font-size: 1.2rem; font-weight: 800; color: #fff;
  padding: 14px 22px; border-radius: 18px; background: linear-gradient(90deg, var(--violet), var(--rose));
  box-shadow: 0 10px 22px rgba(91, 61, 245, .35); transition: transform .15s, box-shadow .15s;
}
.bouton:hover { transform: translateY(-2px) scale(1.02); box-shadow: 0 14px 28px rgba(91, 61, 245, .45); }
.bouton:active { transform: scale(.98); }
.bouton.secondaire { background: #f1eeff; color: var(--violet-fonce); box-shadow: none; }

.alerte { background: #fff0f0; color: #c92a2a; border-radius: 14px; padding: 12px 14px; font-weight: 700; margin: 0 0 10px; }
.secousse { animation: secouer .45s; }
@keyframes secouer { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

/* Résultat */
.minuteur {
  position: absolute; top: 14px; right: 16px; font-size: .78rem; color: var(--gris);
  background: #f4f2ff; padding: 4px 10px; border-radius: 999px;
}
.identite { display: flex; align-items: center; gap: 16px; text-align: left; margin-top: 14px; }
.avatar {
  width: 72px; height: 72px; flex: none; border-radius: 22px; display: grid; place-items: center;
  font: 800 1.7rem "Baloo 2", sans-serif; color: #fff; background: linear-gradient(135deg, var(--violet), var(--rose));
  transform: rotate(-6deg); box-shadow: 0 10px 20px rgba(91, 61, 245, .3);
}
.salut { margin: 0; color: var(--gris); }
.identite h2 { margin: 0; font-size: 1.6rem; line-height: 1.15; }

.infos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 22px 0; }
.infos div { background: #f7f5ff; border-radius: 16px; padding: 10px 8px; }
.infos dt { font-size: .75rem; color: var(--gris); text-transform: uppercase; letter-spacing: .04em; }
.infos dd { margin: 2px 0 0; font-weight: 800; }
@media (max-width: 520px) { .infos { gap: 6px; } .infos dt { font-size: .62rem; } .infos dd { font-size: .88rem; } }

.tuiles { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.tuile {
  border-radius: 22px; padding: 16px; color: #fff; display: flex; flex-direction: column; align-items: center;
  animation: apparaitre .6s .15s both;
}
.tuile.note { background: linear-gradient(135deg, #5b3df5, #7f6bff); }
.tuile.abs { background: linear-gradient(135deg, #12b886, #38d9a9); animation-delay: .25s; }
.tuile.abs.alerte-abs { background: linear-gradient(135deg, #f03e3e, #ff8787); }
.tuile-icone { font-size: 1.6rem; }
.tuile-titre { font-weight: 700; opacity: .9; }
.tuile-valeur { font-size: 2.6rem; font-weight: 800; line-height: 1.1; }
.tuile-valeur small { font-size: 1.1rem; opacity: .85; margin-left: 2px; }

.jauge-bloc { margin-top: 26px; padding: 18px 10px 6px; border-radius: 22px; background: #faf9ff; }
.jauge-bloc h3 { margin: 0; color: var(--violet-fonce); }
.jauge { width: 100%; max-width: 360px; display: block; margin: 6px auto 0; }
.arc { fill: none; stroke-width: 26; stroke-linecap: butt; opacity: .35; }
.arc.fond { stroke: #ece9ff; opacity: 1; stroke-width: 30; }
.arc.n1 { stroke: var(--n1); } .arc.n2 { stroke: var(--n2); } .arc.n3 { stroke: var(--n3); } .arc.n4 { stroke: var(--n4); }
.arc.courant { opacity: 1; filter: drop-shadow(0 3px 6px rgba(0, 0, 0, .2)); }
.aiguille { transform-origin: 150px 150px; transition: transform 1.6s cubic-bezier(.3, 1.5, .5, 1); }
.aiguille line { stroke: var(--encre); stroke-width: 7; stroke-linecap: round; }
.aiguille circle { fill: var(--encre); stroke: #fff; stroke-width: 4; }
.borne { fill: var(--gris); font-size: 13px; font-weight: 700; }

.pct { margin: -6px 0 0; font-size: 3rem; font-weight: 800; line-height: 1; }
.niveau { display: inline-block; margin: 8px 0 4px; padding: 4px 16px; border-radius: 999px; color: #fff; font-size: 1.25rem; font-weight: 800; }
.n1 .pct { color: var(--n1); } .n1 .niveau { background: var(--n1); }
.n2 .pct { color: var(--n2); } .n2 .niveau { background: var(--n2); }
.n3 .pct { color: var(--n3); } .n3 .niveau { background: var(--n3); }
.n4 .pct { color: #12b886; }   .n4 .niveau { background: var(--n4); }
.message { color: var(--gris); margin: 4px 0 10px; }

.legende { list-style: none; padding: 0; margin: 16px 0 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.legende li {
  border-radius: 14px; padding: 8px 4px; font-size: .85rem; display: flex; flex-direction: column; align-items: center;
  background: #f4f2ff; opacity: .6; border: 2px solid transparent; transition: transform .3s;
}
.legende li small { color: var(--gris); }
.legende li.courant { opacity: 1; transform: translateY(-4px) scale(1.05); background: #fff; }
.legende li.n1.courant { border-color: var(--n1); } .legende li.n2.courant { border-color: var(--n2); }
.legende li.n3.courant { border-color: var(--n3); } .legende li.n4.courant { border-color: var(--n4); }
@media (max-width: 520px) { .legende { grid-template-columns: 1fr 1fr; } }

.formule { font-size: .8rem; color: var(--gris); margin: 14px 0 0; }
.actions { margin-top: 6px; }
.actions .bouton { width: 100%; }

.pied { margin-top: 26px; color: rgba(255, 255, 255, .85); font-size: .85rem; text-align: center; }

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

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