:root {
  --bg: #05060d;
  --bg-2: #0a0c18;
  --panel: rgba(18, 22, 40, 0.55);
  --panel-brd: rgba(120, 160, 255, 0.18);
  --cyan: #21e7ff;
  --magenta: #ff2bd6;
  --violet: #8b7bff;
  --green: #3dffb0;
  --amber: #ffcf4d;
  --text: #dfe6ff;
  --dim: #7b86b0;
  --glow-cyan: 0 0 8px rgba(33, 231, 255, 0.65), 0 0 22px rgba(33, 231, 255, 0.35);
  --glow-mag: 0 0 8px rgba(255, 43, 214, 0.6), 0 0 22px rgba(255, 43, 214, 0.3);
  --radius: 12px;
  --font: "Segoe UI", system-ui, sans-serif;
  --mono: "Cascadia Code", "SF Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 800px at 15% -10%, rgba(33, 231, 255, 0.08), transparent 60%),
    radial-gradient(1000px 700px at 100% 0%, rgba(255, 43, 214, 0.07), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  overflow-x: hidden;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 14px 18px 22px;
  gap: 14px;
}
@media (max-width: 560px) { body { padding: 10px 10px 16px; gap: 10px; } }

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--panel-brd);
}
.brand { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.brand .logo { color: var(--cyan); font-size: 22px; text-shadow: var(--glow-cyan); }
.brand .title {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 3px;
  color: #fff;
  text-shadow: var(--glow-cyan);
}
.brand .sub { color: var(--dim); font-size: 13px; letter-spacing: 0.4px; }

.status { display: flex; gap: 8px; align-items: center; }
.pill {
  font-family: var(--mono);
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--panel-brd);
  white-space: nowrap;
}
.pill-idle { color: var(--amber); border-color: rgba(255, 207, 77, 0.4); }
.pill-live { color: var(--green); border-color: rgba(61, 255, 176, 0.5); box-shadow: 0 0 12px rgba(61, 255, 176, 0.25); }
.pill-err  { color: #ff6b6b; border-color: rgba(255, 107, 107, 0.5); }
.pill-ghost { color: var(--dim); }

/* ---------- Stage ---------- */
.stage {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-auto-rows: auto;
  gap: 14px;
  min-height: 0;
}
@media (max-width: 900px) { .stage { grid-template-columns: 1fr; } }

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-brd);
  border-radius: var(--radius);
  padding: 12px 14px 14px;
  backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.panel h2 {
  margin: 0 0 10px;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--cyan);
  text-shadow: var(--glow-cyan);
}
.cockpit h2 { color: var(--magenta); text-shadow: var(--glow-mag); }

.viewport {
  position: relative;
  width: 100%;
  flex: 0 0 auto;
  aspect-ratio: 16 / 10;
  max-height: 56vh;
  min-height: 220px;
  border-radius: 10px;
  overflow: hidden;
  background: #02030a;
  border: 1px solid rgba(120, 160, 255, 0.12);
}
@media (max-width: 900px) { .viewport { max-height: none; } }
.viewport canvas, .viewport video { position: absolute; inset: 0; width: 100%; height: 100%; }
#webcam { object-fit: cover; opacity: 0; pointer-events: none; }
#overlay { z-index: 2; }
#scene { display: block; }

.hint {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-align: center;
  color: var(--text);
  background: rgba(2, 3, 10, 0.72);
}
.hint p { margin: 2px; font-size: 14px; }
.hint .dim { color: var(--dim); font-size: 12px; }
.hint.hidden { display: none; }
.spinner {
  width: 34px; height: 34px; margin-bottom: 8px;
  border: 3px solid rgba(33, 231, 255, 0.2);
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.readouts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 12px;
}
.ro { display: flex; gap: 6px; align-items: baseline; }
.ro b { color: var(--dim); font-weight: 500; }
.ro i { color: var(--text); font-style: normal; min-width: 40px; }

/* ---------- Controls ---------- */
.controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 0 0 auto;
  background: var(--panel);
  border: 1px solid var(--panel-brd);
  border-radius: var(--radius);
  padding: 14px 18px;
  backdrop-filter: blur(6px);
}

/* Barre essentielle (toujours visible) : source + boutons clés */
.ctl-essential { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 20px; }
.ctl-src { display: flex; flex-direction: column; gap: 6px; flex: 1 1 240px; }
.ctl-essential .btn-row { flex: 2 1 360px; }

/* Réglages avancés repliables (dégage la place pour le jeu) */
.adv-settings { border-top: 1px solid var(--panel-brd); padding-top: 8px; }
.adv-settings > summary {
  cursor: pointer; list-style: none; font-family: var(--mono); font-size: 12px;
  letter-spacing: 1px; text-transform: uppercase; color: var(--dim);
  padding: 4px 0; display: flex; align-items: center; gap: 8px;
}
.adv-settings > summary::-webkit-details-marker { display: none; }
.adv-settings > summary::before { content: "▸"; color: var(--cyan); transition: transform 0.15s; }
.adv-settings[open] > summary::before { transform: rotate(90deg); }
.adv-settings > summary:hover { color: var(--text); }
.adv-body { display: grid; grid-template-columns: 1.7fr 1fr; gap: 16px 26px; margin-top: 12px; }
.adv-body .tip { grid-column: 1 / -1; }
@media (max-width: 760px) { .adv-body { grid-template-columns: 1fr; } }
@media (max-width: 1150px) {
  .controls { grid-template-columns: 1fr 1fr; }
  .controls .toggles { grid-column: 1 / -1; }
  .toggles { flex-direction: row; flex-wrap: wrap; gap: 8px 18px; }
}
@media (max-width: 760px) { .controls { grid-template-columns: 1fr; } }

