:root { color-scheme: light;
  --bleu: #1d4f9d; --bleu-f: #133a76; --jaune: #ffcf1f; --rouge: #d42a2a;
  --encre: #13171c; --blanc: #fbfbf7; --verre: rgba(16, 22, 30, .66);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #cfe2ec; color: var(--blanc);
  font-family: 'Rubik', system-ui, -apple-system, 'Segoe UI', sans-serif; touch-action: none;
  -webkit-user-select: none; user-select: none; overscroll-behavior: none; }
#scene, #scene canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
/* flou en haut de l'image (effet maquette / miniature) + léger vignettage */
#tilt { position: fixed; inset: 0; pointer-events: none;
  background: radial-gradient(120% 90% at 50% 62%, transparent 60%, rgba(20,30,40,.22));
  -webkit-backdrop-filter: blur(2.5px); backdrop-filter: blur(2.5px);
  -webkit-mask-image: linear-gradient(#000 0%, rgba(0,0,0,.6) 14%, transparent 30%); mask-image: linear-gradient(#000 0%, rgba(0,0,0,.6) 14%, transparent 30%); }
body.eco #tilt { display: none; }
.hide { display: none !important; }
button { font: inherit; color: inherit; border: 0; cursor: pointer; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; }
#hud button { pointer-events: auto; }
.pill { position: absolute; background: var(--verre); border-radius: 999px; padding: 6px 12px;
 }
#lives { top: calc(env(safe-area-inset-top) + 12px); left: 12px; display: flex; align-items: center; gap: 5px; padding: 7px 11px; }
#lives .lab { font-size: 16px; line-height: 1; margin-right: 2px; }
#lives i { display: block; width: 14px; height: 14px; border-radius: 4px; border: 2px solid rgba(255,255,255,.7); }
#lives i.hit { background: #ff3b3b; border-color: #ffb3b3; box-shadow: 0 0 8px rgba(255,59,59,.8); }
#lives .sh { font-size: 15px; line-height: 1; margin-left: 3px; }
#km { margin-top: 3px; font-weight: 700; font-size: 14px; text-shadow: 0 1px 3px rgba(0,0,0,.6); font-variant-numeric: tabular-nums; }
/* frise de la poursuite, bord gauche */
#gapWrap { position: absolute; left: 14px; top: calc(env(safe-area-inset-top) + 70px); display: flex; flex-direction: column; align-items: center; gap: 6px; }
#gapBar { position: relative; width: 12px; height: 34vh; border-radius: 6px; background: linear-gradient(#ff3b3b, #ffb21f 30%, rgba(255,255,255,.35) 60%, rgba(255,255,255,.2));
  box-shadow: 0 0 0 2px rgba(16,22,30,.45); }
