:root {
  --glass: rgba(8, 18, 32, 0.62);
  --line: rgba(120, 220, 255, 0.35);
  --cyan: #6fe3ff;
  --text: #eaf6ff;
  --muted: #9fb6c8;
  --gold: #ffd36b;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #000; color: var(--text);
  font: 14px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; touch-action: none; }
#globe { position: fixed; inset: 0; }
#cockpit { position: fixed; inset: 0; pointer-events: none; }
body:not(.cockpitView) #cockpit { display: none; }
body.cockpitView #inst, body.cockpitView #minimap { display: none; }
body.cockpitView #help { top: max(12px, env(safe-area-inset-top)); bottom: auto; left: auto; right: max(12px, env(safe-area-inset-right)); transform: none; white-space: normal; width: 300px; text-align: center; }
.cesium-viewer-bottom { opacity: .55; transform: scale(.8); transform-origin: left bottom; }
.hidden { display: none !important; }
.panel { position: fixed; background: var(--glass); border: 1px solid var(--line); border-radius: 12px;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); pointer-events: none; }
.lbl { font-size: 10px; letter-spacing: .12em; color: var(--muted); }

#nav { top: max(12px, env(safe-area-inset-top)); left: max(12px, env(safe-area-inset-left)); padding: 10px 14px; width: 250px; }
#navName { font-weight: 700; font-size: 15px; margin-top: 2px; }
#navMeta { color: var(--cyan); font-variant-numeric: tabular-nums; }
#navArrowWrap { position: absolute; right: 10px; top: 12px; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line);
  display: grid; place-items: center; }
#navArrow { color: var(--gold); font-size: 16px; transition: transform .15s linear; }

#inst { top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); padding: 8px 14px; display: flex; gap: 14px; align-items: center; }
#inst > div { display: flex; flex-direction: column; align-items: center; min-width: 46px; }
#inst b { font-size: 18px; color: var(--cyan); font-variant-numeric: tabular-nums; }
#inst small { color: var(--muted); font-size: 10px; }
#apBadge { font-size: 10px; font-weight: 700; padding: 4px 8px; border-radius: 6px; background: #1d3b2a; color: #7dff9e; letter-spacing: .08em; }
#apBadge.off { background: #2a2f36; color: var(--muted); }

#banner { position: fixed; top: 18%; left: 50%; transform: translateX(-50%); font-size: 30px; font-weight: 800; text-align: center;
  text-shadow: 0 2px 12px #000, 0 0 2px #000; opacity: 0; transition: opacity .6s; pointer-events: none; width: 92vw; }
#banner.show { opacity: 1; }

#pilotCam { left: max(12px, env(safe-area-inset-left)); bottom: max(12px, env(safe-area-inset-bottom)); width: 170px; padding: 8px; overflow: hidden; }
#pilotFace { width: 100%; height: auto; display: block; border-radius: 8px; background: #111; }
.camTag { position: absolute; top: 12px; left: 14px; font-size: 10px; font-weight: 700; color: #ff5a5a; text-shadow: 0 1px 3px #000; letter-spacing: .08em; }
#overLbl { font-size: 12px; margin-top: 6px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

#minimap { right: max(12px, env(safe-area-inset-right)); bottom: max(12px, env(safe-area-inset-bottom)); width: 160px; height: 218px; }
#help { left: 50%; bottom: max(12px, env(safe-area-inset-bottom)); transform: translateX(-50%); padding: 6px 12px; font-size: 11px; color: var(--muted); white-space: nowrap; }

#touch { display: none; }
#touch button { pointer-events: auto; width: 58px; height: 58px; border-radius: 50%; border: 1px solid var(--line); background: var(--glass);
  color: var(--text); font-size: 22px; touch-action: none; user-select: none; -webkit-user-select: none; }
#touch button.on { background: rgba(111, 227, 255, .35); }
.pad { position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; gap: 4px; }
.pad > div { display: flex; gap: 58px; }
.pad2 { position: fixed; left: 50%; transform: translateX(-50%); bottom: max(14px, env(safe-area-inset-bottom)); display: flex; gap: 10px; }
.pad2 button { width: 48px !important; height: 48px !important; font-size: 20px !important; }

#card { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -60%); width: min(420px, 90vw); padding: 18px 20px; text-align: center;
  background: rgba(8, 18, 32, .82); border: 1px solid var(--gold); border-radius: 16px; animation: pop .45s ease-out; pointer-events: none; }
#cardFlag { font-size: 34px; }
#cardTitle { font-size: 20px; font-weight: 800; color: var(--gold); margin: 4px 0 8px; }
#cardFact { font-size: 14px; }
#cardNext { margin-top: 10px; font-size: 12px; color: var(--cyan); }
@keyframes pop { from { opacity: 0; transform: translate(-50%, -50%) scale(.9); } }

