/* Base, couches d'écran et composants partagés (panneaux, boutons, champs). */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--asphalt); color: var(--line-white); }
body {
  font-family: var(--body); font-size: 15px; line-height: 1.4;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent; overscroll-behavior: none; user-select: none; -webkit-user-select: none;
}
input, select, textarea { user-select: text; -webkit-user-select: text; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
:focus-visible { outline: 3px solid var(--balise); outline-offset: 2px; }
svg { width: 1.2em; height: 1.2em; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0; }
[hidden] { display: none !important; }

/* Conteneur de référence : les unités cqw/cqh suivent la page, même tournée en paysage. */
#root { position: fixed; inset: 0; overflow: hidden; container-type: size; }
.main { position: absolute; inset: 0; overflow: hidden; background: #283036; }
#world { position: absolute; inset: 0; width: 100%; height: 100%; display: block; outline: none; touch-action: none; }

/* Couches : garage, conduite, menus. Une seule est interactive à la fois. */
.garage-layer, .hud-layer { position: absolute; inset: 0; pointer-events: none; }
.garage-layer > *, .hud-layer > * { pointer-events: auto; }
.hud-layer { opacity: 1; transition: opacity .25s; }
body.garage-open .hud-layer { opacity: 0; visibility: hidden; }
body:not(.garage-open) .garage-layer { visibility: hidden; }
body.title-open .garage-layer,
body.picker-open .garage-layer { visibility: hidden; }

/* ── Panneau : fond plein, liseré blanc intérieur, coins arrondis ── */
.sign {
  --bg: var(--sign-blue);
  background: var(--bg); color: var(--line-white); border-radius: var(--r-sign);
  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);
}

/* Bouton principal en flèche de direction (pointe à droite), liseré intérieur compris. */
.sign-arrow {
  --bg: var(--balise); --fg: var(--balise-ink); --rule: var(--balise-ink);
  position: relative; isolation: isolate; border: 0; background: var(--bg); color: var(--fg);
  clip-path: polygon(0 0, calc(100% - 26px) 0, 100% 50%, calc(100% - 26px) 100%, 0 100%);
  border-radius: var(--r-sign) 0 0 var(--r-sign);
  padding: 12px 48px 13px 22px; text-align: left;
  font-family: var(--display); font-weight: 800; font-style: italic; font-size: var(--t-xl); line-height: 1;
  transition: transform .12s ease, filter .12s ease;
}
.sign-arrow::before, .sign-arrow::after { content: ''; position: absolute; border-radius: 4px 0 0 4px; }
.sign-arrow::before { z-index: -2; inset: 4px 5px 4px 4px; background: var(--rule); clip-path: polygon(0 0, calc(100% - 23px) 0, 100% 50%, calc(100% - 23px) 100%, 0 100%); }
.sign-arrow::after { z-index: -1; inset: 6px 8px 6px 6px; background: var(--bg); clip-path: polygon(0 0, calc(100% - 21px) 0, 100% 50%, calc(100% - 21px) 100%, 0 100%); }
.sign-arrow small { display: block; font-family: var(--body); font-style: normal; font-weight: 600; font-size: var(--t-xs); letter-spacing: .02em; margin-bottom: 4px; opacity: .78; }
.sign-arrow:hover { filter: brightness(1.06); transform: translateX(3px); }
.sign-arrow:active { transform: translateX(6px); }

/* Petites commandes */
.tiny-btn, .headbutton, .stage-tools button, .view-buttons button, #favoriteFilter, .menu-close {
  border: 1px solid var(--hairline); background: var(--asphalt-2); color: var(--line-white);
  border-radius: var(--r-ctl); padding: 8px 12px; font-weight: 600; font-size: var(--t-s); line-height: 1.1;
  transition: background .12s, border-color .12s, color .12s;
}
.tiny-btn:hover, .headbutton:hover, .stage-tools button:hover, .view-buttons button:hover, #favoriteFilter:hover, .menu-close:hover { border-color: rgba(242, 243, 238, .45); background: var(--asphalt-3); }
.tiny-btn.primary { background: var(--balise); color: var(--balise-ink); border-color: var(--balise); }
.icon-btn { display: inline-grid; place-items: center; padding: 7px 9px; }

.searchbox, select, input[type=number] {
  width: 100%; border: 1px solid var(--hairline); background: rgba(0, 0, 0, .28); color: var(--line-white);
  border-radius: var(--r-ctl); padding: 9px 11px; outline: none; font-size: var(--t-s);
}
.searchbox:focus, select:focus, input[type=number]:focus { border-color: var(--balise); }
select option { background: var(--asphalt); }

input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; background: transparent; margin: 2px 0; touch-action: pan-y; }
input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(90deg, var(--balise) var(--fill, 0%), var(--asphalt-3) var(--fill, 0%)); }
input[type=range]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--asphalt-3); }
input[type=range]::-moz-range-progress { height: 4px; background: var(--balise); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: -6px; border-radius: 3px; background: var(--line-white); border: 3px solid var(--asphalt); box-shadow: 0 0 0 1px var(--balise); }
input[type=range]::-moz-range-thumb { width: 12px; height: 12px; border-radius: 3px; background: var(--line-white); border: 3px solid var(--asphalt); }
input[type=checkbox] { accent-color: var(--balise); width: 17px; height: 17px; margin: 0; }

