/* Questionnaire forain — thème « fête foraine », pensé pour le téléphone (lisible le soir aussi). */
:root {
  --fond: #fff7ea;
  --carte: #ffffff;
  --encre: #2a1d14;
  --doux: #6b5a4c;
  --rouge: #c8102e;
  --rouge-fonce: #9b0c23;
  --jaune: #ffb703;
  --vert: #1f8a7e;
  --bordure: #ecdcc4;
  --option: #fffdf8;
  --choisie: #fff1d6;
  --ombre: 0 2px 10px rgba(80, 40, 10, .08);
  --rayon: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #1a1418;
    --carte: #261e24;
    --encre: #f6ece2;
    --doux: #c3b1a3;
    --rouge: #ff4d6a;
    --rouge-fonce: #e03653;
    --jaune: #ffc53d;
    --vert: #4fd1c0;
    --bordure: #3e3239;
    --option: #2d242b;
    --choisie: #4a2f22;
    --ombre: 0 2px 10px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  background: var(--fond);
  color: var(--encre);
  font: 18px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; width: 100%; max-width: 640px; margin: 0 auto; padding: 20px 16px calc(96px + env(safe-area-inset-bottom)); outline: none; }
h1 { font-size: 1.55rem; line-height: 1.25; margin: .2em 0 .5em; }
h2 { font-size: 1.15rem; margin: 0 0 .6em; }
button { font: inherit; color: inherit; }
.centre { text-align: center; }
.chargement { text-align: center; color: var(--doux); margin-top: 30vh; }

/* ---- En-tête : bandeau de chapiteau ---- */
#entete {
  position: sticky; top: 0; z-index: 10;
  background: var(--rouge);
  color: #fff;
  padding: calc(8px + env(safe-area-inset-top)) 12px 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .18);
}
#entete::after { /* festons du chapiteau */
  content: ""; position: absolute; left: 0; right: 0; bottom: -9px; height: 10px;
  background: radial-gradient(circle at 10px -2px, var(--rouge) 10px, transparent 11px) 0 0 / 20px 10px repeat-x;
}
.entete-ligne, .entete-ligne2 { display: flex; align-items: center; gap: 10px; max-width: 640px; margin: 0 auto; }
.entete-ligne2 { margin-top: 6px; }
.entete-titre { flex: 1; font-weight: 600; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entete-pct { font-weight: 800; font-size: 1.1rem; min-width: 3.2em; text-align: right; }
.entete-reste { flex: none; font-size: .82rem; font-weight: 700; min-width: 4.2em; text-align: right; }
#entete .barre { flex: 1; height: 10px; background: rgba(255, 255, 255, .3); }
.btn-icone {
  background: rgba(255, 255, 255, .18); border: 0; border-radius: 12px; color: inherit;
  width: 40px; height: 40px; font-size: 1.25rem; cursor: pointer; flex: none;
}

/* ---- Barre de progression rayée « sucre d'orge » ---- */
.barre { height: 12px; border-radius: 99px; background: var(--bordure); overflow: hidden; }
.barre.grande { height: 22px; margin: 6px 0 10px; }
.barre > span {
  display: block; height: 100%; width: 0; border-radius: 99px;
  background: repeating-linear-gradient(-45deg, var(--jaune) 0 10px, #ffd56b 10px 20px);
  transition: width .5s ease;
}
.grand-pct { font-size: 3rem; font-weight: 800; text-align: center; margin: 0; color: var(--rouge); }

/* ---- Accueil ---- */
.accueil { text-align: left; }
.accueil h1 { text-align: center; font-size: 1.8rem; }
.chapiteau { font-size: 4rem; text-align: center; margin-top: 10px; }
.accroche { font-size: 1.05rem; color: var(--doux); text-align: center; }
.carte {
  background: var(--carte); border: 1px solid var(--bordure); border-radius: var(--rayon);
  box-shadow: var(--ombre); padding: 18px; margin: 16px 0;
}
.carte-forte { border: 2px solid var(--jaune); }
.etapes, .puces { margin: 0; padding-left: 1.3em; }
.etapes li, .puces li { margin: .45em 0; }
.etiquette { display: block; font-weight: 700; margin: 10px 0 6px; }
.aide { color: var(--doux); font-size: .92rem; }
.erreur { color: var(--rouge); font-weight: 600; min-height: 1.2em; margin: 8px 0; }

/* ---- Champs ---- */
.champ {
  width: 100%; font: inherit; font-size: 1.15rem; color: var(--encre);
  background: var(--option); border: 2px solid var(--bordure); border-radius: 12px;
  padding: 14px; outline: none;
}
.champ:focus { border-color: var(--jaune); box-shadow: 0 0 0 3px rgba(255, 183, 3, .3); }
.champ-code { font-size: 1.8rem; letter-spacing: .5em; text-align: center; max-width: 220px; display: block; margin: 0 auto; }
.champ-long { min-height: 9em; resize: vertical; }
.champ-precision { margin: -2px 0 6px; }
.champ-remarque { font-size: 1rem; margin-top: 8px; }

/* ---- Boutons ---- */
.btn {
  border: 0; border-radius: 14px; padding: 14px 18px; font-weight: 700; font-size: 1.05rem;
  cursor: pointer; min-height: 52px; touch-action: manipulation;
}
.btn:disabled { opacity: .45; cursor: default; }
.btn-principal { background: var(--rouge); color: #fff; box-shadow: 0 3px 0 var(--rouge-fonce); }
.btn-principal:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--rouge-fonce); }
.btn-secondaire { background: var(--carte); color: var(--encre); border: 2px solid var(--bordure); }
.btn-large { width: 100%; margin-top: 14px; font-size: 1.15rem; }
.btn-lien, .btn.btn-lien {
  background: none; border: 0; color: var(--doux); text-decoration: underline; cursor: pointer;
  padding: 10px 0; font-weight: 500; font-size: .95rem; min-height: 0; display: inline; text-align: left;
}
.carte .btn.btn-lien { display: block; margin: 10px auto 0; }

/* ---- Pied fixe : Retour / Valider ---- */
#actions {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: var(--fond); border-top: 1px solid var(--bordure);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  display: flex; gap: 10px; justify-content: center;
}
#actions .btn { flex: 1; max-width: 300px; }
#actions .btn-principal { flex: 2; }

