/* Google Fonts loaded via <link> in Index.html to avoid render-blocking @import */

:root {
    --hud-primary: #00ff88;
    --hud-amber: #ffcc00;
    --hud-red: #ff4444;
    --hud-orange: #ff8800;
    --hud-bg: rgba(0, 10, 6, 0.88);
    --hud-border: rgba(0, 255, 136, 0.3);
    --hud-border-bright: rgba(0, 255, 136, 0.7);
    --hud-glow: 0 0 8px rgba(0, 255, 136, 0.35), 0 0 20px rgba(0, 255, 136, 0.12);
    --text-glow: 0 0 5px rgba(0, 255, 136, 0.65);
}

/* ── Splash Screen ─────────────────────────────────────────────── */
#splash-screen {
    position: fixed;
    inset: 0;
    background: #060a06;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 1;
    transition: opacity 1s ease;
}

#splash-title {
    font-family: 'Orbitron', sans-serif;
    font-size: clamp(2rem, 7vw, 7rem);
    font-weight: 900;
    color: #00ff88;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    text-shadow:
        0 0 20px rgba(0, 255, 136, 0.9),
        0 0 60px rgba(0, 255, 136, 0.4),
        0 0 120px rgba(0, 255, 136, 0.15);
    min-height: 1.3em;
    opacity: 1;
    transition: opacity 0.6s ease;
    white-space: nowrap;
}

#splash-subtitle {
    font-family: 'Share Tech Mono', 'Courier New', monospace;
    font-size: clamp(0.7rem, 1.6vw, 1.4rem);
    color: rgba(0, 255, 136, 0.65);
    letter-spacing: 0.2em;
    margin-top: 2.5em;
    min-height: 1.4em;
    white-space: nowrap;
}

#splash-prompt {
    font-family: 'Share Tech Mono', 'Courier New', monospace;
    font-size: clamp(0.6rem, 1.2vw, 1rem);
    color: rgba(0, 255, 136, 0.4);
    letter-spacing: 0.3em;
    margin-top: 4em;
    animation: blink 1.1s step-end infinite;
}

#splash-cursor {
    display: inline-block;
    width: 0.55em;
    height: 1em;
    background: #00ff88;
    vertical-align: text-bottom;
    animation: blink 0.75s step-end infinite;
    box-shadow: 0 0 8px rgba(0, 255, 136, 0.8);
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0; }
}

body {
    margin: 0;
    overflow: hidden;
    background-color: #111;
    font-family: 'Share Tech Mono', 'Courier New', monospace;
    transition: background-color 0.05s;
    cursor: none;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.ui-overlay {
    position: absolute;
    top: 10px;
    color: var(--hud-primary);
    background-color: var(--hud-bg);
    padding: 10px 14px;
    font-size: 12px;
    font-family: 'Share Tech Mono', 'Courier New', monospace;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    z-index: 10;
    border: 1px solid var(--hud-border);
    border-top: 2px solid var(--hud-border-bright);
    box-shadow: var(--hud-glow);
    text-shadow: var(--text-glow);
    line-height: 1.8;
}

.ui-overlay strong {
    color: var(--hud-amber);
    text-shadow: 0 0 5px rgba(255, 204, 0, 0.6);
}

#instructions {
    left: 10px;
    max-width: 215px;
    top: 90px;
    font-size: 11px;
}

#player-stats {
    left: 10px;
    top: 10px;
    display: flex;
    align-items: center;
    white-space: nowrap;
}

#score-display, #level-display, #xp-display {
    margin-left: 16px;
}

#hp-display {
    color: var(--hud-amber);
    text-shadow: 0 0 5px rgba(255, 204, 0, 0.6);
}

#target-info {
    right: 10px;
    text-align: right;
}

#right-panel {
    position: absolute;
    bottom: 10px;
    right: 10px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}

#right-panel > .ui-overlay {
    position: static;
}

#map-constraints {
    text-align: right;
}

.rate-row {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 3px;
    margin-top: 2px;
}

.rate-label {
    width: 10px;
    text-align: center;
    font-size: 10px;
    color: var(--hud-dim);
    flex-shrink: 0;
}

.rate-val {
    font-size: 10px;
    color: var(--hud-dim);
    width: 46px;
    text-align: right;
    flex-shrink: 0;
    font-family: monospace;
}

.rate-track {
    width: 55px;
    height: 6px;
    background: rgba(0, 255, 136, 0.08);
    border: 1px solid rgba(0, 255, 136, 0.2);
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
}

.rate-track-wide {
    width: 116px;
}

.rate-fill {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 0%;
    background: var(--hud-primary);
    transition: width 0.05s linear;
}

.rate-fill-neg {
    left: auto;
    right: 0;
    background: #ff6633;
}

.rate-fill-speed {
    background: #44aaff;
}

#debug-info {
    text-align: right;
    font-size: 11px;
    line-height: 1.8;
}

#minimap-container {
    position: absolute;
    bottom: 10px;
    left: 10px;
    width: min(400px, 42vmin);
    height: min(400px, 42vmin);
    background-color: rgba(0, 20, 10, 0.75);
    border: 2px solid var(--hud-border-bright);
    border-radius: 50%;
    z-index: 10;
    overflow: hidden;
    box-shadow: var(--hud-glow);
}

#minimap {
    width: 100%;
    height: 100%;
}

#conquered-panel {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: fit-content;
    max-width: 38vw;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
#conquered-panel:not(:has(.has-content)) {
    display: none;
}

.cpanel-row {
    display: none;
    align-items: center;
    gap: 6px;
}
.cpanel-row.has-content {
    display: flex;
}

