/* =====================================================================
   Pilotage mobile — maquette Figma « Admin mobile — pilotage » (390×844)
   Sur ordinateur : même interface centrée, 480 px de large au maximum.
   ===================================================================== */

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background: var(--encre);
  color: var(--encre);
  font-family: var(--police-texte);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* Zone principale : crème quadrillée */
.app {
  max-width: 480px; min-height: 100vh; margin: 0 auto;
  background-color: var(--creme);
  background-image:
    linear-gradient(rgba(255,129,39,.11) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,129,39,.11) 1px, transparent 1px);
  background-size: 26px 26px;
  padding: 20px 24px calc(120px + env(safe-area-inset-bottom));
}
.onglet { animation: apparait 160ms ease-out; }
@keyframes apparait { from { opacity: 0; transform: translateY(6px); } }

/* Typo */
h1 { font: 800 34px/1.15 var(--police-titre); margin: 6px 0 14px; }
.sous-titre { font: 500 13px/1.3 var(--police-mono); margin: -8px 0 18px; opacity: .85; }
.mono { font-family: var(--police-mono); font-weight: 500; }
.petit { font-size: 14px; }
.etiquette { display: block; font: 500 12px var(--police-mono); opacity: .7; margin: 22px 0 10px; letter-spacing: .02em; }

.entete { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 32px; }

/* Capsules */
.chip, .chip-direct, .chip-ecran {
  display: inline-flex; align-items: center; gap: 8px;
  height: 32px; padding: 0 14px;
  border: 3px solid var(--encre); border-radius: 16px;
  font: 500 13px var(--police-mono); white-space: nowrap;
}
.chip-direct { background: var(--rouge); color: var(--creme); }
.chip-direct i { width: 10px; height: 10px; border-radius: 50%; background: var(--creme); border: 2px solid var(--encre); }
.chip-direct.hors-ligne { background: #8A8597; }
.chip-direct.hors-ligne i { animation: clignote 1s infinite; }
@keyframes clignote { 50% { opacity: .2; } }

/* Aperçu de la TV (rendu réel de /tv réduit) */
.apercu-cadre { position: relative; margin-bottom: 34px; }
.apercu {
  position: relative; width: 100%; aspect-ratio: 16 / 9;
  border: 4px solid var(--encre); border-radius: 20px;
  box-shadow: 8px 8px 0 var(--encre);
  overflow: hidden; background: var(--encre);
}
.apercu iframe {
  position: absolute; left: 0; top: 0; width: 1920px; height: 1080px; border: 0;
  transform-origin: 0 0; pointer-events: none;
}
.chip-ecran { position: absolute; left: 16px; bottom: -18px; background: var(--jaune); font-size: 12px; }

/* Boutons */
.btn {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 60px; padding: 8px 12px;
  background: var(--blanc);
  border: 4px solid var(--encre); border-radius: 18px;
  box-shadow: 6px 6px 0 var(--encre);
  font: 800 20px/1.1 var(--police-titre);
  transition: transform 80ms, box-shadow 80ms;
  touch-action: manipulation;
  user-select: none; -webkit-user-select: none;
}
.btn:active, .btn.appui { transform: translate(4px, 4px); box-shadow: 2px 2px 0 var(--encre); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: 6px 6px 0 var(--encre); }
.btn small { font: 500 13px var(--police-mono); }
.btn.creme { background: var(--creme); }
.btn.jaune { background: var(--jaune); }
.btn.lime { background: var(--lime); }
.btn.rouge { background: var(--rouge); color: var(--creme); }
.btn.cyan { background: var(--cyan); }
.btn.rose { background: var(--rose); }
.btn.gros { min-height: 64px; }
.btn.enorme { min-height: 92px; font-size: 28px; }
.btn.ligne { flex-direction: row; gap: 12px; }
.btn.discret { font: 800 17px var(--police-titre); min-height: 54px; background: var(--creme); }
.btn .tri { width: 0; height: 0; border-top: 8px solid transparent; border-bottom: 8px solid transparent; }
.btn .tri.g { border-right: 14px solid var(--encre); }
.btn .tri.d { border-left: 14px solid var(--encre); }

.rang { display: grid; gap: 12px; margin-top: 16px; }
.rang.r2 { grid-template-columns: 1fr 1fr; }
.rang.r-nav { grid-template-columns: 110px 1fr; margin-top: 0; }
.rang.r3 { grid-template-columns: repeat(3, 1fr); }

/* Interrupteur « question double point » */
.interrupteur {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; min-height: 60px; padding: 0 12px;
  background: var(--blanc); border: 4px solid var(--encre); border-radius: 18px;
  box-shadow: 6px 6px 0 var(--encre);
  font: 800 17px var(--police-titre); text-align: left;
}
.interrupteur .bascule {
  flex: none; position: relative; width: 56px; height: 32px;
  border: 3px solid var(--encre); border-radius: 16px; background: var(--peche);
  transition: background .2s;
}
.interrupteur .bascule::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 22px; height: 22px;
  border-radius: 50%; background: var(--creme); border: 3px solid var(--encre);
  transition: left .2s cubic-bezier(.2,1.4,.4,1);
}
.interrupteur.on .bascule { background: var(--lime); }
.interrupteur.on .bascule::after { left: 26px; }

