:root {
  --bg: #05080b; --panel: rgba(12, 18, 24, 0.72); --panel2: rgba(22, 30, 38, 0.8); --line: rgba(255, 255, 255, 0.09);
  --text: #eef3f6; --muted: #8b99a5; --accent: #ffb238; --accent2: #8dffc4; --alert: #ff4d4d;
  --r: 16px; --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: Inter, system-ui, -apple-system, sans-serif; overflow: hidden; overscroll-behavior: none; touch-action: none; -webkit-user-select: none; user-select: none; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
#cesium { position: fixed; inset: 0; }
#cesium .cesium-widget-credits { display: none !important; }
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#credits { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(1px + var(--safe-b)); z-index: 6; font-size: 8px; line-height: 1.1; opacity: 0.7; max-width: 50vw; text-align: center; pointer-events: auto; white-space: nowrap; overflow: hidden; }
#credits img { height: 12px; vertical-align: middle; }
#credits a { color: #cfd8df; }
.cesium-credit-lightbox-overlay { z-index: 100 !important; }

.screen { display: none; }
.screen.active { display: block; }

/* ---------------- MENU ---------------- */
#menu { position: fixed; inset: 0; z-index: 20; overflow-y: auto; touch-action: pan-y; -webkit-overflow-scrolling: touch; }
.menu-bg { position: fixed; inset: 0; background:
  radial-gradient(1200px 600px at 80% -10%, rgba(255, 178, 56, 0.22), transparent 60%),
  radial-gradient(900px 600px at -10% 110%, rgba(40, 150, 255, 0.18), transparent 60%),
  linear-gradient(180deg, rgba(5, 8, 11, 0.55), rgba(5, 8, 11, 0.94)); pointer-events: none; }
.menu-inner { position: relative; max-width: 880px; margin: 0 auto; padding: calc(22px + var(--safe-t)) calc(18px + var(--safe-r)) calc(40px + var(--safe-b)) calc(18px + var(--safe-l)); }
.brand { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.logo { width: 54px; height: 54px; border-radius: 14px; background: linear-gradient(135deg, var(--accent), #ff6a3d); color: #10151a; display: grid; place-items: center; box-shadow: 0 8px 30px rgba(255, 140, 50, 0.35); }
.logo svg { width: 38px; }
h1 { font-family: Rajdhani, sans-serif; font-weight: 700; letter-spacing: 0.14em; font-size: 30px; margin: 0; line-height: 1; }
.tag { margin: 4px 0 0; color: var(--muted); }
h2 { font-family: Rajdhani, sans-serif; letter-spacing: 0.12em; text-transform: uppercase; font-size: 14px; color: var(--muted); margin: 22px 2px 10px; }
h3 { font-family: Rajdhani, sans-serif; letter-spacing: 0.1em; margin: 0 0 12px; font-size: 22px; text-transform: uppercase; }
h4 { margin: 18px 0 6px; font-size: 14px; color: var(--accent); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.row { display: flex; align-items: center; }
.between { justify-content: space-between; } .center { justify-content: center; text-align: center; } .gap { gap: 10px; } .wrap { flex-wrap: wrap; }
.mt { margin-top: 12px; }
.muted { color: var(--muted); } .small { font-size: 12px; } .mono { font-family: Rajdhani, monospace; font-weight: 600; }
.label { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.loc-name { font-size: 18px; font-weight: 600; margin-top: 2px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--panel2); border: 1px solid var(--line); border-radius: 999px; padding: 8px 12px; }
.chip svg { width: 16px; height: 16px; }
select, input[type=text], input[type=password] { background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-width: 0; width: 100%; }
select { appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 28px; }
option { background: #111a22; }
#selStart { flex: 1 1 220px; width: auto; }
.seg { display: inline-flex; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 7px 12px; border-radius: 8px; color: var(--muted); font-weight: 600; font-size: 13px; }
.seg button.on { background: var(--accent); color: #111; }

.hangar { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.ac-card { position: relative; text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; overflow: hidden; transition: transform 0.15s, border-color 0.15s; }
.ac-card.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset, 0 10px 30px rgba(255, 178, 56, 0.15); }
.ac-card .sil { height: 58px; display: grid; place-items: center; }
.ac-card .sil svg { width: 100%; height: 58px; }
.ac-card .nm { font-family: Rajdhani, sans-serif; font-size: 20px; font-weight: 700; letter-spacing: 0.08em; }
.ac-card .cls { font-size: 11px; color: var(--accent); text-transform: uppercase; letter-spacing: 0.08em; }
.ac-card .bl { font-size: 12px; color: var(--muted); margin: 6px 0; min-height: 3em; }
.ac-card .st { display: flex; gap: 10px; font-size: 11px; color: #c9d3da; flex-wrap: wrap; }
.ac-card .st b { font-family: Rajdhani, sans-serif; font-size: 14px; }

.diff { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.diff-card { text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; }
.diff-card.on { border-color: var(--accent2); box-shadow: 0 0 0 1px var(--accent2) inset; }
.diff-card .nm { font-family: Rajdhani, sans-serif; font-weight: 700; font-size: 18px; letter-spacing: 0.08em; text-transform: uppercase; }
.diff-card .tg { font-size: 11px; color: var(--accent2); letter-spacing: 0.08em; text-transform: uppercase; }
.diff-card .bl { font-size: 12px; color: var(--muted); margin-top: 6px; }
.diff-card .pips { display: flex; gap: 4px; margin-top: 8px; } .diff-card .pips i { width: 16px; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.15); } .diff-card .pips i.f { background: var(--accent2); }

.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
label { display: grid; gap: 6px; font-size: 12px; color: var(--muted); }
label.check { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text); }
label.check input { width: 20px; height: 20px; accent-color: var(--accent); }

.btn-primary { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; margin-top: 22px; padding: 18px; border: 0; border-radius: 14px; background: linear-gradient(135deg, var(--accent), #ff6a3d); color: #120d05; font-family: Rajdhani, sans-serif; font-weight: 700; font-size: 20px; letter-spacing: 0.16em; box-shadow: 0 10px 40px rgba(255, 140, 50, 0.35); }
.btn-primary svg { width: 22px; }
.btn-primary.sm { margin-top: 0; padding: 13px; font-size: 16px; }
.btn-primary:active { transform: scale(0.98); }
.btn-ghost { background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; font-weight: 600; font-size: 14px; }
.btn-ghost.danger { color: #ff8a8a; width: 100%; }

/* ---------------- FLIGHT UI ---------------- */
#flight { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
#flight.active { display: block; }
.topbar { position: absolute; top: calc(8px + var(--safe-t)); left: calc(8px + var(--safe-l)); display: flex; gap: 6px; pointer-events: auto; flex-wrap: wrap; max-width: 60vw; }
.icon-btn { height: 38px; min-width: 38px; padding: 0 10px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: rgba(8, 12, 16, 0.55); border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 10px; font-family: Rajdhani, sans-serif; font-weight: 700; font-size: 13px; letter-spacing: 0.06em; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.on { background: rgba(141, 255, 196, 0.2); border-color: var(--accent2); }
.icon-btn.rec .dot { width: 10px; height: 10px; border-radius: 50%; background: #ff4d4d; display: inline-block; }
.icon-btn.rec.live { background: rgba(255, 60, 60, 0.3); border-color: #ff4d4d; }
.icon-btn.rec.live .dot { animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0.2; } }
#lookpad { position: absolute; left: 25%; right: 25%; top: 70px; bottom: 30%; pointer-events: auto; }

.stick { position: absolute; bottom: calc(18px + var(--safe-b)); width: min(34vmin, 170px); pointer-events: auto; touch-action: none; }
.stick-left { left: calc(18px + var(--safe-l)); }
.stick-right { right: calc(18px + var(--safe-r)); }
.stick-base { position: relative; width: 100%; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02) 70%); border: 1.5px solid rgba(255, 255, 255, 0.18); }
.stick.active .stick-base { border-color: rgba(141, 255, 196, 0.6); }
.stick-knob { position: absolute; left: 50%; top: 50%; width: 38%; height: 38%; margin: -19% 0 0 -19%; border-radius: 50%; background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0.15)); border: 1px solid rgba(255, 255, 255, 0.4); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4); }
.stick-lever { display: none; position: absolute; left: -16px; top: 8%; bottom: 8%; width: 7px; border-radius: 4px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
.stick.lever .stick-lever { display: block; }
.stick-lever-fill { position: absolute; bottom: 0; left: 0; right: 0; background: linear-gradient(0deg, var(--accent2), var(--accent)); }
.stick.lever .stick-base { border-radius: 30%; }
.stick-label { text-align: center; font-family: Rajdhani, sans-serif; font-size: 10px; letter-spacing: 0.14em; color: rgba(255, 255, 255, 0.45); margin-top: 4px; }

.replay { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(14px + var(--safe-b)); z-index: 12; display: flex; align-items: center; gap: 8px; padding: 8px; background: rgba(8, 12, 16, 0.7); border: 1px solid var(--line); border-radius: 14px; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); width: min(720px, 94vw); }
.replay input[type=range] { flex: 1; accent-color: var(--accent); }

/* ---------------- OVERLAYS ---------------- */
.overlay { position: fixed; inset: 0; z-index: 40; display: none; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 20px; }
.overlay.active { display: flex; }
.overlay.modal { background: rgba(3, 6, 9, 0.6); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.sheet { width: min(560px, 100%); max-height: 92vh; overflow-y: auto; touch-action: pan-y; background: rgba(14, 20, 27, 0.92); border: 1px solid var(--line); border-radius: 20px; padding: 18px; text-align: left; }
.sheet.tall { width: min(640px, 100%); }
.sheet h3.alert { color: var(--alert); font-size: 30px; }
.sheet .grid2 .btn-primary.sm { width: 100%; }
.form { display: grid; gap: 12px; }
.help p { color: #cbd5dc; font-size: 14px; line-height: 1.5; margin: 0; }
#loading { background: radial-gradient(circle at 50% 40%, #121c26, #05080b 70%); z-index: 50; }
#loadingText { font-family: Rajdhani, sans-serif; font-size: 20px; letter-spacing: 0.1em; margin-top: 18px; }
.loader { width: 110px; height: 110px; position: relative; }
.rotor { position: absolute; inset: 0; border-radius: 50%; background: conic-gradient(from 0deg, transparent 0 40%, rgba(255, 178, 56, 0.9) 48% 50%, transparent 52% 90%, rgba(255, 178, 56, 0.9) 98% 100%); animation: spin 0.35s linear infinite; -webkit-mask: radial-gradient(circle, transparent 12%, #000 13%); mask: radial-gradient(circle, transparent 12%, #000 13%); }
@keyframes spin { to { transform: rotate(360deg); } }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.stats div { background: rgba(255, 255, 255, 0.05); border-radius: 10px; padding: 10px; }
.stats b { display: block; font-family: Rajdhani, sans-serif; font-size: 20px; }
.stats span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.jlist { display: grid; gap: 10px; margin-top: 8px; }
.jitem { background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.jitem .t { font-weight: 600; }
.jitem .m { font-size: 12px; color: var(--muted); margin: 3px 0 8px; }
.jitem .a { display: flex; gap: 6px; flex-wrap: wrap; }
.jitem .a button { padding: 8px 10px; font-size: 12px; }
#rotate { background: rgba(3, 6, 9, 0.92); z-index: 45; color: var(--text); gap: 10px; }
#toast { position: fixed; left: 50%; top: calc(56px + var(--safe-t)); transform: translateX(-50%); z-index: 60; background: rgba(10, 16, 22, 0.9); border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px; font-size: 14px; opacity: 0; transition: opacity 0.3s; pointer-events: none; max-width: 90vw; }
#toast.show { opacity: 1; }
code { background: rgba(255, 255, 255, 0.08); padding: 1px 5px; border-radius: 5px; }

@media (max-width: 640px) {
  .hangar, .diff { grid-template-columns: 1fr; }
  .grid3 { grid-template-columns: 1fr; }
  .ac-card { display: grid; grid-template-columns: 110px 1fr; gap: 10px; align-items: center; }
  .ac-card .sil { height: 50px; }
  .ac-card .bl { min-height: 0; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-height: 460px) {
  .topbar .icon-btn { height: 32px; }
  .stick { width: min(38vmin, 150px); }
}
