/* ===========================================================================
   TSAKI-QUIZZ — habillage
   Direction : la nuit sur l'autoroute. Un champ de couleur qui dérive
   lentement derrière un verre dépoli, et par-dessus, une typographie franche.
   La règle qui prime sur tout le reste : ça se lit d'un coup d'œil. Le champ
   habille, il ne parle jamais plus fort que la question.
   Cousin d'OTOHIME et d'ANAPNOÉ pour la matière, plus net pour la lecture.
   =========================================================================== */

:root {
  --encre: #ffffff;
  --encre-douce: rgba(255, 255, 255, 0.62);
  --encre-faible: rgba(255, 255, 255, 0.38);
  --fond: #0d0b14;
  --verre: rgba(255, 255, 255, 0.055);
  --verre-haut: rgba(255, 255, 255, 0.10);
  --lisere: rgba(255, 255, 255, 0.13);
  --lisere-vif: rgba(255, 255, 255, 0.30);
  --teinte: #8f9de8;
  --juste: #6fe3ab;
  --faux: #ff8b8b;
  --rayon: 20px;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", system-ui, sans-serif;
  --lisser: cubic-bezier(0.4, 0.14, 0.3, 1);
  --marge: max(22px, env(safe-area-inset-left));
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  background: var(--fond);
  color: var(--encre);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-user-select: none; user-select: none;
}

button, input, select { font-family: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }

/* ------------------------------------------------- LE CHAMP ET SON GRAIN */
.champ {
  position: fixed;
  inset: -12%;
  width: 124%;
  height: 124%;
  z-index: 0;
  pointer-events: none;
  filter: blur(26px) saturate(1.15);
  opacity: var(--champ-force, 0.62);
}
/* Le grain casse les bandes que produit un affichage sur huit bits, et donne
   à l'ensemble une matière de papier plutôt qu'un dégradé d'écran. */
.grain {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.30;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.42'/%3E%3C/svg%3E");
}
/* Un voile sombre sous le contenu : c'est lui qui garantit la lisibilité,
   quelle que soit la couleur du champ à cet instant. */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(126% 74% at 50% -4%,
      rgba(var(--voile-rvb, 0, 0, 0), var(--voile-haut, 0.16)) 0%,
      rgba(var(--voile-rvb, 0, 0, 0), calc((var(--voile-haut, 0.16) + var(--voile-bas, 0.78)) / 2)) 62%,
      rgba(var(--voile-rvb, 0, 0, 0), var(--voile-bas, 0.78)) 100%);
}