.screen { position: fixed; inset: 0; display: grid; place-items: center; background: radial-gradient(ellipse at center, rgba(4,12,24,.25), rgba(0,0,0,.55));
  overflow-y: auto; padding: 16px; }
.box { width: min(520px, 100%); background: rgba(8, 18, 32, .82); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); border: 1px solid var(--line); border-radius: 18px; padding: 22px; text-align: center; }
h1 { margin: 0 0 6px; font-size: 30px; background: linear-gradient(90deg, #fff, var(--cyan)); -webkit-background-clip: text; background-clip: text; color: transparent; }
h2 { margin: 0 0 8px; }
.sub { color: var(--muted); margin: 0 0 16px; }
.faceRow { display: flex; gap: 16px; align-items: center; justify-content: center; margin-bottom: 12px; }
#facePreview { width: 140px; height: 140px; border-radius: 50%; border: 3px solid var(--cyan); background: #111; flex: none; }
.faceCtl { display: flex; flex-direction: column; gap: 8px; text-align: left; }
.pilotName { color: #7dff9e; font-weight: 700; font-size: 13px; }
.btn { display: inline-block; cursor: pointer; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line); background: #102338; color: var(--text); font: inherit; font-weight: 600; }
.btn:hover { background: #17324f; }
.btn.go { margin-top: 14px; width: 100%; padding: 14px; font-size: 18px; background: linear-gradient(90deg, #0d7bbf, #13a3d8); border: 0; }
.zoom { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; }
.zoom input { width: 160px; }
#selfieVideo { width: 100%; max-height: 240px; border-radius: 12px; margin: 6px 0; transform: scaleX(-1); }
details { text-align: left; margin-top: 10px; color: var(--muted); }
summary { cursor: pointer; }
details input { width: 100%; padding: 9px; border-radius: 8px; border: 1px solid var(--line); background: #0a1626; color: var(--text); }
.small { font-size: 12px; color: var(--muted); }
.credit { font-size: 10px; color: #6b8194; margin: 4px 0 0; }

#toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: rgba(0,0,0,.75); padding: 8px 14px; border-radius: 10px;
  opacity: 0; transition: opacity .3s; pointer-events: none; font-size: 13px; }
#toast.show { opacity: 1; }

/* touch devices */
body.touch #touch { display: block; }
body.touch #help { display: none; }
body.touch #minimap { display: none; }

/* small screens (phones) */
@media (max-width: 900px), (max-height: 500px) {
  #nav { width: 200px; padding: 7px 10px; }
  #navName { font-size: 13px; }
  #navArrowWrap { width: 28px; height: 28px; top: 8px; }
  #inst { gap: 8px; padding: 6px 10px; }
  #inst > div { min-width: 34px; }
  #inst b { font-size: 14px; }
  #pilotCam { width: 104px; padding: 5px; }
  .camTag { top: 8px; left: 9px; font-size: 8px; }
  #overLbl { font-size: 10px; }
  #banner { font-size: 20px; top: 22%; }
  #card { padding: 12px 14px; transform: translate(-50%, -75%); }
  #cardTitle { font-size: 16px; }
  #cardFact { font-size: 12px; }
  #touch button { width: 50px; height: 50px; font-size: 19px; }
  .pad > div { gap: 50px; }
  .pad2 button { width: 42px !important; height: 42px !important; font-size: 17px !important; }
  h1 { font-size: 24px; }
  .box { padding: 16px; }
  #facePreview { width: 104px; height: 104px; }
}
/* phone portrait: stack instruments under nav */
@media (max-width: 600px) and (orientation: portrait) {
  #nav { width: calc(100vw - 24px); }
  #inst { top: calc(max(12px, env(safe-area-inset-top)) + 72px); left: 12px; right: auto; }
  #apBadge { font-size: 8px; padding: 3px 5px; }
  .pad2 { left: max(12px, env(safe-area-inset-left)); transform: none; bottom: calc(max(12px, env(safe-area-inset-bottom)) + 150px); flex-direction: column; }
  .faceRow { flex-direction: column; }
  .faceCtl { align-items: center; text-align: center; }
}
@media (max-height: 420px) {
  #nav { top: 6px; }
  #inst { top: 6px; }
  .pad { bottom: 8px; }
  #pilotCam { bottom: 6px; width: 88px; }
  .pad2 { bottom: 8px; }
  #card { top: 54%; transform: translate(-50%, -50%); width: min(340px, 46vw); padding: 8px 10px; }
  #cardFlag { font-size: 22px; }
  #cardTitle { font-size: 14px; margin: 2px 0 4px; }
  #cardFact { font-size: 11px; }
  #cardNext { margin-top: 4px; font-size: 10px; }
}
/* cockpit view on touch, landscape: action buttons move to the top-right so the yoke and hands stay visible */
@media (orientation: landscape) {
  body.touch.cockpitView .pad2 { top: max(8px, env(safe-area-inset-top)); bottom: auto; left: auto; right: max(12px, env(safe-area-inset-right)); transform: none; }
}
