/* === Petit BAC — socle des pages de jeu (solo, multijoueur, défi du jour) ===
   Tout ce que les trois pages ont en commun : cadre, barre de manche, grille de
   saisie, STOP, résultats, fenêtres. Chaque page ajoute sa part dans solo.css,
   multi.css ou defi.css. Les couleurs --color-* viennent du thème du jeu. */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
/* L'attribut hidden doit toujours gagner : sans cette règle, un bouton .btn (display: inline-flex)
   masqué par le script restait affiché, par exemple « Revanche » chez un invité. */
[hidden] { display: none !important; }
body {
  font-family: 'Inter', sans-serif;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  background: #062a20;
  color: #e2e8f0;
  /* Le haut est réservé à la barre de compte du réseau, qui flotte par-dessus la page */
  padding: 64px 16px 16px;
}
#app {
  position: relative; z-index: 1;
  background: #0b3327;
  border: 1px solid rgba(110, 231, 183, 0.18);
  border-radius: 24px;
  padding: 24px 28px 24px;
  max-width: 860px;
  width: 100%;
  text-align: center;
}
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.back-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 6px;
  font-size: 0.9rem;
  color: var(--color-accent);
  text-decoration: none;
  font-weight: 600;
}
.back-link:hover { color: var(--color-light); }
h1 { font-size: 1.4rem; font-weight: 800; color: var(--color-light); }
.top-droite { display: flex; align-items: center; gap: 8px; min-width: 70px; justify-content: flex-end; }
.diff-label { font-size: 0.8rem; color: #94a3b8; }
.btn-son {
  width: 44px; height: 44px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  font-size: 1.1rem;
  cursor: pointer;
  color: #e2e8f0;
}
.btn-son[aria-pressed="false"] { opacity: 0.5; }

/* Boutons */
.btn {
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  min-height: 44px;
  padding: 12px 24px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--color-btn1); }