#gapBar.hot { animation: hot .45s infinite alternate; }
@keyframes hot { to { box-shadow: 0 0 0 2px #fff, 0 0 14px 4px rgba(255,59,59,.9); } }
#gapBar .me { position: absolute; left: -4px; top: -6px; width: 20px; height: 12px; border-radius: 3px; background: #d6211c; border: 2px solid #fff; }
#gapBar .cop { position: absolute; left: -3px; width: 18px; height: 10px; border-radius: 3px; background: #1d4f9d; border: 2px solid #fff; transition: top .1s linear; }
#gapLab { font-weight: 800; font-size: 13px; text-shadow: 0 1px 3px rgba(0,0,0,.7); font-variant-numeric: tabular-nums; min-width: 3em; text-align: center; }
#itemBtn { position: absolute; bottom: calc(env(safe-area-inset-bottom) + 122px); right: 28px; width: 64px; height: 64px; border-radius: 50%;
  background: rgba(16,22,30,.72); font-size: 32px; line-height: 64px; text-align: center; box-shadow: 0 0 0 3px #ffcf1f inset, 0 0 16px 3px rgba(255,207,31,.6); }
#itemBtn.empty { box-shadow: 0 0 0 2px rgba(255,255,255,.35) inset; background: rgba(16,22,30,.35); }
#itemBtn.left { right: auto; left: 28px; }
/* lueur des gyrophares quand la police est tout près */
#siren { position: fixed; inset: 0; pointer-events: none; opacity: 0; }
#siren.blue { box-shadow: inset 0 -60px 70px -20px rgba(40,110,255,.9); }
#siren.red { box-shadow: inset 0 -60px 70px -20px rgba(255,40,40,.8); }
#scoreBox { position: absolute; top: calc(env(safe-area-inset-top) + 8px); left: 50%; transform: translateX(-50%); text-align: center; }
#score { font-weight: 800; font-size: 34px; line-height: 1; font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 0 rgba(0,0,0,.45), 0 0 14px rgba(0,0,0,.25); }
#combo { margin-top: 4px; display: inline-block; min-height: 22px; font-weight: 800; font-size: 15px; color: var(--encre);
  background: var(--jaune); border-radius: 6px; padding: 2px 8px; transform-origin: 50% 0; }
#combo:empty { visibility: hidden; }
#combo.bump { animation: bump .25s ease-out; }
@keyframes bump { 0% { transform: scale(1.35); } 100% { transform: scale(1); } }
.round { position: absolute; top: calc(env(safe-area-inset-top) + 10px); right: 12px; width: 40px; height: 40px; border-radius: 50%;
  background: var(--verre); display: flex; align-items: center; justify-content: center; gap: 5px; }
.round span { display: block; width: 5px; height: 15px; background: #fff; border-radius: 2px; }
#speedo { bottom: calc(env(safe-area-inset-bottom) + 22px); left: 14px; display: flex; align-items: baseline; gap: 4px; padding: 8px 14px; }
#speedo b { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; min-width: 2.3em; text-align: right; }
#speedo small { font-size: 12px; opacity: .8; }
#nitroBtn { position: absolute; bottom: calc(env(safe-area-inset-bottom) + 16px); right: 14px; width: 92px; height: 92px; border-radius: 50%;
  background: rgba(16,22,30,.72); overflow: hidden; box-shadow: 0 0 0 3px rgba(255,255,255,.85) inset, 0 6px 16px rgba(0,0,0,.25); }
#nitroBtn.left { right: auto; left: 14px; }
#speedo.right { left: auto; right: 14px; }
#nitroFill { position: absolute; left: 0; right: 0; bottom: 0; height: 0%; background: linear-gradient(#58c8ff, #1d6fd6); transition: height .12s; }
#nitroBtn span { position: relative; font-weight: 900; font-style: italic; font-size: 17px; letter-spacing: .5px; text-shadow: 0 1px 2px rgba(0,0,0,.6); }
#nitroBtn.ready { box-shadow: 0 0 0 3px #fff inset, 0 0 18px 4px rgba(88,200,255,.75); }
#nitroBtn.on { box-shadow: 0 0 0 3px #ffd34d inset, 0 0 24px 8px rgba(255,140,30,.85); }
#nitroBtn.on #nitroFill { background: linear-gradient(#ffd34d, #ff6a1a); }

/* textes qui sautent au-dessus des voitures */
#pops { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.pop { position: absolute; transform: translate(-50%, -50%); font-weight: 900; font-style: italic; white-space: nowrap;
  font-size: 20px; color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.5), 0 0 8px rgba(0,0,0,.35); animation: pop .95s ease-out forwards; }
