/* =====================================================================
   Écran TV — canvas 1920×1080 mis à l'échelle, composants communs
   Toutes les positions des écrans sont en pixels « maquette » (Figma).
   ===================================================================== */

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--encre);
}
body { cursor: none; }
body.apercu { cursor: default; }

/* Canvas : mis à l'échelle par tv.js (letterbox si le ratio diffère) */
.scene {
  position: absolute; left: 0; top: 0;
  width: 1920px; height: 1080px;
  transform-origin: 0 0;
  overflow: hidden;
  background: var(--creme);
  color: var(--encre);
  font-family: var(--police-texte);
  font-optical-sizing: auto; /* comme Figma : taille optique = taille du texte */
  -webkit-font-smoothing: antialiased;
}

/* Une couche par écran (permet le fondu enchaîné) */
.ecran {
  position: absolute; inset: 0;
  width: 1920px; height: 1080px;
  overflow: hidden;
}
.ecran.entree { animation: ecran-entree 260ms cubic-bezier(.2, .9, .3, 1.15) both; }
.ecran.sortie { animation: ecran-sortie 200ms ease-in both; pointer-events: none; }
@keyframes ecran-entree { from { opacity: 0; transform: scale(.985); } to { opacity: 1; transform: none; } }
@keyframes ecran-sortie { to { opacity: 0; } }

/* Positionnement absolu en coordonnées maquette */
.abs { position: absolute; }

/* Typo */
.titre { font-family: var(--police-titre); font-weight: 800; line-height: normal; margin: 0; }
.texte { font-family: var(--police-texte); font-weight: 700; line-height: normal; margin: 0; }
.mono  { font-family: var(--police-mono); font-weight: 500; line-height: normal; margin: 0; font-variation-settings: normal; }
.centre { text-align: center; }
.nowrap { white-space: nowrap; }

/* Fond quadrillé fin (lignes blanches de 2 px tous les 60 px) */
.grille {
  position: absolute; inset: 0;
  --g: .4;
  background-image:
    linear-gradient(rgba(255,255,255,var(--g)) 2px, transparent 2px),
    linear-gradient(90deg, rgba(255,255,255,var(--g)) 2px, transparent 2px);
  background-size: 60px 60px;
}

/* ------------------------- Fenêtre rétro ------------------------- */
.fenetre {
  position: absolute;
  background: var(--creme);
  border-radius: 28px;
  box-shadow: var(--ombre);
  overflow: hidden;
}
.fenetre::after { /* contour d'encre par-dessus le contenu */
  content: ""; position: absolute; inset: 0;
  border: 6px solid var(--encre); border-radius: 28px;
  pointer-events: none; z-index: 5;
}
.fenetre > .barre {
  position: absolute; left: 0; top: 0; right: 0; height: 64px;
  border-bottom: 6px solid var(--encre);
}
.fenetre > .barre .pt {
  position: absolute; top: 17px; width: 28px; height: 28px;
  border-radius: 50%; border: 4px solid var(--encre);
}
.fenetre > .barre .pt1 { left: 26px; background: var(--creme); }
.fenetre > .barre .pt2 { left: 64px; background: var(--jaune); }
.fenetre > .barre .pt3 { left: 102px; background: var(--cyan); }
.fenetre > .barre .nom {
  position: absolute; left: 0; right: 0; top: 15px;
  font: 500 24px/normal var(--police-mono); text-align: center;
  font-variation-settings: normal;
}
.fenetre > .barre .fermer {
  position: absolute; right: 26px; top: 14px; width: 44px; height: 36px;
  background: var(--creme); border: 4px solid var(--encre); border-radius: 10px;
  font: 700 30px/24px var(--police-texte); text-align: center;
}

/* --------------------------- Capsules --------------------------- */
.chip {
  position: absolute;
  border: 5px solid var(--encre); border-radius: 40px;
  padding: 12px 30px;
  font-family: var(--police-mono); font-weight: 500; line-height: normal;
  font-variation-settings: normal;
  white-space: nowrap;
  box-shadow: var(--ombre-pt);
}
.chip.sans-ombre { box-shadow: none; }

.nom-joueur {
  position: absolute;
  border: 6px solid var(--encre); border-radius: 60px;
  padding: 8px 40px;
  font: 800 64px/normal var(--police-titre);
  white-space: nowrap;
  box-shadow: var(--ombre-moy);
}

.bouton-deco {
  position: absolute;
  display: flex; align-items: center; justify-content: center;
  background: var(--cyan); border: 6px solid var(--encre); border-radius: 16px;
  box-shadow: var(--ombre-pt);
  font: 500 34px/normal var(--police-mono); font-variation-settings: normal;
}

/* Étoiles, confettis, ronds décoratifs */
.deco { position: absolute; display: block; pointer-events: none; }
.confetti { position: absolute; border: 3px solid var(--encre); border-radius: 6px; }
.rond { position: absolute; border: 3px solid var(--encre); border-radius: 50%; }