/* ---- Intro de section ---- */
.intro { text-align: center; padding-top: 10px; }
.intro-emoji { font-size: 4.2rem; line-height: 1; margin: 10px 0; }
.intro-partie { color: var(--rouge); font-weight: 800; text-transform: uppercase; letter-spacing: .06em; font-size: .85rem; margin: 0; }
.intro-texte { color: var(--doux); font-size: 1.05rem; }
.intro-duree { display: inline-block; background: var(--carte); border: 1px solid var(--bordure); border-radius: 99px; padding: 6px 14px; font-weight: 600; margin-top: 10px; }
.intro .options { text-align: left; }
.bravo {
  background: var(--vert); color: #fff; border-radius: 12px; padding: 10px 14px; font-weight: 700;
  animation: arrivee .5s ease;
}
.consigne { font-weight: 600; text-align: left; }

/* ---- Question ---- */
.groupe { color: var(--rouge); font-weight: 700; font-size: .9rem; margin: 0 0 6px; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.badge-num { background: var(--encre); color: var(--fond); border-radius: 8px; padding: 2px 9px; font-weight: 800; font-size: .9rem; }
.etoile { background: var(--jaune); color: #3a2600; border-radius: 8px; padding: 2px 9px; font-weight: 800; font-size: .85rem; white-space: nowrap; }
.badge-info { background: var(--choisie); color: var(--encre); border-radius: 8px; padding: 2px 9px; font-size: .85rem; font-weight: 600; }
.question-texte { font-size: 1.25rem; margin: 8px 0 12px; }
.zone-reponse { transition: opacity .2s; }
.zone-reponse.estompee { opacity: .4; }

.options { display: flex; flex-direction: column; gap: 8px; margin: 8px 0; }
.option {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  background: var(--option); border: 2px solid var(--bordure); border-radius: 14px;
  padding: 10px 12px; min-height: 50px; cursor: pointer; touch-action: manipulation;
  transition: border-color .15s, background .15s, transform .1s;
}
.option:active { transform: scale(.985); }
.option.choisie { border-color: var(--rouge); background: var(--choisie); }
.option.bloquee { opacity: .45; }
.option-texte { flex: 1; font-size: 1.05rem; }
.case {
  flex: none; width: 26px; height: 26px; border: 3px solid var(--doux); background: var(--carte);
  display: grid; place-items: center; transition: background .15s, border-color .15s;
}
.option.single .case { border-radius: 50%; }
.option.multi .case { border-radius: 8px; }
.option.choisie .case { background: var(--rouge); border-color: var(--rouge); }
.option.choisie .case::after { content: "✓"; color: #fff; font-weight: 900; font-size: 1.1rem; line-height: 1; }
.option.single.choisie .case::after { content: ""; width: 12px; height: 12px; border-radius: 50%; background: #fff; }
.compteur { font-weight: 700; color: var(--doux); text-align: right; margin: 0; }
.secoue { animation: secoue .35s; color: var(--rouge); }

.speciaux { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 4px; }
.puce-speciale, .puce-rappel {
  background: var(--carte); border: 2px dashed var(--bordure); border-radius: 99px;
  padding: 8px 14px; font-size: .92rem; cursor: pointer; color: var(--doux);
}
.puce-speciale[aria-pressed="true"] { border-style: solid; border-color: var(--rouge); color: var(--encre); background: var(--choisie); font-weight: 700; }
.rappels { display: flex; flex-wrap: wrap; gap: 8px; }
.puce-rappel { border-style: solid; color: var(--encre); }

.remarque { margin-top: 10px; color: var(--doux); }
.remarque summary { cursor: pointer; font-size: .95rem; padding: 6px 0; }

/* ---- Récapitulatif ---- */
.recap-section { margin: 26px 0 8px; font-size: 1.1rem; }
.recap-ligne {
  display: flex; flex-direction: column; gap: 2px; width: 100%; text-align: left; cursor: pointer;
  background: var(--carte); border: 1px solid var(--bordure); border-radius: 12px; padding: 10px 12px; margin: 6px 0;
}
.recap-num { font-weight: 800; font-size: .8rem; color: var(--rouge); }
.recap-q { font-size: .88rem; color: var(--doux); }
.recap-rep { font-weight: 600; white-space: pre-wrap; overflow-wrap: anywhere; }
.recap-rep.vide { color: var(--rouge); font-weight: 500; font-style: italic; }

/* ---- Sommaire ---- */
.sommaire { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, .45); display: flex; justify-content: flex-start; }
.sommaire-boite {
  background: var(--fond); width: min(92vw, 420px); height: 100%; overflow-y: auto;
  padding: calc(14px + env(safe-area-inset-top)) 14px calc(20px + env(safe-area-inset-bottom));
  animation: glisse .2s ease;
}
.sommaire-tete { display: flex; align-items: center; justify-content: space-between; }
.sommaire-tete .btn-icone { background: var(--carte); border: 1px solid var(--bordure); }
#sommaire-liste { list-style: none; margin: 8px 0; padding: 0; }
.sommaire-ligne {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; cursor: pointer;
  background: var(--carte); border: 1px solid var(--bordure); border-radius: 12px; padding: 10px 12px; margin: 5px 0; min-height: 50px;
}
.sommaire-ligne.ici { border: 2px solid var(--rouge); }
.sommaire-emoji { font-size: 1.3rem; }
.sommaire-nom { flex: 1; font-size: .95rem; }
.sommaire-etat { font-weight: 800; color: var(--vert); font-size: .9rem; }
.sommaire-pied { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.sommaire-pied .btn-lien { text-align: center; display: block; }

/* ---- Indicateur d'enregistrement ---- */
.sauvegarde {
  position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--encre); color: var(--fond); padding: 8px 14px; border-radius: 99px; font-size: .88rem;
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; z-index: 15; max-width: 92vw; text-align: center;
}
.sauvegarde.visible { opacity: .95; transform: translate(-50%, 0); }
.sauvegarde.hors-ligne { background: var(--rouge); color: #fff; }

/* ---- Confettis ---- */
.confettis { position: fixed; inset: 0; pointer-events: none; z-index: 30; overflow: hidden; }
.confettis i { position: absolute; top: -20px; width: 9px; height: 14px; border-radius: 2px; animation: tombe linear forwards; }

@keyframes tombe { to { top: 110vh; transform: rotate(720deg) translateX(40px); } }
@keyframes arrivee { from { transform: scale(.8); opacity: 0; } }
@keyframes glisse { from { transform: translateX(-30px); opacity: 0; } }
@keyframes secoue { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---- Champ avec unité (pavé numérique) ---- */
.champ-unite { display: flex; align-items: center; gap: 10px; }
.champ-unite .champ { max-width: 170px; font-size: 1.3rem; text-align: center; }
.champ-unite span { font-weight: 700; color: var(--doux); }

/* ---- Clavier ouvert : boutons sous le contenu, pas par-dessus le champ ---- */
body.clavier #actions { position: static; border-top: 0; padding: 12px 0 16px; max-width: 640px; width: calc(100% - 32px); margin: 0 auto; }
body.clavier main { padding-bottom: 8px; flex: none; }
body.clavier .sauvegarde { display: none; }

/* ---- Choix de la version ---- */
.carte-version {
  display: flex; flex-direction: column; gap: 4px; width: 100%; text-align: left; cursor: pointer;
  background: var(--carte); border: 2px solid var(--bordure); border-radius: var(--rayon); box-shadow: var(--ombre);
  padding: 16px 18px; margin: 14px 0; touch-action: manipulation;
}
.carte-version:active { transform: scale(.985); }
.carte-version.actuelle { border-color: var(--rouge); }
.carte-version-emoji { font-size: 2rem; line-height: 1; }
.carte-version-titre { font-size: 1.3rem; font-weight: 800; }
.carte-version-texte { color: var(--doux); }
.carte-version-duree { font-weight: 700; color: var(--rouge); }
.carte-version-actuelle { font-size: .85rem; font-weight: 700; color: var(--vert); }