.btn-primary:hover:not(:disabled) { background: var(--color-btn2); }
.btn-secondary { background: #3b4a5c; }
.btn-secondary:hover:not(:disabled) { background: #475569; }
.btn-lien { background: none; border: none; color: var(--color-accent); font: inherit; font-weight: 600; cursor: pointer; text-decoration: underline; min-height: 44px; }

/* Barre de manche : collée en haut pendant la saisie, pour que la lettre et le chrono
   restent visibles quand le clavier du téléphone occupe la moitié de l'écran */
.barre-manche {
  position: sticky;
  top: 0;
  z-index: 20;
  background: #0b3327;
  padding: 6px 0 2px;
  margin-bottom: 12px;
}
.info-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 10px;
}
.info-cell {
  padding: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  text-align: center;
}
.info-cell .label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #94a3b8;
  margin-bottom: 2px;
}
.info-cell .value { font-size: 1.3rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.info-cell.manche .value { color: #cbd5e1; }
.info-cell.lettre .value { color: var(--color-accent); font-size: 1.7rem; line-height: 1.1; }
.info-cell.chrono .value { color: var(--color-light); }
.info-cell.points .value { color: #fbbf24; }
.info-cell.chrono.urgent { border-color: rgba(248, 113, 113, 0.6); }
.info-cell.chrono.urgent .value { color: #f87171; }

/* Bandeau de pression : qui est le plus avancé */
.leader-bandeau {
  padding: 9px 14px;
  background: rgba(110, 231, 183, 0.1);
  border: 1px solid rgba(110, 231, 183, 0.3);
  border-radius: 10px;
  font-size: 0.92rem;
  color: #e2e8f0;
  min-height: 42px;
  line-height: 1.4;
}
.leader-bandeau strong { color: var(--color-accent); }
.leader-bandeau.je-mene { background: rgba(110, 231, 183, 0.18); border-color: rgba(110, 231, 183, 0.5); }
.leader-bandeau.danger { background: rgba(251, 191, 36, 0.14); border-color: rgba(251, 191, 36, 0.5); }
.leader-bandeau.danger strong { color: #fbbf24; }

/* Grille de saisie */
.categories {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px 14px;
  margin-bottom: 16px;
  text-align: left;
}
.cat-row { display: flex; flex-direction: column; gap: 4px; }
.cat-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-accent);
}
.cat-input {
  font-family: 'Inter', sans-serif;
  /* 16 px au moins : en dessous, Safari zoome sur le champ à chaque prise de focus */
  font-size: 1rem;
  min-height: 46px;
  padding: 11px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  color: #e2e8f0;
  outline: none;
}
.cat-input:focus { border-color: var(--color-mid); box-shadow: 0 0 0 2px rgba(52, 211, 153, 0.25); }
.cat-input.ok { border-color: rgba(52, 211, 153, 0.7); }
.cat-input.ko { border-color: rgba(239, 68, 68, 0.7); }
.cat-input:disabled { opacity: 0.55; }

.btn-stop {
  font-family: 'Inter', sans-serif;
  font-size: 1.3rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  min-height: 54px;
  padding: 14px 48px;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  color: #fff;
  background: #dc2626;
}
.btn-stop:hover:not(:disabled) { background: #ef4444; }
.btn-stop:disabled { opacity: 0.35; cursor: not-allowed; }
.stop-hint { font-size: 0.84rem; color: #94a3b8; margin-top: 10px; min-height: 1.3em; }
.stop-hint.erreur { color: #fca5a5; }

/* Résultats de manche */
.resultats-titre { font-size: 1.15rem; font-weight: 800; margin-bottom: 12px; color: var(--color-light); }
.res-bloc, .vote-cat {
  margin-bottom: 14px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 12px;
  text-align: left;
}
.res-ligne {
  display: grid;
  grid-template-columns: minmax(110px, 170px) 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 7px 8px;
  border-radius: 8px;
  font-size: 0.92rem;
}
.res-ligne:nth-child(odd) { background: rgba(255, 255, 255, 0.025); }
.res-cat { font-weight: 600; color: #cbd5e1; }
.res-reponse { color: #e2e8f0; overflow-wrap: anywhere; }
.res-reponse .vide, .vote-reponse .vide { color: #64748b; font-style: italic; }
.res-sous { display: block; font-size: 0.8rem; color: #94a3b8; margin-top: 2px; }
.res-sous strong { color: #fbbf24; font-weight: 600; }
.res-ligne.statut-invalide .res-reponse, .res-ligne.statut-veto .res-reponse { text-decoration: line-through; color: #f87171; }
.res-droite { display: flex; align-items: center; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.btn-confirmer {
  font-family: 'Inter', sans-serif;
  min-height: 40px;
  padding: 6px 12px;
  background: rgba(251, 191, 36, 0.14);
  border: 1px solid rgba(251, 191, 36, 0.45);
  border-radius: 8px;
  color: #fcd34d;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}
.btn-confirmer:hover { background: rgba(251, 191, 36, 0.24); }

.badge-points {
  font-size: 0.78rem;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 20px;
  min-width: 52px;
  text-align: center;
  white-space: nowrap;
}
.badge-seul { background: rgba(251, 191, 36, 0.18); color: #fde68a; border: 1px solid rgba(251, 191, 36, 0.45); }
.badge-unique { background: rgba(52, 211, 153, 0.18); color: #6ee7b7; border: 1px solid rgba(52, 211, 153, 0.35); }
.badge-double { background: rgba(148, 163, 184, 0.16); color: #cbd5e1; border: 1px solid rgba(148, 163, 184, 0.35); }
.badge-veto, .badge-invalide { background: rgba(239, 68, 68, 0.12); color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.25); }
.badge-vide { background: rgba(100, 116, 139, 0.12); color: #94a3b8; border: 1px solid rgba(100, 116, 139, 0.25); }

.scores-cumules {
  margin-top: 18px;
  padding: 14px;
  background: rgba(110, 231, 183, 0.05);
  border: 1px solid rgba(110, 231, 183, 0.15);
  border-radius: 12px;
}
.scores-cumules h3 { font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.6px; color: var(--color-accent); margin-bottom: 8px; }
.score-ligne {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 5px 8px;
  border-radius: 8px;
  font-size: 0.9rem;
}
.score-ligne.moi { background: rgba(110, 231, 183, 0.12); font-weight: 600; }
.score-ligne.absent { opacity: 0.55; }
.score-ligne .s-rang { font-weight: 800; color: #94a3b8; }
.score-ligne .s-pseudo { text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-ligne .s-points { font-weight: 800; color: #fbbf24; }
.resultats-actions { margin-top: 16px; display: flex; gap: 10px; justify-content: center; align-items: center; flex-wrap: wrap; }
.prochaine-info { font-size: 0.88rem; color: #94a3b8; }

/* Fenêtres */
.overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.72);
  z-index: 100;
  justify-content: center;
  align-items: center;
  padding: 16px;
}
.overlay.visible { display: flex; }
.countdown-box { text-align: center; }
.countdown-num { font-size: 8rem; font-weight: 900; color: var(--color-light); line-height: 1; }
.countdown-msg { color: #cbd5e1; font-size: 1.1rem; margin-top: 10px; }

.overlay-box {
  position: relative;
  background: #082820;
  border: 1px solid rgba(110, 231, 183, 0.25);
  border-radius: 20px;
  padding: 28px;
  text-align: center;
  max-width: 520px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}
.overlay-fermer {
  position: absolute;
  top: 8px; right: 8px;
  width: 44px; height: 44px;
  background: none;
  border: none;
  border-radius: 10px;
  color: #94a3b8;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}
.overlay-fermer:hover { background: rgba(255, 255, 255, 0.08); color: #e2e8f0; }
.overlay-box h2 { font-size: 1.5rem; font-weight: 800; margin: 0 36px 12px; color: var(--color-light); }
.fin-msg { color: #cbd5e1; margin-bottom: 10px; line-height: 1.5; }
.fin-rang { color: #fbbf24; font-weight: 700; margin-bottom: 10px; }
.fin-rang a, .fin-lien { color: var(--color-accent); font-weight: 600; }
.classement-final { margin: 14px 0; }
.classement-ligne {
  display: grid;
  grid-template-columns: 44px 1fr 90px;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.92rem;
  margin-bottom: 4px;
  background: rgba(255, 255, 255, 0.04);
}
.classement-ligne.moi { background: rgba(110, 231, 183, 0.14); border: 1px solid rgba(110, 231, 183, 0.35); }
.classement-ligne .c-rang { font-weight: 800; }
.classement-ligne .c-pseudo { text-align: left; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.classement-ligne .c-points { font-weight: 800; color: var(--color-accent); text-align: right; }
.fin-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }
.fin-note { font-size: 0.85rem; color: #94a3b8; margin-top: 10px; }
.cta-connexion {
  margin-top: 14px;
  padding: 12px;
  background: rgba(110, 231, 183, 0.06);
  border: 1px solid rgba(110, 231, 183, 0.2);
  border-radius: 10px;
  font-size: 0.88rem;
  color: #cbd5e1;
  line-height: 1.5;
}
.cta-connexion a { color: var(--color-accent); font-weight: 600; }
.bouton-rouvrir { margin-top: 16px; }

/* Message bref en bas d'écran (veto refusé, lien copié...) */
.pb-toast {
  position: fixed;
  left: 50%; bottom: 24px;
  transform: translateX(-50%);
  z-index: 200;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  color: #e2e8f0;
  font-size: 0.9rem;
}
.pb-toast[hidden] { display: none; }

/* Blocs latéraux du réseau (PC) : masqués pendant la partie, de retour à l'écran de réglage et à la fin */
body.pb-en-jeu .bandeau-infos-wrap,
body.pb-en-jeu .bloc-jeux-une-wrap { display: none !important; }

@media (max-width: 640px) {
  body { padding: 56px 10px 12px; }
  #app { padding: 14px 14px 18px; border-radius: 18px; }
  h1 { font-size: 1.1rem; }
  .info-bar { gap: 6px; margin-bottom: 8px; }
  .info-cell { padding: 6px 4px; }
  .info-cell .label { font-size: 0.75rem; letter-spacing: 0; }
  .info-cell .value { font-size: 1.05rem; }
  .info-cell.lettre .value { font-size: 1.4rem; }
  .leader-bandeau { font-size: 0.86rem; padding: 7px 10px; min-height: 0; }
  .categories { grid-template-columns: 1fr; }
  .countdown-num { font-size: 6rem; }
  .res-ligne { grid-template-columns: minmax(84px, 112px) 1fr auto; font-size: 0.86rem; gap: 6px; }
  .btn-stop { width: 100%; }
  .overlay-box { padding: 22px 16px; }
}

/* Téléphone tenu en largeur : avec le clavier ouvert il ne reste qu'une bande de
   quelques lignes. On réduit la barre à une ligne et on le dit. */
@media (max-height: 460px) and (orientation: landscape) {
  body { padding-top: 8px; }
  .barre-manche .info-cell .label { display: none; }
  .barre-manche .info-cell { padding: 3px 4px; }
  .barre-manche .leader-bandeau { display: none; }
  .categories { grid-template-columns: repeat(2, 1fr); }
  .conseil-portrait { display: block; }
}
.conseil-portrait { display: none; font-size: 0.82rem; color: #fcd34d; margin-bottom: 8px; }

@media (prefers-reduced-motion: no-preference) {
  .countdown-num { animation: pb-compte 0.5s ease-out; }
}
@keyframes pb-compte {
  from { transform: scale(0.6); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