/* Cartes génériques */
.carte {
  background: var(--blanc); border: 4px solid var(--encre); border-radius: 18px;
  box-shadow: 6px 6px 0 var(--encre); padding: 14px 16px;
}
.enonce { font: 800 22px/1.2 var(--police-titre); min-height: 96px; }
.enonce .rep-attendue { display: block; margin-top: 10px; font: 500 14px var(--police-mono); opacity: .8; }

/* Choix de la bonne réponse */
.choix {
  display: flex; align-items: center; gap: 10px; width: 100%;
  min-height: 52px; padding: 6px 10px;
  background: var(--blanc); border: 4px solid var(--encre); border-radius: 14px;
  box-shadow: 4px 4px 0 var(--encre);
  font: 800 19px/1.15 var(--police-titre); text-align: left;
  margin-bottom: 10px;
}
.choix .lettre {
  flex: none; width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 3px solid var(--encre); font: 800 17px var(--police-titre);
}
.choix .txt { flex: 1; min-width: 0; }
.choix.bonne { background: var(--lime); }
.choix .badge {
  flex: none; padding: 3px 10px; border: 3px solid var(--encre); border-radius: 14px;
  background: var(--creme); font: 500 11px var(--police-mono);
}
.l-A { background: var(--jaune); } .l-B { background: var(--cyan); } .l-C { background: var(--rose); }
.votes { display: flex; align-items: center; gap: 8px; flex: none; }
.votes b { min-width: 28px; text-align: center; font: 800 22px var(--police-titre); }
.mini {
  width: 44px; height: 44px; border: 3px solid var(--encre); border-radius: 12px;
  background: var(--creme); font: 800 20px var(--police-titre); box-shadow: 3px 3px 0 var(--encre);
}
.mini:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--encre); }
.mini.plus { background: var(--lime); }

