:root {
    --ink: #eef4f3;
    --muted: #97aaa9;
    --panel: rgba(7, 15, 17, 0.88);
    --panel-soft: rgba(15, 27, 29, 0.72);
    --line: rgba(175, 218, 211, 0.18);
    --accent: #ffb44a;
    --accent-soft: rgba(255, 180, 74, 0.14);
    --hud: #b5ffd9;
    --danger: #ff625c;
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    min-width: 100%;
    min-height: 100%;
    background: #071012;
}

body {
    margin: 0;
    overflow: hidden;
    color: var(--ink);
    background: #071012;
    overscroll-behavior: none;
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
    font: inherit;
}

button {
    color: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

#game {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    width: 100dvw;
    height: 100dvh;
    display: flex;
    overflow: hidden;
    background: #030708;
    transition: filter 180ms ease, transform 180ms ease;
}

#game canvas {
    position: absolute;
    inset: 0;
    display: block;
    width: 100% !important;
    height: 100% !important;
}

#game.blurred {
    filter: blur(7px) brightness(38%) saturate(70%);
    transform: scale(1.012);
}

#background-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#interface-container {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    width: 100dvw;
    height: 100dvh;
    z-index: 30;
    display: flex;
    pointer-events: none;
}

#interface-container.fill {
    pointer-events: auto;
}

#interfaceBackground {
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    display: flex;
    width: 100%;
    height: 100%;
    background:
        linear-gradient(90deg, rgba(2, 9, 10, 0.2), rgba(2, 9, 10, 0.05)),
        radial-gradient(circle at 80% 10%, rgba(255, 180, 74, 0.07), transparent 38%);
}

#menuBar {
    min-width: 0;
    min-height: 0;
    overflow-y: auto;
    width: 276px;
    flex: 0 0 276px;
    display: flex;
    flex-direction: column;
    padding: 34px 22px 24px;
    color: var(--ink);
    background: rgba(4, 11, 13, 0.82);
    border-right: 1px solid var(--line);
    backdrop-filter: blur(18px);
}

#menuBar > h1 {
    margin: 0 10px 52px;
    max-width: 170px;
    font-size: 18px;
    font-weight: 720;
    line-height: 1.05;
    letter-spacing: 0.13em;
}

#menuBar > h1::before {
    content: "TFS / 01";
    display: block;
    margin-bottom: 12px;
    color: var(--accent);
    font: 700 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
    letter-spacing: 0.18em;
}

#menubarContainer {
    min-width: 0;
    min-height: 0;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.menuButton {
    flex-shrink: 0;
    position: relative;
    width: 100%;
    height: 50px;
    padding: 0 12px 0 28px;
    border: 0;
    border-left: 2px solid transparent;
    background: transparent;
    color: var(--muted);
    text-align: left;
    font-size: 12px;
    font-weight: 750;
    letter-spacing: 0.16em;
    cursor: pointer;
    transition: 140ms ease;
}

.menuButton::before {
    content: "";
    position: absolute;
    left: 11px;
    width: 5px;
    height: 5px;
    border: 1px solid currentColor;
    transform: rotate(45deg);
}

.menuButton:hover {
    color: var(--ink);
    border-left-color: var(--accent);
    background: linear-gradient(90deg, var(--accent-soft), transparent);
}

#contentPage {
    min-height: 0;
    touch-action: pan-x pan-y;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    min-width: 0;
    flex: 1;
    overflow: auto;
    scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}

.overview-page {
    width: min(760px, calc(100% - 80px));
    min-height: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 70px 0;
}

.eyebrow {
    color: var(--accent);
    font: 750 10px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
    letter-spacing: 0.18em;
}

.overview-page h2 {
    margin: 13px 0 20px;
    font-size: clamp(52px, 8vw, 108px);
    line-height: 0.9;
    letter-spacing: -0.065em;
}

.overview-page > p {
    max-width: 650px;
    margin: 0;
    color: #bcc9c8;
    font-size: 18px;
    line-height: 1.65;
}

.quick-start {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1px;
    margin: 44px 0 34px;
    border: 1px solid var(--line);
    background: var(--line);
}

.quick-start > div {
    min-height: 112px;
    padding: 20px;
    background: rgba(8, 17, 19, 0.78);
}

.quick-start span {
    display: block;
    margin-bottom: 15px;
    color: var(--muted);
    font: 700 9px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
    letter-spacing: 0.16em;
}

.quick-start strong {
    font-size: 12px;
    font-weight: 590;
    line-height: 2;
}

kbd {
    min-width: 25px;
    display: inline-block;
    margin-right: 4px;
    padding: 2px 6px;
    color: var(--ink);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-bottom-color: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
    text-align: center;
    font: 650 10px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.primary-button,
.secondary-button {
    width: fit-content;
    min-height: 46px;
    padding: 0 20px;
    border: 1px solid var(--accent);
    background: var(--accent);
    color: #111719;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.13em;
    cursor: pointer;
}

.primary-button:hover {
    background: #ffc36d;
}

.secondary-button {
    background: transparent;
    color: var(--ink);
    border-color: var(--line);
}

.secondary-button:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.overview-note {
    margin-top: 18px;
    color: var(--muted);
    font-size: 11px;
}

.performance-stats {
    display: none !important;
}

.performance-stats.visible {
    display: block !important;
    z-index: 20 !important;
}

/* Flight telemetry */
#flight-hud {
    position: absolute;
    inset: 0;
    z-index: 12;
    color: var(--hud);
    pointer-events: none;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    text-shadow: 0 0 8px rgba(88, 255, 179, 0.36);
    transition: opacity 120ms ease;
}

