:root {
  --fond: #f6f7f9;
  --carte: #ffffff;
  --texte: #1b1f24;
  --discret: #5b6470;
  --bordure: #d8dde3;
  --accent: #1f4e79;
  --accent-texte: #ffffff;
  --accent-doux: #dce8f4;
  --tour2: #c9822b;
  --bonne: #1e7d4f;
  --bonne-doux: #dff2e8;
  --mauvaise: #a83232;
  --mauvaise-doux: #f8e3e3;
  --rayon: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fond: #14171b;
    --carte: #1d2127;
    --texte: #e8ebef;
    --discret: #9aa4b0;
    --bordure: #333a43;
    --accent: #5b9bd5;
    --accent-texte: #0d1117;
    --accent-doux: #22364a;
    --tour2: #e0a050;
    --bonne: #4fc28a;
    --bonne-doux: #183a2a;
    --mauvaise: #e57373;
    --mauvaise-doux: #3d2020;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --fond: #14171b; --carte: #1d2127; --texte: #e8ebef; --discret: #9aa4b0; --bordure: #333a43;
  --accent: #5b9bd5; --accent-texte: #0d1117; --accent-doux: #22364a; --tour2: #e0a050;
  --bonne: #4fc28a; --bonne-doux: #183a2a; --mauvaise: #e57373; --mauvaise-doux: #3d2020;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--fond);
  color: var(--texte);
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1, h2 { line-height: 1.25; margin: 0 0 .6em; }
button, input, select { font: inherit; color: inherit; }
button, .bouton {
  background: var(--carte);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
  padding: .55em 1em;
  cursor: pointer;
  text-align: left;
}
button:hover:not(:disabled), .bouton:hover { border-color: var(--accent); }
button:disabled { opacity: .45; cursor: default; }
button.principal { background: var(--accent); color: var(--accent-texte); border-color: var(--accent); text-align: center; }
input[type="text"], input:not([type]), select {
  background: var(--carte);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
  padding: .55em .8em;
}
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
code { font-family: ui-monospace, monospace; font-size: .92em; }

.entete {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--carte);
  border-bottom: 1px solid var(--bordure);
}
.marque { font-weight: 700; color: var(--accent); }
.session { margin-left: auto; font-family: ui-monospace, monospace; color: var(--discret); }
.connexion { width: 12px; height: 12px; border-radius: 50%; background: var(--mauvaise); flex: none; }
.connexion[data-etat="connexion"] { background: var(--tour2); }
.connexion[data-etat="connecte"] { background: var(--bonne); }
.aide { color: var(--discret); font-size: .9em; }
.erreur { color: var(--mauvaise); }
.carte { background: var(--carte); border: 1px solid var(--bordure); border-radius: var(--rayon); padding: 20px; }
.surtitre { color: var(--discret); font-size: .85em; text-transform: uppercase; letter-spacing: .04em; margin: 0 0 .4em; }
.explication { background: var(--accent-doux); border-radius: var(--rayon); padding: .8em 1em; }
.resume { font-weight: 600; }
.lettre {
  display: inline-grid; place-items: center; flex: none;
  width: 1.8em; height: 1.8em; border-radius: 50%;
  background: var(--accent-doux); color: var(--accent); font-weight: 700;
}

/* ---------- Résultats ---------- */
.barres { list-style: none; padding: 0; margin: 0 0 1em; display: grid; gap: .5em; }
.barres li {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: .7em;
  row-gap: .25em;
  align-items: center;
  padding: .5em .7em;
  border: 2px solid transparent;
  border-radius: var(--rayon);
  background: var(--fond);
}
.barres li.bonne { border-color: var(--bonne); background: var(--bonne-doux); }
.barres li.bonne .lettre { background: var(--bonne); color: var(--carte); }
.barres li.mauvaise { opacity: .7; }
.barre { grid-column: 2; display: flex; align-items: center; gap: .6em; }
.barre .plein { height: .9em; border-radius: 4px; background: var(--accent); min-width: 2px; transition: width .4s; }
.barre.tour2 .plein { background: var(--tour2); }
.barre .valeur { font-variant-numeric: tabular-nums; font-size: .85em; color: var(--discret); white-space: nowrap; }
.barre .plein { max-width: calc(100% - 4.5em); }
.mienne { color: var(--discret); font-size: .85em; }
.legende { display: flex; gap: 1.2em; font-size: .85em; color: var(--discret); margin: 0 0 .5em; }
.legende span::before { content: ""; display: inline-block; width: .9em; height: .9em; border-radius: 3px; margin-right: .4em; vertical-align: -.1em; background: var(--accent); }
.legende .tour2::before { background: var(--tour2); }
.sans-barres .barre { display: none; }

.echelle-resultats .colonnes { display: flex; align-items: flex-end; gap: 8px; height: 220px; }
.colonne { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; }
.colonne .plein { width: 100%; background: var(--accent); border-radius: 6px 6px 0 0; min-height: 2px; transition: height .4s; }
.colonne .graduation { font-weight: 700; }
.bornes { display: flex; justify-content: space-between; gap: 1em; color: var(--discret); font-size: .85em; margin-top: .4em; }

.numerique-resultats .valeurs { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: .5em; }
.numerique-resultats .valeurs li { background: var(--fond); border-radius: var(--rayon); padding: .3em .7em; }
.attendue { color: var(--bonne); }

.nuage { list-style: none; padding: 0; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .2em .7em; }
.nuage li { color: var(--accent); font-weight: 600; line-height: 1.1; }
.nuage li:nth-child(3n+2) { color: var(--tour2); }
.nuage li:nth-child(3n) { color: var(--discret); }
.nuage li.attendu { color: var(--bonne); text-decoration: underline; }

