/* =========================================================
   PIXEL PLANE RADAR — Retro / CRT / Pixelart Stylesheet
   ========================================================= */

:root {
  --bg:        #060a14;
  --bg-panel:  #0c1428;
  --bg-panel2: #0a1120;
  --grid-line: #12305c;
  --green:     #37ff8b;   /* Radar-Grün */
  --green-dim: #1c8f4d;
  --amber:     #ffcc33;
  --cyan:      #45e6ff;
  --magenta:   #ff5bd0;
  --red:       #ff5555;
  --text:      #cfe9ff;
  --text-dim:  #6b86ad;
  --border:    #1d3a6b;
}

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

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: 'VT323', 'Courier New', monospace;
  font-size: 20px;
  min-height: 100vh;
  overflow-x: hidden;
}

body {
  background:
    radial-gradient(circle at 50% 0%, #0f1e3a 0%, #060a14 60%),
    var(--bg);
  padding: 18px;
}

h1, .panel-label, .stat-key, .callsign-badge, .hdr-clock,
.airline-name, .ftr-status, #refresh-btn, .radar-range, .radar-legend {
  font-family: 'Press Start 2P', 'Courier New', monospace;
}

/* ---------- CRT-Overlays ---------- */
.scanlines {
  position: fixed; inset: 0; pointer-events: none; z-index: 9999;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0,0,0,0) 0px,
    rgba(0,0,0,0) 2px,
    rgba(0,0,0,0.18) 3px,
    rgba(0,0,0,0.18) 4px
  );
  mix-blend-mode: multiply;
  animation: flicker 6s infinite;
}
.vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 9998;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.55) 100%);
}
@keyframes flicker {
  0%,100% { opacity: 1; }
  50%     { opacity: 0.94; }
  52%     { opacity: 0.99; }
}

.crt {
  max-width: 1180px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

/* ---------- Header ---------- */
.hdr {
  display: flex; justify-content: space-between; align-items: flex-end;
  flex-wrap: wrap; gap: 12px;
  border-bottom: 3px solid var(--border);
  padding-bottom: 14px; margin-bottom: 18px;
}
.hdr-title { display: flex; align-items: center; gap: 14px; }
.plane-emoji {
  font-size: 34px;
  filter: drop-shadow(0 0 6px var(--green));
  animation: bob 2.5s ease-in-out infinite;
}
@keyframes bob { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-5px)} }
.hdr h1 {
  font-size: 22px; letter-spacing: 1px;
  color: var(--green);
  text-shadow: 0 0 8px rgba(55,255,139,0.7), 3px 3px 0 #04381e;
  line-height: 1.4;
}
.hdr-meta { text-align: right; }
.hdr-loc { font-size: 22px; color: var(--cyan); }
.hdr-loc .plz { color: var(--text-dim); }
.hdr-clock {
  font-size: 15px; color: var(--amber); margin-top: 6px;
  text-shadow: 0 0 6px rgba(255,204,51,0.6);
}

/* ---------- Panels ---------- */
.panel {
  background: linear-gradient(180deg, var(--bg-panel) 0%, var(--bg-panel2) 100%);
  border: 3px solid var(--border);
  border-radius: 4px;
  padding: 16px;
  position: relative;
  box-shadow: inset 0 0 30px rgba(0,40,90,0.35), 0 0 0 1px #000;
}
.panel-label {
  font-size: 10px; color: var(--green-dim);
  letter-spacing: 1px; margin-bottom: 14px;
  border-bottom: 2px dashed #163258; padding-bottom: 8px;
}

