/* Flight deck hardware. These colours belong to the instruments and their backlighting. */
#flight, #panel.flight-panel {
  --deck-metal: linear-gradient(153deg, #47545a 0%, #303d43 25%, #1d292f 56%, #151f25 100%);
  --deck-press: linear-gradient(#202b30, #111a20 55%, #18252c);
  --deck-edge: #536269;
  --deck-brass: #e5bf79;
  --deck-glow: #a7e0d6;
  --deck-type: #eef1e6;
  --deck-mount: inset 0 1px #b1bdbe48, inset 0 -2px #071016ae, 0 2px 4px #06101771;
  --deck-cap: inset 0 1px #bfc7c040, inset 0 -2px #071014, 0 0 0 1px #050d10, 0 2px 2px #040b0e90;
  --deck-gutter: clamp(8px, 1.3vw, 21px);
}
#flight .hud.top-left, #flight .flight-buttons, #flight .state-read {
  color: var(--deck-type);
  background: var(--deck-metal);
  border: 1px solid var(--deck-edge);
  border-radius: 7px;
  box-shadow: var(--deck-mount);
}
#flight .hud.top-left {
  left: max(var(--deck-gutter), env(safe-area-inset-left));
  top: max(var(--deck-gutter), env(safe-area-inset-top));
  gap: 10px;
  padding: 8px 16px 8px 10px;
  max-width: 34vw;
  min-height: 51px;
  border-bottom-right-radius: 16px;
}
#flight .hud-mark {
  width: 36px;
  height: 36px;
  padding: 3px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 28%, #2e393b, #0b1318 75%);
  box-shadow: 0 0 0 1px #0b1318, 0 1px 0 2px #b0b5a76b, inset 0 1px 1px #000;
}
#flight .mission-data { gap: 3px; }
#flight .mission-data strong {
  color: #fff4d8;
  font: 700 clamp(17px, 1.7vw, 24px)/1.02 var(--display);
  letter-spacing: .005em;
  overflow-wrap: anywhere;
}
#flight #flightStage {
  color: #c6e8df;
  font: 600 clamp(10px, .78vw, 12px)/1.25 var(--mono);
  overflow-wrap: anywhere;
}
#flight .gate-meter {
  height: 4px;
  max-width: 150px;
  margin-top: 1px;
  border-radius: 2px;
  background: #0c151a;
  box-shadow: 0 1px #92a5a04d;
}
#flight .gate-meter::before { background: linear-gradient(90deg, #739b91, #b4e8d7); }

/* The function keys sit in individual raised wells; the amber key opens the compass. */
#flight .flight-buttons {
  right: max(var(--deck-gutter), env(safe-area-inset-right));
  top: max(var(--deck-gutter), env(safe-area-inset-top));
  display: grid;
  grid-auto-flow: column;
  gap: 4px;
  padding: 4px 6px;
  border-radius: 8px 8px 8px 14px;
}
#flight .flight-buttons .hud-icon, #flight .touch-actions .touch-btn, #panel.flight-panel .dialog-head .arrow {
  position: relative;
  isolation: isolate;
  border: 1px solid #637275;
  border-color: #687476 #45555b #24333a;
  border-radius: 5px;
  background: linear-gradient(155deg, #455158, #2c393f 47%, #202d34);
  color: #d1e9df;
  box-shadow: var(--deck-cap);
}
#flight .flight-buttons .hud-icon {
  width: 44px;
  height: 43px;
}
#flight .flight-buttons .hud-icon canvas, #flight .touch-actions .touch-btn canvas {
  width: 18px;
  height: 18px;
  filter: drop-shadow(0 1px 1px #070e11);
}
#flight .flight-buttons .hud-icon::before, #flight .touch-actions .touch-btn::before {
  content: "";
  position: absolute;
  inset: 3px;
  pointer-events: none;
  border: 1px solid #a5b2b528;
  border-radius: 3px;
}
#flight .flight-buttons #hudPause {
  border-radius: 50%;
  color: #ffdf9d;
  border-color: #b7a27e #837459 #514939;
  background: radial-gradient(circle at 35% 24%, #514d3f, #343630 65%, #282a26);
}
#flight .flight-buttons #hudPause::before { border-color: #c6a87591; border-radius: 50%; }
#flight .flight-buttons #hudPause canvas { width: 18px; height: 18px; }
#flight .hud-icon:focus-visible, #flight .touch-btn:focus-visible,
#panel.flight-panel button:focus-visible {
  outline: 2px solid #ffe4a8;
  outline-offset: 3px;
}
@media (hover: hover) {
  #flight .flight-buttons .hud-icon:hover, #flight .touch-btn:hover,
  #panel.flight-panel .dialog-head .arrow:hover {
    border-color: #b6c9bf;
    filter: brightness(1.16);
  }
}
#flight .flight-buttons .hud-icon:active, #flight .touch-actions .touch-btn:active,
#panel.flight-panel .dialog-head .arrow:active {
  color: #fff1cf;
  background: var(--deck-press);
  box-shadow: inset 0 2px 4px #02080d, 0 1px #7c8885;
  transform: translateY(1px);
}