.pop.fr { color: var(--jaune); }
.pop.boom { font-size: 34px; color: #ff8a1f; -webkit-text-stroke: 1.5px #3b1300; }
.pop.car { font-size: 24px; color: #fff; background: var(--rouge); padding: 2px 10px; border-radius: 6px; text-shadow: none; }
.pop.hurt { font-size: 28px; color: #ff4b4b; -webkit-text-stroke: 1.5px #3a0606; }
@keyframes pop { 0% { opacity: 0; margin-top: 10px; transform: translate(-50%,-50%) scale(.6); }
  15% { opacity: 1; transform: translate(-50%,-50%) scale(1.15); } 30% { transform: translate(-50%,-50%) scale(1); }
  100% { opacity: 0; margin-top: -60px; } }
#toast { position: fixed; top: calc(env(safe-area-inset-top) + 70px); left: 50%; transform: translateX(-50%); background: var(--verre);
  padding: 8px 14px; border-radius: 10px; font-size: 14px; }
#hud.hurt::after { content: ''; position: absolute; inset: 0; box-shadow: inset 0 0 80px 20px rgba(220,30,30,.55); animation: fade .6s forwards; }
@keyframes fade { to { opacity: 0; } }

/* ---------- écrans ---------- */
.overlay { position: fixed; inset: 0; display: flex; justify-content: center; align-items: flex-start;
  padding: calc(env(safe-area-inset-top) + 56px) 16px 16px; background: linear-gradient(rgba(19,58,118,.55), rgba(19,23,28,.15) 70%); }
.card { width: 100%; max-width: 380px; background: rgba(251,251,247,.96); color: var(--encre); border-radius: 18px; padding: 22px 20px 18px;
  text-align: center; box-shadow: 0 14px 40px rgba(0,0,0,.25); }
.shield { display: inline-block; background: var(--rouge); color: #fff; font-weight: 800; font-size: 20px; padding: 3px 12px;
  border: 3px solid #fff; outline: 2px solid var(--rouge); border-radius: 4px; }
h1 { margin: 10px 0 0; font-size: 46px; font-weight: 900; font-style: italic; line-height: .95; letter-spacing: -1px; color: var(--bleu); }
h1 em { color: var(--rouge); }
h2 { margin: 0 0 14px; font-size: 26px; font-weight: 800; color: var(--bleu); }
.sub { margin: 6px 0 14px; font-weight: 700; color: #59606a; }
.how { list-style: none; padding: 0; margin: 0 0 18px; text-align: left; font-size: 15px; line-height: 1.35; }
.how li { padding: 8px 10px 8px 38px; position: relative; border-top: 1px solid #e3e3dc; }
.how li::before { content: ''; position: absolute; left: 10px; top: 10px; width: 18px; height: 14px; border-radius: 3px; background: var(--bleu); }
.how li:nth-child(2)::before { background: var(--jaune); }
.how li:nth-child(3)::before { background: #ff7a1f; }
.big { display: block; width: 100%; padding: 15px; margin-top: 10px; border-radius: 12px; font-size: 19px; font-weight: 800;
  background: var(--bleu); color: #fff; box-shadow: 0 4px 0 var(--bleu-f); }
.big:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--bleu-f); }
.big.alt { background: #e6e7e1; color: var(--encre); box-shadow: 0 4px 0 #c5c7bf; }
.best { margin: 12px 0 0; font-size: 14px; color: #59606a; min-height: 1em; }
.opts { margin-top: 16px; display: grid; gap: 8px; }
.opt { padding: 11px; border-radius: 10px; background: #f0f0ea; color: var(--encre); font-size: 15px; font-weight: 700; text-align: left; }
.opt b { float: right; color: var(--bleu); }
.bigscore { font-size: 54px; font-weight: 800; color: var(--encre); line-height: 1; font-variant-numeric: tabular-nums; }
.record { display: inline-block; margin-top: 8px; background: var(--jaune); font-weight: 800; padding: 3px 10px; border-radius: 6px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 16px 0 4px; }
.stats div { background: #f0f0ea; border-radius: 10px; padding: 8px; }
.stats b { display: block; font-size: 22px; font-weight: 800; color: var(--bleu); }
.stats small { font-size: 12px; color: #59606a; }
.pop.rase { font-size: 24px; color: #fff36b; }

/* ---------- poursuite « simu » ---------- */
#lives .dmg { display: block; width: 52px; height: 10px; border-radius: 5px; background: rgba(255,255,255,.2); overflow: hidden; }
#lives .dmg i { display: block; height: 100%; width: 0; border-radius: 5px; background: linear-gradient(90deg, #6fd36a, #ffcf1f 55%, #ff3b3b); transition: width .2s; }
#lives b { font-size: 12px; font-weight: 800; font-variant-numeric: tabular-nums; min-width: 2.9em; }
#lives.bad { animation: hot .45s infinite alternate; }
#nitroBtn.brake { background: rgba(120,16,16,.78); box-shadow: 0 0 0 3px rgba(255,255,255,.85) inset, 0 6px 16px rgba(0,0,0,.25); }
#nitroBtn.brake.on { background: #d42a2a; box-shadow: 0 0 0 3px #fff inset, 0 0 20px 6px rgba(255,60,40,.8); }
#nitroBtn.brake span { font-style: normal; font-size: 18px; }
#bust { position: fixed; left: 50%; top: 38%; transform: translate(-50%, -50%); pointer-events: none; display: flex; flex-direction: column; align-items: center;
  background: rgba(16,22,30,.72); padding: 10px 22px; border-radius: 14px; box-shadow: 0 0 0 3px #ff3b3b inset; }
#bust small { font-weight: 800; font-size: 14px; text-transform: uppercase; letter-spacing: .08em; color: #ffb3b3; }
#bust b { font-size: 54px; font-weight: 900; line-height: 1; color: #fff; }

/* radio de la gendarmerie */
#radio { position: fixed; left: 14px; right: 120px; bottom: calc(env(safe-area-inset-bottom) + 76px); pointer-events: none;
  background: rgba(28,43,92,.86); color: #e8eeff; font-size: 13px; font-weight: 700; line-height: 1.3; padding: 7px 10px; border-radius: 10px;
  box-shadow: 0 0 0 2px rgba(255,255,255,.25) inset; }
#radio.in { animation: radioIn .25s ease-out; }
@keyframes radioIn { from { transform: translateY(8px); opacity: 0; } }