/* ------------------------------------------------------------------ ÉCRANS */
.ecran {
  position: relative;
  z-index: 2;
  display: none;
  flex-direction: column;
  min-height: 100svh;
  padding: 0 var(--marge) calc(env(safe-area-inset-bottom) + 26px);
}
.ecran.actif { display: flex; animation: paraitre 0.5s var(--lisser); }
@keyframes paraitre { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Surface de verre : la brique de toute l'interface. */
.verre {
  background: var(--verre);
  border: 1px solid var(--lisere);
  border-radius: var(--rayon);
  backdrop-filter: blur(22px) saturate(1.3);
  -webkit-backdrop-filter: blur(22px) saturate(1.3);
}

/* ------------------------------------------------------------------ ACCUEIL */
.entete { padding: calc(env(safe-area-inset-top) + 52px) 0 30px; text-align: center; }
.marque {
  font-size: clamp(21px, 6.6vw, 30px);
  font-weight: 300;
  letter-spacing: 0.26em;
  text-indent: 0.26em;
  line-height: 1.1;
  white-space: nowrap;
}
.marque .tiret { opacity: 0.42; font-weight: 200; }
.sous-marque {
  margin-top: 15px;
  font-size: 10.5px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.24em;
  color: var(--encre-faible);
}

.joueurs-reglage { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 28px; }
.champ-joueur { min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.champ-joueur > span {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.20em;
  color: var(--encre-faible);
  padding-left: 3px;
}
.champ-joueur input {
  width: 100%;
  background: var(--verre);
  border: 1px solid var(--lisere);
  border-radius: 14px;
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  padding: 15px 16px;
  font-size: 19px;
  font-weight: 500;
  min-height: 56px;
}
.champ-joueur input:focus { outline: none; border-color: var(--lisere-vif); background: var(--verre-haut); }

.modes { display: flex; flex-direction: column; gap: 11px; }
.mode {
  width: 100%;
  text-align: left;
  padding: 21px 22px;
  min-height: 88px;
  position: relative;
  overflow: hidden;
  transition: transform 0.18s var(--lisser), background 0.18s var(--lisser);
}
.mode::before {
  content: '';
  position: absolute;
  left: 0; top: 22px; bottom: 22px;
  width: 2px;
  border-radius: 0 2px 2px 0;
  background: var(--accent, var(--teinte));
  opacity: 0.9;
}
.mode:active { transform: scale(0.982); background: var(--verre-haut); }
.mode-titre {
  display: block;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.17em;
  margin-bottom: 7px;
}
.mode-detail { display: block; font-size: 14.5px; color: var(--encre-douce); line-height: 1.42; }

.reglages { margin-top: 28px; text-align: center; }
.lien-discret {
  color: var(--encre-faible);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.19em;
  padding: 15px 20px;
}
.lien-discret:active { color: var(--encre); }
.etat-chargement {
  margin-top: 10px;
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--encre-faible);
}
.etat-chargement.erreur { color: var(--faux); }

/* ----------------------------------------------------------------- RÉGLAGES */
.entete-page {
  display: flex; align-items: center; gap: 16px;
  padding: calc(env(safe-area-inset-top) + 26px) 0 22px;
}
.entete-page h2 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.19em; }
.retour { color: var(--encre-douce); font-size: 15px; padding: 12px 6px 12px 0; }

.bloc-reglage { padding: 20px; margin-bottom: 14px; }
.bloc-reglage h3 {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.21em;
  color: var(--encre-faible);
  font-weight: 600;
  margin-bottom: 8px;
}
.ligne-reglage {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--lisere);
  font-size: 16.5px;
  min-height: 54px;
}
.ligne-reglage:last-of-type { border-bottom: none; }
.ligne-reglage.colonne { flex-direction: column; align-items: stretch; gap: 12px; }
.ligne-reglage b { font-variant-numeric: tabular-nums; font-weight: 600; }
.ligne-reglage input[type="checkbox"] { width: 30px; height: 30px; accent-color: var(--teinte); flex: none; }
.ligne-reglage input[type="range"] { width: 100%; accent-color: var(--teinte); height: 36px; }
.ligne-reglage select {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--lisere);
  border-radius: 12px;
  padding: 13px;
  font-size: 16px;
  min-height: 50px;
}
.note { font-size: 14px; color: var(--encre-douce); line-height: 1.5; margin-bottom: 16px; }

/* ----------------------------------------------------------------- BOUTONS */
.bouton-primaire {
  display: block;
  width: 100%;
  background: rgba(255, 255, 255, 0.94);
  color: #12101a;
  border-radius: 16px;
  padding: 19px;
  font-size: 12.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.19em;
  min-height: 62px;
  transition: transform 0.14s var(--lisser), opacity 0.14s var(--lisser);
}
.bouton-primaire.grand { min-height: 78px; font-size: 13.5px; border-radius: 20px; }
.bouton-primaire:active { transform: scale(0.982); opacity: 0.86; }
.bouton-primaire[disabled] { opacity: 0.45; }

.bouton-secondaire {
  background: var(--verre);
  border: 1px solid var(--lisere);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border-radius: 14px;
  padding: 15px 16px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--encre-douce);
  min-height: 54px;
}
.bouton-secondaire:active { background: var(--verre-haut); color: var(--encre); }
.bouton-secondaire.danger { color: var(--faux); }

