/* ==========================================================================
   Écran principal (TV / vidéoprojecteur)
   Même charte que le reste, en grand. Toutes les tailles sont en rem et 1 rem s'adapte à l'écran :
   1 rem = 20 px en 1920 × 1080, 13 px en 1280 × 720 — la composition reste identique quelle que soit la définition.
   Règle d'or des animations : l'état de base est toujours l'état final ; les animations ne font que « partir de ».
   ========================================================================== */

html.tv { font-size: min(1.0417vw, 1.852vh); }

body.tv {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  font-size: 1rem;
  background: var(--color-bg-white);
  cursor: default;
}

.tv-stage { position: relative; display: flex; flex-direction: column; height: 100vh; }

/* ---------- Barre du haut ---------- */
.tv-top {
  position: relative; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  height: 4.5rem;
  background: var(--color-bg-white);
  box-shadow: var(--shadow-header);
}
.tv-top__logo { display: block; height: 4.5rem; width: auto; }
.tv-top__right { display: flex; align-items: center; gap: 0.9rem; padding-right: 2rem; }

.tv-pill {
  display: inline-flex; align-items: center; gap: 0.5rem;
  height: 2.3rem; padding: 0 1rem;
  font-size: 1rem; font-weight: var(--font-weight-bold); letter-spacing: 0.04em; text-transform: uppercase;
  background: var(--color-bg-grey-light);
  border-radius: var(--radius-sm);
  white-space: nowrap;
}
.tv-pill .icon { width: 1.3rem; height: 1.3rem; }

.tv-iconbtn {
  display: grid; place-items: center;
  width: 2.6rem; height: 2.6rem;
  color: var(--color-text-secondary);
  background: transparent; border: 0; border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color 250ms var(--ease), color 250ms var(--ease);
}
.tv-iconbtn:hover { color: var(--color-primary); background: var(--color-primary-subtle); }
.tv-iconbtn .icon { width: 1.6rem; height: 1.6rem; }
.tv-iconbtn.is-off { color: var(--color-primary); }

/* ---------- Barre de temps ---------- */
.tv-timer { height: 0.6rem; background: var(--color-border); }
.tv-timer__bar { width: 0; height: 100%; background: var(--color-primary); }
.tv-timer.is-idle .tv-timer__bar { background: var(--color-text-disabled); }

.tv-main { position: relative; flex: 1; min-height: 0; padding: 2.5rem 4rem 2rem; }
.tv-main > .view { height: 100%; }

/* Badges plus lisibles à distance */
.tv .badge { height: 2.2rem; padding: 0 0.9rem; font-size: 1rem; border-radius: var(--radius-sm); }
.tv .diff-dots i { width: 0.5rem; height: 0.5rem; }
.tv .icon { width: 1.5rem; height: 1.5rem; }

/* ==========================================================================
   Accueil
   ========================================================================== */
.tv-main > .view.lobby { margin: -2.5rem -4rem -2rem; height: calc(100% + 4.5rem); }
.lobby { display: grid; grid-template-columns: 5fr 7fr; }

.lobby__join {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.3rem;
  padding: 2rem 3rem;
  color: #fff; text-align: center;
  background: var(--color-primary);          /* le fond du logo est le même rouge : il s'y fond */
}
.lobby__kicker { font-size: 1.5rem; font-weight: var(--font-weight-black); text-transform: uppercase; letter-spacing: 0.14em; opacity: 0.85; }
.lobby__join h1 { font-size: 3.1rem; color: #fff; }
.lobby__lead { max-width: 24rem; font-size: 1.35rem; font-weight: var(--font-weight-semibold); line-height: 1.4; opacity: 0.95; }
.qr { width: 19rem; height: 19rem; padding: 0.6rem; background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-card); }
.qr__svg { display: block; width: 100%; height: 100%; }
.lobby__or { font-size: 1.1rem; font-weight: var(--font-weight-semibold); text-transform: uppercase; letter-spacing: 0.08em; opacity: 0.8; }
.lobby__url { padding: 0.55rem 1.3rem; font-size: 1.5rem; font-weight: var(--font-weight-bold); word-break: break-all; background: rgba(255, 255, 255, 0.14); border-radius: var(--radius-md); }