/* ---------- Flight-Tracker ---------- */
.tracker-panel { margin-bottom: 18px; padding: 12px 16px; }
.tracker-row {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.tracker-label {
  font-family: 'Press Start 2P', monospace;
  font-size: 11px; color: var(--green);
  text-shadow: 0 0 6px rgba(55,255,139,0.5);
  flex: none;
}
.tracker-form { display: flex; gap: 8px; align-items: center; }
#tracker-input {
  font-family: 'VT323', monospace;
  font-size: 22px;
  background: #030a14;
  border: 2px solid var(--border);
  border-radius: 3px;
  color: var(--amber);
  padding: 6px 12px;
  width: 300px; max-width: 60vw;
  text-transform: uppercase;
  letter-spacing: 1px;
}
#tracker-input::placeholder { color: var(--text-dim); text-transform: none; letter-spacing: 0; }
#tracker-input:focus { outline: none; border-color: var(--amber); box-shadow: 0 0 10px rgba(255,204,51,0.35); }
#tracker-go, #tracker-clear {
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  border-radius: 3px; padding: 8px 10px; cursor: pointer;
  transition: all 0.15s;
}
#tracker-go { background: var(--green); color: #042713; border: 2px solid var(--green); }
#tracker-go:hover { box-shadow: 0 0 12px rgba(55,255,139,0.6); }
#tracker-clear { background: var(--border); color: var(--text); border: 2px solid var(--red); }
#tracker-clear:hover { background: var(--red); color: #fff; }
.tracker-status {
  font-size: 18px; color: var(--text-dim);
  flex: 1; min-width: 200px; text-align: right;
}
.tracker-status.locked { color: var(--amber); text-shadow: 0 0 5px rgba(255,204,51,0.4); }
.tracker-status.lost { color: var(--red); }

/* Feature-Label im Tracking-Modus */
#feature-label.tracking { color: var(--amber); text-shadow: 0 0 6px rgba(255,204,51,0.5); }

/* Standort-Auswahl */
#loc-sel {
  font-family: 'VT323', monospace;
  font-size: 20px;
  background: #030a14;
  border: 2px solid var(--border);
  border-radius: 3px;
  color: var(--cyan);
  padding: 6px 10px;
  max-width: 60vw;
  cursor: pointer;
}
#loc-sel:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 10px rgba(69,230,255,0.3); }
#loc-pin {
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  background: var(--border); color: var(--text);
  border: 2px solid var(--cyan); border-radius: 3px;
  padding: 8px 10px; cursor: pointer; transition: all 0.15s;
}
#loc-pin:hover { background: var(--cyan); color: #04140c; }
#loc-pin.active { background: var(--cyan); color: #04140c; box-shadow: 0 0 12px var(--cyan); }
#loc-current { color: var(--cyan); }

/* ---------- Main Grid ---------- */
.grid {
  display: grid;
  grid-template-columns: 480px 1fr;
  gap: 18px;
  margin-bottom: 18px;
}
.right-col { display: flex; flex-direction: column; gap: 18px; }

/* ---------- Live-Karte ---------- */
.map-wrap {
  position: relative;
  width: 100%; height: 500px;
  border: 2px solid var(--green-dim);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: inset 0 0 40px rgba(55,255,139,0.12), 0 0 24px rgba(55,255,139,0.15);
}
#map {
  width: 100%; height: 100%;
  background: #04140c;
}
/* Retro-Look für die Kacheln: leicht pixelig + grünstichig */
.leaflet-tile {
  image-rendering: pixelated;
  filter: brightness(0.85) saturate(0.5) sepia(0.25) hue-rotate(90deg) contrast(1.1);
}
.leaflet-container { font-family: 'VT323', monospace; }
.leaflet-control-attribution {
  background: rgba(4,20,12,0.8) !important;
  color: var(--text-dim) !important;
  font-size: 10px !important;
}
.leaflet-control-attribution a { color: var(--green-dim) !important; }
.leaflet-control-zoom a {
  background: var(--bg-panel) !important;
  color: var(--green) !important;
  border-color: var(--border) !important;
}

