/* La course à la jaquette — styles du jeu (canvas, compteurs, bouton nitro, carte de départ).
   Chargée dans la racine fantôme (Shadow DOM) de #game-layer : ces règles ne touchent que le jeu, et les styles de
   l'application (css/app.css) ne l'atteignent pas. Les polices (@font-face) sont déclarées par la page principale
   (assets/fonts/fonts.css), seul endroit où le navigateur les prend en compte.
   Mise en page : une seule scène d'arcade vue de dessus (boulevard côtier la nuit), compteurs en haut, nitro en bas
   à droite, cartes par-dessus le canvas. */

/* L'élément hôte (#game-layer) joue le rôle du <body> de l'ancienne page jeu.html */
:host {
  --night: #120c22;
  --panel: rgba(18, 12, 34, 0.84);
  --line: rgba(255, 255, 255, 0.10);
  --pink: #ff2e88;
  --cyan: #2de2e6;
  --sun: #ffb347;
  --cash: #5dff9e;
  --siren-r: #ff3b4f;
  --siren-b: #3b7bff;
  --ink: #f6f0ff;
  --muted: #a99cc9;
  --display: "Bungee", "Impact", "Arial Black", system-ui, sans-serif;
  --body: "Rajdhani", "Segoe UI", system-ui, sans-serif;
  color-scheme: dark;
  box-sizing: border-box;
  background: var(--night); color: var(--ink);
  font-family: var(--body); font-weight: 600;
  overflow: hidden;
  /* marges de l'ancienne page, plus les zones réservées des téléphones à encoche */
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  -webkit-user-select: none; user-select: none;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
#app { height: 100%; display: flex; justify-content: center; }
#stage {
  position: relative; width: 100%; max-width: 520px; height: 100%;
  border-radius: 22px; overflow: hidden; background: #1d1830;
  box-shadow: 0 0 0 1px var(--line), 0 0 60px rgba(255, 46, 136, 0.18);
}
canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
canvas:focus { outline: none; } /* le canvas reçoit le focus au départ de la course, sans cadre visible */

/* Compteurs (butin, distance, vitesse, étoiles, santé) */
.hud { position: absolute; inset: 0 0 auto 0; padding: 10px 12px; display: flex; flex-direction: column; gap: 7px; pointer-events: none; }
.hud-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.money { font-family: var(--display); font-size: 26px; line-height: 1; color: var(--cash); text-shadow: 0 0 12px rgba(93, 255, 158, 0.45), 0 2px 0 #0b3b22; font-variant-numeric: tabular-nums; }
.sub { font-size: 13px; color: var(--muted); letter-spacing: 0.04em; font-variant-numeric: tabular-nums; margin-top: 3px; }
.sub b { color: var(--ink); font-weight: 700; }
.right { display: flex; align-items: center; gap: 8px; }
.stars { display: flex; gap: 2px; }
.stars svg { width: 20px; height: 20px; }
.stars .on { fill: #fff3c4; filter: drop-shadow(0 0 4px rgba(255, 220, 120, 0.9)); }
.stars .off { fill: rgba(255, 255, 255, 0.16); }
.stars.flash svg .on { animation: starflash 0.35s steps(2) 4; }
@keyframes starflash { 50% { fill: var(--siren-r); } }
.icon-btn {
  pointer-events: auto; width: 34px; height: 34px; border: 0; border-radius: 50%;
  background: var(--panel); box-shadow: inset 0 0 0 1px var(--line); color: var(--ink);
  display: grid; place-items: center; cursor: pointer;
}
.icon-btn svg { width: 16px; height: 16px; }
.health { height: 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.12); overflow: hidden; box-shadow: inset 0 0 0 1px var(--line); }
.health i { display: block; height: 100%; width: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--pink), var(--sun)); transform-origin: left; transition: transform 0.15s; }
.health.low i { background: var(--siren-r); animation: blink 0.5s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.4; } }