.cpanel-label {
    flex-shrink: 0;
    font-size: 9px;
    opacity: 0.55;
    letter-spacing: 0.08em;
    color: var(--hud-primary);
}

.cpanel-scroll-wrap {
    flex: 1;
    min-width: 140px;
    overflow: hidden;
    white-space: nowrap;
}

.cpanel-scroll {
    display: inline-block;
    white-space: nowrap;
}

.conquered-entry {
    display: inline-block;
    margin: 0 8px;
    color: var(--hud-amber);
    text-shadow: 0 0 5px rgba(255, 204, 0, 0.6);
    animation: entry-in 0.5s ease-out both;
}

#row2-scroll .conquered-entry {
    color: var(--hud-primary);
    text-shadow: var(--text-glow);
}

#row3-scroll .conquered-entry {
    color: var(--hud-orange);
    text-shadow: 0 0 5px rgba(255, 136, 0, 0.6);
}

#row4-scroll .conquered-entry {
    color: #00ccff;
    text-shadow: 0 0 5px rgba(0, 204, 255, 0.6);
}

@keyframes entry-in {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes conquered-ticker {
    0%, 12%   { transform: translateX(0); }
    88%, 100% { transform: translateX(var(--ticker-dist, 0)); }
}

/* ── Ammo HUD (bottom-center) ──────────────────────────────────── */
#ammo-hud {
    position: absolute;
    bottom: 18px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: var(--hud-bg);
    border: 1px solid var(--hud-border);
    border-top: 2px solid var(--hud-border-bright);
    box-shadow: var(--hud-glow);
    padding: 8px 14px;
    font-family: 'Share Tech Mono', 'Courier New', monospace;
    font-size: 11px;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    z-index: 10;
    white-space: nowrap;
}

.ammo-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ammo-label {
    width: 36px;
    color: var(--hud-amber);
    text-shadow: 0 0 5px rgba(255, 204, 0, 0.6);
}

.ammo-track {
    width: 140px;
    height: 8px;
    background: rgba(0, 255, 136, 0.08);
    border: 1px solid var(--hud-border);
    overflow: hidden;
}

.ammo-fill {
    height: 100%;
    width: 100%;
    background: var(--hud-primary);
    box-shadow: 0 0 4px rgba(0, 255, 136, 0.6);
    transition: width 0.08s linear, background 0.15s;
}

.ammo-status {
    min-width: 52px;
    text-align: right;
    color: var(--hud-primary);
    text-shadow: var(--text-glow);
    font-size: 10px;
    transition: color 0.15s;
}

#paused {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--hud-primary);
    background-color: rgba(0, 12, 6, 0.92);
    padding: 30px 50px;
    font-size: 36px;
    font-weight: bold;
    font-family: 'Share Tech Mono', 'Courier New', monospace;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    text-align: center;
    z-index: 20;
    display: none;
    border: 1px solid var(--hud-border);
    border-top: 2px solid var(--hud-border-bright);
    box-shadow: var(--hud-glow);
    text-shadow: var(--text-glow);
}
#game-over {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--hud-red);
    background-color: rgba(8, 0, 0, 0.92);
    padding: 30px 50px;
    font-size: 36px;
    font-weight: bold;
    font-family: 'Share Tech Mono', 'Courier New', monospace;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    text-align: center;
    z-index: 20;
    display: none;
    border: 1px solid rgba(255, 68, 68, 0.45);
    border-top: 2px solid rgba(255, 68, 68, 0.85);
    box-shadow: 0 0 20px rgba(255, 68, 68, 0.35), 0 0 40px rgba(255, 68, 68, 0.12);
    text-shadow: 0 0 10px rgba(255, 68, 68, 0.85);
}

.kill-notif {
    position: fixed;
    right: 10px;
    background-color: var(--hud-bg);
    color: var(--hud-orange);
    padding: 10px 20px;
    font-family: 'Share Tech Mono', 'Courier New', monospace;
    font-size: 16px;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    z-index: 1000;
    pointer-events: none;
    border: 1px solid rgba(255, 136, 0, 0.35);
    border-left: 4px solid var(--hud-orange);
    white-space: nowrap;
    transition: transform 6s linear, opacity 1.2s ease-in 4.5s;
}

.kill-notif.eliminated {
    border-left-color: var(--hud-red);
    color: var(--hud-red);
    text-shadow: 0 0 5px rgba(255, 68, 68, 0.65);
}

.kill-notif.slide {
    transform: translateX(calc(-100vw - 600px));
    opacity: 0;
}

.congrats-banner {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.85);
    background-color: rgba(0, 12, 6, 0.95);
    color: var(--hud-amber);
    padding: 24px 52px;
    font-family: 'Share Tech Mono', 'Courier New', monospace;
    font-size: 26px;
    font-weight: bold;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    text-align: center;
    z-index: 1100;
    pointer-events: none;
    border: 1px solid rgba(255, 204, 0, 0.4);
    border-top: 3px solid rgba(255, 204, 0, 0.85);
    box-shadow: 0 0 20px rgba(255, 204, 0, 0.3), 0 0 50px rgba(255, 204, 0, 0.1);
    text-shadow: 0 0 10px rgba(255, 204, 0, 0.8);
    opacity: 0;
    transition: transform 0.35s ease-out, opacity 0.35s ease-out;
}

.congrats-banner.visible {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.congrats-banner.fade-out {
    opacity: 0;
    transition: opacity 0.7s ease-in;
}

/* ── Hit-confirm crosshair (idea 4) ───────────────────────────── */
#hit-marker {
    position: fixed;
    top: 50%; left: 50%;
    width: 40px; height: 40px;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 500;
    opacity: 0;
    transition: opacity 0.12s ease-out;
}

