:root {
  --crt-green: #33ff66;
  --crt-dark: #0a1408;
  --panel-bg: #101820;
  --panel-border: #33ff66;
  --amber: #ffcc33;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--crt-dark);
  font-family: 'Press Start 2P', monospace;
}

/* ---------- Top bar ---------- */
#topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 44px;
  z-index: 1000;
  background: var(--panel-bg);
  border-bottom: 3px solid var(--panel-border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 12px;
  color: var(--crt-green);
  font-size: 12px;
  image-rendering: pixelated;
}

#topbar .logo { color: var(--amber); text-shadow: 2px 2px 0 #663300; }
#topbar .subtitle { font-size: 9px; opacity: 0.8; }
#status {
  margin-left: auto;
  font-size: 8px;
  color: var(--crt-green);
  text-align: right;
  line-height: 1.5;
}

/* ---------- Map ---------- */
#map {
  position: absolute;
  top: 44px;
  bottom: 0;
  left: 0;
  right: 0;
  background: #0a2438;
}

/* Retro-ify the base map tiles */
.leaflet-tile-pane {
  filter: saturate(1.6) contrast(1.15) brightness(0.92);
  image-rendering: pixelated;
}

.leaflet-container { font-family: 'Press Start 2P', monospace; }

/* ---------- CRT scanline overlay ---------- */
#scanlines {
  position: fixed;
  inset: 44px 0 0 0;
  z-index: 900;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.09) 0px,
    rgba(0, 0, 0, 0.09) 1px,
    transparent 1px,
    transparent 3px
  );
  mix-blend-mode: multiply;
}

/* ---------- Aircraft markers ---------- */
.plane-icon { background: none; border: none; }

.plane-icon img {
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  filter: drop-shadow(2px 2px 0 rgba(0, 0, 0, 0.45));
  transition: transform 0.8s linear;
}

.plane-icon.selected img {
  filter: drop-shadow(0 0 6px var(--crt-green)) drop-shadow(2px 2px 0 rgba(0,0,0,0.45));
}

.plane-label {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 7px;
  color: #ffffff;
  background: rgba(16, 24, 32, 0.85);
  border: 1px solid var(--crt-green);
  padding: 2px 3px;
  white-space: nowrap;
  pointer-events: none;
}

/* ---------- Airport markers ---------- */
.airport-icon {
  background: var(--amber);
  border: 2px solid #000;
  box-shadow: 2px 2px 0 rgba(0,0,0,0.5);
}
.low-zoom .airport-label { display: none; }

.airport-label {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 8px;
  color: var(--amber);
  text-shadow: 1px 1px 0 #000;
  pointer-events: none;
}

/* ---------- Detail panel ---------- */
#detail-panel {
  position: fixed;
  top: 60px;
  right: 12px;
  width: 300px;
  z-index: 1100;
  background: var(--panel-bg);
  border: 3px solid var(--panel-border);
  box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.6);
  color: var(--crt-green);
  padding: 10px;
}

#detail-panel.hidden { display: none; }

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid var(--panel-border);
  padding-bottom: 8px;
  margin-bottom: 8px;
}

#detail-callsign { font-size: 13px; color: var(--amber); }

#detail-close {
  font-family: inherit;
  font-size: 10px;
  color: #ff5555;
  background: none;
  border: 2px solid #ff5555;
  cursor: pointer;
  padding: 2px 6px;
}
#detail-close:hover { background: #ff5555; color: #000; }

.panel-sprite {
  text-align: center;
  padding: 6px 0 10px;
}
.panel-sprite img {
  width: 96px;
  height: 96px;
  image-rendering: pixelated;
}

.panel-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 9px;
}
.panel-table td {
  padding: 5px 2px;
  border-bottom: 1px dashed rgba(51, 255, 102, 0.3);
}
.panel-table td:first-child { color: #66ccff; width: 40%; }
.panel-table td:last-child { color: #ffffff; text-align: right; }

/* ---------- Legend / sampling info ---------- */
#legend {
  position: fixed;
  bottom: 12px;
  left: 12px;
  z-index: 1100;
  background: var(--panel-bg);
  border: 3px solid var(--panel-border);
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.6);
  color: var(--crt-green);
  font-size: 8px;
  padding: 8px 10px;
  line-height: 1.6;
}
.legend-title { color: #66ccff; margin-bottom: 2px; }

/* Leaflet attribution: keep readable but small */
.leaflet-control-attribution {
  font-family: monospace;
  font-size: 9px;
  background: rgba(16, 24, 32, 0.8) !important;
  color: #aaa !important;
}
.leaflet-control-attribution a { color: var(--crt-green) !important; }

.leaflet-control-zoom a {
  background: var(--panel-bg) !important;
  color: var(--crt-green) !important;
  border: 2px solid var(--panel-border) !important;
  font-family: 'Press Start 2P', monospace !important;
  font-size: 12px !important;
}

/* ---------- Animated rotors / propellers ---------- */
.sprite-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.8s linear;
}
.sprite-wrap img { width: 100%; height: 100%; }

.spin {
  position: absolute;
  left: 50%;
  image-rendering: pixelated;
  pointer-events: none;
  background: center / contain no-repeat;
}

.rotor {
  top: 34%; /* main rotor hub sits over the cabin, not the sprite center */
  width: 105%;
  height: 105%;
  background-image: url('../sprites/rotor.png');
  animation: spin-90 0.24s steps(2) infinite;
}

.propeller {
  width: 46%;
  height: 46%;
  background-image: url('../sprites/propeller.png');
  animation: spin-90 0.16s steps(2) infinite;
}
.propeller.prop       { top: 7%; }
.propeller.floatplane { top: 6%; }

@keyframes spin-90 {
  from { transform: translate(-50%, -50%) rotate(0deg); }
  to   { transform: translate(-50%, -50%) rotate(90deg); }
}

.panel-sprite .sprite-wrap {
  width: 96px;
  height: 96px;
  display: inline-block;
}
