/*
 * Cryptogrammes — pages de jeu (solo, défi du jour, multijoueur).
 *
 * Charte du réseau : aplats et filets (--surface-*, --line), pas de dégradé de
 * surface, pas de backdrop-filter, pas d'ombre colorée, aucune animation en
 * boucle sur l'interface. Les animations passent par transform et opacity.
 */

:root {
  --cg-panel: var(--surface-1, #16191f);
  --cg-panel-2: var(--surface-2, #1c2027);
  --cg-bordure: var(--line, #2a2f37);
  --cg-bordure-forte: var(--line-forte, #39404a);
  --cg-texte: #f1f5f9;
  --cg-doux: var(--texte-doux, #98a1ad);
  --cg-bleu: #0ea5e9;
  --cg-bleu-clair: #bae6fd;
  --cg-ambre: #f59e0b;
  --cg-papier: #f6f1e4;
  --cg-encre: #13263a;
  --cg-gris-encre: #6b7a8c;
  --cg-rouge: #f87171;
  --cg-vert: #34d399;
}

body {
  margin: 0;
  font-family: 'Inter', sans-serif;
  color: var(--cg-texte);
}

/* 800 px bordures comprises : les blocs latéraux sont centrés dans la gouttière
   que laisse un conteneur de cette largeur. Le multijoueur, qui ne les inclut
   pas, s'élargit pour poser son classement à côté de la phrase. */
#app {
  max-width: 800px;
  box-sizing: border-box;
  margin: 0 auto;
  padding: 28px 24px;
  color: var(--cg-texte);
}
body.page-arene #app { max-width: 1100px; }

.cache { display: none !important; }

.visuellement-cache {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Blocs latéraux fixes : visibles hors partie, masqués pendant, de retour à la fin. */
body.cg-en-jeu .bandeau-infos-wrap,
body.cg-en-jeu .bloc-jeux-une-wrap { display: none !important; }

/* ================= ÉCRAN DE PRÉPARATION ================= */

.setup-tete {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 0 6px;
}

#setup h1,
#vue-lobby h1 {
  font-size: clamp(1.45rem, 4vw, 2rem);
  margin: 0;
  color: var(--cg-texte);
}

.setup-intro { color: var(--cg-doux); margin: 0 0 22px; line-height: 1.6; }

.setup-aide { border-top: 1px solid var(--cg-bordure); padding-top: 20px; margin-top: 18px; }
.setup-aide h2 { font-size: 1rem; color: var(--cg-bleu-clair); margin: 0 0 12px; }
.setup-aide ul { margin: 0; padding-left: 20px; color: var(--cg-doux); line-height: 1.7; }
.setup-aide li { margin-bottom: 8px; }
.setup-aide strong, .setup-aide em { color: var(--cg-texte); }
.setup-aide a, .setup-intro a { color: var(--cg-bleu-clair); }
.apprendre-texte p { color: var(--cg-doux); line-height: 1.7; }
.setup-aide-texte { color: var(--cg-doux); font-size: 0.88rem; line-height: 1.6; margin: 8px 0 0; }

/* Le choix de la difficulté : trois cartes, une case radio chacune. */
.choix-difficulte {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 18px;
  padding: 0;
  border: 0;
}
.carte-difficulte {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 14px 12px;
  border: 1px solid var(--cg-bordure);
  border-radius: 12px;
  background: var(--cg-panel);
  cursor: pointer;
}
.carte-difficulte input { position: absolute; opacity: 0; pointer-events: none; }
.carte-difficulte:hover { border-color: var(--cg-bordure-forte); }
.carte-difficulte:has(input:checked) { border-color: var(--cg-ambre); box-shadow: inset 0 0 0 1px var(--cg-ambre); }
.carte-difficulte:has(input:focus-visible) { outline: 2px solid var(--cg-bleu); outline-offset: 2px; }
.carte-nom { font-weight: 800; font-size: 1.05rem; color: var(--cg-texte); }
.carte-desc { font-size: 0.86rem; line-height: 1.5; color: var(--cg-doux); }
.carte-points { margin-top: auto; font-size: 0.76rem; font-weight: 700; color: var(--cg-ambre); }

.defi-carte,
.etat-defi {
  background: var(--cg-panel);
  border: 1px solid var(--cg-bordure);
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 20px;
}
.defi-carte h2 { margin: 0 0 10px; font-size: 1.05rem; color: var(--cg-bleu-clair); }
.defi-carte p,
.etat-defi p { margin: 0 0 8px; color: var(--cg-doux); line-height: 1.6; font-size: 0.92rem; }
.defi-carte p:last-child,
.etat-defi p:last-child { margin-bottom: 0; }
.etat-defi strong { color: var(--cg-texte); }
.etat-defi .etat-defi-titre { font-size: 1.05rem; font-weight: 700; color: var(--cg-bleu-clair); }
.etat-defi .etat-defi-serie { color: var(--cg-ambre); font-weight: 600; }
.defi-theme { color: var(--cg-doux); margin: 0 0 16px; font-size: 0.95rem; }
.defi-theme strong { color: var(--cg-ambre); }

.message-partie {
  display: none;
  margin: 0 0 16px;
  padding: 12px 16px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--cg-rouge) 12%, var(--cg-panel));
  border: 1px solid color-mix(in srgb, var(--cg-rouge) 38%, var(--cg-bordure));
  color: #fecaca;
  font-size: 0.92rem;
}
.message-partie.visible { display: block; }

.setup-actions { text-align: center; }

.parcours-bilan { margin: 0 0 14px; color: var(--cg-doux); font-size: 0.92rem; text-align: center; }
.parcours-bilan strong { color: var(--cg-texte); }
.fiche-lien { color: var(--cg-bleu-clair); }

.lien-classement-accueil {
  display: block;
  margin: 0 0 22px;
  text-align: center;
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--cg-bleu-clair);
  text-decoration: none;
}
.lien-classement-accueil:hover { text-decoration: underline; }

/* ================= BOUTONS ================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: #0369a1;
  color: #fff;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, transform 0.12s;
}
a.btn, a.btn:visited { color: #fff; }
.btn:hover { background: #075985; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-outline { background: transparent; border-color: var(--cg-bordure-forte); color: var(--cg-texte); }
a.btn-outline, a.btn-outline:visited { color: var(--cg-texte); }
.btn-outline:hover { background: color-mix(in srgb, #fff 6%, transparent); border-color: var(--cg-bleu); }

.btn-lancer {
  display: block;
  width: 100%;
  max-width: 340px;
  margin: 4px auto 18px;
  font-size: 1.08rem;
  padding: 15px 24px;
}

/* 44 px de haut : la taille d'un doigt, recommandée pour tout ce qui se touche. */
.btn-petit { padding: 10px 16px; font-size: 0.92rem; min-height: 44px; }

.btn-discret {
  background: transparent;
  border: 1px solid var(--cg-bordure);
  border-radius: 8px;
  color: var(--cg-doux);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 7px 11px;
  min-height: 40px;
  white-space: nowrap;
  cursor: pointer;
}
.btn-discret:hover { color: var(--cg-bleu-clair); border-color: var(--cg-bleu); }
.btn-gros[aria-pressed="true"] { border-color: var(--cg-ambre); color: var(--cg-ambre); }

.setup-boutons { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }

.lien-bouton {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--cg-bleu-clair);
  text-decoration: underline;
  cursor: pointer;
}
.lien-discret { color: var(--cg-doux); font-size: 0.86rem; }

