:root {
    --bg-deep: #070b18;
    --bg-mid: #0f1730;
    --bg-edge: #17345b;
    --panel-border: rgba(100, 226, 255, 0.55);
    --text-main: #e3f7ff;
    --text-muted: #95c8d5;
    --accent-a: #44f7d8;
    --accent-b: #ff5f8f;
    --accent-c: #76a8ff;
    --glow-soft: 0 0 0 1px rgba(148, 236, 255, 0.2), 0 10px 28px rgba(0, 0, 0, 0.45);
    --hud-panel: rgba(8, 19, 43, 0.88);
    --hud-border: rgba(118, 219, 255, 0.52);
    --hud-strong: rgba(148, 235, 255, 0.92);
    --hud-muted: #9cc9d6;
    --bar-track: rgba(26, 46, 79, 0.9);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: "Bahnschrift", "Trebuchet MS", "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at 20% 15%, rgba(68, 247, 216, 0.18), transparent 40%),
        radial-gradient(circle at 80% 25%, rgba(255, 95, 143, 0.16), transparent 35%),
        linear-gradient(145deg, var(--bg-deep), var(--bg-mid) 50%, var(--bg-edge));
    color: var(--text-main);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
    letter-spacing: 0.015em;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background: repeating-linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0.03) 0px,
        rgba(255, 255, 255, 0.03) 1px,
        rgba(0, 0, 0, 0) 2px,
        rgba(0, 0, 0, 0) 4px
    );
    mix-blend-mode: soft-light;
    opacity: 0.25;
}

.game-container {
    position: relative;
    width: min(100vw - 20px, 1120px);
    max-height: calc(100vh - 12px);
    padding: 14px;
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    background: linear-gradient(180deg, rgba(11, 18, 39, 0.95), rgba(10, 16, 35, 0.88));
    box-shadow: 0 18px 44px rgba(2, 6, 20, 0.78), inset 0 0 0 1px rgba(150, 250, 255, 0.12);
    overflow: hidden;
}

.ui {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    align-items: start;
    margin-bottom: 12px;
}

.hud-panel {
    background: linear-gradient(180deg, var(--hud-panel), rgba(8, 17, 37, 0.9));
    border: 1px solid var(--hud-border);
    border-radius: 12px;
    padding: 10px;
    box-shadow: var(--glow-soft);
    display: grid;
    gap: 8px;
}

.hud-panel h3 {
    margin: 0;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--hud-strong);
}

.hud-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    color: var(--hud-muted);
    font-size: 12px;
    line-height: 1.2;
}

.hud-row span {
    min-width: 0;
}

.hud-row span:first-child {
    color: var(--hud-muted);
    flex: 1;
}

.hud-row span:last-child {
    color: var(--text-main);
    font-weight: 700;
    max-width: 64%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: right;
}

.hud-objective {
    margin-top: 2px;
    padding: 7px 8px;
    border-radius: 8px;
    border: 1px solid rgba(101, 183, 227, 0.26);
    background: rgba(9, 21, 44, 0.56);
}

