/* ============================================================
   STYLE DES SALONS, communs à tous les jeux
   (couleurs, boutons et champs : voir /style.css ;
    ce qui est propre au quiz : /jeux/quiz/quiz.css)
   ============================================================ */

/* Dans un salon, la page prend toute la hauteur : bandeau en haut, jeu en dessous */
body.en-salon { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }

/* ---------- Bandeau : infos du salon ---------- */
.entete-salon { display: flex; align-items: center; gap: 10px; }
.salon-nom { display: flex; align-items: center; gap: 6px; font-weight: 600; margin-right: 6px; }
.code-salon {
  padding: 6px 12px; font-weight: 500;
  background: rgba(243, 236, 216, 0.12); color: var(--beige);
  box-shadow: inset 0 0 0 1px rgba(243, 236, 216, 0.5);
}
.code-salon:hover { background: rgba(243, 236, 216, 0.25); }
.code-salon strong {
  background: var(--beige); color: var(--fougere-nuit);
  padding: 1px 8px; border-radius: 6px; letter-spacing: 2px;
}

/* ===================== LOBBY ===================== */
#lobby { max-width: 1180px; margin: 0 auto; padding: 32px 28px 64px; }

.lobby-hero {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; align-items: flex-start; gap: 10px;
  padding: 36px 32px; margin-bottom: 24px; border-radius: 22px;
  background: linear-gradient(135deg, var(--fougere), var(--fougere-nuit));
  color: var(--beige);
  box-shadow: var(--ombre-forte);
}
.lobby-hero h1 { color: var(--beige-clair); font-size: clamp(2.4rem, 5vw, 3.4rem); font-weight: 800; }
.lobby-hero p { opacity: 0.9; font-size: 1.1em; max-width: 520px; }
.lobby-hero .pastille { background: rgba(243, 236, 216, 0.15); color: var(--beige); }
.lobby-fronde {
  position: absolute; width: 220px; right: 20px; top: -70px;
  transform: rotate(40deg); opacity: 0.25; filter: brightness(2.2) saturate(0.6);
}

.lobby-grille { display: grid; grid-template-columns: 400px 1fr; gap: 24px; align-items: start; }
.lobby-gauche { display: flex; flex-direction: column; gap: 20px; }

/* Pseudo + aperçu de l'avatar */
.profil { display: flex; align-items: center; gap: 14px; }
.profil input { flex: 1; min-width: 0; font-size: 1.1em; }
.avatar-apercu {
  width: 54px; height: 54px; flex: none; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: var(--fougere); color: var(--beige-clair);
  font-family: var(--police-titre); font-weight: 800; font-size: 1.6em;
  box-shadow: 0 3px 0 var(--fougere-nuit);
}

.avatar-apercu img { width: 100%; height: 100%; object-fit: cover; border-radius: 12px; }
.profil input[readonly] { background: var(--fougere-pale); border-color: var(--fougere-pale); font-weight: 700; }
.note-compte { margin-top: 10px; font-size: 0.92em; color: var(--texte-doux); }

/* Choix Public / Privé : deux grandes tuiles */
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.option input { position: absolute; opacity: 0; pointer-events: none; } /* la vraie case est cachée */
.option span {
  display: flex; flex-direction: column; gap: 2px; height: 100%;
  padding: 14px; border-radius: 12px; cursor: pointer;
  border: 2px solid var(--beige-fonce); background: #fff;
  transition: border-color 0.15s, background 0.15s;
}
.option .icone { width: 22px; height: 22px; color: var(--fougere); margin-bottom: 6px; }
.option small { color: var(--texte-doux); }
.option input:checked + span { border-color: var(--fougere); background: var(--fougere-pale); }
.option input:focus-visible + span { outline: 3px solid var(--ocre); outline-offset: 2px; }
.bouton-large { width: 100%; }

.ligne { display: flex; gap: 8px; }
.ligne input { flex: 1; min-width: 0; }
#code { text-transform: uppercase; letter-spacing: 6px; font-weight: 700; font-size: 1.2em; text-align: center; }

