/*
 * Chasse aux mots — pages de jeu (parcours, défi du jour, multijoueur, entraînement).
 *
 * 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 {
  --cam-panel: var(--surface-1, #16191f);
  --cam-panel-2: var(--surface-2, #1c2027);
  --cam-bordure: var(--line, #2a2f37);
  --cam-bordure-forte: var(--line-forte, #39404a);
  --cam-texte: #f1f5f9;
  --cam-doux: var(--texte-doux, #98a1ad);
  --cam-vert: #10b981;
  --cam-vert-clair: #a7f3d0;
  --cam-ambre: #fbbf24;
  --cam-case: #fde9b8;
  --cam-case-texte: #3b2a06;
  --cam-rouge: #f87171;
  --cam-gris: #94a3b8;
}

/* head-common.php charge Inter mais ne l'applique à rien : la police de base se pose ici. */
body {
  margin: 0;
  font-family: 'Inter', sans-serif;
  color: var(--cam-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 grille. */
#app {
  max-width: 800px;
  box-sizing: border-box;
  margin: 0 auto;
  padding: 28px 24px;
  color: var(--cam-texte);
}
body.page-arene #app { max-width: 1040px; }

.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.chasse-en-jeu .bandeau-infos-wrap,
body.chasse-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(--cam-texte);
}

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

.setup-bloc h2 {
  font-size: 0.86rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--cam-vert-clair);
  margin: 0 0 10px;
}

.setup-aide-texte { color: var(--cam-doux); font-size: 0.88rem; line-height: 1.6; margin: 8px 0 0; }

.setup-aide { border-top: 1px solid var(--cam-bordure); padding-top: 20px; margin-top: 8px; }
.setup-aide h2 { font-size: 1rem; color: var(--cam-vert-clair); margin: 0 0 12px; }
.setup-aide ul { margin: 0; padding-left: 20px; color: var(--cam-doux); line-height: 1.7; }
.setup-aide li { margin-bottom: 8px; }
.setup-aide strong { color: var(--cam-texte); }
.setup-aide a { color: var(--cam-vert-clair); }

.bareme { width: 100%; border-collapse: collapse; margin: 4px 0 14px; font-size: 0.9rem; }
.bareme th, .bareme td { border: 1px solid var(--cam-bordure); padding: 7px 8px; text-align: center; color: var(--cam-doux); }
.bareme th { color: var(--cam-vert-clair); font-weight: 700; }
.bareme td { color: var(--cam-texte); font-weight: 700; }

