:root {
  --bg: #0b0e14;
  --panel: rgba(20, 24, 33, 0.92);
  --accent: #0a84ff;
  --text: #f5f7fa;
  --danger: #ff3b30;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  user-select: none;
}

#map { position: absolute; inset: 0; }

/* --- Puck voiture --- */
#car-puck {
  position: absolute;
  left: 50%;
  top: 58%; /* aligné avec le padding caméra */
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 5;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.5));
}

/* --- Cartouche vitesse --- */
#speed-box {
  position: absolute;
  left: 20px;
  bottom: 24px;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--panel);
  border: 3px solid rgba(255,255,255,0.15);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
  box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}
.speed-val { font-size: 34px; font-weight: 700; line-height: 1; }
.speed-unit { font-size: 12px; opacity: 0.6; margin-top: 2px; }

/* --- Boutons de contrôle --- */
.ctrl-btn {
  position: absolute;
  right: 20px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: var(--panel);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  box-shadow: 0 6px 20px rgba(0,0,0,0.4);
  cursor: pointer;
}
.ctrl-btn:active { transform: scale(0.94); }
#recenter-btn { bottom: 24px; }
#settings-btn { top: 24px; }

/* --- Bannière d'alerte radar --- */
#alert-banner {
  position: absolute;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  min-width: 300px;
  max-width: min(560px, 92vw);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  border-radius: 20px;
  background: var(--panel);
  border: 2px solid var(--danger);
  z-index: 20;
  box-shadow: 0 8px 28px rgba(0,0,0,0.5);
  transition: border-color 0.2s;
}
#alert-banner.imminent {
  border-color: #fff;
  animation: pulse 0.6s infinite alternate;
}
@keyframes pulse {
  from { box-shadow: 0 0 0 0 rgba(255,59,48,0.6); }
  to   { box-shadow: 0 0 0 14px rgba(255,59,48,0); }
}
/* Visuel : photo par type, avec repli sur l'emoji si la photo manque */
.alert-visual {
  position: relative;
  width: 74px;
  height: 74px;
  flex: 0 0 auto;
  border-radius: 14px;
  overflow: hidden;
  background: #10141c;
  display: flex;
  align-items: center;
  justify-content: center;
}
#alert-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none; /* affichée par JS si la photo charge */
}
.alert-visual.has-photo #alert-photo { display: block; }
.alert-visual.has-photo .alert-icon { display: none; }
.alert-icon { font-size: 40px; }

.alert-text { flex: 1 1 auto; min-width: 0; }
.alert-title { font-size: 19px; font-weight: 700; }
.alert-sub {
  font-size: 14px;
  opacity: 0.7;
  margin: 2px 0 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.alert-dist { font-size: 28px; font-weight: 800; color: var(--danger); }

/* Panneau limite de vitesse (rond rouge façon panneau) */
.alert-limit {
  flex: 0 0 auto;
  width: 66px;
  height: 66px;
  border-radius: 50%;
  background: #fff;
  border: 7px solid var(--danger);
  display: flex;
  align-items: center;
  justify-content: center;
}
.alert-limit span { color: #111; font-size: 26px; font-weight: 800; }

/* --- Panneau réglages --- */
#settings-panel {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: min(360px, 85vw);
  background: var(--panel);
  backdrop-filter: blur(12px);
  z-index: 30;
  padding: 24px;
  overflow-y: auto;
  box-shadow: -8px 0 30px rgba(0,0,0,0.5);
}
#settings-panel h2 { margin: 0 0 20px; }
#settings-panel .row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  font-size: 17px;
}
#settings-panel input[type=checkbox] { width: 26px; height: 26px; accent-color: var(--accent); }
#settings-panel select {
  background: #1c2230; color: var(--text); border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px; padding: 8px 10px; font-size: 16px;
}
.mini-btn {
  background: var(--accent); color: #fff; border: none;
  border-radius: 10px; padding: 10px 16px; font-size: 15px; cursor: pointer;
}
.mini-btn.full { width: 100%; margin-top: 20px; padding: 14px; font-size: 17px; }
#settings-info { font-size: 13px; opacity: 0.6; margin-top: 16px; line-height: 1.5; }
#credits { font-size: 12px; opacity: 0.5; margin-top: 12px; line-height: 1.6; }
#credits code { font-size: 11px; background: rgba(255,255,255,0.08); padding: 1px 4px; border-radius: 4px; }

/* --- Statut --- */
#status {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  padding: 10px 18px;
  border-radius: 20px;
  font-size: 14px;
  z-index: 15;
  max-width: 80vw;
  text-align: center;
}

.hidden { display: none !important; }
