/* Conduite : HUD réduit à l'essentiel, lisible par-dessus la route. */
.hud-layer { --edge: max(14px, env(safe-area-inset-top)); }

/* Panneau de direction : carte, route et progression */
.nav-sign {
  --bg: var(--sign-blue);
  position: absolute; left: var(--safe-l); top: var(--edge); width: min(330px, 34cqw);
  background: var(--bg); border-radius: var(--r-sign); padding: 12px 15px 13px;
  box-shadow: inset 0 0 0 3px var(--bg), inset 0 0 0 5px var(--line-white), 0 10px 26px rgba(0, 0, 0, .28);
}
body[data-sign=col] .nav-sign { --bg: var(--sign-green); }
body[data-sign=region] .nav-sign { --bg: var(--sign-brown); }
body[data-sign=local] .nav-sign { --bg: var(--line-white); color: var(--asphalt); box-shadow: inset 0 0 0 3px var(--bg), inset 0 0 0 5px var(--asphalt), 0 10px 26px rgba(0, 0, 0, .28); }
body[data-sign=local] .location-card { border-top-color: var(--asphalt); }
body[data-sign=local] .progressline span { color: var(--asphalt); }
body[data-sign=local] .progressmeter { background: rgba(27, 31, 35, .2); }
body[data-sign=local] .progressmeter i { background: var(--asphalt); }
.worldtitle { font-family: var(--display); font-weight: 800; font-style: italic; font-size: 1.55rem; line-height: 1; text-transform: none; }
.worldsub { font-size: .68rem; font-weight: 600; opacity: .78; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.location-card { margin-top: 9px; padding-top: 8px; border-top: 2px solid rgba(242, 243, 238, .8); }
.progresslabel { font-weight: 600; font-size: var(--t-s); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.progressline { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-top: 2px; }
.progressline strong { font-family: var(--display); font-weight: 700; font-size: 1.15rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.progressline span { font-family: var(--display); font-weight: 700; font-size: 1rem; color: var(--line-white); white-space: nowrap; }
.progressmeter { height: 4px; margin-top: 7px; border-radius: 2px; background: rgba(242, 243, 238, .25); overflow: hidden; }
.progressmeter i { display: block; height: 100%; width: 0; background: var(--line-white); }

/* Défi chronométré : temps, écart avec la référence, record */
.race-clock {
  position: absolute; left: 50%; top: var(--edge); transform: translateX(-50%); min-width: 210px; text-align: center;
  padding: 7px 18px 8px; border-radius: var(--r-sign); background: #0e0f0f; color: var(--line-white);
  box-shadow: inset 0 0 0 2px #2d2f2f, 0 10px 24px rgba(0, 0, 0, .35); pointer-events: none;
}
.race-clock strong { display: block; font-family: var(--display); font-weight: 800; font-style: italic; font-size: 2rem; line-height: 1; font-variant-numeric: tabular-nums; }
.race-gap { display: inline-block; margin-top: 3px; font-family: var(--display); font-weight: 700; font-size: 1.1rem; color: var(--stop-red); font-variant-numeric: tabular-nums; }
.race-gap.ahead { color: #6fdc8c; }
.race-clock small { display: block; margin-top: 2px; font-size: .66rem; color: var(--gravel); font-weight: 600; }
body.racing .drift-meter { top: calc(var(--edge) + 92px); }
body.racing .toasty.show { transform: translate(-50%, 92px); }
.autopilot-tag { display: none; position: absolute; left: 50%; bottom: calc(var(--safe-b) + 34px); transform: translateX(-50%); padding: 5px 12px; border-radius: 3px; background: var(--balise); color: var(--balise-ink); font-weight: 600; font-size: .78rem; pointer-events: none; }
body.autopilot .autopilot-tag { display: block; }

/* Compteur de drift : discret au repos, il s'allume en glisse */
.drift-meter {
  position: absolute; left: 50%; top: var(--edge); transform: translateX(-50%);
  display: flex; align-items: baseline; gap: 10px; padding: 6px 16px 7px; border-radius: var(--r-ctl);
  background: var(--panel-soft); opacity: .0; transition: opacity .3s, background .2s;
  pointer-events: none;
}
.drift-meter.scored { opacity: .78; }
.drift-meter.drifting { opacity: 1; background: rgba(36, 26, 0, .82); box-shadow: inset 0 -3px 0 var(--balise); }
.drift-label { font-family: var(--display); font-weight: 700; font-style: italic; font-size: 1rem; color: var(--balise); }
.drift-meter strong { font-family: var(--display); font-weight: 800; font-style: italic; font-size: 2rem; line-height: .9; font-variant-numeric: tabular-nums; }
.drift-angle { font-family: var(--display); font-weight: 700; font-size: 1rem; color: var(--gravel); font-variant-numeric: tabular-nums; min-width: 3.4em; }
.drift-meter.drifting .drift-angle { color: var(--line-white); }

/* Coin haut droit : outils et carte */
.top-right { position: absolute; right: var(--safe-r); top: var(--edge); display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.stage-tools { display: flex; gap: 5px; }
.stage-tools button { display: inline-flex; align-items: center; gap: 7px; background: var(--panel); padding: 8px 10px; }
.stage-tools #cameraLabel { font-weight: 600; }
.minimap-wrap {
  width: clamp(120px, 15cqw, 176px); aspect-ratio: 1; border-radius: 50%; overflow: hidden;
  box-shadow: 0 0 0 3px var(--asphalt), 0 0 0 5px rgba(242, 243, 238, .8), 0 10px 24px rgba(0, 0, 0, .35);
}
#minimap { width: 100%; height: 100%; display: block; }

/* Compteur de vitesse */
.speedo {
  --rpm: 0; position: absolute; right: var(--safe-r); bottom: var(--safe-b); width: 236px;
  padding: 12px 16px 12px; border-radius: var(--r-sign); background: var(--panel); backdrop-filter: blur(6px);
  box-shadow: 0 10px 26px rgba(0, 0, 0, .3);
}
.rpm-bar { height: 8px; border-radius: 1px; background: repeating-linear-gradient(90deg, rgba(242, 243, 238, .16) 0 9px, transparent 9px 12px); position: relative; overflow: hidden; }
.rpm-bar::after { content: ''; position: absolute; right: 0; top: 0; bottom: 0; width: 14%; background: repeating-linear-gradient(90deg, rgba(216, 38, 46, .45) 0 9px, transparent 9px 12px); }
.rpm-bar i { position: absolute; left: 0; top: 0; bottom: 0; width: calc(var(--rpm) * 100%); background: repeating-linear-gradient(90deg, var(--balise) 0 9px, transparent 9px 12px); z-index: 1; }
.speedo.redline .rpm-bar i { background: repeating-linear-gradient(90deg, var(--stop-red) 0 9px, transparent 9px 12px); }
.speed-row { display: flex; align-items: flex-end; justify-content: space-between; margin-top: 6px; }
#speed { font-family: var(--display); font-weight: 800; font-style: italic; font-size: 4.4rem; line-height: .82; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.gear-box { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.gear-box b { display: grid; place-items: center; width: 44px; height: 44px; border-radius: var(--r-ctl); background: var(--line-white); color: var(--asphalt); font-family: var(--display); font-weight: 800; font-size: 2rem; line-height: 1; }
.speedo.redline .gear-box b { background: var(--stop-red); color: var(--line-white); }
.gear-box span { font-size: .68rem; color: var(--gravel); font-weight: 600; }
.speedo-foot { display: flex; justify-content: space-between; margin-top: 8px; font-size: .7rem; color: var(--gravel); font-weight: 600; font-variant-numeric: tabular-nums; }
.boost-row { display: flex; align-items: center; gap: 8px; margin-top: 7px; font-size: .66rem; font-weight: 600; color: var(--gravel); }
.boost { flex: 1; height: 5px; border-radius: 1px; background: rgba(242, 243, 238, .12); overflow: hidden; }
.boost i { display: block; height: 100%; width: 0; background: #6fb6ff; transition: width .08s linear; }
.aid-lights { display: flex; gap: 5px; margin-top: 7px; }
.aid-lights span { flex: 1; text-align: center; font-family: var(--display); font-weight: 700; font-size: .72rem; letter-spacing: .04em; padding: 2px 0; border-radius: 2px; color: rgba(242, 243, 238, .22); background: rgba(242, 243, 238, .05); }
.aid-lights span.on { color: var(--balise-ink); background: var(--balise); }
.pedals { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 6px; }
.gauge { height: 3px; background: rgba(242, 243, 238, .12); border-radius: 2px; overflow: hidden; }
.gauge i { display: block; height: 100%; width: 0; background: var(--line-white); }
.gauge.brake i { background: var(--stop-red); }

/* Bas gauche : adhérence et G latéral */
.side-readout { position: absolute; left: var(--safe-l); bottom: calc(var(--safe-b) + 18px); display: flex; flex-direction: column; align-items: flex-start; gap: 6px; pointer-events: none; }
.statusline { font-weight: 600; font-size: .72rem; padding: 4px 9px; border-radius: 3px; background: var(--panel-soft); color: var(--gravel); }
.statusline.alert { background: var(--balise); color: var(--balise-ink); }
.metric { display: flex; gap: 8px; align-items: baseline; padding: 3px 9px; border-radius: 3px; background: var(--panel-soft); }
.metric span { font-size: .68rem; color: var(--gravel); font-weight: 600; }
.metric strong { font-family: var(--display); font-weight: 700; font-size: .98rem; font-variant-numeric: tabular-nums; }

.chartbox { display: none; position: absolute; left: var(--safe-l); bottom: calc(var(--safe-b) + 92px); width: min(360px, 32cqw); padding: 8px 10px; border-radius: var(--r-ctl); background: var(--panel); }
body.telemetry-on .chartbox { display: block; }
.chart-head { display: flex; justify-content: space-between; font-size: .68rem; color: var(--gravel); font-weight: 600; }
.legend { display: flex; gap: 6px; align-items: center; }
.legend i { width: 8px; height: 3px; display: inline-block; }
.l-speed { background: var(--line-white); } .l-slip { background: var(--balise); } .l-yaw { background: #6fb6ff; }
#chart { width: 100%; height: 72px; display: block; margin-top: 4px; }

.bottom-keys { position: absolute; left: 50%; bottom: var(--safe-b); transform: translateX(-50%); font-size: .72rem; font-weight: 600; color: rgba(242, 243, 238, .82); padding: 5px 11px; border-radius: 3px; background: var(--panel-soft); white-space: nowrap; transition: opacity 1s; pointer-events: none; }
.bottom-keys.faded { opacity: 0; }

.map-attribution { position: absolute; left: var(--safe-l); bottom: 4px; font-size: .62rem; color: rgba(242, 243, 238, .75); }
.map-attribution a { color: inherit; }

/* Commandes tactiles : écrans tactiles uniquement */
.mobile-controls { display: none; }
@media (hover: none) and (pointer: coarse) {
  .mobile-controls { display: flex; position: absolute; left: var(--safe-l); right: var(--safe-r); bottom: var(--safe-b); justify-content: space-between; align-items: flex-end; pointer-events: none; }
  .touchset { display: flex; gap: 10px; pointer-events: auto; }
  .touchkey {
    display: grid; place-items: center; width: 78px; height: 78px; border-radius: 50%; border: 0;
    background: rgba(27, 31, 35, .55); color: var(--line-white); box-shadow: inset 0 0 0 2px rgba(242, 243, 238, .5);
    font-family: var(--display); font-weight: 700; font-size: 1rem; line-height: 1; touch-action: none; user-select: none; -webkit-user-select: none;
  }
  .touchkey svg { width: 34px; height: 34px; stroke-width: 3; }
  .touchkey.down { background: rgba(242, 243, 238, .85); color: var(--asphalt); }
  .touchkey.gas { width: 84px; height: 112px; border-radius: 16px; background: rgba(255, 194, 26, .32); box-shadow: inset 0 0 0 2px var(--balise); }
  .touchkey.gas.down { background: var(--balise); color: var(--balise-ink); }
  .touchkey.brake { width: 78px; height: 92px; border-radius: 16px; background: rgba(216, 38, 46, .28); box-shadow: inset 0 0 0 2px var(--stop-red); }
  .touchkey.brake.down { background: var(--stop-red); color: var(--line-white); }
  .touchkey.hand { width: 64px; height: 64px; font-size: .78rem; text-align: center; padding: 6px; align-self: flex-start; }
  .pedals-touch { align-items: flex-end; }
  /* En tactile, le compteur se place au-dessus des pédales et l'aide clavier disparaît. */
  .bottom-keys { display: none; }
  .speedo { bottom: calc(var(--safe-b) + 122px); width: 196px; padding: 9px 12px; }
  #speed { font-size: 3.4rem; }
  .gear-box b { width: 38px; height: 38px; font-size: 1.7rem; }
  .speedo-foot, .pedals { display: none; }
  .side-readout { left: calc(var(--safe-l) + 190px); bottom: var(--safe-b); }
}

/* Instrument finishing: compact glass surfaces and a stronger speed hierarchy. */
.speedo { width: 244px; border: 1px solid #ffffff20; border-bottom: 3px solid var(--balise); background: linear-gradient(150deg,#13212bed,#101a23e8); box-shadow: 0 10px 36px #0004; backdrop-filter: none; }
.rpm-bar { height: 6px; }
#speed { font-size: 4.7rem; letter-spacing: -.025em; }
.gear-box b { background: #f2f3ee; border-radius: 5px; }
.speedo-foot { color: #b0bbc2; }
.stage-tools button { min-height: 36px; background: #111d27dd; border-color: #ffffff26; }
.nav-sign { box-shadow: inset 0 0 0 3px var(--bg),inset 0 0 0 4px #f2f3eeb8,0 12px 28px #0003; }
.location-card { border-top-width: 1px; border-color: #ffffff60; }
.minimap-wrap { box-shadow: 0 0 0 3px #111d27,0 0 0 4px #ffffff70,0 10px 28px #0004; }
.autopilot-tag { padding: 6px 12px; border-radius: 5px; box-shadow: 0 4px 16px #0003; }
body.options-open .hud-layer { opacity: .25; }
