/*
 * Mots mêlés — 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 {
  --mm-panel: var(--surface-1, #16191f);
  --mm-panel-2: var(--surface-2, #1c2027);
  --mm-bordure: var(--line, #2a2f37);
  --mm-bordure-forte: var(--line-forte, #39404a);
  --mm-texte: #f1f5f9;
  --mm-doux: var(--texte-doux, #98a1ad);
  --mm-violet: #8b5cf6;
  --mm-violet-clair: #ddd6fe;
  --mm-jaune: #facc15;
  --mm-papier: #f8f5ee;
  --mm-encre: #1e1b2e;
  --mm-rouge: #f87171;
  --mm-gris: #94a3b8;
  --mm-vert: #34d399;
}

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

.setup-intro { color: var(--mm-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(--mm-violet-clair);
  margin: 0 0 10px;
}

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

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

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

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

.message-partie {
  display: none;
  margin: 0 0 16px;
  padding: 12px 16px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--mm-rouge) 12%, var(--mm-panel));
  border: 1px solid color-mix(in srgb, var(--mm-rouge) 38%, var(--mm-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(--mm-violet-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(--mm-violet) 45%, var(--mm-bordure)); text-align: center; }
.fiche-titre { margin: 0 0 4px; font-size: 1.25rem; font-weight: 800; color: var(--mm-texte); }
.fiche-theme { margin: 0 0 8px; font-size: 0.9rem; color: var(--mm-violet-clair); }
.fiche-etoiles { font-size: 1.5rem; letter-spacing: 4px; color: var(--mm-jaune); 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(--mm-bordure);
  border-radius: 999px;
  font-size: 0.84rem;
  color: var(--mm-jaune);
  white-space: nowrap;
}
.fiche-objectifs li.atteint { border-color: var(--mm-jaune); }
.fiche-objectifs strong { color: var(--mm-texte); font-weight: 600; }
.fiche-record { margin: 0 0 14px; font-size: 0.9rem; color: var(--mm-doux); }
.fiche-record strong { color: var(--mm-texte); }
.fiche-niveau .btn-lancer { margin-bottom: 8px; }
.fiche-lien { font-size: 0.86rem; color: var(--mm-violet-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(--mm-doux); font-size: 0.92rem; }
.parcours-bilan strong { color: var(--mm-texte); }

.tranche { border: 1px solid var(--mm-bordure); border-radius: 12px; margin-bottom: 8px; background: var(--mm-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(--mm-texte);
  list-style: none;
}
.tranche summary::-webkit-details-marker { display: none; }
.tranche summary small { font-weight: 600; color: var(--mm-doux); font-size: 0.8rem; text-align: right; }
.tranche[open] summary { border-bottom: 1px solid var(--mm-bordure); }
.tranche.fermee summary { color: var(--mm-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(--mm-bordure-forte);
  border-radius: 9px;
  background: var(--mm-panel-2);
  color: var(--mm-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(--mm-jaune); min-height: 0.6rem; }
.niveau:hover { border-color: var(--mm-violet); }
.niveau.choisi { border-color: var(--mm-violet); background: color-mix(in srgb, var(--mm-violet) 24%, var(--mm-panel-2)); }
.niveau.courant { border-color: var(--mm-jaune); }
.niveau.verrou { color: color-mix(in srgb, var(--mm-doux) 55%, transparent); border-color: var(--mm-bordure); background: transparent; }
.niveau.verrou:hover { border-color: var(--mm-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: #7c3aed;
  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: #6d28d9; 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(--mm-bordure-forte); color: var(--mm-texte); }
a.btn-outline, a.btn-outline:visited { color: var(--mm-texte); }
.btn-outline:hover { background: color-mix(in srgb, #fff 6%, transparent); border-color: var(--mm-violet); }

.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(--mm-bordure);
  border-radius: 8px;
  color: var(--mm-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(--mm-violet-clair); border-color: var(--mm-violet); }

.lien-bouton {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--mm-violet-clair);
  text-decoration: underline;
  cursor: pointer;
}
.lien-discret { color: var(--mm-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(--mm-rouge) 26%, transparent); border-color: var(--mm-rouge); color: #fff; }

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

#jeu {
  position: relative;
  border-radius: 18px;
  padding: 18px 18px 20px;
  background-color: color-mix(in srgb, var(--mm-violet) 9%, var(--surface-0, #0e1014));
  border: 1px solid color-mix(in srgb, var(--mm-violet) 32%, var(--mm-bordure));
}

.seance-titre { margin: 0 0 12px; text-align: center; font-size: 0.95rem; font-weight: 700; color: var(--mm-violet-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(--mm-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(--mm-doux);
  margin-top: 3px;
}
.hud-principal .hud-valeur { color: var(--mm-jaune); font-size: 1.7rem; }
#jeu.derniere-ligne-droite #hud-chrono { color: var(--mm-rouge); }

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

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

.theme-grille { margin: 0 0 8px; text-align: center; font-size: 0.88rem; color: var(--mm-doux); }
.theme-grille strong { color: var(--mm-jaune); }

/*
 * La grille : un papier clair, les traits de surligneur dessous (SVG), les
 * lettres dessus. Le SVG a le même cadre que la grille, sans écart entre les
 * cases : une case vaut une unité de son viewBox.
 */