/* The instrument faces contain their own rolled rims and legible digital windows. */
#flight .instruments {
  --dial-width: clamp(235px, 25vw, 342px);
  padding: 0;
  left: max(var(--deck-gutter), env(safe-area-inset-left));
  bottom: max(var(--deck-gutter), env(safe-area-inset-bottom));
  background: none;
  border: 0;
  box-shadow: none;
  filter: drop-shadow(0 2px 3px #071016a8);
}
#flight .dial-cluster {
  display: block;
  width: var(--dial-width);
  height: calc(var(--dial-width) / 3);
}
#flight .instruments:has(.dial-cluster) .gauge {
  position: absolute;
  width: 1px;
  min-width: 0;
  height: 1px;
  padding: 0;
  margin: -1px;
  border: 0;
  overflow: hidden;
  white-space: nowrap;
  clip-path: inset(50%);
}
#flight .state-read {
  right: max(var(--deck-gutter), env(safe-area-inset-right));
  bottom: max(var(--deck-gutter), env(safe-area-inset-bottom));
  gap: 9px;
  padding: 7px 10px;
  border-radius: 12px 5px 5px 5px;
  font: 700 10px/1.2 var(--mono);
  letter-spacing: .025em;
}
#flight .gear-state i {
  width: 7px;
  height: 7px;
  background: radial-gradient(circle at 35% 30%, #c6b896, #7c7864 65%);
  box-shadow: 0 0 0 1px #0b141a, 0 1px 0 2px #84908b52;
}
#flight .gear-state.down i {
  background: radial-gradient(circle at 35% 30%, #edffcf, #a0d9a1 40%, #4b926e);
  box-shadow: 0 0 0 1px #08141a, 0 0 5px #8ccda475;
}
#flight .flight-time { color: var(--deck-glow); border-color: #5f6f70; }
#flight .flight-tip {
  bottom: max(calc(var(--deck-gutter) + 3px), env(safe-area-inset-bottom));
  max-width: min(38vw, 570px);
  padding: 8px 14px 8px 15px;
  background: linear-gradient(125deg, #102127f7, #0b171ff1);
  color: #f4f2df;
  border: 1px solid #58696a;
  border-left: 3px solid #d4b680;
  border-radius: 2px 9px 3px 3px;
  box-shadow: 0 2px 5px #07121969, inset 0 1px #d4e3ce23;
  text-wrap: pretty;
}
#flight.in-cockpit .instruments {
  --dial-width: clamp(188px, 16vw, 248px);
  top: calc(max(var(--deck-gutter), env(safe-area-inset-top)) + 75px);
  bottom: auto;
}
#flight.in-cockpit .state-read {
  top: calc(max(var(--deck-gutter), env(safe-area-inset-top)) + 61px);
  bottom: auto;
}
#flight.in-cockpit .flight-tip {
  top: calc(max(var(--deck-gutter), env(safe-area-inset-top)) + 54px);
  bottom: auto;
  max-width: min(37vw, 505px);
}

