:root {
  --nuit: #0A0D24;
  --encre: #151A3D;
  --encre-2: #1E2450;
  --aube: #FFB23E;
  --corail: #FF6A4D;
  --lune: #EEF0FA;
  --brume: #9AA0C8;
  --display: 'Syne', 'Arial Black', system-ui, sans-serif;
  --mono: 'Martian Mono', 'IBM Plex Mono', ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--nuit) url('contours.svg') center / cover fixed no-repeat;
  color: var(--lune);
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--aube); outline-offset: 3px; }
h1, h2, h3 { font-family: var(--display); font-weight: 800; margin: 0; line-height: 1.02; }
p { margin: 0; }
.muted { color: var(--brume); }

/* ---------- Route de progression (10 étapes) ---------- */
.route { list-style: none; margin: 0; padding: 0; display: flex; align-items: center; gap: 0; }
.route li { flex: 1; display: flex; align-items: center; }
.route li::after { content: ''; flex: 1; border-top: 2px dotted rgba(238, 240, 250, 0.35); margin: 0 4px; }
.route li:last-child { flex: 0; }
.route li:last-child::after { display: none; }
.route span { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--aube); flex-shrink: 0; }
.route .done span { background: var(--aube); }
.route .current span { border-color: var(--corail); box-shadow: 0 0 0 4px rgba(255, 106, 77, 0.3); }

/* ---------- Code ---------- */
.code {
  margin: 0;
  background: rgba(21, 26, 61, 0.92);
  border: 2px solid rgba(255, 178, 62, 0.45);
  border-radius: 14px;
  padding: 1em 1.2em;
  font-family: var(--mono);
  white-space: pre;
  overflow: auto;
  color: var(--lune);
  line-height: 1.45;
}

/* ---------- Timer ---------- */
.timer-bar { height: 6px; border-radius: 3px; background: rgba(238, 240, 250, 0.15); overflow: hidden; }
.timer-bar i { display: block; height: 100%; background: var(--aube); width: 100%; transition: width 0.2s linear; }
.timer-bar.late i { background: var(--corail); }

/* ---------- Équipes ---------- */
.team-dot { display: inline-block; width: 0.8em; height: 0.8em; border-radius: 50%; background: var(--tc); vertical-align: -0.05em; }
.bar { height: 100%; border-radius: 8px; background: var(--tc); min-width: 6px; transition: width 0.8s cubic-bezier(.2,.8,.2,1); }

@media (prefers-reduced-motion: reduce) {
  .bar, .timer-bar i { transition: none; }
}

/* =========================================================
   Téléphone
   ========================================================= */
.phone { max-width: 520px; margin: 0 auto; min-height: 100%; padding: 20px 18px 32px; display: flex; flex-direction: column; gap: 22px; }
.phone .brand { font-family: var(--display); font-weight: 800; font-size: 28px; letter-spacing: -0.01em; }
.phone .brand small { display: block; font-family: var(--mono); font-weight: 400; font-size: 12px; color: var(--aube); letter-spacing: 0.04em; margin-top: 4px; }
.phone h2 { font-size: 30px; }
.phone .code { font-size: 13px; max-height: 38vh; }

.field { display: flex; flex-direction: column; gap: 8px; }
.field label { font-size: 13px; color: var(--brume); }
.field input {
  font: inherit; font-size: 18px; color: var(--lune);
  background: var(--encre); border: 2px solid rgba(238, 240, 250, 0.2); border-radius: 12px; padding: 14px 16px;
}
.team-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.team-pick button {
  text-align: left; background: var(--encre); border: 2px solid rgba(238, 240, 250, 0.15); border-radius: 14px;
  padding: 14px; min-height: 96px; display: flex; flex-direction: column; justify-content: space-between; gap: 6px;
}
.team-pick button b { font-family: var(--display); font-size: 17px; color: var(--tc); overflow-wrap: anywhere; }
.team-pick button small { font-size: 11px; color: var(--brume); line-height: 1.35; }
.team-pick button[aria-pressed="true"] { border-color: var(--tc); background: color-mix(in srgb, var(--tc) 16%, var(--encre)); }

.primary {
  background: var(--aube); color: var(--nuit); border: 0; border-radius: 14px; padding: 16px 20px;
  font-family: var(--display); font-weight: 800; font-size: 20px;
}
.primary:disabled { opacity: 0.4; cursor: default; }
.linkish { background: none; border: 0; color: var(--brume); text-decoration: underline; padding: 6px 0; font-size: 13px; align-self: flex-start; }
.error { color: var(--corail); font-size: 14px; }