.grille-cadre {
  position: relative;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  aspect-ratio: 1;
  border-radius: 14px;
  background: var(--mm-papier);
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.12);
  container-type: inline-size;
}
.grille-traits {
  position: absolute;
  inset: 3%;
  width: 94%;
  height: 94%;
  pointer-events: none;
  overflow: visible;
  z-index: 0;
}
.grille {
  position: absolute;
  z-index: 1;
  inset: 3%;
  display: grid;
  grid-template-columns: repeat(var(--n, 10), 1fr);
  grid-template-rows: repeat(var(--n, 10), 1fr);
  /* 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;
  outline: none;
  cursor: pointer;
}
.grille:focus-visible { box-shadow: 0 0 0 3px var(--mm-violet); border-radius: 8px; }
.case {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--mm-encre);
  font-weight: 800;
  /* La taille suit celle de la grille (unités de conteneur), et le nombre de cases. */
  font-size: calc(94cqi / var(--n, 10) * 0.56);
  line-height: 1;
  border-radius: 50%;
  -webkit-tap-highlight-color: transparent;
}
.grille.verrou { cursor: default; }
#jeu.en-decompte .case { color: transparent; }
.case.ancre { box-shadow: inset 0 0 0 3px var(--mm-violet); }
.case.curseur { box-shadow: inset 0 0 0 2px #2563eb; }
.case.ancre.curseur { box-shadow: inset 0 0 0 3px var(--mm-violet), 0 0 0 2px #2563eb; }
.case.indice { box-shadow: inset 0 0 0 3px #ea580c; }
.case.prise.indice { box-shadow: none; }
.case.mystere { background: #7c3aed; color: #fff; }

.trait { stroke-width: 0.74; stroke-linecap: round; fill: none; }
.trait-trouve { stroke: var(--mm-jaune); opacity: 0.55; }
.trait-sel { stroke: #8b5cf6; opacity: 0.45; }
.trait-ko { stroke: #ef4444; opacity: 0.4; }
.trait-manque { stroke: #64748b; opacity: 0.55; stroke-width: 0.62; stroke-dasharray: 0.18 0.16; fill: none; }

/* 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: #7c3aed;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  z-index: 2;
}

.mot-retour {
  margin: 10px 0 0;
  min-height: 1.4em;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--mm-doux);
}
.mot-retour.ok { color: var(--mm-vert); }
.mot-retour.ko { color: var(--mm-rouge); }
.mot-retour.deja { color: var(--mm-gris); }

/* La liste des mots : barrés à mesure, à la couleur de leur trait. */
.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;
}
.jeu-mots h2 {
  margin: 0 0 8px;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--mm-violet-clair);
  display: flex;
  justify-content: space-between;
}
.jeu-mots h2 span { color: var(--mm-doux); }

.liste-mots {
  list-style: none;
  margin: 0;
  padding: 0;
  columns: 2;
  column-gap: 10px;
}
.mot-liste {
  display: flex;
  flex-direction: column;
  break-inside: avoid;
  padding: 3px 6px;
  margin: 0 0 2px;
  border-radius: 6px;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--mm-texte);
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.mot-liste.trouve .mot-texte {
  text-decoration: line-through;
  text-decoration-color: var(--couleur, var(--mm-jaune));
  text-decoration-thickness: 3px;
  color: var(--mm-doux);
}
.mot-liste.aide .mot-texte::before { content: '● '; color: #fb923c; }
.mot-liste.manque { color: var(--mm-rouge); }
.mot-auteur { font-size: 0.68rem; color: var(--couleur, var(--mm-doux)); font-weight: 700; }
.mot-auteur:empty { display: none; }

.mystere-bloc { margin-top: 12px; padding-top: 10px; border-top: 1px solid color-mix(in srgb, #fff 10%, transparent); }
.mystere-titre { margin: 0 0 4px; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--mm-violet-clair); font-weight: 700; }
.mystere-titre span { color: var(--mm-doux); text-transform: none; letter-spacing: 0; }
.mystere-aide { margin: 0 0 8px; font-size: 0.76rem; color: var(--mm-doux); line-height: 1.45; }
.mystere-form { display: flex; gap: 6px; }
.mystere-form .champ { flex: 1 1 auto; min-width: 0; padding: 8px 10px; font-size: 0.88rem; text-transform: uppercase; }
.mystere-form .btn { flex: 0 0 auto; }
.mystere-retour { margin: 6px 0 0; font-size: 0.78rem; color: var(--mm-doux); min-height: 1.1em; }
.mystere-retour.ok { color: var(--mm-vert); font-weight: 700; }
.mystere-retour.ko { color: var(--mm-rouge); }

.jeu-aide { text-align: center; color: var(--mm-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), 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.86);
  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(--mm-panel);
  border: 1px solid var(--mm-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(--mm-violet-clair); }
.overlay-carte > p { color: var(--mm-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(--mm-bordure);
  background: transparent;
  color: var(--mm-doux);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}
.overlay-fermer:hover { color: var(--mm-texte); border-color: var(--mm-violet); }

.overlay-carte > .fin-etoiles { font-size: 2.2rem; letter-spacing: 8px; color: var(--mm-jaune); margin: 0 0 6px; line-height: 1; }
.overlay-carte > .fin-rang { color: var(--mm-texte); font-weight: 600; font-size: 0.95rem; }
.overlay-carte > .fin-rang.fin-rang-record { color: var(--mm-jaune); }
.overlay-carte > .fin-mystere { color: var(--mm-texte); font-size: 0.92rem; }
.overlay-carte > .fin-mystere strong { color: var(--mm-violet-clair); }

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

.fin-classement { list-style: none; margin: 0; padding: 0; border: 1px solid var(--mm-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(--mm-bordure); }
.fin-classement li:last-child { border-bottom: 0; }
.fin-classement li.moi { background: color-mix(in srgb, var(--mm-violet) 22%, transparent); }

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

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

#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(--mm-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(--mm-jaune); }
/* 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(--mm-bordure);
  border-radius: 10px;
  background: color-mix(in srgb, #000 22%, transparent);
  font-size: 0.9rem;
}
.salon-hote { color: var(--mm-violet-clair); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; }
.salon-absent { color: var(--mm-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(--mm-violet-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) 240px; gap: 16px; align-items: start; }

.classement-live { background: var(--mm-panel); border: 1px solid var(--mm-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(--mm-violet-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(--mm-texte); }
.classement-live li + li { margin-top: 2px; }
.classement-live li.moi { background: color-mix(in srgb, var(--mm-violet) 26%, transparent); }
.classement-live li.hors-top { margin-top: 8px; border-top: 1px dashed var(--mm-bordure); border-radius: 0 0 8px 8px; }
.live-pastille { flex: 0 0 auto; width: 10px; height: 10px; border-radius: 50%; background: var(--couleur, var(--mm-doux)); align-self: center; }
.live-rang { color: var(--mm-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(--mm-jaune); font-variant-numeric: tabular-nums; }

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

/* ================= 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(--mm-doux); }

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

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

.choix-format { border: 1px solid var(--mm-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(--mm-violet-clair); }

.defi-ami { border-color: color-mix(in srgb, var(--mm-jaune) 45%, var(--mm-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(--mm-jaune) 40%, var(--mm-bordure));
  border-radius: 10px;
  background: color-mix(in srgb, var(--mm-jaune) 8%, transparent);
  text-align: center;
}
.libre-resultat p { margin: 0 0 10px; font-weight: 700; color: var(--mm-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(--mm-bordure); font-size: 0.9rem; }
.stats-liste > div:last-child { border-bottom: 0; }
.stats-liste dt { color: var(--mm-doux); }
.stats-liste dd { margin: 0; font-weight: 700; color: var(--mm-texte); text-align: right; }
.stats-liste small { font-weight: 500; color: var(--mm-doux); }

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

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

/* ================= ÉCRANS BAS (portable 1366 × 768) ================= */
@media (min-width: 721px) and (max-height: 860px) {
  body.mm-en-jeu #app { padding-top: 12px; padding-bottom: 12px; }
  body.mm-en-jeu .jeu-banner { margin-bottom: 10px; padding-top: 8px; padding-bottom: 8px; }
  body.mm-en-jeu .banner-deco { display: none; }
  .grille-cadre { max-width: min(520px, calc(100vh - 250px)); }
  .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; }
  .niveaux { grid-template-columns: repeat(5, minmax(0, 1fr)); }

  /* En partie, tout l'écran va au jeu : ni banner, ni barre de compte. */
  body.mm-en-jeu { padding-top: 0; }
  body.mm-en-jeu #app { padding: 8px 8px 14px; }
  body.mm-en-jeu .jeu-banner,
  body.mm-en-jeu .auth-nav,
  body.mm-en-jeu footer,
  body.mm-en-jeu .arene-etat { display: none !important; }
  #jeu { padding: 10px 8px 12px; border-radius: 14px; }
  .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.35rem; }
  .hud-objectif { margin-bottom: 6px; font-size: 0.76rem; }

  /* La grille prend la largeur, la liste des mots passe dessous. */
  .jeu-corps { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .grille-cadre { max-width: min(100%, 64vh); border-radius: 10px; }
  .liste-mots { columns: 3; }
  .mot-liste { font-size: 0.8rem; padding: 2px 4px; }
  .jeu-aide { display: none; }
  .actions-jeu { margin-top: 10px; }
}

@media (max-width: 420px) {
  .liste-mots { columns: 2; }
}

/* ================= TÉLÉPHONE COUCHÉ ================= */
@media (orientation: landscape) and (max-height: 520px) {
  body.mm-en-jeu { padding-top: 0; }
  body.mm-en-jeu #app { padding: 6px 12px; max-width: none; }
  body.mm-en-jeu .jeu-banner,
  body.mm-en-jeu .auth-nav,
  body.mm-en-jeu footer,
  body.mm-en-jeu .arene-etat,
  body.mm-en-jeu .classement-live { display: none !important; }
  .jeu-corps { grid-template-columns: min(calc(100vh - 24px), 55vw) minmax(0, 1fr); }
  .grille-cadre { max-width: none; }
  .theme-grille { display: none; }
  .jeu-hud { gap: 6px; margin-bottom: 4px; }
  .hud-bloc { padding: 3px 4px; }
  .hud-valeur { font-size: 1.05rem; }
  .hud-label { font-size: 0.54rem; margin-top: 1px; }
  .hud-objectif { margin-bottom: 4px; font-size: 0.74rem; }
  .jeu-aide { display: none; }
}

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

/* ================= IMPRESSION (entraînement) ================= */
/* La grille et sa liste de mots, en noir sur blanc, sur une page. */
@media print {
  body { background: #fff !important; color: #000; padding: 0; }
  body * { visibility: hidden; }
  #jeu, #jeu * { visibility: visible; }
  #jeu { position: absolute; left: 0; top: 0; width: 100%; border: 0; background: #fff; padding: 0; }
  #jeu .jeu-hud, #jeu .hud-objectif, #jeu .actions-jeu, #jeu .libre-resultat, #jeu .mot-retour,
  #jeu .jeu-aide, #jeu .mystere-form, #jeu .mystere-retour, #jeu .grille-traits { display: none !important; }
  .seance-titre, .theme-grille, .theme-grille strong, .jeu-mots h2, .jeu-mots h2 span, .mystere-titre, .mystere-aide { color: #000 !important; }
  .jeu-corps { display: block; }
  .grille-cadre { max-width: 16cm; background: #fff; box-shadow: none; border: 1px solid #000; }
  .case { color: #000 !important; background: none !important; box-shadow: none !important; }
  .jeu-mots { background: none; border: 0; margin-top: 0.6cm; }
  .liste-mots { columns: 4; }
  .mot-liste, .mot-liste .mot-texte { color: #000 !important; text-decoration: none !important; }
}

/* ================= 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(--mm-doux); }