.ctl-group { display: flex; flex-direction: column; gap: 12px; }
.ctl-label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--dim);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  background: rgba(0, 0, 0, 0.3);
  padding: 5px;
  border-radius: 10px;
  border: 1px solid var(--panel-brd);
}
.segmented button {
  font-family: var(--font);
  font-size: 13px;
  padding: 8px 4px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--dim);
  cursor: pointer;
  transition: all 0.15s;
}
.segmented button:hover { color: var(--text); }
.segmented button.active {
  color: #001018;
  background: var(--cyan);
  box-shadow: var(--glow-cyan);
  font-weight: 600;
}

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn {
  font-family: var(--font);
  font-size: 13px;
  padding: 9px 14px;
  border-radius: 9px;
  border: 1px solid var(--panel-brd);
  background: rgba(120, 160, 255, 0.06);
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
}
.btn:hover:not(:disabled) { border-color: var(--cyan); box-shadow: var(--glow-cyan); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary {
  border-color: var(--magenta);
  color: #fff;
  background: rgba(255, 43, 214, 0.14);
}
.btn-primary:hover:not(:disabled) { border-color: var(--magenta); box-shadow: var(--glow-mag); }
/* Appel d'attention sur "Démarrer la webcam" (clignote jusqu'au 1er clic ; classe retirée au démarrage). */
.btn-cam-attn { animation: camAttn 1.25s ease-in-out infinite; }
@keyframes camAttn {
  0%, 100% { box-shadow: 0 0 0 rgba(255, 43, 214, 0); border-color: var(--panel-brd); }
  50% { box-shadow: var(--glow-mag); border-color: var(--magenta); }
}
@media (prefers-reduced-motion: reduce) { .btn-cam-attn { animation: none; } }
.btn-ghost { color: var(--dim); }

/* Curseurs compacts : grille auto-fit, plus petits, responsive. */
.sliders {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: 10px 18px;
  align-content: start;
}
.slider label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--text);
  margin-bottom: 4px;
}
.slider output { font-family: var(--mono); color: var(--cyan); }
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--cyan), var(--violet));
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px; height: 13px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--glow-cyan);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 13px; height: 13px; border: none;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--glow-cyan);
  cursor: pointer;
}

.toggles { gap: 9px; }
.tog {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}
.tog input { accent-color: var(--magenta); width: 15px; height: 15px; }

/* ---------- Calibration overlay ---------- */
.cal-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: rgba(2, 3, 10, 0.35);
}
.cal-overlay.hidden { display: none; }
.cal-info {
  position: absolute;
  top: 6%;
  left: 0;
  right: 0;
  text-align: center;
  font-family: var(--mono);
  font-size: 16px;
  color: #fff;
  text-shadow: var(--glow-cyan);
}
.cal-progress { color: var(--cyan); }
.cal-hint {
  position: absolute;
  bottom: 6%;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 13px;
  color: var(--dim);
}
.cal-hint b { color: var(--text); }
.cal-cross {
  position: absolute;
  width: 46px;
  height: 46px;
  transform: translate(-50%, -50%);
  transition: left 0.35s ease, top 0.35s ease;
}
.cal-cross span {
  position: absolute;
  background: var(--green);
  box-shadow: 0 0 10px rgba(61, 255, 176, 0.9), 0 0 22px rgba(61, 255, 176, 0.5);
}
.cal-cross span:first-child { left: 50%; top: 0; width: 2px; height: 100%; transform: translateX(-50%); }
.cal-cross span:last-child { top: 50%; left: 0; height: 2px; width: 100%; transform: translateY(-50%); }
.cal-cross::after {
  content: "";
  position: absolute;
  inset: 50% auto auto 50%;
  width: 8px; height: 8px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.9);
}
.cal-cross.flash { animation: calFlash 0.35s ease; }
.cal-cross.flash-err { animation: calErr 0.35s ease; }
@keyframes calFlash { 0% { transform: translate(-50%, -50%) scale(1); } 40% { transform: translate(-50%, -50%) scale(1.5); } 100% { transform: translate(-50%, -50%) scale(1); } }
@keyframes calErr { 0%, 100% { transform: translate(-50%, -50%); } 25% { transform: translate(-58%, -50%); } 75% { transform: translate(-42%, -50%); } }

/* ---------- Jeu ---------- */
.goverlay {
  position: absolute;
  inset: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(2, 3, 10, 0.7);
  backdrop-filter: blur(3px);
}
.goverlay.hidden { display: none; }
.gcard {
  text-align: center;
  padding: 26px 34px;
  border: 1px solid var(--panel-brd);
  border-radius: 14px;
  background: rgba(12, 16, 32, 0.7);
  box-shadow: 0 0 40px rgba(33, 231, 255, 0.15);
  max-width: 82%;
}
.gcard h3 {
  margin: 4px 0 8px;
  font-family: var(--mono);
  font-size: 24px;
  letter-spacing: 2px;
  color: #fff;
  text-shadow: var(--glow-cyan);
}
.gkicker {
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--magenta);
  text-shadow: var(--glow-mag);
}
.gdesc { margin: 6px 0 18px; font-size: 14px; color: var(--dim); line-height: 1.5; }
.gdesc b { color: var(--text); }
.btn.big { font-size: 16px; padding: 12px 26px; }

.ghud {
  position: absolute;
  inset: 0;
  z-index: 12;
  pointer-events: none;
}
/* Le HUD (vie, score, niveau) NE doit PAS s'afficher au menu : la règle .hidden manquait pour .ghud
   (elle existait pour tous les autres overlays) -> vie/score/dernier stage restaient visibles au repos. */
.ghud.hidden { display: none; }
/* HUD « arcade » : éléments nettement plus gros (retour user). clamp() = lisible en fenêtré ET énorme
   en plein écran (où l'on joue). */