/* ---------- Participant ---------- */
.participant main { max-width: 640px; margin: 0 auto; padding: 16px; }
.rejoindre { display: grid; gap: .8em; margin-top: 10vh; }
.rejoindre input { font-size: 1.8em; text-align: center; letter-spacing: .12em; font-family: ui-monospace, monospace; text-transform: uppercase; }
.attente { text-align: center; padding: 2em 0; }
.enonce { font-size: 1.25em; }
.choix { list-style: none; padding: 0; margin: 0; display: grid; gap: .6em; }
.choix button, .choix .case {
  width: 100%; display: flex; align-items: center; gap: .7em;
  padding: .8em; border: 2px solid var(--bordure); border-radius: var(--rayon); background: var(--carte); cursor: pointer;
}
.choix button.choisi, .choix .case:has(input:checked) { border-color: var(--accent); background: var(--accent-doux); }
.choix .case input { width: 1.2em; height: 1.2em; accent-color: var(--accent); }
.choix .principal { margin-top: .4em; }
.echelle .crans { display: flex; gap: 8px; }
.echelle .crans button { flex: 1; text-align: center; font-size: 1.3em; font-weight: 700; padding: .6em 0; }
.echelle .crans button.choisi { background: var(--accent); color: var(--accent-texte); border-color: var(--accent); }
.saisie { display: flex; gap: 8px; }
.saisie input { flex: 1; min-width: 0; font-size: 1.2em; }
.verdict { font-size: 1.2em; font-weight: 700; padding: .5em .8em; border-radius: var(--rayon); }
.verdict.oui { color: var(--bonne); background: var(--bonne-doux); }
.verdict.non { color: var(--mauvaise); background: var(--mauvaise-doux); }

/* ---------- Présentateur ---------- */
.presentateur { height: 100vh; display: grid; grid-template-rows: auto 1fr auto; }
.titre-quiz { color: var(--discret); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.code-session {
  margin-left: auto; font-family: ui-monospace, monospace; font-weight: 700; font-size: 1.3em;
  letter-spacing: .08em; padding: .2em .7em; color: var(--accent);
}
.presents { font-variant-numeric: tabular-nums; }
.menu { position: relative; }
.menu summary { list-style: none; cursor: pointer; font-size: 1.3em; padding: 0 .3em; }
.menu summary::-webkit-details-marker { display: none; }
.menu-contenu {
  position: absolute; right: 0; top: 2.2em; z-index: 5; width: 320px;
  display: grid; gap: 8px; padding: 12px;
  background: var(--carte); border: 1px solid var(--bordure); border-radius: var(--rayon);
  box-shadow: 0 8px 24px rgb(0 0 0 / .15);
}
.disposition { display: grid; grid-template-columns: 300px 1fr; min-height: 0; }
.liste { border-right: 1px solid var(--bordure); overflow-y: auto; padding: 12px; background: var(--carte); }
.pages { display: flex; align-items: center; gap: 6px; margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--bordure); }
.pages button { padding: .3em .6em; text-align: center; }
.page-titre { flex: 1; display: grid; text-align: center; line-height: 1.2; }
.page-titre strong { color: var(--accent); }
.page-titre span { font-size: .75em; color: var(--discret); }
.liste ol { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.liste li button { width: 100%; display: flex; gap: .6em; align-items: flex-start; border-color: transparent; font-size: .88em; }
.liste li button.active { background: var(--accent-doux); border-color: var(--accent); }
.liste .texte { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pastille { margin-top: .45em; width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--bordure); }
.pastille[data-phase="vote"] { background: var(--tour2); }
.pastille[data-phase="ferme"] { background: var(--accent); }
.pastille[data-phase="revele"] { background: var(--bonne); }

.scene { overflow-y: auto; padding: 32px 48px; font-size: 1.45em; max-width: 1400px; width: 100%; margin: 0 auto; }
.scene .enonce { font-size: 1.6em; }
.scene .vide { text-align: center; margin-top: 15vh; color: var(--discret); }
.scene .aide.grand { font-size: 1em; }
.etiquette { margin-left: .8em; padding: .1em .6em; border-radius: 99px; background: var(--fond); text-transform: none; letter-spacing: 0; }
.etiquette[data-phase="vote"] { background: var(--tour2); color: #fff; }
.etiquette[data-phase="revele"] { background: var(--bonne); color: #fff; }
.consigne { font-size: 1.2em; font-weight: 700; color: var(--tour2); text-align: center; }

.commandes {
  display: flex; align-items: center; gap: 8px; padding: 10px 16px;
  background: var(--carte); border-top: 1px solid var(--bordure);
}
.commandes .compte { margin-left: auto; color: var(--discret); font-variant-numeric: tabular-nums; }
.commandes #vote { min-width: 11em; }

.rejoindre-plein {
  position: fixed; inset: 0; z-index: 10; display: grid; place-items: center;
  background: rgb(0 0 0 / .55);
}
.rejoindre-plein .carte { text-align: center; font-size: 1.6em; padding: 32px 48px; }
.rejoindre-plein p { margin: .3em 0; }
.qr svg { width: min(52vh, 80vw); height: auto; display: block; margin: .3em auto; border-radius: 8px; }
.adresse a { color: inherit; }
.adresse { font-family: ui-monospace, monospace; font-size: .8em; color: var(--discret); }
.code-grand { font-family: ui-monospace, monospace; font-size: 1.6em; letter-spacing: .1em; color: var(--accent); }

@media (max-width: 800px) {
  .disposition { grid-template-columns: 1fr; }
  .liste { display: none; }
  .scene { padding: 16px; font-size: 1.1em; }
  .commandes { flex-wrap: wrap; }
  .titre-quiz { display: none; }
}
