:root {
  --bg: #0b0d17;
  --panel: #141829;
  --panel2: #1b2034;
  --line: #262c45;
  --ink: #e8ebff;
  --muted: #8a90bb;
  --muted2: #6a7196;
  --pink: #ff3b6b;
  --violet: #7b5cff;
  --cyan: #19e3c0;
  --grad: linear-gradient(135deg, #ff3b6b, #7b5cff);
  --shadow: 0 18px 50px rgba(0, 0, 0, .55);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: 'Space Grotesk', system-ui, sans-serif;
  background: var(--bg); color: var(--ink);
  overflow: hidden; -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
a { color: var(--violet); }

#map { position: fixed; inset: 0; z-index: 1; background: #0b0d17; }

/* ---------- Overlay / auth ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center; padding: 18px;
  background: radial-gradient(1200px 600px at 50% -10%, rgba(123, 92, 255, .22), transparent 60%),
              radial-gradient(900px 500px at 90% 110%, rgba(255, 59, 107, .18), transparent 55%),
              rgba(7, 9, 16, .92);
  backdrop-filter: blur(6px);
  animation: fade .4s ease;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }

.auth-card {
  width: min(880px, 100%); max-height: 94vh; overflow: auto;
  display: grid; grid-template-columns: 1fr 1fr;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 24px; box-shadow: var(--shadow);
}
.auth-card.narrow { grid-template-columns: 1fr; width: min(460px, 100%); }
.auth-hero {
  background: var(--grad); padding: 40px 34px; color: #fff;
  display: flex; flex-direction: column;
  position: relative; overflow: hidden;
}
.auth-hero::after {
  content: ""; position: absolute; inset: 0;
  background: repeating-linear-gradient(45deg, rgba(255,255,255,.06) 0 14px, transparent 14px 28px);
  pointer-events: none;
}
.auth-hero .logo { font-size: 46px; }
.auth-hero h1 {
  font-family: 'Archivo Black', sans-serif; font-size: 44px; line-height: .92;
  margin: 14px 0 10px; letter-spacing: -1px;
}
.auth-hero h1 span { display: block; font-size: 20px; opacity: .8; letter-spacing: 4px; }
.tagline { font-size: 15px; opacity: .92; max-width: 24ch; line-height: 1.5; }
.hero-preview { margin-top: auto; display: grid; place-items: center; min-height: 120px; }

.auth-body { padding: 30px 32px; }
.tabs { display: flex; gap: 6px; background: var(--panel2); padding: 5px; border-radius: 14px; margin-bottom: 22px; }
.tab {
  flex: 1; border: 0; background: transparent; color: var(--muted);
  font: 600 14px 'Space Grotesk'; padding: 10px; border-radius: 10px; cursor: pointer; transition: .18s;
}
.tab.active { background: var(--panel); color: var(--ink); box-shadow: 0 2px 10px rgba(0,0,0,.3); }

.pane { display: none; flex-direction: column; gap: 14px; }
.pane.active { display: flex; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
label { font: 600 12px 'Space Grotesk'; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
label.inline { flex-direction: row; align-items: center; gap: 10px; }
input[type=text], input[type=email], input[type=password] {
  background: var(--panel2); border: 1px solid var(--line); color: var(--ink);
  border-radius: 12px; padding: 12px 14px; font: 500 15px 'Space Grotesk'; transition: .15s;
}
input:focus { outline: 0; border-color: var(--violet); box-shadow: 0 0 0 3px rgba(123,92,255,.25); }
input[type=color] {
  width: 48px; height: 36px; padding: 0; border: 1px solid var(--line);
  border-radius: 10px; background: none; cursor: pointer;
}

button.primary {
  border: 0; cursor: pointer; color: #fff; font: 700 15px 'Space Grotesk';
  padding: 14px; border-radius: 14px; background: var(--grad);
  box-shadow: 0 10px 26px rgba(123,92,255,.35); transition: transform .12s, filter .12s; margin-top: 4px;
}
button.primary:hover { transform: translateY(-1px); filter: brightness(1.08); }
button.primary:active { transform: translateY(0); }
button.ghost {
  border: 1px solid var(--line); background: var(--panel2); color: var(--ink);
  font: 600 14px 'Space Grotesk'; padding: 11px 16px; border-radius: 12px; cursor: pointer; transition: .15s;
}
button.ghost:hover { border-color: var(--violet); }

button.instant {
  border: 1px dashed var(--line); background: transparent; color: var(--ink);
  font: 700 14px 'Space Grotesk'; padding: 12px; border-radius: 14px; cursor: pointer; transition: .15s;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
button.instant:hover { border-color: var(--cyan); color: var(--cyan); }
button.instant small { color: var(--muted2); font-weight: 500; }

.form-msg { font-size: 13px; min-height: 18px; margin: 2px 0 0; color: var(--muted); }
.form-msg.ok { color: var(--cyan); }
.form-msg.err { color: #ff6b8a; }

/* styler */
.styler { display: grid; grid-template-columns: 120px 1fr; gap: 16px; align-items: center;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 16px; padding: 16px; }
.styler-preview { display: grid; place-items: center; min-height: 110px; }
.styler-controls { display: flex; flex-direction: column; gap: 12px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  border: 1px solid var(--line); background: var(--panel); color: var(--muted);
  font: 600 12px 'Space Grotesk'; padding: 7px 12px; border-radius: 999px; cursor: pointer; transition: .15s;
}
.chip.active { background: var(--grad); color: #fff; border-color: transparent; }

.fineprint { color: var(--muted2); font-size: 12px; margin-top: 14px; text-align: center; }
.modal-title { font-family: 'Archivo Black'; font-size: 22px; margin: 0 0 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* ---------- HUD ---------- */
#hud {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  display: flex; align-items: center; gap: 18px; padding: 12px 16px;
  background: linear-gradient(180deg, rgba(11,13,23,.92), rgba(11,13,23,.55) 70%, transparent);
  pointer-events: none;
}
#hud > * { pointer-events: auto; }
.hud-brand { font-family: 'Archivo Black'; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.hud-brand span { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hud-stats { display: flex; gap: 10px; margin-left: auto; }
.stat {
  background: rgba(20,24,41,.82); border: 1px solid var(--line); border-radius: 14px;
  padding: 7px 14px; min-width: 92px; text-align: center; backdrop-filter: blur(8px);
}
.stat label { display: block; font-size: 10px; letter-spacing: .5px; text-transform: uppercase; color: var(--muted2); }
.stat b { font-size: 18px; font-weight: 700; }
.stat b.hot { color: var(--pink); text-shadow: 0 0 14px rgba(255,59,107,.7); }
.hud-actions { display: flex; gap: 8px; }
.hud-actions .ghost { font-size: 17px; padding: 9px 12px; background: rgba(20,24,41,.82); backdrop-filter: blur(8px); }

.gps-pill {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 40;
  background: rgba(20,24,41,.92); border: 1px solid var(--line); color: var(--ink);
  padding: 9px 16px; border-radius: 999px; font: 600 13px 'Space Grotesk'; backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
}
.gps-pill.ok { border-color: var(--cyan); }
.gps-pill.warn { border-color: #ffb23b; }

/* ---------- drawer ---------- */
.drawer {
  position: fixed; top: 64px; right: 14px; z-index: 45; width: 300px; max-height: 70vh; overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow);
}
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 8px; }
.drawer-head h3 { margin: 0; font-size: 16px; }
.x { background: none; border: 0; color: var(--muted); font-size: 22px; cursor: pointer; line-height: 1; }
.board-list { list-style: none; margin: 0; padding: 6px 12px 14px; }
.board-list li { display: flex; align-items: center; gap: 10px; padding: 9px 8px; border-radius: 10px; }
.board-list li:nth-child(odd) { background: var(--panel2); }
.board-list .rank { width: 22px; font-weight: 700; color: var(--muted); text-align: center; }
.board-list .dot { width: 12px; height: 12px; border-radius: 50%; box-shadow: 0 0 8px currentColor; }
.board-list .bn { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-list .empty { justify-content: center; color: var(--muted2); }

/* ---------- toast ---------- */
.toast {
  position: fixed; top: 74px; left: 50%; transform: translate(-50%, -20px); z-index: 90;
  background: var(--panel); border: 1px solid var(--line); color: var(--ink);
  padding: 12px 20px; border-radius: 14px; font-weight: 600; font-size: 14px;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: .3s; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { border-color: var(--cyan); }
.toast.warn { border-color: #ffb23b; }
.toast.err { border-color: #ff6b8a; }

/* ---------- car markers ---------- */
.car-marker { position: relative; width: 44px; height: 70px; }
.car-rot { transform-origin: 50% 50%; transition: transform .25s linear; }
.car-marker .leaflet-interactive, .car-marker svg { display: block; }
.car-badge {
  position: absolute; top: -14px; left: 50%; transform: translateX(-50%);
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  font: 800 13px 'Space Grotesk'; border: 2px solid rgba(255,255,255,.85);
  box-shadow: 0 3px 10px rgba(0,0,0,.5); z-index: 2;
}
.car-name {
  position: absolute; top: 74px; left: 50%; transform: translateX(-50%);
  font: 600 11px 'Space Grotesk'; color: #fff; white-space: nowrap;
  background: rgba(11,13,23,.78); padding: 2px 8px; border-radius: 8px; backdrop-filter: blur(4px);
}
.car-marker.me .car-badge { animation: pulse 1.8s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(123,92,255,.55) } 50% { box-shadow: 0 0 0 8px rgba(123,92,255,0) } }

.flag-marker { font-size: 32px; position: relative; filter: drop-shadow(0 4px 6px rgba(0,0,0,.6)); animation: bob 1.6s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0) } 50% { transform: translateY(-5px) } }
.flag-ping {
  position: absolute; left: 6px; bottom: 2px; width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--pink); animation: ping 1.6s ease-out infinite;
}
@keyframes ping { 0% { transform: scale(.4); opacity: .9 } 100% { transform: scale(3.2); opacity: 0 } }

.capture-burst {
  position: absolute; z-index: 60; font-size: 34px; transform: translate(-50%, -50%);
  animation: burst 1.2s ease-out forwards; pointer-events: none;
}
@keyframes burst { 0% { transform: translate(-50%,-50%) scale(.3); opacity: 0 } 25% { opacity: 1; transform: translate(-50%,-50%) scale(1.4) } 100% { transform: translate(-50%,-120%) scale(1); opacity: 0 } }

/* leaflet dark tweaks */
.leaflet-bar a { background: var(--panel); color: var(--ink); border-color: var(--line); }
.leaflet-bar a:hover { background: var(--panel2); }

/* ---------- responsive ---------- */
@media (max-width: 680px) {
  .auth-card { grid-template-columns: 1fr; }
  .auth-hero { padding: 28px 24px; }
  .auth-hero h1 { font-size: 36px; }
  .hero-preview { min-height: 90px; margin-top: 18px; }
  .row2 { grid-template-columns: 1fr; }
  .hud-brand span { display: none; }
  .hud-stats { gap: 6px; }
  .stat { min-width: 70px; padding: 6px 8px; }
  .stat b { font-size: 15px; }
  .drawer { width: calc(100vw - 28px); }
}