.hit-line {
    position: absolute;
    background: #ff3333;
    box-shadow: 0 0 4px rgba(255, 50, 50, 0.8);
}

.hit-line.hit-top    { width: 2px; height: 10px; top: 2px;  left: 50%; transform: translateX(-50%); }
.hit-line.hit-bottom { width: 2px; height: 10px; bottom: 2px; left: 50%; transform: translateX(-50%); }
.hit-line.hit-left   { height: 2px; width: 10px; left: 2px;  top: 50%; transform: translateY(-50%); }
.hit-line.hit-right  { height: 2px; width: 10px; right: 2px; top: 50%; transform: translateY(-50%); }

/* ── Memory / entity debug (idea 10) ─────────────────────────── */
#memory-debug {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 10px;
    line-height: 1.6;
    min-width: 130px;
    display: none;
}
#memory-debug.active { display: block; }

/* ── Tube ribbon reward (ideas 7-9) ──────────────────────────── */
.tube-ribbon {
    position: fixed;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.85);
    background-color: rgba(0, 12, 20, 0.95);
    color: #00ccff;
    padding: 22px 48px;
    font-family: 'Share Tech Mono', 'Courier New', monospace;
    font-size: 24px;
    font-weight: bold;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    text-align: center;
    z-index: 1100;
    pointer-events: none;
    border: 1px solid rgba(0, 204, 255, 0.4);
    border-top: 3px solid rgba(0, 204, 255, 0.85);
    box-shadow: 0 0 20px rgba(0, 204, 255, 0.35), 0 0 50px rgba(0, 204, 255, 0.12);
    text-shadow: 0 0 10px rgba(0, 204, 255, 0.9);
    opacity: 0;
    transition: transform 0.35s ease-out, opacity 0.35s ease-out;
    white-space: nowrap;
}
.tube-ribbon.visible {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}
.tube-ribbon.fade-out {
    opacity: 0;
    transition: opacity 0.7s ease-in;
}

/* ── Steering cursor (mouse-aim reticle) ─────────────────────── */
#steer-cursor {
    position: fixed;
    display: none;
    width: 22px;
    height: 22px;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 200;
    border: 1.5px solid rgba(0, 255, 136, 0.85);
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(0, 255, 136, 0.35);
}
#steer-cursor .sc-line {
    position: absolute;
    background: rgba(0, 255, 136, 0.9);
}
#steer-cursor .sc-h {
    width: 7px;
    height: 1.5px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}
#steer-cursor .sc-v {
    width: 1.5px;
    height: 7px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* ── Narrow / short viewports: keep the essentials, drop reference panels ── */
@media (max-width: 900px), (max-height: 620px) {
    #instructions, #debug-info, #map-constraints { display: none; }
    #conquered-panel { max-width: 60vw; }
}
@media (max-width: 900px) {
    #player-stats { flex-wrap: wrap; white-space: normal; max-width: 50vw; row-gap: 2px; }
    #score-display, #level-display, #xp-display { margin-left: 0; margin-right: 12px; }
    #target-info { font-size: 10px; }
    /* minimap takes the bottom-left corner; move ammo to the bottom-right */
    #minimap-container { width: min(400px, 38vmin); height: min(400px, 38vmin); }
    #ammo-hud { left: auto; right: 10px; transform: scale(0.72); transform-origin: bottom right; }
}

/* ── Menus: start, pause, game over, settings ─────────────────── */
[hidden] { display: none !important; }
body.menu-open, body.menu-open * { cursor: auto; }
body.menu-open button, body.menu-open summary, body.menu-open input { cursor: pointer; }
.menu-screen {
    position: fixed;
    inset: 0;
    z-index: 800;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 20px;
    background: rgba(0, 8, 4, 0.8);
    color: var(--hud-primary);
    font-family: 'Share Tech Mono', 'Courier New', monospace;
    text-align: center;
    text-shadow: var(--text-glow);
}
#settings-dialog { z-index: 900; background: rgba(0, 8, 4, 0.92); overflow-y: auto; justify-content: flex-start; }
/* Centred while it fits, scrollable when it does not (phones in landscape) */
#settings-dialog > :first-child { margin-top: auto; }
#settings-dialog > :last-child { margin-bottom: auto; }
body.touch #settings-dialog { gap: 8px; }
#start-title {
    margin: 0;
    font-family: 'Orbitron', sans-serif;
    font-size: clamp(2rem, 7vw, 4.5rem);
    letter-spacing: 0.2em;
    text-transform: uppercase;
}
#settings-title { margin: 0 0 6px; letter-spacing: 0.15em; text-transform: uppercase; }
.menu-sub { margin: 0; color: var(--hud-amber); font-size: 14px; }
.menu-buttons { display: flex; flex-direction: column; gap: 10px; min-width: 220px; margin-top: 12px; }
.menu-buttons.menu-row { flex-direction: row; justify-content: center; }
.menu-buttons button {
    font-family: inherit;
    font-size: 18px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--hud-primary);
    background: rgba(0, 30, 16, 0.9);
    border: 1px solid var(--hud-border-bright);
    padding: 10px 18px;
    text-shadow: var(--text-glow);
}
.menu-buttons button:hover, .menu-buttons button:focus-visible,
.menu-screen input:focus-visible, .menu-controls summary:focus-visible {
    background: rgba(0, 255, 136, 0.18);
    outline: 2px solid var(--hud-amber);
    outline-offset: 2px;
}
.menu-hint { margin-top: 8px; font-size: 12px; letter-spacing: 0.05em; opacity: 0.75; text-transform: none; }
.menu-controls { max-width: min(600px, 92vw); font-size: 13px; text-align: left; line-height: 1.6; }
.menu-controls summary { text-align: center; font-size: 15px; }
#settings-dialog label { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-width: min(340px, 90vw); font-size: 15px; }
#settings-dialog input[type="range"] { width: 160px; accent-color: #00ff88; }
#settings-dialog input[type="checkbox"] { width: 18px; height: 18px; accent-color: #00ff88; }

