:root {
  --orange: #ff7900;
  --vert: #00a85a;
  --jaune: #ffd400;
  --fond: #101613;
  --panneau: rgba(14, 20, 17, 0.82);
  --texte: #f4f1ea;
  --doux: #b9c2bc;
  --titre: "Arial Black", "Segoe UI Black", Impact, system-ui, sans-serif;
  --corps: "Segoe UI", Roboto, "Helvetica Neue", Arial, system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--fond); color: var(--texte); font-family: var(--corps); }
body { -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; touch-action: none; }
#scene3d { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
kbd { display: inline-block; min-width: 1.6em; padding: 1px 6px; border-radius: 5px; background: rgba(255, 255, 255, 0.12); border: 1px solid rgba(255, 255, 255, 0.25); font: 600 12px var(--corps); text-align: center; }
a { color: var(--jaune); }

.ecran { position: fixed; inset: 0; z-index: 10; }

/* ---------- chargement ---------- */
#chargement { display: flex; flex-direction: column; justify-content: center; padding: 0 max(16px, 8vw); background: radial-gradient(circle at 75% 30%, #1f3a2a 0%, var(--fond) 60%); }
.logo { font: 900 clamp(48px, 11vw, 140px)/0.9 var(--titre); letter-spacing: -0.02em; color: var(--orange); }
.logo span { color: #fff; }
.sous-titre { margin: 10px 0 32px; font: 700 clamp(14px, 2.2vw, 20px) var(--corps); letter-spacing: 0.3em; text-transform: uppercase; color: var(--doux); }
.barre { height: 6px; max-width: 520px; border-radius: 3px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
#barre-chargement { height: 100%; width: 0; background: linear-gradient(90deg, var(--orange), #fff, var(--vert)); transition: width 0.3s; }
#msg-chargement { margin-top: 14px; font-size: 15px; color: var(--texte); }
.conseil { position: absolute; left: max(16px, 8vw); right: 16px; bottom: 32px; font-size: 14px; color: var(--doux); }
.conseil b { color: var(--jaune); text-transform: uppercase; letter-spacing: 0.15em; font-size: 12px; margin-right: 8px; }

/* ---------- menu ---------- */
#menu { overflow-y: auto; background: linear-gradient(90deg, rgba(10, 14, 12, 0.92) 0%, rgba(10, 14, 12, 0.7) 45%, rgba(10, 14, 12, 0.05) 75%); }
.entete { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 14px max(16px, 4vw); background: linear-gradient(180deg, rgba(10, 14, 12, 0.9), rgba(10, 14, 12, 0)); }
.marque { display: flex; align-items: center; gap: 10px; }
.marque b { display: block; font: 900 15px var(--titre); letter-spacing: 0.04em; }
.marque small { display: block; font-size: 11px; color: var(--doux); letter-spacing: 0.06em; }
.pastille { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 9px; background: var(--orange); color: #111; font: 900 14px var(--titre); }
nav { display: flex; gap: 4px; flex-wrap: wrap; }
nav button { padding: 8px 14px; border: 0; border-radius: 999px; background: transparent; color: var(--doux); font-weight: 600; font-size: 14px; }
nav button:hover { color: #fff; }
nav button.actif { background: rgba(255, 255, 255, 0.12); color: #fff; }
.onglet { padding: 8px max(16px, 4vw) 48px; max-width: 760px; }
.hero { padding-top: clamp(20px, 7vh, 80px); }
.surtitre { color: var(--orange); font: 800 13px var(--corps); letter-spacing: 0.25em; }
h1 { margin: 6px 0 10px; font: 900 clamp(48px, 10vw, 112px)/0.95 var(--titre); letter-spacing: -0.02em; }
h1 span { color: var(--jaune); }
h2 { font: 900 22px var(--titre); margin: 26px 0 12px; }
.accroche { max-width: 520px; font-size: clamp(15px, 2vw, 18px); line-height: 1.5; color: #e7e3d8; }
.nom { display: flex; flex-direction: column; gap: 6px; max-width: 360px; margin: 18px 0; font-size: 13px; color: var(--doux); }
.nom input { padding: 11px 14px; border-radius: 10px; border: 1px solid rgba(255, 255, 255, 0.2); background: rgba(0, 0, 0, 0.35); color: #fff; font: 600 16px var(--corps); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0 16px; }
.gros { padding: 14px 22px; border-radius: 12px; border: 0; background: var(--orange); color: #111; font-weight: 800; font-size: 16px; box-shadow: 0 6px 20px rgba(255, 121, 0, 0.3); }
.gros:hover { filter: brightness(1.08); }
.gros.secondaire { background: rgba(255, 255, 255, 0.1); color: #fff; box-shadow: none; border: 1px solid rgba(255, 255, 255, 0.2); }
.wari { font-size: 14px; color: var(--doux); }
.wari b { color: #fff; }
.petit { font-size: 13px; color: var(--doux); line-height: 1.5; }
.cartes { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.carte-choix { text-align: left; padding: 16px; border-radius: 14px; border: 1px solid rgba(255, 255, 255, 0.14); background: var(--panneau); }
.carte-choix:hover:not(:disabled) { border-color: var(--orange); }
.carte-choix.actif { border-color: var(--orange); box-shadow: inset 0 0 0 1px var(--orange); }
.carte-choix:disabled { opacity: 0.45; cursor: not-allowed; }
.carte-choix b { font: 900 17px var(--titre); }
.carte-choix p { margin: 6px 0 12px; font-size: 13px; line-height: 1.45; color: var(--doux); }
.carte-choix .meta { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--jaune); font-weight: 700; }
.stat { display: grid; grid-template-columns: 92px 1fr; align-items: center; gap: 8px; font-size: 12px; color: var(--doux); margin-top: 5px; }
.stat i { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--orange) var(--v), rgba(255, 255, 255, 0.12) var(--v)); }
.reglage-ligne { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; padding: 12px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.08); font-size: 14px; }
.choix { display: flex; gap: 6px; flex-wrap: wrap; }
.choix button { padding: 7px 13px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, 0.2); background: rgba(0, 0, 0, 0.3); font-size: 13px; font-weight: 600; }
.choix button.actif { background: var(--orange); color: #111; border-color: var(--orange); }
.choix button.couleur::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 6px; border-radius: 50%; background: var(--pastille); border: 1px solid rgba(0, 0, 0, 0.4); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid rgba(255, 255, 255, 0.08); }
th { color: var(--doux); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }
.commandes td:first-child { white-space: nowrap; width: 1%; }
dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 14px; }
dt { font-weight: 800; color: var(--jaune); }
dd { margin: 0; color: #e7e3d8; }
.stats { font-weight: 600; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; z-index: 5; pointer-events: none; font-weight: 600; }
#hud button, #dialogue, #tactile, #tactile * { pointer-events: auto; }
.hud-haut-gauche, .hud-haut-droite, .hud-gps, .hud-bas-droite, .hud-rue { position: absolute; background: var(--panneau); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 14px; backdrop-filter: blur(6px); }
.hud-haut-gauche { top: 14px; left: 14px; padding: 10px 14px; min-width: 150px; }
.hud-mode { font-size: 11px; letter-spacing: 0.2em; color: var(--orange); font-weight: 800; }
.hud-chrono { font: 900 24px var(--titre); font-variant-numeric: tabular-nums; }
.hud-rang { font-size: 14px; color: var(--jaune); }
.hud-gps { top: 14px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 12px; padding: 8px 16px 8px 10px; max-width: min(460px, 52vw); }
.hud-gps .fleche { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 10px; background: var(--jaune); color: #111; font: 900 28px var(--corps); flex: none; }
.gps-dist { font-size: 16px; font-weight: 800; }
.gps-rue { font-size: 13px; color: var(--doux); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-haut-droite { top: 14px; right: 14px; padding: 10px 14px; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; min-width: 130px; }
.hud-argent { font: 900 22px var(--titre); color: #7dff9f; font-variant-numeric: tabular-nums; }
.hud-passagers { font-size: 15px; letter-spacing: 0.1em; color: var(--jaune); }
.hud-compteur { font-size: 13px; color: #fff; background: #111; padding: 2px 8px; border-radius: 6px; border: 1px solid var(--jaune); }
.hud-btn { margin-top: 4px; padding: 4px 12px; border-radius: 8px; border: 1px solid rgba(255, 255, 255, 0.25); background: rgba(0, 0, 0, 0.3); font-weight: 900; }
#minicarte { position: absolute; left: 14px; bottom: 14px; width: 190px; height: 190px; border-radius: 50%; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45); }
.hud-bas-droite { right: 14px; bottom: 14px; padding: 12px 16px; width: 210px; }
.vitesse { display: flex; align-items: baseline; justify-content: flex-end; gap: 6px; }
.vitesse b { font: 900 46px/1 var(--titre); font-variant-numeric: tabular-nums; }
.vitesse small { color: var(--doux); }
.jauge { display: grid; grid-template-columns: 68px 1fr; align-items: center; gap: 8px; margin-top: 6px; font-size: 11px; color: var(--doux); text-transform: uppercase; letter-spacing: 0.08em; }
.jauge div { height: 7px; border-radius: 4px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
.jauge i { display: block; height: 100%; width: 100%; background: var(--vert); border-radius: 4px; transition: width 0.2s; }
.jauge i.bas { background: #ff3b3b; }
.jauge i.inverse { background: var(--jaune); }
.jauge i.inverse.bas { background: #ff3b3b; }
.hud-rue { left: 50%; bottom: 14px; transform: translateX(-50%); padding: 8px 16px; text-align: center; max-width: 46vw; }
.hud-rue b { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-rue span { font-size: 12px; color: var(--doux); }
#paroles { position: absolute; left: 50%; bottom: 84px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; width: min(560px, 90vw); }
.parole { padding: 9px 16px; border-radius: 16px; background: #fff; color: #111; font-size: 15px; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35); animation: entre 0.25s ease-out; }
.parole b { color: var(--orange); margin-right: 8px; }
#toasts { position: absolute; top: 92px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; width: min(560px, 92vw); }
.toast { padding: 9px 16px; border-radius: 10px; background: var(--panneau); border: 1px solid rgba(255, 255, 255, 0.15); font-size: 14px; text-align: center; animation: entre 0.25s ease-out; }
.toast.alerte { border-color: #ff3b3b; background: rgba(90, 14, 14, 0.88); }
.toast.client { border-color: var(--jaune); }
.toast.gps { border-color: var(--jaune); color: var(--jaune); }
.toast.sort, .parole.sort { opacity: 0; transform: translateY(-6px); transition: 0.4s; }
@keyframes entre { from { opacity: 0; transform: translateY(8px); } }
.gain { position: absolute; right: 30px; top: 110px; font: 900 26px var(--titre); color: #7dff9f; text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6); animation: monte 1.6s ease-out forwards; }
.gain.perte { color: #ff6b6b; }
@keyframes monte { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-50px); } }
#compte { position: absolute; top: 34%; left: 50%; transform: translate(-50%, -50%); font: 900 clamp(64px, 14vw, 150px) var(--titre); color: #fff; text-shadow: 0 6px 30px rgba(0, 0, 0, 0.6); opacity: 0; white-space: nowrap; }
#compte.anim { animation: compte 0.95s ease-out forwards; }
@keyframes compte { 0% { opacity: 0; transform: translate(-50%, -50%) scale(1.6); } 20% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -50%) scale(0.9); } }
#attente { position: absolute; top: 40%; left: 50%; transform: translateX(-50%); padding: 12px 18px; border-radius: 12px; background: var(--panneau); border: 1px solid var(--jaune); text-align: center; width: min(420px, 88vw); }
#attente .barre { margin-top: 8px; height: 5px; }
#attente i { display: block; height: 100%; background: var(--jaune); }
#dialogue { position: absolute; left: 50%; bottom: 120px; transform: translateX(-50%); width: min(620px, 94vw); padding: 14px 16px; border-radius: 16px; background: rgba(250, 248, 242, 0.97); color: #111; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5); animation: entre 0.2s ease-out; }
#dialogue .qui { font-size: 12px; font-weight: 800; color: var(--orange); text-transform: uppercase; letter-spacing: 0.1em; }
#dialogue .texte { margin: 4px 0 10px; font-size: 17px; font-weight: 700; }
#dialogue .choix { display: flex; flex-direction: column; gap: 6px; }
#dialogue .choix button { display: flex; align-items: center; gap: 10px; text-align: left; padding: 10px 12px; border-radius: 10px; border: 1px solid #ddd6c8; background: #fff; color: #111; font-size: 15px; font-weight: 600; }
#dialogue .choix button:hover { border-color: var(--orange); }
#dialogue kbd { background: #111; color: #fff; border: 0; }

/* ---------- commandes tactiles : volant + pédales ---------- */
#tactile { position: absolute; inset: auto 0 0 0; height: 0; }
#bloc-volant { position: absolute; left: max(14px, env(safe-area-inset-left)); bottom: 14px; }
#volant { position: relative; width: clamp(150px, 34vh, 210px); aspect-ratio: 1; touch-action: none; filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.5)); }
#volant svg { width: 100%; height: 100%; display: block; }
#moyeu { position: absolute; left: 50%; top: 50%; width: 36%; aspect-ratio: 1; transform: translate(-50%, -50%); border-radius: 50%; background: radial-gradient(circle at 40% 35%, #4a4a4a, #161616); border: 3px solid #555; display: grid; place-items: center; font-size: 10px; font-weight: 900; letter-spacing: 0.05em; color: var(--jaune); touch-action: none; }
#pedales { position: absolute; right: max(14px, env(safe-area-inset-right)); bottom: 14px; display: flex; align-items: flex-end; gap: 12px; }
#pedales button { touch-action: none; border-radius: 16px; border: 2px solid rgba(255, 255, 255, 0.35); font-weight: 900; letter-spacing: 0.08em; color: #fff; box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45); }
#t-gaz { width: clamp(78px, 17vh, 104px); height: clamp(120px, 30vh, 170px); background: linear-gradient(180deg, #2ec46d, #0b7a3e); }
#t-frein { width: clamp(78px, 17vh, 104px); height: clamp(84px, 20vh, 112px); background: linear-gradient(180deg, #e04a3a, #8e1d12); }
#pedales button.appuye { transform: scale(0.94); filter: brightness(1.2); }
#bloc-joystick { position: absolute; left: 0; bottom: 0; }
#joystick { position: absolute; left: 22px; bottom: 26px; width: 150px; height: 150px; border-radius: 50%; background: rgba(255, 255, 255, 0.1); border: 2px solid rgba(255, 255, 255, 0.3); touch-action: none; }
#joystick-bouton { position: absolute; left: 50%; top: 50%; width: 64px; height: 64px; margin: -32px 0 0 -32px; border-radius: 50%; background: rgba(255, 121, 0, 0.85); box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4); }
#t-klaxon { position: absolute; left: 190px; bottom: 40px; width: 70px; height: 70px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.35); background: rgba(255, 212, 0, 0.85); color: #111; font-size: 12px; font-weight: 800; touch-action: none; }
.hud-boutons { display: flex; gap: 6px; }
/* conseil « tourne ton téléphone » : un simple bandeau, il ne bloque jamais le jeu */
#tourne-telephone { position: absolute; top: 30%; left: 50%; transform: translateX(-50%); z-index: 12; width: min(340px, 92vw); padding: 12px 14px; border-radius: 14px; background: var(--panneau); border: 1px solid var(--jaune); text-align: center; pointer-events: auto; box-shadow: 0 8px 26px rgba(0, 0, 0, 0.5); }
#tourne-telephone p { margin: 0 0 10px; font-size: 14px; line-height: 1.4; }
#tourne-telephone .actions { justify-content: center; margin: 0; gap: 8px; }
#tourne-telephone button { padding: 9px 14px; border-radius: 10px; border: 0; font-weight: 800; font-size: 14px; }
#btn-horizontal { background: var(--orange); color: #111; }
#btn-vertical { background: rgba(255, 255, 255, 0.12); color: #fff; border: 1px solid rgba(255, 255, 255, 0.25) !important; }
/* téléphone tenu à la verticale : on joue quand même, volant et pédales en bas */
@media (orientation: portrait) and (pointer: coarse) {
  #bloc-volant { left: 10px; bottom: max(14px, env(safe-area-inset-bottom)); }
  #volant { width: min(44vw, 190px); }
  #pedales { right: 10px; bottom: max(14px, env(safe-area-inset-bottom)); gap: 8px; }
  #t-gaz { width: min(21vw, 92px); height: min(36vw, 150px); }
  #t-frein { width: min(21vw, 92px); height: min(25vw, 104px); }
  #dialogue, #paroles { bottom: calc(min(44vw, 190px) + 34px) !important; }
  #joystick { left: 12px; bottom: 20px; width: min(40vw, 150px); height: min(40vw, 150px); }
  #t-klaxon { left: 22px; bottom: calc(min(40vw, 150px) + 34px); width: 60px; height: 60px; }
  #toasts { top: 222px; }
}
/* liste des villes */
.ville-bloc { margin-bottom: 18px; }
.ville-bloc h3 { margin: 0 0 8px; font: 900 18px var(--titre); color: var(--jaune); }
.zone-chargee { margin: -18px 0 22px; font-weight: 700; color: var(--jaune); }

/* ---------- pause et résultats ---------- */
.voile { display: grid; place-items: center; background: rgba(6, 10, 8, 0.6); backdrop-filter: blur(4px); padding: 16px; overflow-y: auto; }
.panneau { display: flex; flex-direction: column; gap: 10px; padding: 24px; border-radius: 18px; background: var(--panneau); border: 1px solid rgba(255, 255, 255, 0.12); width: min(360px, 100%); }
.panneau.large { width: min(720px, 100%); }
.panneau h2 { margin: 0 0 6px; }
.res-rang { font: 900 64px/1 var(--titre); color: var(--jaune); }
.res td, .res th { padding: 7px 8px; font-size: 13px; }
.res tr.moi td { color: var(--jaune); font-weight: 800; }
.table-defile { overflow-x: auto; }

/* ---------- téléphone ---------- */
@media (max-width: 760px) {
  #menu { background: rgba(10, 14, 12, 0.82); }
  .entete { padding: 10px 16px; }
  nav button { padding: 6px 10px; font-size: 13px; }
  .hud-haut-gauche { top: 8px; left: 8px; padding: 6px 10px; min-width: 0; }
  .hud-chrono { font-size: 18px; }
  .hud-haut-droite { top: 8px; right: 8px; padding: 6px 10px; min-width: 0; }
  .hud-argent { font-size: 17px; }
  .hud-gps { top: 66px; max-width: 92vw; padding: 6px 12px 6px 6px; }
  .hud-gps .fleche { width: 36px; height: 36px; font-size: 22px; }
  #minicarte { width: 112px; height: 112px; top: 120px; left: 8px; bottom: auto; }
  .hud-bas-droite { right: 8px; bottom: auto; top: 120px; width: 150px; padding: 8px 10px; }
  .vitesse b { font-size: 30px; }
  .jauge { grid-template-columns: 54px 1fr; font-size: 9px; }
  .hud-rue { bottom: auto; top: 8px; max-width: 40vw; padding: 4px 10px; display: none; }
  #paroles { bottom: 190px; }
  #toasts { top: 120px; }
  #dialogue { bottom: 190px; }
  .gain { top: 70px; right: 16px; }
}
/* téléphone tenu à l'horizontale : tout se range autour du volant et des pédales */
@media (max-height: 520px) and (orientation: landscape) {
  .hud-haut-gauche { top: 6px; left: max(8px, env(safe-area-inset-left)); padding: 5px 10px; min-width: 0; }
  .hud-mode { font-size: 9px; }
  .hud-chrono { font-size: 16px; }
  .hud-rang { font-size: 12px; }
  .hud-gps { top: 6px; padding: 4px 10px 4px 4px; max-width: 40vw; }
  .hud-gps .fleche { width: 32px; height: 32px; font-size: 20px; }
  .gps-dist { font-size: 13px; }
  .gps-rue { font-size: 11px; }
  .hud-haut-droite { top: 6px; right: max(8px, env(safe-area-inset-right)); padding: 5px 10px; min-width: 0; }
  .hud-argent { font-size: 16px; }
  .hud-passagers { font-size: 12px; }
  #minicarte { width: 96px; height: 96px; left: max(8px, env(safe-area-inset-left)); top: 74px; bottom: auto; }
  .hud-bas-droite { top: 108px; bottom: auto; right: max(8px, env(safe-area-inset-right)); width: 130px; padding: 6px 10px; }
  .hud-btn { padding: 3px 9px; font-size: 11px; }
  .vitesse b { font-size: 26px; }
  .jauge { grid-template-columns: 48px 1fr; font-size: 8px; margin-top: 3px; }
  .hud-rue { display: none; }
  #toasts { top: 52px; width: min(420px, 50vw); }
  .toast { font-size: 12px; padding: 6px 10px; }
  #paroles { bottom: 12px; width: min(380px, 42vw); }
  .parole { font-size: 12px; padding: 6px 10px; }
  #dialogue { top: 48px; bottom: auto; width: min(460px, 52vw); padding: 10px 12px; }
  #dialogue .texte { font-size: 14px; margin-bottom: 6px; }
  #dialogue .choix button { padding: 7px 10px; font-size: 13px; }
  #compte { top: 40%; }
  .gain { top: 40px; right: 150px; font-size: 20px; }
}
