:root {
  color-scheme: light;
  --paper: #f0e9e5;
  --card: #fff4e8;
  --ink: #283150;
  --ink-deep: #212844;
  --quiet: #4f5774;
  --line: #c8bfbf;
  --gold: #ffd478;
  --gold-light: #ffe499;
  --pad: clamp(8px, 2.3vw, 36px);
  font-family: "Helvetica Neue", "Trebuchet MS", system-ui, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); }
button, select { color: inherit; font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
button, a, select, summary { touch-action: manipulation; }
button:focus-visible, a:focus-visible, select:focus-visible, summary:focus-visible, [tabindex="-1"]:focus-visible {
  outline: 3px solid #973724;
  outline-offset: 3px;
}
button:disabled { opacity: .72; }
body:has(dialog[open]) { overflow: hidden; }
button[hidden], [hidden] { display: none !important; }
a { color: inherit; }

.flight-deck { max-width: 1490px; margin: 0 auto; padding: 0 var(--pad) 24px; }
.masthead {
  min-height: 57px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.back {
  align-self: stretch;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--ink-deep);
  font-weight: 750;
  text-decoration: none;
}
.back:hover { text-decoration: underline; text-underline-offset: 4px; }
.back::before {
  content: '';
  width: .49rem;
  height: .49rem;
  border-left: 1.5px solid;
  border-bottom: 1.5px solid;
  rotate: 45deg;
}
.flight-tools { display: flex; align-items: center; justify-content: end; gap: 7px; }
.tool, .pace {
  min-height: 44px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 6px 11px;
  font-size: .875rem;
  font-weight: 650;
}
.tool:hover:not(:disabled), .pace:hover { background: #ebddd6; }
#sound-state { font-weight: 500; }
.pace { display: flex; align-items: center; gap: 9px; padding-block: 0; }
.pace > span { color: var(--quiet); font-weight: 600; }
.pace select {
  appearance: none;
  background: transparent linear-gradient(45deg, transparent 50%, var(--ink) 50%) calc(100% - 4px) 55% / 4px 4px no-repeat;
  border: 0;
  cursor: pointer;
  min-height: 44px;
  padding: 1px 14px 1px 0;
  border-radius: 2px;
}

.stage {
  position: relative;
  height: clamp(430px, calc(100svh - 146px), 755px);
  isolation: isolate;
  background: #f4ceb1;
  overflow: hidden;
}
#field { width: 100%; height: 100%; display: block; }
.cover, .message-wrap { position: absolute; inset: 0; }
.cover { display: grid; padding: clamp(16px, 4vw, 58px); }
.intercept { display: flex; flex-direction: column; justify-content: space-between; align-items: flex-start; gap: 16px; }
.cover-line { color: var(--ink-deep); font-size: .92rem; font-weight: 700; margin: 10px 0 0; }
.game-title, h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  color: var(--ink-deep);
  font-weight: 700;
}
.game-title {
  font-size: clamp(3.8rem, 8.3vw, 8rem);
  letter-spacing: -.079em;
  line-height: .87;
  margin: 0;
}
.launch-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 15px; }
.cover-input { color: #fff1e0; font-size: .88rem; font-weight: 650; margin: 0; }
.primary, .secondary {
  padding: 10px 17px;
  min-height: 45px;
  border-radius: 4px;
  border: 1px solid var(--ink-deep);
  font-weight: 750;
}
.primary {
  background: var(--gold);
  color: #2b2d48;
  box-shadow: 0 3px 0 #303751;
}
.primary:hover { background: var(--gold-light); }
.primary:active { transform: translateY(2px); box-shadow: 0 1px 0 #303751; }
#launch {
  min-height: 49px;
  border: 0;
  border-radius: 2px;
  background: #f9dfbb;
  color: #212844;
  box-shadow: none;
}
#launch:hover { background: #fff0d7; }
#launch:focus-visible { outline-color: #fff1e0; }
.secondary { background: var(--card); }
.secondary:hover { background: #eddfdb; }

.instruments, .air-state {
  position: absolute;
  inset-block-start: 17px;
  z-index: 1;
  border-radius: 2px;
  color: var(--ink-deep);
  background: #fef0e2f5;
  border: 1px solid #43527c50;
}
.instruments {
  inset-inline-start: 18px;
  display: flex;
  gap: 13px;
  padding: 7px 13px;
  box-shadow: 0 2px 0 #3a416120;
}
.instruments div + div { border-inline-start: 1px solid var(--line); padding-inline-start: 13px; }
.instruments div > span {
  display: block;
  color: var(--quiet);
  font-size: .75rem;
  line-height: 1.3;
  font-weight: 650;
}
.instruments strong {
  font-size: 1.18rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
  letter-spacing: -.025em;
  display: block;
}
.instruments strong small { font-size: .72rem; font-weight: 650; }
.air-state {
  inset-inline-end: 18px;
  padding: 8px 12px;
  font-size: .875rem;
  font-weight: 750;
}
.air-state[data-air="normal"] { display: none; }
.air-state[data-air="lift"] { background: #ffe7a0; }
.air-state[data-air="sink"] { background: #e8d9f0; color: #3c2953; }
.air-state[data-air="stall"] { background: #fbdcd2; color: #5e281d; }
.in-flight-tip {
  position: absolute;
  inset: auto 16px 15px auto;
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: calc(100% - 32px);
  padding: 5px 10px;
  border-radius: 4px;
  background: #262e4cf5;
  color: #fff1e0;
  font-size: .875rem;
  font-weight: 650;
}
#tip-symbol { color: var(--gold); font-size: 1em; }

.message-wrap {
  z-index: 2;
  display: grid;
  place-items: center;
  background: #163d4166;
  padding: 15px;
  overflow-y: auto;
  align-items: safe center;
}
.message {
  width: min(100%, 432px);
  padding: clamp(16px, 4vw, 35px);
  border: 1px solid #153d38;
  border-radius: 8px;
  background: var(--card);
  box-shadow: 0 5px 0 #303751;
}
.message h2 { margin: 2px 0 5px; font-size: clamp(2rem, 5vw, 3rem); line-height: 1; letter-spacing: -.06em; }
#message-detail { margin: 0; }
.flight-result { display: grid; grid-template-columns: 1fr 1fr; gap: 7px 10px; margin: 11px 0 0; border-top: 1px solid var(--line); padding-top: 8px; }
.flight-result dt { color: var(--quiet); font-size: .78rem; font-weight: 700; }
.flight-result dd { margin: 0; font-size: 1.12rem; font-weight: 750; }
.message .score-note { color: var(--ink-deep); font-size: .86rem; margin: 8px 0 0; }
.message-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 17px; }

.cockpit {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  align-items: center;
  gap: clamp(10px, 2.8vw, 46px);
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}
.controls { display: flex; gap: 7px; }
body[data-screen="ready"] .cockpit { visibility: hidden; }
.pitch {
  display: flex;
  min-height: 52px;
  align-items: center;
  gap: 9px;
  padding: 6px 11px 6px 7px;
  text-align: left;
  border: 1px solid #a8c3b2;
  border-radius: 5px;
  background: #f0f5e8;
  touch-action: none;
  user-select: none;
}
.pitch:disabled { opacity: 1; }
.pitch:hover:not(:disabled) { background: #f4f8df; }
.pitch:active:not(:disabled), .pitch[data-held="true"] { background: var(--gold-light); border-color: #8a681b; box-shadow: inset 0 2px 0 #8a681b2e; }
.pitch[data-coach="true"] { border-color: #9d7330; box-shadow: inset 0 0 0 1px #c28127; animation: pitch-coach .6s ease-out 3 alternate; }
@keyframes pitch-coach { to { background: #f6e4a2; } }
.pitch strong { display: block; line-height: 1.15; white-space: nowrap; }
.pitch strong { font-size: .91rem; font-weight: 770; }
kbd {
  display: grid;
  place-items: center;
  inline-size: 32px;
  block-size: 32px;
  border: 1px solid #528070;
  border-radius: 4px;
  background: var(--grove);
  color: var(--card);
  font: 800 1.22rem/1 "Helvetica Neue", sans-serif;
}
.glide { display: none; }
body[data-pace="step"] .glide { display: flex; }
.course { min-width: 0; }
.course-top { display: flex; justify-content: space-between; align-items: baseline; gap: 9px; margin-bottom: 5px; }
#route-name { font-weight: 760; line-height: 1.15; }
.route-profile { display: block; width: 100%; height: 18px; }
.step-report { margin: 8px 0 0; min-height: 2.8em; font-size: .83rem; font-weight: 650; }

.flight-deck dialog {
  width: min(390px, calc(100% - 26px));
  max-height: calc(100% - 28px);
  border: 1px solid #6c9382;
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
  padding: 14px 18px;
}
dialog::backdrop { background: #232945a5; }
.dialog-top, .settings { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.dialog-top h2 { margin: 0; font-size: 1.9rem; }
.settings { justify-content: start; margin-top: 12px; flex-wrap: wrap; }
.wind-button { margin-top: 10px; }
.wind-button[aria-pressed="true"] { background: #f5e0a7; border-color: #9d783e; }
.route-options { display: grid; gap: 3px; margin-top: 10px; }
.route-options button {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
  text-align: left;
  background: transparent;
  border: 1px solid #b6cabc;
  border-radius: 4px;
  padding: 5px 9px;
  min-height: 46px;
  font-weight: 700;
}
.route-options button:hover, .route-options button[aria-pressed="true"] { background: #eadfdf; border-color: #a394a7; }
.route-options small { font-size: .77rem; color: var(--quiet); }
summary { cursor: pointer; min-height: 48px; display: list-item; padding: 12px 5px 8px; white-space: nowrap; font-weight: 740; }
.instruction-body { max-width: 62ch; font-size: .91rem; }
.instruction-body p { margin: 0 0 .65em; }
.announcer { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

@media (max-width: 760px) {
  .stage { height: clamp(380px, calc(100svh - 163px), 650px); }
}

@media (max-width: 590px) {
  .flight-deck { padding-bottom: 13px; }
  .masthead { min-height: 58px; }
  .flight-tools { gap: 4px; }
  .tool, .pace { padding-inline: 8px; font-size: .8rem; }
  .back { gap: 4px; font-size: .875rem; }
  .stage { height: clamp(305px, calc(100svh - 190px), 606px); }
  .cover { padding: 20px 16px 16px; }
  .game-title { font-size: clamp(3.3rem, 14vw, 4.1rem); }
  .launch-controls { align-items: flex-start; flex-direction: column; gap: 7px; }
  .cover-input { font-size: .83rem; }
  .instruments, .air-state { inset-block-start: 8px; }
  .instruments { inset-inline-start: 8px; padding: 5px 8px; gap: 7px; }
  .instruments div + div { padding-inline-start: 7px; }
  .instruments strong { font-size: 1.04rem; }
  .air-state { inset-inline-end: 8px; padding: 5px 7px; font-size: .77rem; }
  .in-flight-tip { inset: auto 8px 8px auto; font-size: .77rem; padding: 4px 7px; max-width: calc(100% - 16px); }
  .cockpit { grid-template-columns: minmax(0, 1fr); gap: 11px; padding: 9px 0 11px; }
  .pitch { flex: 1 1 0; justify-content: center; padding: 5px; gap: 7px; }
  body[data-pace="step"] .pitch { gap: 4px; }
  body[data-pace="step"] .pitch strong { font-size: .82rem; }
  .pitch kbd { inline-size: 27px; block-size: 30px; flex: 0 0 27px; }
  .step-report { margin-top: 6px; }
  summary { padding-top: 8px; }
}
@media (max-width: 360px) {
  .tool, .pace { padding-inline: 5px; }
  .flight-tools { gap: 3px; }
  .air-state { font-size: .73rem; }
  .controls { gap: 4px; }
}

@media (orientation: landscape) and (max-height: 560px) {
  .masthead { min-height: 47px; }
  .stage { height: clamp(198px, calc(100svh - 116px), 410px); }
  .cover { padding: 12px 16px; }
  .launch-controls { flex-direction: row; align-items: center; }
  .game-title { font-size: clamp(2.05rem, 6vw, 3.6rem); }
  .cockpit { grid-template-columns: max-content minmax(0, 1fr); align-items: start; }
  .in-flight-tip { max-width: 65%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
  .primary:active { transform: none; }
  .pitch[data-coach="true"] { animation: none; }
}