.ghud-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
}
.hp { display: flex; align-items: center; gap: 12px; }
.hp-label { font-family: var(--mono); font-size: clamp(14px, 1.6vw, 20px); font-weight: 700; color: #cfe; letter-spacing: 1px; }
.hpbar {
  width: clamp(220px, 26vw, 360px); height: clamp(16px, 2vw, 24px);
  border-radius: 999px;
  border: 2px solid var(--panel-brd);
  background: rgba(0, 0, 0, 0.4);
  overflow: hidden;
}
#hpFill {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #ff3b6b, #ffcf4d, #3dffb0);
  box-shadow: 0 0 12px rgba(61, 255, 176, 0.5);
  transition: width 0.25s ease;
}
.ghud-right { display: flex; align-items: baseline; gap: clamp(18px, 2.6vw, 38px); }
.gstat { font-family: var(--mono); font-size: clamp(15px, 1.9vw, 26px); font-weight: 700; color: #bcd; letter-spacing: 1px; }
.gstat b { color: #fff; font-weight: 900; text-shadow: var(--glow-cyan); }
/* Le SCORE = le chiffre vedette (arcade), encore plus gros. */
#scoreVal { font-size: clamp(20px, 2.9vw, 40px); }
.gcombo b { font-size: clamp(18px, 2.4vw, 34px); }

.gtoast {
  position: absolute;
  top: 34%;
  left: 0; right: 0;
  z-index: 13;
  text-align: center;
  font-family: var(--mono);
  font-size: 44px;
  font-weight: 700;
  color: #fff;
  text-shadow: var(--glow-cyan);
  pointer-events: none;
}

#gameVignette {
  position: absolute;
  inset: 0;
  z-index: 11;
  pointer-events: none;
  opacity: 0;
  box-shadow: inset 0 0 90px 30px rgba(255, 40, 60, 0.9);
}
#gameVignette.flash { animation: vignetteFlash 0.4s ease; }
/* Flash VERT de soin (Éclat ramassé -> +vie). */
#gameVignette.heal { box-shadow: inset 0 0 80px 26px rgba(34, 224, 107, 0.8); animation: vignetteFlash 0.45s ease; }
@keyframes vignetteFlash { 0% { opacity: 0.9; } 100% { opacity: 0; } }

#finishFlash { position: absolute; inset: 0; z-index: 16; pointer-events: none; background: #fff; opacity: 0; }
#finishFlash.flash { animation: finishFlash 0.28s ease; }
@keyframes finishFlash { 0% { opacity: 0; } 8% { opacity: 0.95; } 100% { opacity: 0; } }

.title-xl { font-size: 40px !important; letter-spacing: 6px; }
.title-xl span { color: var(--magenta); text-shadow: var(--glow-mag); }
.gcombo b { color: var(--magenta) !important; text-shadow: var(--glow-mag); }

.map-wrap { text-align: center; width: min(92%, 520px); }
.map-nodes { display: flex; flex-direction: column-reverse; gap: 12px; margin: 18px 0; }
.map-node {
  display: flex; align-items: center; gap: 14px; justify-content: center;
  padding: 12px 16px; border-radius: 12px;
  border: 1px solid var(--panel-brd); background: rgba(12, 16, 32, 0.6);
  cursor: pointer; transition: all 0.15s; font-family: var(--mono);
}
.map-node:hover:not(.locked) { border-color: var(--cyan); box-shadow: var(--glow-cyan); transform: translateY(-2px); }
.map-node .mn-id { font-size: 18px; color: #fff; min-width: 40px; }
.map-node .mn-name { color: var(--dim); font-size: 13px; flex: 1; text-align: left; }
.map-node.current { border-color: var(--magenta); box-shadow: var(--glow-mag); }
.map-node.locked { opacity: 0.4; cursor: not-allowed; }
.map-node.boss .mn-id { color: var(--magenta); }
.mn-rank { font-family: var(--mono); font-weight: 700; font-size: 16px; }
.mn-rank.rank-S { color: var(--amber); } .mn-rank.rank-A { color: var(--cyan); } .mn-rank.rank-B { color: var(--green); } .mn-rank.rank-C { color: var(--dim); }

.chips { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 2px 0 12px; }
.chip { font-size: 12px; padding: 4px 12px; border-radius: 999px; border: 1px solid var(--panel-brd); color: var(--text); font-family: var(--mono); }
.gbest { font-family: var(--mono); font-size: 13px; color: var(--dim); margin: 0 0 14px; }
.btn-row.center { justify-content: center; flex-wrap: wrap; }

/* nowrap + result-main flexible : sur fenêtre étroite (cockpit ~350px) le mât NE passe plus SOUS
   le bloc en se centrant (retour user : "drapeau bizarre centré au lieu d'être au bord"). Il reste
   collé à droite, centré verticalement. */
.gcard.result { display: flex; gap: 18px; align-items: center; max-width: 92%; text-align: left; flex-wrap: nowrap; justify-content: center; }
.result-main { min-width: 0; flex: 1 1 auto; }
.gr-tally { margin: 14px 0 18px; font-family: var(--mono); min-height: 120px; }
.gr-row { display: flex; justify-content: space-between; gap: 30px; font-size: 15px; padding: 3px 0; color: var(--dim); }
.gr-row b { color: #fff; font-weight: 500; }
.gr-total { border-top: 1px solid var(--panel-brd); margin-top: 6px; padding-top: 8px; font-size: 18px; color: var(--text); }
.gr-total b { color: var(--cyan); text-shadow: var(--glow-cyan); }
.gr-pole { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.gr-pole-track { position: relative; width: 8px; height: 168px; border-radius: 999px; background: linear-gradient(to top, rgba(33, 231, 255, 0.14), rgba(255, 255, 255, 0.3)); box-shadow: 0 0 12px rgba(33, 231, 255, 0.45); }
/* socle du mât */
.gr-pole-track::after { content: ""; position: absolute; left: 50%; bottom: -5px; transform: translateX(-50%); width: 26px; height: 6px; border-radius: 999px; background: rgba(255, 255, 255, 0.25); box-shadow: 0 0 8px rgba(33, 231, 255, 0.4); }
/* drapeau clairement au SOMMET du mât, flottant vers la droite */
.gr-bead { position: absolute; left: 50%; bottom: 0; width: 18px; height: 18px; margin-left: -9px; margin-bottom: -3px; border-radius: 50%; background: #fff; box-shadow: 0 0 14px rgba(255, 255, 255, 0.9), 0 0 26px rgba(33, 231, 255, 0.7); transition: bottom 1.1s cubic-bezier(0.5, -0.2, 0.3, 1.4); }
.gr-rank { font-family: var(--mono); font-weight: 700; font-size: 44px; height: 52px; opacity: 0; transform: scale(1.6); transition: all 0.18s ease; }
.gr-rank.in { opacity: 1; transform: scale(1); }
.gr-rank.rank-S { color: var(--amber); text-shadow: 0 0 16px rgba(255, 207, 77, 0.8); }
.gr-rank.rank-A { color: var(--cyan); text-shadow: var(--glow-cyan); }
.gr-rank.rank-B { color: var(--green); }
.gr-rank.rank-C { color: var(--dim); }

.tip {
  grid-column: 1 / -1;
  margin: 4px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--panel-brd);
  font-size: 12.5px;
  color: var(--dim);
  line-height: 1.6;
}
.tip b { color: var(--text); font-weight: 600; }

/* ---------- Panneau Mission (hors fenêtre 3D) ---------- */
.mission {
  background: var(--panel);
  border: 1px solid var(--panel-brd);
  border-radius: var(--radius);
  padding: 16px 18px;
  backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.mission-scroll { display: flex; flex-direction: column; gap: 14px; }
.mission-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px 22px;
}
.m-block h3 {
  margin: 0 0 8px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--cyan);
  text-shadow: var(--glow-cyan);
}
.m-text { margin: 0; font-size: 13px; color: var(--dim); line-height: 1.55; }
.m-text b { color: var(--text); }
.cmd-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--dim); }
.cmd-list .k {
  display: inline-block; min-width: 58px; text-align: center;
  font-family: var(--mono); font-size: 12px; color: var(--text);
  padding: 2px 8px; margin-right: 8px;
  border: 1px solid var(--panel-brd); border-radius: 7px;
  background: rgba(120, 160, 255, 0.08);
}
/* Bloc « Mondes & stages » sur 2 colonnes : le sélecteur à gauche, la fiche du stage
   sélectionné à droite (remplit le vide à droite et rapproche l'info de la sélection). */
.m-level-cols { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(240px, 0.85fr); gap: 12px 20px; align-items: start; }
@media (max-width: 820px) { .m-level-cols { grid-template-columns: 1fr; } }
.m-levelinfo {
  margin: 0; font-size: 12.5px; color: var(--dim); line-height: 1.55;
  border: 1px solid var(--panel-brd); border-radius: 10px; padding: 11px 13px;
  background: rgba(120, 160, 255, 0.045); align-self: stretch;
}
.m-levelinfo b { color: var(--text); }
.m-levelinfo .dim { color: var(--dim); opacity: 0.85; }

.level-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.level-picker.locked-during-play { opacity: 0.5; pointer-events: none; }
.lv-node {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 12px; border-radius: 10px;
  border: 1px solid var(--panel-brd); background: rgba(12, 16, 32, 0.6);
  color: var(--text); cursor: pointer; font-family: var(--mono);
  transition: all 0.15s;
}
.lv-node:hover:not(.locked) { border-color: var(--cyan); box-shadow: var(--glow-cyan); transform: translateY(-1px); }
.lv-node .lv-id { font-size: 14px; }
.lv-node.sel { border-color: var(--magenta); box-shadow: var(--glow-mag); color: #fff; }
.lv-node.locked { opacity: 0.4; cursor: not-allowed; }
.lv-node.boss .lv-id { color: var(--magenta); }
.lv-rank { font-weight: 700; font-size: 13px; }
.lv-rank.rank-S { color: var(--amber); } .lv-rank.rank-A { color: var(--cyan); }
.lv-rank.rank-B { color: var(--green); } .lv-rank.rank-C { color: var(--dim); }
.lv-lock { font-size: 12px; opacity: 0.8; }

/* ---- Menu horizontal : rayons (échelle Nutri-Score) + stages, texte du monde À DROITE ---- */
.rayon-stack { display: flex; flex-direction: column; gap: 10px; }
.rayon-line, .stage-line { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 0; }
.rayon-line h3, .stage-line h3 { margin: 0; min-width: 58px; }
.world-scale { display: flex; align-items: center; gap: 8px; }
.wbadge {
  position: relative; display: inline-grid; place-items: center;
  width: 30px; height: 30px; border-radius: 8px;
  border: 1.5px solid currentColor; background: rgba(12, 16, 32, 0.5);
  color: var(--cyan); font-family: var(--mono); font-weight: 700; font-size: 15px;
  cursor: pointer; transition: transform 0.14s, box-shadow 0.14s, width 0.14s, height 0.14s, font-size 0.14s;
}
.wbadge-1 { color: #22e06b; } .wbadge-2 { color: #a6e22e; } .wbadge-3 { color: #ffd21f; }
.wbadge-4 { color: #ff9a1f; } .wbadge-5 { color: #ff3b30; }
/* Séparateur (petit losange) entre les 5 rayons et le rayon infini. */
.wbadge-sep { color: #6a7390; font-size: 12px; margin: 0 3px; align-self: center; user-select: none; }
/* 6e rayon = « ABCDE » (mode infini) : pill auto-largeur, lettres A..E en couleurs Nutri (dégradé
   horizontal néon), fond sombre du cockpit initial. Se comporte comme les autres badges. */
.wbadge-abcde {
  display: inline-flex; flex-direction: row; align-items: center; gap: 1px;
  width: auto; height: 30px; padding: 0 10px; font-size: 13px; letter-spacing: 1px; font-weight: 800;
  border-color: #6a7390; background: rgba(12, 16, 32, 0.6); color: #fff;
}
.wbadge-abcde:hover:not(.sel) { transform: translateY(-1px); box-shadow: 0 0 8px rgba(255,210,31,.45); border-color: #ffd21f; }
/* Spécificité renforcée (.world-scale) pour battre .wbadge.sel qui force width:42px et casserait
   l'affichage (les 5 lettres écrasées) quand le rayon ABCDE est sélectionné (retour user). */
.world-scale .wbadge-abcde.sel { display: inline-flex; width: auto; padding: 0 14px; height: 42px; font-size: 16px; letter-spacing: 2px; border-color: #ffd21f; background: rgba(255,255,255,0.06); box-shadow: 0 0 14px rgba(255,210,31,.5); text-shadow: none; }
/* Note du rayon infini dans la rangée des stages. */
.stage-note { font-family: var(--mono); font-size: 13px; color: #ffd88a; letter-spacing: 1px; align-self: center; }
/* Feedback du bouton Partager (écran de fin). */
.gc-sharemsg { margin: 12px 0 0; font-size: 13px; color: #8dffbc; }
.gc-sharemsg[hidden] { display: none; }
.wbadge:hover:not(.locked):not(.sel) { transform: translateY(-1px); box-shadow: 0 0 8px currentColor; }
.wbadge.sel { width: 42px; height: 42px; font-size: 21px; background: rgba(255, 255, 255, 0.06); box-shadow: 0 0 12px currentColor, inset 0 0 8px rgba(255, 255, 255, 0.05); text-shadow: 0 0 9px currentColor; }
.wbadge.locked { opacity: 0.4; cursor: not-allowed; }
.wb-lock { position: absolute; bottom: -7px; right: -7px; font-size: 10px; }
.world-scale.locked-during-play, .stage-scale.locked-during-play { opacity: 0.5; pointer-events: none; }
.rayon-name { font-family: var(--mono); color: var(--text); font-size: 14px; }
.stage-scale { display: flex; gap: 7px; flex-wrap: wrap; }
.sbadge {
  display: flex; align-items: center; gap: 6px; padding: 7px 12px;
  border-radius: 9px; border: 1px solid var(--panel-brd); background: rgba(12, 16, 32, 0.6);
  color: var(--text); cursor: pointer; font-family: var(--mono); font-size: 13px; transition: all 0.14s;
}
.sbadge:hover:not(.locked):not(.sel) { border-color: var(--cyan); transform: translateY(-1px); }
.sbadge.sel { border-color: var(--rayon, var(--magenta)); box-shadow: 0 0 10px var(--rayon, var(--magenta)); color: #fff; }
.sbadge.boss .sb-id { color: var(--rayon, var(--magenta)); font-weight: 700; }
.sbadge.locked { opacity: 0.4; cursor: not-allowed; }
.sb-id { font-size: 14px; }
.sb-rank { font-weight: 700; font-size: 13px; }
.sb-rank.rank-S { color: var(--amber); } .sb-rank.rank-A { color: var(--cyan); }
.sb-rank.rank-B { color: var(--green); } .sb-rank.rank-C { color: var(--dim); }
.sb-lock { font-size: 12px; opacity: 0.8; }

.mission-actions {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 14px; flex-wrap: wrap;
  border-top: 1px solid var(--panel-brd); padding-top: 14px;
}
/* Rappel du stage sélectionné, à gauche de la barre de lancement (pousse les boutons à droite). */
.launch-sel { margin-right: auto; font-family: var(--mono); font-size: 12.5px; color: var(--dim); letter-spacing: 0.3px; }
.launch-sel b { color: var(--cyan); }
.mission-msg { font-family: var(--mono); font-size: 13px; color: var(--green); opacity: 0; }
.mission-msg.show { animation: missionMsg 2.4s ease forwards; }
@keyframes missionMsg { 0% { opacity: 0; } 10%, 70% { opacity: 1; } 100% { opacity: 0; } }

/* Astuce de test affichée sur la vue 3D au repos. */
.idle-hint {
  position: absolute; left: 0; right: 0; bottom: 12px;
  z-index: 10; text-align: center; pointer-events: none; padding: 0 16px;
}
.idle-hint p { margin: 2px; font-size: 13px; color: var(--text); text-shadow: 0 1px 4px #000, 0 0 10px rgba(33, 231, 255, 0.3); }
.idle-hint .dim { color: var(--dim); font-size: 12px; }
.idle-hint.hidden { display: none; }

/* Bloc Audio (menu) */
.slider.mini label { font-size: 12px; margin-bottom: 3px; }
.m-audio .tog { font-size: 13px; margin-bottom: 2px; }
/* Appel d'attention sur le mot « Musique » (off par défaut). Pulse néon + petite note qui
   flotte ; s'arrête net dès que la case est cochée (:has). */
.m-audio .tog-music .mus-attn {
  display: inline-block;
  font-weight: 700;
  color: #ff8ae0;
  animation: musAttn 1.5s ease-in-out infinite;
  will-change: transform, text-shadow;
}
.m-audio .tog-music .mus-attn::after {
  content: " ♪";
  display: inline-block;
  animation: musNote 1.5s ease-in-out infinite;
}
.m-audio .tog-music:has(#tgMusic:checked) .mus-attn,
.m-audio .tog-music:has(#tgMusic:checked) .mus-attn::after {
  animation: none;
  color: var(--text);
  text-shadow: none;
  transform: none;
}
@keyframes musAttn {
  0%, 100% { transform: scale(1); text-shadow: 0 0 4px rgba(255, 43, 214, 0); }
  50% { transform: scale(1.08); text-shadow: var(--glow-mag); }
}
@keyframes musNote {
  0%, 100% { transform: translateY(0) rotate(-8deg); opacity: 0.5; }
  50% { transform: translateY(-4px) rotate(8deg); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .m-audio .tog-music .mus-attn,
  .m-audio .tog-music .mus-attn::after { animation: none; }
}
.m-credit { margin: 10px 0 0; font-size: 11px; color: var(--dim); }
.m-credit a { color: var(--cyan); text-decoration: none; }
.m-credit a:hover { text-decoration: underline; }

/* Légende code couleur */
.legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--dim); }
.legend b { color: var(--text); font-weight: 600; }
.legend-play li { line-height: 1.35; }
.legend-note { margin: 7px 0 0; font-size: 11.5px; line-height: 1.4; color: var(--dim); opacity: 0.92; border-top: 1px dashed var(--panel-brd); padding-top: 6px; }
.legend-note b { color: var(--cyan); }
.legend .sw {
  display: inline-block; width: 12px; height: 12px; border-radius: 3px;
  background: var(--c); box-shadow: 0 0 8px var(--c); vertical-align: -1px; margin-right: 6px;
}

/* Barre de vie du boss */
.bossbar {
  position: absolute; top: 60px; left: 50%; transform: translateX(-50%);
  width: min(560px, 82%); display: flex; align-items: center; gap: 14px;
  pointer-events: none;
}
.bossbar.hidden { display: none; }
.boss-label { font-family: var(--mono); font-size: clamp(14px, 1.7vw, 22px); font-weight: 800; color: var(--magenta); text-shadow: var(--glow-mag); white-space: nowrap; }
.boss-track { flex: 1; height: clamp(14px, 1.8vw, 22px); border-radius: 999px; border: 2px solid rgba(255, 43, 214, 0.5); background: rgba(0, 0, 0, 0.4); overflow: hidden; }
#bossFill { height: 100%; width: 100%; border-radius: 999px; background: linear-gradient(90deg, #8b7bff, #ff2bd6, #ff3b3b); box-shadow: 0 0 12px rgba(255, 43, 214, 0.5); transition: width 0.2s ease; }

/* ---------- HUD des mécaniques de monde ---------- */
.mech-name {
  position: absolute; top: 52px; left: 50%; transform: translateX(-50%);
  font-family: var(--mono); font-size: clamp(14px, 1.8vw, 22px); font-weight: 800; letter-spacing: 3px; color: var(--cyan);
  text-shadow: var(--glow-cyan); pointer-events: none;
}
.mech-name.hidden { display: none; }

/* Badge mode invincible (test) : visible en jeu quand l'option est cochée. */
.invinc-badge {
  position: absolute; top: 46px; right: 14px; z-index: 13; pointer-events: none;
  font-family: var(--mono); font-size: 11px; letter-spacing: 1.5px; color: #ffd24d;
  border: 1px solid rgba(255, 210, 77, 0.6); border-radius: 999px; padding: 3px 10px;
  background: rgba(40, 30, 0, 0.55); text-shadow: 0 0 8px rgba(255, 210, 77, 0.6);
  animation: invincPulse 1.4s ease-in-out infinite;
}
.invinc-badge.hidden { display: none; }
@keyframes invincPulse { 0%, 100% { opacity: 0.7; } 50% { opacity: 1; } }
/* Option de test mise en avant dans les réglages. */
.tog-test { color: #ffd24d; }

.graze-wrap, .beat-wrap, .grav-wrap {
  position: absolute; right: 20px; bottom: 16px; z-index: 12; pointer-events: none;
  display: flex; align-items: center; gap: 10px;
  font-family: var(--mono); font-size: clamp(13px, 1.5vw, 19px); font-weight: 700; color: #bcd;
}
.graze-wrap.hidden, .beat-wrap.hidden, .grav-wrap.hidden { display: none; }
.gz-track { width: clamp(150px, 16vw, 230px); height: clamp(12px, 1.4vw, 18px); border-radius: 999px; border: 2px solid var(--panel-brd); background: rgba(0,0,0,.45); overflow: hidden; }
#grazeFill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--cyan), var(--violet)); transition: width 0.06s linear; }
.graze-wrap.surcharge .gz-track { border-color: var(--green); box-shadow: 0 0 12px rgba(61,255,176,.6); }
.graze-wrap.surcharge #grazeFill { background: linear-gradient(90deg, var(--green), var(--amber)); }
.graze-wrap.surcharge .gz-label { color: var(--green); }

.bt-pip { width: 13px; height: 13px; border-radius: 50%; background: rgba(255,255,255,.18); transition: transform .05s, background .05s, box-shadow .05s; }
.bt-pip.on { background: var(--amber); box-shadow: 0 0 14px var(--amber); transform: scale(1.5); }

.grav-wrap { color: var(--amber); }

.inv-banner {
  position: absolute; top: 40%; left: 0; right: 0; z-index: 13; text-align: center;
  font-family: var(--mono); font-size: 34px; font-weight: 700; letter-spacing: 6px;
  color: #fff; text-shadow: 0 0 20px rgba(255,58,208,.9), 0 0 40px rgba(139,92,255,.7);
  opacity: 0; transform: scaleX(-1); pointer-events: none; transition: opacity .12s;
}
.inv-banner.on { opacity: 1; }
.inv-banner.hidden { display: none; }

/* Jauge d'ouverture de bouche (visible en jeu, même en plein écran) */
.fire-meter {
  position: absolute; left: 18px; bottom: 14px; z-index: 12;
  display: flex; align-items: center; gap: 8px; pointer-events: none;
  font-family: var(--mono); font-size: 11px; color: var(--dim);
}
.fm-track {
  position: relative; width: 120px; height: 9px; border-radius: 999px;
  border: 1px solid var(--panel-brd); background: rgba(0, 0, 0, 0.45); overflow: hidden;
}
#mouthFill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--cyan), var(--violet)); transition: width 0.05s linear; }
#mouthFill.hot { background: linear-gradient(90deg, var(--green), #b6ff6b); box-shadow: 0 0 10px rgba(61, 255, 176, 0.7); }
.fm-tick { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--amber); box-shadow: 0 0 6px var(--amber); }
.fm-fire { color: var(--green); font-weight: 700; opacity: 0; transition: opacity 0.08s; text-shadow: 0 0 8px rgba(61, 255, 176, 0.7); }
.fm-fire.on { opacity: 1; }

/* Fondu doux plein écran */
#fsFade {
  position: fixed; inset: 0; z-index: 9999; pointer-events: none;
  background: #02030a; opacity: 0; transition: opacity 0.22s ease;
}
#fsFade.on { opacity: 1; }

/* ---------- Avertissement épilepsie ---------- */
.epi-overlay {
  position: fixed; inset: 0; z-index: 10000;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  background: rgba(2, 3, 10, 0.94); backdrop-filter: blur(6px);
}
.epi-overlay.hidden { display: none; }
.epi-card {
  max-width: 560px; width: 100%;
  background: #0b0d1c; border: 1px solid rgba(255, 207, 77, 0.55);
  border-radius: 16px; padding: 28px 30px;
  box-shadow: 0 0 60px rgba(255, 138, 43, 0.18);
  text-align: left;
}
.epi-ico { font-size: 46px; line-height: 1; color: var(--amber); text-align: center; text-shadow: 0 0 18px rgba(255, 138, 43, 0.5); }
.epi-card h2 {
  margin: 14px 0 14px; text-align: center;
  font-family: var(--mono); font-size: 19px; letter-spacing: 1px; color: #fff;
}
.epi-card p { margin: 0 0 12px; font-size: 14px; line-height: 1.55; color: var(--text); }
.epi-card p b { color: #fff; }
.epi-card .epi-stop { color: #ffd0d0; }
.epi-card .epi-stop b { color: #ff8a8a; }
.epi-card .epi-dim { color: var(--dim); font-size: 13px; }
.epi-card .btn { display: block; width: 100%; margin-top: 6px; text-align: center; }

.epi-pill {
  cursor: pointer; font-family: var(--mono); font-size: 12px;
  color: var(--amber); border-color: rgba(255, 207, 77, 0.45); background: transparent;
}
.epi-pill:hover { border-color: var(--amber); box-shadow: 0 0 10px rgba(255, 138, 43, 0.35); }

/* ---------- Sélecteur 5 mondes / 25 stages ---------- */
.m-level { grid-column: 1 / -1; }
.level-picker { flex-direction: column; align-items: stretch; gap: 7px; }
.world-row { display: flex; align-items: center; gap: 12px; }
.world-row.locked { opacity: 0.5; }
.wr-label { display: flex; align-items: center; gap: 8px; min-width: 168px; font-family: var(--mono); font-size: 12.5px; color: var(--dim); }
.wr-num { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 7px; border: 1px solid var(--panel-brd); color: var(--cyan); font-size: 13px; font-weight: 700; }
/* Lettres de monde aux couleurs officielles du Nutri-Score, en néon (fait le lien avec le score). */
.wr-num-1 { color: #22e06b; border-color: rgba(34, 224, 107, 0.6); box-shadow: 0 0 9px rgba(34, 224, 107, 0.45); text-shadow: 0 0 7px rgba(34, 224, 107, 0.85); }
.wr-num-2 { color: #a6e22e; border-color: rgba(166, 226, 46, 0.6); box-shadow: 0 0 9px rgba(166, 226, 46, 0.45); text-shadow: 0 0 7px rgba(166, 226, 46, 0.85); }
.wr-num-3 { color: #ffd21f; border-color: rgba(255, 210, 31, 0.6); box-shadow: 0 0 9px rgba(255, 210, 31, 0.45); text-shadow: 0 0 7px rgba(255, 210, 31, 0.85); }
.wr-num-4 { color: #ff9a1f; border-color: rgba(255, 154, 31, 0.6); box-shadow: 0 0 9px rgba(255, 154, 31, 0.45); text-shadow: 0 0 7px rgba(255, 154, 31, 0.85); }
.wr-num-5 { color: #ff3b30; border-color: rgba(255, 59, 48, 0.6); box-shadow: 0 0 9px rgba(255, 59, 48, 0.45); text-shadow: 0 0 7px rgba(255, 59, 48, 0.85); }
.wr-name { color: var(--text); }
.wr-medal { font-size: 14px; }
.wr-lock { font-size: 11px; }
.medal-bronze { color: #cd7f32; } .medal-argent { color: #c8d0e0; } .medal-or { color: var(--amber); } .medal-platine { color: #7bfaff; text-shadow: 0 0 8px rgba(123,250,255,.6); }
.wr-stages { display: flex; gap: 6px; flex-wrap: wrap; }
.wr-stages .lv-node { padding: 7px 11px; }
.li-world { font-family: var(--mono); font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--cyan); }
@media (max-width: 620px) { .wr-label { min-width: 0; } .world-row { flex-wrap: wrap; gap: 6px; } }

/* ---------- Intro de monde (histoire) ---------- */
dialog.wi-overlay {
  position: fixed; inset: 0; width: 100vw; height: 100vh; max-width: 100vw; max-height: 100vh;
  margin: 0; padding: 24px; border: none; background: rgba(2, 3, 10, 0.95); color: var(--text);
  align-items: center; justify-content: center;
}
dialog.wi-overlay[open] { display: flex; }
dialog.wi-overlay::backdrop { background: rgba(2, 3, 10, 0.6); backdrop-filter: blur(6px); }
.wi-card {
  max-width: 620px; width: 100%; background: #080a16;
  border: 1px solid var(--wi, #21e7ff); border-radius: 16px; padding: 30px 34px;
  box-shadow: 0 0 60px rgba(33, 231, 255, 0.16); text-align: center;
}
.wi-num { margin: 0; font-family: var(--mono); font-size: 12px; letter-spacing: 4px; text-transform: uppercase; color: var(--wi, #21e7ff); }
.wi-name { margin: 8px 0 2px; font-family: var(--mono); font-size: clamp(22px, 4.2vw, 32px); letter-spacing: 1px; color: #fff; }
.wi-sub { margin: 0 0 18px; font-style: italic; color: var(--dim); }
.wi-story { margin: 0 0 16px; text-align: left; font-size: 15px; line-height: 1.62; color: #cdd4f5; }
.wi-tip {
  margin: 0 0 22px; text-align: left; font-family: var(--mono); font-size: 13px; line-height: 1.5;
  color: var(--wi, #21e7ff); border: 1px solid var(--wi, #21e7ff); border-radius: 10px; padding: 11px 13px;
  background: rgba(33, 231, 255, 0.05);
}
.wi-card .btn { width: 100%; }
/* Rangée de 2 boutons (confirmation webcam, écran de fin) : côte à côte, pas empilés. */
.wi-btns { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 6px; }
.wi-btns .btn { width: auto; flex: 1 1 190px; }
.cam-confirm { --wi: #22e06b; }
.game-complete { --wi: #ffd24d; }
.gc-credits { margin: 4px 0 14px; font-family: var(--mono); font-size: 13px; line-height: 1.6; color: var(--dim); }
.gc-unlock { margin: 0 0 20px; font-weight: 800; color: #22e06b; font-size: 16px; }
/* Bouton mode infini « Rayon ABCDE » (dégradé Nutri-Score A->E). */
.btn-endless {
  background: linear-gradient(90deg, rgba(34,224,107,.18), rgba(255,210,77,.18), rgba(255,59,48,.18));
  border-color: #ffd24d; color: #fff; font-weight: 800; letter-spacing: 1px;
}
.btn-endless:hover:not(:disabled) { box-shadow: 0 0 18px rgba(255,210,77,.5); border-color: #fff; }
.btn-endless.hidden { display: none; }

/* ---------- Mode « tient dans l'écran » (sans défilement de page) ----------
   Objectif : l'ESSENTIEL est toujours visible sans scroller (les 2 fenêtres, le
   sélecteur de niveau, le bouton Lancer, les réglages). Seule la zone de référence
   (Règles / Commandes / Code couleur / Audio) défile en interne quand l'écran est court.
   Sur 1080 tout tient sans aucun défilement ; sur un portable 768 l'info se compacte
   dans son cadre mais on garde tout le reste à l'écran. En dessous de 1000px de large,
   on repasse en mode responsive empilé/défilant classique. */
@media (min-width: 1000px) and (min-height: 640px) {
  body { height: 100vh; overflow: hidden; }
  /* Barre de contrôle en haut : hauteur naturelle, ne grandit pas (les réglages avancés
     repliés). Ouvrir « Réglages avancés » réduit les fenêtres, jamais l'inverse. */
  .controls { flex: 0 0 auto; padding: 10px 16px; }
  /* Les 2 colonnes (Vision+Commandes | Nutri-score+Cockpit) remplissent la hauteur restante. */
  .stage { flex: 1 1 0; min-height: 150px; grid-auto-rows: minmax(0, 1fr); }
  .col { min-height: 0; gap: 9px; }
  .col .panel { flex: 1 1 auto; min-height: 0; }
  .viewport { flex: 1 1 auto; aspect-ratio: auto; max-height: none; min-height: 120px; }
  .tip { padding-top: 8px; }
  /* Blocs compacts : libèrent de la hauteur pour les fenêtres webcam + cockpit. */
  .m-block h3 { margin-bottom: 5px; }
  .cmd-block { flex: 0 0 auto; }
  .cmd-list { gap: 4px; font-size: 12.5px; }
  .made-by { margin-top: 2px; }
  .level-head { flex: 0 0 auto; gap: 5px 18px; padding: 0 2px; }
  .m-audio .tog { margin: 0; }
}

/* ---------- Panneau de reglage du tunnel (flottant SUR la fenetre de jeu) ---------- */
.tune-btn {
  position: absolute; left: 12px; bottom: 12px; z-index: 15;
  pointer-events: auto; cursor: pointer;
  font-size: 12px; font-weight: 600; color: #bfe0ff;
  background: rgba(8, 14, 30, 0.72); border: 1px solid rgba(120, 160, 255, 0.35);
  border-radius: 8px; padding: 7px 11px;
}
.tune-btn:hover { background: rgba(20, 34, 64, 0.9); color: #fff; }
.tune-panel {
  position: absolute; left: 12px; bottom: 12px; z-index: 16;
  width: 250px; max-width: calc(100% - 24px);
  pointer-events: auto;
  background: rgba(6, 11, 26, 0.92); border: 1px solid rgba(120, 160, 255, 0.32);
  border-radius: 10px; padding: 11px 13px;
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.55);
}
.tune-panel.hidden { display: none; }
.tune-title {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: #9fd0ff; margin-bottom: 8px;
}
.tune-close { background: none; border: none; color: #8fa5c4; cursor: pointer; font-size: 14px; padding: 0 2px; line-height: 1; }
.tune-close:hover { color: #fff; }
.tune-row { display: block; margin: 8px 0; font-size: 12px; color: #cfe0f5; }
.tune-row > span { display: flex; justify-content: space-between; margin-bottom: 2px; }
.tune-row output { color: #6fe0ff; font-variant-numeric: tabular-nums; }
.tune-row input[type="range"] { width: 100%; margin: 0; }
.tune-foot { margin-top: 9px; font-size: 10.5px; line-height: 1.35; color: #8394ad; }

/* ============================================================================
   Refonte menu : barre de contrôle remontée en haut + scène sur 2 colonnes
   (gauche : Vision + Commandes ; droite : Nutri-score/Stages + Cockpit).
   ============================================================================ */

/* --- Barre de contrôle (haut) : source · webcam · audio · lancement --- */
.ctl-cam { flex: 2 1 320px; }
/* Audio compact : [case] [curseur] [valeur] sur 2 lignes. */
.ctl-audio { display: grid; grid-template-columns: auto minmax(70px, 1fr) auto; align-items: center; gap: 6px 12px; flex: 1 1 260px; min-width: 230px; }
.ctl-audio .tog { margin: 0; white-space: nowrap; }
.ctl-audio output { font-family: var(--mono); color: var(--cyan); font-size: 12px; min-width: 34px; text-align: right; }
.ctl-audio input[type="range"] { min-width: 80px; }
/* Lancer / Quitter poussés à droite de la barre. */
.ctl-launch { display: flex; align-items: center; gap: 10px; flex: 1 1 auto; justify-content: flex-end; margin-left: auto; }
.ctl-launch .mission-msg { margin: 0; }
/* Ligne 2 : réglages avancés (gauche) + crédit musiques (droite). */
.ctl-foot { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; border-top: 1px solid var(--panel-brd); padding-top: 8px; }
.ctl-foot .adv-settings { flex: 1 1 auto; border-top: none; padding-top: 0; }
.ctl-foot .m-credit { flex: 0 0 auto; margin: 2px 0 0; white-space: nowrap; }
@media (max-width: 760px) { .ctl-foot { flex-direction: column; } .ctl-foot .m-credit { white-space: normal; } }

/* --- Scène sur 2 colonnes --- */
.col { display: flex; flex-direction: column; gap: 12px; min-width: 0; min-height: 0; }

/* En-tête de la colonne droite : échelle Nutri-score + stages + meilleur score. */
.level-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 22px; padding: 2px; }
.level-head h3 {
  margin: 0; font-family: var(--mono); font-size: 12px; letter-spacing: 2px;
  text-transform: uppercase; color: var(--cyan); text-shadow: var(--glow-cyan);
}
.best-line { display: flex; align-items: baseline; gap: 8px; margin-left: auto; }
.best-label { font-family: var(--mono); font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--dim); }
.best-val { font-family: var(--mono); font-size: 16px; font-weight: 700; color: var(--amber); text-shadow: 0 0 8px rgba(255, 207, 77, 0.4); }

/* Signature (bas de la colonne gauche). */
.made-by { margin: 4px 2px 0; font-family: var(--mono); font-size: 11px; letter-spacing: 0.3px; color: var(--dim); }