#flight .touch-controls .stick {
  border: 1px solid #899792;
  background: radial-gradient(circle, #15252a40 47%, #30434285 58%, #101a20bb 62%, #657273a4 66%, #243137d9 69%);
  outline: 1px solid #0f1b20ae;
  outline-offset: -4px;
  box-shadow: 0 2px 5px #0a11175e, inset 0 1px #d9deca78;
}
#flight .touch-controls .stick::before, #flight .touch-controls .stick::after { background: #d0d8bf66; }
#flight .touch-controls .stick i {
  border: 1px solid #d7cba8;
  background: radial-gradient(circle at 34% 25%, #969c84, #5d695b 58%, #33403f);
  box-shadow: 0 2px 3px #0c1419a1, inset 0 1px #f7e9bd78;
}
#flight .touch-actions { grid-template-columns: repeat(2, 44px); gap: 5px; }
#flight .touch-actions .touch-btn {
  width: 44px;
  height: 44px;
  color: #e3ecd8;
  font: 600 24px/1 var(--mono);
}
#flight .touch-actions #touchPing { color: var(--deck-brass); }
.touch-ui #flight:not(.in-cockpit) .instruments, .touch-ui #flight:not(.in-cockpit) .state-read {
  bottom: calc(max(var(--deck-gutter), env(safe-area-inset-bottom)) + 107px);
}

/* Recessed instrument tray and compass rose for the in-flight menus. */
#panel.flight-panel {
  --accent: #dcb777;
  --bright: #f1d19a;
  color: var(--deck-type);
  border: 1px solid #87918b;
  border-radius: 12px;
  background: linear-gradient(145deg, #25333a, #17232a 45%, #121d24);
  box-shadow: inset 0 0 0 2px #1b272b, inset 0 0 0 3px #8a9b9440, 0 15px 60px #030a10bf;
}
#panel.flight-panel::backdrop { background: #091319ad; backdrop-filter: blur(3px); }
#panel.flight-panel .dialog-head {
  min-height: 52px;
  padding: 9px 16px;
  border-top: 1px solid #82908c;
  border-bottom: 1px solid #53635f;
  background: var(--deck-metal);
  box-shadow: inset 0 1px #bac2af43, 0 2px 5px #0711176e;
}
#panel.flight-panel .dialog-title { gap: 11px; }
#panel.flight-panel .dialog-title h2 { color: #fff1d1; font-size: clamp(23px, 3vw, 31px); line-height: 1.05; }
#panel.flight-panel .dialog-icon {
  width: 31px;
  height: 31px;
  border-radius: 50%;
  color: var(--deck-brass);
  border: 1px solid #ad9776;
  background: radial-gradient(circle, #253336, #121b20);
  box-shadow: 0 0 0 2px #152027, 0 1px 0 3px #9da69b5c;
}
#panel.flight-panel .dialog-head .arrow { width: 40px; height: 36px; }
#panel.flight-panel #panelBody { padding: 17px 19px 20px; }
#panel.flight-panel .secondary, #panel.flight-panel .pick-line {
  color: #e8ece2;
  background: linear-gradient(150deg, #35434a, #222e36);
  border-color: #697670 #435259 #29363c;
  border-radius: 4px;
  box-shadow: inset 0 1px #d8ded41b;
}
#panel.flight-panel .primary {
  background: linear-gradient(#ebc888, #c49d61);
  color: #1b2424;
  border-color: #f2d799 #ae8f55 #7c693f;
  border-radius: 4px;
  box-shadow: inset 0 1px #f9e2b3, 0 2px #131a1a;
}
#panel.flight-panel .secondary:enabled:hover, #panel.flight-panel .pick-line:hover,
#panel.flight-panel .pick-line.active { border-color: #b7a078; }
#panel.flight-panel .summary-line strong { color: #c0e6d6; }