.badge { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; background: color-mix(in srgb, var(--tc) 18%, transparent); border: 1.5px solid var(--tc); font-size: 13px; }
.badge b { font-family: var(--display); color: var(--tc); font-size: 15px; }

.qhead { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.qhead .t { font-family: var(--display); font-weight: 800; font-size: 34px; line-height: 1; }

.answers { display: flex; flex-direction: column; gap: 10px; }
.answers button {
  display: flex; align-items: center; gap: 14px; text-align: left;
  background: var(--encre); border: 2px solid rgba(238, 240, 250, 0.18); border-radius: 14px;
  padding: 14px 16px; min-height: 64px; font-family: var(--display); font-weight: 800; font-size: 20px;
}
.answers button:active { transform: scale(0.98); }
.answers button .k, .choices .k {
  flex-shrink: 0; width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--aube); color: var(--aube);
  display: grid; place-items: center; font-family: var(--mono); font-size: 14px; font-weight: 500;
}

.verdict { border-radius: 18px; padding: 22px; display: flex; flex-direction: column; gap: 6px; }
.verdict.ok { background: var(--aube); color: var(--nuit); }
.verdict.ko { background: var(--encre); border: 2px solid var(--corail); }
.verdict .big { font-family: var(--display); font-weight: 800; font-size: 34px; line-height: 1.05; }

.standings { display: flex; flex-direction: column; gap: 10px; }
.standings .row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: baseline; }
.standings .row .name { font-family: var(--display); font-weight: 800; font-size: 18px; color: var(--tc); }
.standings .row .score { font-size: 16px; }
.standings .row .track { grid-column: 1 / -1; height: 10px; }
.standings .row .detail { grid-column: 1 / -1; font-size: 12px; color: var(--brume); }

.waiting { display: flex; flex-direction: column; gap: 14px; padding: 22px; border-radius: 18px; background: rgba(21, 26, 61, 0.85); border: 1.5px dashed rgba(238, 240, 250, 0.25); }

/* =========================================================
   Projection (admin)
   ========================================================= */
.screen { height: 100vh; padding: 3.2vh 3.4vw; display: flex; flex-direction: column; gap: 3vh; overflow: hidden; }
.screen .top { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 3vw; }
.screen .top .label { font-family: var(--display); font-weight: 800; font-size: 3.4vh; white-space: nowrap; }
.screen .top .clock { font-family: var(--display); font-weight: 800; font-size: 7vh; line-height: 1; min-width: 2.2ch; text-align: right; color: var(--aube); }
.screen .top .clock.late { color: var(--corail); }

/* Accueil */
.lobby { flex: 1; display: grid; grid-template-columns: 1.15fr 0.85fr; grid-template-rows: auto 1fr; gap: 4vh 4vw; min-height: 0; }
.lobby .title h1 { font-size: 15vh; letter-spacing: -0.02em; }
.lobby .title p { font-size: 2.6vh; color: var(--aube); margin-top: 1.6vh; }
.lobby .join { grid-row: 1 / span 2; grid-column: 2; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2.4vh; }
.lobby .qr { background: var(--lune); padding: 2.4vh; border-radius: 22px; }
.lobby .qr img, .lobby .qr canvas { display: block; width: 46vh; height: 46vh; }
.lobby .join .url { font-size: 2.6vh; text-align: center; word-break: break-all; }
.lobby .join .count { font-family: var(--display); font-weight: 800; font-size: 4vh; }
.lobby .teams { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2vh 2vw; min-height: 0; }
.lobby .team { background: rgba(21, 26, 61, 0.9); border-radius: 18px; border-top: 6px solid var(--tc); padding: 2vh 1.4vw; display: flex; flex-direction: column; gap: 0.8vh; min-height: 0; overflow: hidden; }
.lobby .team h3 { font-size: 3.6vh; color: var(--tc); display: flex; justify-content: space-between; align-items: baseline; gap: 1vw; }
.lobby .team h3 span { font-family: var(--mono); font-weight: 400; font-size: 2.4vh; color: var(--lune); }
.lobby .team .tag { font-size: 1.7vh; color: var(--brume); }
.lobby .team .names { font-size: 1.9vh; line-height: 1.5; overflow: hidden; }