/* Liste des salons publics */
.lobby-salons { min-height: 420px; }
.lobby-salons .bloc-titre { justify-content: space-between; }
#listeSalons { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.salon {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 14px; border-radius: 12px;
  background: #fff; border: 1px solid var(--beige-fonce);
  transition: transform 0.15s, box-shadow 0.15s;
}
.salon:hover { transform: translateY(-2px); box-shadow: var(--ombre); }
.salon-initiale {
  width: 46px; height: 46px; flex: none; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: var(--fougere-pale); color: var(--fougere-fonce);
  font-family: var(--police-titre); font-weight: 800; font-size: 1.3em;
}
.salon-infos { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.salon-titre { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pastille-jeu { background: var(--fougere); color: var(--beige-clair); }
.jauge { height: 6px; border-radius: 999px; background: var(--beige-fonce); overflow: hidden; max-width: 220px; }
.jauge span { display: block; height: 100%; background: var(--mousse); border-radius: 999px; }

.vide { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 40px 0; }
.vide img { width: 70px; opacity: 0.35; transform: rotate(-15deg); margin-bottom: 8px; }

/* ===================== JEU : 3 colonnes ===================== */
#jeu { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 290px 320px; }

/* Colonne de la partie : les pastilles en haut, le reste centré */
#zoneJeu {
  display: flex; flex-direction: column; align-items: center;
  padding: 18px 28px; overflow-y: auto; text-align: center;
}
.barre-haut { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
#centre { /* prend toute la hauteur restante et centre son contenu verticalement */
  flex: 1; width: 100%; max-width: 640px;
  display: flex; flex-direction: column; justify-content: center; gap: 20px;
}

/* Salle d'attente */
.salle-attente {
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  padding: 32px; border-radius: 22px;
  background: var(--beige-clair); border: 1px solid var(--beige-fonce); box-shadow: var(--ombre);
}
.compte { /* grand rond avec le compte à rebours */
  width: 110px; height: 110px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 30% 30%, var(--mousse), var(--fougere));
  color: var(--beige-clair); font-family: var(--police-titre); font-weight: 800; font-size: 3em;
  box-shadow: 0 0 0 10px var(--fougere-pale), var(--ombre-forte);
}
#attente { font-weight: 600; font-size: 1.1em; color: var(--fougere-fonce); }
.invitation { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-top: 4px; }
.code-geant {
  font-family: var(--police-titre); font-size: 1.8em; font-weight: 800; letter-spacing: 8px;
  padding: 8px 20px; border-radius: 12px;
  background: var(--fougere-pale); color: var(--fougere-nuit); box-shadow: inset 0 0 0 2px var(--fougere);
}
.code-geant:hover { background: #d3e1c2; }
.code-geant .icone { width: 20px; height: 20px; }

/* Petite animation d'apparition (podium, et jeux) */
@keyframes apparait { from { opacity: 0; transform: scale(0.9); } }

/* Fin de partie : gagnant et podium */
#fin { display: flex; flex-direction: column; align-items: center; animation: apparait 0.4s ease-out; }
.titre-fin { font-weight: 700; color: var(--texte-doux); text-transform: uppercase; letter-spacing: 2px; }
#gagnant {
  font-family: var(--police-titre); font-size: clamp(2.6rem, 6vw, 4rem); font-weight: 800;
  color: var(--ocre); margin: 6px 0; overflow-wrap: anywhere;
}
#scoreGagnant { font-size: 1.15em; }
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 10px; margin-top: 22px; }
.marche { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 120px; }
.marche-nom { font-weight: 700; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.marche-score { font-size: 0.9em; color: var(--texte-doux); }
.marche-bloc {
  width: 100%; border-radius: 10px 10px 0 0;
  display: flex; align-items: flex-start; justify-content: center; padding-top: 10px;
  font-family: var(--police-titre); font-weight: 800; font-size: 1.8em; color: var(--beige-clair);
}
.marche-1 .marche-bloc { height: 110px; background: linear-gradient(var(--ocre), #a87b1f); }
.marche-2 .marche-bloc { height: 80px; background: linear-gradient(var(--mousse), var(--fougere)); }
.marche-3 .marche-bloc { height: 56px; background: linear-gradient(var(--fougere), var(--fougere-fonce)); }

/* Confettis de la victoire */
.confettis { position: fixed; inset: 0; z-index: 40; pointer-events: none; overflow: hidden; }
.confettis span {
  position: absolute; top: -20px; width: 9px; height: 15px; border-radius: 2px;
  animation-name: tombe; animation-timing-function: linear; animation-fill-mode: forwards;
}
@keyframes tombe { to { transform: translateY(110vh) rotate(720deg); } }

/* ---------- Colonne des joueurs ---------- */
#zoneJoueurs { padding: 16px 12px; overflow-y: auto; min-height: 0; }
#cartes { display: flex; flex-direction: column; gap: 10px; }
.carte {
  display: flex; gap: 10px; align-items: center;
  padding: 7px 10px 7px 7px; border-radius: 12px;
  background: var(--fougere); color: var(--beige-clair);
  border: 2px solid var(--fougere-fonce);
  box-shadow: 0 3px 0 var(--fougere-nuit);
  transition: background 0.2s, transform 0.2s;
}
.carte.moi { border-color: var(--beige-fonce); }
.carte.meneur { border-color: var(--ocre); }          /* premier du classement */
.carte.trouve { background: var(--fougere-fonce); }   /* a trouvé cette manche */
.carte.trouve .etat { color: var(--ocre-pale); font-weight: 700; }
.cadre { position: relative; flex: none; } /* repère pour placer le badge */
.avatar {
  width: 56px; height: 56px; border-radius: 8px; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background: var(--fougere-nuit); color: var(--beige);
  font-family: var(--police-titre); font-weight: 800; font-size: 1.6em;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.badge { /* le score, posé sur le coin en bas à gauche de l'image */
  position: absolute; left: -4px; bottom: -4px;
  background: var(--beige-clair); color: var(--fougere-nuit);
  font-weight: 800; font-size: 0.85em; padding: 0 6px; border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}
.carte.meneur .badge { background: var(--ocre); }
.infos { flex: 1; min-width: 0; }
.nom { display: flex; align-items: center; gap: 6px; }
.nom strong { font-size: 1.05em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role { /* l'étiquette "admin" à côté du pseudo */
  flex: none; font-size: 0.65em; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
  background: var(--beige); color: var(--fougere-nuit); padding: 1px 6px; border-radius: 4px;
}
.etat { font-size: 0.9em; font-style: italic; opacity: 0.95; overflow-wrap: anywhere; }
.carte.trouve .etat { font-style: normal; } /* temps et points : pas en italique */

/* Spectateurs : de petites étiquettes sous les cartes */
#zoneSpectateurs { margin-top: 18px; }
#zoneSpectateurs h4 {
  font-size: 0.75em; text-transform: uppercase; letter-spacing: 1px;
  color: var(--texte-doux); margin-bottom: 8px;
}
#listeSpectateurs { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
#listeSpectateurs li {
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding: 3px 10px; border-radius: 999px; font-size: 0.9em; font-weight: 600;
  background: var(--beige-clair); border: 1px solid var(--beige-fonce); color: var(--fougere-fonce);
}
#listeSpectateurs li.moi { border-color: var(--fougere); }
#listeSpectateurs .role { margin-left: 6px; }

/* Bandeau "Tu es spectateur" en haut de la partie */
.bandeau-spectateur {
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 10px;
  margin-top: 12px; padding: 8px 8px 8px 16px; border-radius: 16px;
  background: var(--fougere-pale); color: var(--fougere-nuit); font-weight: 600;
  box-shadow: inset 0 0 0 2px var(--fougere);
}
.bandeau-spectateur .icone { width: 20px; height: 20px; }

/* ---------- Chat ---------- */
#zoneChat {
  display: flex; flex-direction: column; min-height: 0;
  padding: 16px; background: var(--beige-clair); border-left: 1px solid var(--beige-fonce);
}
#zoneChat h3 { font-size: 1.2em; margin-bottom: 10px; }
#messages {
  list-style: none; margin: 0; padding: 0; flex: 1; overflow-y: auto;
  display: flex; flex-direction: column; gap: 6px; overflow-wrap: anywhere;
}
#messages li {
  align-self: flex-start; max-width: 100%;
  padding: 7px 12px; border-radius: 4px 14px 14px 14px;
  background: #fff; border: 1px solid var(--beige-fonce);
}
#messages li strong { display: block; font-size: 0.8em; color: var(--fougere); }
#messages li.systeme { /* messages automatiques */
  align-self: center; text-align: center;
  background: transparent; border: none; padding: 2px 6px;
  font-size: 0.85em; font-style: italic; color: var(--texte-doux);
}
#formChat { display: flex; gap: 6px; margin-top: 10px; }
#formChat input { flex: 1; min-width: 0; }
#formChat .bouton-icone { width: 44px; height: 44px; }