/* Avatar : image SVG contenue dans sa boîte */
.avatar { position: absolute; object-fit: contain; display: block; }
.ombre-sol { position: absolute; width: 260px; height: 34px; border-radius: 50%; background: rgba(31,26,56,.14); }

/* --------------------------- Bandeau --------------------------- */
.bandeau {
  position: absolute; top: 950px;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 22px;
  padding: 16px 36px;
  background: var(--jaune);
  border: 5px solid var(--encre); border-radius: 60px;
  box-shadow: var(--ombre-moy);
  font: 800 44px/normal var(--police-titre);
  white-space: nowrap;
}
.bandeau svg { width: 34px; height: 34px; flex: none; }

/* ------------------------ Carte réponse ------------------------ */
.reponse {
  position: absolute; height: 190px;
  display: flex; align-items: center; gap: 24px;
  padding: 0 28px;
  background: var(--blanc);
  border: 6px solid var(--encre); border-radius: 28px;
  box-shadow: var(--ombre);
  transition: background-color .35s, opacity .35s, transform .35s;
}
.reponse .pastille {
  flex: none; width: 96px; height: 96px;
  display: flex; align-items: center; justify-content: center;
  border: 5px solid var(--encre); border-radius: 48px;
  font: 800 52px/normal var(--police-titre);
}
.reponse .libelle {
  flex: 1 1 0; min-width: 0; max-height: 150px; overflow: hidden;
  font: 700 44px/1.09 var(--police-texte);
  overflow-wrap: break-word;
}
.reponse.bonne { background: var(--lime); animation: bonne 600ms cubic-bezier(.2,1.6,.4,1); }
.reponse.eteinte { opacity: .45; }
@keyframes bonne { 0% { scale: 1; } 40% { scale: 1.06; rotate: -1deg; } 100% { scale: 1; rotate: 0deg; } }

.p-A { background: var(--jaune); }
.p-B { background: var(--cyan); }
.p-C { background: var(--rose); }

/* ------------------------ Panneau scores ------------------------ */
.panneau-scores {
  position: absolute; left: 1730px; top: 0; width: 190px; height: 1080px;
  background: var(--encre);
  display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  padding: 36px 20px;
}
.panneau-scores.peu { justify-content: space-evenly; }
.tuile {
  width: 100%;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 14px 8px 16px;
  background: var(--creme); border-radius: 22px;
  overflow: hidden;
}
.tuile .av { width: 120px; height: 104px; position: relative; }
.tuile .av img { position: absolute; left: 0; top: 4px; width: 120px; height: 96px; object-fit: contain; }
.tuile .score { font: 800 92px/normal var(--police-titre); }
.tuile .score.pop { animation: pop 700ms cubic-bezier(.2,1.8,.4,1); }
.tuile .nom {
  font: 500 22px/normal var(--police-mono); font-variation-settings: normal;
  padding: 4px 14px; border-radius: 20px; white-space: nowrap;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis;
}
@keyframes pop { 0% { scale: 1; } 35% { scale: 1.35; color: var(--rose); } 100% { scale: 1; } }

/* ---------------------------- Chrono ---------------------------- */
.chrono {
  position: absolute; top: 30px; height: 40px;
  display: none; align-items: center; gap: 14px;
}
.chrono.visible { display: flex; }
.chrono .temps {
  flex: none; min-width: 112px; text-align: center;
  padding: 2px 14px;
  background: var(--creme); border: 5px solid var(--encre); border-radius: 22px;
  font: 500 26px/normal var(--police-mono); font-variation-settings: normal;
}
.chrono .piste {
  flex: 1; height: 28px; position: relative; overflow: hidden;
  background: var(--peche); border: 5px solid var(--encre); border-radius: 14px;
}
.chrono .rempli {
  position: absolute; left: 0; top: 0; bottom: 0; width: 100%;
  background: var(--jaune);
  border-right: 5px solid var(--encre);
  transform-origin: 0 50%;
}
.chrono.urgent .rempli { background: var(--rouge); }
.chrono.urgent .temps { background: var(--rouge); color: var(--creme); animation: urgence 1s infinite; }
@keyframes urgence { 50% { scale: 1.08; } }

/* --------------------------- Effets --------------------------- */
.tremble { animation: tremble 520ms cubic-bezier(.36,.07,.19,.97) both; }
@keyframes tremble {
  10%, 90% { transform: translate(-4px, 0); }
  20%, 80% { transform: translate(8px, 2px); }
  30%, 50%, 70% { transform: translate(-14px, -2px); }
  40%, 60% { transform: translate(14px, 2px); }
}
.pluie-confettis { position: absolute; inset: 0; pointer-events: none; z-index: 50; overflow: hidden; }
.pluie-confettis i {
  position: absolute; top: -60px; display: block;
  border: 3px solid var(--encre); border-radius: 5px;
  animation: tombe linear forwards;
}
@keyframes tombe {
  to { transform: translate(var(--dx), 1200px) rotate(var(--rot)); }
}