/* --------------------------------------------------------------------- JEU */
.bandeau-score {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: calc(env(safe-area-inset-top) + 46px) 0 14px;
  position: relative;
}
.quitter {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 4px); right: -12px;
  font-size: 26px; font-weight: 200; line-height: 1;
  color: var(--encre-faible);
  padding: 10px 16px;
  z-index: 3;
}
.score-joueur {
  min-width: 0;
  padding: 13px 15px;
  display: flex; flex-direction: column; gap: 3px;
  opacity: 0.44;
  transition: opacity 0.3s var(--lisser), border-color 0.3s var(--lisser);
}
.score-joueur.actif { opacity: 1; border-color: var(--lisere-vif); }
.sj-nom {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.17em;
  color: var(--encre-douce);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sj-pts { font-size: 32px; font-weight: 300; line-height: 1.05; font-variant-numeric: tabular-nums; }
.sj-parts { display: flex; gap: 5px; margin-top: 4px; min-height: 10px; }
.sj-parts i { width: 9px; height: 9px; border-radius: 50%; border: 1px solid; display: block; }

.zone-jeu { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 20px 0 26px; }

.tour-de { font-size: 11px; text-transform: uppercase; letter-spacing: 0.19em; color: var(--encre-faible); margin-bottom: 9px; }
.categorie {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.24em;
  color: var(--teinte);
  margin-bottom: 24px;
}
.question {
  font-size: clamp(25px, 6.8vw, 34px);
  font-weight: 400;
  line-height: 1.26;
  letter-spacing: -0.012em;
  margin-bottom: 24px;
  text-wrap: balance;
}

.chrono { height: 2px; background: var(--lisere); border-radius: 2px; overflow: hidden; margin-bottom: 22px; }
#chrono-jauge { height: 100%; background: var(--encre); width: 100%; opacity: 0.85; }

/* Écoute */
.zone-ecoute { display: flex; flex-direction: column; align-items: center; gap: 20px; padding: 14px 0 22px; }
.onde { display: flex; align-items: center; gap: 7px; height: 42px; }
.onde i {
  display: block; width: 4px; height: 42px; border-radius: 4px;
  background: var(--encre); opacity: 0.9;
  animation: onde 1.15s var(--lisser) infinite;
}
.onde i:nth-child(1) { animation-delay: 0s; }
.onde i:nth-child(2) { animation-delay: 0.13s; }
.onde i:nth-child(3) { animation-delay: 0.26s; }
.onde i:nth-child(4) { animation-delay: 0.39s; }
.onde i:nth-child(5) { animation-delay: 0.52s; }
@keyframes onde { 0%, 100% { transform: scaleY(0.16); opacity: 0.45; } 50% { transform: scaleY(1); opacity: 1; } }
.transcription { font-size: 19px; color: var(--encre-douce); text-align: center; min-height: 27px; font-weight: 300; }

.lecteur-audio { padding: 4px 0 20px; }

/* Choix tactiles : quatre cibles larges, visées sans regarder. */
.choix { display: flex; flex-direction: column; gap: 10px; }
.choix-bouton {
  width: 100%;
  text-align: left;
  background: var(--verre);
  border: 1px solid var(--lisere);
  backdrop-filter: blur(22px) saturate(1.3);
  -webkit-backdrop-filter: blur(22px) saturate(1.3);
  border-radius: 16px;
  padding: 19px 20px;
  font-size: 19px;
  font-weight: 500;
  min-height: 68px;
  line-height: 1.3;
  transition: background 0.14s var(--lisser), border-color 0.14s var(--lisser), transform 0.14s var(--lisser);
}
.choix-bouton:active { transform: scale(0.985); background: var(--verre-haut); }
.choix-bouton.juste { border-color: var(--juste); background: rgba(111, 227, 171, 0.17); }
.choix-bouton.faux { border-color: var(--faux); background: rgba(255, 139, 139, 0.15); }
.choix-bouton[disabled] { opacity: 0.42; }
.choix-bouton.juste[disabled], .choix-bouton.faux[disabled] { opacity: 1; }

/* Verdict */
.verdict { padding: 4px 0 0; animation: paraitre 0.4s var(--lisser); }
.verdict-titre { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.24em; margin-bottom: 12px; }
.verdict-titre.ok { color: var(--juste); }
.verdict-titre.ko { color: var(--faux); }
.verdict-reponse { font-size: 27px; font-weight: 400; line-height: 1.22; margin-bottom: 13px; }
.verdict-anecdote {
  font-size: 16.5px; font-weight: 300;
  color: var(--encre-douce); line-height: 1.5;
  padding-left: 14px; border-left: 1px solid var(--lisere);
}
.verdict-anecdote:empty { display: none; }

/* Actions */
.actions { display: flex; flex-direction: column; gap: 9px; }
.actions-secondaires { display: flex; gap: 8px; }
.actions-secondaires .bouton-secondaire { flex: 1; min-width: 0; padding: 14px 4px; font-size: 10px; letter-spacing: 0.11em; }

/* --------------------------------------------------------------------- FIN */
#ecran-fin { justify-content: center; align-items: center; text-align: center; gap: 14px; }
.titre-fin { font-size: clamp(30px, 9vw, 42px); font-weight: 300; letter-spacing: 0.02em; line-height: 1.1; }
.detail-fin { font-size: 18px; color: var(--encre-douce); margin-bottom: 22px; max-width: 30ch; }
#ecran-fin .bouton-primaire, #ecran-fin .bouton-secondaire { max-width: 420px; }

/* ------------------------------------------------------------ HORS RÉSEAU */
.bandeau-reseau {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(env(safe-area-inset-bottom) + 10px);
  margin: 0 auto;
  width: fit-content;
  z-index: 50;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid var(--lisere);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border-radius: 999px;
  padding: 10px 20px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--encre-douce);
}