.lobby__wall { display: flex; flex-direction: column; gap: 1.4rem; padding: 3rem 3.5rem 2.5rem; overflow: hidden; background: var(--color-bg-white); }
.lobby__count { display: flex; align-items: baseline; gap: 0.9rem; font-size: 1.5rem; font-weight: var(--font-weight-bold); }
.lobby__count strong { font-size: 5.5rem; font-weight: var(--font-weight-black); line-height: 1; color: var(--color-primary); font-variant-numeric: tabular-nums; }
.lobby__wait { margin-top: -0.6rem; font-size: 1.2rem; font-weight: var(--font-weight-semibold); color: var(--color-text-secondary); }

/* La taille des prénoms (--chip-size) est choisie par ecran.js pour que tout le monde tienne ; marges et espaces suivent */
.wall { display: flex; flex-wrap: wrap; align-content: flex-start; gap: calc(var(--chip-size, 1.35rem) * 0.5); flex: 1; overflow: hidden; }
.chip {
  padding: 0.34em 0.8em;
  font-size: var(--chip-size, 1.35rem); font-weight: var(--font-weight-bold);
  background: var(--color-bg-grey-light);
  border-radius: var(--radius-md);
  animation: pop 420ms var(--ease) both;
}

/* ==========================================================================
   Décompte de lancement (plein cadre, même rouge que l'accueil)
   ========================================================================== */