/* Chrono */
.chrono-carte { padding: 12px 14px; }
.chrono-haut { display: flex; justify-content: space-between; align-items: baseline; }
.chrono-temps { font: 800 30px var(--police-titre); font-variant-numeric: tabular-nums; }
.chrono-piste { height: 16px; margin: 8px 0 12px; border: 3px solid var(--encre); border-radius: 8px; background: var(--peche); overflow: hidden; }
.chrono-rempli { height: 100%; background: var(--jaune); border-right: 3px solid var(--encre); transform-origin: 0 50%; }
.chrono-carte.urgent .chrono-rempli { background: var(--rouge); }
.chrono-carte.urgent .chrono-temps { color: var(--rouge); }
.durees { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.durees button {
  min-width: 48px; height: 36px; border: 3px solid var(--encre); border-radius: 18px;
  background: var(--creme); font: 500 13px var(--police-mono);
}
.durees button.on { background: var(--jaune); }

/* Joueurs (qui marque ?) */
.joueurs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.joueur {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px;
  min-height: 92px; padding: 8px 4px;
  background: var(--blanc); border: 4px solid var(--encre); border-radius: 16px;
  box-shadow: 4px 4px 0 var(--encre);
  font: 500 13px var(--police-mono);
}
.joueur img { width: 54px; height: 46px; object-fit: contain; }
.joueur.on { background: var(--jaune); transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--encre); }
.joueur span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Scores */
.score-carte {
  position: relative; display: grid; grid-template-columns: 84px 1fr auto; align-items: center; gap: 10px;
  margin-bottom: 18px; padding: 12px 12px 18px;
  background: var(--blanc); border: 4px solid var(--encre); border-radius: 18px;
  box-shadow: 6px 6px 0 var(--encre); overflow: hidden;
}
.score-carte::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 7px; background: var(--c); }
.score-carte img { width: 84px; height: 84px; object-fit: contain; }
.score-carte .nom { font: 500 13px var(--police-mono); text-transform: uppercase; }
.score-carte .pts { font: 800 58px/1 var(--police-titre); }
.score-carte .pts.pop { animation: pop 500ms cubic-bezier(.2,1.8,.4,1); }
@keyframes pop { 40% { transform: scale(1.25); color: var(--rose); } }
.score-carte .actions { display: grid; grid-template-columns: 48px 48px; gap: 8px; }
.score-carte .actions .mini { width: 48px; height: 48px; }
.score-carte .actions .x2 {
  grid-column: span 2; height: 32px; border: 3px solid var(--encre); border-radius: 16px;
  background: var(--rose); font: 500 11px var(--police-mono);
}

/* Grille des écrans */
.ecrans { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 14px; }
.vignette {
  position: relative; display: flex; flex-direction: column; gap: 8px; padding: 6px 6px 10px;
  background: var(--blanc); border: 4px solid var(--encre); border-radius: 14px;
  box-shadow: 5px 5px 0 var(--encre);
  font: 500 13px var(--police-mono); text-align: left;
}
.vignette .mini-ecran {
  position: relative; height: 68px; border: 3px solid var(--encre); border-radius: 8px; background: var(--c);
}
.vignette .mini-ecran::before, .vignette .mini-ecran::after {
  content: ""; position: absolute; left: 10px; height: 8px; border-radius: 4px; background: var(--l, var(--creme));
}
.vignette .mini-ecran::before { top: 12px; width: 70px; }
.vignette .mini-ecran::after { top: 28px; width: 46px; }
.vignette .mini-ecran i {
  position: absolute; right: 10px; bottom: 8px; width: 24px; height: 24px; border-radius: 50%;
  border: 3px solid var(--encre); background: var(--p, var(--jaune));
}
.vignette .lib { padding: 0 4px; }
.vignette.actif { background: var(--peche); }
.vignette.actif::before {
  content: "À L'ÉCRAN"; position: absolute; top: -16px; left: 50%; transform: translateX(-50%);
  padding: 3px 12px; border: 3px solid var(--encre); border-radius: 14px; background: var(--cyan);
  font: 500 11px var(--police-mono); white-space: nowrap; z-index: 2;
}
.vignette:active { transform: translate(3px, 3px); box-shadow: 2px 2px 0 var(--encre); }

select.aller {
  width: 100%; height: 48px; padding: 0 12px; margin-top: 4px;
  border: 3px solid var(--encre); border-radius: 14px; background: var(--creme);
  font: 500 14px var(--police-mono); color: var(--encre);
}
.vide { padding: 18px; text-align: center; font: 500 14px var(--police-mono); opacity: .75; }