#panel.flight-panel.compass-menu { width: min(424px, calc(100vw - 22px)); }
#panel.flight-panel.compass-menu #panelBody {
  --dial-size: min(100%, 330px);
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 15px 18px 17px;
  background: radial-gradient(ellipse at 50% 26%, #36454b61, transparent 72%);
}
#panel.flight-panel .compass-nav {
  position: relative;
  isolation: isolate;
  width: var(--dial-size);
  aspect-ratio: 1;
  border: 2px solid #8d9490;
  border-radius: 50%;
  background: radial-gradient(circle at center, transparent 63%, #060e14 64%, #899790 65%, #344449 66%, #121e24 69%, #62716d 71%),
              radial-gradient(circle at 32% 19%, #334a4e, #1d3339 41%, #122229 73%, #0c171c);
  box-shadow: inset 0 0 0 3px #172328, inset 0 0 0 4px #697875, 0 0 0 1px #111b21, 0 4px 8px #030b106e;
}
#panel.flight-panel .compass-nav::before, #panel.flight-panel .compass-nav::after {
  content: "";
  position: absolute;
  inset: 5.1%;
  border-radius: 50%;
  pointer-events: none;
}
#panel.flight-panel .compass-nav::before {
  background: repeating-conic-gradient(from -.55deg, #ccd1bcbc 0 1.1deg, transparent 1.1deg 5deg);
  -webkit-mask: radial-gradient(circle closest-side, transparent 95%, #000 95.8%);
  mask: radial-gradient(circle closest-side, transparent 95%, #000 95.8%);
}
#panel.flight-panel .compass-nav::after {
  background: repeating-conic-gradient(from -.7deg, #e2bf7d 0 1.4deg, transparent 1.4deg 30deg);
  -webkit-mask: radial-gradient(circle closest-side, transparent 91.5%, #000 92.3%);
  mask: radial-gradient(circle closest-side, transparent 91.5%, #000 92.3%);
}
#panel.flight-panel .compass-rose {
  --rose-size: 25%;
  position: absolute;
  top: 50%;
  left: 50%;
  width: var(--rose-size);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border: 1px solid #a89e7980;
  border-radius: 50%;
  background: radial-gradient(circle, #153038, #213b40 49%, #576963 50%, #22363a 52%, #13252c 68%, #4f605b 69%, #26383b 73%);
  box-shadow: 0 0 0 3px #14252a, 0 0 0 4px #87918855, inset 0 1px #adb4a557;
  pointer-events: none;
}
#panel.flight-panel .compass-rose::before {
  content: "";
  position: absolute;
  inset: 5%;
  transform: rotate(var(--rose-bearing, 0deg));
  clip-path: polygon(50% 0, 56% 41%, 88% 50%, 57% 56%, 50% 100%, 43% 57%, 12% 50%, 43% 43%);
  background: conic-gradient(from 0deg, #e6be74 0 45deg, #b3b9a5 45deg 90deg, #5d706d 90deg 135deg, #9dafaa 135deg 180deg, #e1e3cb 180deg 225deg, #6c837e 225deg 270deg, #c8c7a8 270deg 315deg, #f8dca1 315deg);
}
#panel.flight-panel .compass-rose::after {
  content: "";
  position: absolute;
  left: 43%;
  top: 43%;
  width: 14%;
  height: 14%;
  border: 1px solid #c8ba92;
  border-radius: 50%;
  background: #5a655b;
}
#panel.flight-panel .compass-key {
  position: absolute;
  z-index: 1;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 4px;
  width: 29%;
  min-height: max(44px, 17%);
  padding: 5px 2px;
  transform: translate(-50%, -50%);
  border: 1px solid #72837d;
  border-radius: 7px;
  background: linear-gradient(155deg, #405354, #2c4044 44%, #24363c);
  box-shadow: var(--deck-cap);
  color: #f2f5e9;
  font: 700 clamp(11px, 1.05vw, 13px)/1.12 Arial, sans-serif;
  text-align: center;
  text-wrap: balance;
}
#panel.flight-panel .compass-key canvas { width: 18px; height: 18px; color: #b5e5db; }
#panel.flight-panel .compass-key.key-north { left: 50%; top: 21%; }
#panel.flight-panel .compass-key.key-east { left: 77.4%; top: 50%; }
#panel.flight-panel .compass-key.key-south { left: 50%; top: 79%; }
#panel.flight-panel .compass-key.key-west { left: 22.6%; top: 50%; }
#panel.flight-panel .compass-key.key-north {
  background: linear-gradient(155deg, #665e46, #453f31);
  border-color: #b6a074 #8a7b5e #635840;
  color: #fff1c5;
}
#panel.flight-panel .compass-key.key-north canvas { color: #f6d59b; }
#panel.flight-panel .compass-key:enabled:hover { filter: brightness(1.16); border-color: #d3c39a; }
#panel.flight-panel .compass-key:active {
  background: var(--deck-press);
  box-shadow: inset 0 2px 3px #030a0c, 0 1px #718078;
}
#panel.flight-panel .compass-readout {
  margin: 0;
  text-align: center;
  font: 600 12px/1.35 var(--mono);
  letter-spacing: .025em;
  color: var(--deck-glow);
}
#panel.flight-panel .compass-footer {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: stretch;
  flex-wrap: wrap;
  gap: 7px;
}
#panel.flight-panel .compass-footer button { flex: 1 1 105px; min-height: 39px; font-size: 12px; }
#panel.flight-panel.compass-menu .dialog-actions { margin: 0; }