.actions-jeu {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 16px;
}

/* Second clic demandé avant de clore la partie. */
.btn.a-confirmer { background: color-mix(in srgb, var(--cg-rouge) 26%, transparent); border-color: var(--cg-rouge); color: #fff; }

/* ================= ZONE DE JEU ================= */

#jeu {
  position: relative;
  /* La barre de compte est fixée en haut à droite : quand la page défile jusqu'au
     jeu, le tableau de bord doit rester sous elle. */
  scroll-margin-top: 84px;
  border-radius: 18px;
  padding: 18px 18px 20px;
  background-color: color-mix(in srgb, var(--cg-bleu) 7%, var(--surface-0, #0e1014));
  border: 1px solid color-mix(in srgb, var(--cg-bleu) 30%, var(--cg-bordure));
}

.seance-titre { margin: 0 0 12px; text-align: center; font-size: 0.95rem; font-weight: 700; color: var(--cg-bleu-clair); }

.jeu-hud { display: flex; gap: 10px; margin-bottom: 8px; }
.hud-bloc {
  flex: 1 1 0;
  background: color-mix(in srgb, #000 28%, transparent);
  border: 1px solid color-mix(in srgb, #fff 10%, transparent);
  border-radius: 12px;
  padding: 8px;
  text-align: center;
}
.hud-valeur {
  display: block;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--cg-texte);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.hud-label {
  display: block;
  font-size: 0.64rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--cg-doux);
  margin-top: 3px;
}
.hud-principal .hud-valeur { color: var(--cg-ambre); font-size: 1.7rem; }
#jeu.derniere-ligne-droite #hud-chrono { color: var(--cg-rouge); }

.hud-objectif {
  margin: 0 0 10px;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--cg-doux);
  min-height: 1.2em;
}

/* La phrase, sur une feuille claire : chaque mot reste d'un seul tenant, les
   lignes se coupent entre les mots. Les cases se mesurent en em : la taille de
   police de .crypto-texte règle tout. */
.crypto-cadre {
  position: relative;
  background: var(--cg-papier);
  color: var(--cg-encre);
  border-radius: 14px;
  padding: 18px 14px 14px;
}
.crypto-texte {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-end;
  gap: 0.9em 1.05em;
  font-size: clamp(0.92rem, 2.7vw, 1.2rem);
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.mot { display: inline-flex; align-items: flex-end; gap: 0.18em; }
.case {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  width: 1.45em;
  border-radius: 6px;
  cursor: pointer;
  padding: 2px 0 1px;
}
.case-clair {
  display: block;
  width: 100%;
  height: 1.45em;
  line-height: 1.45em;
  text-align: center;
  font-weight: 800;
  font-size: 1.15em;
  border-bottom: 2px solid #9aa7b6;
  color: var(--cg-encre);
}
.case-chiffre {
  display: block;
  margin-top: 2px;
  font-size: 0.78em;
  font-weight: 700;
  color: var(--cg-gris-encre);
  letter-spacing: 0.02em;
}
.signe {
  align-self: flex-start;
  font-size: 1.15em;
  font-weight: 800;
  line-height: 1.45em;
  padding-top: 2px;
  color: var(--cg-encre);
}
.case:hover { background: rgba(14, 165, 233, 0.1); }
.case.choisie { background: rgba(245, 158, 11, 0.24); }
.case.curseur { box-shadow: inset 0 0 0 2px #0369a1; }
.case.posee .case-clair { border-bottom-color: var(--cg-encre); }
/* Leçons : le code dont parle l'explication. */
.case.guide { box-shadow: inset 0 0 0 2px #f59e0b; background: rgba(245, 158, 11, 0.18); }
.case.fixe .case-clair { color: #0369a1; }
.case.en-attente .case-clair { opacity: 0.35; }
.case.refusee .case-clair { animation: cg-refus 0.45s ease-out; }
@keyframes cg-refus {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-3px); color: #dc2626; }
  60% { transform: translateX(3px); color: #dc2626; }
}
.crypto-cadre.masquee .case-chiffre,
.crypto-cadre.masquee .signe { color: transparent; }
.crypto-cadre.verrou .case { cursor: default; }
.crypto-cadre.verrou .case:hover { background: none; }
.crypto-cadre.resolue .case-clair { color: #047857; border-bottom-color: #047857; }
.case.fausse .case-clair { color: #b91c1c; border-bottom-color: #b91c1c; }
.case.manquee .case-clair { color: #b45309; }

/* Décompte de départ, posé sur la feuille dont les lettres restent cachées. */
.decompte {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  font-size: 3.4rem;
  font-weight: 800;
  color: #0369a1;
  pointer-events: none;
}

.mot-retour {
  margin: 10px 0 6px;
  min-height: 1.35em;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--cg-doux);
}
.mot-retour.ok { color: var(--cg-vert); }
.mot-retour.ko { color: var(--cg-rouge); }

/* Le clavier : trois rangées AZERTY, une lettre déjà posée reste touchable (la reposer
   ailleurs la déplace), une lettre donnée (offerte, indice) est grisée. */
.clavier { display: flex; flex-direction: column; align-items: center; gap: 6px; margin: 6px 0 10px; }
.clavier-ligne { display: flex; gap: 5px; justify-content: center; width: 100%; max-width: 560px; }
.touche {
  flex: 1 1 0;
  max-width: 48px;
  min-width: 0;
  height: 46px;
  padding: 0;
  border: 1px solid var(--cg-bordure-forte);
  border-radius: 8px;
  background: var(--cg-panel-2);
  color: var(--cg-texte);
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 800;
  cursor: pointer;
}
.touche:hover:not(:disabled) { border-color: var(--cg-bleu); }
.touche.utilisee { background: transparent; color: var(--cg-doux); border-style: dashed; }
.touche.donnee { opacity: 0.3; }
.touche:disabled { cursor: default; }
.touche-effacer { flex-grow: 1.6; max-width: 76px; font-size: 1.15rem; }

.frequences { margin: 4px 0 0; font-size: 0.86rem; color: var(--cg-doux); }
.frequences summary { cursor: pointer; text-align: center; padding: 8px 0; font-weight: 600; }
.frequences-aide { margin: 0 0 8px; text-align: center; font-size: 0.8rem; line-height: 1.5; }
.frequences-liste { display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; }
.freq {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  padding: 5px 8px;
  border: 1px solid var(--cg-bordure);
  border-radius: 8px;
  background: transparent;
  color: var(--cg-texte);
  font-family: inherit;
  cursor: pointer;
}
.freq.choisie { border-color: var(--cg-ambre); }
.freq-c { font-weight: 800; }
.freq-n { font-size: 0.74rem; color: var(--cg-doux); }
.freq-p { font-weight: 800; color: var(--cg-ambre); min-width: 0.6em; }

.jeu-aide { text-align: center; color: var(--cg-doux); font-size: 0.8rem; line-height: 1.5; margin: 12px 0 0; }

/* ================= ÉCRAN DE FIN ================= */

.overlay {
  display: none;
  position: fixed;
  inset: 0;
  /* Au-dessus de la barre de compte (1000) ; sous les annonces de badges du réseau (9000 et plus). */
  z-index: 1100;
  background: rgba(8, 10, 16, 0.86);
  padding: 16px;
  overflow-y: auto;
}
/* Aligné en haut, la carte se centrant par ses marges : une carte plus haute que
   l'écran garde son titre atteignable. */
.overlay.visible { display: flex; align-items: flex-start; justify-content: center; }

.overlay-carte {
  position: relative;
  width: 100%;
  max-width: 520px;
  box-sizing: border-box;
  margin: auto;
  background: var(--cg-panel);
  border: 1px solid var(--cg-bordure-forte);
  border-radius: 16px;
  padding: 24px 22px 20px;
  text-align: center;
}
.overlay-carte h2 { margin: 0 34px 10px; font-size: 1.45rem; color: var(--cg-bleu-clair); }
.overlay-carte > p { color: var(--cg-doux); margin: 0 0 14px; line-height: 1.55; }

.overlay-fermer {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--cg-bordure);
  background: transparent;
  color: var(--cg-doux);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}
.overlay-fermer:hover { color: var(--cg-texte); border-color: var(--cg-bleu); }

/* La citation déchiffrée : dans l'écran de fin, et la phrase d'hier sur la page du défi. */
.fin-citation {
  margin: 0 0 14px;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--cg-papier);
  color: var(--cg-encre);
  text-align: left;
}
.fin-citation p { margin: 0 0 6px; font-size: 1.02rem; line-height: 1.55; font-style: italic; }
.fin-citation footer { margin: 0; padding: 0; border: 0; font-size: 0.84rem; font-weight: 700; color: #475569; text-align: right; }

.overlay-carte > .fin-rang { color: var(--cg-texte); font-weight: 600; font-size: 0.95rem; }

.fin-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.stat-bloc {
  background: color-mix(in srgb, #fff 5%, transparent);
  border: 1px solid color-mix(in srgb, #fff 10%, transparent);
  border-radius: 10px;
  padding: 9px 4px;
}
.stat-valeur { display: block; font-size: 1.1rem; font-weight: 800; color: var(--cg-texte); font-variant-numeric: tabular-nums; }
.stat-label { display: block; font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--cg-doux); margin-top: 2px; }

.fin-bloc { margin: 0 0 14px; text-align: left; }
.fin-bloc-titre { margin: 0 0 6px; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--cg-doux); }
.fin-classement { list-style: none; margin: 0; padding: 0; border: 1px solid var(--cg-bordure); border-radius: 10px; max-height: 210px; overflow-y: auto; }
.fin-classement li { display: flex; align-items: baseline; gap: 8px; padding: 6px 12px; font-size: 0.9rem; border-bottom: 1px solid var(--cg-bordure); }
.fin-classement li:last-child { border-bottom: 0; }
.fin-classement li.moi { background: color-mix(in srgb, var(--cg-bleu) 22%, transparent); }

.fin-compte {
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--cg-ambre) 40%, var(--cg-bordure));
  border-radius: 10px;
  background: color-mix(in srgb, var(--cg-ambre) 8%, transparent);
}
.fin-compte p { margin: 0 0 10px; font-size: 0.88rem; line-height: 1.5; color: var(--cg-texte); }
.fin-compte-btns { display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap; }
.fin-compte .btn { padding: 9px 16px; font-size: 0.86rem; }

.overlay-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 6px; }
.fin-voir { display: block; margin: 14px auto 0; font-size: 0.88rem; min-height: 32px; }
.fin-lien-classement {
  display: block;
  margin: 10px 0 4px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--cg-bleu-clair);
  text-decoration: none;
}
.fin-lien-classement:hover { text-decoration: underline; }

/* ================= MULTIJOUEUR ================= */

.lobby-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-bottom: 20px; }
.note-invite { color: var(--cg-doux); font-size: 0.85rem; text-align: center; margin-top: 16px; }
.overlay-carte > .note-invite { margin: 0 0 12px; }

.setup-amis { margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--cg-bordure); }
.setup-amis h2 { font-size: 0.86rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--cg-bleu-clair); margin: 0 0 10px; }
.setup-note { color: var(--cg-doux); font-size: 0.88rem; line-height: 1.6; margin: 0 0 16px; }

