:root {
  --font-display: proxima-nova, "Proxima Nova", "Avenir Next", Avenir, -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: rgb(169, 203, 214);
  font-family: var(--font-display);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  color: #222;
}

.visually-hidden:where(:not(:focus-within, :active)) {
  position: absolute !important;
  clip-path: inset(50%) !important;
  overflow: hidden !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  border: 0 !important;
  white-space: nowrap !important;
}

#stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

#stage > canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
}

#base,
#fog,
#under {
  pointer-events: none;
}

#map.clickable {
  cursor: pointer;
}

#map.dragging {
  cursor: grabbing;
}

#night {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: rgb(8 13 32 / var(--night-alpha, 0));
}

#truck-lights {
  position: fixed;
  left: 0;
  top: 0;
  pointer-events: none;
}

#truck-lights i {
  position: absolute;
  width: calc(2 * var(--r, 12px));
  height: calc(2 * var(--r, 12px));
  margin: calc(-1 * var(--r, 12px));
  border-radius: 50%;
  opacity: 0;
  will-change: opacity;
  background: radial-gradient(
    circle closest-side,
    rgb(255 252 245) 0 14%,
    var(--c) 32%,
    color-mix(in srgb, var(--c) 45%, transparent) 52%,
    transparent 85%
  );
  animation: flash 0.8s step-end infinite;
}

#truck-lights .red {
  --c: rgb(255 43 31);
}

#truck-lights .white {
  --c: rgb(240 247 255);
}

@keyframes flash {
  0% { opacity: 0.68; }
  22% { opacity: 0; }
}

.panel {
  position: fixed;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 0 0 1px rgb(29 39 51 / 0.08), 0 2px 8px rgb(29 39 51 / 0.06);
  padding: 10px 12px;
}

#welcome {
  --fog: 204 214 221;
  --ink: #3b4a57;
  --glow: rgb(255 255 255 / 0.9);
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  display: grid;
  place-items: center;
  background: rgb(var(--fog));
  pointer-events: auto;
  transition: background-color 1.2s ease;
}

#welcome p {
  margin: 0;
  padding: 0 24px;
  text-align: center;
  font: 600 clamp(1.375rem, 1rem + 3vw, 2.125rem)/1.2 var(--font-display);
  letter-spacing: 0.01em;
  color: var(--ink);
  text-shadow: 0 1px 12px var(--glow);
  transition: opacity 1.4s ease 0.5s, transform 1.4s ease 0.5s;
}

#welcome-plane {
  display: block;
  width: 220px;
  height: 90px;
  margin: 6px auto 0;
}

#welcome.open {
  pointer-events: none;
  background-color: rgb(var(--fog) / 0);
}

#welcome.open p {
  opacity: 0;
  transform: translateY(-8px);
}

#hud {
  top: max(12px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  width: 260px;
  padding: 0;
  overflow: hidden;
  font: 12px/1.4 var(--font-display);
  color: #222;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 0 0 1px rgb(29 39 51 / 0.08), 0 2px 8px rgb(29 39 51 / 0.06);
  z-index: 20;
}

#panel-toggle {
  display: none;
  border: 0;
  background: #fff;
  color: #444;
  font: 500 12px/1.4 var(--font-display);
  border-radius: 8px;
  box-shadow: 0 0 0 1px rgb(29 39 51 / 0.08), 0 2px 8px rgb(29 39 51 / 0.06);
  cursor: pointer;
  z-index: 22;
}

#panel-toggle svg {
  width: 12px;
  height: 12px;
}

:where(button, a:any-link, summary, input):focus-visible {
  outline: 2px solid #1d4ed8;
  outline-offset: 2px;
}

#panel-pages {
  position: relative;
  overflow: clip;
}

.panel-page {
  box-sizing: border-box;
  top: 0;
  left: 0;
  width: 100%;
  max-height: min(460px, calc(100dvh - 140px));
  background: #fff;
  overflow-x: hidden;
  overflow-y: auto;
}

.panel-header {
  position: sticky;
  top: 0;
  z-index: 2;
  min-height: 36px;
  padding: 4px 12px;
  box-sizing: border-box;
  display: flex;
  gap: 4px;
  align-items: center;
  background: #fff;
}

#hud h1,
#hud h2 {
  margin: 0;
  font-size: 13px;
  line-height: 1.4;
  font-weight: 600;
  letter-spacing: normal;
  color: #222;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel-body {
  padding: 2px 12px 10px;
}

#airport-page {
  position: relative;
  transform: translateX(0);
}

#plane-page,
#attribution-page,
#collection-page {
  position: absolute;
  transform: translateX(100%);
  opacity: 0;
  visibility: hidden;
}

#hud:not([data-view="airport"]) #airport-page {
  position: absolute;
  transform: translateX(-28%);
  opacity: 0;
  visibility: hidden;
}

#hud[data-view="plane"] #plane-page,
#hud[data-view="attribution"] #attribution-page,
#hud[data-view="collection"] #collection-page {
  position: relative;
  transform: translateX(0);
  opacity: 1;
  visibility: visible;
}

.panel-back {
  display: grid;
  place-items: center;
  flex: 0 0 24px;
  min-width: 24px;
  min-height: 28px;
  margin-left: -6px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.panel-back:hover { opacity: 0.65; }
.panel-back svg { width: 12px; height: 12px; }

#attribution-open,
#collection-open,
#tv-open,
.panel-nav-link {
  display: flex;
  align-items: center;
  width: 100%;
  height: 26px;
  min-height: 26px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #555;
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

#attribution-open:hover,
#collection-open:hover,
#tv-open:hover,
.panel-nav-link:hover {
  color: #111827;
}

#attribution-open::after,
#collection-open::after,
#tv-open::after,
.panel-nav-link::after {
  content: "";
  width: 6px;
  height: 6px;
  margin-left: auto;
  margin-right: 3px;
  border-top: 1.5px solid #888;
  border-right: 1.5px solid #888;
  transform: rotate(45deg);
}

#flight-search-wrap {
  flex: 1;
  min-width: 0;
}

#flight-search-form {
  display: flex;
  margin: 0;
}

#search-toggle {
  display: grid;
  place-items: center;
  flex: 0 0 24px;
  min-width: 24px;
  min-height: 28px;
  margin: 0 -6px 0 auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: #6b7280;
  cursor: pointer;
}

#search-toggle:hover { color: #111827; }
#search-toggle svg { width: 14px; height: 14px; }
#search-toggle[aria-expanded="false"] .search-close,
#search-toggle[aria-expanded="true"] .search-open {
  display: none;
}

#flight-search {
  flex: 1;
  min-width: 0;
  width: 220px;
  height: 26px;
  min-height: 26px;
  margin: 0 0 0 -4px;
  padding: 2px 8px;
  box-sizing: border-box;
  border: 0;
  border-radius: 6px;
  background: #f2f4f6;
  color: #222;
  font: 600 13px/normal var(--font-display);
  text-transform: uppercase;
  appearance: none;
}

#flight-search:focus-visible {
  outline: 2px solid #1d4ed8;
  outline-offset: -1px;
}

#flight-search::placeholder {
  text-transform: none;
  font-weight: 400;
  color: #767f89;
}

#flight-search::-webkit-search-cancel-button { display: none; }
#search-miss { margin: 0 0 6px; color: #666; }
#search-miss b { color: #222; font-weight: 600; }