/* Karten-Marker */
.map-plane {
  filter: drop-shadow(0 0 4px rgba(55,255,139,0.8));
  transition: transform 0.8s linear;
}
.map-plane svg { width: 100%; height: 100%; image-rendering: pixelated; display: block; }
.map-plane.nearest { filter: drop-shadow(0 0 7px rgba(255,204,51,0.9)); }
.map-home {
  width: 12px; height: 12px;
  background: var(--cyan);
  box-shadow: 0 0 10px var(--cyan);
  animation: homePulse 2s ease-in-out infinite;
}
@keyframes homePulse { 0%,100%{transform:scale(1)} 50%{transform:scale(1.35)} }
.map-label {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: var(--cyan);
  text-shadow: 0 0 4px #000, 0 0 8px rgba(69,230,255,0.6);
  white-space: nowrap;
}
.map-label.apt { color: var(--magenta); text-shadow: 0 0 4px #000, 0 0 8px rgba(255,91,208,0.6); }

/* Dunkle Popups */
.leaflet-popup-content-wrapper {
  background: var(--bg-panel) !important;
  color: var(--text) !important;
  border: 2px solid var(--border) !important;
  border-radius: 4px !important;
  font-family: 'VT323', monospace !important;
  font-size: 17px !important;
}
.leaflet-popup-tip { background: var(--border) !important; }
.popup-cs { color: var(--amber); font-size: 19px; }
.popup-route { color: var(--green); }
.popup-track {
  margin-top: 8px;
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  background: var(--amber); color: #2a1e00;
  border: none; border-radius: 3px;
  padding: 7px 10px; cursor: pointer;
}
.popup-track:hover { box-shadow: 0 0 10px rgba(255,204,51,0.6); }
.radar-range {
  position: absolute; top: 8px; right: 10px;
  font-size: 9px; color: var(--green); opacity: 0.8;
}
.radar-legend {
  display: flex; justify-content: center; gap: 16px;
  font-size: 8px; color: var(--text-dim);
  margin-top: 14px;
}
.radar-legend span { display: flex; align-items: center; gap: 6px; }
.dot { width: 9px; height: 9px; display: inline-block; image-rendering: pixelated; }
.dot-home  { background: var(--cyan);   box-shadow: 0 0 6px var(--cyan); }
.dot-near  { background: var(--amber);  box-shadow: 0 0 6px var(--amber); }
.dot-plane { background: var(--green);  box-shadow: 0 0 6px var(--green); }
.dot-apt   { background: var(--magenta); box-shadow: 0 0 6px var(--magenta); }

/* ---------- Feature-Panel ---------- */
.feature-hero {
  display: flex; gap: 16px; align-items: center; margin-bottom: 18px;
}
.plane-sprite-box {
  width: 96px; height: 96px; flex: none;
  background: #04140c;
  border: 2px solid var(--green-dim);
  border-radius: 4px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px;
  box-shadow: inset 0 0 18px rgba(55,255,139,0.2);
}
.size-tag {
  font-family: 'Press Start 2P', monospace;
  font-size: 6px;
  color: var(--green-dim);
  letter-spacing: 1px;
  text-align: center;
}
.plane-sprite {
  width: 68px; height: 68px; image-rendering: pixelated;
  transition: transform 0.6s ease;
  filter: drop-shadow(0 0 4px rgba(55,255,139,0.6));
}

/* ---------- Flugzeug-Foto (planespotters.net) ---------- */
.photo-strip {
  position: relative;
  margin-bottom: 14px;
  border: 2px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  background: #000;
}
.photo-strip img {
  width: 100%;
  height: 190px;
  object-fit: cover;
  display: block;
  filter: saturate(0.92) contrast(1.05);
}
/* dezente Scanline-Textur über dem Foto, damit es zum CRT-Look passt */
.photo-strip::after {
  content: '';
  position: absolute; inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0,0,0,0) 0px, rgba(0,0,0,0) 3px,
    rgba(0,0,0,0.12) 4px
  );
  pointer-events: none;
}
.photo-credit {
  position: absolute; right: 8px; bottom: 8px; z-index: 1;
  background: rgba(4,10,20,0.85);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 3px 9px;
  font-size: 14px;
  color: var(--text-dim);
  text-decoration: none;
}
.photo-credit:hover { color: var(--cyan); border-color: var(--cyan); }
.feature-headline { min-width: 0; flex: 1; }
.airline-name {
  font-size: 15px; color: var(--amber); line-height: 1.5;
  text-shadow: 0 0 6px rgba(255,204,51,0.5);
  word-break: break-word;
}
.aircraft-name { font-size: 24px; color: var(--text); margin: 6px 0; line-height: 1.1; }
.callsign-badge {
  display: inline-block; font-size: 13px;
  background: var(--green); color: #042713;
  padding: 6px 10px; border-radius: 3px;
  letter-spacing: 1px;
  box-shadow: 0 0 10px rgba(55,255,139,0.5);
}

