/*
 * Flipper — pages de jeu (solo, défi) : écran de préparation et zone de jeu.
 * Pendant la partie, la zone de jeu couvre tout l'écran : un flipper se joue
 * en hauteur, chaque pixel vertical compte.
 */

/*
 * Hors partie, #app reste à 800 px : au-delà, les blocs latéraux fixes (Infos,
 * Jeux à la une) recouvrent le contenu. Padding horizontal de 24 px au moins :
 * le banner partagé sort du conteneur avec des marges négatives calées dessus.
 */
* { box-sizing: border-box; }

body.page-flipper {
  margin: 0;
  background: #0d0b1a;
  color: #f1f5f9;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}
/* Un display posé par une classe (.fl-btn…) ne doit jamais rendre visible un élément `hidden`. */
.page-flipper [hidden] { display: none !important; }
.page-flipper #app { max-width: 800px; margin: 0 auto; padding: 28px 24px 40px; }
.page-flipper h1 { font-size: 1.6rem; color: #fde68a; margin: 8px 0 12px; text-align: center; }
.page-flipper h2 { font-size: 1.1rem; color: #fcd34d; margin: 18px 0 8px; }
.page-flipper a { color: #fde68a; }
.page-flipper footer { text-align: center; font-size: 0.85rem; color: #94a3b8; margin-top: 30px; }

/* ---------------- préparation ---------------- */
.setup-intro { text-align: center; line-height: 1.55; margin: 0 auto 14px; max-width: 640px; }
.message-partie { text-align: center; min-height: 1.4em; color: #fca5a5; }
.message-partie a { color: #fde68a; }
.resume-progression { text-align: center; font-size: 0.92rem; color: #cbd5e1; }
.resume-progression a { color: #fde68a; }

.choix-tables {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin: 10px 0 18px;
}
.table-carte {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 12px 10px 14px;
  border-radius: 14px;
  border: 2px solid var(--line, rgba(255, 255, 255, 0.12));
  background: var(--surface-1, rgba(255, 255, 255, 0.04));
  color: inherit; font: inherit; cursor: pointer; text-align: center;
}
.table-carte:hover, .table-carte:focus-visible { border-color: rgba(253, 230, 138, 0.6); }
.table-carte[aria-pressed="true"] { border-color: #fbbf24; background: rgba(251, 191, 36, 0.1); }
.table-carte .vignette { width: 100%; aspect-ratio: 1 / 1.25; border-radius: 10px; background: #0b0b14 center / cover no-repeat; }
.vignette.v-nebuleuse { background-image: url('../images/tables/nebuleuse.webp'); }
.vignette.v-pavillon-noir { background-image: url('../images/tables/pavillon-noir.webp'); }
.vignette.v-grand-huit { background-image: url('../images/tables/grand-huit.webp'); }
.vignette.v-age-d-or { background-image: url('../images/tables/age-d-or.webp'); }
.table-carte strong { font-size: 1.05rem; }
.table-carte .table-desc { font-size: 0.8rem; color: #cbd5e1; line-height: 1.35; }
.table-carte .table-record { font-size: 0.78rem; color: #fde68a; }

.options-partie { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px 26px; margin: 6px 0 16px; }
.option-groupe { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.option-groupe .titre { font-size: 0.85rem; color: #cbd5e1; font-weight: 600; }
.segmente { display: inline-flex; border-radius: 10px; overflow: hidden; border: 1px solid rgba(255, 255, 255, 0.18); }
.segmente button {
  background: transparent; color: inherit; border: 0; padding: 7px 14px; min-height: 44px; min-width: 44px; font: inherit; cursor: pointer;
  border-left: 1px solid rgba(255, 255, 255, 0.12);
}
.segmente button:first-child { border-left: 0; }
.segmente button[aria-pressed="true"] { background: #fbbf24; color: #1f1300; font-weight: 700; }
.note-classement { text-align: center; font-size: 0.85rem; color: #cbd5e1; margin: 0 0 12px; }
.lancer-partie { text-align: center; margin: 8px 0 20px; display: flex; gap: 12px; align-items: center; justify-content: center; }
.choix-resume { display: none; font-size: 0.85rem; color: #cbd5e1; }
.liens-modes { list-style: none; padding: 0; margin: 10px auto 0; max-width: 560px; display: grid; gap: 8px; }
.liens-modes a { display: block; padding: 10px 12px; border-radius: 10px; background: rgba(255, 255, 255, 0.04); text-decoration: none; font-size: 0.92rem; }
.liens-modes a:hover { background: rgba(255, 255, 255, 0.08); }
.noms-joueurs { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 14px; margin: 0 0 12px; }
.noms-joueurs label { font-size: 0.85rem; color: #cbd5e1; display: flex; gap: 6px; align-items: center; }
.noms-joueurs input { width: 120px; padding: 8px; min-height: 40px; border-radius: 8px; border: 1px solid rgba(255, 255, 255, 0.2); background: rgba(0, 0, 0, 0.3); color: #f8fafc; font: inherit; }

/* Téléphone : cartes compactes, bouton Jouer toujours sous le pouce. */
@media (max-width: 600px) {
  .choix-tables { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .table-carte { padding: 8px 6px 10px; gap: 4px; }
  .table-carte .vignette { aspect-ratio: 1 / 1; }
  .table-carte .table-desc { display: none; }
  .lancer-collant {
    position: sticky; bottom: 0; z-index: 20; margin: 8px -24px 0; padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    background: rgba(13, 11, 26, 0.95); border-top: 1px solid rgba(255, 255, 255, 0.12); justify-content: space-between;
  }
  .choix-resume { display: block; }
}

/* ---------------- boutons ---------------- */
.fl-btn {
  display: inline-block; padding: 10px 20px; border-radius: 10px; border: 0;
  background: #f59e0b; color: #1f1300; font: inherit; font-weight: 700; cursor: pointer; text-decoration: none;
}
.fl-btn.secondaire { background: rgba(255, 255, 255, 0.1); color: #f8fafc; border: 1px solid rgba(255, 255, 255, 0.2); }
.fl-btn:focus-visible { outline: 3px solid #fde68a; outline-offset: 2px; }
.fl-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 12px; }

/* ---------------- zone de jeu ---------------- */
.flipper { position: relative; }
.flipper.en-jeu {
  position: fixed; inset: 0; z-index: 100000;  /* au-dessus de la barre de connexion du réseau */
  background: #05060a;
  display: flex; align-items: center; justify-content: center;
  overscroll-behavior: none;
}
.fl-caisse { display: flex; align-items: stretch; gap: 14px; max-height: 100%; }
.fl-fronton { display: flex; flex-direction: column; gap: 12px; width: 300px; justify-content: center; }
#afficheur { width: 100%; aspect-ratio: 4 / 1; border-radius: 6px; border: 3px solid #2a1a0a; background: #120802; }
.fl-outils { display: flex; gap: 8px; justify-content: center; }
.fl-outils button {
  width: 44px; height: 44px; border-radius: 10px; border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06); color: #f8fafc; font-size: 1.1rem; cursor: pointer;
}
.fl-aide { color: #94a3b8; font-size: 0.8rem; line-height: 1.5; }
.fl-aide p { margin: 2px 0; }
kbd {
  display: inline-block; padding: 0 5px; border-radius: 4px; border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.06); font-size: 0.78rem; font-family: inherit;
}
.fl-plateau { position: relative; touch-action: none; user-select: none; -webkit-user-select: none; }
#table {
  display: block;
  height: min(calc(100vh - 16px), 1300px);
  height: min(calc(100dvh - 16px), 1300px);
  aspect-ratio: 520 / 1060;
  width: auto;
  max-width: 100vw;
  border-radius: 8px;
  /* Rails de caisse : liseré chromé, rail sombre, arête claire (sans changer la taille) */
  box-shadow: 0 0 0 2px #d1d5db, 0 0 0 5px #23262d, 0 0 0 7px #6b7280, 0 12px 40px rgba(0, 0, 0, 0.7);
}
#afficheur { box-shadow: inset 0 0 14px rgba(0, 0, 0, 0.85), 0 0 18px rgba(255, 120, 20, 0.12); }
.flipper:not(.en-jeu) .fl-caisse { display: none; }

.fl-tactile-btn {
  position: absolute; display: none;
  border-radius: 999px; border: 2px solid rgba(255, 255, 255, 0.5);
  background: rgba(15, 23, 42, 0.55); color: #fff; font: inherit; font-weight: 700; font-size: 0.85rem;
}
.mode-tactile .fl-tactile-btn { display: block; }
#btn-tactile-lancer { right: 2%; bottom: 3%; width: 21%; aspect-ratio: 1; }
#btn-tactile-lancer:not(.visible) { opacity: 0.25; }
/* En haut à gauche : loin des pouces posés en bas pour les flippers. */
#btn-tactile-secouer { left: 2%; top: 1.5%; padding: 10px 14px; min-height: 44px; opacity: 0.6; }
.mode-tactile .fl-clavier-seul { display: none; }
.flipper:not(.mode-tactile) .fl-tactile-seul { display: none; }

/* Téléphone et tablette en portrait : afficheur au-dessus du plateau. */
@media (max-aspect-ratio: 4/5), (max-width: 700px) {
  .fl-caisse { flex-direction: column; gap: 6px; align-items: center; }
  .fl-fronton { width: min(100vw - 12px, 520px); flex-direction: row; align-items: center; gap: 6px; }
  #afficheur { flex: 1; min-width: 0; }
  .fl-outils { flex-direction: row; }
  .fl-outils button { width: 44px; height: 44px; font-size: 0.95rem; }
  .fl-aide { display: none; }
  /* Hauteur de l'afficheur mesurée par partie.js (--fl-haut-fronton). */
  #table {
    height: min(calc(100vh - var(--fl-haut-fronton, 96px)), calc((100vw - 8px) * 2.0385));
    height: min(calc(100dvh - var(--fl-haut-fronton, 96px)), calc((100vw - 8px) * 2.0385));
  }
  .flipper.en-jeu { align-items: flex-start; padding-top: 6px; }
}

/* ---------------- écrans ---------------- */
.fl-voile {
  position: absolute; inset: 0; z-index: 5;
  display: flex; align-items: center; justify-content: center;
  background: rgba(3, 4, 10, 0.78);
  padding: 16px;
}
.fl-voile[hidden] { display: none; }
.flipper:not(.en-jeu) .fl-voile { display: none; }
.fl-carte {
  max-width: 420px; width: 100%;
  background: #12141f; border: 1px solid rgba(255, 255, 255, 0.14); border-radius: 16px;
  padding: 20px 22px; text-align: center; color: #f8fafc;
}
.fl-carte h2 { margin: 0 0 8px; }
.fl-sous-titre, .fl-commandes, .fl-note { color: #cbd5e1; font-size: 0.92rem; line-height: 1.5; }
.fl-note { font-size: 0.82rem; margin-top: 10px; }
.bilan table { margin: 8px auto; border-collapse: collapse; min-width: 240px; }
.bilan th { text-align: left; font-weight: 600; padding: 4px 12px 4px 0; color: #cbd5e1; }
.bilan td { text-align: right; padding: 4px 0; font-variant-numeric: tabular-nums; font-weight: 700; }
.fl-match { font-size: 0.82rem; color: #94a3b8; margin: 4px 0 0; }
.fl-fin-statut { min-height: 1.3em; font-size: 0.92rem; margin: 10px 0 0; line-height: 1.45; }
.fl-fin-statut.attente { color: #cbd5e1; }
.fl-fin-statut.ok { color: #bbf7d0; }
.fl-fin-statut.erreur { color: #fca5a5; }
.fl-fin-statut a { color: #fde68a; }

/* Partie classée en cours : pas de fiche de règles par-dessus le jeu. */
.flipper.partie-classee.partie-lancee #btn-regles { display: none; }
.flipper:not(.partie-classee) .fl-classee-seule { display: none; }

/* Bandeau « Arrêter ? » : le jeu continue dessous, il ne couvre que le haut. */
.fl-bandeau-arret {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%); z-index: 6;
  width: min(420px, calc(100vw - 16px)); padding: 12px 14px; border-radius: 14px; text-align: center;
  background: rgba(18, 20, 31, 0.96); border: 1px solid rgba(251, 191, 36, 0.6); color: #f8fafc;
}
.fl-bandeau-arret p { margin: 0 0 4px; font-size: 0.92rem; }
.fl-bandeau-arret .fl-actions { margin-top: 8px; }

/* Fiche de règles de la table */
.fl-carte-regles { max-width: 560px; max-height: calc(100dvh - 32px); overflow-y: auto; text-align: left; position: relative; }
.fl-carte-regles h2 { text-align: center; padding: 0 30px; }
.fl-carte-regles h3 { font-size: 0.95rem; color: #fcd34d; margin: 16px 0 6px; }
.fl-regles-resume { color: #cbd5e1; font-size: 0.92rem; line-height: 1.5; }
.fl-regles-liste { margin: 0; }
.fl-regles-liste dt { font-weight: 700; color: #fde68a; margin-top: 8px; font-size: 0.92rem; }
.fl-regles-liste dd { margin: 2px 0 0; color: #e2e8f0; font-size: 0.88rem; line-height: 1.45; }
.fl-fermer {
  position: absolute; top: 8px; right: 8px; width: 44px; height: 44px; border-radius: 10px; border: 0;
  background: rgba(255, 255, 255, 0.08); color: #f8fafc; font-size: 1.5rem; cursor: pointer;
}

/* Barre de l'entraînement et du rejeu : au-dessus du jeu, en bas à gauche (en haut au centre sur téléphone). */
.barre-entrainement {
  position: fixed; z-index: 100001; left: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 8px; max-width: 220px;
}
.barre-entrainement[hidden] { display: none; }
.barre-entrainement .fl-btn { padding: 8px 12px; min-height: 44px; font-size: 0.85rem; }
@media (max-aspect-ratio: 4/5), (max-width: 700px) {
  .barre-entrainement { left: 50%; bottom: auto; top: calc(var(--fl-haut-fronton, 96px) + 4px); transform: translateX(-50%);
    flex-direction: row; max-width: none; gap: 4px; }
  .barre-entrainement .fl-btn { font-size: 0.72rem; padding: 6px 8px; }
}

/* Téléphone en paysage */
.fl-tourner {
  position: absolute; inset: 0; z-index: 8; display: flex; align-items: center; justify-content: center;
  background: rgba(3, 4, 10, 0.94); padding: 24px; text-align: center; font-size: 1.1rem; color: #f8fafc;
}
.fl-tourner[hidden] { display: none; }

/* Classement : lien « revoir la partie » et initiales */
.lb-revoir { width: 36px; text-align: center; flex: 0 0 36px; }
.fl-revoir { display: inline-flex; width: 32px; height: 32px; align-items: center; justify-content: center; border-radius: 50%;
  background: rgba(251, 191, 36, 0.15); color: #fbbf24; text-decoration: none; font-size: 0.8rem; }
.lb-initiales { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: 0.08em; color: #fde68a; }

/* Bandeaux du réseau masqués pendant la partie ; ils reviennent sur la carte de
   départ et l'écran de fin (body.fl-bandeaux-visibles, js/partie.js), au-dessus
   de la zone de jeu plein écran. La table, en portrait, laisse les gouttières libres. */
body.fl-en-partie:not(.fl-bandeaux-visibles) .bandeau-infos-wrap,
body.fl-en-partie:not(.fl-bandeaux-visibles) .bloc-jeux-une-wrap { display: none !important; }
@media (min-width: 1280px) {
  body.fl-bandeaux-visibles .bandeau-infos-wrap,
  body.fl-bandeaux-visibles .bloc-jeux-une-wrap { z-index: 100002; }
}
body.fl-en-partie { overflow: hidden; }

/* En-tête réseau (01/11/2026) : page de partie plein écran, le jeu garde tout l'écran.
   Pas de bande en haut ; la barre de compte reste en surimpression, comme avant.
   Sélecteurs préfixés par html : ils l'emportent sur head-common.css quel que soit
   l'ordre de chargement. */
html:root {
  --entete-reseau: 0px;
}
html .net-entete {
  display: none;
}
html .net-entete + .auth-nav {
  position: fixed;
  top: 6px;
  right: 6px;
  background: var(--surface-1);
  border-color: var(--line-forte);
}
html .net-entete + .auth-nav::before {
  background: var(--surface-1);
  border-color: var(--line-forte);
}

/* Le bouton de repli de la barre reste utile ici (téléphone et tablette) */
@media (max-width: 768px) {
  html .net-entete + .auth-nav:not(.no-collapse) .auth-nav-toggle {
    display: inline-flex;
  }
}
