:root { color-scheme: dark; font-family: system-ui, sans-serif; color: #d8e4eb; background: #070f16; --line: #21333e; --muted: #8a9eab; --cyan: #4ddfd9; --amber: #ffaa57; --text-xs: 12px; --text-sm: 13px; --text-base: 14px; --text-body: 16px; --timeline-height: 54px; }
* { box-sizing: border-box; scrollbar-width: none; }
*::-webkit-scrollbar { display: none; }
html { width: 100%; height: 100%; overflow: hidden; overscroll-behavior: none; }
body { position: fixed; top: var(--app-top, 0px); left: 0; width: 100%; height: 100vh; height: var(--app-height, 100dvh); margin: 0; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); display: flex; flex-direction: column; overflow: hidden; }
[hidden] { display: none !important; }
button, textarea, input { font: inherit; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--cyan); }
header { flex: 0 0 auto; min-height: 52px; display: flex; align-items: center; gap: 18px; padding: 6px 14px; border-bottom: 1px solid var(--line); }
.wordmark { font-weight: 750; letter-spacing: .14em; font-size: 18px; white-space: nowrap; }
.mark { color: var(--cyan); font-size: 23px; margin-right: 6px; }
.badge, .panel-heading, .map-caption, .readout, .legend, .run-row { font-family: ui-monospace, monospace; }
.badge { color: var(--muted); font-size: var(--text-xs); letter-spacing: .08em; }
#console-toggle { white-space: nowrap; color: var(--muted); background: transparent; border-color: transparent; }
#console-toggle:hover { color: #d8e4eb; background: #14232d; border-color: var(--line); }
#console-toggle[aria-expanded="true"] { color: var(--cyan); }
#help-open { margin-left: auto; white-space: nowrap; }
.source { color: var(--muted); font-size: var(--text-base); white-space: nowrap; }
main { flex: 1; min-height: 0; min-width: 0; padding: 8px; position: relative; overflow: hidden; }
.workspace { display: grid; height: 100%; min-height: 0; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); gap: 8px; position: relative; }
.workspace.console-open { grid-template-columns: minmax(0, 1fr) 360px; }
.map-panel, .console-panel { border: 1px solid var(--line); background: #0b151e; min-width: 0; min-height: 0; overflow: hidden; }
.tactical-layout, .map-toolbar { display: contents; }
.map-panel { display: flex; flex-direction: column; container: tactical / inline-size; }
.panel-heading { flex: 0 0 36px; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 12px; border-bottom: 1px solid var(--line); font-size: var(--text-xs); }
h2 { font-size: var(--text-sm); font-weight: 500; letter-spacing: .04em; text-transform: uppercase; margin: 0; }
#engine-status { color: var(--cyan); }
.map-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; flex: 0 0 auto; padding: 4px 8px; border-bottom: 1px solid var(--line); }
.map-tools button { min-height: 30px; padding: 4px 7px; font-size: var(--text-sm); }
.map-tools button[aria-pressed="true"] { color: var(--cyan); border-color: var(--cyan); background: #173b40; }
.zoom-buttons { display: flex; gap: 4px; margin-left: auto; }
.zoom-buttons button { min-width: 30px; font-size: 16px; padding: 2px 5px; }
.map-scale { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.map-scale span { text-align: left; }
.canvas-wrap { touch-action: none; cursor: grab; position: relative; flex: 1; min-height: 0; min-width: 0; overflow: hidden; }
/* Map gestures must not select labels or open touch-and-hold callouts. */
.canvas-wrap { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
#timeline-controls { display: grid; grid-template-columns: 48px minmax(100px, 1fr) minmax(120px, 2fr); align-items: center; gap: 8px; flex: 0 0 var(--timeline-height); height: var(--timeline-height); padding: 3px 10px; border-top: 1px solid var(--line); }
#forecast-live { min-height: 32px; padding: 4px; }
#forecast-live[aria-pressed="true"] { color: var(--cyan); border-color: var(--cyan); }
#forecast-label { margin: 0; font: var(--text-xs)/16px ui-monospace, monospace; }
#forecast-scale { position: relative; min-width: 0; height: 46px; }
#forecast-axis { position: absolute; top: 14px; left: calc(var(--timeline-thumb-size) / 2); right: calc(var(--timeline-thumb-size) / 2); height: 6px; border-radius: 3px; background: linear-gradient(to right, var(--cyan) var(--near-share, 40%), #966335 var(--near-share, 40%)); pointer-events: none; }
#forecast-axis span { position: absolute; top: 15px; white-space: nowrap; font: var(--text-xs)/16px ui-monospace, monospace; }
.forecast-now { left: 0; color: var(--muted); }
#forecast-boundary { color: var(--cyan); transform: translateX(-50%); }
#forecast-boundary.at-end { transform: translateX(-100%); }
#forecast-end { right: 0; color: var(--amber); }
#forecast-ticks i { position: absolute; top: -2px; height: 10px; width: 1px; background: var(--amber); }
#forecast-ticks i:first-child { background: var(--cyan); }
#forecast-ready-marks i { position: absolute; top: -2px; width: 9px; height: 9px; background: #b0f5af; border: 1px solid #123b29; transform: translateX(-50%) rotate(45deg); }
#forecast-axis #forecast-ready-label { top: -15px; color: #b0f5af; font-size: var(--text-xs); line-height: 14px; }
#forecast-time { appearance: none; position: relative; display: block; width: 100%; height: 34px; min-height: 34px; min-width: 0; margin: 0; padding: 0; border: 0; border-radius: 0; background: transparent; cursor: ew-resize; touch-action: none; }
#forecast-time::-webkit-slider-runnable-track { height: 6px; background: transparent; }
#forecast-time::-moz-range-track { height: 6px; background: transparent; }
#forecast-time::-webkit-slider-thumb { appearance: none; width: var(--timeline-thumb-size); height: var(--timeline-thumb-size); margin-top: calc((6px - var(--timeline-thumb-size)) / 2); border-radius: 50%; border: 2px solid #0b151e; background: var(--thumb-color, var(--cyan)); }
#forecast-time::-moz-range-thumb { width: calc(var(--timeline-thumb-size) - 4px); height: calc(var(--timeline-thumb-size) - 4px); border-radius: 50%; border: 2px solid #0b151e; background: var(--thumb-color, var(--cyan)); }
#forecast-time:focus-visible { outline: 1px solid var(--cyan); outline-offset: 2px; }
#forecast-time:disabled { opacity: .5; cursor: default; }
#time-forecast { pointer-events: none; }
#time-forecast path { stroke-width: 1.5; }
#time-forecast .forecast-route { stroke: var(--cyan); stroke-dasharray: 5 5; opacity: .65; }
#time-forecast .forecast-own { stroke: var(--cyan); fill: var(--cyan); }
#time-forecast .forecast-enemy { stroke: var(--amber); fill: var(--amber); stroke-dasharray: 3 3; }
#time-forecast .forecast-round { stroke: white; fill: white; }
#time-forecast text { stroke: #070f16; stroke-width: 3px; stroke-dasharray: none; paint-order: stroke; }
#mission-overlay[data-preview="true"] + .map-caption .map-scale { visibility: hidden; }
/* Bevy sets inline minimum dimensions; allow the canvas to fit compact viewports. */
canvas { display: block; width: 100%; height: 100%; min-width: 0 !important; min-height: 0 !important; outline: none; }
.map-caption { position: absolute; top: 12px; left: 12px; right: 12px; display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: var(--text-xs); pointer-events: none; }
.map-caption > span { text-align: right; }
.flight-controls { flex: 0 1 auto; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: 'transport transport' 'telemetry burn'; overflow: auto; overscroll-behavior: contain; border-top: 1px solid var(--line); }
.transport { grid-area: transport; padding: 8px 12px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 20px; border-bottom: 1px solid var(--line); }
.command-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex: 1 1 360px; min-width: 0; }
.clock { min-width: 0; }
#window-time { display: block; margin-top: 4px; color: var(--muted); font: var(--text-xs) ui-monospace, monospace; }
.readout { display: grid; grid-template-columns: 9ch max-content; gap: 0 6px; align-items: center; font-size: var(--text-xs); font-variant-numeric: tabular-nums; }
.readout > small { grid-column: 1 / -1; }
.readout strong, #window-time { white-space: nowrap; }
#mode { color: var(--cyan); }
.readout strong { font-size: 18px; font-weight: 500; }
small { color: var(--muted); font-size: var(--text-xs); }
.buttons { display: flex; gap: 6px; }
button { border: 1px solid #354b59; border-radius: 3px; padding: 8px 11px; min-height: 36px; cursor: pointer; color: #d8e4eb; background: #14232d; font-size: var(--text-base); }
button:hover:not(:disabled) { border-color: var(--cyan); background: #1b343b; }
button:disabled { opacity: .4; cursor: default; }
button:focus-visible, textarea:focus-visible, input:focus-visible, a:focus-visible, summary:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--cyan); outline-offset: -2px; }
#commit, #run, #help-open { background: var(--cyan); color: #071319; border-color: var(--cyan); font-weight: 700; }
#commit:hover:not(:disabled), #run:hover:not(:disabled), #help-open:hover:not(:disabled) { background: #85eee9; }
#commit[aria-pressed="true"] { background: #a5fff6; box-shadow: inset 0 0 0 2px #267b78; }
.legend { flex: 0 0 auto; border-top: 1px solid var(--line); margin: 0; padding: 5px 12px; color: var(--muted); font-size: var(--text-xs); line-height: 1.5; }
.legend span:not(:first-child) { margin-left: 10px; }
.cyan { color: var(--cyan); }
.amber { color: var(--amber); }
.console-panel { display: flex; flex-direction: column; }
.console-panel .panel-heading { flex-basis: 44px; }
#console-close { min-height: 32px; padding: 4px 10px; }
#console-output { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 12px; font: var(--text-base)/1.7 ui-monospace, monospace; background: #09121a; overflow-wrap: anywhere; }
#console-output p { margin: 0 0 8px; white-space: pre-wrap; }
.hint { color: var(--muted); }
.input-line { color: #77949f; }
.result { color: var(--cyan); }
.error-line { color: #ffad92; }
form { padding: 10px 12px; }
#repl-form { flex: 0 0 auto; border-top: 1px solid var(--line); }
label { display: block; color: var(--muted); font-size: var(--text-sm); margin-bottom: 6px; }
textarea { display: block; width: 100%; resize: none; height: 90px; border: 1px solid #354b59; border-radius: 3px; background: #071017; color: #e0eef4; font: 16px/1.5 ui-monospace, monospace; padding: 8px; }
.lua-editor { position: relative; }
#lua-input, #lua-highlight { font: 16px/1.5 ui-monospace, monospace; font-variant-ligatures: none; letter-spacing: normal; tab-size: 2; white-space: pre-wrap; overflow-wrap: anywhere; word-break: normal; }
#lua-highlight { position: absolute; inset: 0; margin: 0; padding: 8px; border: 1px solid transparent; border-radius: 3px; overflow: hidden; pointer-events: none; -webkit-user-select: none; user-select: none; color: #e0eef4; background: #071017; }
#lua-input { position: relative; }
#lua-input[data-highlighted="true"] { color: transparent; -webkit-text-fill-color: transparent; caret-color: #e0eef4; background: transparent; }
#lua-input::placeholder { color: var(--muted); -webkit-text-fill-color: var(--muted); }
#lua-input::selection { background: #5487b080; }
#lua-input[data-composing="true"] { color: #e0eef4; -webkit-text-fill-color: #e0eef4; background: #071017; }
.lua-keyword { color: #d8a0ef; }
.lua-string { color: #a5dda1; }
.lua-comment { color: #8a9eab; }
.lua-number { color: #ffba76; }
@media (forced-colors: active) {
  #lua-highlight { display: none; }
  #lua-input[data-highlighted="true"] { color: CanvasText; -webkit-text-fill-color: CanvasText; background: Canvas; caret-color: auto; }
}
.run-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 8px; font-size: var(--text-xs); color: var(--muted); }
details { flex: 0 1 auto; max-height: 35%; overflow: auto; overscroll-behavior: contain; padding: 10px 12px; border-top: 1px solid var(--line); font-size: var(--text-base); }
summary { cursor: pointer; }
.examples { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.examples button { font-size: var(--text-xs); padding: 6px 8px; }
details p { color: var(--muted); line-height: 1.7; font-size: var(--text-sm); margin-bottom: 0; }
#error { position: absolute; z-index: 3; inset: 12px 12px auto; max-height: calc(100% - 24px); overflow: auto; color: #ffad92; background: #211915; border: 1px solid #774839; margin: 0; padding: 12px; line-height: 1.6; }
.playback { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; flex: 0 1 440px; min-width: 0; }
.playback > button { padding-inline: 7px; white-space: nowrap; }
#toggle { min-width: 66px; }
.speed-buttons { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); flex: 1; min-width: 136px; }
.speed-buttons button { padding-inline: 4px; border-radius: 0; }
.speed-buttons button + button { margin-left: -1px; }
.speed-buttons button:first-child { border-radius: 3px 0 0 3px; }
.speed-buttons button:last-child { border-radius: 0 3px 3px 0; }
.speed-buttons button[aria-pressed="true"] { position: relative; border-color: var(--cyan); color: var(--cyan); background: #173b40; font-weight: 700; }
input { min-width: 0; color: #d8e4eb; background: #071017; border: 1px solid #354b59; border-radius: 3px; padding: 6px; min-height: 36px; font-size: 16px; }
.telemetry { grid-area: telemetry; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; padding: 10px 12px 4px; color: var(--muted); font: var(--text-xs) ui-monospace, monospace; }
.telemetry strong { display: block; margin-top: 5px; color: #d8e4eb; font-size: var(--text-base); font-weight: 500; line-height: 1.2; white-space: nowrap; overflow-x: auto; }
#burn-form { grid-area: burn; border-left: 1px solid var(--line); }
fieldset { padding: 0; margin: 0; border: 0; min-width: 0; }
fieldset:disabled { opacity: .55; }
legend { color: var(--muted); font-size: var(--text-sm); margin-bottom: 8px; }
.burn-inputs { display: flex; align-items: end; gap: 8px; }
.burn-inputs label { flex: 1; min-width: 0; margin: 0; }
.burn-inputs input { display: block; width: 100%; margin-top: 4px; font-family: ui-monospace, monospace; }
/* Reserve vector rows so changing digits cannot resize the tactical map. */
.telemetry .vector span { display: block; white-space: nowrap; overflow-x: auto; }
@container tactical (max-width: 850px) {
  .telemetry { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@container tactical (max-width: 600px) {
  .flight-controls { grid-template-columns: minmax(0, 1fr); grid-template-areas: 'transport' 'telemetry' 'burn'; }
  .transport { gap: 6px; padding: 6px 10px; }
  .command-row, .playback { flex-basis: 100%; }
  .speed-buttons { order: 1; flex-basis: 100%; }
  .buttons { flex-shrink: 0; gap: 5px; }
  .buttons button { padding: 6px 4px; }

  .telemetry { padding: 5px 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 10px; }
  .telemetry strong { margin-top: 3px; }
  #burn-form { border-left: 0; border-top: 1px solid var(--line); padding: 7px 10px; }
  .legend { display: none; }
}
@media (max-width: 900px) {
  .badge { display: none; }
  .workspace.console-open { grid-template-columns: minmax(0, 1fr); }
  .workspace.console-open .map-panel { visibility: hidden; }
  .console-panel { position: absolute; inset: 0; z-index: 2; }
}
@media (max-width: 480px) {
  header { gap: 8px; padding: 4px 8px; min-height: 48px; }
  .wordmark { font-size: var(--text-base); letter-spacing: .08em; }
  .mark { display: none; }
  .source { display: none; }
  #console-toggle { font-size: var(--text-sm); padding: 6px 8px; }
  #help-open { font-size: var(--text-sm); padding: 6px 8px; }
  header .wordmark { min-width: 0; white-space: normal; }
  main { padding: 4px; }
  .panel-heading { flex-basis: 32px; padding: 0 10px; }
}
.short-viewport header { min-height: 40px; padding-block: 2px; }
.short-viewport main { padding: 4px; }
.short-viewport .badge, .short-viewport .legend { display: none; }
.short-viewport .workspace.console-open { grid-template-columns: minmax(0, 1fr); }
.short-viewport .workspace.console-open .map-panel { visibility: hidden; }
.short-viewport .console-panel { position: absolute; inset: 0; z-index: 2; }
.short-viewport textarea { height: 60px; }
.short-viewport .console-panel details { display: none; }
.short-viewport .console-panel .panel-heading { flex-basis: 36px; }
.short-viewport .map-panel { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 340px); grid-template-rows: 30px auto minmax(0, 1fr); }
.short-viewport .map-toolbar > .panel-heading { grid-column: 1 / -1; }
.short-viewport .map-tools { grid-column: 1; grid-row: 2; }
.short-viewport .canvas-wrap { grid-column: 1; grid-row: 3; }
.short-viewport .flight-controls { grid-column: 2; grid-row: 2 / 4; border-top: 0; border-left: 1px solid var(--line); grid-template-columns: minmax(0, 1fr); grid-template-areas: 'transport' 'telemetry' 'burn'; align-content: start; }
.short-viewport .mission-active .map-panel { grid-template-rows: 30px auto minmax(0, 1fr) var(--timeline-height); }
.short-viewport .mission-active .flight-controls { grid-row: 2 / 5; }
.short-viewport #timeline-controls { grid-column: 1; grid-row: 4; grid-template-columns: 42px minmax(70px, 1fr) minmax(90px, 1fr); gap: 4px; }
.short-viewport .command-row, .short-viewport .playback { flex-basis: 100%; }
.short-viewport .speed-buttons { order: 1; flex-basis: 100%; }
.short-viewport .buttons { flex-shrink: 0; gap: 4px; }
.short-viewport .buttons button { padding: 4px; }
.short-viewport .telemetry { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 4px 10px; gap: 5px; }
.short-viewport .telemetry strong { margin-top: 2px; }
.short-viewport .transport { padding: 6px 10px; gap: 8px; }
.short-viewport #burn-form { border: 0; border-top: 1px solid var(--line); padding: 6px 10px; }
@media (max-width: 600px) {
  .short-viewport .map-panel { display: flex; }
  .short-viewport .flight-controls { flex: 1; border-left: 0; }
  .short-viewport .canvas-wrap { flex: 0 0 60px; }
}

#numeric-burn { max-height: none; padding: 8px 0 0; border: 0; overflow: visible; }
#numeric-burn summary { color: var(--muted); font-size: var(--text-sm); }
#numeric-burn fieldset { margin-top: 8px; }
/* Route handles share the Bevy map's world projection. */
#route-editor { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; touch-action: none; overflow: hidden; }
#arrival-handle { pointer-events: all; cursor: grab; }
#arrival-handle text { fill: var(--cyan); font: var(--text-xs) ui-monospace, monospace; pointer-events: none; }
.handle-hit { fill: transparent; }
.handle-dot { fill: var(--cyan); stroke: #071319; stroke-width: 2; }
#arrival-handle:focus-visible { outline: none; }
#arrival-handle:focus-visible .handle-dot { stroke: white; stroke-width: 3; }
.reach-area { pointer-events: all; cursor: crosshair; fill: #12403c30; stroke: #3e817c; }
#map-coast-route { fill: none; stroke: #8a9eab; stroke-dasharray: 5 5; }
#map-planned-route, #arrival-arrow { fill: none; stroke: var(--cyan); stroke-width: 2; }
#map-planned-route { stroke-dasharray: 1 5; stroke-linecap: round; }
#route-editor[data-invalid="true"] .handle-dot { fill: #ffad92; }
#route-editor[data-invalid="true"] #arrival-handle text { fill: #ffad92; }
.route-stats { display: grid; grid-template-columns: 1fr 1fr 2fr; gap: 8px; padding: 0; font: var(--text-xs) ui-monospace, monospace; color: var(--muted); }
.route-stats > div { min-width: 0; }
.route-stats > div > span { display: block; height: 2.4em; line-height: 1.2; }
.route-stats strong { display: block; height: 1.2em; margin-top: 4px; color: #d8e4eb; white-space: nowrap; overflow-x: auto; line-height: 1.2; font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
/* Keep two status lines in every phase, including empty/loading states. */
#route-feedback { height: 32px; overflow: auto; overscroll-behavior: contain; margin: 5px 0; font-size: var(--text-xs); line-height: 16px; color: var(--cyan); }
#route-feedback[data-invalid="true"] { color: #ffad92; }

@media (max-width: 480px) {
  .map-tools button { font-size: var(--text-xs); padding-inline: 5px; }
}
#burn-label, #forecast-boundaries text { fill: #a3b6c2; font: var(--text-xs) ui-monospace, monospace; pointer-events: none; }
#forecast-boundaries { pointer-events: none; }
#forecast-boundaries path { fill: none; stroke: var(--cyan); stroke-width: 1; }
#arrival-handle { outline: none; }

@media (max-width: 480px) { body[data-ready="true"] #railgun-label { display: none; } }

#burn-vector { fill: none; stroke: var(--amber); stroke-width: 2; pointer-events: none; }
#burn-label { fill: var(--amber); }

/* Presentation-clock pulse for each applied command, including coasting. */
#command-pulse { fill: none; stroke: #e0fff6; stroke-width: 2; pointer-events: none; }

.mission-active .flight-controls { grid-template-areas: 'transport transport' 'game game' 'mission mission' 'telemetry burn'; }
.mission-active .canvas-wrap { min-height: 160px; }
#mission-controls { grid-area: mission; padding: 7px 12px; border-bottom: 1px solid var(--line); min-width: 0; }
.mission-readout { display: flex; flex: 1; min-width: 0; flex-direction: column; gap: 4px; font: var(--text-sm) ui-monospace, monospace; white-space: nowrap; }
#mission-status, #mission-metrics { height: 1.2em; line-height: 1.2; overflow: auto; }
#mission-status { color: var(--amber); font-weight: 500; overflow: auto; }
#mission-status[data-outcome='timeout'], #mission-status[data-outcome='disabled'] { color: var(--cyan); }
#mission-metrics { color: var(--muted); font-size: var(--text-xs); }
.gun-buttons { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); max-width: 315px; gap: 5px; margin-top: 0; }
.gun-buttons button { min-width: 0; height: 44px; font-size: var(--text-sm); line-height: 16px; padding: 4px 6px; }
#queue-shot { border-color: var(--amber); color: #1c1208; background: var(--amber); font-weight: 700; }
#queue-shot:hover:not(:disabled) { border-color: #ffd09b; background: #ffd09b; }
#queue-shot { white-space: pre-line; }
#queue-shot[data-unreachable="true"]:disabled { opacity: 1; color: var(--amber); border-color: var(--amber); background: #30251a; }
#gun-feedback[data-invalid="true"] { color: #ffad92; }
#gun-feedback { height: 32px; overflow: auto; font: var(--text-xs)/16px ui-monospace, monospace; color: var(--muted); margin: 5px 0 0; }
#mission-overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; touch-action: none; overflow: hidden; }
#mission-overlay path, #mission-goal { fill: none; }
#mission-goal { stroke: #ff806c; stroke-width: 2; }
#goal-label { fill: #ff806c; }
#mission-overlay text { font: var(--text-xs) ui-monospace, monospace; }
#enemy-prediction { stroke: var(--amber); stroke-dasharray: 1 5; stroke-linecap: round; }
#mission-overlay #enemy-symbol { fill: #070f16; stroke: var(--amber); stroke-width: 2; }
#enemy-velocity { stroke: var(--amber); opacity: .55; stroke-width: 1.5; }
#enemy-acceleration { stroke: #ffe3ae; stroke-width: 2; }
#enemy-speed { fill: var(--amber); }
#enemy-motion { fill: var(--muted); }
#enemy-contact[data-motion="slowing"] #enemy-motion,
#enemy-contact[data-motion="speeding"] #enemy-motion,
#enemy-contact[data-motion="turning"] #enemy-motion { fill: #ffe3ae; }
#prediction-label { fill: var(--amber); }
#aim-line { stroke: #ddeaf3; stroke-dasharray: 4 7; opacity: .5; }
#queued-shot-line { stroke: #fff; stroke-dasharray: 8 4; }
#shot-paths path { stroke: #dcecf5; opacity: .6; stroke-dasharray: 3 5; }
#shot-labels text { fill: #fff; font-size: var(--text-sm); paint-order: stroke; stroke: #070f16; stroke-width: 3px; stroke-linejoin: round; }
#aim-handle { pointer-events: all; cursor: crosshair; outline: none; }
#aim-handle path, #aim-handle circle:not(.handle-hit) { fill: none; stroke: white; }
#aim-handle text { fill: white; pointer-events: none; }
#aim-grip { display: inline; }
#aim-handle #aim-grip circle { fill: #14232d; stroke: var(--amber); stroke-width: 2; }
#aim-grip .grip-link { opacity: .5; stroke-dasharray: 2 4; pointer-events: none; }
#aim-grip .grip-control { cursor: move; }
#aim-detail { position: absolute; top: var(--detail-edge); left: var(--detail-edge); width: clamp(120px, 38%, 240px); max-width: calc(100% - 2 * var(--detail-edge)); height: min(200px, calc(100% - 2 * var(--detail-edge))); display: flex; flex-direction: column; padding: 6px; border: 1px solid var(--amber); border-radius: 3px; background: #0b151e; pointer-events: none; overflow: hidden; }
.aim-detail-heading { flex: 0 0 32px; display: flex; flex-wrap: wrap; align-content: start; justify-content: space-between; gap: 0 4px; font: var(--text-xs)/1.3 ui-monospace, monospace; }
#aim-detail-note { color: var(--amber); }
#aim-detail-map { display: block; flex: 1; min-height: 0; width: 100%; overflow: hidden; }
#aim-detail-map path { fill: none; stroke-width: 1; }
#aim-detail-map .detail-grid { stroke: #354b59; stroke-dasharray: 2 4; }
#aim-detail-map .detail-shot { stroke: #ddeaf3; stroke-dasharray: 4 4; }
#aim-detail-map .detail-offset { stroke: var(--amber); stroke-dasharray: 2 3; opacity: .6; }
#aim-detail-map .detail-route { stroke: var(--amber); stroke-dasharray: 3 4; }
#aim-detail-map .detail-current { stroke: var(--amber); fill: var(--amber); }
#aim-detail-map .detail-enemy { stroke: var(--amber); stroke-width: 1.5; fill: #0b151e; stroke-dasharray: 3 2; }
#aim-detail-map .detail-current-label { fill: var(--amber); paint-order: stroke; stroke: #0b151e; stroke-width: 3px; }
#aim-detail-map .detail-crosshair { stroke: white; stroke-width: 1.5; }
#aim-detail-map .detail-scale { stroke: var(--muted); }
#aim-detail-map text { fill: var(--muted); font: var(--text-xs) ui-monospace, monospace; }
#aim-detail-offset { flex: 0 0 32px; color: var(--amber); font: var(--text-xs)/16px ui-monospace, monospace; overflow-wrap: anywhere; overflow: hidden; }
#arrival-contact path { stroke: var(--amber); stroke-dasharray: 3 3; }
#arrival-contact text { fill: var(--amber); paint-order: stroke; stroke: #070f16; stroke-width: 3px; stroke-linejoin: round; }
@media (max-width: 600px) { #arrival-contact text { display: none; } }
#aim-handle:focus-visible { outline: none; }
#aim-handle:focus-visible circle:not(.handle-hit) { stroke: var(--cyan); stroke-width: 3; }
@container tactical (max-width: 600px) {
  .mission-active .flight-controls { grid-template-areas: 'transport' 'game' 'mission' 'telemetry' 'burn'; }
  #mission-status, #mission-metrics { height: 2.4em; white-space: normal; }
  #mission-controls { padding: 6px 10px; }
}
.short-viewport .mission-active .flight-controls { grid-template-areas: 'transport' 'game' 'mission' 'telemetry' 'burn'; }
.short-viewport #mission-status, .short-viewport #mission-metrics { height: 2.4em; white-space: normal; }
@media (max-width: 600px) {
  .short-viewport .mission-active .canvas-wrap { min-height: 60px; }
}

#shot-ledger { display: grid; grid-template-columns: minmax(0, 1fr) 150px; gap: 8px; height: 84px; min-width: 0; margin-top: 6px; }
#shot-queue { display: flex; gap: 6px; min-width: 0; overflow: auto; align-items: center; }
#shot-history { display: flex; flex-direction: column; justify-content: center; min-width: 0; border-left: 1px solid var(--line); padding-left: 8px; font: var(--text-xs)/15px ui-monospace, monospace; }
#shot-history h3 { margin: 0 0 3px; font: var(--text-xs)/16px ui-monospace, monospace; color: var(--muted); text-transform: uppercase; }
#launch-list > div { white-space: nowrap; }
#empty-history { color: var(--muted); }
#empty-queue { color: var(--muted); font-size: var(--text-sm); }
.queued-shot { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; padding: 4px 6px; border: 1px solid var(--line); font: var(--text-xs)/16px ui-monospace, monospace; }
.queued-shot span { max-width: 180px; }
.queued-shot button { min-height: 40px; padding: 4px 8px; }
.queued-shot.invalid { color: #ffab70; }
#queued-shot-markers text { fill: #fff; font-size: var(--text-sm); }

/* Place game actions beside the result, between playback and weapon controls. */
#game-controls { grid-area: game; display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: #101e27; }
.retry-action { display: contents; }
#retry { min-width: 104px; min-height: 44px; padding: 10px 20px; font-size: var(--text-body); font-weight: 650; white-space: nowrap; color: #071319; background: var(--cyan); border-color: var(--cyan); }
#retry:hover:not(:disabled) { background: #85eee9; }

/* Keep the timeline attached to the map, with flight controls beside it on desktop.
   Query the panel width so opening the console can restore the stacked layout. */
@container tactical (min-width: 900px) {
  :root:not(.short-viewport) .map-toolbar { display: flex; flex: 0 0 auto; align-items: stretch; border-bottom: 1px solid var(--line); }
  :root:not(.short-viewport) .map-toolbar > .panel-heading { flex: 0 0 auto; gap: 16px; border-bottom: 0; }
  :root:not(.short-viewport) .map-toolbar > .map-tools { flex: 1; border-bottom: 0; border-left: 1px solid var(--line); }
}
@container tactical (min-width: 1000px) {
  :root:not(.short-viewport) .tactical-layout {
    --flight-sidebar-width: 540px;
    display: grid; flex: 1; min-height: 0; min-width: 0; position: relative;
    grid-template-columns: minmax(0, 1fr) var(--flight-sidebar-width);
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    grid-template-areas: 'toolbar controls' 'map controls' 'timeline controls' 'legend controls';
  }
  :root:not(.short-viewport) .map-toolbar { grid-area: toolbar; flex-wrap: wrap; }
  :root:not(.short-viewport) .canvas-wrap { grid-area: map; }
  :root:not(.short-viewport) #timeline-controls { grid-area: timeline; }
  :root:not(.short-viewport) .legend { grid-area: legend; }
  :root:not(.short-viewport) .flight-controls {
    grid-area: controls; grid-template-columns: minmax(0, 1fr);
    grid-template-areas: 'transport' 'telemetry' 'burn'; align-content: start;
    border-top: 0; border-left: 1px solid var(--line);
  }
  :root:not(.short-viewport) .mission-active .flight-controls { grid-template-areas: 'transport' 'game' 'mission' 'telemetry' 'burn'; }
  :root:not(.short-viewport) .mission-active .flight-controls { padding-bottom: 65px; scroll-padding-bottom: 73px; }
  :root:not(.short-viewport) #game-controls { display: contents; }
  :root:not(.short-viewport) .mission-readout { grid-area: game; padding: 8px 12px; background: #101e27; border-bottom: 1px solid var(--line); }
  :root:not(.short-viewport) .retry-action {
    position: absolute; right: 0; bottom: 0; z-index: 1; width: var(--flight-sidebar-width);
    display: flex; justify-content: flex-end; padding: 10px 12px;
    border-top: 1px solid var(--line); border-left: 1px solid var(--line); background: #101e27;
  }
  :root:not(.short-viewport) .transport { gap: 10px; }
  :root:not(.short-viewport) .command-row, :root:not(.short-viewport) .playback { flex-basis: 100%; }
  :root:not(.short-viewport) .speed-buttons { order: 1; flex-basis: 100%; }
  :root:not(.short-viewport) .gun-buttons { max-width: none; }
  :root:not(.short-viewport) #shot-ledger { grid-template-columns: minmax(0, 1fr); grid-template-rows: 128px 76px; height: 212px; }
  :root:not(.short-viewport) #shot-queue { flex-direction: column; align-items: stretch; }
  :root:not(.short-viewport) .queued-shot { justify-content: space-between; }
  :root:not(.short-viewport) .queued-shot span { max-width: none; }
  :root:not(.short-viewport) #shot-history { border-left: 0; border-top: 1px solid var(--line); padding: 6px 0 0; }
  :root:not(.short-viewport) #launch-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 3px 8px; }
  :root:not(.short-viewport) #gun-feedback { height: 48px; }
  :root:not(.short-viewport) #mission-status, :root:not(.short-viewport) #mission-metrics { height: 2.4em; white-space: normal; }
  :root:not(.short-viewport) .telemetry { grid-template-columns: repeat(2, minmax(0, 1fr)); padding-bottom: 10px; }
  :root:not(.short-viewport) #burn-form { border-left: 0; border-top: 1px solid var(--line); }
}

.canvas-wrap[data-navigating="true"], .canvas-wrap[data-navigating="true"] * { cursor: grabbing !important; }

#asteroid-map, #asteroid-forecast { stroke: #b4a38b; stroke-width: 1.5; fill: #514a3c; pointer-events: none; }
#asteroid-map text, #asteroid-forecast text { stroke: none; fill: #d8c9ae; font: var(--text-xs) ui-monospace, monospace; }
#asteroid-map .asteroid-route { fill: none; stroke-dasharray: 2 6; opacity: .65; }
#asteroid-map .asteroid-velocity { stroke: #d8c9ae; }
#asteroid-forecast .asteroid-velocity { opacity: .55; }
#asteroid-forecast circle { fill: #514a3c44; stroke-dasharray: 4 3; }
#cover-contact { fill: none; stroke: #ff8c80; stroke-width: 2; pointer-events: none; }
#cover-contact text { stroke: none; fill: #ff8c80; font: var(--text-xs) ui-monospace, monospace; }
#gun-feedback[data-cover="true"], #mission-status[data-outcome="own_disabled"] { color: #ff8c80; }