@media (max-width: 900px) {
  #flight .instruments { --dial-width: clamp(184px, 28vw, 240px); }
  #flight .flight-tip { max-width: 39vw; }
}
@media (max-width: 600px) and (orientation: portrait) {
  #flight .hud.top-left { max-width: min(62vw, calc(100vw - 118px)); min-height: 46px; gap: 7px; padding: 7px 10px 7px 7px; }
  #flight .hud-mark { width: 27px; height: 27px; }
  #flight .mission-data strong { font-size: 17px; }
  #flight #flightStage { font-size: 10px; }
  #flight .flight-buttons { grid-auto-flow: row; grid-template-columns: repeat(2, 42px); gap: 3px; padding: 3px; }
  #flight .flight-buttons .hud-icon { width: 42px; height: 42px; }
  #flight .instruments { --dial-width: clamp(154px, 49vw, 205px); }
  #flight .state-read { font-size: 9px; padding: 6px 7px; gap: 6px; }
  #flight .flight-tip { bottom: calc(max(var(--deck-gutter), env(safe-area-inset-bottom)) + 83px); max-width: 86vw; font-size: 12px; }
  .touch-ui #flight:not(.in-cockpit) .flight-tip { bottom: calc(max(var(--deck-gutter), env(safe-area-inset-bottom)) + 185px); }
  #flight.in-cockpit .instruments { --dial-width: clamp(156px, 45vw, 190px); top: calc(max(var(--deck-gutter), env(safe-area-inset-top)) + 69px); }
  #flight.in-cockpit .state-read { top: calc(max(var(--deck-gutter), env(safe-area-inset-top)) + 98px); }
  #flight.in-cockpit .flight-tip { top: calc(max(var(--deck-gutter), env(safe-area-inset-top)) + 143px); bottom: auto; max-width: 86vw; }
}
@media (max-height: 540px) and (orientation: landscape) {
  #flight { --deck-gutter: 6px; }
  #flight .hud.top-left { min-height: 40px; max-width: 33vw; padding: 5px 9px 5px 6px; gap: 7px; }
  #flight .mission-data strong { font-size: 16px; }
  #flight #flightStage { font-size: 9px; }
  #flight .hud-mark { width: 26px; height: 26px; }
  #flight .flight-buttons { padding: 2px 4px; gap: 3px; }
  #flight .flight-buttons .hud-icon { width: 40px; height: 40px; }
  #flight .instruments, #flight.in-cockpit .instruments { --dial-width: clamp(145px, 25vw, 194px); }
  .touch-ui #flight:not(.in-cockpit) .instruments { left: calc(max(8px, env(safe-area-inset-left)) + 85px); bottom: max(7px, env(safe-area-inset-bottom)); }
  .touch-ui #flight .touch-actions { bottom: max(7px, env(safe-area-inset-bottom)); gap: 4px; }
  .touch-ui #flight:not(.in-cockpit) .state-read { bottom: calc(max(7px, env(safe-area-inset-bottom)) + 99px); }
  #flight.in-cockpit .instruments { top: calc(max(7px, env(safe-area-inset-top)) + 53px); }
  #flight.in-cockpit .state-read { top: calc(max(7px, env(safe-area-inset-top)) + 48px); }
  #flight .flight-tip, .touch-ui #flight:not(.in-cockpit) .flight-tip, #flight.in-cockpit .flight-tip {
    left: 50%; top: auto; bottom: max(7px, env(safe-area-inset-bottom)); max-width: 38vw; padding: 5px 9px; font-size: 10px;
  }
  .touch-ui #flight:not(.in-cockpit) .flight-tip { top: calc(max(7px, env(safe-area-inset-top)) + 50px); bottom: auto; }
  #panel.flight-panel.compass-menu { width: min(550px, calc(100vw - 25px)); max-height: calc(100dvh - 12px); }
  #panel.flight-panel.compass-menu #panelBody { --dial-size: min(100%, 237px); grid-template-columns: minmax(184px, 1fr) minmax(108px, .76fr); column-gap: 18px; row-gap: 7px; align-items: center; padding: 11px 18px; }
  #panel.flight-panel.compass-menu .compass-nav { grid-column: 1; grid-row: 1 / span 4; justify-self: end; }
  #panel.flight-panel.compass-menu #panelBody > :not(.compass-nav) { grid-column: 2; justify-self: stretch; }
  #panel.flight-panel.compass-menu .compass-key { gap: 2px; font-size: 10px; }
  #panel.flight-panel.compass-menu .compass-key canvas { width: 14px; height: 14px; }
}
@media (forced-colors: active) {
  #panel.flight-panel .compass-key, #flight .flight-buttons .hud-icon, #flight .touch-btn { border: 1px solid ButtonText; }
  #panel.flight-panel .compass-rose { border: 2px solid CanvasText; }
}
@media (pointer: coarse) {
  #flight .flight-buttons .hud-icon, #panel.flight-panel .dialog-head .arrow {
    min-width: 44px;
    min-height: 44px;
  }
}
@media (pointer: coarse) and (max-width: 600px) and (orientation: portrait) {
  #flight .flight-buttons { grid-template-columns: repeat(2, 44px); }
}