/* ---------- Tiroir des paramètres : caché à gauche, seule la poignée dépasse ---------- */
#tiroir {
  position: fixed; top: 0; bottom: 0; left: 0; width: 320px; z-index: 30;
  background: var(--beige-clair); border-right: 1px solid var(--beige-fonce);
  transform: translateX(-100%);   /* décalé de toute sa largeur vers la gauche */
  transition: transform 0.25s;    /* glissement en douceur */
}
#tiroir.ouvert { transform: translateX(0); box-shadow: 4px 0 30px rgba(31, 51, 25, 0.25); }
#panneau { height: 100%; overflow-y: auto; padding: 24px 22px; display: flex; flex-direction: column; gap: 18px; }
#panneau h3 { font-size: 1.5em; }
.reglage { display: flex; flex-direction: column; gap: 8px; }
.reglages-jeu { display: flex; flex-direction: column; gap: 18px; }
.reglage > span { display: flex; justify-content: space-between; font-weight: 600; }
.reglage input[type="range"] { width: 100%; }
.puces { display: flex; flex-wrap: wrap; gap: 6px; }
.puce input { position: absolute; opacity: 0; pointer-events: none; }
.puce span {
  display: inline-block; padding: 5px 12px; border-radius: 999px; cursor: pointer;
  border: 2px solid var(--beige-fonce); background: #fff; font-size: 0.9em; font-weight: 600;
}
.puce input:checked + span { background: var(--fougere); border-color: var(--fougere); color: var(--beige-clair); }
.puce input:focus-visible + span { outline: 3px solid var(--ocre); outline-offset: 2px; }
#poignee { /* la petite flèche collée au bord droit du tiroir */
  position: absolute; top: 50%; right: -36px; transform: translateY(-50%);
  width: 36px; height: 64px; padding: 0;
  border-radius: 0 12px 12px 0; font-size: 1.5em;
  box-shadow: 3px 0 10px rgba(31, 51, 25, 0.2);
}

