#plan {
  margin-top: clamp(8px, 1.8vh, 20px);
}
#plan .plan-intro {
  padding: 14px 24px 8px;
}
#plan .plan-intro h1 { margin: 0; font-size: clamp(24px, 3.6vw, 36px); }
#plan #message:empty { display: none; }
#plan a {
  color: #a8d9ef;
}
.plan-modes {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  padding: 0 24px 12px;
}
.plan-modes button {
  min-height: 40px;
  font-weight: 700;
  border-radius: 9px;
  border: 1px solid rgba(140, 200, 235, 0.25);
  background: rgba(16, 38, 58, 0.75);
  color: #aed5e8;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  letter-spacing: 0.2px;
}
.plan-modes button:hover {
  background: rgba(28, 76, 108, 0.9);
  color: #fff;
  border-color: #65dcff;
  transform: translateY(-1px);
}
.plan-modes button[aria-pressed="true"] {
  border-color: #00e5ff;
  background: linear-gradient(135deg, #154c6d, #1b6da4);
  color: #ffffff;
  box-shadow: 0 0 16px rgba(0, 229, 255, 0.35);
  font-weight: 800;
}
#plan .planner {
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  grid-template-areas: "preview setup";
  gap: 20px;
  padding: 20px 24px 24px;
}
.plan-setup { grid-area: setup; min-width: 0; }
.plan-preview {
  grid-area: preview;
  min-width: 0;
  background: rgba(12, 32, 48, 0.75);
  border-radius: 14px;
  padding: 16px;
  border: 1px solid rgba(140, 200, 235, 0.2);
  box-shadow: inset 0 0 24px rgba(0, 0, 0, 0.35);
}
.plan-setup section { padding: 0; }
.plan-setup select, .plan-preview select { min-width: 0; max-width: 100%; }
.plan-setup details, .plan-preview details, .plan-reference {
  border: 1px solid rgba(140, 200, 235, 0.2);
  border-radius: 10px;
  background: rgba(11, 26, 40, 0.6);
  margin-top: 14px;
  padding: 10px 14px;
  transition: all 0.2s ease;
}
.plan-setup details[open], .plan-preview details[open] {
  border-color: rgba(0, 229, 255, 0.35);
  background: rgba(11, 26, 40, 0.9);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}
.plan-primary label { margin-top: 0; }
.plan-start {
  display: flex;
  gap: 10px;
  margin: 16px 0;
}
.plan-start #fly {
  flex: 1.6;
  min-height: 50px;
  font-size: 16px;
  font-weight: 800;
  border-radius: 10px;
  background: linear-gradient(135deg, #f59e0b, #fbbf24);
  color: #0f1c24;
  border: none;
  box-shadow: 0 4px 16px rgba(245, 158, 11, 0.4);
  letter-spacing: 0.5px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.plan-start #fly:hover {
  transform: translateY(-2px);
  filter: brightness(1.1);
  box-shadow: 0 6px 22px rgba(245, 158, 11, 0.6);
}
.plan-start #fly:active {
  transform: translateY(0);
}
.plan-start #approach, .plan-start #quickFastCruise {
  flex: 1;
  min-height: 50px;
  font-size: 14px;
  font-weight: 650;
  border-radius: 10px;
  background: rgba(18, 45, 66, 0.85);
  border: 1px solid rgba(140, 200, 235, 0.35);
  color: #e0f2fe;
  transition: all 0.2s ease;
}
.plan-start #approach:hover, .plan-start #quickFastCruise:hover {
  background: rgba(28, 70, 102, 0.95);
  border-color: #65dcff;
  transform: translateY(-2px);
}
.plan-preview .map {
  margin-top: 14px;
  min-height: 140px;
  background: #0a1826;
  border: 1px solid rgba(0, 229, 255, 0.3);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}