#flight .flight-buttons #hudPause canvas { transform:rotate(var(--hud-bearing, 0deg)) }
#panel.flight-panel .compass-readout { display:flex; flex-wrap:wrap; justify-content:center; gap:4px 14px }
#panel.flight-panel .compass-readout strong { color:#f1d3a6 }
#panel.flight-panel .cardinal {
 position:absolute; z-index:1; pointer-events:none; transform:translate(-50%, -50%);
 color:#c5c4a6; font:700 clamp(9px,1.1vw,13px)/1 var(--mono); text-shadow:0 1px 2px #091316;
}
#panel.flight-panel .cardinal-n { left:50%;top:8.2%;color:#f1c981 }
#panel.flight-panel .cardinal-e { left:91.2%;top:50% }
#panel.flight-panel .cardinal-s { left:50%;top:92% }
#panel.flight-panel .cardinal-w { left:8.8%;top:50% }

#flight.in-cockpit .instruments { top:calc(max(var(--deck-gutter), env(safe-area-inset-top)) + var(--plaque-height, 76px) + 7px) }
#panel .sortie-photos { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:6px; margin:12px 0 }
#panel .sortie-photo { display:grid; color:#eddaa8; text-decoration:none; font:600 11px/1.35 var(--mono); gap:5px }
#panel .sortie-photo img { width:100%; aspect-ratio:16/9; object-fit:cover; border:1px solid #8b978e; border-radius:3px }
#panel .sortie-photo:hover,#panel .sortie-photo:focus-visible { color:#fff1cd; text-decoration:underline }
@media (max-width:600px) and (min-height:481px) {
 #flight.in-cockpit .flight-tip {
   top:calc(max(var(--deck-gutter), env(safe-area-inset-top)) + var(--plaque-height, 76px) + clamp(52px,15vw,64px) + 17px);
 }
}
.touch-ui #flight .context-trigger { min-height:44px }
@media (max-width:600px) {
 #flight .flight-buttons { grid-template-columns:repeat(2,44px) }
 #flight .flight-buttons .hud-icon { min-height:44px; min-width:44px }
}