/* ---------- Écrans moyens : chat plus étroit ---------- */
@media (max-width: 1150px) {
  #jeu { grid-template-columns: 1fr 250px 260px; }
  .lobby-grille { grid-template-columns: minmax(0, 1fr); } /* minmax : la colonne ne déborde jamais de l'écran */
}

/* ---------- Petit écran (téléphone) : tout passe en une colonne ---------- */
/* De haut en bas : la question, les joueurs (en bande qu'on fait glisser), le chat */
@media (max-width: 800px) {
  body.en-salon { height: auto; overflow: visible; }
  .salon-nom { display: none; }
  #lobby { padding: 20px 16px 48px; }
  .options { grid-template-columns: 1fr; }

  /* Bandeau du salon : on garde l'essentiel, en plus petit, sur une seule ligne */
  body.en-salon .burger { display: none; }       /* pas de menu pendant une partie */
  body.en-salon .logo { font-size: 0; gap: 0; }  /* juste la fougère, sans le nom */
  body.en-salon .entete { gap: 8px; }
  .entete-salon { gap: 6px; }
  .entete-salon button { padding: 7px 10px; font-size: 0.9em; }
  .entete-salon .bouton-icone { width: 34px; height: 34px; padding: 6px; }
  .code-libelle, .code-salon .icone { display: none; } /* "Code" et l'icône : le code suffit */
  .code-salon strong { letter-spacing: 1px; }

  /* minmax(0, 1fr) : la colonne ne s'élargit pas pour suivre la bande des joueurs */
  #jeu { grid-template-columns: minmax(0, 1fr); }
  #zoneJeu { padding: 12px 16px 8px; }
  #centre { justify-content: flex-start; gap: 14px; margin-top: 14px; }
  .salle-attente { padding: 22px 16px; }
  .compte { width: 84px; height: 84px; font-size: 2.4em; }
  .code-geant { font-size: 1.5em; letter-spacing: 6px; }
  .marche { width: 30vw; max-width: 120px; }
  #gagnant { font-size: 2rem; } /* un pseudo de 20 caractères tient sur une ligne */

  /* Les joueurs : une bande horizontale de petites cartes */
  #zoneJoueurs { padding: 6px 0 12px; overflow: visible; }
  #cartes {
    flex-direction: row; gap: 8px; overflow-x: auto;
    padding: 4px 16px 8px; scroll-snap-type: x proximity; scroll-padding: 0 16px;
  }
  .carte { flex: 0 0 auto; width: 160px; padding: 5px 8px 5px 5px; scroll-snap-align: start; }
  .avatar { width: 42px; height: 42px; font-size: 1.25em; }
  .nom strong { font-size: 0.95em; }
  .etat { font-size: 0.8em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #zoneSpectateurs { margin-top: 6px; padding: 0 16px; }

  #zoneChat { border-left: none; border-top: 1px solid var(--beige-fonce); height: 45vh; min-height: 280px; }

  /* Bandeau spectateur : sur une ligne, le bouton à droite */
  .bandeau-spectateur { flex-wrap: nowrap; text-align: left; font-size: 0.9em; line-height: 1.3; padding: 8px 8px 8px 12px; }
  .bandeau-spectateur button { flex: none; padding: 9px 16px; }

  /* Tiroir des paramètres : pas plus large que l'écran, poignée plus discrète */
  #tiroir { width: min(320px, 85vw); }
  #poignee { width: 28px; height: 52px; right: -28px; font-size: 1.2em; }
}