/* --------------------------------------------------------- TÉLÉCHARGEMENT */
.barre-dl { height: 2px; background: var(--lisere); border-radius: 2px; overflow: hidden; margin: 14px 0 10px; }
#barre-dl-jauge { height: 100%; width: 0; background: var(--encre); transition: width 0.25s var(--lisser); }

/* ------------------------------------------------------------- MOUVEMENT */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
/* Un écran très petit : on rend la question au texte, on retire le superflu. */
@media (max-height: 700px) {
  .entete { padding-top: calc(env(safe-area-inset-top) + 32px); padding-bottom: 22px; }
  .zone-jeu { padding: 12px 0 18px; }
  .question { margin-bottom: 18px; }
}

/* ===========================================================================
   PALETTES D'ESSAI
   Quatre directions, à comparer côte à côte. On bascule avec l'attribut
   data-theme sur la balise racine ; sans attribut, c'est « graphite ».
   Chaque palette redéfinit le fond, l'encre, le verre — et la vivacité du
   champ de couleur, qui est réglée depuis app.js.
   =========================================================================== */

/* ENCRE ET CRÈME — la charte LUXE ÆTERNAI. Le champ ne fait qu'affleurer. */
:root[data-theme="encre"] {
  --encre: #fafaf9;
  --encre-douce: rgba(250, 250, 249, 0.58);
  --encre-faible: rgba(250, 250, 249, 0.34);
  --fond: #0a0a0a;
  --verre: rgba(255, 255, 255, 0.045);
  --verre-haut: rgba(255, 255, 255, 0.09);
  --lisere: rgba(255, 255, 255, 0.11);
  --lisere-vif: rgba(255, 255, 255, 0.28);
  --voile-haut: 0.34;
  --voile-bas: 0.86;
  --champ-force: 0.34;
}

/* AMBRE NOCTURNE — l'habitacle de nuit, la lumière du tableau de bord. */
:root[data-theme="ambre"] {
  --encre: #fdf6ec;
  --encre-douce: rgba(253, 246, 236, 0.62);
  --encre-faible: rgba(253, 246, 236, 0.36);
  --fond: #17110a;
  --verre: rgba(255, 226, 184, 0.065);
  --verre-haut: rgba(255, 226, 184, 0.12);
  --lisere: rgba(255, 226, 184, 0.15);
  --lisere-vif: rgba(255, 226, 184, 0.34);
  --voile-haut: 0.04;
  --voile-bas: 0.62;
  --champ-force: 0.94;
}

