/* ============================================================
   GTO — Styles : mobile-first, HUD arcade, contrôles tactiles
   ============================================================ */

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
  background: #0c1420;
  font-family: system-ui, -apple-system, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

#game {
  position: fixed;
  inset: 0;
  display: block;
  touch-action: none;
}

/* ================= HUD ================= */
#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 20;
  padding: calc(env(safe-area-inset-top, 0px) + 10px)
           calc(env(safe-area-inset-right, 0px) + 10px)
           calc(env(safe-area-inset-bottom, 0px) + 10px)
           calc(env(safe-area-inset-left, 0px) + 10px);
}

#hud-top-left {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  left: calc(env(safe-area-inset-left, 0px) + 10px);
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 132px;
}
#minimap {
  width: clamp(92px, 26vw, 132px);
  height: auto;
  aspect-ratio: 1;
  border-radius: 10px;
  opacity: 0.92;
}
#hud-health {
  height: 7px;
  border-radius: 4px;
  background: rgba(0,0,0,0.55);
  overflow: hidden;
}
#hud-health-fill {
  height: 100%;
  width: 100%;
  background: #4fc94f;
  border-radius: 4px;
  transition: width 0.2s;
}

#hud-top-right {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  right: calc(env(safe-area-inset-right, 0px) + 10px);
  text-align: right;
}
#hud-money {
  font-size: clamp(22px, 5.5vw, 34px);
  font-weight: 900;
  font-style: italic;
  color: #f5d020;
  -webkit-text-stroke: 1px rgba(0,0,0,0.6);
  text-shadow: 2px 2px 0 rgba(0,0,0,0.75);
  font-variant-numeric: tabular-nums;
}
#hud-stars {
  font-size: clamp(16px, 4vw, 22px);
  letter-spacing: 2px;
  color: rgba(255,255,255,0.16);
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}
#hud-stars span.on { color: #4f9fe8; }
#hud-sys {
  margin-top: 6px;
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  pointer-events: auto;
}
#hud-sys button {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 9px;
  background: rgba(0,0,0,0.45);
  color: #fff;
  font-size: 15px;
  cursor: pointer;
  touch-action: manipulation;
}

#hud-objective {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.55);
  color: #f5d020;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 5px 12px;
  border-radius: 20px;
  display: none;
  white-space: nowrap;
}

#hud-msg {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 48px);
  left: 50%;
  transform: translateX(-50%);
  max-width: min(560px, 64vw);
  background: rgba(8,12,20,0.78);
  border: 1px solid rgba(255,255,255,0.12);
  color: #e8e8ee;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  text-align: center;
  padding: 9px 16px;
  border-radius: 12px;
  opacity: 0;
  transition: opacity 0.25s;
}
#hud-msg.show { opacity: 1; }

#splash {
  position: absolute;
  top: 38%;
  left: 0;
  right: 0;
  text-align: center;
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.18s, transform 0.18s;
}
#splash.show { opacity: 1; transform: scale(1); }
#splash-title {
  font-size: clamp(38px, 11vw, 84px);
  font-weight: 900;
  font-style: italic;
  letter-spacing: 0.02em;
  -webkit-text-stroke: 2px rgba(0,0,0,0.85);
  text-shadow: 3px 4px 0 rgba(0,0,0,0.8);
}
#splash-sub {
  margin-top: 6px;
  color: #e8e8ee;
  font-size: clamp(13px, 3.5vw, 18px);
  font-weight: 700;
  text-shadow: 0 2px 4px rgba(0,0,0,0.9);
}

#hurt {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(200,20,20,0.5) 100%);
  opacity: 0;
  transition: opacity 0.12s;
}
#hurt.show { opacity: 1; }

/* ---- hotbar d'armes (style inventaire) ---- */
/* marge basse qui dégage à la fois le home-indicator (PWA) et la barre
   d'outils Safari (navigateur) : on prend le max des deux mesures. */
#hotbar {
  position: absolute;
  bottom: calc(max(env(safe-area-inset-bottom, 0px), var(--vp-bottom, 0px)) + 12px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  pointer-events: auto;
}
/* sur mobile : la hotbar se cale en bas à gauche (loin des boutons d'action
   de droite), et rétrécit un peu pour rester compacte en portrait. */
body.touch #hotbar {
  left: calc(env(safe-area-inset-left, 0px) + 10px);
  transform: none;
  gap: 6px;
}
body.touch .slot { width: 46px; height: 46px; border-radius: 11px; }
body.touch .slot canvas { width: 38px; height: 38px; }
.slot {
  position: relative;
  width: 52px;
  height: 52px;
  border: 2px solid rgba(255,255,255,0.22);
  border-radius: 12px;
  background: rgba(10,14,22,0.6);
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  transition: border-color 0.12s, background 0.12s, transform 0.12s;
}
.slot canvas { width: 44px; height: 44px; display: block; margin: 2px auto 0; }
.slot:not(.owned) { opacity: 0.32; }
.slot.active {
  border-color: #f5d020;
  background: rgba(245,208,32,0.20);
  transform: translateY(-4px);
}
.slot .key {
  position: absolute;
  top: 2px;
  left: 6px;
  font-size: 9px;
  font-weight: 800;
  color: rgba(255,255,255,0.5);
}
body.touch .slot .key { display: none; }
.slot .ammo {
  position: absolute;
  bottom: 2px;
  right: 6px;
  font-size: 10px;
  font-weight: 800;
  color: #e8e8ee;
  text-shadow: 0 1px 2px rgba(0,0,0,0.9);
}
body.in-car #hotbar { display: none; }