.lobby-prenom { max-width: 340px; margin: 0 auto 18px; }
.lobby-prenom label { display: block; font-size: 0.85rem; color: var(--cg-doux); margin-bottom: 8px; text-align: center; }
.lobby-prenom .champ { width: 100%; box-sizing: border-box; text-align: center; font-weight: 700; }
.lobby-note { text-align: center; margin: -8px auto 14px; max-width: 480px; }

.lobby-rejoindre { max-width: 340px; margin: 0 auto; }
.lobby-rejoindre label { display: block; font-size: 0.85rem; color: var(--cg-doux); margin-bottom: 8px; text-align: center; }
.controle-ligne { display: flex; gap: 10px; }

.champ,
#input-code {
  padding: 11px 14px;
  border: 2px solid var(--cg-bordure);
  border-radius: 10px;
  background: var(--cg-panel);
  color: var(--cg-texte);
  font-family: inherit;
  font-size: 0.95rem;
}
.champ:focus-visible,
#input-code:focus { outline: none; border-color: var(--cg-bleu); }

#input-code {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 5px;
  text-align: center;
  text-transform: uppercase;
}
#input-code::placeholder { color: var(--cg-doux); opacity: 0.5; letter-spacing: 5px; }

.salon-code-bloc { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
#salon-code { font-size: 1.9rem; font-weight: 800; letter-spacing: 8px; color: var(--cg-ambre); }
/* Le code QR se lit sur fond clair, marge comprise : le fond blanc fait partie du dessin. */
.salon-qr { width: 132px; height: 132px; border-radius: 8px; background: #fff; image-rendering: pixelated; }
.salon-lien { width: 100%; box-sizing: border-box; margin: 0 0 14px; font-size: 0.84rem; }

.salon-joueurs { list-style: none; padding: 0; margin: 0 0 16px; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.salon-joueurs li {
  padding: 9px 13px;
  border: 1px solid var(--cg-bordure);
  border-radius: 10px;
  background: color-mix(in srgb, #000 22%, transparent);
  font-size: 0.9rem;
}
.salon-joueurs li.moi { border-color: var(--cg-bleu); }
.salon-hote { color: var(--cg-bleu-clair); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; }
.salon-absent { color: var(--cg-doux); font-size: 0.78rem; font-style: italic; }
#btn-lancer-manche { display: block; width: 100%; margin: 0; max-width: none; }

.arene-etat {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 4px 0 12px;
  color: var(--cg-bleu-clair);
  font-weight: 700;
  font-size: 0.92rem;
}
.arene-pastille { width: 9px; height: 9px; border-radius: 50%; background: #4ade80; }

.arene-grille { display: grid; grid-template-columns: minmax(0, 1fr) 250px; gap: 16px; align-items: start; }

.classement-live { background: var(--cg-panel); border: 1px solid var(--cg-bordure); border-radius: 14px; padding: 14px; }
.classement-live h2 { margin: 0 0 10px; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--cg-bleu-clair); }
.classement-live ol { list-style: none; margin: 0; padding: 0; }
.classement-live li { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; font-size: 0.88rem; color: var(--cg-texte); }
.classement-live li + li { margin-top: 2px; }
.classement-live li.moi { background: color-mix(in srgb, var(--cg-bleu) 24%, transparent); }
.classement-live li.hors-top { margin-top: 8px; border-top: 1px dashed var(--cg-bordure); border-radius: 0 0 8px 8px; }
.live-rang { color: var(--cg-doux); font-size: 0.78rem; min-width: 1.6em; }
.live-nom { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-etat { font-weight: 800; color: var(--cg-ambre); font-variant-numeric: tabular-nums; font-size: 0.84rem; }
.live-etat.resolu { color: var(--cg-vert); }
/* La progression d'un joueur : la part des cases qu'il a remplies, jamais leur justesse. */
.live-barre { flex: 0 0 52px; height: 6px; border-radius: 3px; background: var(--cg-bordure); overflow: hidden; }
.live-barre span { display: block; height: 100%; background: var(--cg-bleu); }
.live-parti {
  margin-left: 4px;
  padding: 1px 6px;
  border: 1px solid var(--cg-bordure-forte);
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--cg-doux);
}

.compte-a-rebours { text-align: center; font-size: 1.9rem; font-weight: 800; color: var(--cg-ambre); margin: 18px 0 6px; font-variant-numeric: tabular-nums; }

.case-option { display: flex; align-items: flex-start; gap: 10px; margin: 0 0 6px; padding: 8px 0; font-size: 0.86rem; line-height: 1.5; color: var(--cg-doux); cursor: pointer; }
.case-option input { flex: 0 0 auto; width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--cg-bleu); }

.flux-pris {
  margin: 0 0 8px;
  min-height: 1.3em;
  text-align: center;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--cg-doux);
  opacity: 0;
  transition: opacity 0.25s;
}
.flux-pris.visible { opacity: 1; }

/* ================= DÉFI DU JOUR ================= */

/* Encart du classement du jour : cadre commun aux pages de défi du réseau. Le
   contenu (podium, lignes) vient du socle classement-bloc.css. */
.classement-section {
  max-width: 800px;
  margin: 22px auto;
  padding: 18px;
  box-sizing: border-box;
  background: rgba(148, 163, 184, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
.classement-section h2 { margin: 0 0 12px; font-size: 1.15rem; font-weight: 700; color: #f0f3f6; }
.classement-cta-compte { margin: 12px 0 0; text-align: center; font-size: 0.88rem; color: var(--cg-doux); }
.lien-classement { display: block; margin-top: 12px; text-align: center; font-size: 0.9rem; font-weight: 700; color: var(--cg-bleu-clair); text-decoration: none; }
.lien-classement:hover { text-decoration: underline; }

.defi-hier { margin: 0 0 18px; }
.defi-hier-titre { margin: 0 0 8px; font-size: 0.9rem; color: var(--cg-doux); }
.defi-hier-titre strong { color: var(--cg-texte); }

.calendrier-defi {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 34px));
  gap: 4px;
  margin: 12px 0 6px;
}
.cal-jour { text-align: center; font-size: 0.7rem; font-weight: 700; color: var(--cg-doux); }
.cal-case {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  border-radius: 7px;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--cg-doux);
  border: 1px solid var(--cg-bordure);
}
.cal-fini { background: color-mix(in srgb, var(--cg-vert) 38%, transparent); border-color: var(--cg-vert); color: #fff; }
.cal-tente { background: color-mix(in srgb, var(--cg-ambre) 26%, transparent); border-color: var(--cg-ambre); color: #fff; }
.cal-rate { background: transparent; }
.cal-futur, .cal-avant { opacity: 0.35; }
.cal-auj { outline: 2px solid var(--cg-bleu); outline-offset: 1px; }
.cal-legende { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 0.78rem; }
.cal-legende .cal-case { display: inline-block; width: 12px; height: 12px; aspect-ratio: auto; border-radius: 3px; }

/* « Tes chiffres », sous le choix de la difficulté. */
.tranche { border: 1px solid var(--cg-bordure); border-radius: 12px; margin-bottom: 8px; background: var(--cg-panel); }
.tranche summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--cg-texte);
  list-style: none;
}
.tranche summary::-webkit-details-marker { display: none; }
.tranche summary small { font-weight: 600; color: var(--cg-doux); font-size: 0.8rem; }
.tranche[open] summary { border-bottom: 1px solid var(--cg-bordure); }
.stats-joueur { margin-top: 14px; }
.stats-liste { margin: 0; padding: 4px 14px 12px; }
.stats-liste > div { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 16px; padding: 8px 0; border-bottom: 1px solid var(--cg-bordure); font-size: 0.9rem; }
.stats-liste > div:last-child { border-bottom: 0; }
.stats-liste dt { color: var(--cg-doux); }
.stats-liste dd { margin: 0; font-weight: 700; color: var(--cg-texte); text-align: right; }
.stats-liste small { font-weight: 500; color: var(--cg-doux); }

/* ================= APPRENDRE ================= */

.lecons-liste { margin: 22px 0 18px; }
.lecons-titre { margin: 0 0 10px; font-size: 1rem; color: var(--cg-bleu-clair); }
.lecons-liste ol { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.lecon-bouton {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--cg-bordure);
  border-radius: 10px;
  background: var(--cg-panel);
  color: var(--cg-texte);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.lecon-bouton:hover { border-color: var(--cg-bleu); }
.lecon-bouton.active { border-color: var(--cg-ambre); }
.lecon-num {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--cg-panel-2);
  border: 1px solid var(--cg-bordure-forte);
  font-size: 0.8rem;
  font-weight: 800;
}
.lecon-bouton.faite .lecon-num { background: var(--cg-vert); border-color: var(--cg-vert); color: #052e1c; }
.lecon-compte { margin: 8px 0 0; font-size: 0.86rem; color: var(--cg-doux); text-align: center; }
.lecon-compte-invite { margin-top: 6px; }
.lecon-compte-invite a { color: var(--cg-bleu-clair); }

.lecon-panneau {
  margin: 0 0 14px;
  padding: 14px 16px;
  border: 1px solid color-mix(in srgb, var(--cg-ambre) 40%, var(--cg-bordure));
  border-radius: 12px;
  background: color-mix(in srgb, var(--cg-ambre) 6%, var(--cg-panel));
}
.lecon-numero { margin: 0; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--cg-ambre); font-weight: 700; }
.lecon-titre { margin: 2px 0 8px; font-size: 1.15rem; color: var(--cg-texte); }
.lecon-texte { margin: 0 0 8px; line-height: 1.6; color: var(--cg-texte); }
.lecon-bravo { margin: 0 0 10px; min-height: 1.2em; line-height: 1.5; font-weight: 600; color: var(--cg-vert); }
.lecon-boutons { display: flex; flex-wrap: wrap; gap: 8px; }

.fin-lecons {
  margin: 18px 0;
  padding: 18px;
  border: 1px solid var(--cg-vert);
  border-radius: 12px;
  background: color-mix(in srgb, var(--cg-vert) 8%, var(--cg-panel));
  text-align: center;
}
.fin-lecons h2 { margin: 0 0 8px; color: var(--cg-texte); }
.fin-lecons p { margin: 0 0 12px; color: var(--cg-doux); line-height: 1.6; }
.apprendre-texte ol { margin: 0 0 12px; padding-left: 20px; color: var(--cg-doux); line-height: 1.7; }

/* ================= ENTRAÎNEMENT ================= */

.reglages-entrainement { display: grid; gap: 12px; margin: 0 0 18px; }
.reglage-ligne { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; font-size: 0.9rem; color: var(--cg-doux); }
.reglage-ligne label { color: var(--cg-texte); font-weight: 600; }
.reglage-ligne select { min-height: 44px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--cg-bordure-forte); background: var(--cg-panel); color: var(--cg-texte); font-family: inherit; font-size: 0.92rem; }
.liste-archives { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.liste-archives a { display: inline-block; padding: 8px 12px; border: 1px solid var(--cg-bordure); border-radius: 8px; color: var(--cg-bleu-clair); text-decoration: none; font-size: 0.86rem; }
.liste-archives a:hover { border-color: var(--cg-bleu); }

@media (max-width: 560px) {
  .lecons-liste ol { grid-template-columns: 1fr; }
}

/* ================= PIED DE PAGE ================= */

footer {
  margin-top: 36px;
  padding-top: 20px;
  border-top: 1px solid var(--cg-bordure);
  text-align: center;
  color: var(--cg-doux);
  font-size: 0.85rem;
  line-height: 1.9;
}
footer a { color: var(--cg-bleu-clair); text-decoration: none; }
footer a:hover { text-decoration: underline; }
.footer-sources { font-size: 0.76rem; line-height: 1.5; max-width: 620px; margin: 6px auto; }

/* ================= ÉCRANS BAS (portable 1366 × 768) ================= */
@media (min-width: 721px) and (max-height: 860px) {
  body.cg-en-jeu #app { padding-top: 12px; padding-bottom: 12px; }
  body.cg-en-jeu .jeu-banner { margin-bottom: 10px; padding-top: 8px; padding-bottom: 8px; }
  .jeu-aide { display: none; }
}

/* ================= TABLETTE ET TÉLÉPHONE ================= */

@media (max-width: 900px) {
  .arene-grille { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  /* La barre de compte est fixée en haut à droite : sans cette réserve elle
     passait sur le titre du banner. */
  body { padding-top: 46px; }
  /* Le padding horizontal reste à 24 px : les marges négatives du banner sont
     calées dessus, le réduire fait défiler la page de côté. */
  #app { padding: 14px 24px 20px; }
  .jeu-banner .banner-deco { display: none; }
  .setup-intro { margin-bottom: 16px; font-size: 0.92rem; }
  .setup-tete { flex-wrap: wrap; }
  .choix-difficulte { grid-template-columns: 1fr; }

  /* En partie, tout l'écran va au jeu : ni banner, ni barre de compte. */
  body.cg-en-jeu { padding-top: 0; }
  body.cg-en-jeu #app { padding: 8px 8px 14px; }
  body.cg-en-jeu .jeu-banner,
  body.cg-en-jeu .auth-nav,
  body.cg-en-jeu footer,
  body.cg-en-jeu .arene-etat { display: none !important; }

  #jeu { display: flex; flex-direction: column; padding: 10px 6px 12px; border-radius: 14px; }
  #jeu > .seance-titre { order: 0; margin-bottom: 6px; }
  #jeu > .jeu-hud { order: 1; }
  #jeu > .hud-objectif, #jeu > .flux-pris { order: 2; }
  #jeu > .crypto-cadre { order: 3; }
  #jeu > .mot-retour { order: 4; }
  #jeu > .clavier { order: 5; }
  #jeu > .actions-jeu { order: 6; margin: 4px 0 8px; gap: 6px; }
  #jeu > .actions-jeu .btn { flex: 1 1 auto; padding: 8px 10px; font-size: 0.88rem; }
  #jeu > .frequences { order: 7; }
  #jeu > .jeu-aide { display: none; }
  .jeu-hud { gap: 6px; margin-bottom: 6px; }
  .hud-bloc { padding: 5px 4px; }
  .hud-valeur { font-size: 1.15rem; }
  .hud-principal .hud-valeur { font-size: 1.3rem; }
  .hud-label { font-size: 0.66rem; }
  .hud-objectif { margin-bottom: 6px; font-size: 0.8rem; }
  .crypto-cadre { padding: 12px 6px 10px; border-radius: 10px; }
  .crypto-texte { gap: 0.75em 1.15em; font-size: clamp(0.82rem, 3.9vw, 1rem); }
  #jeu { scroll-margin-top: 0; }
  .mot { gap: 0.1em; }
  .case { width: 1.35em; }
  .clavier-ligne { gap: 4px; }
  .touche { height: 44px; font-size: 1rem; }
}

/* ================= GROS CARACTÈRES ================= */
html.cg-gros .crypto-texte { font-size: clamp(1.1rem, 4.6vw, 1.55rem); }
html.cg-gros .case-chiffre { font-size: 0.86em; color: #334155; }
html.cg-gros .touche { height: 52px; font-size: 1.25rem; }
html.cg-gros .hud-objectif, html.cg-gros .mot-retour { font-size: 1rem; color: #e2e8f0; }

@media (prefers-reduced-motion: reduce) {
  .btn, .flux-pris { transition: none; }
  .case.refusee .case-clair { animation: none; color: #dc2626; }
}
