/* ==========================================================
   BLIP — interface
   Les couleurs changent avec le style de carte (body[data-style]).
   ========================================================== */
:root {
  --bg: #0b0a1a; --panel: #110f26; --panel-2: #1a1738; --line: #2c2860; --fg: #e9f7ff; --dim: #8e9cc0;
  --accent: #00e5ff; --on-accent: #06061a; --route: #fcee0a; --me: #00e5ff;
  --font: "Chakra Petch", "Bahnschrift", "Arial Narrow", system-ui, sans-serif;
  --display: var(--font);
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --danger: #ff3b4a;
  color-scheme: dark;
}
/* Couleurs d'interface de chaque style */
body[data-style="radar"]      { --font: "Rajdhani", "Chakra Petch", sans-serif; --bg:#1f2327; --panel:#1b1f23; --panel-2:#262b30; --line:#3a4148; --fg:#f1f3f4; --dim:#9aa3ab; --accent:#b76ce6; --on-accent:#fff; --route:#b76ce6; --me:#ffffff; }
body[data-style="western"]    { --font: "IM Fell English", Georgia, serif; --display:"Rye", Georgia, serif; --bg:#2a1d12; --panel:#e6d3a8; --panel-2:#d8c190; --line:#3b2a1a; --fg:#2e1f12; --dim:#6b5234; --accent:#8b1a1a; --on-accent:#f3e6c4; --route:#8b1a1a; --me:#8b1a1a; --shadow:0 8px 22px rgba(30,15,0,.4); color-scheme:light; }
body[data-style="fantasy"]    { --font: "IM Fell English", Georgia, serif; --display:"Cinzel", Georgia, serif; --bg:#2b2116; --panel:#efe1bc; --panel-2:#e3d1a2; --line:#b89a63; --fg:#3b2a17; --dim:#76603f; --accent:#8b1a1a; --on-accent:#f6e9c6; --route:#8b1a1a; --me:#8b1a1a; --shadow:0 8px 24px rgba(40,20,0,.35); color-scheme:light; }
body[data-style="tactique"]   { --font: "Share Tech Mono", ui-monospace, monospace; --display:"Black Ops One", "Chakra Petch", sans-serif; --bg:#07100a; --panel:#0b1a0f; --panel-2:#12281a; --line:#2a5a35; --fg:#c8ffc2; --dim:#6fae76; --accent:#5fd16f; --on-accent:#04100a; --route:#ff4040; --me:#b6ff9a; }
body[data-style="retro"]      { --font: "VT323", ui-monospace, monospace; --display:"Press Start 2P", monospace; --bg:#1e2416; --panel:#e0e8c8; --panel-2:#c9d3a8; --line:#56603f; --fg:#1e2416; --dim:#4d553a; --accent:#1e2416; --on-accent:#e0e8c8; --route:#1e2416; --me:#1e2416; --shadow:none; color-scheme:light; }
body[data-style="blocs"]      { --font: "Pixelify Sans", "Chakra Petch", sans-serif; --display:"Silkscreen", "Press Start 2P", monospace; --bg:#2d4a1e; --panel:#c6c6c6; --panel-2:#b3b3b3; --line:#555555; --fg:#1e1e1e; --dim:#474747; --accent:#3c8a26; --on-accent:#ffffff; --route:#ffd83a; --me:#ffffff; --shadow:none; color-scheme:light; }
body[data-style="apocalypse"] { --font: "Courier Prime", "Courier New", monospace; --display:"Special Elite", "Courier New", monospace; --bg:#2e251a; --panel:#3a2f22; --panel-2:#4a3c2c; --line:#6b5a44; --fg:#f0e2c4; --dim:#b8a27e; --accent:#9eff4a; --on-accent:#1a1408; --route:#9eff4a; --me:#f5d38a; }
body[data-style="horreur"]    { --font: "IM Fell English", Georgia, serif; --display:"Creepster", "Chakra Petch", cursive; --bg:#08080a; --panel:#141418; --panel-2:#1e1e24; --line:#3a1a1e; --fg:#e6e2e2; --dim:#8e8a90; --accent:#e0212e; --on-accent:#ffffff; --route:#c1121f; --me:#e6e2e2; }
body[data-style="espace"]     { --font: "Exo 2", "Chakra Petch", sans-serif; --display:"Orbitron", "Chakra Petch", sans-serif; --bg:#02040c; --panel:#061026; --panel-2:#0b1a3a; --line:#16407a; --fg:#d8f1ff; --dim:#7aa6c8; --accent:#35b8ff; --on-accent:#02040c; --route:#ff9a1a; --me:#9ae6ff; }
body[data-style="course"]     { --font: "Titillium Web", "Chakra Petch", sans-serif; --display:"Racing Sans One", "Chakra Petch", sans-serif; --bg:#111318; --panel:#1a1d24; --panel-2:#262a33; --line:#3a3f4c; --fg:#ffffff; --dim:#9aa0ac; --accent:#ffb400; --on-accent:#111111; --route:#3dff5a; --me:#ffffff; }
body[data-style="pirate"]     { --font: "IM Fell English", Georgia, serif; --display:"Pirata One", Georgia, serif; --bg:#0e3a44; --panel:#f0dcaa; --panel-2:#e2c88a; --line:#8f5f2e; --fg:#3a220e; --dim:#7a5a36; --accent:#b0271f; --on-accent:#fff3d6; --route:#b0271f; --me:#b0271f; --shadow:0 8px 22px rgba(0,30,40,.4); color-scheme:light; }
body[data-style="glace"]      { --font: "Exo 2", "Chakra Petch", sans-serif; --display:"Russo One", "Chakra Petch", sans-serif; --bg:#dfeaf2; --panel:#f6fbff; --panel-2:#e6f0f7; --line:#b8cfdf; --fg:#1a3a52; --dim:#5a7a92; --accent:#2a7ab8; --on-accent:#ffffff; --route:#ff6a3d; --me:#2a7ab8; --shadow:0 8px 24px rgba(30,70,100,.18); color-scheme:light; }
body[data-style="jungle"]     { --font: "Fredoka", "Chakra Petch", sans-serif; --display:"Luckiest Guy", "Chakra Petch", sans-serif; --bg:#12220f; --panel:#1c301a; --panel-2:#274023; --line:#3e5a34; --fg:#eef4d8; --dim:#a8b88a; --accent:#ffb21a; --on-accent:#1a1408; --route:#ff9a1a; --me:#f4e6a0; }
body[data-style="samourai"]   { --font: "Zen Old Mincho", Georgia, serif; --display:"Shojumaru", Georgia, serif; --bg:#e8e0cc; --panel:#f7f1e3; --panel-2:#ece4d0; --line:#c9bfa6; --fg:#1a1714; --dim:#6a645a; --accent:#b3202a; --on-accent:#ffffff; --route:#b3202a; --me:#b3202a; --shadow:0 8px 22px rgba(40,30,10,.2); color-scheme:light; }
body[data-style="synthwave"]  { --font: "Exo 2", "Chakra Petch", sans-serif; --display:"Audiowide", "Chakra Petch", sans-serif; --bg:#0d0518; --panel:#170a2a; --panel-2:#24103e; --line:#4a1a6a; --fg:#ffe6f7; --dim:#b08acb; --accent:#ff3ca6; --on-accent:#0d0518; --route:#3cf0ff; --me:#3cf0ff; }
body[data-style="bd"]         { --font: "Comic Neue", "Comic Sans MS", cursive; --display:"Bangers", "Chakra Petch", cursive; --bg:#ffe9a8; --panel:#ffffff; --panel-2:#fff4d6; --line:#111111; --fg:#111111; --dim:#555555; --accent:#ff3a6a; --on-accent:#ffffff; --route:#ff3a6a; --me:#ff3a6a; --shadow:none; color-scheme:light; }
body[data-style="plan"]       { --font: "Roboto", system-ui, sans-serif; --bg:#f2efe9; --panel:#ffffff; --panel-2:#f3f4f6; --line:#dfe2e6; --fg:#1f2328; --dim:#5f6770; --accent:#1a73e8; --on-accent:#fff; --route:#1a73e8; --me:#1a73e8; --shadow:0 6px 20px rgba(0,0,0,.18); color-scheme:light; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; }
#panel { overflow-x: hidden; }
body { background: var(--bg); color: var(--fg); font-family: var(--font); font-size: 15px; overflow: hidden; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.tnum { font-variant-numeric: tabular-nums; }

/* ---------- Cartes (panneaux) : forme selon le style ---------- */
.card { background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 10px; }
.card { border-radius: 0; clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 12px 100%, 0 calc(100% - 12px)); }
body[data-style="plan"] .card, body[data-style="glace"] .card { clip-path: none; border-radius: 12px; }
body[data-style="fantasy"] .card, body[data-style="pirate"] .card { clip-path: none; border-radius: 5px; border: 2px solid var(--line); }
body[data-style="western"] .card { clip-path: none; border-radius: 2px; border: 2px solid var(--line); outline: 1px solid var(--line); outline-offset: -6px; }
body[data-style="samourai"] .card { clip-path: none; border-radius: 2px; border-left: 4px solid var(--accent); }
body[data-style="retro"] .card { clip-path: none; border-radius: 0; border: 3px solid var(--fg); box-shadow: 4px 4px 0 var(--fg); }
body[data-style="blocs"] .card { clip-path: none; border-radius: 0; border: 3px solid #000; box-shadow: inset 3px 3px 0 #ffffff, inset -3px -3px 0 #555555; }
body[data-style="bd"] .card { clip-path: none; border-radius: 12px; border: 3px solid #111; box-shadow: 4px 4px 0 #111; }
body[data-style="horreur"] .card { box-shadow: 0 0 30px rgba(193,18,31,.18), var(--shadow); }
body[data-style="synthwave"] .card, body[data-style="espace"] .card { box-shadow: 0 0 24px color-mix(in srgb, var(--accent) 22%, transparent), var(--shadow); }

/* Titres et chiffres avec la police du style */
.logo, #instr .dist, .speed b, .stat b, #banner .t, .routes .dur, #place h2, .card h3 { font-family: var(--display); }
body[data-style="retro"] .logo, body[data-style="blocs"] .logo { font-size: 12px; }
body[data-style="retro"] #instr .dist { font-size: 20px; }
body[data-style="retro"] .stat b, body[data-style="retro"] .speed b { font-size: 15px; line-height: 1.6; }
body[data-style="retro"] .routes .dur, body[data-style="retro"] .card h3 { font-size: 13px; line-height: 1.6; }
body[data-style="retro"] #place h2 { font-size: 15px; line-height: 1.5; }
body[data-style="retro"] #banner .t { font-size: clamp(18px, 3.4vw, 34px); line-height: 1.4; }

/* ---------- Carte ---------- */
#stage { position: fixed; inset: 0; }
#map { position: absolute; inset: 0; }
.maplibregl-ctrl-attrib { font-family: system-ui, sans-serif; font-size: 11px; }
.maplibregl-ctrl-bottom-left { display: none; }

/* Minimap ronde (navigation) */
#stage.mini { background: radial-gradient(circle at 50% 45%, var(--panel-2), var(--bg) 70%); }
#stage.mini #map, #stage.mini #ring {
  --d: min(82vmin, calc(100vh - 250px), 640px);
  width: var(--d); height: var(--d); inset: auto; left: calc(50% - var(--d) / 2); top: calc(50% - var(--d) / 2 + 5px);
  border-radius: 50%;
}
#stage.mini #map { overflow: hidden; box-shadow: 0 0 0 6px var(--panel), 0 0 0 9px var(--accent), 0 0 50px color-mix(in srgb, var(--accent) 40%, transparent); }
#ring { display: none; position: absolute; pointer-events: none; }
#stage.mini #ring { display: block; }
.ring-dot { position: absolute; left: 50%; top: 50%; width: 30px; height: 30px; margin: -15px 0 0 -15px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 14px; }
#north { background: var(--panel); border: 2px solid var(--accent); color: var(--fg); }
#edge { background: var(--route); border: 3px solid #000; box-shadow: 0 0 14px var(--route); display: none; }
#stage.mini .maplibregl-ctrl-bottom-right { display: none; }

/* Marqueurs */
.me { width: 22px; height: 22px; border-radius: 50%; background: var(--me); border: 3px solid #fff; box-shadow: 0 0 0 6px color-mix(in srgb, var(--me) 25%, transparent), 0 2px 8px rgba(0,0,0,.5); }
.me svg { display: none; }
.me.arrow { width: 46px; height: 46px; background: none; border: 0; box-shadow: none; }
.me.arrow svg { display: block; width: 100%; height: 100%; filter: drop-shadow(0 0 6px var(--me)); }
.pin { width: 30px; height: 30px; border-radius: 50%; background: var(--route); border: 3px solid #000; box-shadow: 0 0 0 3px var(--route), 0 0 18px var(--route); }
.pin.place { background: var(--accent); box-shadow: 0 0 0 3px var(--accent), 0 0 18px var(--accent); }
.pin.start { width: 18px; height: 18px; background: var(--panel); border: 4px solid var(--fg); box-shadow: 0 2px 6px rgba(0,0,0,.5); animation: none; }
/* Pulsation par un anneau (::after) animé en « transform » : fluide et léger pour la carte graphique.
   La carte place les marqueurs avec « transform » sur le marqueur lui-même : on n'y touche pas. */
.pin { animation: none; } /* pas de « position » ici : la carte place le marqueur en absolu */
.pin::after { content: ""; position: absolute; inset: -6px; border-radius: 50%; border: 3px solid var(--route); opacity: .7; animation: ring 1.8s ease-out infinite; pointer-events: none; }
.pin.place::after { border-color: var(--accent); }
.pin.start::after, .pin.via::after { display: none; }
@keyframes ring { from { transform: scale(.8); opacity: .8; } to { transform: scale(1.6); opacity: 0; } }
body.eco .pin::after, body.eco #speedo.over .speed, body.eco #alert, body.eco #xpPop div { animation: none !important; }
body.eco .card { box-shadow: none; }

/* ---------- Panneau gauche ---------- */
#panel { position: fixed; z-index: 10; top: calc(var(--safe-t) + 12px); left: 12px; width: 400px; max-width: calc(100% - 24px);
  max-height: calc(100% - var(--safe-t) - var(--safe-b) - 24px); display: flex; flex-direction: column; gap: 10px; }
#searchbar { display: flex; align-items: center; gap: 4px; padding: 4px; }
.logo { font-weight: 700; letter-spacing: .14em; color: var(--accent); padding: 0 10px 0 8px; font-size: 17px; }
.field { flex: 1; min-width: 0; border: 0; background: transparent; padding: 11px 8px; font-size: 16px; outline: none; }
.field::placeholder { color: var(--dim); }
.ib { width: 42px; height: 42px; flex: none; border: 0; background: transparent; display: grid; place-items: center; border-radius: 8px; color: var(--fg); }
.ib:hover { background: var(--panel-2); }
.ib svg { width: 22px; height: 22px; }
.ib.accent { color: var(--accent); }

/* Raccourcis sous la recherche */
#quick { display: flex; gap: 6px; padding: 0 8px 8px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--panel-2); border-radius: 999px; padding: 6px 12px; display: inline-flex; gap: 6px; align-items: center; font-size: 13px; font-weight: 600; }
.chip svg { width: 16px; height: 16px; }
.chip:hover { border-color: var(--accent); }
.chip.go { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.chip .n { color: var(--dim); font-weight: 500; }
.chip.go .n { color: inherit; opacity: .7; }

.suggest { list-style: none; margin: 0; padding: 4px 0; max-height: 50vh; overflow-y: auto; }
.suggest li button { width: 100%; text-align: left; border: 0; background: transparent; padding: 9px 14px; display: flex; gap: 12px; align-items: center; }
.suggest li button:hover, .suggest li button.hl { background: var(--panel-2); }
.suggest svg, .suggest canvas { width: 20px; height: 20px; flex: none; color: var(--dim); }
.suggest b { display: block; font-weight: 600; }
.suggest span { display: block; font-size: 13px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.suggest .empty, .suggest .sep { padding: 10px 14px; color: var(--dim); font-size: 13px; }
.suggest .sep { padding: 8px 14px 2px; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; }

.scroll { overflow-y: auto; min-height: 0; }
#place { padding: 16px; display: grid; gap: 12px; }
.place-head { display: flex; gap: 12px; align-items: center; }
.place-head canvas { width: 38px; height: 38px; flex: none; }
#place h2 { margin: 0; font-size: 22px; line-height: 1.15; text-wrap: balance; }
#place p { margin: 0; color: var(--dim); font-size: 14px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn { border: 1px solid var(--line); background: var(--panel-2); padding: 9px 14px; border-radius: 999px; display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn.on { color: var(--accent); border-color: var(--accent); }
.btn:hover { filter: brightness(1.08); }
.link { border: 0; background: none; padding: 2px 0; color: var(--dim); font-size: 13px; text-decoration: underline; text-underline-offset: 3px; }
.link:hover, .link.on { color: var(--accent); }
.coords { font-size: 12px; color: var(--dim); }

/* Liste des favoris */
.card h3 { margin: 0; font-size: 16px; }
.card-head { display: flex; align-items: center; gap: 6px; padding: 8px 8px 8px 16px; border-bottom: 1px solid var(--line); }
.card-head h3 { flex: 1; }
.list { list-style: none; margin: 0; padding: 4px 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 14px; }
.list li:hover { background: var(--panel-2); }
.list canvas { width: 30px; height: 30px; flex: none; }
.list .txt { flex: 1; min-width: 0; cursor: pointer; }
.list b { display: block; font-weight: 600; }
.list span { display: block; font-size: 13px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .ib { width: 36px; height: 36px; }
.list .ib svg { width: 18px; height: 18px; }
.hint { padding: 12px 16px; color: var(--dim); font-size: 14px; }

/* Itinéraire */
#dir { display: flex; flex-direction: column; min-height: 0; }
.dir-head { display: flex; align-items: center; gap: 6px; padding: 8px 8px 0; }
.modes { display: flex; gap: 4px; flex: 1; justify-content: center; }
.mode { border: 0; background: transparent; padding: 8px 14px; border-radius: 999px; display: inline-flex; gap: 6px; align-items: center; color: var(--dim); font-weight: 600; font-size: 13px; }
.mode svg { width: 20px; height: 20px; }
.mode[aria-pressed="true"] { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.ends { display: grid; grid-template-columns: 22px 1fr 42px; gap: 6px 8px; align-items: center; padding: 10px 12px 12px; position: relative; }
.ends .dot { width: 12px; height: 12px; border-radius: 50%; border: 3px solid var(--fg); justify-self: center; }
.ends .dot.b { background: var(--route); border-color: #000; box-shadow: 0 0 0 2px var(--route); }
.ends .inwrap { position: relative; }
.ends input { width: 100%; border: 1px solid var(--line); background: var(--panel-2); padding: 10px 12px; border-radius: 8px; outline: none; }
.ends input:focus { border-color: var(--accent); }
.ends .suggest { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 5; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 8px; }
#swap { grid-column: 3; grid-row: 1 / span 2; }
.routes { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.routes li button { width: 100%; text-align: left; border: 0; background: transparent; padding: 14px 16px; display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; border-left: 4px solid transparent; }
.routes li button:hover { background: var(--panel-2); }
.routes li button[aria-current="true"] { border-left-color: var(--route); background: color-mix(in srgb, var(--route) 8%, transparent); }
.routes .dur { font-size: 20px; font-weight: 700; }
.routes .len { color: var(--dim); align-self: center; }
.routes .via { grid-column: 1 / -1; font-size: 13px; color: var(--dim); }
.routes .go { grid-column: 1 / -1; margin-top: 8px; display: flex; gap: 8px; }
.status { padding: 14px 16px; color: var(--dim); font-size: 14px; border-top: 1px solid var(--line); }
.steps { list-style: none; margin: 0; padding: 0 0 8px; border-top: 1px solid var(--line); }
.steps li button { width: 100%; text-align: left; border: 0; background: transparent; padding: 10px 16px; display: grid; grid-template-columns: 28px 1fr auto; gap: 12px; align-items: center; font-size: 14px; }
.steps li button:hover { background: var(--panel-2); }
.steps svg { width: 24px; height: 24px; color: var(--accent); }
.steps .d { color: var(--dim); font-size: 13px; }

/* ---------- Contrôles à droite ---------- */
#controls { position: fixed; z-index: 9; right: 12px; bottom: calc(var(--safe-b) + 34px); display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.stack { display: flex; flex-direction: column; padding: 3px; }
.ctl { width: 44px; height: 44px; border: 0; background: transparent; display: grid; place-items: center; border-radius: 8px; }
.ctl:hover { background: var(--panel-2); }
.ctl svg { width: 22px; height: 22px; }
.ctl.on { color: var(--accent); }
.ctl .txt { font-weight: 700; font-size: 14px; }
.ctl.report svg { color: #ff8a00; }
#compass svg { transition: transform .2s; }
#styleBtn { width: 64px; height: 64px; padding: 3px; position: relative; }
#styleBtn i { display: block; width: 100%; height: 100%; }
#styleBtn span { position: absolute; bottom: 4px; left: 0; right: 0; text-align: center; font-size: 11px; font-weight: 700; color: #fff; text-shadow: 0 1px 2px #000, 0 0 4px #000; }

/* Panneaux flottants à droite (styles, réglages, signalement) */
.float { position: fixed; z-index: 11; right: 66px; bottom: calc(var(--safe-b) + 34px); max-width: calc(100vw - 90px); max-height: calc(100vh - 60px); overflow-y: auto; }
#styles { padding: 10px; display: grid; grid-template-columns: repeat(auto-fill, 80px); gap: 8px; width: 380px; }
.sw { border: 2px solid transparent; background: transparent; padding: 0; border-radius: 8px; display: grid; gap: 4px; font-size: 12px; font-weight: 600; color: var(--fg); }
.sw i { display: block; height: 54px; border-radius: 6px; position: relative; overflow: hidden; }
.sw i canvas { position: absolute; right: 3px; bottom: 3px; width: 22px; height: 22px; }
.sw[aria-pressed="true"] { border-color: var(--accent); }

#settings { width: 300px; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 16px; cursor: pointer; font-size: 14px; }
.toggle small { display: block; color: var(--dim); font-size: 12px; margin-top: 2px; }
.toggle input { appearance: none; width: 40px; height: 22px; border-radius: 999px; background: var(--line); position: relative; flex: none; cursor: pointer; transition: background .15s; }
.toggle input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.toggle input:checked { background: var(--accent); }
.toggle input:checked::after { transform: translateX(18px); }
.settings-foot { padding: 10px 16px 14px; display: flex; gap: 14px; flex-wrap: wrap; }

#report { width: 340px; }
.rep-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; padding: 12px; }
.rep-grid button { border: 1px solid var(--line); background: var(--panel-2); border-radius: 10px; padding: 10px 6px; display: grid; justify-items: center; gap: 6px; font-size: 13px; font-weight: 600; }
.rep-grid button:hover { border-color: var(--accent); }
.rep-grid canvas { width: 40px; height: 40px; }

/* Petite bulle (signalement, radar) */
#pop { position: fixed; z-index: 31; width: 250px; padding: 12px 14px; display: grid; gap: 8px; }
#pop .top { display: flex; gap: 10px; align-items: center; }
#pop canvas { width: 34px; height: 34px; flex: none; }
#pop b { display: block; }
#pop span { color: var(--dim); font-size: 13px; }

/* Menu clic droit */
#ctx { position: fixed; z-index: 30; min-width: 240px; padding: 6px 0; }
#ctx button { display: flex; width: 100%; gap: 10px; align-items: center; text-align: left; border: 0; background: transparent; padding: 9px 14px; font-size: 14px; }
#ctx button:hover { background: var(--panel-2); }
#ctx svg { width: 18px; height: 18px; color: var(--dim); }
#ctx .coords { padding: 4px 14px 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }

/* ---------- Navigation ---------- */
#nav { position: fixed; inset: 0; z-index: 12; pointer-events: none; }
#nav > * { pointer-events: auto; }
#instr { position: absolute; top: calc(var(--safe-t) + 12px); left: 50%; transform: translateX(-50%); width: min(560px, calc(100% - 24px)); display: flex; align-items: center; gap: 14px; padding: 12px 18px; }
#instr svg { width: 52px; height: 52px; flex: none; color: var(--accent); }
#instr .dist { font-size: 32px; font-weight: 700; line-height: 1; }
#instr .street { color: var(--dim); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#instr .txt { min-width: 0; }

/* Alerte radar / signalement */
#alert { position: absolute; top: calc(var(--safe-t) + 104px); left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 12px; padding: 10px 16px; min-width: 240px;
  background: var(--danger); color: #fff; border-radius: 12px; box-shadow: 0 8px 26px rgba(0,0,0,.45); font-weight: 700; clip-path: none; animation: alertIn .3s ease-out; }
#nav.free #alert { top: calc(var(--safe-t) + 16px); }
#alert canvas { width: 36px; height: 36px; flex: none; }
#alert .d { font-size: 22px; font-family: var(--display); }
#alert small { display: block; font-weight: 500; opacity: .9; }
@keyframes alertIn { from { transform: translate(-50%, -12px); opacity: 0; } }

/* Compteur de vitesse + panneau de limitation */
#speedo { position: absolute; left: 16px; bottom: calc(var(--safe-b) + 96px); display: flex; align-items: center; gap: 10px; }
.speed { width: 86px; height: 86px; border-radius: 50%; background: var(--panel); border: 3px solid var(--line); box-shadow: var(--shadow); display: grid; place-content: center; text-align: center; transition: background .2s, border-color .2s; }
.speed b { font-size: 32px; line-height: 1; }
.speed span { font-size: 11px; letter-spacing: .12em; color: var(--dim); }
#speedo.over .speed { background: var(--danger); border-color: #fff; color: #fff; animation: overPulse 1s ease-in-out infinite; }
#speedo.over .speed span { color: #fff; }
@keyframes overPulse { 50% { transform: scale(1.06); } }
.limit { width: 64px; height: 64px; border-radius: 50%; background: #fff; border: 7px solid #e3141c; display: grid; place-items: center; color: #111; font: 700 24px/1 "Arial Narrow", Arial, sans-serif; box-shadow: 0 4px 12px rgba(0,0,0,.4); }
.limit.unknown { color: #999; font-size: 18px; }

#navbar { position: absolute; bottom: calc(var(--safe-b) + 12px); left: 50%; transform: translateX(-50%); width: min(760px, calc(100% - 24px)); display: flex; align-items: center; gap: 6px; padding: 8px 10px; flex-wrap: wrap; }
.stats { display: flex; flex: 1; min-width: 220px; }
.stat { flex: 1; text-align: center; padding: 2px 6px; }
.stat b { display: block; font-size: 26px; line-height: 1.05; }
.stat span { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--dim); }
.stat + .stat { border-left: 1px solid var(--line); }
.navbtns { display: flex; gap: 2px; flex-wrap: wrap; }
.navbtns .ctl { width: auto; min-width: 52px; padding: 0 8px; gap: 2px; grid-auto-flow: row; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--dim); height: 52px; }
.navbtns .ctl svg { margin: 0 auto; color: var(--fg); }
.navbtns .ctl.on, .navbtns .ctl.on svg { color: var(--accent); }
.navbtns .quit svg { color: var(--danger); }
.navbtns .report svg { color: #ff8a00; }
#recenter { position: absolute; right: 12px; bottom: calc(var(--safe-b) + 100px); }

#banner { position: fixed; left: 0; right: 0; top: 36%; z-index: 40; text-align: center; pointer-events: none; opacity: 0; transition: opacity .4s; }
#banner.on { opacity: 1; }
#banner .band { background: linear-gradient(90deg, transparent, rgba(0,0,0,.78) 20%, rgba(0,0,0,.78) 80%, transparent); padding: 16px 0; }
#banner .k { font-size: 13px; letter-spacing: .4em; text-transform: uppercase; color: var(--accent); }
#banner .t { font-size: clamp(30px, 6vw, 58px); font-weight: 700; text-transform: uppercase; color: #fff; text-shadow: 0 0 18px var(--accent), 0 3px 0 #000; padding: 4px 16px; text-wrap: balance; }
#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--safe-b) + 90px); z-index: 45; padding: 10px 16px; max-width: calc(100% - 32px); text-align: center; font-size: 14px; }

/* Téléphone */
@media (max-width: 640px) {
  #panel { left: 8px; right: 8px; width: auto; max-width: none; top: calc(var(--safe-t) + 8px); }
  .float { right: 8px; left: 8px; width: auto !important; bottom: calc(var(--safe-b) + 90px); max-width: none; }
  #styles { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); }
  .mode span { display: none; }
  #instr .dist { font-size: 26px; }
  #speedo { bottom: calc(var(--safe-b) + 150px); }
  .speed { width: 72px; height: 72px; } .speed b { font-size: 26px; }
  .limit { width: 54px; height: 54px; border-width: 6px; font-size: 20px; }
}
@media (prefers-reduced-motion: reduce) { .pin::after, #speedo.over .speed, #alert { animation: none; } #banner { transition: none; } }

/* ==========================================================
   Ajouts : étapes, options, profil, météo, brouillard, XP
   ========================================================== */
/* Itinéraire : départ, étapes, arrivée */
.ends { display: grid; gap: 6px; padding: 10px 56px 10px 12px; position: relative; grid-template-columns: none; }
.end-row { display: grid; grid-template-columns: 22px 1fr; gap: 8px; align-items: center; }
.end-row.via { grid-template-columns: 22px 1fr 34px; }
.end-row.via .ib { width: 34px; height: 34px; }
.ends .dot.v { width: 18px; height: 18px; border-radius: 4px; border: 0; background: var(--route); color: #000; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
#vias { display: grid; gap: 6px; }
#swap { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); grid-column: auto; grid-row: auto; }
.dir-opts { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; padding: 0 12px 10px; font-size: 13px; color: var(--dim); }
.avoid { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.chip.sm { padding: 4px 10px; font-size: 12px; }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.pin.via { width: 24px; height: 24px; border-radius: 6px; background: var(--route); border: 3px solid #000; color: #000; font: 700 12px/1 var(--font); display: grid; place-items: center; animation: none; box-shadow: 0 2px 8px rgba(0,0,0,.5); }

/* Niveau dans les raccourcis */
.chip.lvl .lv { background: var(--accent); color: var(--on-accent); border-radius: 6px; padding: 1px 6px; font-family: var(--display); font-size: 12px; }

/* Profil */
#profile h4, #explo h4 { margin: 14px 16px 6px; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--dim); }
.prof-top { display: flex; gap: 14px; align-items: center; padding: 14px 16px 4px; }
.lvl-badge { width: 58px; height: 58px; flex: none; display: grid; place-items: center; background: var(--accent); color: var(--on-accent); font: 700 26px/1 var(--display);
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%); }
.prof-txt { flex: 1; min-width: 0; display: grid; gap: 3px; }
.prof-txt b { font-family: var(--display); font-size: 18px; }
.prof-txt span { font-size: 12px; color: var(--dim); }
.bar { height: 8px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .5s; }
.daily { list-style: none; margin: 0; padding: 0 16px; display: grid; gap: 8px; }
.daily li { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; font-size: 14px; }
.daily li .bar { grid-column: 1 / -1; height: 6px; }
.daily li.done { color: var(--dim); text-decoration: line-through; }
.daily small { color: var(--accent); font-weight: 700; }
.missions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 0 16px; }
.mis { text-align: left; border: 1px solid var(--line); background: var(--panel-2); border-radius: 10px; padding: 10px 12px; display: grid; gap: 3px; }
.mis:hover { border-color: var(--accent); }
.mis b { font-family: var(--display); }
.mis span { font-size: 12px; color: var(--dim); }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 0 16px; }
.stat-grid div { background: var(--panel-2); border-radius: 8px; padding: 8px 10px; }
.stat-grid b { display: block; font: 700 18px/1.2 var(--display); }
.stat-grid span { font-size: 11px; color: var(--dim); }
.row.pad { padding: 10px 16px 0; }
.ach { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 8px; padding: 0 16px; }
.ach div { border: 1px solid var(--line); border-radius: 8px; padding: 8px; font-size: 12px; opacity: .45; }
.ach div.got { opacity: 1; border-color: var(--accent); }
.ach b { display: block; font-size: 13px; }
.trips li { cursor: pointer; }
.trips .d { font-size: 12px; color: var(--dim); white-space: nowrap; }
#profile .list { padding-bottom: 12px; }

/* Réglages : bouton à 3 choix */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; flex: none; }
.seg button { border: 0; background: transparent; padding: 5px 10px; font-size: 12px; font-weight: 600; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }

/* Météo */
#weather { position: fixed; z-index: 9; top: calc(var(--safe-t) + 12px); right: 12px; display: flex; gap: 6px; align-items: center; padding: 6px 12px; font-size: 15px; cursor: pointer; }
#weather svg { width: 24px; height: 24px; }
#weather b { font-family: var(--display); }
body.navmode #weather { top: auto; bottom: calc(var(--safe-b) + 200px); right: 12px; }
#fx, #fog { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#fx { z-index: 2; }
#fog { z-index: 1; }
#fogfx { position: absolute; inset: 0; pointer-events: none; z-index: 2; background: radial-gradient(ellipse at 50% 60%, rgba(220,225,235,.05), rgba(220,225,235,.38)); }
#stage.mini #fx, #stage.mini #fog, #stage.mini #fogfx { display: none; }
.flash { animation: flash .6s ease-out; }
@keyframes flash { 10% { background: rgba(255,255,255,.35); } 100% { background: transparent; } }

/* Gains d'XP */
#xpPop { position: fixed; z-index: 44; left: 50%; top: 22%; transform: translateX(-50%); pointer-events: none; display: grid; justify-items: center; gap: 6px; }
#xpPop div { font: 700 26px/1 var(--display); color: var(--accent); text-shadow: 0 0 12px var(--accent), 0 2px 0 #000; animation: xpUp 1.8s ease-out forwards; white-space: nowrap; }
#xpPop div small { display: block; font-size: 13px; color: #fff; text-align: center; margin-top: 2px; }
@keyframes xpUp { 0% { transform: translateY(12px) scale(.8); opacity: 0; } 15% { transform: none; opacity: 1; } 75% { opacity: 1; } 100% { transform: translateY(-30px); opacity: 0; } }
@media (max-width: 640px) { .missions { grid-template-columns: 1fr; } .stat-grid { grid-template-columns: repeat(2, 1fr); } }
@media (prefers-reduced-motion: reduce) { #xpPop div { animation: none; } }
/* 5 modes : on n'affiche que le nom du mode choisi */
.mode { padding: 8px 10px; }
.mode span { display: none; }
.mode[aria-pressed="true"] span { display: inline; }

/* ---------- Mobile / tactile ---------- */
button { touch-action: manipulation; }
#map, #stage { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
input { font-size: 16px !important; } /* évite le zoom automatique d'iOS */
.float { z-index: 20; }
#styles .card-head.span { grid-column: 1 / -1; margin: -10px -10px 0; }
.float .card-head { position: sticky; top: 0; background: var(--panel); z-index: 1; }
@media (max-width: 640px) {
  .float { bottom: calc(var(--safe-b) + 8px); max-height: 70vh; }
  #nav .float, body.navmode .float { bottom: calc(var(--safe-b) + 8px); }
  #weather { top: auto; bottom: calc(var(--safe-b) + 34px); right: 66px; }
  body.navmode #weather { bottom: calc(var(--safe-b) + 250px); right: 12px; }
  .navbtns { width: 100%; justify-content: space-around; }
  #panel .scroll { max-height: 62vh; }
}
@media (display-mode: standalone) { #panel { top: calc(var(--safe-t) + 6px); } }

/* GPS peu précis (ordinateur, intérieur) : le bouton de position passe en orange */
#locate.weak svg { color: #ff9a1a; }

/* Polices d'interface selon le style : réglages de taille pour les polices spéciales */
body[data-style="retro"] { font-size: 19px; }
body[data-style="retro"] .suggest span, body[data-style="retro"] .coords, body[data-style="retro"] .stat span { font-size: 16px; }
body[data-style="radar"], body[data-style="course"] { font-size: 16px; }
body[data-style="blocs"] { font-size: 14px; }

/* ---------- Transports en commun et trajets habituels ---------- */
.legs { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin: 4px 0 2px; }
.legs i { font-style: normal; color: var(--dim); }
.tchip { display: inline-flex; align-items: center; gap: 3px; padding: 2px 7px 2px 5px; border-radius: 6px; font: 700 12px/1.4 var(--font); }
.tchip svg { width: 15px; height: 15px; }
.tchip.walk { background: var(--panel-2); color: var(--dim); border: 1px solid var(--line); }
.ticon { display: grid; place-items: center; color: var(--accent); }
.ticon svg { width: 24px; height: 24px; }
.steps li button b { color: var(--fg); }
.habit { grid-column: 1 / -1; justify-self: start; margin-top: 4px; font-size: 12px; font-weight: 700; color: var(--on-accent); background: var(--accent); border-radius: 999px; padding: 2px 10px; }
.topts { display: inline-flex; gap: 6px; align-items: center; }
.topts select, .topts input { background: var(--panel-2); color: var(--fg); border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; font: inherit; font-size: 16px !important; }

/* Exploration : monde, pays, régions, villes */
.xw { display: flex; gap: 12px; align-items: center; margin: 0 16px; padding: 10px 12px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; }
.xw-badge { width: 46px; height: 46px; flex: none; display: grid; place-items: center; border-radius: 50%; border: 3px solid var(--accent); color: var(--accent); font: 700 20px/1 var(--display); }
.xw-txt { flex: 1; min-width: 0; display: grid; gap: 4px; }
.xw-txt b { font-family: var(--display); font-size: 16px; }
.xw-txt span, .xw-txt small { font-size: 12px; color: var(--dim); }
.xq { margin: 8px 16px 0; font-size: 12px; }
.xc { margin: 8px 16px 0; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); overflow: hidden; }
.xc summary { list-style: none; cursor: pointer; padding: 9px 10px; display: grid; grid-template-columns: auto 1fr auto; gap: 6px 10px; align-items: center; }
.xc summary::-webkit-details-marker { display: none; }
.xc summary .nm { min-width: 0; display: grid; }
.xc summary .nm b { font-family: var(--display); font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.xc em, .xrow em { font-style: normal; font-size: 11px; color: var(--dim); white-space: nowrap; }
.xc .bar, .xrow .bar { grid-column: 1 / -1; height: 5px; }
.cc { font: 700 11px/1 var(--display); background: var(--accent); color: var(--on-accent); border-radius: 4px; padding: 4px 5px; letter-spacing: .04em; }
.pct { font: 700 14px/1 var(--display); white-space: nowrap; }
.xrow { display: grid; grid-template-columns: 1fr auto auto; gap: 4px 8px; align-items: center; padding: 7px 10px; font-size: 13px; border-top: 1px solid var(--line); }
.xrow b { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.xrow.city { padding-left: 24px; font-size: 12px; }
.xrow.city .pct { font-size: 12px; }
.xrow.more { display: block; color: var(--dim); }
#profile .row.pad { gap: 8px; }

#explo { padding-bottom: 14px; }
#explo .xw { margin-top: 12px; }
#explo .row.pad { gap: 8px; }
/* Trafic */
.traf { display: block; font-size: 12px; font-weight: 700; margin-top: 2px; }
.traf.ok { color: #2fbf71; }
.traf.mid { color: #ff8a00; }
.traf.bad { color: #ff3b4a; }
.traf.wait { color: var(--dim); font-weight: 400; }
.traf.none { color: var(--dim); font-weight: 400; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.toggle.col { flex-direction: column; align-items: stretch; cursor: default; }
.toggle a { color: var(--accent); }
#ttNote.ok { color: #2fbf71; }
#ttNote.bad { color: #ff3b4a; }
.ttkey { display: flex; gap: 8px; }
.ttkey input { flex: 1; min-width: 0; font: 16px/1.2 var(--font); padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); color: var(--fg); }

/* Résumé de fin de trajet */
#summary { position: fixed; z-index: 45; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(420px, calc(100vw - 24px)); max-height: calc(100vh - 40px); overflow-y: auto; padding-bottom: 14px; }
.sum-xp { text-align: center; font: 800 40px/1.1 var(--display); color: var(--accent); margin: 10px 0 6px; }
.sum-lvl { display: flex; gap: 12px; align-items: center; margin: 0 16px 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); }
.sum-lvl.up { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.lvl-badge.sm { width: 44px; height: 44px; font-size: 20px; }
#summary .stat-grid { margin-bottom: 8px; }
.sum-list { list-style: none; margin: 8px 16px 0; padding: 0; font-size: 13px; }
.sum-list li { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-top: 1px solid var(--line); }
.sum-list li b { color: var(--accent); white-space: nowrap; }
.sum-list.notes li { display: block; }
.sum-list.notes li b { color: var(--fg); }
#summary .row.pad { gap: 8px; }