.tv-main > .view.cd { margin: -2.5rem -4rem -2rem; height: calc(100% + 4.5rem); }
.cd { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem; color: #fff; text-align: center; background: var(--color-primary); }
.cd__label { font-size: 2.6rem; font-weight: var(--font-weight-black); letter-spacing: 0.06em; text-transform: uppercase; }
.cd__num { font-size: 26rem; font-weight: var(--font-weight-black); line-height: 1; font-variant-numeric: tabular-nums; }
.cd__num--pop { animation: cd-pop 900ms var(--ease) both; }
@keyframes cd-pop { from { transform: scale(1.4); opacity: 0; } 30% { opacity: 1; } }
.cd__hint { font-size: 1.8rem; font-weight: var(--font-weight-semibold); opacity: 0.85; }

/* ==========================================================================
   Question et réponse
   ========================================================================== */
.question { display: flex; flex-direction: column; gap: 1.6rem; }
.question__meta { display: flex; align-items: center; gap: 1rem; }
.question__meta .spacer { flex: 1; }
/* L'énoncé et les réponses forment UN bloc, centré verticalement entre l'en-tête et le pied de la question */
.question__body { flex: 1; min-height: 0; display: flex; flex-direction: column; justify-content: center; gap: 2.4rem; }
.question__text {
  display: flex; align-items: center;
  margin: 0;
  font-size: 3.1rem; font-weight: var(--font-weight-black); line-height: 1.2;
  letter-spacing: 0; text-transform: none;      /* un énoncé n'est pas un titre : pas de capitales */
}
.question__img { max-height: 14rem; max-width: 100%; object-fit: contain; border-radius: var(--radius-md); align-self: flex-start; }

.countdown {
  display: grid; place-items: center;
  width: 6rem; height: 6rem;
  font-size: 3rem; font-weight: var(--font-weight-black); font-variant-numeric: tabular-nums; color: #fff;
  background: var(--color-primary);
  border-radius: 50%;
  transition: background-color 250ms var(--ease);
}
.countdown .icon { width: 3.4rem; height: 3.4rem; }
.countdown.is-idle   { background: var(--color-text-disabled); }
.countdown.is-urgent { animation: pulse 1s ease-in-out infinite; }
.countdown.is-done   { background: var(--color-success); animation: pop 420ms var(--ease) both; }

.tv-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
.tv-choice {
  position: relative;
  display: flex; align-items: center; gap: 1.3rem;
  min-height: 6.6rem; padding: 1rem 1.8rem;
  overflow: hidden;
  font-size: 1.95rem; font-weight: var(--font-weight-bold); line-height: 1.2;
  background: var(--color-bg-white);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  animation: choice-in 520ms var(--ease) both;     /* le délai d'apparition est posé par ecran.js (une proposition après l'autre) */
  transition: border-color 350ms var(--ease), background-color 350ms var(--ease), opacity 350ms var(--ease);
}
@keyframes choice-in { from { opacity: 0; transform: translateY(1.4rem); } }
.tv-choice > :not(.tv-choice__fill) { position: relative; }
.tv-choice__fill { position: absolute; inset: 0 auto 0 0; width: 0; background: rgba(33, 33, 33, 0.07); transition: width 1000ms var(--ease); }
.tv-choice__key {
  flex: none; display: grid; place-items: center;
  width: 3.5rem; height: 3.5rem;
  font-size: 1.7rem; font-weight: var(--font-weight-black);
  background: var(--color-bg-grey-light); border-radius: 50%;
  transition: background-color 350ms var(--ease), color 350ms var(--ease);
}
.tv-choice__text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.tv-choice__count { display: none; flex: none; min-width: 7.5rem; text-align: right; font-size: 2.2rem; font-weight: var(--font-weight-black); line-height: 1.1; font-variant-numeric: tabular-nums; }
.tv-choice__count small { display: block; margin-top: 0.15rem; font-size: 1rem; font-weight: var(--font-weight-semibold); line-height: 1.1; color: var(--color-text-secondary); }
.is-result .tv-choice__count { display: block; }

.is-result .tv-choice.is-dim { opacity: 0.5; }
.is-result .tv-choice.is-correct { border-color: var(--color-success); background: var(--color-success-bg); animation: pop 520ms var(--ease) both; }
.is-result .tv-choice.is-correct .tv-choice__key { color: #fff; background: var(--color-success); }
.is-result .tv-choice.is-correct .tv-choice__fill { background: rgba(46, 125, 50, 0.18); }

.question__foot { display: flex; align-items: center; justify-content: space-between; gap: 2rem; min-height: 3rem; font-size: 1.3rem; font-weight: var(--font-weight-semibold); color: var(--color-text-secondary); }
.answered { display: flex; align-items: center; gap: 1.2rem; }
.answered .progress { width: 16rem; height: 0.7rem; }
.facts { display: flex; flex-wrap: wrap; gap: 0.4rem 2.2rem; justify-content: flex-end; }
.facts strong { color: var(--color-text-primary); font-weight: var(--font-weight-black); }

/* ==========================================================================
   Classement
   ========================================================================== */
.ranking { display: flex; flex-direction: column; align-items: center; gap: 1.3rem; }
.ranking__head { text-align: center; }
.ranking__head h1 { font-size: 3rem; }
.ranking__head p { margin-top: 0.3rem; font-size: 1.2rem; font-weight: var(--font-weight-semibold); color: var(--color-text-secondary); }

/* Classement à gauche, palmarès à droite (centré seul s'il n'y a pas encore de statistiques) */
.ranking__body { display: grid; grid-template-columns: minmax(0, 52rem) 29rem; gap: 3.5rem; align-items: stretch; justify-content: center; width: 100%; }
.ranking__body.is-solo { grid-template-columns: minmax(0, 62rem); }
.ranking__body .stats-card { justify-content: space-evenly; }      /* même hauteur que la liste, items répartis */

.rank-list { position: relative; width: 100%; flex: none; }
.rank-row {
  position: absolute; left: 0; right: 0;
  display: grid; grid-template-columns: 3.4rem 1fr auto 7rem; align-items: center; gap: 1.1rem;
  height: 3.2rem; padding: 0 1.3rem 0 0.7rem;
  background: var(--color-bg-white);
  border: 0.8px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: transform 1100ms cubic-bezier(0.2, 0.8, 0.2, 1), opacity 600ms var(--ease);
  will-change: transform;
}
.rank-row__rank { display: grid; place-items: center; width: 2.4rem; height: 2.4rem; font-size: 1.2rem; font-weight: var(--font-weight-black); background: var(--color-bg-grey-light); border-radius: 50%; transition: background-color 400ms var(--ease), color 400ms var(--ease); }
.rank-row[data-rank="1"] .rank-row__rank { color: #fff; background: var(--color-primary); }
.rank-row[data-rank="2"] .rank-row__rank { color: #fff; background: var(--color-bg-dark); }
.rank-row[data-rank="3"] .rank-row__rank { color: #fff; background: #616161; }
.rank-row__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 1.5rem; font-weight: var(--font-weight-bold); }
.rank-row__gain { padding: 0.1rem 0.6rem; font-size: 1.1rem; font-weight: var(--font-weight-black); color: var(--color-success); background: var(--color-success-bg); border-radius: var(--radius-sm); animation: pop 420ms var(--ease) both; }
.rank-row__score { text-align: right; font-size: 1.8rem; font-weight: var(--font-weight-black); font-variant-numeric: tabular-nums; }

/* ==========================================================================
   Podium
   ========================================================================== */
.final { display: flex; flex-direction: column; align-items: center; gap: 0.9rem; }
.final__head { text-align: center; }
.final__head h1 { font-size: 2.6rem; }
.final__head p { margin-top: 0.2rem; font-size: 1.3rem; font-weight: var(--font-weight-semibold); color: var(--color-text-secondary); }

/* Podium à gauche, palmarès à droite, alignés par le bas */
.final__top { display: flex; align-items: flex-end; justify-content: center; gap: 4rem; width: 100%; margin-top: 0.4rem; }
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 1.2rem; }
.podium__col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; width: 15rem; }
.podium__who { max-width: 100%; margin-bottom: 0.7rem; text-align: center; animation: view-in 700ms var(--ease) both; animation-delay: var(--d, 0ms); }
.podium__name { max-width: 14.5rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 1.9rem; font-weight: var(--font-weight-black); }
.podium__score { font-size: 1.3rem; font-weight: var(--font-weight-bold); color: var(--color-text-secondary); }
.podium__bar {
  display: flex; justify-content: center; width: 100%; padding-top: 0.7rem;
  font-size: 3.2rem; font-weight: var(--font-weight-black); color: #fff;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  transform-origin: bottom;
  animation: podium-grow 1000ms var(--ease) both;
  animation-delay: var(--d0, 0ms);
}
@keyframes podium-grow { from { transform: scaleY(0); } }
.podium__col[data-rank="1"] .podium__bar { height: 13.5rem; background: var(--color-primary); }
.podium__col[data-rank="2"] .podium__bar { height: 10.5rem; background: var(--color-bg-dark); }
.podium__col[data-rank="3"] .podium__bar { height: 8rem; background: #616161; }
.podium__col[data-rank="1"] .podium__name { color: var(--color-primary); font-size: 2.2rem; }
.podium__crown { display: block; margin: 0 auto 0.2rem; width: 2.6rem; height: 2.6rem; color: var(--color-primary); }

.final__rest { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem 2.5rem; width: min(70rem, 100%); margin-top: 0.6rem; animation: view-in 700ms var(--ease) both; animation-delay: 3600ms; }
.final__rest .rank-row { position: static; height: 2.6rem; grid-template-columns: 3rem 1fr 6rem; transition: none; }
.final__rest .rank-row__name { font-size: 1.3rem; }
.final__rest .rank-row__score { font-size: 1.5rem; }

/* ==========================================================================
   Palmarès (classement et podium)
   ========================================================================== */
.stats-card {
  display: flex; flex-direction: column; gap: 1.1rem;
  width: 29rem; flex: none;
  padding: 1.5rem 1.6rem;
  background: var(--color-bg-beige);
  border: 0.8px solid var(--color-border);
  border-radius: var(--radius-lg);
  animation: view-in 600ms var(--ease) both;
  animation-delay: 400ms;
}
.stats-card h2 { margin: 0 0 0.2rem; font-size: 1.3rem; font-weight: var(--font-weight-black); letter-spacing: 0.04em; text-transform: uppercase; }
.stat-item { display: flex; align-items: center; gap: 1rem; }
.stat-item__icon { flex: none; display: grid; place-items: center; width: 3rem; height: 3rem; color: #fff; background: var(--color-bg-dark); border-radius: 50%; }
.stat-item__icon .icon { width: 1.7rem; height: 1.7rem; }
.stat-item--speed .stat-item__icon { background: var(--color-primary); }
.stat-item--good  .stat-item__icon { background: var(--color-success); }
.stat-item--bad   .stat-item__icon { background: var(--color-text-disabled); }
.stat-item__text { min-width: 0; }
.stat-item__label { font-size: 0.95rem; font-weight: var(--font-weight-bold); letter-spacing: 0.04em; text-transform: uppercase; color: var(--color-text-secondary); }
.stat-item__who { display: flex; flex-direction: column; }
.stat-item__who strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 1.5rem; font-weight: var(--font-weight-black); line-height: 1.2; }
.stat-item__who span { font-size: 1.05rem; font-weight: var(--font-weight-semibold); color: var(--color-text-secondary); }
.stat-item__none { font-size: 1.5rem; font-weight: var(--font-weight-bold); color: var(--color-text-disabled); }

/* Version compacte (écran de fin, où la hauteur est comptée) */
.stats-card--compact { gap: 0.7rem; padding: 1.1rem 1.4rem; }
.stats-card--compact h2 { margin-bottom: 0; font-size: 1.15rem; }
.stats-card--compact .stat-item { gap: 0.85rem; }
.stats-card--compact .stat-item__icon { width: 2.5rem; height: 2.5rem; }
.stats-card--compact .stat-item__icon .icon { width: 1.4rem; height: 1.4rem; }
.stats-card--compact .stat-item__label { font-size: 0.85rem; }
.stats-card--compact .stat-item__who strong { font-size: 1.3rem; }
.stats-card--compact .stat-item__who span { font-size: 0.95rem; }

/* ==========================================================================
   Superpositions
   ========================================================================== */
.tv-overlay { position: absolute; inset: 0; z-index: 20; display: grid; place-items: center; background: rgba(255, 255, 255, 0.92); animation: view-in 250ms var(--ease) both; }
.tv-overlay[hidden] { display: none; }
.tv-overlay__box { display: flex; flex-direction: column; align-items: center; gap: 0.8rem; text-align: center; color: var(--color-text-secondary); font-size: 1.5rem; font-weight: var(--font-weight-semibold); }
.tv-overlay__box strong { font-size: 3.6rem; font-weight: var(--font-weight-black); text-transform: uppercase; color: var(--color-text-primary); }
.tv-overlay__box .icon { width: 7rem; height: 7rem; color: var(--color-primary); }

.tv-netbanner { position: absolute; left: 50%; bottom: 1.2rem; z-index: 30; padding: 0.6rem 1.4rem; font-size: 1.1rem; font-weight: var(--font-weight-bold); color: var(--color-warning); background: var(--color-warning-bg); border: 0.8px solid var(--color-border); border-radius: var(--radius-md); transform: translateX(-50%); }
.tv-netbanner[hidden] { display: none; }

/* Invitation à activer le son : dans la barre du haut, à côté des pastilles, pour ne jamais masquer le contenu */
.tv-soundprompt { height: 2.3rem; padding: 0 1.1rem; font: inherit; font-size: 1rem; font-weight: var(--font-weight-bold); letter-spacing: 0.04em; text-transform: uppercase; color: #fff; background: var(--color-bg-black); border: 0; border-radius: var(--radius-sm); cursor: pointer; animation: pulse 2s ease-in-out infinite; }
.tv-soundprompt[hidden] { display: none; }

@media (prefers-reduced-motion: reduce) {
  .countdown.is-urgent, .tv-soundprompt { animation: none; }
}

/* ==========================================================================
   Règles du jeu (avant le décompte) : titre + cinq puces courtes
   ========================================================================== */
.rules { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2.4rem; }
.rules__title { margin: 0; font-size: 4rem; text-align: center; }
.rules-list { display: flex; flex-direction: column; gap: 1.7rem; width: 100%; max-width: 76rem; margin: 0; padding: 0; list-style: none; }
.rules-row { display: flex; align-items: center; gap: 1.8rem; animation: view-in 600ms var(--ease) both; }
.rules-row:nth-child(2) { animation-delay: 150ms; }
.rules-row:nth-child(3) { animation-delay: 300ms; }
.rules-row:nth-child(4) { animation-delay: 450ms; }
.rules-row:nth-child(5) { animation-delay: 600ms; }
.rules-row__icon { flex: none; display: grid; place-items: center; width: 4.8rem; height: 4.8rem; color: #fff; background: var(--color-primary); border-radius: 50%; }
.rules-row__icon .icon { width: 2.6rem; height: 2.6rem; }
.rules-row__text { font-size: 2.5rem; font-weight: var(--font-weight-semibold); line-height: 1.3; }
.rules-row__text strong { font-weight: var(--font-weight-black); color: var(--color-primary); }
.rules-levels { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 2rem; vertical-align: middle; }
.rules-lv { display: inline-flex; align-items: center; gap: 0.5rem; }
.rules-lv strong { color: var(--color-text-primary); }