/* Question */
.ask { flex: 1; display: grid; grid-template-columns: 1.35fr 1fr; gap: 3vw; min-height: 0; }
.ask .code { height: 100%; font-size: 4vh; display: flex; align-items: center; overflow: hidden; }
.choices { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2vh; justify-content: center; }
.choices li { display: flex; align-items: center; gap: 1.6vw; padding: 2.2vh 1.6vw; border-radius: 18px; background: rgba(21, 26, 61, 0.9); border: 2px solid rgba(238, 240, 250, 0.15); font-family: var(--display); font-weight: 800; font-size: 4.2vh; line-height: 1.1; }
.choices .k { width: 6vh; height: 6vh; font-size: 2.4vh; }
.choices li.right { background: var(--aube); color: var(--nuit); border-color: var(--aube); }
.choices li.right .k { border-color: var(--nuit); color: var(--nuit); }
.choices li.wrong { opacity: 0.35; }
.footer-line { display: flex; justify-content: space-between; align-items: center; gap: 2vw; font-size: 2.4vh; }
.footer-line .timer-bar { flex: 1; height: 1.2vh; }

/* Résultats */
.results { flex: 1; display: grid; grid-template-columns: 1fr 1.25fr; gap: 4vw; min-height: 0; }
.results .reveal { display: flex; flex-direction: column; gap: 2.4vh; min-height: 0; }
.results .reveal .code { font-size: 2.4vh; max-height: 34vh; overflow: hidden; }
.results .reveal .answer { font-family: var(--display); font-weight: 800; font-size: 7vh; line-height: 1.05; color: var(--aube); overflow-wrap: break-word; }
.results .reveal .anecdote { font-size: 2.3vh; line-height: 1.55; max-width: 60ch; }
.board { display: flex; flex-direction: column; justify-content: center; gap: 3vh; min-width: 0; }
.board .row { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 2vw; row-gap: 0.8vh; align-items: baseline; }
.board .row .name { font-family: var(--display); font-weight: 800; font-size: 3.6vh; color: var(--tc); grid-column: 1; grid-row: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.board .row .score { font-family: var(--display); font-weight: 800; font-size: 3.6vh; text-align: right; grid-column: 2; grid-row: 1; }
.board .row .track { height: 3.2vh; grid-column: 1 / -1; grid-row: 2; }
.board .row .detail { font-size: 1.9vh; color: var(--brume); grid-column: 1 / -1; grid-row: 3; }
.board .row .detail b { color: var(--lune); font-weight: 500; }

/* Récap */
.final { flex: 1; display: grid; grid-template-columns: 1.4fr 1fr; gap: 4vw; min-height: 0; }
.final h1 { font-size: 11vh; letter-spacing: -0.02em; }
.final .podium { display: flex; flex-direction: column; gap: 2.4vh; margin-top: 4vh; }
.final .podium .row { display: grid; grid-template-columns: 6vh 1fr auto; align-items: center; gap: 1.6vw; padding: 2vh 1.6vw; border-radius: 18px; background: rgba(21, 26, 61, 0.9); border-left: 8px solid var(--tc); }
.final .podium .row:first-child { background: var(--tc); color: var(--nuit); }
.final .podium .rank { font-family: var(--display); font-weight: 800; font-size: 5vh; }
.final .podium .name { font-family: var(--display); font-weight: 800; font-size: 5vh; line-height: 1; }
.final .podium .name small { display: block; font-family: var(--mono); font-weight: 400; font-size: 1.9vh; margin-top: 0.8vh; opacity: 0.85; }
.final .podium .score { font-family: var(--display); font-weight: 800; font-size: 5.4vh; }
.final .best { display: flex; flex-direction: column; gap: 1.6vh; justify-content: center; }
.final .best h2 { font-size: 4vh; margin-bottom: 1vh; }
.final .best ol { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 1.4vh; }
.final .best li { display: grid; grid-template-columns: 4vh 1fr auto; gap: 1vw; align-items: baseline; font-size: 2.6vh; }
.final .best li .n { font-family: var(--display); font-weight: 800; color: var(--aube); }
.final .best li .who b { font-family: var(--display); font-weight: 800; font-size: 3vh; }

/* Barre de pilotage */
.controls {
  position: fixed; right: 2vw; bottom: 2vh; display: flex; gap: 8px; align-items: center;
  background: rgba(10, 13, 36, 0.92); border: 1.5px solid rgba(238, 240, 250, 0.2); border-radius: 14px; padding: 8px;
  font-size: 13px; z-index: 10;
}
.controls[hidden] { display: none; }
body.with-controls .screen { padding-bottom: 10vh; }
.controls button { background: var(--encre-2); border: 0; border-radius: 10px; padding: 10px 14px; }
.controls button.go { background: var(--aube); color: var(--nuit); font-family: var(--display); font-weight: 800; font-size: 15px; }
.controls .hint { color: var(--brume); padding: 0 6px; }
.gate { height: 100vh; display: grid; place-items: center; text-align: center; padding: 24px; }
.gate p { max-width: 46ch; margin-top: 12px; color: var(--brume); }