.note { color: var(--gravel); font-size: var(--t-xs); line-height: 1.45; margin: 8px 0; }
.btnrow { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }

/* Panneau à message variable : les notifications du jeu. */
.toasty {
  position: absolute; left: 50%; top: max(14px, env(safe-area-inset-top)); z-index: 60; transform: translate(-50%, -140%);
  background: #0e0f0f; color: var(--pmv); border-radius: 4px; padding: 9px 16px 8px; max-width: min(560px, 80cqw);
  font-family: var(--display); font-weight: 700; font-size: var(--t-m); letter-spacing: .12em; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-shadow: 0 0 8px rgba(255, 178, 26, .55);
  box-shadow: inset 0 0 0 2px #2d2f2f, 0 8px 20px rgba(0, 0, 0, .4);
  background-image: radial-gradient(rgba(255, 255, 255, .05) 1px, transparent 1.4px); background-size: 4px 4px;
  transition: transform .22s cubic-bezier(.2, .8, .2, 1), opacity .22s, visibility .22s; pointer-events: none; opacity: 0; visibility: hidden;
}
.toasty.show { transform: translate(-50%, 0); opacity: 1; visibility: visible; }

/* Chargement de la carte régionale */
.world-loading { position: absolute; inset: 0; z-index: 70; display: grid; place-items: center; background: rgba(18, 21, 24, .72); backdrop-filter: blur(4px); }
.loading-sign { --bg: var(--sign-brown); min-width: min(380px, 70cqw); padding: 22px 30px 24px; text-align: left; }
.loading-sign { background: var(--bg); border-radius: var(--r-sign); box-shadow: inset 0 0 0 4px var(--bg), inset 0 0 0 6px var(--line-white); }
.loading-sign strong { display: block; font-family: var(--display); font-weight: 800; font-style: italic; font-size: var(--t-xxl); line-height: .95; }
.loading-sign span { display: block; font-weight: 600; margin-top: 4px; }
.loading-sign p { margin: 14px 0 10px; font-size: var(--t-s); opacity: .85; }
.loading-bar { display: block; height: 4px; border-radius: 2px; background: linear-gradient(90deg, transparent, var(--line-white), transparent) 0 0 / 40% 100% no-repeat, rgba(255, 255, 255, .2); animation: load 1.2s linear infinite; }
@keyframes load { from { background-position: -40% 0, 0 0; } to { background-position: 140% 0, 0 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* Shared finishing: a clear hierarchy, readable secondary text and quieter surfaces. */
button:disabled { cursor: default; opacity: .45; }
button, input, select, summary { scroll-margin-block: 18px; }
kbd { font: 600 .75em var(--body); border: 1px solid var(--hairline); border-bottom-width: 2px; border-radius: 4px; padding: 2px 6px; color: var(--line-white); }
.section-kicker { display: block; margin: 0 0 10px; font: 600 .68rem var(--body); letter-spacing: .16em; text-transform: uppercase; color: var(--balise); }
.section-kicker span { color: var(--gravel); letter-spacing: .04em; }
.searchbox { min-height: 39px; background: rgba(0,0,0,.18); }
.searchbox::placeholder { color: #9aa6ae; opacity: 1; }
.empty-state { padding: 26px 14px; text-align: center; border: 1px dashed var(--hairline); border-radius: var(--r-sign); color: var(--gravel); }
.empty-state b { display: block; color: var(--line-white); font: 700 1.35rem var(--display); }
.empty-state p { font-size: var(--t-s); margin: 7px auto 14px; max-width: 28ch; }
.toasty { display: flex; align-items: center; justify-content: center; gap: 14px; letter-spacing: .06em; }
.toasty span { overflow: hidden; text-overflow: ellipsis; }
.toasty.has-action { pointer-events: auto; }
.toasty button { border: 1px solid var(--pmv); background: transparent; color: var(--pmv); border-radius: 4px; padding: 5px 9px; font: 600 .8rem var(--body); flex: none; }
.performance-readout { position: absolute; z-index: 55; left: var(--safe-l); bottom: calc(var(--safe-b) + 30px); padding: 4px 9px; background: #121b21e8; border: 1px solid var(--hairline); border-radius: 4px; color: var(--gravel); font: 500 .7rem var(--body); pointer-events: none; font-variant-numeric: tabular-nums; }
body.reduced-motion *, body.reduced-motion *::before, body.reduced-motion *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-thumb { background: #536470; border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }
#carFavorites, #favoriteFilter { display: inline-flex; align-items: center; gap: 5px; }
#carFavorites svg, #favoriteFilter svg, .car-favorite svg, .favorite-btn svg, .field-reset svg { width: 15px; height: 15px; flex: none; }
.car-favorite[aria-pressed=true] svg, .favorite-btn[aria-pressed=true] svg { fill: currentColor; }