.plan-preview #planMap { max-height: 310px; width: auto; border-radius: 8px; }
#routePreview {
  margin: 10px 0 0;
  padding: 8px 12px;
  background: rgba(9, 23, 36, 0.85);
  border-radius: 8px;
  border: 1px solid rgba(140, 200, 235, 0.2);
  color: #aae0fa;
  font-size: 13px;
}
.plan-reference a { display: inline-block; margin: 6px 12px 0 0; }
#plan .plan-history { padding-top: 0; }
.mobile-mode #plan .planner { grid-template-columns: 1fr; grid-template-areas: "setup" "preview"; gap: 14px; }
#hangarControls {
  position: fixed;
  z-index: 5;
  right: clamp(8px, 2vw, 24px);
  bottom: 24px;
  width: min(450px, calc(100vw - 16px));
  padding: 12px 14px;
  border: 1px solid #79aec8;
  background: #0c2335ed;
}
#hangarControls label { margin: 5px 0; }
#hangarControls select { min-width: 0; padding: 7px; }
#hangarControls p { margin: 6px 0 0; }
.hangar-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.hangar-heading button { flex: none; }
#hangarOptions { max-height: min(52vh, 240px); overflow: auto; }
body.hangar-active { overflow: hidden; }
body.hangar-active::before {
  content: '';
  position: fixed;
  inset: 80px 0 0;
  touch-action: none;
}
body.hangar-active:has(#hangarOptions[hidden]) #hangarControls { width: auto; }
body.hangar-active #hangarControls { bottom: max(24px, env(safe-area-inset-bottom)); }
body:not(.mobile-mode) #flightNext.cargo-action {
  display: block;
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  z-index: 4;
}
#flightTimeControls {
  position: absolute;
  bottom: 54px;
  right: 0;
  z-index: 4;
  pointer-events: auto;
  text-align: right;
}
#flightTimeControls label {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding-left: 7px;
  background: #0a2135e8;
}
#flightTimeControls label::after {
  content: '▾';
  position: absolute;
  right: 7px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  font-size: 11px;
}
#flightTimeControls select {
  min-height: 40px;
  padding: 5px 19px 5px 7px;
  appearance: none;
  color-scheme: dark;
  background: #193a53;
  color: #fff;
}
#flightRateStatus:not(:empty) { display: block; margin-top: 4px; padding: 3px 5px; background: #0a2135e8; }
.mobile-mode #flightTimeControls { top: 0; bottom: auto; font-size: 11px; }
.mobile-mode #flightTimeControls select { min-height: 42px; font-size: 12px; }
.mobile-mode .touch-actions { grid-template-columns: minmax(0, 1fr) 48px; }
.mobile-mode #touchThrottleControl {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  margin: 0;
  gap: 0 6px;
  padding: 4px 6px 0;
  pointer-events: auto;
  background: #0b2439e8;
  border: 1px solid #a8ccdf66;
  font-size: 11px;
}
.mobile-mode #touchThrottle {
  grid-column: 1 / -1;
  width: 100%;
  min-width: 0;
  height: 33px;
  margin: 0;
  accent-color: #65ceff;
  touch-action: none;
}
.mobile-mode #touchQuick { grid-template-columns: repeat(3,minmax(0,1fr)); }
@media (max-width: 380px) {
  .mobile-mode #flightTimeControls label { font-size: 0; }
}
body.hangar-active .quick-controls { display: none; }
#deviceMode { color-scheme: dark; }
#quickFlights {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 7px;
  padding: 0 clamp(14px, 3vw, 24px) 12px;
}
#quickFlights button {
  min-height: 36px;
  padding: 6px 8px;
  font-size: 13px;
  font-weight: 700;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  letter-spacing: 0.2px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
#quickFlights button[data-quick="carrierCatapult"] {
  background: linear-gradient(135deg, #16364d, #1a5779);
  border-color: #00e5ff;
  color: #c7f3ff;
}
#quickFlights button[data-quick="carrierTrap"] {
  background: linear-gradient(135deg, #422315, #7a3a1e);
  border-color: #ff9800;
  color: #ffe6cc;
}
#quickFlights button:hover {
  transform: translateY(-2px);
  filter: brightness(1.15);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}