.defi-carte,
.etat-defi,
.fiche-niveau {
  background: var(--cam-panel);
  border: 1px solid var(--cam-bordure);
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 20px;
}
.defi-carte h2 { margin: 0 0 10px; font-size: 1.05rem; color: var(--cam-vert-clair); }
.defi-carte p,
.etat-defi p { margin: 0 0 8px; color: var(--cam-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(--cam-texte); }
.etat-defi .etat-defi-titre { font-size: 1.05rem; font-weight: 700; color: var(--cam-vert-clair); }
.etat-defi .etat-defi-serie { color: var(--cam-ambre); font-weight: 600; }

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

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

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

/* ================= PARCOURS : FICHE ET CARTE DES NIVEAUX ================= */

.fiche-niveau { border-color: color-mix(in srgb, var(--cam-vert) 45%, var(--cam-bordure)); text-align: center; }
.fiche-titre { margin: 0 0 4px; font-size: 1.25rem; font-weight: 800; color: var(--cam-texte); }
.fiche-etoiles { font-size: 1.5rem; letter-spacing: 4px; color: var(--cam-ambre); margin: 0 0 8px; line-height: 1; }
.fiche-objectifs {
  list-style: none;
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 10px;
  padding: 0;
}
.fiche-objectifs li {
  padding: 6px 12px;
  border: 1px solid var(--cam-bordure);
  border-radius: 999px;
  font-size: 0.86rem;
  color: var(--cam-doux);
  white-space: nowrap;
}
.fiche-objectifs li.atteint { border-color: var(--cam-ambre); color: var(--cam-ambre); }
.fiche-objectifs strong { color: var(--cam-texte); }
.fiche-record { margin: 0 0 14px; font-size: 0.9rem; color: var(--cam-doux); }
.fiche-record strong { color: var(--cam-texte); }
.fiche-niveau .btn-lancer { margin-bottom: 8px; }
.fiche-lien { font-size: 0.86rem; color: var(--cam-vert-clair); }
/* Lien seul sur sa ligne : une zone de toucher de 40 px, pas la hauteur du texte. */
#fiche-lien { display: inline-block; padding: 13px 14px; }

.parcours-bilan { margin: 0 0 14px; color: var(--cam-doux); font-size: 0.92rem; }
.parcours-bilan strong { color: var(--cam-texte); }

.tranche { border: 1px solid var(--cam-bordure); border-radius: 12px; margin-bottom: 8px; background: var(--cam-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(--cam-texte);
  list-style: none;
}
.tranche summary::-webkit-details-marker { display: none; }
.tranche summary small { font-weight: 600; color: var(--cam-doux); font-size: 0.8rem; }
.tranche[open] summary { border-bottom: 1px solid var(--cam-bordure); }
.tranche.fermee summary { color: var(--cam-doux); }

.niveaux {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 6px;
  padding: 12px;
}
.niveau {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 7px 0 5px;
  border: 1px solid var(--cam-bordure-forte);
  border-radius: 9px;
  background: var(--cam-panel-2);
  color: var(--cam-texte);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}
.niveau small { font-size: 0.58rem; letter-spacing: 1px; color: var(--cam-ambre); min-height: 0.6rem; }
.niveau:hover { border-color: var(--cam-vert); }
.niveau.choisi { border-color: var(--cam-vert); background: color-mix(in srgb, var(--cam-vert) 22%, var(--cam-panel-2)); }
.niveau.courant { border-color: var(--cam-ambre); }
.niveau.verrou { color: color-mix(in srgb, var(--cam-doux) 55%, transparent); border-color: var(--cam-bordure); background: transparent; }
.niveau.verrou:hover { border-color: var(--cam-bordure-forte); }

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: #059669;
  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: #047857; 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(--cam-bordure-forte); color: var(--cam-texte); }
a.btn-outline, a.btn-outline:visited { color: var(--cam-texte); }
.btn-outline:hover { background: color-mix(in srgb, #fff 6%, transparent); border-color: var(--cam-vert); }

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

.btn-petit { padding: 9px 14px; font-size: 0.84rem; }

.btn-discret {
  background: transparent;
  border: 1px solid var(--cam-bordure);
  border-radius: 8px;
  color: var(--cam-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(--cam-vert-clair); border-color: var(--cam-vert); }

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

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

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

#jeu {
  position: relative;
  border-radius: 18px;
  padding: 18px 18px 20px;
  background-color: color-mix(in srgb, var(--cam-vert) 10%, var(--surface-0, #0e1014));
  border: 1px solid color-mix(in srgb, var(--cam-vert) 34%, var(--cam-bordure));
}

.seance-titre { margin: 0 0 12px; text-align: center; font-size: 0.95rem; font-weight: 700; color: var(--cam-vert-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 8px;
  text-align: center;
}
.hud-valeur {
  display: block;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--cam-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(--cam-doux);
  margin-top: 3px;
}
.hud-principal .hud-valeur { color: var(--cam-ambre); font-size: 1.85rem; }
#jeu.derniere-ligne-droite #hud-chrono { color: var(--cam-rouge); }

.hud-objectif {
  margin: 0 0 8px;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--cam-doux);
  min-height: 1.2em;
}
.hud-objectif .etoiles { color: var(--cam-ambre); letter-spacing: 2px; }
.hud-objectif.atteint { color: var(--cam-ambre); }

.jauge {
  height: 6px;
  border-radius: 999px;
  background: color-mix(in srgb, #fff 9%, transparent);
  overflow: hidden;
  margin-bottom: 14px;
}
.jauge-barre {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: var(--cam-vert);
  transform-origin: left center;
}
#jeu.derniere-ligne-droite .jauge-barre { background: var(--cam-rouge); }
#jeu.format-libre .jauge,
#jeu.format-libre .hud-bloc-chrono { display: none; }

.jeu-corps {
  display: grid;
  grid-template-columns: minmax(0, 400px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

/* Le mot en cours et le verdict du précédent, au-dessus de la grille : l'œil ne
   quitte pas les lettres. */
.mot-en-cours {
  margin: 0 0 4px;
  min-height: 1.5em;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--cam-texte);
  text-transform: uppercase;
  line-height: 1.5;
  overflow: hidden;
  white-space: nowrap;
}
.mot-en-cours.hors-grille { color: var(--cam-gris); }
.mot-retour {
  margin: 0 0 8px;
  min-height: 1.4em;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--cam-doux);
}
.mot-retour.ok { color: var(--cam-vert-clair); }
.mot-retour.ko { color: var(--cam-rouge); }
.mot-retour.deja { color: var(--cam-gris); }
.mot-retour.definition { color: var(--cam-doux); }
.mot-retour a,
.fin-definition a { color: var(--cam-vert-clair); }

.grille-cadre {
  position: relative;
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
  aspect-ratio: 1;
}
.grille {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 2.4%;
  width: 100%;
  height: 100%;
  /* Le doigt trace les mots : la page ne doit ni défiler ni zoomer sous lui. */
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.case {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 14%;
  background: var(--cam-case);
  color: var(--cam-case-texte);
  font-family: inherit;
  font-size: clamp(1.5rem, 8.2vw, 2.5rem);
  font-weight: 800;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.16);
  transition: transform 0.08s, background-color 0.12s;
  -webkit-tap-highlight-color: transparent;
}
.case.sel { background: #34d399; color: #022c22; transform: scale(0.95); }
.case.ok { background: #6ee7b7; color: #022c22; }
.case.deja { background: #cbd5e1; color: #1e293b; }
.case.ko { background: #fca5a5; color: #450a0a; }
.case.montre { background: #fbbf24; color: #3b2a06; }
.grille.verrou .case { cursor: default; }

/* Grande grille de 5 × 5 (entraînement et salon privé). */
.grille.t5 { grid-template-columns: repeat(5, 1fr); grid-template-rows: repeat(5, 1fr); gap: 2%; }
.grille.t5 .case { font-size: clamp(1.2rem, 6.4vw, 2.05rem); }
.grille-cadre.t5 { max-width: 440px; }
.grille-cadre.t5 + .saisie-actions { max-width: 440px; margin-left: auto; margin-right: auto; }
#jeu.en-decompte .case { color: transparent; }

.grille-trace {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.grille-trace polyline {
  fill: none;
  stroke: rgba(4, 120, 87, 0.55);
  stroke-width: 9;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.grille-trace.montre polyline { stroke: rgba(180, 83, 9, 0.6); }

/* Décompte de départ : posé sur la grille, dont les lettres restent cachées
   tant que le chrono n'est pas parti. */
.decompte {
  position: absolute;
  inset: 0;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(3.4rem, 16vw, 5.5rem);
  font-weight: 800;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.55);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.saisie-actions { display: flex; gap: 8px; justify-content: center; margin-top: 12px; }
.saisie-actions .btn { flex: 1 1 0; max-width: 190px; }

.jeu-mots {
  background: color-mix(in srgb, #000 24%, transparent);
  border: 1px solid color-mix(in srgb, #fff 10%, transparent);
  border-radius: 12px;
  padding: 12px;
  min-height: 120px;
}
.jeu-mots h2 {
  margin: 0 0 8px;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--cam-vert-clair);
  display: flex;
  justify-content: space-between;
}
.jeu-mots h2 span { color: var(--cam-doux); }

.mots-liste { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; max-height: 360px; overflow-y: auto; }
.mots-liste li { margin: 0; }
.mot {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  padding: 5px 9px;
  border-radius: 8px;
  border: 1px solid color-mix(in srgb, #fff 12%, transparent);
  background: color-mix(in srgb, #fff 6%, transparent);
  color: var(--cam-texte);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}
.mot small { color: var(--cam-ambre); font-weight: 800; font-size: 0.72rem; }
.mot:hover { border-color: var(--cam-vert); }
.mot.manque { color: var(--cam-doux); border-style: dashed; }
.mot.rare { color: var(--cam-gris); font-weight: 500; }
.mot.commun { text-decoration: line-through; color: var(--cam-gris); }
.mot.commun small { color: var(--cam-gris); }
.mots-vide { color: var(--cam-doux); font-size: 0.86rem; margin: 0; }

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

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

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

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

.overlay-carte {
  position: relative;
  width: 100%;
  max-width: 500px;
  box-sizing: border-box;
  margin: auto;
  background: var(--cam-panel);
  border: 1px solid var(--cam-bordure-forte);
  border-radius: 16px;
  padding: 24px 22px 20px;
  text-align: center;
}
.overlay-carte h2 { margin: 0 34px 8px; font-size: 1.45rem; color: var(--cam-vert-clair); }
.overlay-carte > p { color: var(--cam-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(--cam-bordure);
  background: transparent;
  color: var(--cam-doux);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}
.overlay-fermer:hover { color: var(--cam-texte); border-color: var(--cam-vert); }

.overlay-carte > .fin-etoiles { font-size: 2.2rem; letter-spacing: 8px; color: var(--cam-ambre); margin: 0 0 6px; line-height: 1; }
.overlay-carte > .fin-rang { color: var(--cam-texte); font-weight: 600; font-size: 0.95rem; }
.overlay-carte > .fin-rang.fin-rang-record { color: var(--cam-ambre); }

.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.2rem; font-weight: 800; color: var(--cam-texte); font-variant-numeric: tabular-nums; }
.stat-label { display: block; font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--cam-doux); margin-top: 2px; }

.overlay-carte > .fin-part { font-size: 0.88rem; margin: 0 0 14px; }
.overlay-carte > .fin-definition { font-size: 0.9rem; margin: -6px 0 14px; color: var(--cam-doux); }
.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(--cam-doux); }
.fin-bloc .mots-liste { max-height: 132px; }
.fin-bloc .mot { cursor: default; }

.restants { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin: 0; padding: 0; list-style: none; }
.restants li {
  border: 1px solid var(--cam-bordure);
  border-radius: 8px;
  padding: 6px 2px;
  text-align: center;
  font-size: 0.66rem;
  color: var(--cam-doux);
  line-height: 1.3;
}
.restants strong { display: block; font-size: 1.05rem; color: var(--cam-texte); font-variant-numeric: tabular-nums; }
.restants li.zero strong { color: var(--cam-vert-clair); }
.restants-note { margin: 6px 0 0; font-size: 0.78rem; color: var(--cam-doux); }

.fin-classement { list-style: none; margin: 0; padding: 0; border: 1px solid var(--cam-bordure); border-radius: 10px; max-height: 190px; 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(--cam-bordure); }
.fin-classement li:last-child { border-bottom: 0; }
.fin-classement li.moi { background: color-mix(in srgb, var(--cam-vert) 20%, transparent); }

.fin-compte {
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--cam-ambre) 40%, var(--cam-bordure));
  border-radius: 10px;
  background: color-mix(in srgb, var(--cam-ambre) 8%, transparent);
}
.fin-compte p { margin: 0 0 10px; font-size: 0.88rem; line-height: 1.5; color: var(--cam-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-lien-classement {
  display: block;
  margin: 14px 0 4px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--cam-vert-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(--cam-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(--cam-bordure); }
.setup-note { color: var(--cam-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(--cam-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(--cam-doux); margin-bottom: 8px; text-align: center; }
.controle-ligne { display: flex; gap: 10px; }

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

#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(--cam-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(--cam-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(--cam-bordure);
  border-radius: 10px;
  background: color-mix(in srgb, #000 22%, transparent);
  font-size: 0.9rem;
}
.salon-hote { color: var(--cam-vert-clair); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; }
.salon-absent { color: var(--cam-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(--cam-vert-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(--cam-panel); border: 1px solid var(--cam-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(--cam-vert-clair); }
.classement-live ol { list-style: none; margin: 0; padding: 0; }
.classement-live li { display: flex; align-items: baseline; gap: 8px; padding: 6px 8px; border-radius: 8px; font-size: 0.88rem; color: var(--cam-texte); }
.classement-live li + li { margin-top: 2px; }
.classement-live li.moi { background: color-mix(in srgb, var(--cam-vert) 24%, transparent); }
.classement-live li.hors-top { margin-top: 8px; border-top: 1px dashed var(--cam-bordure); border-radius: 0 0 8px 8px; }
.live-rang { color: var(--cam-doux); font-size: 0.78rem; min-width: 1.6em; }
.live-nom { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-score { font-weight: 800; color: var(--cam-ambre); font-variant-numeric: tabular-nums; }

.compte-a-rebours { text-align: center; font-size: 1.9rem; font-weight: 800; color: var(--cam-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(--cam-doux); cursor: pointer; }
.case-option input { flex: 0 0 auto; width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--cam-vert); }

/* ================= 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,
.classement-section h3 { 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(--cam-doux); }

.lien-classement { display: block; margin-top: 12px; text-align: center; font-size: 0.9rem; font-weight: 700; color: var(--cam-vert-clair); text-decoration: none; }
.lien-classement:hover { text-decoration: underline; }

.defi-archives { margin-top: 24px; }
.archives-ligne { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* Le mot rare d'un défi passé, au-dessus de ses réponses. */
.archive-rare { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; font-size: 0.88rem; color: var(--cam-doux); }
.archive-rare .mots-liste { display: inline-flex; }

/* ================= GRILLE LIBRE (entraînement, défis passés) ================= */

.choix-format { border: 1px solid var(--cam-bordure); border-radius: 12px; margin: 0 0 18px; padding: 8px 16px 6px; }
.choix-format legend { padding: 0 6px; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--cam-vert-clair); }

.defi-ami { border-color: color-mix(in srgb, var(--cam-ambre) 45%, var(--cam-bordure)); text-align: center; }
.defi-ami .btn-lancer { margin-bottom: 0; }

.libre-resultat {
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--cam-ambre) 40%, var(--cam-bordure));
  border-radius: 10px;
  background: color-mix(in srgb, var(--cam-ambre) 8%, transparent);
  text-align: center;
}
.libre-resultat p { margin: 0 0 10px; font-weight: 700; color: var(--cam-texte); }
.libre-resultat .salon-lien { margin: 10px 0 0; }

/* « Tes chiffres », sous la carte des niveaux. */
.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(--cam-bordure); font-size: 0.9rem; }
.stats-liste > div:last-child { border-bottom: 0; }
.stats-liste dt { color: var(--cam-doux); }
.stats-liste dd { margin: 0; font-weight: 700; color: var(--cam-texte); text-align: right; }
.stats-liste small { font-weight: 500; color: var(--cam-doux); }

.libre-bilan { margin: 12px 0 0; text-align: center; font-size: 0.9rem; color: var(--cam-doux); }
.libre-bilan strong { color: var(--cam-texte); }
.solution { margin-top: 16px; }
.solution h3 { margin: 14px 0 6px; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--cam-vert-clair); }
.solution .mots-liste { max-height: none; }

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

footer {
  margin-top: 36px;
  padding-top: 20px;
  border-top: 1px solid var(--cam-bordure);
  text-align: center;
  color: var(--cam-doux);
  font-size: 0.85rem;
  line-height: 1.9;
}
footer a { color: var(--cam-vert-clair); text-decoration: none; }
footer a:hover { text-decoration: underline; }

/* ================= ÉCRANS BAS (portable 1366 × 768) ================= */
@media (min-width: 721px) and (max-height: 860px) {
  body.chasse-en-jeu #app { padding-top: 12px; padding-bottom: 12px; }
  body.chasse-en-jeu .jeu-banner { margin-bottom: 10px; padding-top: 8px; padding-bottom: 8px; }
  body.chasse-en-jeu .banner-deco { display: none; }
  .jeu-corps { grid-template-columns: minmax(0, 340px) minmax(0, 1fr); }
  .grille-cadre { max-width: 340px; }
  .mots-liste { max-height: 300px; }
  .jauge { margin-bottom: 8px; }
}

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

@media (max-width: 860px) {
  .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; }
  .niveaux { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .restants { grid-template-columns: repeat(3, 1fr); }

  /* En partie, tout l'écran va au jeu : ni banner, ni barre de compte. */
  body.chasse-en-jeu { padding-top: 0; }
  body.chasse-en-jeu #app { padding: 8px 12px 14px; }
  body.chasse-en-jeu .jeu-banner,
  body.chasse-en-jeu .auth-nav,
  body.chasse-en-jeu footer,
  body.chasse-en-jeu .arene-etat { display: none !important; }
  #jeu { padding: 10px 10px 12px; border-radius: 14px; }
  .jeu-hud { gap: 6px; margin-bottom: 6px; }
  .hud-bloc { padding: 5px 4px; }
  .hud-valeur { font-size: 1.2rem; }
  .hud-principal .hud-valeur { font-size: 1.45rem; }
  .hud-objectif { margin-bottom: 6px; font-size: 0.78rem; }
  .jauge { margin-bottom: 8px; }
  .mot-en-cours { font-size: 1.3rem; }
  .mot-retour { margin-bottom: 6px; }

  /* La grille prend la largeur, les mots trouvés passent dessous sur une ligne
     qui défile de côté : la page, elle, ne bouge pas pendant la partie. */
  /* minmax(0, 1fr) et non 1fr : 1fr vaut minmax(auto, 1fr), et la liste des mots,
     tenue sur une ligne, imposait sa largeur à la colonne, donc à la grille, qui
     sortait de l'écran au cinquième mot trouvé. */
  .jeu-corps { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .grille-cadre { max-width: min(100%, 58vh, 420px); }
  .grille-cadre.t5 { max-width: min(100%, 60vh, 440px); }

  /* Grille libre : elle reste collée en haut pendant qu'on parcourt les mots
     manqués, sinon le chemin d'un mot touché plus bas s'allume hors de l'écran.
     display: contents fait de #jeu le bloc de référence, qui contient la liste. */
  #jeu.format-libre .jeu-corps { display: contents; }
  #jeu.format-libre .jeu-plateau {
    position: sticky;
    top: 0;
    z-index: 2;
    padding-bottom: 8px;
    background-color: color-mix(in srgb, var(--cam-vert) 10%, var(--surface-0, #0e1014));
  }
  #jeu.format-libre .jeu-mots { margin-top: 2px; }
  .jeu-mots { min-height: 0; padding: 8px 10px; }
  .jeu-mots h2 { margin-bottom: 6px; }
  #jeu:not(.fini) .jeu-mots .mots-liste { flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; max-height: none; padding-bottom: 4px; }
  #jeu:not(.fini) .jeu-mots .mot { white-space: nowrap; }
  .jeu-aide { display: none; }
  .saisie-actions { margin-top: 8px; }
  .actions-jeu { margin-top: 10px; }
}

/* ================= PETIT TÉLÉPHONE DEBOUT (360 × 640) ================= */
/* Sans cela, « Terminer maintenant » passait sous le bas de l'écran. */
@media (max-width: 720px) and (max-height: 700px) and (orientation: portrait) {
  body.chasse-en-jeu .seance-titre { display: none; }
  .grille-cadre { max-width: min(100%, 43vh); }
  .grille-cadre.t5 { max-width: min(100%, 46vh); }
  .jeu-mots { padding: 6px 8px; }
  .jeu-mots h2 { margin-bottom: 4px; }
  .saisie-actions { margin-top: 6px; }
  .actions-jeu { margin-top: 6px; }
}

/* ================= TÉLÉPHONE COUCHÉ ================= */
@media (orientation: landscape) and (max-height: 520px) {
  body.chasse-en-jeu { padding-top: 0; }
  body.chasse-en-jeu #app { padding: 6px 12px; max-width: none; }
  body.chasse-en-jeu .jeu-banner,
  body.chasse-en-jeu .auth-nav,
  body.chasse-en-jeu footer,
  body.chasse-en-jeu .arene-etat,
  body.chasse-en-jeu .classement-live { display: none !important; }
  /* La grille prend toute la hauteur, à gauche ; tout le reste (compteurs, mot en
     cours, boutons, mots trouvés) se range à droite. Avec les compteurs au-dessus
     d'elle, le bas de la grille et les boutons sortaient de l'écran. */
  #jeu {
    display: grid;
    grid-template-columns: min(calc(100vh - 30px), 52vw) minmax(0, 1fr);
    column-gap: 12px;
    align-content: start;
    padding: 8px 12px;
  }
  #jeu.cache { display: none; }
  #jeu > * { grid-column: 2; }
  #jeu .jeu-corps,
  #jeu .jeu-plateau,
  #jeu.format-libre .jeu-corps { display: contents; }
  #jeu .jeu-plateau > *,
  #jeu .jeu-mots { grid-column: 2; }
  #jeu .grille-cadre { grid-column: 1; grid-row: 1 / span 9; max-width: none; margin: 0; align-self: start; }
  #jeu.format-libre .jeu-plateau { position: static; padding-bottom: 0; }
  #jeu .solution { grid-column: 1 / -1; }
  .seance-titre { margin-bottom: 4px; font-size: 0.82rem; }
  .jeu-hud { gap: 6px; margin-bottom: 4px; }
  .hud-bloc { padding: 3px 4px; }
  .hud-valeur { font-size: 1.05rem; }
  .hud-principal .hud-valeur { font-size: 1.2rem; }
  .hud-label { font-size: 0.54rem; margin-top: 1px; }
  .hud-objectif { margin-bottom: 4px; font-size: 0.74rem; }
  .jauge { margin-bottom: 4px; }
  .mot-en-cours { font-size: 1.1rem; margin: 0; line-height: 1.3; min-height: 1.3em; }
  .mot-retour { margin: 0 0 4px; font-size: 0.8rem; }
  .saisie-actions { margin-top: 0; }
  .jeu-mots { min-height: 0; padding: 6px 8px; margin-top: 6px; }
  .jeu-mots h2 { margin-bottom: 4px; }
  #jeu:not(.fini) .jeu-mots .mots-liste { flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; max-height: none; padding-bottom: 4px; }
  #jeu:not(.fini) .jeu-mots .mot { white-space: nowrap; }
  .actions-jeu { margin-top: 6px; }
  .jeu-aide { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .case, .btn { transition: none; }
}

/* ================= CONTRÔLE (page réservée à l'administrateur) ================= */
#app.controle { max-width: 1180px; }
.controle-table { font-size: 0.8rem; }
.controle-table td { font-weight: 500; }
.controle-table code { font-size: 0.68rem; user-select: all; color: var(--cam-doux); }
