:root {
  --bg: #07131d;
  --bg-soft: #102637cc;
  --accent: #ffb84c;
  --accent-2: #46d5ff;
  --text: #f6fbff;
  --muted: #9bb3c3;
  --map-controls-clearance: 56px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  background: radial-gradient(circle at 20% 10%, #123149 0%, var(--bg) 55%, #050c12 100%);
  color: var(--text);
  overflow: hidden;
}

#map {
  width: 100%;
  height: 100%;
  filter: saturate(1.1) contrast(1.02);
}

.panel {
  position: absolute;
  top: 16px;
  left: calc(16px + var(--map-controls-clearance));
  width: min(320px, calc(100vw - 32px - var(--map-controls-clearance)));
  padding: 14px 16px;
  border-radius: 14px;
  background: linear-gradient(145deg, #0d2437f0, var(--bg-soft));
  border: 1px solid #2f4d62;
  backdrop-filter: blur(8px);
  box-shadow: 0 14px 35px #00000055;
  z-index: 640;
}

h1 {
  margin: 0 0 8px;
  font-size: 1.25rem;
  line-height: 1.1;
}

.status {
  margin: 0 0 10px;
  color: var(--accent-2);
  font-weight: 500;
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

.stats div {
  background: #0a1826;
  border: 1px solid #2a4356;
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stats .label {
  color: var(--muted);
  font-size: 0.76rem;
}

.stats span:last-child {
  font-size: 1.2rem;
  font-weight: 700;
}

.hint {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.4;
}

.location-btn {
  margin-top: 8px;
  padding: 7px 10px;
  border-radius: 9px;
  border: 1px solid #2f4d62;
  background: linear-gradient(140deg, #113247, #0a2234);
  color: #dff9ff;
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}

.location-btn:hover {
  border-color: #4f718a;
}

.location-btn:focus-visible {
  outline: 2px solid #7cd9ff;
  outline-offset: 2px;
}

.mobile-hud {
  position: absolute;
  top: 14px;
  right: 12px;
  display: none;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  z-index: 640;
  pointer-events: none;
}

.mobile-chip {
  margin: 0;
  padding: 6px 9px;
  border-radius: 10px;
  border: 1px solid #2f4d62;
  background: #0b2031e8;
  color: #dff6ff;
  font-size: 0.73rem;
  line-height: 1.25;
  box-shadow: 0 6px 16px #00000048;
  max-width: min(75vw, 290px);
}

.mobile-chip-status {
  color: #87e8ff;
}

.mobile-chip-location {
  color: #c6e5f3;
}

.mobile-location-btn {
  pointer-events: auto;
  font: inherit;
  color: #dff9ff;
  cursor: pointer;
  background: linear-gradient(140deg, #113247, #0a2234);
}

.mobile-location-btn:hover {
  border-color: #4f718a;
}

.mobile-location-btn:focus-visible {
  outline: 2px solid #7cd9ff;
  outline-offset: 2px;
}

code {
  color: var(--accent);
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: #0f1c29;
  color: var(--text);
}

.leaflet-popup-pane {
  z-index: 900;
}

.leaflet-popup {
  z-index: 901 !important;
}

.leaflet-popup.ac-popup-has-scroll-toggle .leaflet-popup-close-button {
  right: 4px;
}

.ac-popup-scroll-toggle {
  position: absolute;
  top: 6px;
  right: 30px;
  width: 20px;
  height: 20px;
  border: 1px solid #3d6278;
  border-radius: 999px;
  background: #0b2536ee;
  color: #9ee0ff;
  font-size: 11px;
  line-height: 1;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 910;
}

.ac-popup-scroll-toggle:hover {
  border-color: #6da5c3;
  color: #d5f2ff;
}

.ac-popup-scroll-toggle:focus-visible {
  outline: 2px solid #6bd5ff;
  outline-offset: 1px;
}

.ac-popup-scroll-toggle.is-active {
  border-color: #6fc6ea;
  background: #154560f2;
  color: #ebfbff;
}

.leaflet-popup.ac-popup-scroll-forced .ac-popup {
  overflow-y: scroll;
  max-height: min(46vh, 320px);
}

.ac-badge-heli {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid #3f6b79;
  background: #173747;
  color: #b7ecff;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  vertical-align: 2px;
}

.ac-badge-police {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid #4d6387;
  background: #1a2c47;
  color: #d8e9ff;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  vertical-align: 2px;
}

.ac-badge-ambu {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid #7a4b4b;
  background: #4a2222;
  color: #ffdada;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  vertical-align: 2px;
}

.ac-badge-military {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid #6b7651;
  background: #2f3d25;
  color: #e6f4c8;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  vertical-align: 2px;
}

.ac-badge-cargo {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid #6f5b2a;
  background: #413515;
  color: #ffe0a3;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  vertical-align: 2px;
}

.ac-badge-government {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid #7c6b35;
  background: #433712;
  color: #ffe7a3;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  vertical-align: 2px;
}

.ac-badge-landing {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid #4f8a5d;
  background: #1f4528;
  color: #d9ffe3;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  vertical-align: 2px;
}

.ac-popup {
  min-width: min(230px, calc(100vw - 96px));
  max-width: min(360px, calc(100vw - 96px));
  max-height: calc(100vh - 140px);
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding-right: 10px;
}

.ac-popup::-webkit-scrollbar {
  width: 8px;
}

.ac-popup::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: #3f6178;
}

.ac-popup::-webkit-scrollbar-track {
  background: #0a1824;
  border-radius: 999px;
}

.ac-popup-title {
  margin-bottom: 4px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding-right: 14px;
}

.ac-popup-title-main {
  min-width: 0;
}

.ac-popup-name {
  font-weight: 700;
}

.ac-country-flag {
  flex: 0 0 auto;
  font-size: 1.05rem;
  line-height: 1;
  transform: translateY(1px);
  filter: drop-shadow(0 1px 1px #00000088);
  user-select: none;
}

.ac-popup-section {
  margin-top: 7px;
  padding-top: 6px;
  border-top: 1px solid #294454;
}

.ac-popup-header {
  margin-bottom: 4px;
  color: #9ec2d3;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ac-popup-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-top: 2px;
}

.ac-popup-key {
  color: #8aa8b9;
  font-size: 0.77rem;
}

.ac-popup-value {
  color: #f2fbff;
  font-size: 0.77rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.ac-vr {
  font-weight: 700;
}

.ac-vr-up {
  color: #7dff9f;
}

.ac-vr-down {
  color: #ff8a8a;
}

.ac-vr-level {
  color: #c8d4de;
}

.surveillance-marker {
  pointer-events: auto;
}

.surveillance-icon-wrap {
  --surv-icon-size: 30px;
  --surv-symbol-size: 16px;
  width: var(--surv-icon-size);
  height: var(--surv-icon-size);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid #6e2f4f;
  background: radial-gradient(circle at 35% 30%, #ffe6ef, #ff8ab7 72%);
  box-shadow: 0 2px 8px #00000073;
}

.surveillance-icon-wrap img {
  width: var(--surv-symbol-size);
  height: var(--surv-symbol-size);
  display: block;
  filter: drop-shadow(0 1px 1px #00000077);
}

.surveillance-icon-wrap-ambu {
  border-color: #8f2f36;
  background: radial-gradient(circle at 35% 30%, #ffe7ea, #ff7f8f 72%);
}

.surveillance-cross {
  display: inline-block;
  font-size: varsurveillance-marker-compact(--surv-symbol-size);
  line-height: 1;
  font-weight: 800;
  color: #fff8f8;
  text-shadow: 0 1px 2px #450d1499;
  transform: translateY(-0.5px);
}

.surveillance-marker-compact .surveillance-icon-dot {
  --surv-dot-size: 8px;
  width: var(--surv-dot-size);
  height: var(--surv-dot-size);
  display: inline-block;
  border-radius: 999px;
  box-shadow:
    0 0 0 1.5px #ffffffcc,
    0 0 8px #00000073;
}

.surveillance-icon-dot-police {
  background: radial-gradient(circle at 35% 30%, #daf2ff, #5ea9ff 75%);
}

.surveillance-icon-dot-ambu {
  background: radial-gradient(circle at 35% 30%, #ffe5ea, #ff7588 75%);
}

.surveillance-popup {
  min-width: 220px;
}

.surveillance-popup-title {
  margin-bottom: 5px;
  font-weight: 700;
  color: #ffd0e5;
}

.surveillance-popup-title-ambu {
  color: #ffd6dc;
}

.surveillance-popup-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.surveillance-popup-table th {
  text-align: left;
  color: #9ab7c8;
  font-weight: 600;
  padding: 2px 8px 2px 0;
  white-space: nowrap;
}

.surveillance-popup-table td {
  color: #f0fbff;
  padding: 2px 0;
}

.plane-marker {
  background: transparent;
  border: 0;
}

.plane-hitbox {
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}

.plane-icon-wrap {
  position: relative;
  width: 32px;
  height: 32px;
}

.plane-icon-wrap::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -2px;
  width: 20px;
  height: 8px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: #00000080;
  filter: blur(3px);
  pointer-events: none;
}

.plane-icon-wrap.is-ground {
  opacity: 0.85;
}

.aircraft-icon-layer {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 32px;
  height: 32px;
  display: block;
  pointer-events: none;
  -webkit-mask: var(--aircraft-icon-url) center / contain no-repeat;
  mask: var(--aircraft-icon-url) center / contain no-repeat;
  transform: rotate(var(--plane-rotation)) scale(var(--icon-scale, 1));
  transform-origin: 50% 50%;
  transition: transform 180ms linear;
}

.aircraft-icon-halo {
  --icon-scale: 1.24;
  background: #ffffff;
  opacity: 0.9;
  filter: drop-shadow(0 0 3px #f6fdff) drop-shadow(0 0 5px #00152399);
}

.aircraft-icon-outline {
  --icon-scale: 1.08;
  background: #032135;
  opacity: 0.95;
}

.aircraft-icon-shape {
  --icon-scale: 0.95;
  background: var(--aircraft-color);
  filter: drop-shadow(0 0 2px #00101daa);
}

.runway-end-label {
  pointer-events: auto;
  cursor: pointer;
}

.runway-end-label span {
  display: inline-block;
  position: relative;
  transform: translate(-50%, -50%);
  padding: 1px 5px;
  border-radius: 6px;
  border: 1px solid #5f4f2e;
  background: #f8dd9fcc;
  color: #2d1d00;
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  white-space: nowrap;
  box-shadow: 0 1px 3px #0000004f;
  transition:
    background-color 120ms ease,
    border-color 120ms ease,
    color 120ms ease,
    box-shadow 120ms ease,
    transform 120ms ease;
}

.runway-end-label span::after {
  content: "";
  position: absolute;
  left: -14px;
  right: -14px;
  top: -10px;
  bottom: -10px;
}

.runway-end-label:hover span,
.runway-end-label.runway-end-label-active span {
  background: #fff3c8f2;
  border-color: #857041;
  color: #1e1400;
  box-shadow: 0 2px 8px #00000066;
  transform: translate(-50%, -50%) scale(1.03);
}

.runway-end-label-military span {
  border-color: #7a3344;
  background: #ffd5decc;
  color: #40101d;
}

.runway-end-label-military:hover span,
.runway-end-label-military.runway-end-label-active span {
  background: #ffe3eaf2;
  border-color: #a45065;
  color: #280a13;
}

.runway-op-marker {
  pointer-events: auto;
  cursor: pointer;
}

.runway-op-pill {
  display: inline-block;
  transform: translate(-50%, -50%);
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid #1f6140;
  background: #123526e8;
  color: #d3ffe9;
  font-size: 0.56rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
  box-shadow: 0 1px 3px #00000061;
}

.runway-op-departure .runway-op-pill {
  border-color: #2b4d81;
  background: #142740e8;
  color: #d6e8ff;
}

.runway-op-military .runway-op-pill {
  border-color: #8d3653;
  background: #3f1624e8;
  color: #ffd8e2;
}

.runway-op-popup {
  min-width: 220px;
}

.runway-op-popup-title {
  margin-bottom: 5px;
  font-weight: 700;
  color: #d6ffe9;
}

.runway-op-popup-departure .runway-op-popup-title {
  color: #d6e8ff;
}

.runway-op-popup-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.runway-op-popup-table th {
  text-align: left;
  color: #9ab7c8;
  font-weight: 600;
  padding: 2px 8px 2px 0;
  white-space: nowrap;
}

.runway-op-popup-table td {
  color: #f0fbff;
  padding: 2px 0;
}

.airport-tower-marker {
  pointer-events: none;
}

.airport-tower-pin {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: translate(-50%, -50%);
}

.airport-tower-symbol {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #b08a39;
  background: radial-gradient(circle at 35% 30%, #ffe6ab, #f1c56b 75%);
  box-shadow: 0 1px 4px #0000006f;
}

.airport-tower-symbol img {
  width: 14px;
  height: 14px;
  display: block;
  filter: drop-shadow(0 1px 1px #00000070);
}

.airport-tower-code {
  margin-top: 3px;
  padding: 1px 5px;
  border-radius: 999px;
  border: 1px solid #6a5730;
  background: #2b2011d9;
  color: #ffe1a2;
  font-size: 0.56rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.04em;
  white-space: nowrap;
  box-shadow: 0 1px 3px #00000059;
}

.airport-tower-count {
  position: absolute;
  top: -5px;
  right: -7px;
  min-width: 15px;
  height: 15px;
  padding: 0 3px;
  border-radius: 999px;
  border: 1px solid #8c7639;
  background: #3e2f10;
  color: #ffe3a4;
  font-size: 0.53rem;
  font-weight: 700;
  line-height: 13px;
  text-align: center;
  box-shadow: 0 1px 2px #0000006f;
}

.airport-tower-marker-military .airport-tower-symbol {
  border-color: #9e3750;
  background: radial-gradient(circle at 35% 30%, #ffd3dd, #ff8eab 75%);
}

.airport-tower-marker-military .airport-tower-code {
  border-color: #7a2f43;
  background: #3b1320d9;
  color: #ffdce4;
}

.airport-tower-marker-military .airport-tower-count {
  border-color: #8e3a4f;
  background: #4a1828;
  color: #ffd8e2;
}

@media (max-width: 760px), (hover: none) and (pointer: coarse) {
  .ac-popup {
    min-width: min(210px, calc(100vw - 72px));
    max-width: calc(100vw - 72px);
    max-height: min(60vh, 380px);
  }

  .panel {
    display: none;
  }

  .mobile-hud {
    display: flex;
  }
}