/* Bouton nitro */
.nitro {
  position: absolute; right: 14px; bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  width: 74px; height: 74px; border-radius: 50%; border: 0; cursor: pointer;
  background: radial-gradient(circle at 50% 40%, #2a1f4d, #160f2c);
  box-shadow: 0 0 0 2px rgba(45, 226, 230, 0.55), 0 0 18px rgba(45, 226, 230, 0.35);
  color: var(--cyan); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-family: var(--display); font-size: 11px; letter-spacing: 0.04em;
  touch-action: manipulation;
}
.nitro:disabled { opacity: 0.45; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.15); color: var(--muted); }
.nitro.active { background: radial-gradient(circle, #2de2e6, #127c8a); color: #06222a; }
.nitro svg { width: 24px; height: 24px; }
.pips { display: flex; gap: 4px; }
.pips i { width: 7px; height: 7px; border-radius: 50%; background: rgba(255, 255, 255, 0.18); }
.pips i.on { background: var(--cyan); box-shadow: 0 0 6px var(--cyan); }

/* Carte de départ, posée sur le canvas */
.overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 14px; background: rgba(10, 6, 22, 0.55); overflow-y: auto; }
.card {
  width: 100%; max-width: 380px; margin: auto; padding: 22px 18px 18px;
  border-radius: 22px; background: var(--panel);
  box-shadow: inset 0 0 0 1px var(--line), 0 18px 50px rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  display: flex; flex-direction: column; gap: 14px; text-align: center;
}
h1 { margin: 0; font-family: var(--display); font-weight: 400; line-height: 0.92; text-wrap: balance; }
h1 { font-size: clamp(38px, 11.5vw, 52px); color: var(--pink); text-shadow: 0 0 22px rgba(255, 46, 136, 0.55), 3px 3px 0 #4a0f3a; }
h1 span { display: block; color: var(--sun); text-shadow: 0 0 22px rgba(255, 179, 71, 0.5), 3px 3px 0 #5a2a00; }
h1.neon { line-height: 1.1; text-transform: uppercase; white-space: nowrap; font-size: clamp(16px, 5.4vw, 21px); }
h1.neon .n1 { display: inline; font-size: inherit; color: #FFF6FB; text-shadow: 0 0 8px #FF4FA3, 0 0 22px #FF4FA3; white-space: nowrap; }
h1.neon .n2 { display: inline; font-size: inherit; color: #FFE3F1; text-shadow: 0 0 8px #FF9F45, 0 0 24px #FF9F45; white-space: nowrap; }
.lead { margin: 0; font-size: 16px; line-height: 1.35; color: var(--muted); font-weight: 500; }
.lead strong { color: var(--ink); font-weight: 700; }
.legend { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.tile { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 4px 6px; border-radius: 12px; background: rgba(255, 255, 255, 0.05); min-width: 0; }
.tile canvas { position: static; width: 40px; height: 40px; }
.tile span { font-size: 13px; line-height: 1.1; }
.tile b { display: block; font-size: 12px; font-weight: 700; }
.tile.good b { color: var(--cash); }
.tile.gold { background: rgba(255, 201, 74, 0.12); box-shadow: inset 0 0 0 1px rgba(255, 201, 74, 0.45); }
.tile.gold b { color: #ffc94a; }
.tile.bad b { color: var(--siren-r); }
.score-line { color: var(--cash); font-weight: 700; }
.legend-title { margin: 2px 0 -2px; font-size: 13px; font-weight: 700; text-align: left; }
.legend-title.good { color: var(--cash); }
.legend-title.bad { color: var(--siren-r); }
.howto { display: flex; flex-direction: column; gap: 8px; text-align: left; }
.howto-row { display: flex; gap: 10px; align-items: center; font-size: 14px; line-height: 1.3; color: var(--ink); }
.howto-row b { color: var(--cyan); }
.howto-ico { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: rgba(45, 226, 230, 0.12); color: var(--cyan); }
.howto-ico svg { width: 20px; height: 20px; }
.nitro-ico { font-family: var(--display); font-size: 14px; box-shadow: inset 0 0 0 2px var(--cyan); }
.tip { margin: 0; padding: 9px 12px; border-radius: 12px; background: rgba(59, 123, 255, 0.12); box-shadow: inset 0 0 0 1px rgba(59, 123, 255, 0.35); font-size: 14px; line-height: 1.3; font-weight: 600; }
.tip strong { color: var(--cash); }
/* Message du serveur quand la partie ne peut pas s'ouvrir (connexion perdue, serveur occupé…) */
.intro-msg { margin: 0; padding: 9px 12px; border-radius: 12px; background: rgba(255, 59, 79, 0.14); box-shadow: inset 0 0 0 1px rgba(255, 59, 79, 0.5); font-size: 15px; line-height: 1.3; font-weight: 700; color: var(--ink); }
.btn {
  align-self: center; border: 0; cursor: pointer; padding: 13px 40px; border-radius: 14px;
  background: var(--pink); color: #fff; font-family: var(--display); font-size: 20px; letter-spacing: 0.03em;
  box-shadow: 0 5px 0 #8a1048, 0 0 24px rgba(255, 46, 136, 0.45);
  transition: transform 0.08s, box-shadow 0.08s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #8a1048; }
.btn:disabled { opacity: 0.45; cursor: wait; }
.btn-ghost { align-self: center; cursor: pointer; padding: 8px 18px; border-radius: 12px; border: 1px solid rgba(45, 226, 230, 0.5); background: transparent; color: var(--cyan); font-family: var(--body); font-weight: 700; font-size: 15px; }
.btn-ghost:disabled { opacity: 0.45; cursor: default; }
.btn:focus-visible, .btn-ghost:focus-visible, .icon-btn:focus-visible, .nitro:focus-visible { outline: 3px solid var(--cyan); outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { .stars.flash svg .on, .health.low i { animation: none; } .btn { transition: none; } }