.stats-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
}
.stat {
  background: #071026;
  border: 2px solid #16294a;
  border-radius: 3px;
  padding: 10px 8px;
}
.stat-key { font-size: 8px; color: var(--text-dim); letter-spacing: 1px; margin-bottom: 6px; }
.stat-val { font-size: 26px; color: var(--green); line-height: 1; text-shadow: 0 0 6px rgba(55,255,139,0.4); }
.stat-val.small { font-size: 20px; color: var(--cyan); }
.stat-val .unit { font-size: 13px; color: var(--text-dim); }

/* ---------- Wetter ---------- */
.weather-row { display: flex; align-items: center; gap: 16px; }
.weather-icon { font-size: 52px; filter: drop-shadow(0 0 8px rgba(69,230,255,0.5)); }
.weather-main { flex: 1; }
.weather-temp { font-size: 42px; color: var(--cyan); line-height: 1; text-shadow: 0 0 10px rgba(69,230,255,0.4); }
.weather-desc { font-size: 20px; color: var(--text-dim); margin-top: 4px; }
.weather-side { font-size: 19px; color: var(--text); text-align: right; }
.weather-side .w-line { margin: 4px 0; white-space: nowrap; }

/* ---------- Traffic-Liste ---------- */
.traffic-list {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px;
}
.traffic-item {
  display: flex; align-items: center; gap: 10px;
  background: #071026; border: 2px solid #16294a; border-radius: 3px;
  padding: 8px 10px;
  transition: border-color 0.2s, transform 0.1s;
}
.traffic-item:hover { border-color: var(--green-dim); transform: translateX(2px); }
.ti-icon { font-size: 22px; flex: none; }
.ti-body { min-width: 0; flex: 1; }
.ti-line1 { font-size: 18px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ti-cs { color: var(--amber); }
.ti-line2 { font-size: 15px; color: var(--text-dim); }
.ti-dist { font-size: 18px; color: var(--green); flex: none; text-align: right; }
.traffic-empty { color: var(--text-dim); font-size: 18px; padding: 10px; grid-column: 1 / -1; }

/* ---------- Footer ---------- */
.ftr {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 10px;
  border-top: 3px solid var(--border);
  margin-top: 18px; padding-top: 14px;
  font-size: 16px; color: var(--text-dim);
}
.ftr-status { font-size: 10px; color: var(--green); }
.ftr-status.err { color: var(--red); }
.ftr-status.live { color: var(--green); }
#countdown { color: var(--amber); }
#refresh-btn {
  font-size: 9px; background: var(--border); color: var(--text);
  border: 2px solid var(--cyan); border-radius: 3px;
  padding: 5px 8px; cursor: pointer; transition: all 0.15s;
}
#refresh-btn:hover { background: var(--cyan); color: #04140c; box-shadow: 0 0 10px var(--cyan); }
#refresh-btn:active { transform: translateY(1px); }
.ftr-src { font-size: 13px; }

/* =========================================================
   FALLBLATT-ANZEIGE (Split-Flap, Solari-Board-Style)
   ========================================================= */
.flap-row {
  display: inline-flex; gap: 3px;
  perspective: 400px;
}
.flap-cell {
  position: relative;
  min-width: 0.72em;
  padding: 3px 2px;
  text-align: center;
  font-family: 'VT323', monospace;
  font-size: 30px;
  line-height: 1;
  color: var(--green);
  background: linear-gradient(180deg, #101c14 0%, #050d08 48%, #020604 52%, #0a140d 100%);
  border: 1px solid #1a3a28;
  border-radius: 3px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), 0 2px 3px rgba(0,0,0,0.6);
  text-shadow: 0 0 6px rgba(55,255,139,0.5);
  transform-style: preserve-3d;
  will-change: transform;
}
/* Mittellinie wie beim echten Solari-Board */
.flap-cell::after {
  content: '';
  position: absolute; left: 0; right: 0; top: 50%;
  height: 1px;
  background: rgba(0,0,0,0.85);
  box-shadow: 0 1px 0 rgba(255,255,255,0.04);
  pointer-events: none;
}
.flap-cell.flipping {
  animation: flapFlip 0.28s ease-in-out;
}
@keyframes flapFlip {
  0%   { transform: rotateX(0deg); filter: brightness(1); }
  49%  { transform: rotateX(-88deg); filter: brightness(1.6); }
  51%  { transform: rotateX(88deg); filter: brightness(1.6); }
  100% { transform: rotateX(0deg); filter: brightness(1); }
}