/* ---------- Carte d'invitation (arrivée par un lien /salon/?salon=CODE) ---------- */
/* Tant qu'elle est affichée, le reste du lobby est caché : pas de risque de créer un autre salon */
#lobby.invite .lobby-hero, #lobby.invite .lobby-grille { display: none; }
.carte-invitation {
  max-width: 520px; margin: 24px auto; display: flex; flex-direction: column; align-items: flex-start; gap: 12px;
}
.carte-invitation h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); line-height: 1.15; }
.carte-invitation .ligne { width: 100%; }
.carte-invitation .ligne input { flex: 1; min-width: 0; }
.carte-invitation .erreur:empty { display: none; } /* pas de trou quand il n'y a pas d'erreur */

/* ---------- Salle d'attente : boutons de l'admin et règles du jeu ---------- */
.actions-admin { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.actions-admin:not(:has(button:not([hidden]))) { display: none; } /* rien à montrer : pas de place vide */
#btnParametres { display: inline-flex; align-items: center; gap: 8px; }
#btnParametres[hidden] { display: none; }
.regles {
  max-width: 560px; text-align: left; padding: 12px 18px; border-radius: 14px;
  background: var(--beige-clair); border: 1px solid var(--beige-fonce);
}
.regles ul { margin: 6px 0 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
.regles li { font-size: 0.95em; }

/* La languette du tiroir : la flèche et le mot "Paramètres" écrit à la verticale */
#poignee { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; height: auto; padding: 12px 0; }
.poignee-texte { writing-mode: vertical-rl; transform: rotate(180deg); font-size: 0.55em; font-weight: 700; letter-spacing: 1px; }

/* ---------- Téléphone ---------- */
@media (max-width: 800px) {
  .carte-invitation { margin: 0 auto; }
  /* L'étiquette "admin" devient une petite étoile : le pseudo garde la place */
  .carte .role { font-size: 0; padding: 0 3px; background: none; }
  .carte .role::before { content: "★"; font-size: 13px; color: var(--ocre); }
  #poignee { height: auto; padding: 10px 0; }
  .poignee-texte { font-size: 0.6em; }
}

/* Pendant une partie, pas de pied de page (l'écran de jeu prend toute la place) */
body.en-salon .pied { display: none; }