/* VERT ANGLAIS — le cuir d'une anglaise ancienne. Feutré. */
:root[data-theme="vert"] {
  --encre: #f2f8f4;
  --encre-douce: rgba(242, 248, 244, 0.60);
  --encre-faible: rgba(242, 248, 244, 0.35);
  --fond: #0b1310;
  --verre: rgba(198, 240, 214, 0.055);
  --verre-haut: rgba(198, 240, 214, 0.11);
  --lisere: rgba(198, 240, 214, 0.14);
  --lisere-vif: rgba(198, 240, 214, 0.32);
  --voile-haut: 0.05;
  --voile-bas: 0.64;
  --champ-force: 0.92;
}

/* GRAPHITE — neutre absolu. La couleur ne vient QUE de la catégorie. */
:root[data-theme="graphite"] {
  --encre: #ffffff;
  --encre-douce: rgba(255, 255, 255, 0.60);
  --encre-faible: rgba(255, 255, 255, 0.36);
  --fond: #131316;
  --verre: rgba(255, 255, 255, 0.05);
  --verre-haut: rgba(255, 255, 255, 0.10);
  --lisere: rgba(255, 255, 255, 0.12);
  --lisere-vif: rgba(255, 255, 255, 0.30);
  --voile-haut: 0.22;
  --voile-bas: 0.80;
  --champ-force: 0.52;
}

/* -------------------------------------------------------- LA TABLE DE JEU */
.liste-joueurs { display: flex; flex-direction: column; gap: 9px; margin-bottom: 10px; }
.ligne-joueur {
  display: grid;
  grid-template-columns: 1fr 76px;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 6px;
}
.ligne-joueur:has(.retirer-joueur) { grid-template-columns: 1fr 76px 40px; }
.ligne-joueur input {
  background: none; border: none; outline: none;
  padding: 13px 12px;
  font-size: 18px; font-weight: 500;
  min-height: 50px; min-width: 0; width: 100%;
}
.entree-age {
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: var(--encre-douce);
  border-left: 1px solid var(--lisere) !important;
  border-radius: 0;
  -moz-appearance: textfield;
}
.entree-age::-webkit-outer-spin-button, .entree-age::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.entree-nom::placeholder, .entree-age::placeholder { color: var(--encre-faible); font-weight: 400; }
.retirer-joueur {
  font-size: 22px; font-weight: 200; line-height: 1;
  color: var(--encre-faible);
  min-height: 44px; min-width: 40px;
}
.retirer-joueur:active { color: var(--faux); }

.ajouter-joueur {
  width: 100%;
  padding: 14px;
  margin-bottom: 24px;
  font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.18em;
  color: var(--encre-faible);
  border: 1px dashed var(--lisere);
  border-radius: 14px;
  min-height: 50px;
}
.ajouter-joueur:active { color: var(--encre); border-color: var(--lisere-vif); }