#quickFlights button:active {
  transform: translateY(0);
}
#quickFlights button[data-quick="sunset"] {
  background: linear-gradient(135deg, #7c3a14, #b45309);
  border-color: #f59e0b;
}
#quickFlights button[data-quick="landing"] {
  background: linear-gradient(135deg, #0e4e5e, #157383);
  border-color: #06b6d4;
}
#quickFlights button[data-quick="mirage"] {
  background: linear-gradient(135deg, #1e3a68, #2563eb);
  border-color: #60a5fa;
}
#quickFlights button[data-quick="duel"] {
  background: linear-gradient(135deg, #7f1d1d, #b91c1c);
  border-color: #ef4444;
}
#quickFlights button[data-quick="multiplayer"] {
  background: linear-gradient(135deg, #064e3b, #059669);
  border-color: #10b981;
}
#start2D { margin-top: 8px; }
#overviewScale {
  position: absolute;
  top: var(--hdr-h, 58px);
  right: 0;
  bottom: auto;
  display: grid;
  justify-items: end;
  gap: 6px;
  padding: 8px 10px;
  color: #f2fbff;
  background: rgba(11, 30, 48, 0.92);
  border: 1px solid rgba(110, 231, 255, 0.45);
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
  font: 700 12px system-ui,sans-serif;
  pointer-events: auto;
  z-index: 8;
}
.overview-ctrl-row { display: flex; align-items: center; gap: 10px; }
.overview-ctrl-btns { display: flex; gap: 5px; }
.overview-ctrl-btns button {
  min-height: 28px;
  padding: 3px 8px;
  font-size: 11.5px;
  font-weight: 700;
  border-radius: 6px;
  border: 1px solid rgba(140, 200, 235, 0.4);
  background: rgba(20, 56, 82, 0.9);
  color: #e6f8ff;
}
.overview-ctrl-btns button[aria-pressed="true"] {
  background: linear-gradient(135deg, #0e5a74, #17829c);
  border-color: #6ee7ff;
  color: #fff;
}
#scaleBar { border: 2px solid #fff; border-top: 0; text-align: center; white-space: nowrap; min-width: 34px; }
.overview-active #attitudePanel,.overview-active #flightGuide,.overview-active #reticle,
.overview-active #systems,.overview-active #flightNavigation { visibility: hidden; }
.mobile-mode #taiwanOverview { white-space: nowrap; }
#mouseYoke {
  position: absolute;
  left: 50%;
  top: 47%;
  width: min(210px,48vw,48vh);
  transform: translate(-50%,-50%);
  stroke: #e7f9ff;
  stroke-width: 2;
  fill: none;
  filter: drop-shadow(0 1px 2px #071827);
}
#mouseDeadzone { stroke-dasharray: 3 3; }
#mouseYokeLine,#mouseYokeDot { stroke: #58daff; }
#mouseYokeDot { fill: #58daff; }
.mobile-mode #mouseYoke { display: none; }
#gunSight {
  position: fixed;
  transform: translate(-50%,-50%);
  color: #ffdb8a;
  font: bold 27px monospace;
  text-shadow: 0 1px 3px #030b11;
}
#landingCard {
  position: absolute;
  z-index: 7;
  left: 50%;
  bottom: 170px;
  transform: translateX(-50%);
  width: min(94%,340px);
  padding: 12px;
  text-align: center;
  background: #10283bf5;
  border: 1px solid #79aec8;
  border-radius: 7px;
  pointer-events: auto;
}
#landingGrade { color: #ffd976; }
#landingDetails { margin: 5px 0 9px; }
#landingCard button { min-height: 42px; padding: 5px 12px; }
.mobile-mode #landingCard { bottom: calc(var(--stick-size) + 56px); }
#status.coach-warning { color: #fff0e3; background: #85332bf0; }
.instrument-flight #adiCanvas { width: min(250px,36vh,33vw); }
.instrument-flight.mobile-mode #adiCanvas { width: min(135px,30vh,32vw); }
.instrument-flight.mobile-mode #attitudeMode { left: min(139px,31vh,33vw); }
.instrument-flight #openHangar,.instrument-flight #viewScene,.instrument-flight #view,
.instrument-flight #cockpitViews,.instrument-flight #touchQuick [data-action="KeyC"] { display: none !important; }
.instrument-flight:not(.mobile-mode) #flightNavigation { width: min(230px,24vw); }
body:not(.mobile-mode):has(#hud:not([hidden])) #quickControls { top: 100px; right: 225px; bottom: auto; width: min(260px,28vw); }
body:not(.mobile-mode):has(#hud:not([hidden])) #quickControls[open] { z-index: 9; }
#adiCanvas {
  position: absolute;
  left: 0;
  bottom: 148px;
  width: clamp(110px, 25vh, 184px);
  aspect-ratio: 1;
  filter: drop-shadow(0 1px 4px #0414209e);
}
#attitudeMode {
  position: absolute;
  left: 0;
  bottom: 114px;
  padding: 5px 10px;
  font: 700 12px system-ui, sans-serif;
  background: #0a2135ed;
}
#attitudePanel[data-mode="hud"] #adiCanvas {
  left: 50%;
  top: 47%;
  bottom: auto;
  width: min(320px, 56vh, 72vw);
  transform: translate(-50%, -50%);
}
#attitudeMode[aria-pressed="true"] { color: #a2ffd2; }
#hud:has(#attitudePanel[data-mode="hud"]:not([hidden])) #reticle { visibility: hidden; }
body:not(.mobile-mode) #status.practice-status { bottom: 126px; top: auto; }
.mobile-mode #adiCanvas { top: 49px; bottom: auto; width: clamp(84px, 24vh, 110px); }
.mobile-mode #attitudeMode { top: 49px; bottom: auto; left: clamp(88px, 25vh, 114px); min-height: 42px; min-width: 44px; }
.mobile-mode #attitudePanel[data-mode="hud"] #adiCanvas { top: 44%; width: min(220px, 54vh, 63vw); }
.mobile-mode [data-mobile-panel]:not([data-mobile-panel=""]) #attitudePanel { visibility: hidden; }
body:not(.mobile-mode) #hud:has(#systems:not([hidden])) #attitudePanel[data-mode="pfd"] #adiCanvas {
  left: min(49vw, 370px);
}
body:not(.mobile-mode) #hud:has(#systems:not([hidden])) #attitudeMode {
  left: min(49vw, 370px);
}
@media (max-width: 860px) {
  #quickFlights {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }
  .plan-modes {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }
}
@media (max-width: 580px) {
  #quickFlights {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }
  #quickFlights button:last-child {
    grid-column: 1 / -1;
  }
  .plan-modes {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
    padding-inline: 12px;
  }
  .plan-modes button {
    padding: 8px 4px;
    font-size: 13px;
    min-height: 42px;
  }
  #plan .planner {
    grid-template-columns: 1fr;
    grid-template-areas: "setup" "preview";
    padding: 14px;
  }
  #plan .plan-setup, #plan .plan-preview {
    padding: 12px;
  }
}
@media (max-height: 590px) {
  body:not(.mobile-mode) #hud:has(#systems:not([hidden])) #adiCanvas { left: 0; bottom: 101px; width: min(22vh,130px); }
  body:not(.mobile-mode) #hud:has(#systems:not([hidden])) #attitudeMode { left: min(22vh,130px); bottom: 101px; }
  body:not(.mobile-mode) #hud #systems { max-height: max(62px,calc(100% - 236px)); }
}
