/* Moteur : thème sombre, gros boutons, pensé pour l'écran tactile de la Tesla (paysage) */

:root {
  --fond: #0a0c0f;
  --panneau: #13171d;
  --panneau-2: #1b2129;
  --bord: #262e38;
  --texte: #e8edf2;
  --doux: #8b97a5;
  --ambre: #ffb020;
  --rouge: #ff3b30;
  --bleu: #3aa0ff;
  --vert: #34c759;
  --rayon: 18px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--fond);
  color: var(--texte);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
}

button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
[hidden] { display: none !important; }

.ecran {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
  height: 100vh;
  height: 100dvh;
  padding: 14px 24px 18px;
}

/* ------------------------------------------------------------- barre du haut */
.barre {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 44px;
}
.marque { font-weight: 800; letter-spacing: 0.32em; color: var(--doux); font-size: 15px; }
.message { flex: 1; text-align: center; color: var(--ambre); font-size: 17px; min-width: 0; }
.pastilles { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.pastille {
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--panneau);
  border: 1px solid var(--bord);
  color: var(--doux);
  font-size: 14px;
  white-space: nowrap;
}
.pastille.ok { color: var(--vert); border-color: #24563a; }
.pastille.alerte { color: var(--ambre); border-color: #5c4614; }
.pastille.erreur { color: var(--rouge); border-color: #5c1f1b; }

/* ------------------------------------------------------------- tableau de bord */
.tableau {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(330px, 0.75fr);
  gap: 28px;
  min-height: 0;
}

.instruments {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  min-width: 0;
}

#compte-tours { width: 100%; height: 100%; max-height: 100%; display: block; }

.arc-fond { fill: none; stroke: #1d232b; stroke-width: 22; stroke-linecap: round; }
.arc-rouge { fill: none; stroke: var(--rouge); stroke-width: 22; opacity: 0.55; }
.arc-regime { fill: none; stroke: var(--ambre); stroke-width: 22; stroke-linecap: round; }
.arc-regime.vide { stroke-opacity: 0; }
.zone-rouge .arc-regime { stroke: var(--rouge); }

.trait { stroke: #56616e; stroke-width: 2; }
.trait.majeur { stroke: #c3ccd6; stroke-width: 4; }
.trait.rouge { stroke: var(--rouge); }
.chiffre { fill: #c3ccd6; font-size: 22px; font-weight: 700; text-anchor: middle; dominant-baseline: central; }
.chiffre.rouge { fill: var(--rouge); }

.aiguille line { stroke: #f4f6f8; stroke-width: 6; stroke-linecap: round; }
.aiguille circle { fill: #f4f6f8; }

.lecture text { text-anchor: middle; fill: var(--texte); font-variant-numeric: tabular-nums; }
.rapport { font-size: 70px; font-weight: 800; }
.rapport.change { fill: var(--ambre); }
.vitesse { font-size: 46px; font-weight: 700; }
.regime { font-size: 30px; font-weight: 700; fill: var(--doux) !important; }
.zone-rouge .regime { fill: var(--rouge) !important; }
.unite { font-size: 15px; fill: var(--doux) !important; letter-spacing: 0.1em; }
.charge-fond { fill: #1d232b; }
.charge { fill: var(--ambre); }
.charge.lacher { fill: var(--bleu); }

/* Avant le démarrage, le compte-tours est grisé et le gros bouton est au centre */
.arret #compte-tours { opacity: 0.25; }

.accueil {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
}
.marche .accueil { display: none; }

.demarrer {
  width: min(300px, 44vh, 60vw);
  height: min(300px, 44vh, 60vw);
  border-radius: 50%;
  border: 6px solid #3a434f;
  background: radial-gradient(circle at 50% 35%, #2a313b, #12161b 70%);
  box-shadow: 0 0 0 10px #12161b, 0 0 60px rgba(255, 59, 48, 0.25), inset 0 -10px 30px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.12s, border-color 0.2s;
}
.demarrer:active { transform: scale(0.96); }
.demarrer-titre { font-size: clamp(26px, 4.4vh, 40px); font-weight: 800; letter-spacing: 0.06em; color: #fff; }
.demarrer-sous { font-size: 14px; letter-spacing: 0.3em; color: var(--rouge); font-weight: 700; }
.demarrer:disabled { opacity: 0.6; cursor: wait; }

.progression { width: min(300px, 60vw); height: 10px; border-radius: 5px; background: var(--panneau-2); overflow: hidden; }
#progression-barre { height: 100%; width: 0; background: var(--ambre); transition: width 0.1s; }
.message-accueil { margin: 0; max-width: 460px; text-align: center; color: var(--doux); font-size: 17px; line-height: 1.4; min-height: 1.4em; }

/* ------------------------------------------------------------- commandes */
.commandes {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  overflow-y: auto;
  padding-bottom: 4px;
}

.groupe {
  background: var(--panneau);
  border: 1px solid var(--bord);
  border-radius: var(--rayon);
  padding: 16px 18px;
}
.etiquette { font-size: 15px; color: var(--doux); text-transform: uppercase; letter-spacing: 0.12em; margin-bottom: 12px; display: flex; justify-content: space-between; }
.valeur { color: var(--texte); font-variant-numeric: tabular-nums; }
.aide { color: var(--doux); font-size: 15px; margin-top: 10px; line-height: 1.35; }

.segments { display: flex; gap: 10px; }
.segments button {
  flex: 1;
  min-height: 72px;
  border-radius: 14px;
  border: 2px solid var(--bord);
  background: var(--panneau-2);
  font-size: 28px;
  font-weight: 800;
}
.segments button[aria-checked="true"] { border-color: var(--ambre); color: var(--ambre); background: #241c0b; }
.segments button:disabled { opacity: 0.5; }

/* Curseurs (volume, vitesse démo) : gros « pouce » facile à attraper au doigt */
.curseur {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 48px;
  background: transparent;
  margin: 0;
  touch-action: none;
}
.curseur::-webkit-slider-runnable-track { height: 12px; border-radius: 6px; background: var(--panneau-2); border: 1px solid var(--bord); }
.curseur::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 44px; height: 44px; margin-top: -17px;
  border-radius: 50%; background: var(--texte); border: 4px solid var(--ambre);
}
.curseur::-moz-range-track { height: 12px; border-radius: 6px; background: var(--panneau-2); border: 1px solid var(--bord); }
.curseur::-moz-range-thumb { width: 36px; height: 36px; border-radius: 50%; background: var(--texte); border: 4px solid var(--ambre); }

/* Interrupteurs (Outside, Démo) */
.interrupteur {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 84px;
  padding: 14px 18px;
  text-align: left;
  background: var(--panneau);
  border: 1px solid var(--bord);
  border-radius: var(--rayon);
}
.interrupteur-texte { display: flex; flex-direction: column; gap: 4px; }
.interrupteur-texte b { font-size: 24px; }
.interrupteur-texte small { font-size: 15px; color: var(--doux); }
.glissiere {
  flex: none;
  width: 84px; height: 46px;
  border-radius: 23px;
  background: var(--panneau-2);
  border: 2px solid var(--bord);
  position: relative;
  transition: background 0.2s, border-color 0.2s;
}
.pouce {
  position: absolute; top: 4px; left: 4px;
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--doux);
  transition: transform 0.2s, background 0.2s;
}
.interrupteur[aria-checked="true"] .glissiere { background: #241c0b; border-color: var(--ambre); }
.interrupteur[aria-checked="true"] .pouce { transform: translateX(38px); background: var(--ambre); }

.bouton-couper {
  min-height: 64px;
  border-radius: var(--rayon);
  border: 2px solid #5c1f1b;
  background: #1d1010;
  color: #ff8a82;
  font-size: 20px;
  font-weight: 700;
}

/* ------------------------------------------------------------- zone démo */
.zone-demo {
  display: flex;
  align-items: center;
  gap: 20px;
  background: var(--panneau);
  border: 1px solid var(--bord);
  border-radius: var(--rayon);
  padding: 10px 20px;
}
.demo-etiquette { color: var(--doux); font-size: 16px; white-space: nowrap; min-width: 190px; }
.demo-etiquette b { color: var(--texte); font-size: 24px; font-variant-numeric: tabular-nums; margin-left: 6px; }
.curseur-demo { flex: 1; height: 64px; }
.curseur-demo::-webkit-slider-thumb { width: 56px; height: 56px; margin-top: -23px; }
.raccourcis { display: flex; gap: 8px; }
.raccourcis button {
  min-width: 64px; min-height: 56px;
  border-radius: 12px; border: 1px solid var(--bord);
  background: var(--panneau-2); font-size: 19px; font-weight: 700;
}

/* ------------------------------------------------------------- son suspendu */
.voile-son {
  position: fixed; inset: 0;
  background: rgba(5, 6, 8, 0.82);
  display: flex; align-items: center; justify-content: center;
  z-index: 10;
}
.voile-son button {
  min-height: 110px; padding: 0 48px;
  border-radius: 24px; border: 3px solid var(--ambre);
  background: #241c0b; color: var(--ambre);
  font-size: 30px; font-weight: 800;
}

/* ------------------------------------------------------------- petits écrans / portrait */
@media (max-width: 820px), (max-aspect-ratio: 1/1) {
  .ecran { height: auto; min-height: 100dvh; grid-template-rows: auto auto auto; padding: 12px 16px 16px; }
  .tableau { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .instruments { height: min(92vw, 62vh); }
  .commandes { overflow: visible; }
  .barre { flex-wrap: wrap; }
  .message { order: 3; flex-basis: 100%; }
  .zone-demo { flex-wrap: wrap; gap: 8px 12px; padding: 12px 16px; }
  .curseur-demo { flex-basis: 100%; }
  .raccourcis { flex: 1; }
  .raccourcis button { flex: 1; min-width: 0; }
}

@media (max-height: 560px) and (min-aspect-ratio: 1/1) {
  .interrupteur { min-height: 64px; padding: 8px 14px; }
  .interrupteur-texte b { font-size: 20px; }
  .segments button { min-height: 56px; }
  .groupe { padding: 10px 14px; }
  .commandes { gap: 10px; }
}