/* --------------------------------------------------------------- LE NIVEAU */
.reglage-difficulte { margin-bottom: 26px; }
.reglage-difficulte .etiquette {
  display: block;
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.20em;
  color: var(--encre-faible);
  margin-bottom: 9px; padding-left: 3px;
}
.segments {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  background: var(--verre);
  border: 1px solid var(--lisere);
  border-radius: 14px;
  padding: 4px;
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
}
.segment {
  padding: 12px 2px;
  border-radius: 10px;
  font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.10em;
  color: var(--encre-faible);
  min-height: 46px;
  transition: background 0.16s var(--lisser), color 0.16s var(--lisser);
}
.segment.actif { background: rgba(255, 255, 255, 0.92); color: #12101a; }

/* Un mode indisponible se voit, et dit pourquoi. */
.mode.indisponible { opacity: 0.42; }
.mode.indisponible::before { opacity: 0.3; }

/* Quatre joueurs et plus : les cartes se serrent, le score reste lisible. */
.bandeau-score.serre .score-joueur { padding: 10px 11px; }
.bandeau-score.serre .sj-pts { font-size: 24px; }
.bandeau-score.serre .sj-nom { font-size: 9px; letter-spacing: 0.12em; }
.bandeau-score.serre .sj-parts i { width: 6px; height: 6px; }

.segments-large { grid-template-columns: repeat(4, 1fr); }

/* BLEU DE NUIT — l'heure bleue, juste après le coucher. Froid et profond. */
:root[data-theme="nuit"] {
  --encre: #eef2fb;
  --encre-douce: rgba(238, 242, 251, 0.62);
  --encre-faible: rgba(238, 242, 251, 0.37);
  --fond: #070b18;
  --verre: rgba(190, 212, 255, 0.06);
  --verre-haut: rgba(190, 212, 255, 0.12);
  --lisere: rgba(190, 212, 255, 0.15);
  --lisere-vif: rgba(190, 212, 255, 0.34);
  --voile-haut: 0.04; --voile-bas: 0.62; --champ-force: 0.94;
}

/* LIE DE VIN — bordeaux sombre, lumière rosée. Chaud, feutré, un peu théâtral. */
:root[data-theme="bordeaux"] {
  --encre: #fbeef1;
  --encre-douce: rgba(251, 238, 241, 0.62);
  --encre-faible: rgba(251, 238, 241, 0.37);
  --fond: #170a0e;
  --verre: rgba(255, 198, 212, 0.06);
  --verre-haut: rgba(255, 198, 212, 0.12);
  --lisere: rgba(255, 198, 212, 0.15);
  --lisere-vif: rgba(255, 198, 212, 0.34);
  --voile-haut: 0.05; --voile-bas: 0.64; --champ-force: 0.92;
}

/* ARDOISE ET CUIVRE — un fond froid, une lumière chaude. Le contraste des deux. */
:root[data-theme="cuivre"] {
  --encre: #f6f2ee;
  --encre-douce: rgba(246, 242, 238, 0.60);
  --encre-faible: rgba(246, 242, 238, 0.36);
  --fond: #101216;
  --verre: rgba(232, 168, 120, 0.065);
  --verre-haut: rgba(232, 168, 120, 0.13);
  --lisere: rgba(232, 168, 120, 0.17);
  --lisere-vif: rgba(232, 168, 120, 0.38);
  --voile-haut: 0.10; --voile-bas: 0.70; --champ-force: 0.78;
}

/* PAPIER — la palette de jour. Plein soleil sur l'autoroute, l'écran reste
   lisible. Le voile passe au blanc, tout le reste s'inverse. */
:root[data-theme="papier"] {
  --encre: #14120f;
  --encre-douce: rgba(20, 18, 15, 0.66);
  --encre-faible: rgba(20, 18, 15, 0.44);
  --fond: #f6f3ed;
  --verre: rgba(255, 255, 255, 0.52);
  --verre-haut: rgba(255, 255, 255, 0.76);
  --lisere: rgba(20, 18, 15, 0.13);
  --lisere-vif: rgba(20, 18, 15, 0.32);
  --voile-rvb: 250, 247, 241;
  --voile-haut: 0.30; --voile-bas: 0.80; --champ-force: 0.72;
}
:root[data-theme="papier"] .grain { opacity: 0.16; mix-blend-mode: multiply; }
:root[data-theme="papier"] .bouton-primaire { background: #14120f; color: #f6f3ed; }
:root[data-theme="papier"] .segment.actif { background: #14120f; color: #f6f3ed; }
:root[data-theme="papier"] #chrono-jauge { background: #14120f; }
:root[data-theme="papier"] .onde i { background: #14120f; }
:root[data-theme="papier"] .bandeau-reseau { background: rgba(255, 255, 255, 0.8); }
:root[data-theme="papier"] .juste { color: #1c7a4f; }

.segments-palettes { grid-template-columns: repeat(4, 1fr); }

/* ===========================================================================
   LA GRILLE DE COULEURS
   On voit la couleur avant de la choisir. Une liste de mots ne le permet pas.
   =========================================================================== */
.palettes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.pastille {
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  padding: 8px 2px 10px;
  border-radius: 14px;
  border: 1px solid transparent;
  min-height: 78px;
  transition: border-color 0.16s var(--lisser), background 0.16s var(--lisser);
}
.pastille .rond {
  width: 38px; height: 38px; border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
  transition: transform 0.16s var(--lisser);
}
.pastille .etiq {
  font-size: 8.5px; text-transform: uppercase; letter-spacing: 0.09em;
  color: var(--encre-faible); text-align: center; line-height: 1.2;
}
.pastille.actif { border-color: var(--lisere-vif); background: var(--verre); }
.pastille.actif .rond { transform: scale(1.1); box-shadow: inset 0 0 0 1px rgba(255,255,255,.3), 0 0 0 2px var(--lisere-vif); }
.pastille.actif .etiq { color: var(--encre); }
.pastille:active .rond { transform: scale(0.94); }

/* ===========================================================================
   MODE NUIT
   Un voile chaud par-dessus TOUT, boutons blancs compris : c'est le seul moyen
   d'éteindre vraiment l'écran dans un habitacle sombre. Baisser les seules
   couleurs de fond ne suffit pas — c'est le blanc des boutons qui éblouit.
   =========================================================================== */
.voile-nuit {
  position: fixed; inset: 0; z-index: 99;
  pointer-events: none;
  opacity: 0;
  background: #1a0e04;
  mix-blend-mode: multiply;
  transition: opacity 0.8s var(--lisser);
}
:root[data-nuit="1"] .voile-nuit { opacity: 0.52; }
/* Le champ de couleur, lui, se calme aussi : sinon il ressort à travers. */
:root[data-nuit="1"] .champ { opacity: calc(var(--champ-force, 0.62) * 0.55); }
:root[data-nuit="1"] .grain { opacity: 0.14; }

.oublier {
  font-size: inherit; letter-spacing: inherit; text-transform: inherit;
  color: var(--encre-douce);
  text-decoration: underline; text-underline-offset: 3px;
  padding: 4px 2px;
}

/* ===========================================================================
   ESSAI DE L'ÉCOUTE
   À faire dans la voiture avant de partir : c'est le seul moyen de savoir si
   la reconnaissance tient le bruit de roulement.
   =========================================================================== */
.essai-consigne { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.2em; color: var(--encre-faible); margin-bottom: 10px; }
.essai-cible { font-size: 27px; font-weight: 400; line-height: 1.25; margin-bottom: 20px; }
.niveau-micro { height: 4px; background: var(--lisere); border-radius: 3px; overflow: hidden; margin-bottom: 16px; }
#niveau-micro-jauge { height: 100%; width: 0; background: var(--encre); transition: width 0.08s linear; }
.essai-entendu { font-size: 19px; font-weight: 300; color: var(--encre-douce); min-height: 30px; line-height: 1.35; }
.essai-verdict { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.2em; margin-top: 12px; min-height: 16px; }
.essai-verdict.ok { color: var(--juste); }
.essai-verdict.ko { color: var(--faux); }
.essai-resultats { padding: 16px 18px; margin-bottom: 16px; }
.essai-ligne { display: flex; gap: 10px; align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--lisere); font-size: 14.5px; }
.essai-ligne:last-child { border-bottom: none; }
.essai-ligne .marque { font-size: 11px; font-weight: 700; letter-spacing: 0.12em; flex: none; width: 52px; }
.essai-ligne .marque.ok { color: var(--juste); }
.essai-ligne .marque.ko { color: var(--faux); }
.essai-ligne .dit { color: var(--encre-douce); }
.essai-bilan { font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--encre-faible); padding-top: 12px; }

/* Le libellé de durée, à côté du titre du réglage. */
.reglage-difficulte .etiquette b {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0.02em;
  color: var(--encre-faible);
  opacity: 0.85;
}