.hud-objective span {
    color: var(--hud-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.hud-objective p {
    margin-top: 4px;
    color: var(--text-main);
    font-size: 12px;
    line-height: 1.25;
    max-height: 4em;
    overflow: hidden;
    overflow-wrap: anywhere;
}

.obj-hint {
    display: block;
    margin-top: 2px;
    color: #50f8d8;
    font-size: 11px;
    font-style: italic;
    opacity: 0.85;
}

.bar-track {
    height: 10px;
    border-radius: 999px;
    border: 1px solid rgba(121, 210, 255, 0.36);
    background: var(--bar-track);
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    width: 0%;
    border-radius: inherit;
    transition: width 180ms ease;
}

.bar-track.hp .bar-fill {
    background: linear-gradient(90deg, #ff5b8e, #ff8a63);
}

.bar-track.time .bar-fill {
    background: linear-gradient(90deg, #64f7da, #6ab8ff);
}

.bar-track.boss .bar-fill {
    background: linear-gradient(90deg, #ff527d, #ffb45f);
}

.hud-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    align-items: stretch;
}

.perf-btn {
    background: linear-gradient(180deg, rgba(15, 28, 58, 0.94), rgba(9, 18, 40, 0.94));
    border: 1px solid rgba(105, 210, 255, 0.35);
    border-radius: 999px;
    padding: 8px 11px;
    color: var(--text-main);
    cursor: pointer;
    text-align: center;
    font-weight: 700;
    font-size: 12px;
    line-height: 1.15;
    min-height: 34px;
    white-space: normal;
    transition: transform 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

.perf-btn:hover {
    border-color: rgba(130, 233, 255, 0.75);
    transform: translateY(-1px);
    box-shadow: 0 0 0 1px rgba(130, 233, 255, 0.42), 0 12px 24px rgba(3, 12, 28, 0.55);
}

.boss-hud {
    position: relative;
    width: min(420px, calc(100% - 36px));
    margin: -2px auto 10px;
    z-index: 14;
    border: 1px solid rgba(255, 125, 150, 0.68);
    border-radius: 12px;
    padding: 8px 10px;
    background: linear-gradient(180deg, rgba(41, 12, 24, 0.92), rgba(20, 8, 18, 0.86));
    box-shadow: 0 0 0 1px rgba(255, 173, 192, 0.2), 0 10px 24px rgba(0, 0, 0, 0.45);
}

.boss-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 11px;
    margin-bottom: 6px;
    color: #ffdce7;
}

.boss-hp-text {
    margin-top: 4px;
    text-align: right;
    font-size: 11px;
    color: #ffdce7;
}

#gameCanvas {
    width: 100%;
    height: min(54vh, 520px);
    aspect-ratio: 16 / 9;
    display: block;
    border: 2px solid rgba(94, 214, 252, 0.7);
    border-radius: 12px;
    background: #081124;
    box-shadow: 0 0 0 1px rgba(140, 230, 255, 0.16), 0 24px 42px rgba(3, 8, 20, 0.72);
}

.instructions {
    margin-top: 10px;
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.45;
    text-align: center;
}

.guide-panel {
    position: absolute;
    right: 18px;
    top: 72px;
    width: min(360px, calc(100% - 36px));
    max-height: calc(100% - 36px);
    z-index: 26;
}

.guide-card {
    display: grid;
    gap: 10px;
    max-height: inherit;
    background: linear-gradient(180deg, rgba(10, 18, 39, 0.96), rgba(9, 16, 34, 0.94));
    border: 1px solid rgba(125, 226, 255, 0.6);
    border-radius: 14px;
    box-shadow: 0 0 0 1px rgba(168, 246, 255, 0.18), 0 20px 38px rgba(2, 6, 18, 0.72);
    padding: 14px;
}

.guide-tab-hint {
    margin: -2px 0 2px;
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.35;
}

.guide-tabs {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
}

.guide-tab {
    border: 1px solid rgba(110, 204, 245, 0.42);
    border-radius: 999px;
    background: rgba(11, 25, 49, 0.9);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.03em;
    line-height: 1.1;
    min-height: 28px;
    padding: 5px 8px;
    cursor: pointer;
    transition: border-color 120ms ease, color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}

.guide-tab:hover {
    border-color: rgba(146, 233, 255, 0.82);
    color: var(--text-main);
    transform: translateY(-1px);
}

.guide-tab.active,
.guide-tab[aria-selected="true"] {
    border-color: rgba(129, 236, 255, 0.9);
    background: linear-gradient(180deg, rgba(25, 58, 92, 0.92), rgba(12, 28, 49, 0.94));
    color: #ddf7ff;
    box-shadow: 0 0 0 1px rgba(147, 235, 255, 0.28);
}

.guide-live-intel {
    border: 1px solid rgba(99, 188, 243, 0.35);
    border-left: 3px solid rgba(117, 238, 255, 0.75);
    border-radius: 8px;
    padding: 7px;
    background: rgba(8, 24, 44, 0.66);
    color: #d4f6ff;
    font-size: 11px;
    line-height: 1.3;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.guide-intel-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    max-width: 100%;
    padding: 4px 7px;
    border: 1px solid rgba(108, 221, 255, 0.28);
    border-radius: 999px;
    background: rgba(5, 16, 34, 0.72);
    color: #d8f7ff;
}

.guide-intel-chip strong {
    color: #7ff7f2;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.guide-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.guide-header h2 {
    margin: 0;
    font-size: 15px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--hud-strong);
}

.guide-header button {
    border: 1px solid rgba(121, 213, 255, 0.6);
    border-radius: 999px;
    background: rgba(13, 31, 62, 0.95);
    color: var(--text-main);
    font-size: 12px;
    padding: 6px 10px;
    cursor: pointer;
}

.guide-content {
    overflow: auto;
    display: grid;
    gap: 10px;
    min-height: 0;
    padding-right: 4px;
}

.guide-section {
    border: 1px solid rgba(103, 193, 246, 0.35);
    border-radius: 10px;
    padding: 10px;
    background: rgba(9, 21, 44, 0.72);
}

.guide-section h4 {
    margin: 0 0 8px;
    font-size: 11px;
    color: var(--hud-strong);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.guide-list {
    display: grid;
    gap: 6px;
    color: var(--text-main);
    font-size: 12px;
}

.guide-list div {
    line-height: 1.3;
}

.guide-list strong {
    color: #8fe8ff;
}

body.compact-hud .ui,
.game-container.compact-hud .ui {
    gap: 7px;
    margin-bottom: 8px;
}

body.compact-hud .hud-panel,
.game-container.compact-hud .hud-panel {
    border-radius: 10px;
    padding: 8px 8px 7px;
    gap: 6px;
}

body.compact-hud .hud-panel h3,
.game-container.compact-hud .hud-panel h3 {
    font-size: 11px;
    letter-spacing: 0.07em;
}

body.compact-hud .hud-row,
body.compact-hud .hud-objective p,
.game-container.compact-hud .hud-row,
.game-container.compact-hud .hud-objective p {
    font-size: 11px;
}

body.compact-hud .hud-objective,
.game-container.compact-hud .hud-objective {
    margin-top: 0;
    padding: 6px 7px;
    border-color: rgba(101, 183, 227, 0.22);
    background: rgba(9, 21, 44, 0.48);
}

body.compact-hud .bar-track,
.game-container.compact-hud .bar-track {
    height: 8px;
}

body.compact-hud .hud-actions,
.game-container.compact-hud .hud-actions {
    gap: 5px;
}

body.compact-hud .perf-btn,
.game-container.compact-hud .perf-btn {
    min-height: 30px;
    padding: 6px 8px;
    font-size: 11px;
}

body.compact-hud .instructions,
.game-container.compact-hud .instructions {
    margin-top: 8px;
    font-size: 10px;
    line-height: 1.3;
    opacity: 0.7;
}

.mobile-controls {
    margin-top: 10px;
    display: none;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.mobile-controls.force-show {
    display: grid;
}

.notify-toast {
    position: absolute;
    left: 50%;
    bottom: 84px;
    transform: translateX(-50%);
    z-index: 24;
    background: rgba(5, 16, 34, 0.9);
    border: 1px solid rgba(120, 240, 255, 0.8);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13px;
    color: var(--text-main);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

.mobile-controls button {
    border: 1px solid rgba(121, 213, 255, 0.65);
    background: rgba(13, 31, 62, 0.9);
    color: var(--text-main);
    border-radius: 8px;
    padding: 10px 8px;
    font-size: 14px;
}

.virtual-stick {
    grid-column: span 2;
    position: relative;
    min-height: 76px;
    border: 1px solid rgba(121, 213, 255, 0.65);
    border-radius: 999px;
    background: rgba(13, 31, 62, 0.9);
    touch-action: none;
    overflow: hidden;
}

.stick-knob {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 34px;
    height: 34px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    border: 1px solid rgba(198, 243, 255, 0.95);
    background: rgba(113, 232, 255, 0.65);
}

.mobile-controls button:active {
    transform: translateY(1px);
    background: rgba(28, 60, 110, 0.95);
}

.game-over {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(90%, 380px);
    background: rgba(10, 18, 38, 0.95);
    border: 2px solid rgba(116, 234, 255, 0.85);
    border-radius: 10px;
    padding: 24px;
    text-align: center;
    z-index: 20;
}

.game-over h2 {
    color: var(--accent-a);
    font-size: 32px;
    margin-bottom: 14px;
}

.game-over p {
    margin: 8px 0;
}

.hidden {
    display: none;
}

.menu-overlay {
    position: absolute;
    inset: 0;
    background: rgba(4, 8, 22, 0.82);
    display: grid;
    place-items: center;
    z-index: 25;
}

.menu-overlay.hidden {
    display: none;
}

.menu-card {
    width: min(92%, 420px);
    background: rgba(9, 17, 36, 0.95);
    border: 1px solid rgba(112, 227, 255, 0.55);
    border-radius: 14px;
    padding: 20px;
    display: grid;
    gap: 10px;
    text-align: center;
    box-shadow: 0 0 0 1px rgba(160, 240, 255, 0.18), 0 20px 44px rgba(2, 8, 21, 0.75);
}

.menu-subtitle {
    margin-top: 6px;
    font-size: 12px;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.menu-list {
    display: grid;
    gap: 6px;
}

.menu-list button {
    padding: 8px 10px;
    font-size: 12px;
}

.menu-card h2 {
    margin-bottom: 2px;
}

.menu-card button {
    border: 1px solid rgba(119, 220, 255, 0.65);
    border-radius: 10px;
    padding: 10px;
    background: rgba(15, 30, 58, 0.95);
    color: var(--text-main);
    cursor: pointer;
    font-weight: 700;
    transition: transform 120ms ease, border-color 120ms ease, filter 120ms ease;
}

.menu-card button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.menu-card button:hover:not(:disabled) {
    border-color: rgba(145, 240, 255, 0.95);
    transform: translateY(-1px);
    filter: brightness(1.06);
}

.menu-card.danger {
    border-color: rgba(255, 130, 150, 0.85);
}

.setting-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: rgba(14, 26, 52, 0.9);
    border: 1px solid rgba(100, 190, 255, 0.4);
    border-radius: 10px;
    padding: 10px 12px;
}

.setting-item select,
.setting-item input[type="range"] {
    width: 130px;
}

.mutations-list {
    display: grid;
    gap: 5px;
    margin-top: 4px;
}

.mutation-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(14, 22, 46, 0.9);
    border: 1px solid rgba(100, 190, 255, 0.35);
    border-radius: 8px;
    padding: 8px 10px;
    cursor: pointer;
    transition: border-color 120ms ease;
}

.mutation-item:hover {
    border-color: rgba(145, 240, 255, 0.75);
}

.mutation-item input[type="checkbox"] {
    accent-color: var(--accent-a);
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.mut-name {
    font-weight: 700;
    font-size: 12px;
    color: var(--text-main);
    min-width: 90px;
}

.mut-desc {
    font-size: 11px;
    color: var(--text-muted);
}

.mutation-best-time {
    font-size: 11px;
    color: var(--accent-a);
    text-align: right;
    margin-top: 4px;
    min-height: 14px;
}

body.high-contrast {
    --bg-deep: #03050e;
    --bg-mid: #091a2b;
    --bg-edge: #123a58;
    --panel-border: rgba(175, 245, 255, 0.9);
    --text-main: #f5fcff;
    --text-muted: #cae9f5;
}

.mobile-controls.southpaw {
    direction: rtl;
}

.boot-diag {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 100;
    max-width: 440px;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid rgba(255, 120, 140, 0.88);
    background: rgba(25, 8, 18, 0.92);
    color: #ffdce3;
    font-size: 13px;
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.45);
}

.boot-diag code {
    color: #aaf3ff;
}

@media (max-width: 980px) {
    .ui {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    #gameCanvas {
        height: min(46vh, 420px);
    }

    .mobile-controls {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .game-container {
        padding: 12px;
    }

    .ui {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px;
    }

    .hud-panel {
        padding: 8px;
        gap: 6px;
    }

    .hud-panel h3 {
        font-size: 11px;
    }

    .hud-row,
    .hud-objective p,
    .guide-list {
        font-size: 11px;
    }

    .hud-actions {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .instructions {
        font-size: 10px;
        line-height: 1.35;
    }

    .guide-panel {
        left: 12px;
        right: 12px;
        top: 58px;
        width: auto;
        max-height: calc(100% - 32px);
    }

    #gameCanvas {
        height: min(42vh, 310px);
    }

    .mobile-controls {
        gap: 6px;
    }

    .mobile-controls button {
        min-height: 36px;
        font-size: 12px;
        line-height: 1.1;
        white-space: nowrap;
    }

    .guide-tabs {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .guide-tab {
        min-height: 30px;
    }

    .guide-live-intel {
        font-size: 10px;
        gap: 5px;
    }

    .guide-intel-chip {
        padding: 3px 6px;
    }
}

@media (max-width: 420px) {
    .ui {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .hud-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 5px;
    }

    .perf-btn {
        padding: 6px 6px;
        font-size: 10px;
        min-height: 30px;
    }

    .guide-header h2 {
        font-size: 13px;
    }

    .guide-tab-hint {
        display: none;
    }

    .guide-card {
        gap: 8px;
    }

    .guide-content {
        gap: 8px;
    }

    .guide-section {
        padding: 8px;
    }

    #gameCanvas {
        height: min(40vh, 250px);
    }

    .mobile-controls {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 5px;
    }

    .mobile-controls button {
        padding: 8px 4px;
        font-size: 11px;
    }

    .virtual-stick {
        min-height: 64px;
    }

    .instructions {
        max-width: 94%;
        margin-left: auto;
        margin-right: auto;
    }
}

@media (max-width: 340px) {
    .game-container {
        padding: 10px;
    }

    .ui {
        gap: 5px;
        margin-bottom: 8px;
    }

    .hud-panel {
        padding: 6px;
        gap: 5px;
    }

    .hud-objective {
        padding: 5px 6px;
    }

    .hud-objective p {
        max-height: 3em;
    }

    .boss-hud {
        padding: 6px 8px;
        margin-bottom: 8px;
    }

    .boss-head {
        margin-bottom: 4px;
        font-size: 10px;
    }

    .boss-hp-text {
        margin-top: 2px;
        font-size: 10px;
    }

    .bar-track.boss {
        height: 8px;
    }

    #gameCanvas {
        height: min(32vh, 180px);
    }
}

@media (max-width: 360px) {
    .hud-row span:last-child {
        max-width: 60%;
    }

    .guide-card {
        padding: 11px;
    }

    .guide-tab {
        font-size: 10px;
        padding: 5px 6px;
    }

    .mobile-controls button {
        font-size: 10px;
    }
}

/* Field HUD: shared desktop/mobile visual language; world retains its 16:9 ratio. */
body { min-height: 100dvh; overflow: auto; background: #060e18; }
.game-container { width: min(1280px, calc(100vw - 24px)); max-height: none; padding: 0; border-radius: 12px; background: #07121f; }
#gameCanvas { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; max-height: none; border: 0; border-radius: 0; object-fit: contain; }
.ui.hud-shell, body.compact-hud .ui.hud-shell { position: relative; z-index: 4; display: grid; grid-template-columns: minmax(150px, 220px) minmax(100px, 1fr) minmax(175px, 240px); align-items: center; gap: 24px; min-height: 80px; padding: 12px 20px; margin: 0; background: linear-gradient(180deg,#152837,#091521); }
.hud-shell .hud-panel, body.compact-hud .hud-shell .hud-panel { background: none; border: none; box-shadow: none; border-radius: 0; padding: 0; gap: 4px; min-width: 0; }
.hud-shell h3 { display: none; }
.hud-shell .hud-row { font-size: 11px; }
#hudVitals .bar-track { height: 7px; border: 0; border-radius: 0; }
#hudVitals .hp .bar-fill { background: #a3ffde; }
#hudVitals .time { height: 3px; }
#hudVitals .stat-line:first-of-type { text-transform: uppercase; letter-spacing: 1.5px; color: #d5ebe5; }
#hudVitals .stat-line:nth-of-type(3) { font-size: 10px; }
.field-objective, body.compact-hud .field-objective { margin: 0; padding: 0 0 0 14px; min-width: 0; border-left: 2px solid #dbbd8d; }
.field-objective > span { display: block; font-size: 9px; letter-spacing: 1.7px; text-transform: uppercase; color: #91a2af; }
.field-objective #objectiveLabel { margin: 5px 0 0; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#hudCombat { position: relative; padding-right: 62px; }
#hudCombat .hud-row { display: block; text-align: right; }
#hudCombat .hud-row > span:first-child { display: none; }
#weaponLabel { text-transform: uppercase; letter-spacing: .7px; }
#weaponModLabel { font-size: 10px; color: #92b0bd; }
#hudCombat .hud-actions { position: absolute; right: 0; top: 50%; transform: translateY(-50%); margin: 0; width: 48px; display: block; }
#pauseBtn { width: 48px; height: 48px; min-height: 48px; padding: 0; border-radius: 10px; font-size: 11px; background: #162c3b; }
.boss-hud { position: relative; width: min(520px, calc(100% - 32px)); margin: 0 auto; padding: 5px 12px; border: 0; border-radius: 0; background: #141c2c; }
.boss-head { font-size: 10px; }.boss-hud .bar-track { height: 4px; }.boss-hp-text { display: none; }
.instructions { display: none; }
.menu-overlay { position: absolute; min-height: 100%; padding: 12px; overflow-y: auto; align-items: start; }
.menu-card { max-height: calc(100dvh - 28px); overflow-y: auto; margin: auto; }
.pause-status { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; text-align: left; }.pause-status .hud-panel { padding: 10px; gap: 6px; }.pause-tools { display: flex; gap: 6px; flex-wrap: wrap; }.pause-tools button { flex: 1; min-height: 48px; }
.mobile-controls, .mobile-controls.force-show { display: none; }
.mobile-controls.force-show { display: block; position: relative; height: 280px; margin: 0; background: linear-gradient(145deg,#183342,#091522); }
.mobile-controls button { position: absolute; min-width: 48px; min-height: 48px; margin: 0; padding: 4px; touch-action: none; user-select: none; }
.mobile-controls .touch-action { display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 3px; width: 52px; height: 52px; border-radius: 50%; border: 1px solid #78919f; background: linear-gradient(145deg,#263e50ed,#091622ed); box-shadow: inset 0 0 0 4px #101e2d,0 3px 10px #0007; color: #e4eff3; }
.touch-action svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }.touch-action span { font-size: 10px; text-transform: uppercase; font-weight: bold; pointer-events: none; }
.mobile-controls .touch-attack { width: 72px; height: 72px; right: 36px; bottom: 105px; color: #07303a; border-color: #bdfff1; background: linear-gradient(145deg,#b4ffdf,#5cb8ba); box-shadow: inset 0 0 0 4px #8bf1d490,0 4px 20px #2bcaaa33; }
.mobile-controls .touch-jump { width: 64px; height: 64px; right: 115px; bottom: 50px; }
.mobile-controls .touch-dash { right: 116px; bottom: 128px; }
.mobile-controls .touch-swap { right: 28px; top: 16px; }
.mobile-controls .touch-hack { right: 188px; bottom: 136px; width: 92px; height: 48px; flex-direction: row; border-radius: 10px; border-color: #8afae4; color: #acffdd; background: linear-gradient(145deg,#12443d,#0b252e); }
.mobile-controls .touch-slow { left: 24px; top: 18px; }.mobile-controls .touch-gravity { left: 84px; top: 18px; }
.mobile-controls .virtual-stick { position: absolute; left: 38px; bottom: 42px; width: 112px; height: 112px; min-height: 0; border-radius: 50%; background: radial-gradient(circle,#29475c90,#142d4080 64%,#07203380 65%); box-shadow: inset 0 0 0 9px #30485933; }
.mobile-controls .stick-knob { width: 48px; height: 48px; background: linear-gradient(135deg,#acc6ca,#365568); box-shadow: inset 0 0 0 4px #315a6b; }
.mobile-controls .touch-context { left: calc(50% - 70px); bottom: 18px; width: 140px; height: 48px; border-radius: 9px; background: #112634ed; }
.mobile-controls .touch-help { left: 155px; top: 18px; width: 48px; height: 48px; font-size: 11px; }
.touch-dpad { display: none; }.mobile-controls.show-dpad .touch-dpad { display: block; }.show-dpad .virtual-stick { display: none; }.touch-dpad button { bottom: 66px; left: 28px; }.touch-dpad button + button { left: 88px; }
.mobile-controls [aria-disabled="true"], .mobile-controls button:disabled { opacity: .58; filter: saturate(.3); }.mobile-controls button:focus-visible, #pauseBtn:focus-visible { outline: 2px solid white; outline-offset: 3px; }
.mobile-controls.southpaw { direction: ltr; transform: scaleX(-1); }.mobile-controls.southpaw .touch-action, .mobile-controls.southpaw .touch-context, .mobile-controls.southpaw .touch-help, .mobile-controls.southpaw .touch-dpad button { transform: scaleX(-1); }
@media (max-width: 640px) {
 body { align-items: flex-start; }.game-container { width: 100%; margin: 0; border: 0; border-radius: 0; padding-top: env(safe-area-inset-top); }
 .ui.hud-shell, body.compact-hud .ui.hud-shell { grid-template-columns: minmax(100px,1fr) minmax(130px,1fr); gap: 10px 14px; padding: 12px 14px; min-height: 106px; }
 .field-objective { grid-column: 1 / -1; grid-row: 2; }#hudCombat { grid-column: 2; grid-row: 1; }
 .field-objective > span { display: none; }.field-objective #objectiveLabel { margin: 0; font-size: 11px; }
 .mobile-controls.force-show { height: 310px; padding-bottom: env(safe-area-inset-bottom); }.mobile-controls .touch-hack { right: 104px; top: 18px; bottom: auto; }.mobile-controls .touch-help { left: 148px; top: 82px; }.mobile-controls .touch-slow { left: 18px; }.mobile-controls .touch-gravity { left: 78px; }
 .mobile-controls .touch-attack { right: 22px; bottom: 136px; }.mobile-controls .touch-jump { right: 99px; bottom: 73px; }.mobile-controls .touch-dash { right: 26px; bottom: 65px; }.mobile-controls .virtual-stick { left: 24px; bottom: 85px; }.mobile-controls .touch-context { bottom: 8px; }
 .pause-status { grid-template-columns: 1fr; }.notify-toast { max-width: calc(100% - 28px); font-size: 11px; bottom: auto; top: 116px; }
}
@media (orientation: landscape) and (max-height: 540px) {
 body { overflow: hidden; align-items: center; }.game-container { width: 100vw; height: 100dvh; border: 0; border-radius: 0; }
 #gameCanvas { width: 100%; height: 100%; object-fit: contain; }
 .ui.hud-shell, body.compact-hud .ui.hud-shell { position: absolute; left: max(14px,env(safe-area-inset-left)); right: max(14px,env(safe-area-inset-right)); top: max(10px,env(safe-area-inset-top)); padding: 0; min-height: 48px; gap: 20px; grid-template-columns: 190px minmax(100px,1fr) 190px; background: none; pointer-events: none; }
 .hud-shell button { pointer-events: auto; }.field-objective { grid-column: auto; grid-row: auto; }#hudCombat { grid-column: auto; grid-row: auto; }.field-objective > span { display: block; }
 .mobile-controls.force-show { position: absolute; inset: 0; height: auto; background: none; pointer-events: none; margin: 0; padding: 0; }.mobile-controls button,.mobile-controls .virtual-stick { pointer-events: auto; }
 .mobile-controls .virtual-stick { left: max(38px,env(safe-area-inset-left)); bottom: max(38px,env(safe-area-inset-bottom)); }.mobile-controls .touch-attack { right: max(54px,env(safe-area-inset-right)); bottom: 68px; }.mobile-controls .touch-jump { right: 136px; bottom: 34px; }.mobile-controls .touch-dash { right: 136px; bottom: 114px; }.mobile-controls .touch-hack { right: 207px; top: auto; bottom: 135px; }.mobile-controls .touch-swap { right: 24px; top: 94px; }.mobile-controls .touch-slow { left: 24px; top: 134px; }.mobile-controls .touch-gravity { left: 84px; top: 134px; }.mobile-controls .touch-help { left: 24px; top: 75px; }.mobile-controls .touch-context { left: calc(50% - 70px); bottom: 64px; }
 .boss-hud { position: absolute; z-index: 5; top: 69px; left: 30%; width: 40%; margin: 0; }.notify-toast { top: 78px; bottom: auto; }.guide-panel { top: 12px; max-height: calc(100% - 24px); }.menu-card { max-height: calc(100dvh - 24px); }
}
/* Live eligibility is supplied by mobile-interface.js. */
.mobile-controls .is-locked, .mobile-controls .is-unavailable { color: #9bb1be; border-color: #567080; background: #132536; }
.mobile-controls .is-ready { border-color: #adffe5; }
.control-state { display: block; font-size: 8px; line-height: 1.1; text-transform: uppercase; letter-spacing: .4px; }
body.field-modal-open .mobile-controls { visibility: hidden; pointer-events: none; }

/* Field identity and hierarchy: restrained rails rather than dashboard cards. */
.hud-shell #hudVitals { position: relative; padding-left: 42px; }
.hud-shell #hudVitals::before { content: 'H'; position: absolute; left: 0; top: 3px; width: 30px; height: 39px; display: grid; place-items: center; background: #d0eee4; color: #123c40; font-size: 19px; font-weight: 800; clip-path: polygon(0 0,100% 0,100% 72%,50% 100%,0 72%); }
.field-objective, body.compact-hud .field-objective { background: none; border-top: 0; border-right: 0; border-bottom: 0; border-radius: 0; }
.field-objective .obj-hint { display: none; }
#hudCombat .hud-row { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#hudCombat { min-height: 48px; }
#hudCombat .no-mod { display: none; }
@media(max-width:340px) and (orientation:portrait) {
 .ui.hud-shell,body.compact-hud .ui.hud-shell { min-height:88px;padding:10px 14px;gap:4px 12px; }
 .mobile-controls.force-show { height:266px; }
 .mobile-controls .virtual-stick { left:16px;bottom:64px;width:104px;height:104px; }
 .mobile-controls .touch-hack { right:18px;top:18px; }
 .mobile-controls .touch-swap { right:18px;top:78px; }
 .mobile-controls .touch-dash { right:110px;top:88px;bottom:auto; }
 .mobile-controls .touch-attack { right:18px;bottom:60px; }
 .mobile-controls .touch-jump { right:100px;bottom:18px; }
 .mobile-controls .touch-context { left:18px;bottom:8px;width:124px; }
 .boss-hud { padding:2px 12px; }
}

/* Accessible run debrief: covers the keyboard-only Canvas summary. */
.field-result{background:#071322;backdrop-filter:none;z-index:75}
.field-result .field-dialog-card{width:min(570px,100%)}
.field-result-stats{display:grid;grid-template-columns:repeat(4,1fr);gap:10px;margin:14px 0}
.field-result-stats div{padding:12px 8px;background:#071c2a;border:1px solid #365967;border-radius:8px}
.field-result-stats dt{color:#9fbbc4;font-size:11px}.field-result-stats dd{margin:6px 0 0;font-size:22px;color:#bdf9e5;font-weight:bold}
.field-result .field-replay-goal{padding:12px;background:#133746;border-left:3px solid #99f5d9;font-size:13px;line-height:1.5;margin:12px 0}
.field-result .field-carry-note{display:block;margin-top:14px;letter-spacing:0;font-size:11px;line-height:1.5}
.field-result button:focus-visible{outline:3px solid white;outline-offset:3px}
@media(max-width:600px){.field-result-stats{grid-template-columns:repeat(2,1fr)}.field-result .field-dialog-actions{display:grid;grid-template-columns:1fr;width:100%;gap:8px}.field-result .field-dialog-actions button{width:100%;min-height:48px}.field-result .field-dialog-card{max-height:calc(100dvh - 40px)}}
@media(max-height:450px) and (min-width:601px){.field-result{padding:10px}.field-result .field-dialog-card{padding:12px 18px}.field-result .field-dialog-card h2{margin:5px 0;font-size:21px}.field-result-stats{margin:8px 0}.field-result-stats div{padding:7px}.field-result .field-replay-goal{padding:8px;margin:8px 0}.field-result .field-carry-note{margin-top:8px}.field-result .field-dialog-actions{gap:8px}.field-result .field-dialog-actions button{min-width:120px}}

.touch-action.power-active { border-color:var(--power-color); box-shadow:inset 0 0 0 2px var(--power-color),0 0 12px #82cdda30; }
.touch-action.power-active .control-state { color:var(--power-color); opacity:1; }

.touch-action.power-active.is-unavailable { opacity:1; }

/* Touch playfield: portrait zoom and clear landscape control gutters. */
body.field-touch .mobile-controls .touch-action.is-locked { width:48px;height:48px;box-shadow:none; }
body.field-touch .mobile-controls .control-state { bottom:-12px;font-size:8px; }
@media (orientation:portrait) and (max-width:640px) {
 body.field-touch { align-items:flex-start; }
 body.field-touch .game-container { width:100%;height:auto; }
 body.field-touch .ui.hud-shell,body.field-touch.compact-hud .ui.hud-shell { min-height:88px;padding:10px 14px;gap:4px 12px; }
 body.field-touch #gameCanvas { display:block;width:100%;height:min(360px,calc(100dvh - 304px));object-fit:fill; }
 body.field-touch .mobile-controls.force-show { position:relative;inset:auto;height:216px;padding:0; }
 body.field-touch .mobile-controls .touch-slow { left:12px;top:8px;bottom:auto;width:48px;height:48px; }
 body.field-touch .mobile-controls .touch-gravity { left:68px;top:8px;bottom:auto;width:48px;height:48px; }
 body.field-touch .mobile-controls .touch-hack { left:auto;right:72px;top:8px;bottom:auto;width:92px;height:48px; }
 body.field-touch .mobile-controls .touch-swap { left:auto;right:12px;top:8px;bottom:auto;width:48px;height:48px; }
 body.field-touch .mobile-controls .virtual-stick { left:12px;right:auto;top:auto;bottom:56px;width:104px;height:104px; }
 body.field-touch .mobile-controls .touch-attack { left:auto;right:12px;top:auto;bottom:64px;width:64px;height:64px; }
 body.field-touch .mobile-controls .touch-jump { left:auto;right:84px;top:auto;bottom:64px;width:56px;height:56px; }
 body.field-touch .mobile-controls .touch-dash { left:auto;right:88px;top:auto;bottom:8px;width:48px;height:48px; }
 body.field-touch .mobile-controls .touch-context { left:12px;right:auto;top:auto;bottom:4px;width:124px;height:48px; }
 body.field-touch .touch-dpad button { left:12px;bottom:88px;width:48px;height:48px; }
 body.field-touch .touch-dpad button+button { left:68px; }
 body.field-touch .notify-toast { top:98px; }
 body.field-touch .boss-hud { position:absolute;left:0;top:76px;width:100%;z-index:5; }
}
@media (orientation:landscape) and (max-height:540px) {
 body.field-touch .game-container { width:100vw;height:100dvh;overflow:hidden; }
 body.field-touch #gameCanvas { position:absolute;left:136px;top:72px;width:calc(100% - 272px);height:calc(100% - 72px);object-fit:fill; }
 body.field-touch .mobile-controls.force-show { position:absolute;inset:0;height:auto;background:linear-gradient(to right,#102535 0 136px,transparent 136px calc(100% - 136px),#102535 calc(100% - 136px)); }
 body.field-touch .mobile-controls .virtual-stick { left:16px;right:auto;top:auto;bottom:24px;width:104px;height:104px; }
 body.field-touch .mobile-controls .touch-slow { left:16px;right:auto;top:86px;bottom:auto;width:48px;height:48px; }
 body.field-touch .mobile-controls .touch-gravity { left:72px;right:auto;top:86px;bottom:auto;width:48px;height:48px; }
 body.field-touch .mobile-controls .touch-context { left:12px;right:auto;top:158px;bottom:auto;width:112px;height:48px; }
 body.field-touch .mobile-controls .touch-hack { left:auto;right:12px;top:86px;bottom:auto;width:112px;height:48px; }
 body.field-touch .mobile-controls .touch-attack { left:auto;right:12px;top:auto;bottom:104px;width:64px;height:64px; }
 body.field-touch .mobile-controls .touch-jump { left:auto;right:84px;top:auto;bottom:102px;width:52px;height:52px; }
 body.field-touch .mobile-controls .touch-dash { left:auto;right:84px;top:auto;bottom:34px;width:52px;height:52px; }
 body.field-touch .mobile-controls .touch-swap { left:auto;right:20px;top:auto;bottom:34px;width:48px;height:48px; }
 body.field-touch .touch-dpad button { left:16px;bottom:40px;width:48px;height:48px; }
 body.field-touch .touch-dpad button+button { left:72px; }
 body.field-touch .notify-toast { top:80px;max-width:calc(100% - 300px); }
 body.field-touch .boss-hud { left:136px;top:60px;width:calc(100% - 272px); }
 body.field-touch .ui.hud-shell,body.field-touch.compact-hud .ui.hud-shell { gap:12px;grid-template-columns:170px minmax(100px,1fr) 170px; }
}