/* Farbvarianten */
.flap-cyan .flap-cell { color: var(--cyan); text-shadow: 0 0 6px rgba(69,230,255,0.5); border-color: #164a58; }
.callsign-flap .flap-cell {
  color: var(--amber);
  text-shadow: 0 0 6px rgba(255,204,51,0.55);
  border-color: #5a4410;
  font-size: 24px;
  background: linear-gradient(180deg, #1c1608 0%, #0d0a04 48%, #060402 52%, #141006 100%);
}
.stat-flap .flap-cell { font-size: 27px; }
.route-code .flap-cell {
  font-size: 34px;
  color: var(--amber);
  text-shadow: 0 0 8px rgba(255,204,51,0.55);
  border-color: #5a4410;
  background: linear-gradient(180deg, #1c1608 0%, #0d0a04 48%, #060402 52%, #141006 100%);
  min-width: 0.78em;
}

/* ---------- Route-Board ---------- */
.route-board {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  background: #071026;
  border: 2px solid #16294a;
  border-radius: 3px;
  padding: 12px 14px;
  margin-bottom: 14px;
}
.route-airport { text-align: center; min-width: 0; }
.route-tag {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px; color: var(--text-dim);
  letter-spacing: 1px; margin-bottom: 7px;
}
.route-city {
  font-size: 17px; color: var(--text-dim);
  margin-top: 6px;
  max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* Fortschritt: Origin -> Destination mit Flugzeug an aktueller Position */
.route-progress {
  flex: 1; min-width: 120px;
  display: flex; flex-direction: column; align-items: stretch; gap: 8px;
  padding: 0 6px;
}
.route-track {
  position: relative;
  height: 10px;
  background: #030a14;
  border: 1px solid var(--grid-line);
  border-radius: 2px;
}
.route-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 0%;
  background: repeating-linear-gradient(90deg,
    var(--green) 0px, var(--green) 6px,
    transparent 6px, transparent 9px);
  box-shadow: 0 0 8px rgba(55,255,139,0.4);
  transition: width 1s ease;
}
.route-plane {
  position: absolute; top: 50%;
  left: 0%;
  transform: translate(-50%, -58%);
  font-size: 20px;
  color: var(--amber);
  filter: drop-shadow(0 0 5px var(--amber));
  transition: left 1s ease;
  line-height: 1;
}
.route-eta {
  text-align: center;
  font-size: 17px;
  color: var(--amber);
  text-shadow: 0 0 5px rgba(255,204,51,0.4);
  white-space: nowrap;
}

/* Refresh-Intervall- & Radius-Auswahl */
#refresh-sel, #radius-sel {
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  background: var(--border); color: var(--text);
  border: 2px solid var(--text-dim); border-radius: 3px;
  padding: 4px 5px; cursor: pointer;
}
#refresh-sel:hover, #radius-sel:hover { border-color: var(--cyan); }

/* Sound-Button */
#sound-btn {
  font-size: 13px; background: var(--border); color: var(--text);
  border: 2px solid var(--text-dim); border-radius: 3px;
  padding: 3px 7px; cursor: pointer; transition: all 0.15s;
}
#sound-btn.on { border-color: var(--amber); box-shadow: 0 0 8px rgba(255,204,51,0.4); }

/* ---------- Flash-Animation bei neuem Feature ---------- */
.feature-panel.flash { animation: flashHit 0.6s ease; }
@keyframes flashHit {
  0% { box-shadow: inset 0 0 30px rgba(255,204,51,0.6), 0 0 30px rgba(255,204,51,0.4); }
  100% { box-shadow: inset 0 0 30px rgba(0,40,90,0.35); }
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .grid { grid-template-columns: 1fr; }
  .radar-wrap { width: 100%; max-width: 440px; aspect-ratio: 1; height: auto; }
  #radar { height: auto; aspect-ratio: 1; }
  .hdr { flex-direction: column; align-items: flex-start; }
  .hdr-meta { text-align: left; }
}
@media (max-width: 520px) {
  body { font-size: 18px; padding: 10px; }
  .hdr h1 { font-size: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