/* Barre de navigation */
.nav {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%);
  width: 100%; max-width: 480px;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px;
  padding: 10px 8px calc(10px + env(safe-area-inset-bottom));
  background: var(--encre); z-index: 20;
}
.nav button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  height: 64px; border: 0; border-radius: 20px; background: none; color: var(--creme);
  font: 500 11px var(--police-mono);
}
.nav button.actif { background: var(--jaune); color: var(--encre); }
.nav .ic { height: 24px; display: flex; align-items: center; justify-content: center; font: 800 28px/1 var(--police-titre); }
.nav .ic-live::before { content: ""; width: 22px; height: 22px; border-radius: 50%; background: currentColor; }
.nav button.actif .ic-live::before { background: var(--encre); }
.nav button:not(.actif) .ic-live::before { background: var(--creme); }
.nav .ic-ecrans::before { content: ""; width: 22px; height: 17px; border: 3px solid currentColor; border-radius: 4px; }
.nav .ic-question { font-size: 30px; }
.nav .ic-scores { font-size: 28px; }

/* Bouton Annuler flottant */
.annuler {
  position: fixed; left: 50%; bottom: calc(100px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 30; min-height: 48px; padding: 0 20px;
  background: var(--encre); color: var(--creme);
  border: 3px solid var(--creme); border-radius: 24px;
  font: 500 15px var(--police-mono); box-shadow: 4px 4px 0 rgba(31,26,56,.35);
  animation: monte 220ms cubic-bezier(.2,1.4,.4,1);
}
@keyframes monte { from { opacity: 0; transform: translate(-50%, 20px); } }
.toast {
  position: fixed; left: 50%; top: 16px; transform: translateX(-50%); z-index: 40;
  max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 14px;
  background: var(--rouge); color: var(--creme); border: 3px solid var(--encre);
  font: 500 14px var(--police-mono);
}

/* Code PIN */
.pin { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: rgba(31,26,56,.85); padding: 16px; }
.pin-boite { width: min(360px, 100%); background: var(--creme); border: 4px solid var(--encre); border-radius: 20px; padding: 22px; box-shadow: 8px 8px 0 var(--jaune); }
.pin-boite h2 { font: 800 28px var(--police-titre); margin: 0 0 4px; }
.pin-boite input {
  width: 100%; height: 56px; margin: 14px 0 10px; padding: 0 14px; text-align: center; letter-spacing: .3em;
  border: 4px solid var(--encre); border-radius: 14px; background: var(--blanc); font: 800 26px var(--police-titre);
}
.pin-boite .erreur { color: var(--rouge); margin: 0 0 10px; }
.pin-boite button { width: 100%; height: 56px; border: 4px solid var(--encre); border-radius: 16px; background: var(--jaune); font: 800 20px var(--police-titre); box-shadow: 5px 5px 0 var(--encre); }

@media (min-width: 520px) {
  body { padding: 24px 0; }
  .app { border-radius: 28px; min-height: calc(100vh - 48px); }
}

/* Ajustements : textes de boutons sur une seule ligne quand c'est serré */
.rang.r-nav .btn { padding: 8px 10px; gap: 10px; font-size: 19px; white-space: nowrap; }
.rang.r2 .btn:not(.enorme) { font-size: 16px; padding: 8px 8px; }
.durees { flex-wrap: nowrap; }
.durees button { flex: 1; min-width: 0; padding: 0; }

/* Points que rapporte une bonne réponse (manche avec barème) */
.joueur .coef {
  font: 800 14px var(--police-titre); font-style: normal;
  padding: 1px 8px; border: 2px solid var(--encre); border-radius: 10px; background: var(--lime);
}
.score-carte .pts { white-space: nowrap; }

/* Réponse attendue, visible depuis l'onglet Live (seulement sur le téléphone) */
.reponse-live {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  margin: -6px 0 18px; padding: 10px 14px;
  background: var(--lime); border: 3px solid var(--encre); border-radius: 14px;
}
.reponse-live .mono { font-size: 11px; opacity: .75; }
.reponse-live b { font: 800 19px/1.2 var(--police-titre); }
