:root {
  --bg: #0a0f0a;
  --panel-bg: #0f1a10;
  --grid: #1a2e1c;
  --accent: #3ef27a;
  --accent-dim: #1f7a44;
  --ground: #e0b84c;
  --text: #d6ffe0;
  --text-dim: #6b9a78;
  --danger: #ff5d5d;
  --font: 'IBM Plex Mono', monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
}

.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: rgba(10, 15, 10, 0.9);
  border-bottom: 1px solid var(--grid);
  backdrop-filter: blur(4px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.brand h1 {
  font-size: 15px;
  letter-spacing: 3px;
  margin: 0;
  font-weight: 600;
  color: var(--accent);
}

#help-button {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid var(--accent-dim);
  background: transparent;
  color: var(--accent);
  font-family: var(--font);
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
#help-button:hover {
  background: var(--accent-dim);
  color: var(--bg);
}

.help-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
}

.help-content {
  position: relative;
  width: min(480px, calc(100vw - 32px));
  max-height: min(600px, calc(100vh - 64px));
  overflow-y: auto;
  background: var(--panel-bg);
  border: 1px solid var(--grid);
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.6);
}

.help-content h2 {
  margin: 0 0 16px 0;
  color: var(--accent);
  font-size: 16px;
  letter-spacing: 1px;
}

.help-content h3 {
  margin: 20px 0 8px 0;
  color: var(--text-dim);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.help-content h3:first-of-type {
  margin-top: 0;
}

.help-content p,
.help-content li {
  font-size: 13px;
  line-height: 1.5;
}

.help-content ul {
  margin: 0;
  padding-left: 18px;
}

.help-content li + li {
  margin-top: 8px;
}

.help-content a {
  color: var(--accent);
}

.help-legend {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.help-legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.legend-icon {
  color: var(--accent);
  flex-shrink: 0;
}

.legend-icon.on-ground {
  color: var(--ground);
}

#help-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
}
#help-close:hover { color: var(--text); }

.zone-picker {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.zone-picker select {
  background: var(--panel-bg);
  color: var(--text);
  border: 1px solid var(--grid);
  border-radius: 4px;
  font-family: var(--font);
  font-size: 12px;
  padding: 4px 6px;
  cursor: pointer;
}

.zone-picker select:focus {
  outline: 1px solid var(--accent-dim);
}

.stats {
  display: flex;
  gap: 28px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.stat-label {
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.stat-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

#map {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg);
}

/* Leaflet overrides for dark radar look */
.leaflet-container {
  background: var(--bg) !important;
  font-family: var(--font);
}

.leaflet-control-attribution {
  background: rgba(10, 15, 10, 0.8) !important;
  color: var(--text-dim) !important;
}
.leaflet-control-attribution a { color: var(--accent-dim) !important; }

.leaflet-control-zoom a {
  background: var(--panel-bg) !important;
  color: var(--accent) !important;
  border-color: var(--grid) !important;
}

.plane-icon {
  color: var(--accent);
  filter: drop-shadow(0 0 3px var(--accent));
  transition: transform 0.3s ease-out;
}

.plane-icon.stale {
  color: var(--text-dim);
  filter: none;
}

.plane-icon.on-ground {
  color: var(--ground);
  filter: none;
  opacity: 0.85;
}

.panel {
  position: fixed;
  top: 70px;
  right: 20px;
  width: 260px;
  background: var(--panel-bg);
  border: 1px solid var(--grid);
  border-radius: 6px;
  padding: 16px;
  z-index: 1001;
  box-shadow: 0 0 20px rgba(0,0,0,0.5);
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.panel.hidden {
  transform: translateX(20px);
  opacity: 0;
  pointer-events: none;
}

#panel-close {
  position: absolute;
  top: 8px;
  right: 10px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
}
#panel-close:hover { color: var(--text); }

.panel-callsign {
  font-size: 16px;
  font-weight: 600;
  color: var(--accent);
  margin: 0 0 10px 0;
  letter-spacing: 1px;
}

.panel-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px dashed var(--grid);
  font-size: 12px;
}

.panel-row:last-child { border-bottom: none; }

.panel-row .k { color: var(--text-dim); }
.panel-row .v { color: var(--text); font-weight: 500; }

.error-banner {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 93, 93, 0.15);
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 10px 18px;
  border-radius: 6px;
  font-size: 12px;
  z-index: 1002;
}

.hidden { display: none !important; }

@media (max-width: 600px) {
  .topbar { flex-direction: column; align-items: flex-start; gap: 8px; }
  .stats { gap: 16px; }
  .panel { left: 12px; right: 12px; width: auto; top: 100px; }
  .zone-picker { width: 100%; }
  .zone-picker select { width: 100%; }
}