#flight-hud.hidden {
    opacity: 0;
}

#flight-experience {
    position: absolute;
    inset: 0;
    z-index: 16;
    color: var(--hud);
    pointer-events: none;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    text-shadow: 0 0 8px rgba(88, 255, 179, 0.35);
}

.flight-tutorial,
.flight-mission,
.flight-operations,
.replay-status,
.landing-report,
.performance-prompt,
.pause-panel {
    border: 1px solid rgba(181, 255, 217, 0.32);
    background: rgba(2, 12, 12, 0.74);
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.22);
    backdrop-filter: blur(8px);
}

.flight-tutorial,
.flight-mission {
    position: absolute;
    left: 50%;
    width: min(360px, calc(100% - 42px));
    padding: 11px 13px;
    transform: translateX(-50%);
}

.flight-tutorial { top: 58px; }
.flight-mission { top: 138px; border-color: rgba(255, 180, 74, 0.45); }

.flight-operations {
    position: absolute;
    right: 18px;
    bottom: 138px;
    width: min(270px, calc(100% - 36px));
    padding: 10px 11px;
    border: 1px solid rgba(181, 255, 217, 0.32);
    background: rgba(2, 12, 12, 0.72);
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.22);
    backdrop-filter: blur(8px);
    pointer-events: auto;
    font-size: 9px;
    letter-spacing: .08em;
}

.flight-operations > span,
.replay-status > span {
    display: block;
    color: var(--accent);
    font-size: 8px;
    font-weight: 800;
}

.flight-operations strong { display: block; margin-top: 4px; font-size: 12px; }
.flight-operations p { margin: 4px 0; color: rgba(218, 255, 234, .78); font-size: 9px; }
.flight-operations .radio-line { color: #e9ff86; font-size: 8px; line-height: 1.35; }
.flight-operations > div { display: flex; gap: 6px; }
.flight-operations button { margin-top: 4px !important; min-height: 24px !important; }

.replay-status {
    position: absolute;
    top: 92px;
    left: 50%;
    padding: 8px 12px;
    border: 1px solid rgba(255, 189, 85, .65);
    background: rgba(17, 10, 2, .7);
    transform: translateX(-50%);
    text-align: center;
}
.replay-status strong { display: block; margin-top: 4px; color: #ffe0a7; font-size: 10px; }

.flight-tutorial > span,
.flight-mission > span,
.landing-report > span,
.pause-panel > span,
.performance-prompt > span {
    display: block;
    margin-bottom: 5px;
    color: var(--accent);
    font-size: 8px;
    font-weight: 800;
    letter-spacing: 0.14em;
}

.flight-tutorial strong,
.flight-mission strong,
.landing-report strong,
.pause-panel strong,
.performance-prompt strong {
    display: block;
    font-size: 13px;
    letter-spacing: 0.08em;
}

.flight-tutorial p,
.flight-mission p,
.landing-report p,
.performance-prompt p {
    margin: 7px 0 0;
    color: rgba(218, 255, 234, 0.78);
    font-size: 10px;
    line-height: 1.4;
}

#flight-experience button {
    min-height: 28px;
    margin-top: 9px;
    padding: 0 9px;
    border: 1px solid rgba(181, 255, 217, 0.42);
    background: rgba(80, 159, 119, 0.16);
    color: var(--hud);
    font: 750 8px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
    letter-spacing: 0.08em;
    pointer-events: auto;
}

#flight-experience button:disabled { opacity: .38; }

.flight-pause-toggle {
    position: absolute;
    top: 17px;
    left: 17px;
    margin: 0 !important;
}

.flight-sound-toggle {
    position: absolute;
    top: 17px;
    left: 82px;
    margin: 0 !important;
}

.flight-event {
    position: absolute;
    top: 31%;
    left: 50%;
    padding: 7px 10px;
    border: 1px solid rgba(181, 255, 217, 0.4);
    background: rgba(2, 12, 12, 0.54);
    opacity: 0;
    transform: translate(-50%, -6px);
    transition: opacity 150ms ease, transform 150ms ease;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.1em;
}

.flight-event.active {
    opacity: 1;
    transform: translate(-50%, 0);
}

.landing-report,
.performance-prompt,
.pause-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    width: min(420px, calc(100% - 40px));
    padding: 18px;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: auto;
}