/* Entrées animées réutilisables */
.rebond { animation: rebond 700ms cubic-bezier(.2,1.6,.4,1) both; }
@keyframes rebond { from { opacity: 0; scale: .4; rotate: -6deg; } to { opacity: 1; scale: 1; rotate: 0deg; } }
.glisse-g { animation: glisse-g 500ms cubic-bezier(.2,1.2,.4,1) both; }
@keyframes glisse-g { from { opacity: 0; translate: -120px 0; } to { opacity: 1; translate: 0 0; } }
.glisse-h { animation: glisse-h 600ms cubic-bezier(.2,1.2,.4,1) both; }
@keyframes glisse-h { from { opacity: 0; translate: 0 -80px; } to { opacity: 1; translate: 0 0; } }
.monte { animation: monte 800ms cubic-bezier(.2,1.1,.4,1) both; }
@keyframes monte { from { translate: 0 110%; } to { translate: 0 0; } }
.flotte { animation: flotte 3.2s ease-in-out infinite; }
@keyframes flotte { 50% { translate: 0 -14px; rotate: 2deg; } }

/* --------------------- Voyant de connexion --------------------- */
.voyant {
  position: fixed; right: 10px; bottom: 10px; width: 14px; height: 14px;
  border-radius: 50%; background: var(--rouge); border: 2px solid var(--creme);
  opacity: 0; transition: opacity .3s; z-index: 100;
}
.voyant.hors-ligne { opacity: .9; animation: clignote 1.2s infinite; }
@keyframes clignote { 50% { opacity: .3; } }

.aide {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%);
  padding: 8px 16px; border-radius: 20px;
  background: rgba(31,26,56,.8); color: var(--creme);
  font: 500 14px var(--police-mono); z-index: 100;
  transition: opacity .6s; pointer-events: none;
}
.aide.cache, .apercu .aide { opacity: 0; }

@media (prefers-reduced-motion: reduce) {
  .ecran.entree, .rebond, .glisse-g, .glisse-h, .monte, .flotte { animation-duration: 1ms !important; animation-iteration-count: 1 !important; }
}

/* Arrivée par le haut puis flottement continu */
.arrivee-flotte {
  animation: glisse-h 600ms cubic-bezier(.2,1.2,.4,1) both, flotte 3.2s ease-in-out 600ms infinite;
}

/* Cartes « À qui va le point ? » */
.carte-joueur {
  position: absolute; width: 440px; height: 620px;
  background: var(--blanc);
  border: 6px solid var(--encre); border-radius: 28px;
  box-shadow: 12px 12px 0 var(--encre);
  transform-origin: 50% 0;
  transition: background-color .3s, opacity .3s, transform .4s cubic-bezier(.2,1.6,.4,1);
}
.carte-joueur.elue { background: var(--lime); transform: translateY(-24px) rotate(-2deg); }
.carte-joueur.pas-elue { opacity: .5; }

/* Explosion ×2 qui pulse */
.explosion { animation: rebond 600ms cubic-bezier(.2,1.6,.4,1) both, pulse 1.6s ease-in-out 600ms infinite; }
@keyframes pulse { 50% { scale: 1.04; } }

/* Podium du classement */
.marche {
  position: absolute; width: 380px;
  border: 6px solid var(--encre); border-radius: 28px;
  box-shadow: 12px 12px 0 var(--encre);
}
.avatar.champion { animation: rebond 700ms cubic-bezier(.2,1.6,.4,1) both, flotte 2.4s ease-in-out 1.4s infinite; }
.aureole {
  border-radius: 50%;
  background: repeating-conic-gradient(from 0deg, rgba(255,194,26,.55) 0 12deg, transparent 12deg 24deg);
  -webkit-mask: radial-gradient(circle, #000 35%, transparent 70%);
          mask: radial-gradient(circle, #000 35%, transparent 70%);
  animation: rebond 600ms both, tourne 14s linear infinite;
}
@keyframes tourne { to { rotate: 360deg; } }

/* Bandeau « active le son » (disparaît au premier clic) */
.activer-son {
  position: fixed; left: 50%; top: 16px; transform: translateX(-50%); z-index: 120;
  padding: 10px 20px; border-radius: 22px;
  background: var(--jaune); color: var(--encre); border: 3px solid var(--encre);
  font: 500 16px var(--police-mono); box-shadow: 4px 4px 0 var(--encre);
  animation: clignote-doux 1.6s ease-in-out infinite;
  cursor: pointer;
}
@keyframes clignote-doux { 50% { opacity: .65; } }
.son-actif .activer-son, .apercu .activer-son { display: none; }