/* bouton voiture qui s'illumine quand une voiture est à portée */
#btn-car.ready {
  border-color: #f5d020;
  background: rgba(245,208,32,0.30);
  box-shadow: 0 0 16px rgba(245,208,32,0.55);
  animation: carpulse 0.9s ease-in-out infinite;
}
@keyframes carpulse {
  50% { transform: scale(1.08); }
}

/* ================= Contrôles tactiles ================= */
.touch-only { display: none; }
body.touch .touch-only { display: block; }

#touch {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 30;
}

#joy {
  display: none;
  position: fixed;
  width: 0;
  height: 0;
  z-index: 31;
}
#joy-base {
  position: absolute;
  left: -60px;
  top: -60px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(255,255,255,0.07);
  border: 2px solid rgba(255,255,255,0.25);
}
#joy-stick {
  position: absolute;
  left: -26px;
  top: -26px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(255,255,255,0.30);
  border: 2px solid rgba(255,255,255,0.5);
}

/* cluster d'action à droite : grille 2×2 condensée, alignée en bas-droite,
   remontée au-dessus de la barre Safari / du home-indicator.
   [ ⇆ ] [ 🚗 ]
   [SAUT] [TIR] */
#btns {
  position: fixed;
  right: calc(env(safe-area-inset-right, 0px) + 12px);
  bottom: calc(max(env(safe-area-inset-bottom, 0px), var(--vp-bottom, 0px)) + 14px);
  display: grid;
  grid-template-columns: auto auto;
  gap: 9px;
  align-items: end;
  justify-items: center;
  pointer-events: auto;
}
.ctl {
  border: 2px solid rgba(255,255,255,0.35);
  border-radius: 50%;
  background: rgba(10,14,22,0.5);
  color: #fff;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}
.ctl:active { background: rgba(245,208,32,0.35); transform: scale(0.94); }
.ctl.big { width: 70px; height: 70px; font-size: 18px; font-style: italic; letter-spacing: 0.05em; }
.ctl.mid { width: 54px; height: 54px; font-size: 21px; }
.ctl.small { width: 46px; height: 46px; font-size: 19px; }
#btn-fire { border-color: rgba(245,90,60,0.7); background: rgba(60,18,14,0.5); }
#btn-brake { font-size: 11px; letter-spacing: 0.04em; }

/* affichage contextuel pied / voiture
   (en iso, le bouton SAUT/DRIFT reste visible dans les deux modes) */
.when-car { display: none; }
body.in-car .when-car { display: inline; }
body.in-car .when-foot { display: none; }
body.in-car #btn-weapon { visibility: hidden; }
#btn-brake { font-style: italic; font-weight: 900; }

/* ================= Écrans (titre / pause) ================= */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(42,68,110,0.35), transparent 60%),
    rgba(9, 13, 22, 0.94);
  padding: 24px;
}
.overlay.show { display: flex; }

.logo {
  font-size: clamp(84px, 24vw, 170px);
  font-weight: 900;
  font-style: italic;
  line-height: 0.95;
  letter-spacing: -0.02em;
  background: linear-gradient(180deg, #ffe95e 0%, #f5b020 55%, #e37b1a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-stroke: 3px #16161a;
  filter: drop-shadow(4px 6px 0 rgba(0,0,0,0.85));
}
.logo-sm {
  font-size: clamp(44px, 12vw, 80px);
  -webkit-text-stroke: 2px #16161a;
}
.subtitle {
  color: #e8e8ee;
  font-size: clamp(16px, 4.5vw, 26px);
  font-weight: 800;
  letter-spacing: 0.55em;
  margin-left: 0.55em; /* compense le letter-spacing */
  text-shadow: 0 2px 6px rgba(0,0,0,0.8);
}
.tagline {
  color: rgba(232,232,238,0.75);
  font-size: clamp(13px, 3.4vw, 16px);
  line-height: 1.5;
  max-width: 480px;
}

.menu-btn {
  margin-top: 8px;
  min-width: 220px;
  padding: 15px 42px;
  font-size: 19px;
  font-weight: 900;
  font-style: italic;
  letter-spacing: 0.1em;
  color: #16161a;
  background: linear-gradient(180deg, #ffe95e, #f0a818);
  border: none;
  border-radius: 14px;
  box-shadow: 0 5px 0 #8a5c0a, 0 8px 18px rgba(0,0,0,0.5);
  cursor: pointer;
  touch-action: manipulation;
}
.menu-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #8a5c0a; }
.menu-btn.ghost {
  background: transparent;
  color: #e8e8ee;
  border: 2px solid rgba(255,255,255,0.35);
  box-shadow: none;
}

.help {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 18px;
  color: rgba(232,232,238,0.65);
  font-size: 12.5px;
  max-width: 520px;
}
.help b { color: #f5d020; font-weight: 800; }
.help-touch { display: none; }
body.touch .help-touch { display: flex; }
body.touch .help-desktop { display: none; }

#best {
  margin-top: 10px;
  color: rgba(245,208,32,0.85);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.05em;
}

/* variante iso du logo + lien retour */
.logo-iso {
  font-size: 0.42em;
  vertical-align: 0.62em;
  letter-spacing: 0.04em;
  -webkit-text-stroke: 2px #16161a;
}
.other-version {
  margin-top: 12px;
  color: rgba(232,232,238,0.55);
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: none;
}
.other-version:hover { color: #f5d020; }

/* écrans étroits en paysage : compacter le titre */
@media (max-height: 480px) {
  .logo { font-size: 72px; }
  .tagline { display: none; }
  .overlay { gap: 8px; }
  .menu-btn { padding: 11px 34px; }
}