/* Settings → hide the reference panels */
body.hide-reference #instructions, body.hide-reference #debug-info, body.hide-reference #map-constraints { display: none; }

/* Respect reduced-motion preferences: no scrolling tickers, banner slides or splash fades */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
/* Settings opened from the pause menu: hide the panel underneath instead of showing it through */
body:has(#settings-dialog:not([hidden])) #paused { visibility: hidden; }

/* ── Mission objective (game/mission.js) ───────────────────────── */
#objective { position: absolute; top: auto; left: 50%; bottom: 140px; height: auto; transform: translateX(-50%); padding: 6px 14px; text-align: center; white-space: nowrap; font-size: 13px; }
#objective-arrow { display: inline-block; margin-right: 8px; color: var(--hud-amber); transition: transform 0.1s linear; }
.objective-label { text-transform: uppercase; opacity: 0.75; }
#objective-name { color: var(--hud-amber); }
#objective-kicker, #objective-bar { display: none; }
/* Map chooser (ui/mapPicker.js) */
.map-pick { display: flex; gap: 14px; align-items: center; justify-content: center; margin: 12px auto 4px; padding: 10px 12px; max-width: 460px; border: 1px solid var(--hud-border, rgba(0,255,120,0.35)); border-radius: 8px; background: rgba(0, 20, 12, 0.55); }
.map-pick[hidden] { display: none; }
.map-preview { width: 132px; height: 132px; border-radius: 50%; border: 2px solid var(--hud-border-bright, #2f8); box-shadow: 0 0 10px rgba(0, 255, 120, 0.25); flex: none; }
.map-info { text-align: left; min-width: 0; }
.map-kicker { font-size: 10px; letter-spacing: 0.2em; opacity: 0.7; text-transform: uppercase; }
.map-name { font: bold 18px 'Orbitron', 'Share Tech Mono', sans-serif; color: var(--hud-amber, #ffb000); }
.map-meta { font-size: 11px; opacity: 0.8; margin: 2px 0 6px; }
.map-row { display: flex; gap: 6px; margin-top: 4px; }
.map-row button { padding: 4px 9px; font-size: 12px; }
.map-seed input { width: 120px; padding: 3px 6px; font: inherit; font-size: 12px; background: rgba(0,0,0,0.4); color: inherit; border: 1px solid rgba(0,255,120,0.35); border-radius: 4px; }
@media (max-width: 520px) { .map-pick { flex-direction: column; } .map-info { text-align: center; } .map-row { justify-content: center; } }
#objective.quest { border-color: rgba(255, 210, 58, 0.55); box-shadow: 0 0 14px rgba(255, 170, 0, 0.25); }
#objective.quest #objective-kicker { display: block; font-size: 10px; letter-spacing: 0.16em; color: #ffd23a; text-transform: uppercase; margin-bottom: 2px; }
#objective.quest #objective-name { color: #fff2b0; font-weight: bold; }
#objective.quest #objective-bar { display: block; height: 3px; margin: 4px 0 2px; background: rgba(255, 210, 58, 0.18); }
#objective.quest #objective-bar div { height: 100%; background: #ffd23a; box-shadow: 0 0 6px #ffd23a; transition: width 0.3s; }
.objective-progress { font-size: 11px; opacity: 0.8; }
#game-over.victory { color: var(--hud-amber); border-color: rgba(255, 204, 0, 0.6); text-shadow: 0 0 10px rgba(255, 204, 0, 0.85); }

/* ── Threat readability (ui/threats.js) ────────────────────────── */
#hit-indicators { position: fixed; inset: 0; pointer-events: none; z-index: 450; }
.hit-arc {
    position: absolute; top: 50%; left: 50%;
    width: min(44vh, 360px); height: min(44vh, 360px);
    border-radius: 50%;
    border-top: 6px solid rgba(255, 40, 40, 0.9);
    transform: translate(-50%, -50%) rotate(var(--bearing, 0rad));
    filter: drop-shadow(0 0 6px #ff2222);
    opacity: 0;
    transition: opacity 0.35s ease-out;
}
#flight-warning {
    position: fixed; top: 30%; left: 50%; transform: translateX(-50%);
    z-index: 400; pointer-events: none;
    color: var(--hud-red); font: bold 22px 'Share Tech Mono', 'Courier New', monospace; letter-spacing: 0.2em;
    text-shadow: 0 0 10px rgba(255, 68, 68, 0.9);
    animation: flight-warning-blink 0.8s steps(1) infinite;
}
@keyframes flight-warning-blink { 50% { opacity: 0.25; } }
body.menu-open #flight-warning, body.menu-open #objective, body.menu-open #hit-indicators { display: none; }

/* Kill confirmation: the hit marker flashes gold and larger */
#hit-marker.kill { transform: translate(-50%, -50%) scale(1.4); }
#hit-marker.kill .hit-line { background: #ffcc00; box-shadow: 0 0 6px rgba(255, 204, 0, 0.9); }

#settings-dialog select { font: inherit; color: var(--hud-primary); background: rgba(0, 30, 16, 0.9); border: 1px solid var(--hud-border-bright); padding: 4px 8px; }
@media (max-width: 900px) { #objective { bottom: 110px; font-size: 11px; } }

/* ── Ace rival (entities/rival.js, ui/rivalHud.js) ─────────────── */
:root { --ace: #ff33cc; }
#rival-panel { right: 10px; top: 124px; min-width: 210px; border-color: rgba(255, 51, 204, 0.35); border-top-color: rgba(255, 51, 204, 0.85); }
#rival-panel.engaged { box-shadow: 0 0 14px rgba(255, 51, 204, 0.45); }
.rival-head { color: var(--ace); text-shadow: 0 0 6px rgba(255, 51, 204, 0.7); white-space: nowrap; }
.rival-tier { margin-left: 6px; padding: 0 5px; font-size: 10px; border: 1px solid currentColor; opacity: 0.85; }
.rival-hp-track { height: 6px; margin: 6px 0 4px; background: rgba(255, 68, 68, 0.35); }
#rival-hp-bar { height: 100%; width: 100%; background: var(--ace); transition: width 0.15s linear; }
.rival-row { white-space: nowrap; }
#rival-arrow { display: inline-block; margin-right: 6px; color: var(--ace); transition: transform 0.1s linear; }
#rival-warning {
    position: fixed; top: 35%; left: 50%; transform: translateX(-50%);
    z-index: 400; pointer-events: none; white-space: nowrap;
    color: var(--ace); font: bold 18px 'Share Tech Mono', 'Courier New', monospace; letter-spacing: 0.18em;
    text-shadow: 0 0 10px rgba(255, 51, 204, 0.9);
    animation: flight-warning-blink 0.4s steps(1) infinite;
}
.rival-banner {
    position: fixed; top: 16%; left: 50%; transform: translateX(-50%);
    z-index: 500; pointer-events: none; white-space: nowrap;
    padding: 8px 22px; background: var(--hud-bg);
    font: bold 17px 'Share Tech Mono', 'Courier New', monospace; letter-spacing: 0.15em; text-transform: uppercase;
    border: 1px solid currentColor; border-left-width: 4px;
    animation: rival-banner-in 0.3s ease-out;
}
.rival-banner.threat { color: var(--ace); text-shadow: 0 0 10px rgba(255, 51, 204, 0.8); }
.rival-banner.alert { color: var(--hud-orange); text-shadow: 0 0 10px rgba(255, 136, 0, 0.8); }
.rival-banner.win { color: var(--hud-amber); text-shadow: 0 0 10px rgba(255, 204, 0, 0.8); }
@keyframes rival-banner-in { from { opacity: 0; transform: translateX(-50%) scale(0.85); } }
body.menu-open #rival-panel, body.menu-open #rival-warning, body.menu-open .rival-banner { display: none; }

/* Start menu: Ace AI segmented toggle */
.skill-toggle { display: flex; align-items: center; gap: 0; margin-top: 4px; }
.skill-toggle-label { margin-right: 10px; color: var(--ace); font-size: 14px; letter-spacing: 0.1em; text-transform: uppercase; }
.skill-toggle button {
    font: inherit; font-size: 14px; letter-spacing: 0.1em; text-transform: uppercase;
    color: var(--hud-primary); background: rgba(0, 30, 16, 0.9);
    border: 1px solid var(--hud-border-bright); padding: 6px 14px; margin-left: -1px;
}
.skill-toggle button[aria-pressed="true"] { color: #000; background: var(--ace); border-color: var(--ace); text-shadow: none; }
.skill-toggle button:hover, .skill-toggle button:focus-visible { outline: 2px solid var(--hud-amber); outline-offset: 2px; position: relative; }
@media (max-width: 900px) { #rival-panel { top: 100px; min-width: 0; font-size: 10px; } }

/* ── Touch controls (ui/touch.js) — only with body.touch ───────── */
#touch-controls { position: fixed; inset: 0; z-index: 30; pointer-events: none; user-select: none; -webkit-user-select: none; }
#touch-controls button, .tc-wheel { pointer-events: auto; touch-action: none; -webkit-tap-highlight-color: transparent; }
#touch-controls button {
    font: bold 12px 'Share Tech Mono', 'Courier New', monospace; letter-spacing: 0.06em;
    color: var(--hud-primary); background: rgba(0, 20, 10, 0.55); border: 1.5px solid var(--hud-border-bright); border-radius: 50%;
}
#touch-controls button.held, #touch-controls button:active { background: rgba(0, 255, 136, 0.35); color: #000; }
.tc-wheel {
    position: absolute; bottom: 20px; width: 150px; height: 150px; border-radius: 50%;
    background: rgba(0, 20, 10, 0.35); border: 1.5px solid var(--hud-border);
}
.tc-left { left: max(20px, env(safe-area-inset-left)); }
.tc-right { right: max(20px, env(safe-area-inset-right)); }
.tc-knob {
    position: absolute; left: 50%; top: 50%; width: 62px; height: 62px; margin: -31px 0 0 -31px; border-radius: 50%;
    background: rgba(0, 255, 136, 0.3); border: 2px solid var(--hud-primary); pointer-events: none;
}
.tc-right .tc-knob { background: rgba(255, 204, 0, 0.25); border-color: var(--hud-amber); }
.tc-hint { position: absolute; font: 9px 'Share Tech Mono', 'Courier New', monospace; letter-spacing: 0.1em; color: var(--hud-primary); opacity: 0.55; pointer-events: none; }
.tc-right .tc-hint { color: var(--hud-amber); }
.tc-up { top: 6px; left: 50%; transform: translateX(-50%); }
.tc-down { bottom: 6px; left: 50%; transform: translateX(-50%); }
.tc-left-hint { left: 8px; top: 50%; transform: translateY(-50%); }
/* Weapons sit above and beside the right wheel, where the right thumb can slide to them */
.tc-weapons { position: absolute; right: max(20px, env(safe-area-inset-right)); bottom: 184px; display: flex; gap: 8px; }
.tc-weapons button { width: 50px; height: 50px; }
.tc-weapons .tc-gun {
    position: fixed; right: calc(max(20px, env(safe-area-inset-right)) + 162px); bottom: 26px;
    width: 88px; height: 88px; font-size: 15px !important; border-width: 2px !important;
}
.tc-weapons [data-tap="laser"] { border-radius: 10px; width: 58px; }
#touch-controls .tc-weapons [aria-pressed="true"] { color: #000; background: rgba(0, 255, 136, 0.75); }
.tc-system { position: absolute; top: 8px; right: max(10px, env(safe-area-inset-right)); display: flex; gap: 8px; }
.tc-system button { width: 44px; height: 44px; border-radius: 8px !important; font-size: 15px !important; }
.tc-system [data-tap="tilt"] { width: 58px; font-size: 12px !important; }
.tc-system [aria-pressed="true"] { background: var(--hud-primary) !important; color: #000 !important; }
.tc-rotate { display: none; }
/* Menus own the screen; the overlay only shows while flying */
body.menu-open #touch-controls .tc-wheel, body.menu-open #touch-controls .tc-weapons { display: none; }
/* Tilt steering: the phone does pitch and roll; their wheel directions lock (ui/touch.js applyLayout) */
#touch-controls .tc-wheel.tc-off { display: none; }
.tc-wheel.tc-narrow { width: 90px; border-radius: 45px; }
/* Settings → Touch wheels (touch devices only) */
.tc-layout { border: 1px solid var(--hud-border); border-radius: 6px; margin: 6px 0; padding: 4px 10px 8px; }
.tc-layout legend { font-size: 11px; letter-spacing: 0.1em; color: var(--hud-amber); }
.tc-layout label { display: flex; justify-content: space-between; gap: 10px; margin-top: 4px; }
.tc-system .tc-level { display: none; width: 58px; font-size: 11px !important; }
body.tilt-on .tc-system .tc-level { display: block; }
/* Motion indicator (ui/motionIndicator.js): ball = pitch/roll rate, bar = yaw rate, gauge = airspeed */
#motion-indicator { position: absolute; left: calc(50% - 250px); bottom: 26px; z-index: 12; display: flex; align-items: flex-end; gap: 8px; pointer-events: none; opacity: 0.9; }
.mi-ring { position: relative; width: 60px; height: 60px; border-radius: 50%; border: 1.5px solid var(--hud-border-bright); background: var(--hud-bg); }
.mi-cross { position: absolute; inset: 29px 6px; border-top: 1px solid var(--hud-border); }
.mi-cross::after { content: ''; position: absolute; left: 23px; top: -24px; height: 46px; border-left: 1px solid var(--hud-border); }
.mi-ball { position: absolute; left: 24px; top: 24px; width: 12px; height: 12px; border-radius: 50%; background: var(--hud-primary); box-shadow: 0 0 6px var(--hud-primary); }
.mi-yaw { position: absolute; left: 0; right: 0; bottom: -9px; height: 4px; }
.mi-yaw div { width: 12px; height: 4px; margin: 0 auto; background: var(--hud-amber); }
.mi-thr { width: 8px; height: 60px; border: 1px solid var(--hud-amber); background: var(--hud-bg); display: flex; align-items: flex-end; }
.mi-thr div { width: 100%; background: var(--hud-amber); }
body.menu-open #motion-indicator { display: none; }
body.touch #motion-indicator { left: 50%; bottom: 22px; transform: translateX(-50%); }
@media (max-width: 900px) { body:not(.touch) #motion-indicator { left: 10px; bottom: auto; top: 50%; } }
/* Declutter the HUD around the thumbs: stats + minimap top-left, ammo top-centre, no reference panels */
body.touch { touch-action: none; overscroll-behavior: none; }
body.touch #instructions, body.touch #debug-info, body.touch #map-constraints, body.touch #target-info { display: none; }
body.touch #player-stats { font-size: 10px; padding: 4px 8px; max-width: 45vw; }
body.touch #hp-display { margin-right: 12px; }
body.touch #minimap-container { top: 44px; bottom: auto; left: 8px; width: 30vmin; height: 30vmin; }
body.touch #ammo-hud { top: 4px; bottom: auto; left: 50%; right: auto; transform: translateX(-50%) scale(0.55); transform-origin: top center; }
body.touch #objective { bottom: auto; top: 64px; font-size: 10px; pointer-events: auto; cursor: pointer; }
/* Compact objective (phones): arrow, name, distance; tap to expand */
body.touch #objective.compact { padding: 3px 10px; font-size: 9px; }
body.touch #objective.compact .objective-label, body.touch #objective.compact #objective-units, body.touch #objective.compact .obj-sep, body.touch #objective.compact .objective-progress { display: none; }
body.touch #objective.compact #objective-name { max-width: 30vw; overflow: hidden; text-overflow: ellipsis; display: inline-block; vertical-align: bottom; }
body.touch #rival-panel { top: 60px; font-size: 10px; min-width: 0; }
@media (orientation: portrait) {
    body.touch .tc-rotate {
        display: block; position: fixed; left: 50%; top: 40%; transform: translateX(-50%); padding: 10px 18px;
        font: 16px 'Share Tech Mono', 'Courier New', monospace; color: var(--hud-amber); background: var(--hud-bg); border: 1px solid currentColor;
    }
}

/* Combo meter (ui/comboHud.js): multiplier, draining window, close-kill flash */
#combo-meter { position: fixed; top: 24%; left: 50%; transform: translateX(-50%); z-index: 120; pointer-events: none; text-align: center;
    font: bold 20px 'Share Tech Mono', 'Courier New', monospace; letter-spacing: 0.12em; color: #ffdd00; text-shadow: 0 0 8px #ff8800, 0 0 18px rgba(255, 136, 0, 0.6); }
#combo-meter[hidden] { display: none; }
#combo-meter.solo .cm-multi, #combo-meter.solo .cm-bar { display: none; }
#combo-meter .cm-bar { width: 150px; height: 4px; margin: 5px auto 0; background: rgba(255, 221, 0, 0.18); border-radius: 2px; overflow: hidden; }
#combo-meter .cm-bar div { height: 100%; background: linear-gradient(90deg, #ff8800, #ffdd00); box-shadow: 0 0 6px #ffaa00; }
#combo-meter[data-level="4"], #combo-meter[data-level="5"] { color: #ff6a3d; text-shadow: 0 0 10px #ff2200, 0 0 22px rgba(255, 60, 0, 0.7); }
#combo-meter.bump .cm-multi { animation: combo-bump 0.35s ease-out; }
#combo-meter .cm-close { margin-top: 4px; font-size: 13px; color: #9ff; opacity: 0; text-shadow: 0 0 8px #0cf; }
#combo-meter .cm-close.flash { animation: combo-close 1.6s ease-out; }
@keyframes combo-bump { from { transform: scale(1.6); } }
@keyframes combo-close { 0% { opacity: 1; transform: scale(1.3); } 70% { opacity: 1; transform: none; } 100% { opacity: 0; } }
body.menu-open #combo-meter, body.menu-open #lead-marker { display: none; }
@media (prefers-reduced-motion: reduce) { #combo-meter.bump .cm-multi, #combo-meter .cm-close.flash { animation-duration: 0.01s; } }

/* Freaky mode (ui/bossHud.js): start-menu toggle, alert banner, vignette, boss HP frame */
.freaky-toggle { margin-top: 6px; font: 15px 'Share Tech Mono', 'Courier New', monospace; letter-spacing: 0.1em; text-transform: uppercase; color: #c9a0ff;
    background: rgba(30, 0, 40, 0.6); border: 1px solid rgba(201, 160, 255, 0.5); border-radius: 4px; padding: 6px 14px; cursor: pointer; }
.freaky-toggle[aria-pressed="true"] { color: #000; background: #c9a0ff; box-shadow: 0 0 14px rgba(201, 160, 255, 0.7); }
.freaky-toggle:focus-visible { outline: 2px solid var(--hud-amber); outline-offset: 2px; }
#boss-frame { --boss: #ff4848; position: fixed; top: 64px; left: 50%; transform: translateX(-50%); z-index: 110; width: min(560px, 62vw); pointer-events: none;
    padding: 6px 12px 7px; background: rgba(10, 0, 4, 0.72); border: 1px solid var(--boss); border-top-width: 3px; border-radius: 4px;
    box-shadow: 0 0 18px color-mix(in srgb, var(--boss) 45%, transparent); font-family: 'Share Tech Mono', 'Courier New', monospace; color: #fff; }
#boss-frame[hidden] { display: none; }
#boss-frame .bf-head { display: flex; align-items: baseline; gap: 10px; white-space: nowrap; overflow: hidden; }
#boss-frame .bf-skull { color: var(--boss); font-size: 17px; text-shadow: 0 0 8px var(--boss); }
#boss-frame .bf-name { font: bold 17px 'Orbitron', 'Share Tech Mono', sans-serif; letter-spacing: 0.12em; color: var(--boss); text-shadow: 0 0 10px var(--boss); }
#boss-frame .bf-title { font-size: 11px; opacity: 0.75; overflow: hidden; text-overflow: ellipsis; flex: 1; }
#boss-frame .bf-dist { font-size: 12px; color: var(--hud-amber); }
#boss-frame .bf-arrow { display: inline-block; margin-right: 4px; transition: transform 0.15s linear; }
#boss-frame .bf-bar { position: relative; height: 14px; margin-top: 5px; background: rgba(255, 255, 255, 0.07); border: 1px solid rgba(255, 255, 255, 0.35); overflow: hidden;
    background-image: repeating-linear-gradient(90deg, transparent 0 calc(10% - 1px), rgba(0, 0, 0, 0.55) calc(10% - 1px) 10%); }
#boss-frame .bf-lag { position: absolute; inset: 0 auto 0 0; background: rgba(255, 255, 255, 0.85); }
#boss-frame .bf-fill { position: absolute; inset: 0 auto 0 0; background: linear-gradient(180deg, color-mix(in srgb, var(--boss) 70%, #fff), var(--boss) 55%, color-mix(in srgb, var(--boss) 60%, #000));
    box-shadow: 0 0 10px var(--boss); }
#boss-frame .bf-bar::after { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0 calc(10% - 1px), rgba(0, 0, 0, 0.5) calc(10% - 1px) 10%); }
#boss-frame .bf-mark { position: absolute; left: 50%; top: -2px; bottom: -2px; width: 2px; background: #ffdd33; box-shadow: 0 0 6px #ffdd33; z-index: 2; }
#boss-frame .bf-foot { display: flex; justify-content: space-between; margin-top: 3px; font-size: 11px; letter-spacing: 0.1em; }
#boss-frame .bf-phase { color: var(--boss); font-weight: bold; }
#boss-frame.enraged { animation: boss-enraged 0.6s ease-in-out infinite alternate; }
#boss-frame.enraged .bf-phase { animation: boss-blink 0.5s steps(2) infinite; }
@keyframes boss-enraged { to { box-shadow: 0 0 30px var(--boss), inset 0 0 12px color-mix(in srgb, var(--boss) 50%, transparent); } }
@keyframes boss-blink { 50% { opacity: 0.25; } }
#boss-alert { --boss: #ff4848; position: fixed; top: 30%; left: 50%; transform: translateX(-50%); z-index: 520; pointer-events: none; text-align: center;
    font-family: 'Share Tech Mono', 'Courier New', monospace; animation: boss-alert-in 0.45s cubic-bezier(.2, 1.6, .4, 1); white-space: nowrap; }
#boss-alert[hidden] { display: none; }
#boss-alert .ba-kicker { font-size: 15px; letter-spacing: 0.4em; color: #ffdd33; text-shadow: 0 0 10px #ff8800; animation: boss-blink 0.6s steps(2) 5; }
#boss-alert .ba-name { font: 900 clamp(26px, 6vw, 56px) 'Orbitron', 'Share Tech Mono', sans-serif; letter-spacing: 0.08em; color: var(--boss);
    text-shadow: 0 0 12px var(--boss), 0 0 34px var(--boss), 0 3px 0 #000; }
#boss-alert .ba-line { margin-top: 4px; font-size: 16px; letter-spacing: 0.15em; text-transform: uppercase; color: #fff; text-shadow: 0 0 8px #000, 0 0 2px #000; }
#boss-alert.boss-alert-defeat .ba-name { color: #ffdd33; text-shadow: 0 0 14px #ff8800, 0 0 34px #ff8800, 0 3px 0 #000; }
@keyframes boss-alert-in { from { opacity: 0; transform: translateX(-50%) scale(1.8); } }
#boss-vignette { --boss: #ff4848; position: fixed; inset: 0; z-index: 90; pointer-events: none; opacity: 0;
    box-shadow: inset 0 0 120px 30px var(--boss); }
#boss-vignette.on { animation: boss-vignette 1.2s ease-in-out infinite; }
@keyframes boss-vignette { 0%, 100% { opacity: 0; } 50% { opacity: 0.75; } }
body.menu-open #boss-frame, body.menu-open #boss-alert, body.menu-open #boss-vignette { display: none; }
body.touch #boss-frame { top: 52px; width: min(420px, 56vw); padding: 4px 8px; }
body.touch #boss-frame .bf-title { display: none; }
@media (prefers-reduced-motion: reduce) { #boss-vignette.on, #boss-frame.enraged, #boss-alert { animation: none; } #boss-vignette.on { opacity: 0.4; } }

/* Parasites latched on (entities/minions.js) */
#parasite-warning { position: fixed; top: 41%; left: 50%; transform: translateX(-50%); z-index: 400; pointer-events: none; white-space: nowrap;
    color: #9cff6a; font: bold 17px 'Share Tech Mono', 'Courier New', monospace; letter-spacing: 0.14em; text-shadow: 0 0 10px rgba(120, 255, 80, 0.9), 0 0 2px #000;
    animation: flight-warning-blink 0.35s steps(1) infinite; }
#parasite-warning[hidden] { display: none; }
body.menu-open #parasite-warning { display: none; }

/* Freaky mode quests (ui/questHud.js): tracker, radio comms, banners */
    font: 12px 'Share Tech Mono', 'Courier New', monospace; color: #fff; background: rgba(12, 10, 0, 0.72);
    border: 1px solid rgba(255, 210, 58, 0.55); border-left: 3px solid #ffd23a; border-radius: 3px; box-shadow: 0 0 14px rgba(255, 210, 58, 0.25); }
#quest-comms { --speaker: #9fe8ff; position: fixed; left: 50%; bottom: 215px; transform: translateX(-50%); z-index: 115; width: min(560px, 80vw); pointer-events: none;
    padding: 8px 12px; background: rgba(0, 8, 12, 0.82); border: 1px solid var(--speaker); border-left-width: 4px; border-radius: 3px;
    font: 14px 'Share Tech Mono', 'Courier New', monospace; color: #e8f6ff; box-shadow: 0 0 16px color-mix(in srgb, var(--speaker) 35%, transparent); }
#quest-comms[hidden] { display: none; }
#quest-comms .qc-who { display: flex; align-items: baseline; gap: 8px; margin-bottom: 3px; }
#quest-comms .qc-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--speaker); box-shadow: 0 0 8px var(--speaker); animation: boss-blink 0.8s steps(2) infinite; }
#quest-comms .qc-name { font-weight: bold; color: var(--speaker); letter-spacing: 0.1em; }
#quest-comms .qc-role { font-size: 11px; opacity: 0.65; }
#quest-banner { position: fixed; top: 22%; left: 50%; transform: translateX(-50%); z-index: 510; pointer-events: none; text-align: center; white-space: nowrap;
    font-family: 'Share Tech Mono', 'Courier New', monospace; animation: boss-alert-in 0.4s cubic-bezier(.2, 1.6, .4, 1); }
#quest-banner[hidden] { display: none; }
#quest-banner .qb-kicker { font-size: 13px; letter-spacing: 0.35em; color: #ffd23a; }
#quest-banner .qb-name { font: 900 clamp(20px, 4vw, 34px) 'Orbitron', 'Share Tech Mono', sans-serif; color: #fff2b0; text-shadow: 0 0 12px #ffaa00, 0 2px 0 #000; }
#quest-banner .qb-line { font-size: 14px; letter-spacing: 0.15em; color: #fff; text-shadow: 0 0 6px #000; }
#quest-banner.done .qb-name { color: #9cff6a; text-shadow: 0 0 12px #2a8a00, 0 2px 0 #000; }
#quest-banner.arc .qb-name { color: #ffd23a; font-size: clamp(24px, 5vw, 44px); }
body.menu-open body.touch body.touch body.touch #quest-comms { bottom: auto; top: 30%; font-size: 12px; }