.landing-report strong { color: #e9ff86; font-size: 22px; }
.pause-panel strong { font-size: 20px; }
.performance-prompt { border-color: rgba(255, 180, 74, 0.55); }
.performance-prompt > div,
.pause-panel > div { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; }

.multiplayer-page { width: min(720px, 100%); }
.multiplayer-card {
    display: grid;
    gap: 12px;
    padding: 18px;
    border: 1px solid rgba(181, 255, 217, .34);
    background: rgba(2, 12, 12, .72);
}
.multiplayer-card label { display: grid; gap: 6px; color: var(--accent); font: 800 9px/1 ui-monospace, monospace; letter-spacing: .1em; }
.multiplayer-card input {
    min-height: 38px;
    padding: 0 10px;
    border: 1px solid rgba(181, 255, 217, .36);
    background: rgba(7, 24, 24, .85);
    color: var(--hud);
    font: 700 12px/1 ui-monospace, monospace;
    text-transform: uppercase;
}
.multiplayer-status { color: #e9ff86; font: 800 11px/1 ui-monospace, monospace; letter-spacing: .1em; }
.multiplayer-private { display: flex; gap: 8px; }
.multiplayer-card select { width: 100%; min-width: 0; min-height: 44px; background: #061b1b; color: #b5ffda; border: 1px solid #527e70; padding: 10px; }
.formation-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.formation-actions button { flex: 1 1 160px; min-height: 44px; }
.formation-actions button:disabled { opacity: .4; cursor: not-allowed; }
.aircraft-settings select { min-width: 0; max-width: 100%; min-height: 44px; padding: 8px; color: #b5ffda; background: #061b1b; border: 1px solid #527e70; font-size: 14px; }
.aircraft-settings p, .aircraft-settings small { color: #bdd6cc; line-height: 1.5; }
.aircraft-settings button:disabled { opacity: .45; cursor: not-allowed; }
.multiplayer-private input { min-width: 0; flex: 1; }
.multiplayer-card small { color: rgba(218,255,234,.72); font-size: 10px; line-height: 1.45; }

.tactical-map-page { width: min(980px, 100%); }
.tactical-map-layout { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 14px; }
.tactical-map-frame { position: relative; min-height: 440px; overflow: hidden; border: 1px solid rgba(181,255,217,.38); background: #041114; }
.tactical-map-frame canvas { width: 100%; height: 100%; min-height: 440px; display: block; }
.map-north, .map-range { position: absolute; padding: 5px 7px; border: 1px solid rgba(181,255,217,.32); background: rgba(2,12,12,.72); color: var(--hud); font: 800 9px/1 ui-monospace, monospace; letter-spacing: .1em; }
.map-north { top: 10px; left: 50%; transform: translateX(-50%); }
.map-range { right: 10px; bottom: 10px; }
.map-click-hint { position: absolute; left: 10px; bottom: 10px; padding: 5px 7px; color: rgba(218,255,234,.82); background: rgba(2,12,12,.72); border: 1px solid rgba(181,255,217,.24); font: 800 8px/1 ui-monospace, monospace; letter-spacing: .1em; pointer-events: none; }
.tactical-map-readout { display: grid; align-content: start; gap: 5px; padding: 13px; border: 1px solid rgba(181,255,217,.32); background: rgba(2,12,12,.72); }
.tactical-map-readout span { margin-top: 4px; color: var(--accent); font: 800 8px/1 ui-monospace, monospace; letter-spacing: .14em; }
.tactical-map-readout strong { color: #e9ff86; font: 800 12px/1.2 ui-monospace, monospace; letter-spacing: .08em; }
.tactical-map-readout p { margin: 0; color: rgba(218,255,234,.78); font: 700 9px/1.45 ui-monospace, monospace; }
.tactical-map-readout hr { width: 100%; margin: 8px 0; border: 0; border-top: 1px solid rgba(181,255,217,.2); }
.map-key { display: inline-block; width: 7px; height: 7px; margin-right: 3px; vertical-align: 1px; }
.map-key.own { background: #e9ff86; transform: rotate(45deg); }
.map-key.pilot { background: #78caff; transform: rotate(45deg); }
.map-key.airport { background: #78ffbb; }
.map-key.point { background: var(--accent); border-radius: 50%; }
.map-key.water { background: #1a557a; }
.map-key.lowland { background: #4d7443; }
.map-key.highland { background: #8c826e; }
.tactical-map-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.tactical-map-actions button { min-height: 34px; }
.tactical-map-actions .map-zoom { min-height: 34px; display: flex; align-items: center; gap: 7px; padding: 0 10px; border: 1px solid rgba(181,255,217,.28); color: var(--hud); background: rgba(7,28,27,.76); font: 800 9px/1 ui-monospace, monospace; letter-spacing: .1em; }
.tactical-map-actions .map-zoom input { width: 100px; accent-color: var(--accent); }
.tactical-map-actions .map-control-button { padding: 0 12px; border: 1px solid rgba(181,255,217,.44); background: rgba(10,45,39,.94) !important; color: var(--hud) !important; font: 800 10px/1 ui-monospace, monospace; letter-spacing: .1em; }
.tactical-map-actions .map-control-button:hover, .tactical-map-actions .map-control-button.active { border-color: var(--accent); background: rgba(89,59,17,.96) !important; color: #fff2cd !important; }
.tactical-map-actions .map-control-button:disabled { border-color: rgba(181,255,217,.16); background: rgba(7,20,20,.72) !important; color: rgba(181,255,217,.36) !important; cursor: not-allowed; }
@media (max-width: 760px) {
    .tactical-map-layout { grid-template-columns: 1fr; }
    .tactical-map-frame, .tactical-map-frame canvas { min-height: 330px; }
    .tactical-map-readout { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .tactical-map-readout hr { display: none; }
}

.mobile-top-controls {
    flex-wrap: wrap;
    justify-content: center;
    width: min(720px, calc(100% - 24px));
}

.hud-topline {
    position: absolute;
    top: 24px;
    left: 50%;
    width: min(620px, calc(100% - 48px));
    display: flex;
    justify-content: space-between;
    transform: translateX(-50%);
    font-size: 9px;
    letter-spacing: 0.13em;
}

.hud-mode i {
    display: inline-block;
    width: 5px;
    height: 5px;
    margin: 0 8px 1px 0;
    border-radius: 50%;
    background: var(--hud);
    box-shadow: 0 0 8px var(--hud);
}

.hud-mode b {
    font-weight: 600;
}

.hud-hint {
    opacity: 0.62;
}

.hud-readout {
    position: absolute;
    top: 50%;
    display: flex;
    flex-direction: column;
    transform: translateY(-50%);
}

.hud-speed {
    left: clamp(24px, 8vw, 120px);
    align-items: flex-end;
}

.hud-altitude {
    right: clamp(24px, 8vw, 120px);
}

.hud-readout strong {
    padding: 5px 10px;
    border: 1px solid rgba(181, 255, 217, 0.5);
    font-size: 31px;
    line-height: 1;
    font-weight: 500;
}

.hud-readout small,
.hud-label {
    margin: 6px 0;
    font-size: 9px;
    letter-spacing: 0.13em;
}

.hud-reticle {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 74px;
    height: 24px;
    border-top: 1px solid var(--hud);
    transform: translate(-50%, -50%);
}

.hud-reticle::before,
.hud-reticle::after {
    content: "";
    position: absolute;
    top: -1px;
    width: 10px;
    height: 8px;
    border-top: 1px solid var(--hud);
}

.hud-reticle::before {
    left: -10px;
    transform: rotate(-25deg);
    transform-origin: right top;
}

.hud-reticle::after {
    right: -10px;
    transform: rotate(25deg);
    transform-origin: left top;
}

.hud-reticle span {
    position: absolute;
    left: 50%;
    top: -5px;
    width: 9px;
    height: 9px;
    border: 1px solid var(--hud);
    border-radius: 50%;
    transform: translateX(-50%);
}

.hud-flight-state {
    position: absolute;
    bottom: 36px;
    left: 50%;
    display: flex;
    gap: 24px;
    padding: 8px 14px;
    border-top: 1px solid rgba(181, 255, 217, 0.4);
    transform: translateX(-50%);
    font-size: 9px;
    letter-spacing: 0.1em;
}

.hud-flight-state strong,
.hud-flight-state b {
    font-weight: 500;
}

.hud-engine,
.hud-nav,
.hud-systems {
    position: absolute;
    bottom: 26px;
    padding: 11px 13px;
    border: 1px solid rgba(181, 255, 217, 0.28);
    background: rgba(2, 12, 12, 0.34);
    backdrop-filter: blur(3px);
}

.hud-engine {
    left: 26px;
    width: 150px;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 4px 10px;
}

.hud-engine .hud-label {
    margin: 0;
    align-self: end;
}

.hud-engine > strong {
    grid-row: span 2;
    font-size: 26px;
    font-weight: 500;
    letter-spacing: -0.05em;
}

.hud-engine small {
    grid-column: 1 / -1;
    font-size: 8px;
    letter-spacing: 0.09em;
}

.hud-throttle-track {
    height: 3px;
    overflow: hidden;
    background: rgba(181, 255, 217, 0.18);
}

.hud-throttle-track i {
    display: block;
    width: 0;
    height: 100%;
    background: var(--hud);
    box-shadow: 0 0 8px var(--hud);
}

.hud-nav {
    top: 72px;
    right: 26px;
    bottom: auto;
    width: min(330px, 34vw);
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px 14px;
}

.hud-systems {
    right: 26px;
    width: min(390px, 38vw);
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px 14px;
}

.hud-nav span,
.hud-systems span {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.hud-nav small,
.hud-systems small {
    margin-bottom: 3px;
    opacity: 0.6;
    font-size: 7px;
    letter-spacing: 0.12em;
}

.hud-nav strong,
.hud-systems strong {
    overflow: hidden;
    font-size: 9px;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hud-caution {
    color: var(--danger);
}

.cockpit-mfds {
    position: absolute;
    bottom: 24px;
    left: 50%;
    display: none;
    grid-template-columns: repeat(2, minmax(210px, 260px));
    gap: 14px;
    padding: 13px;
    border: 1px solid rgba(181, 255, 217, 0.22);
    background: rgba(1, 8, 9, 0.72);
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.35), inset 0 0 30px rgba(32, 170, 112, 0.06);
    transform: translateX(-50%);
}

.cockpit-active .cockpit-mfds {
    display: grid;
}

.cockpit-active .hud-engine,
.cockpit-active .hud-nav,
.cockpit-active .hud-systems {
    display: none;
}

.mfd {
    min-height: 194px;
    padding: 8px;
    border: 2px solid rgba(181, 255, 217, 0.52);
    background: linear-gradient(135deg, rgba(5, 25, 20, 0.96), rgba(1, 10, 10, 0.98));
    box-shadow: inset 0 0 0 3px rgba(0, 0, 0, 0.56), inset 0 0 22px rgba(82, 255, 171, 0.08);
    color: #aef4cc;
    text-shadow: 0 0 5px rgba(88, 255, 179, 0.55);
}

.mfd header,
.mfd footer {
    display: flex;
    justify-content: space-between;
    font-size: 7px;
    letter-spacing: 0.14em;
}

.mfd header strong {
    font-weight: 700;
}

.mfd footer {
    margin-top: 5px;
    padding-top: 4px;
    border-top: 1px solid rgba(181, 255, 217, 0.32);
    opacity: 0.84;
}

.mfd-scope {
    position: relative;
    width: 132px;
    height: 118px;
    margin: 5px auto 2px;
    overflow: hidden;
    border: 1px solid rgba(181, 255, 217, 0.32);
    background: repeating-linear-gradient(0deg, transparent 0 28px, rgba(181, 255, 217, 0.08) 29px 30px), repeating-linear-gradient(90deg, transparent 0 32px, rgba(181, 255, 217, 0.07) 33px 34px);
}

.mfd-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    border: 1px solid rgba(181, 255, 217, 0.32);
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

.mfd-ring-outer { width: 92px; height: 92px; }
.mfd-ring-inner { width: 45px; height: 45px; }

.mfd-ownship {
    position: absolute;
    top: 50%;
    left: 50%;
    font-size: 19px;
    font-weight: 500;
    transform: translate(-50%, -57%);
}

.mfd-waypoint {
    position: absolute;
    width: 8px;
    height: 8px;
    border: 1px solid #e9ff86;
    background: rgba(233, 255, 134, 0.35);
    box-shadow: 0 0 8px rgba(233, 255, 134, 0.65);
    transform: translate(-50%, -50%) rotate(45deg);
}

.mfd-player-contacts, .hud-player-cues { position: absolute; inset: 0; pointer-events: none; }
.mfd-player-contact { position: absolute; width: 6px; height: 6px; border: 1px solid #78daff; background: #123f50; transform: translate(-50%, -50%); }
.mfd-player-contact.selected { background: #ffba50; border-color: #fff0a0; box-shadow: 0 0 0 2px #ffba5055; }
.hud-player-cue { position: absolute; padding: 15px 5px 2px; color: #9ee7ff; font: 600 10px/1.4 ui-monospace, monospace; white-space: pre; text-align: center; text-shadow: 0 1px 3px #000, 0 0 5px #000; transform: translateX(-50%); }
.hud-player-cue::before { content: ""; position: absolute; top: -6px; left: calc(50% - 6px); width: 10px; height: 10px; border: 1px solid currentColor; transform: rotate(45deg); }
.hud-player-cue.selected { color: #ffcf7d; }
.hud-player-target { position: absolute; top: 58px; left: 50%; max-width: calc(100% - 28px); transform: translateX(-50%); padding: 6px 10px; background: #021214c9; border: 1px solid #ffcf7d66; color: #ffcf7d; font: 600 10px/1.5 ui-monospace, monospace; white-space: pre-line; text-align: center; }
@media (pointer: coarse) {
    .hud-player-target { top: max(86px, calc(env(safe-area-inset-top) + 80px)); font-size: 9px; }
    .hud-player-cue { font-size: 9px; }
}

.mfd-north,
.mfd-east,
.mfd-south,
.mfd-west {
    position: absolute;
    font-size: 7px;
    opacity: 0.74;
}

.mfd-north { top: 3px; left: 50%; transform: translateX(-50%); }
.mfd-east { top: 50%; right: 3px; transform: translateY(-50%); }
.mfd-south { bottom: 3px; left: 50%; transform: translateX(-50%); }
.mfd-west { top: 50%; left: 3px; transform: translateY(-50%); }

.mfd-readout-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px 9px;
}

.mfd-readout-grid span {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.mfd-readout-grid small {
    font-size: 6px;
    letter-spacing: 0.12em;
    opacity: 0.62;
}

.mfd-readout-grid strong {
    overflow: hidden;
    font-size: 8px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mfd-engine-bar {
    position: relative;
    height: 118px;
    margin: 5px 9px 9px;
    border: 1px solid rgba(181, 255, 217, 0.28);
    background: repeating-linear-gradient(0deg, rgba(181, 255, 217, 0.08) 0 1px, transparent 1px 21px);
}

.mfd-engine-bar i {
    position: absolute;
    right: 9px;
    bottom: 5px;
    left: 9px;
    height: 0;
    background: linear-gradient(90deg, rgba(77, 211, 139, 0.35), #aef4cc);
    box-shadow: 0 0 10px rgba(88, 255, 179, 0.45);
    transition: height 80ms linear;
}

.mfd-engine-bar span,
.mfd-engine-bar strong {
    position: absolute;
    z-index: 1;
    top: 8px;
    left: 9px;
    font-size: 8px;
    letter-spacing: 0.12em;
}

.mfd-engine-bar strong {
    top: 22px;
    font-size: 28px;
    font-weight: 500;
    letter-spacing: -0.05em;
}

@media (max-width: 760px) {
    .cockpit-mfds {
        bottom: 12px;
        grid-template-columns: repeat(2, minmax(136px, 42vw));
        gap: 6px;
        padding: 6px;
    }

    .mfd { min-height: 152px; padding: 5px; }
    .mfd-scope { width: 92px; height: 76px; }
    .mfd-ring-outer { width: 60px; height: 60px; }
    .mfd-ring-inner { width: 28px; height: 28px; }
    .mfd-engine-bar { height: 76px; margin: 4px 4px 6px; }
    .mfd-engine-bar strong { font-size: 20px; }
}

.hud-warning {
    position: absolute;
    top: 28%;
    left: 50%;
    padding: 8px 12px;
    color: var(--danger);
    border: 1px solid transparent;
    transform: translateX(-50%);
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.13em;
}

.hud-callout {
    position: absolute;
    top: 35%;
    left: 50%;
    padding: 6px 10px;
    color: var(--hud);
    border: 1px solid transparent;
    transform: translateX(-50%);
    font-size: 11px;
    font-weight: 750;
    letter-spacing: 0.13em;
}

.hud-warning.active {
    border-color: currentColor;
    animation: warning-pulse 800ms steps(2, end) infinite;
}

.hud-callout.active {
    border-color: rgba(181, 255, 217, 0.42);
    background: rgba(2, 12, 12, 0.28);
}

@keyframes warning-pulse {
    50% { opacity: 0.4; }
}

@media (max-width: 760px) {
    #interfaceBackground {
        flex-direction: column;
    }

    #menuBar {
        width: 100%;
        flex: 0 0 auto;
        padding: 16px;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    #menuBar > h1 {
        max-width: none;
        margin: 0 8px 16px;
        font-size: 14px;
    }

    #menuBar > h1::before {
        display: inline;
        margin-right: 12px;
    }

    #menubarContainer {
        flex-direction: row;
        overflow-x: auto;
    }

    .menuButton {
        width: auto;
        min-width: max-content;
        padding: 0 13px;
    }

    .menuButton::before {
        display: none;
    }

    .overview-page {
        width: calc(100% - 36px);
        min-height: auto;
        padding: 48px 0;
    }

    .quick-start {
        grid-template-columns: 1fr;
    }

    .quick-start > div {
        min-height: 0;
    }

    .hud-hint,
    .hud-flight-state,
    .hud-nav,
    .hud-systems {
        display: none;
    }

    .hud-engine {
        bottom: 16px;
        left: 16px;
    }
}

#mobile-menu-section { display: none; }
.menuButton[aria-current="page"] { color: var(--accent); background: var(--accent-soft); border-left-color: var(--accent); }
@media (pointer: coarse), (max-width: 760px) {
    #interfaceBackground { flex-direction: column; }
    #menuBar {
        width: 100%; flex: 0 0 auto; overflow: hidden;
        padding: max(8px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left));
        border-right: 0; border-bottom: 1px solid var(--line);
    }
    #menuBar > h1 { margin: 0 0 8px; max-width: none; font-size: 13px; }
    #menuBar > h1::before { display: none; }
    #menubarContainer {
        flex-direction: row; width: 100%; max-width: 100%;
        overflow-x: auto; overflow-y: hidden;
        touch-action: pan-x; overscroll-behavior-x: contain;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }
    #menubarContainer .menuButton { flex: 0 0 auto; width: auto; min-width: max-content; min-height: 48px; padding: 0 14px; }
    #menubarContainer .menuButton::before { display: none; }
    #contentPage { flex: 1 1 0; width: 100%; padding-bottom: env(safe-area-inset-bottom); }
    #contentPage > * { max-width: 100%; }
}
@media (orientation: portrait) and (max-width: 900px) {
    #mobile-menu-section { display: block; width: 100%; min-height: 48px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; background: #102426; color: var(--ink); font-size: 16px; touch-action: manipulation; }
    #menubarContainer { display: none; }
}
@media (pointer: coarse) and (orientation: landscape) and (max-height: 500px) {
    #menuBar > h1 { display: none; }
}

/* Mobile flight controls */
.mobile-controls {
    --mobile-control: rgba(181, 255, 217, 0.72);
    --mobile-panel: rgba(3, 12, 14, 0.54);
    position: absolute;
    inset: 0;
    z-index: 18;
    display: none;
    overflow: hidden;
    color: var(--hud);
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    font: 700 9px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
    letter-spacing: 0.09em;
}

.mobile-controls.active {
    display: block;
}

.mobile-controls button,
.mobile-controls input,
.mobile-stick {
    pointer-events: auto;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
}

.mobile-controls button {
    min-width: 48px;
    min-height: 44px;
    padding: 0 10px;
    border: 1px solid rgba(181, 255, 217, 0.36);
    border-radius: 5px;
    background: var(--mobile-panel);
    color: var(--hud);
    box-shadow: inset 0 0 14px rgba(92, 255, 183, 0.035), 0 4px 18px rgba(0, 0, 0, 0.18);
    backdrop-filter: blur(5px);
    font-size: 8px;
    font-weight: 750;
    letter-spacing: 0.08em;
}

.mobile-controls button:active,
.mobile-controls button.pressed,
.mobile-controls button[aria-pressed="true"] {
    border-color: var(--hud);
    background: rgba(64, 143, 108, 0.45);
    box-shadow: 0 0 16px rgba(88, 255, 179, 0.22), inset 0 0 12px rgba(181, 255, 217, 0.12);
}

.mobile-top-controls {
    position: absolute;
    top: max(12px, env(safe-area-inset-top));
    left: 50%;
    display: flex;
    gap: 5px;
    transform: translateX(-50%);
    pointer-events: auto;
}

.mobile-top-controls button[hidden] {
    display: none;
}

.mobile-stick {
    position: absolute;
    width: clamp(124px, 19vw, 158px);
    height: clamp(124px, 19vw, 158px);
    border: 1px solid rgba(181, 255, 217, 0.32);
    border-radius: 50%;
    background: radial-gradient(circle, rgba(75, 145, 112, 0.08) 0 38%, rgba(2, 12, 13, 0.42) 39% 100%);
    box-shadow: inset 0 0 28px rgba(88, 255, 179, 0.055), 0 8px 30px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(3px);
}

.mobile-flight-stick {
    bottom: max(18px, env(safe-area-inset-bottom));
    left: max(18px, env(safe-area-inset-left));
}

.mobile-stick::before,
.mobile-stick::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    background: rgba(181, 255, 217, 0.17);
    transform: translate(-50%, -50%);
}

.mobile-stick::before {
    width: 74%;
    height: 1px;
}

.mobile-stick::after {
    width: 1px;
    height: 74%;
}

.mobile-stick-ring {
    position: absolute;
    inset: 26%;
    border: 1px dashed rgba(181, 255, 217, 0.25);
    border-radius: 50%;
}

.mobile-stick-knob {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 2;
    width: 42px;
    height: 42px;
    border: 1px solid var(--mobile-control);
    border-radius: 50%;
    background: rgba(34, 80, 64, 0.72);
    box-shadow: 0 0 18px rgba(88, 255, 179, 0.14);
    transform: translate(-50%, -50%);
}

.mobile-stick.pressed .mobile-stick-knob {
    background: rgba(73, 153, 117, 0.78);
}

.mobile-stick small {
    position: absolute;
    bottom: -15px;
    left: 50%;
    color: rgba(181, 255, 217, 0.7);
    font-size: 7px;
    transform: translateX(-50%);
}

.tilt-active .mobile-flight-stick {
    opacity: 0.65;
}
.tilt-active .mobile-flight-stick.pressed { opacity: 1; }

.mobile-rudder-controls {
    position: absolute;
    bottom: max(26px, calc(env(safe-area-inset-bottom) + 8px));
    left: max(155px, calc(env(safe-area-inset-left) + 144px));
    display: grid;
    gap: 6px;
    pointer-events: auto;
}

.mobile-wheel-brake {
    position: absolute;
    right: max(82px, calc(env(safe-area-inset-right) + 68px));
    bottom: max(26px, calc(env(safe-area-inset-bottom) + 8px));
}

.mobile-throttle {
    --mobile-throttle-height: clamp(190px, 54dvh, 360px);
    position: absolute;
    right: max(14px, env(safe-area-inset-right));
    bottom: max(20px, env(safe-area-inset-bottom));
    width: 88px;
    height: var(--mobile-throttle-height);
    box-sizing: border-box;
    touch-action: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 9px 5px 7px;
    border: 1px solid rgba(181, 255, 217, 0.3);
    border-radius: 5px;
    background: var(--mobile-panel);
    backdrop-filter: blur(5px);
    pointer-events: auto;
}

.mobile-throttle strong {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    font-size: 12px;
}

.mobile-throttle output {
    font-size: 18px;
}

.mobile-throttle > div {
    position: relative;
    width: 72px;
    flex: 1;
}

.mobile-throttle input {
    position: absolute;
    top: 50%;
    left: 50%;
    width: calc(var(--mobile-throttle-height) - 66px);
    height: 64px;
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    touch-action: none;
    margin: 0;
    accent-color: var(--hud);
    transform: translate(-50%, -50%) rotate(-90deg);
}
.mobile-throttle input::-webkit-slider-runnable-track { height: 12px; border-radius: 6px; background: #355b50; border: 1px solid #8cc8ae; }
.mobile-throttle input::-webkit-slider-thumb { -webkit-appearance: none; width: 40px; height: 56px; margin-top: -23px; border-radius: 10px; background: #ffb544; border: 3px solid #09211a; box-shadow: 0 0 0 1px #ffdc9b; }
.mobile-throttle input::-moz-range-track { height: 12px; border-radius: 6px; background: #355b50; border: 1px solid #8cc8ae; }
.mobile-throttle input::-moz-range-thumb { width: 34px; height: 50px; border-radius: 10px; background: #ffb544; border: 3px solid #09211a; }
.mobile-throttle input:focus-visible { outline: 2px solid #ffdc9b; outline-offset: 2px; }
.mobile-gyro-notice { padding: 10px 12px; background: #07171e; border: 1px solid #79bba3; color: #bcffe0; font-size: 14px; line-height: 1.4; }

.mobile-orientation-message {
    display: none;
}

@media (pointer: coarse) {
    #game,
    #game canvas {
        touch-action: none;
    }

    .hud-hint,
    .hud-flight-state,
    .hud-engine,
    .hud-nav,
    .hud-systems {
        display: none;
    }

    .hud-topline {
        top: max(62px, calc(env(safe-area-inset-top) + 56px));
        width: auto;
    }

    .hud-readout {
        top: 38%;
    }

    .hud-speed {
        left: max(12px, env(safe-area-inset-left));
    }

    .hud-altitude {
        right: max(12px, env(safe-area-inset-right));
    }

    .hud-readout strong {
        padding: 4px 7px;
        font-size: 22px;
    }

    .flight-tutorial { top: max(62px, calc(env(safe-area-inset-top) + 56px)); }
    .flight-mission { top: max(132px, calc(env(safe-area-inset-top) + 126px)); }
    .flight-tutorial,
    .flight-mission { width: min(290px, calc(100% - 30px)); }
    .flight-pause-toggle { top: max(14px, env(safe-area-inset-top)); left: max(14px, env(safe-area-inset-left)); }
    .flight-sound-toggle { top: max(14px, env(safe-area-inset-top)); left: max(79px, calc(env(safe-area-inset-left) + 65px)); }
}

@media (pointer: coarse) and (max-height: 600px) {
    .cockpit-mfds {
        display: none !important;
    }
}

@media (orientation: portrait) and (pointer: coarse) {
    .mobile-orientation-message {
        position: absolute;
        top: 50%;
        left: 50%;
        display: block;
        width: min(310px, calc(100% - 48px));
        padding: 11px;
        border: 1px solid rgba(181, 255, 217, 0.36);
        background: rgba(2, 10, 12, 0.72);
        text-align: center;
        transform: translate(-50%, -50%);
    }
}

@media (max-width: 680px) and (orientation: landscape) {
    .mobile-controls button {
        min-width: 42px;
        padding: 0 7px;
        font-size: 7px;
    }

    .mobile-stick {
        width: 116px;
        height: 116px;
    }

    .mobile-rudder-controls {
        left: max(130px, calc(env(safe-area-inset-left) + 120px));
    }

    .mobile-wheel-brake {
        right: max(70px, calc(env(safe-area-inset-right) + 58px));
    }

    .mobile-throttle {
        width: 88px;
    }
}
#game ~ .crash-recovery, .crash-recovery {
    position: fixed;
    z-index: 25;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(560px, calc(100vw - 40px));
    max-height: calc(100dvh - 40px);
    overflow: auto;
    box-sizing: border-box;
    padding: 24px;
    background: #07171e;
    color: #bcffe0;
    border: 1px solid #79bba3;
    font: 16px/1.5 monospace;
    pointer-events: auto;
}
.crash-recovery[hidden] { display: none; }
.recovery-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0; }
.recovery-actions button { min-height: 48px; padding: 10px 16px; background: #153a3d; color: #bcffe0; border: 1px solid #79bba3; cursor: pointer; font: inherit; }
.recovery-actions button:disabled { opacity: .45; cursor: not-allowed; }
.recovery-actions button:focus-visible { outline: 3px solid #ffb544; outline-offset: 3px; }
.race-status { position: fixed; top: 18%; left: 50%; transform: translateX(-50%); z-index: 17; max-width: 85vw; text-align: center; color: #ffcf80; background: #06171ecc; padding: 6px 12px; font: 14px/1.4 monospace; pointer-events: none; }
.lightning-cockpit .cockpit-mfds { gap: 0; padding: 8px; border-color: #91b8c7; }
.lightning-cockpit .mfd { border-width: 1px; border-color: #547986; color: #c0eef6; }
.mobile-controls .mobile-wheel-brake { right: max(110px, calc(env(safe-area-inset-right) + 100px)); }
.hud-telemetry {
    position: absolute; left: 18px; top: 76px; width: 215px;
    display: flex; flex-direction: column; gap: 5px;
    padding: 8px; background: #04141099; border: 1px solid #8ac5a855;
    font-size: 12px; line-height: 1.4; box-sizing: border-box;
}
.hud-attitude { position: absolute; left: 18px; top: 192px; width: 120px; height: 64px; overflow: hidden; border: 1px solid #8ac5a855; border-radius: 6px; background: #04141066; text-align: center; }
.hud-attitude::before { content: 'ATT'; position: absolute; top: 2px; left: 4px; font-size: 10px; }
.hud-attitude::after { content: '— • —'; position: absolute; top: 25px; left: 30px; color: #ffcf80; }
.hud-attitude > div { position: absolute; width: 100%; top: 25px; font-size: 11px; }
.hud-flight-path { position: absolute; transform: translate(-50%, -50%); font-size: 28px; line-height: 1; color: #baffdb; }
.hud-flight-path[hidden] { display: none; }
@media (pointer: coarse), (max-height: 600px) {
    .hud-telemetry { top: auto; bottom: max(8px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); width: min(270px, calc(100vw - 330px)); font-size: 10px; gap: 2px; padding: 4px; }
    .hud-attitude { display: none; }
}
@media (max-width: 500px) {
    .hud-telemetry { bottom: 200px; width: calc(100vw - 32px); }
}
@media (pointer: coarse) {
    /* Leave room beside the taller throttle for the altitude readout. */
    .hud-altitude { right: max(112px, calc(env(safe-area-inset-right) + 104px)); }
}

/* One bounded, flowing notice area, separate from instruments and touch controls. */
#flight-notice-dock {
    position: fixed;
    z-index: 17;
    top: max(58px, calc(env(safe-area-inset-top) + 44px));
    left: 50%;
    transform: translateX(-50%);
    width: min(380px, calc(100vw - 560px));
    max-height: 28dvh;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: var(--hud);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    overscroll-behavior: contain;
}
#flight-notice-dock > * {
    position: static;
    transform: none;
    flex: 0 0 auto;
    width: 100%;
    max-width: none;
    box-sizing: border-box;
    margin: 0;
    overflow-wrap: anywhere;
    white-space: normal;
    pointer-events: auto;
}
#flight-notice-dock > [hidden],
#flight-notice-dock :is(.flight-event, .hud-warning, .hud-callout):not(.active),
body:has(#flight-hud.hidden) #flight-notice-dock :is(.hud-warning, .hud-callout, .hud-player-target) { display: none; }
#flight-notice-dock .hud-warning { order: -5; background: #170a08; }
#flight-notice-dock .hud-callout { order: -4; }
#flight-notice-dock .race-status { order: -3; }
#flight-notice-dock .replay-status { order: -2; }
#flight-notice-dock .flight-event { order: -1; }
#flight-notice-dock button {
    min-height: 32px;
    padding: 6px 12px;
    margin-top: 8px;
    border: 1px solid #79bba3;
    background: #153a3d;
    color: var(--hud);
    cursor: pointer;
}
/* Training is still available after racing/replay, but never competes with them. */
#flight-notice-dock:has(.race-status:not([hidden])) :is(.flight-tutorial, .flight-mission),
#flight-notice-dock:has(.replay-status:not([hidden])) :is(.flight-tutorial, .flight-mission) { display: none; }

/* Show one dialog at a time: crash > pause > landing > performance suggestion. */
body:has(.crash-recovery:not([hidden])) #flight-experience,
body:has(.pause-panel:not([hidden])) :is(.landing-report, .performance-prompt),
body:has(.landing-report:not([hidden])) .performance-prompt,
body:has(.replay-status:not([hidden])) :is(.landing-report, .performance-prompt) { display: none; }
body:not(:has(.replay-status:not([hidden]))):has(:is(.crash-recovery, .pause-panel, .landing-report, .performance-prompt):not([hidden])) :is(#flight-notice-dock, #flight-hud, .mobile-controls, .flight-operations, .dg),
body.flight-menu-open :is(#flight-notice-dock, #flight-hud, #flight-experience, .mobile-controls, .crash-recovery, .dg) { visibility: hidden; pointer-events: none; }
.landing-report, .pause-panel, .performance-prompt {
    box-sizing: border-box;
    max-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 32px);
    overflow: auto;
    overscroll-behavior: contain;
}
/* Debug sun controls should not cover navigation during normal play. */
body:not(.flight-menu-open) .dg.ac { display: none; }
@media (max-width: 700px), (pointer: coarse) {
    #flight-notice-dock {
        top: max(92px, calc(env(safe-area-inset-top) + 86px));
        width: min(340px, calc(100vw - 180px));
        max-height: 24dvh;
    }
    .flight-operations { display: none; }
}
@media (max-width: 420px) {
    #flight-notice-dock { width: calc(100vw - 32px); max-height: 20dvh; }
}
