* {
        box-sizing: border-box;
        -webkit-user-select: none;
        user-select: none;
    }
    button, select, input, textarea {
        touch-action: manipulation;
    }
    body {
        margin: 0;
        background: radial-gradient(circle at center, #1e293b 0%, #020617 100%);
        color: #f8fafc;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: flex-start;
        height: 100dvh;
        font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Inter', Helvetica, Arial, sans-serif;
        overflow: hidden;
        padding-bottom: env(safe-area-inset-bottom);
        position: relative;
    }
    body::before {
        display: none;
    }
    html, body {
        width: 100%;
        height: 100%;
        min-height: 100%;
        overflow: hidden;
        overscroll-behavior: none;
        -webkit-text-size-adjust: 100%;
    }
    html:fullscreen, html:-webkit-full-screen, body:fullscreen, body:-webkit-full-screen {
        width: 100vw;
        height: 100dvh;
        margin: 0;
        padding: 0;
    }
    #game-container {
        position: relative;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        width: 100%;
        max-width: 100vw;
        height: 100%;
        z-index: 1;
    }
    canvas {
        background: #020617;
        flex-shrink: 0;
        display: block;
        box-shadow: none;
        border: 0;
        cursor: crosshair;
        touch-action: none;
    }
    .th-row {
        display: flex; align-items: center; gap: 12px;
        text-align: left; padding: 9px 2px;
    }
    .th-row + .th-row { border-top: 1px solid rgba(56, 189, 248, 0.14); }
    .th-icon {
        flex: 0 0 auto; width: 34px; height: 34px;
        display: flex; align-items: center; justify-content: center;
    }
    .th-icon svg { width: 100%; height: 100%; }
    .th-text { font-size: 13px; line-height: 1.4; color: #cbe4f5; }
    .th-text b { color: #7fe6ff; font-weight: 700; }
    .th-hairline {
        margin: 4px 0 2px; height: 1px;
        background: linear-gradient(90deg, transparent, rgba(56,189,248,0.4), transparent);
    }
    #ui {
        font-size: 9px;
        font-weight: 700;
        letter-spacing: 0.06em;
        backdrop-filter: blur(18px);
        -webkit-backdrop-filter: blur(18px);
        width: 100%;
        flex-wrap: wrap;
        border-top: 1px solid rgba(51, 65, 85, 0.3);
        flex-shrink: 0;
        text-transform: uppercase;
        color: #94a3b8;
        position: relative;
        overflow: hidden;
    }
    @media (max-width: 700px) {
        #ui, .overlay-screen, .sleek-card, .ts-options-card {
            backdrop-filter: none !important;
            -webkit-backdrop-filter: none !important;
        }
        .overlay-screen {
            background: #05070f !important;
        }
        #title-screen, #pause-screen {
            background: radial-gradient(ellipse at 50% 32%, #0d1830 0%, #05070f 58%, #04060c 100%) !important;
        }
    }
    #ui > * {
        position: relative;
        z-index: 1;
    }
    .hud-primary {
        display: flex;
    }
    .hud-stat:first-child {
        padding-left: 0;
    }
    .hud-stat:last-child {
        border-right: 0;
    }
    .hud-label {
        display: block;
        line-height: 1;
    }
    .hud-value {
        display: block;
        color: #e0f2fe;
        font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
        font-weight: 900;
        letter-spacing: 0;
        white-space: nowrap;
    }
    .hud-stat.score .hud-value {
        color: #67e8f9;
    }
    .hud-stat.stage .hud-value {
        color: #c4b5fd;
    }
    .hud-stat.coins .hud-value {
        color: #fbbf24;
    }
    .hud-stat.armor .hud-value {
        color: #a7f3d0;
    }
    .hud-stat.shield-status .hud-value {
        color: #38bdf8;
    }
    .hud-meters {
        display: flex;
        flex-direction: column;
        justify-content: center;
    }
    .hud-meter {
        display: grid;
        align-items: center;
    }
    .hud-countdown {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 6px;
        min-height: 15px;
    }
    .hud-countdown-value {
        color: #38bdf8;
        font: 900 11px/1 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
        letter-spacing: 0;
        white-space: nowrap;
    }
    .hud-countdown-value .number {
        color: #38bdf8;
    }
    .hud-countdown-value .unit {
        color: #94a3b8;
    }
    .hud-countdown-value.active {
        color: #f87171;
        animation: bossPulse 0.9s ease-in-out infinite alternate;
    }
    .hud-countdown-value.hud-countdown-text {
        font-size: 8px;
        letter-spacing: 0.01em;
        white-space: normal;
        line-height: 1.15;
        word-break: break-word;
        overflow: visible;
        text-overflow: clip;
    }

        @keyframes bossPulse {
            from { text-shadow: 0 0 4px rgba(248, 113, 113, 0.2); }
            to { text-shadow: 0 0 12px rgba(248, 113, 113, 0.85); }
        }
    .hud-meter-label {
        color: #94a3b8;
    }
    .hud-meter {
        position: relative;
        border: 1px solid rgba(103,232,249,.22);
        border-radius: 7px;
        background: linear-gradient(180deg, rgba(8,20,38,.88), rgba(2,8,20,.72));
        box-shadow: inset 0 0 10px rgba(0,0,0,.45), 0 0 8px rgba(0,0,0,.18);
    }
    .hud-meter-label {
        display: flex;
        min-width: 0;
        align-items: center;
        text-shadow: 0 0 7px currentColor;
    }
    .hud-system-icon {
        line-height: 1;
        filter: drop-shadow(0 0 5px currentColor);
        flex: 0 0 24px;
    }
    .shield-icon {
        color: #67e8f9;
        font-size: 22px;
        animation: shieldIconPulse 2.4s ease-in-out infinite;
    }
    .hull-icon {
        color: #fb7185;
        font-size: 22px;
    }

        @keyframes shieldIconPulse {
            0%,100% { transform:scale(1); opacity:.9; }
            50% { transform:scale(1.12); opacity:1; }
        }
    .hud-meter:has(.shield-bar-fill[style*="width: 0%"]) .shield-icon {
        opacity: .35;
        filter: none;
    }
    .hud-meter:has(.hp-bar-fill[style*="width: 0%"]) .hull-icon {
        opacity: .35;
        filter: none;
    }
    .hud-meter-label::before {
        content: '';
        width: 5px;
        height: 5px;
        border-radius: 50%;
        background: currentColor;
        box-shadow: 0 0 7px currentColor;
    }
    .hud-meter[title="Player Health Points"] {
        border-color: rgba(248,113,113,.24);
    }
    .hud-meter[title="Player Health Points"] .hud-meter-label {
        color: #fb7185 !important;
    }
    .hud-bar {
        margin-top: 3px;
    }
    .hud-bar .hp-bar-fill, .hud-bar .shield-bar-fill {
        position: relative;
        height: 100%;
        transition: width .12s linear, filter .15s ease;
    }
    .hud-bar .hp-bar-fill {
        background: linear-gradient(90deg,#991b1b,#ef4444,#fca5a5);
    }
    .hud-meter:has(.shield-bar-fill[style*="width: 0%"]) .shield-bar-fill {
        box-shadow: none;
    }
    .hud-meter:has(.hp-bar-fill[style*="width: 0%"]) .hp-bar-fill {
        box-shadow: none;
    }

        @keyframes shieldHudPulse {
            0%,100% { filter: brightness(1); } 50% { filter: brightness(1.65); }
        }
    .hud-meter:first-child .shield-bar-fill {
        animation: shieldHudPulse 2.8s ease-in-out infinite;
    }
    .hud-bar {
        background: rgba(2, 6, 23, 0.9);
        border: 1px solid rgba(100, 116, 139, 0.38);
        border-radius: 999px;
        overflow: hidden;
    }
    .hud-bar .hp-bar-fill, .hud-bar .shield-bar-fill {
        border-radius: inherit;
    }
    .hud-bar .shield-bar-fill {
        height: 100%;
        width: 0%;
        transition: width 0.08s linear, opacity 0.15s ease;
    }
    .hud-actions {
        display: flex !important;
        align-items: center;
    }
    .hud-action {
        padding: 0 !important;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border-radius: 7px !important;
        letter-spacing: 0 !important;
    }
    .coin-display {
        display: inline-flex;
        align-items: center;
        gap: 3px;
        white-space: nowrap;
    }
    .coin-display::first-letter {
        font-size: 0.72em;
    }
    .coin-display span {
        color: #fbbf24 !important;
    }
    .coin-display .coin-icon {
        display: inline-block;
        font-size: 0.72em;
        line-height: 1;
        flex: 0 0 auto;
    }
    :root { --graphics-css-glow: 1; }
    .hp-bar-fill, .shield-bar-fill {
        filter: brightness(calc(0.94 + var(--graphics-css-glow) * 0.06));
    }
    .hp-bar-fill {
        width: 100%;
        height: 100%;
        background: #22c55e;
        transition: width 0.1s linear, background-color 0.2s;
        box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
    }
    .diffSelect {
        background: rgba(30, 41, 59, 0.85);
        color: #f8fafc;
        border: 1px solid rgba(51, 65, 85, 0.7);
        border-radius: 8px;
        padding: 4px 8px;
        font-size: 11px;
        font-weight: 700;
        text-transform: uppercase;
        outline: none;
        cursor: pointer;
        touch-action: manipulation;
        pointer-events: auto !important;
        transition: all 0.15s ease;
        box-shadow: 0 2px 6px rgba(0,0,0,0.25);
    }
    .diffSelect:hover {
        background: #334155;
        border-color: #38bdf8;
        box-shadow: 0 0 12px rgba(56, 189, 248, 0.3);
    }
    .diffSelect:active {
        transform: scale(0.96);
    }

    #controls-deck { width:100%; max-width:100vw; padding:0; display:flex; align-items:center; justify-content:center; z-index:8; flex-shrink:0; touch-action:none; position:relative; background:transparent; border:0; box-shadow:none; }
    #deck-fire-zone { position:relative; width:min(860px,94vw); height:62px; margin:0 auto; padding:0; display:flex; align-items:center; justify-content:center; overflow:hidden; border-radius:9px; background:linear-gradient(90deg,#07172b,#0b3158,#07172b); border:1px solid #168cff; box-shadow:0 0 18px #087bff66 inset,0 0 14px #087bff55; pointer-events:auto; cursor:pointer; touch-action:none; user-select:none; }
    #deck-fire-zone::before { content:""; position:absolute; left:4%; right:4%; height:4px; top:7px; background:#25a9ff; box-shadow:0 0 10px #25a9ff; }
    #deck-fire-btn-inner { position:relative; z-index:2; display:flex; align-items:center; justify-content:center; padding:0; background:transparent; border:0; box-shadow:none; pointer-events:none; }
    #deck-fire-label { color:#dff5ff; font-weight:900; letter-spacing:3px; text-shadow:0 0 8px #168cff88; }
    #deck-fire-zone.fire-warm { border-color:#ffd23f; box-shadow:0 0 18px #ffd23f66 inset,0 0 14px #ffd23f55; }
    #deck-fire-zone.fire-warm::before { background:#ffd23f; box-shadow:0 0 10px #ffd23f; }
    #deck-fire-zone.fire-hot { border-color:#ff8a24; box-shadow:0 0 18px #ff8a2466 inset,0 0 14px #ff8a2455; }
    #deck-fire-zone.fire-hot::before { background:#ff8a24; box-shadow:0 0 10px #ff8a24; }
    #deck-fire-zone.fire-critical, #deck-fire-zone.fire-overheated { border-color:#ff365e; box-shadow:0 0 18px #ff365e66 inset,0 0 14px #ff365e55; }
    #deck-fire-zone.touch-active { transform:scale(0.985); filter:brightness(1.35); box-shadow:0 0 24px #25a9ffcc inset,0 0 22px #25a9ff99; }
    #deck-fire-zone.touch-active #deck-fire-label { text-shadow:0 0 12px #ffffff,0 0 20px #25a9ff; }
    #deck-fire-zone.fire-critical::before, #deck-fire-zone.fire-overheated::before { background:#ff365e; box-shadow:0 0 10px #ff365e; }

    .overlay-screen {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(2, 6, 23, 0.92);
        backdrop-filter: blur(14px);
        -webkit-backdrop-filter: blur(14px);
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: flex-start;
        z-index: 25;
        padding: 20px;
        text-align: center;
        pointer-events: auto;
        touch-action: auto;
        overflow-y: auto;
    }

    .overlay-fit {
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
        margin-top: auto;
        margin-bottom: auto;
    }
    .stage-eyebrow {
        color: #22d3ee;
        font-size: 11px;
        font-weight: 700;
        letter-spacing: 0.3em;
        text-transform: uppercase;
        margin-bottom: 4px;
    }
    .overlay-screen h1 {
        font-size: 26px;
        font-weight: 900;
        font-style: italic;
        letter-spacing: -0.03em;
        text-transform: uppercase;
        color: #f8fafc;
        margin: 0 0 4px 0;
        text-shadow: 0 0 30px rgba(6, 182, 212, 0.45);
    }
    .overlay-screen p {
        color: #94a3b8;
        font-size: 12px;
        margin: 0 0 16px 0;
        letter-spacing: 0.02em;
    }
    .sleek-card {
        background: rgba(15, 23, 42, 0.65);
        border: 1px solid rgba(51, 65, 85, 0.55);
        backdrop-filter: blur(12px);
        border-radius: 16px;
        padding: 16px;
        box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    }
    .stats-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        width: 100%;
        max-width: 340px;
        margin-bottom: 16px;
    }
    .stat-cell {
        background: rgba(15, 23, 42, 0.55);
        border: 1px solid rgba(51, 65, 85, 0.45);
        backdrop-filter: blur(8px);
        border-radius: 12px;
        padding: 10px 12px;
        text-align: left;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }
    .stat-label {
        font-size: 9px;
        color: #94a3b8;
        text-transform: uppercase;
        letter-spacing: 0.12em;
        font-weight: 600;
        margin-bottom: 2px;
    }
    .stat-val {
        font-size: 16px;
        font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
        font-weight: 700;
        color: #f8fafc;
    }
    .upgrade-panel {
        width: 100%;
        max-width: 380px;
        background: rgba(15, 23, 42, 0.72);
        border: 1px solid rgba(251, 191, 36, 0.38);
        border-radius: 14px;
        padding: 11px;
        margin: -2px 0 12px;
        box-shadow: 0 0 24px rgba(251, 191, 36, 0.08);
    }
    .upgrade-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 9px;
        color: #fde68a;
        font-size: 11px;
        font-weight: 800;
        letter-spacing: 0.14em;
        text-transform: uppercase;
    }
    .upgrade-header-actions {
        display: flex;
        align-items: center;
        gap: 8px;
    }
    #upgrade-hp-val {
        color: #86efac;
    }
    .stage-stats-panel {
        max-width: none;
        margin: 0 0 10px;
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }
    .stage-stats-panel .stat-cell {
        padding: 8px;
        border-radius: 8px;
    }
    .stage-stats-panel .stat-label {
        font-size: 7px;
    }
    .stage-stats-panel .stat-val {
        font-size: 14px;
    }
    .upgrade-balance {
        color: #fbbf24;
        font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
        letter-spacing: 0;
        font-size: 13px;
    }
    .upgrade-tabs {
        grid-template-columns: 1fr 1fr 1fr;
        gap: 6px;
        margin-bottom: 8px;
    }
    .upgrade-tab-btn {
        font-weight: 800;
        touch-action: manipulation;
    }
    .upgrade-card {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 5px;
        padding: 8px;
        min-height: 82px;
        border: 1px solid rgba(71, 85, 105, 0.8);
        border-radius: 10px;
        color: #e2e8f0;
        text-align: left;
    }
    .upgrade-card strong {
        font-size: 10px;
        color: #f8fafc;
        letter-spacing: 0.03em;
    }
    .upgrade-card small {
        color: #94a3b8;
        font-size: 9px;
        line-height: 1.25;
        min-height: 22px;
    }
    .upgrade-current-value {
        display: block;
        margin-top: 3px;
        color: #67e8f9;
        font-size: 8px;
        font-weight: 800;
        letter-spacing: 0.03em;
    }
    .upgrade-card button {
        margin-top: auto;
        padding: 5px 6px;
        border: 1px solid rgba(251, 191, 36, 0.65);
        border-radius: 7px;
        font-size: 9px;
        font-weight: 800;
        cursor: pointer;
        text-transform: uppercase;
        touch-action: manipulation;
    }
    .upgrade-card button:hover:not(:disabled) {
        background: #92400e;
        box-shadow: 0 0 12px rgba(251, 191, 36, 0.25);
    }
    .upgrade-card button:disabled {
        opacity: 0.42;
        cursor: not-allowed;
    }
    .debug-back-btn {
        background: rgba(127, 29, 29, 0.5);
        border: 1px solid rgba(248, 113, 113, 0.4);
        color: #fecaca;
        padding: 8px 12px;
        border-radius: 8px;
        font-size: 10px;
        font-weight: 800;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        cursor: pointer;
        touch-action: manipulation;
        margin-top: 8px;
        display: none;
    }
    .debug-back-btn:hover {
        background: rgba(248, 113, 113, 0.35);
    }
    .upgrade-card.maxed {
        border-color: rgba(34, 197, 94, 0.6);
    }
    .upgrade-card.maxed button {
        border-color: rgba(34, 197, 94, 0.5);
        background: rgba(20, 83, 45, 0.65);
        color: #86efac;
    }
    @media (max-width: 360px) {
        #ui {
            min-height: 76px;
            gap: 6px;
            padding: 6px 8px;
        }
        .hud-primary {
            flex: 1 1 100%;
            min-width: 0;
        }
        .hud-meters {
            flex: 1 1 118px;
            min-width: 0;
        }
        .hud-actions {
            flex: 0 0 90px;
        }
        .stage-stats-panel {
            grid-template-columns: 1fr 1fr;
        }
        .upgrade-header-actions {
            gap: 4px;
        }
        .upgrade-card {
            padding: 6px;
        }
        .upgrade-card small {
            font-size: 8px;
        }
        .ts-debug-btn {
            font-size: 7px;
            min-height: 32px;
            padding: 3px 4px;
        }
        .hud-countdown-value.hud-countdown-text {
            font-size: 7px;
        }
    }
    .menu-btn {
        background: linear-gradient(135deg, #06b6d4, #0891b2);
        border: 1px solid #67e8f9;
        color: #ffffff;
        padding: 12px 34px;
        font-size: 14px;
        font-weight: 800;
        border-radius: 9999px;
        cursor: pointer;
        text-transform: uppercase;
        letter-spacing: 0.08em;
        box-shadow: 0 0 25px rgba(6, 182, 212, 0.45), 0 4px 12px rgba(0,0,0,0.4);
        margin-top: 6px;
        touch-action: manipulation;
        pointer-events: auto;
        transition: all 0.15s ease;
    }
    .menu-btn:hover {
        box-shadow: 0 0 35px rgba(6, 182, 212, 0.65), 0 6px 18px rgba(0,0,0,0.4);
        transform: translateY(-1px);
    }
    .menu-btn:active {
        transform: scale(0.96);
    }
    #title-screen {
        z-index: 30;
        justify-content: flex-start;
        gap: 0;
        padding: 24px 20px;
        background: radial-gradient(ellipse at 50% 32%, rgba(9,24,54,0.93) 0%, rgba(2,6,23,0.96) 58%, rgba(2,6,23,0.98) 100%);
    }
    #pause-screen {
        z-index: 20;
        justify-content: flex-start;
        gap: 0;
        padding: 24px 20px;
        background: radial-gradient(ellipse at 50% 32%, rgba(9,24,54,0.93) 0%, rgba(2,6,23,0.96) 58%, rgba(2,6,23,0.98) 100%);
    }
    .ts-stars {
        position: absolute;
        inset: 0;
        z-index: 1;
        pointer-events: none;
        background-image: radial-gradient(1px 1px at 30px 40px, rgba(255,255,255,0.85), transparent),
                radial-gradient(1px 1px at 120px 90px, rgba(125,211,252,0.7), transparent),
                radial-gradient(1.5px 1.5px at 80px 150px, rgba(255,255,255,0.55), transparent),
                radial-gradient(1px 1px at 165px 60px, rgba(196,181,253,0.65), transparent),
                radial-gradient(1px 1px at 40px 180px, rgba(255,255,255,0.5), transparent);
        background-size: 200px 200px;
        animation: ts-starscroll 9s linear infinite;
        opacity: 0.55;
    }

        @keyframes ts-starscroll {
            from { background-position: 0 0; }
            to { background-position: 0 200px; }
        }
    .ts-vignette {
        position: absolute;
        inset: 0;
        z-index: 2;
        pointer-events: none;
        box-shadow: inset 0 0 130px 22px rgba(2,6,23,0.92);
    }
    .ts-scanlines {
        position: absolute;
        inset: 0;
        z-index: 3;
        pointer-events: none;
        background: repeating-linear-gradient(to bottom, rgba(0,0,0,0) 0, rgba(0,0,0,0) 2px, rgba(0,0,0,0.14) 3px, rgba(0,0,0,0) 4px);
        opacity: 0.7;
    }
    .ts-inner {
        position: relative;
        z-index: 4;
        display: flex;
        flex-direction: column;
        align-items: center;
        width: 100%;
        max-width: 330px;
        margin-top: auto;
        margin-bottom: auto;
    }
    .ts-title {
        font-size: 52px;
        line-height: 0.84;
        font-weight: 900;
        font-style: italic;
        letter-spacing: -0.045em;
        text-transform: uppercase;
        text-align: center;
        color: #f0f9ff;
        margin: 0;
        text-shadow: 0 0 6px rgba(255,255,255,0.45),
                0 0 22px rgba(56,189,248,0.85),
                0 0 46px rgba(56,189,248,0.45),
                3px 3px 0 rgba(139,92,246,0.5),
                -2px -2px 0 rgba(244,63,94,0.32);
        opacity: 0;
        transform: translateY(-24px) scale(0.86);
        animation: ts-drop-in 0.7s cubic-bezier(0.2,0.9,0.25,1.12) 0.05s forwards;
    }
    .ts-title span {
        display: block;
    }
    .ts-title .ts-hawk {
        color: #38bdf8;
    }
    .ts-ship-stage {
        position: relative;
        width: 100%;
        height: 118px;
        display: flex;
        align-items: center;
        justify-content: center;
        margin: 26px 0 8px;
        opacity: 0;
        animation: ts-fade-in 0.6s ease 0.35s forwards;
    }
    .ts-ship {
        position: relative;
        width: 58px;
        height: 77px;
        animation: ts-float 3.2s ease-in-out infinite;
        filter: drop-shadow(0 10px 16px rgba(56,189,248,0.4));
        transform: scale(1.65);
    }
    .ts-ship-img {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        object-fit: contain;
        filter: drop-shadow(0 0 9px rgba(56,189,248,0.65));
        pointer-events: none;
        transform: scale(1.8);
    }
    .ts-thruster {
        position: absolute;
        bottom: -9px;
        width: 7px;
        height: 20px;
        border-radius: 0 0 60% 60%;
        background: linear-gradient(to bottom, #fef9c3, #fb923c 45%, rgba(194,65,12,0) 100%);
        filter: blur(0.8px);
        transform-origin: top center;
        animation: ts-flame 0.11s steps(2) infinite;
    }
    .ts-thruster.left {
        left: 31%;
        transform: translateX(-50%);
    }
    .ts-thruster.right {
        right: 31%;
        transform: translateX(50%);
        animation-delay: 0.05s;
    }
    .ts-diff {
        display: flex;
        gap: 8px;
        width: 100%;
        margin: 14px 0 2px;
        opacity: 0;
        animation: ts-fade-in 0.6s ease 0.5s forwards;
    }
    .ts-chip {
        flex: 1;
        padding: 9px 4px 8px;
        border-radius: 12px;
        cursor: pointer;
        background: rgba(15,23,42,0.6);
        border: 1.5px solid rgba(71,85,105,0.5);
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 3px;
        color: #cbd5e1;
        transition: all 0.15s ease;
        touch-action: manipulation;
    }
    .ts-chip-name {
        font-size: 12px;
        font-weight: 800;
        text-transform: uppercase;
        letter-spacing: 0.05em;
    }
    .ts-chip-sub {
        font-size: 7.5px;
        letter-spacing: 0.12em;
        text-transform: uppercase;
        color: #64748b;
    }
    .ts-chip:active {
        transform: scale(0.96);
    }
    .ts-chip.active .ts-chip-sub {
        color: inherit;
        opacity: 0.7;
    }
    .ts-chip[data-diff="veryeasy"].active {
        border-color: #2dd4bf;
        color: #99f6e4;
        background: rgba(45,212,191,0.14);
        box-shadow: 0 0 16px rgba(45,212,191,0.35), inset 0 0 12px rgba(45,212,191,0.12);
    }
    .ts-chip[data-diff="easy"].active {
        border-color: #4ade80;
        color: #bbf7d0;
        background: rgba(34,197,94,0.14);
        box-shadow: 0 0 16px rgba(74,222,128,0.35), inset 0 0 12px rgba(74,222,128,0.12);
    }
    .ts-chip[data-diff="normal"].active {
        border-color: #38bdf8;
        color: #bae6fd;
        background: rgba(56,189,248,0.14);
        box-shadow: 0 0 16px rgba(56,189,248,0.4), inset 0 0 12px rgba(56,189,248,0.14);
    }
    .ts-chip[data-diff="hard"].active {
        border-color: #f43f5e;
        color: #fecdd3;
        background: rgba(244,63,94,0.16);
        box-shadow: 0 0 18px rgba(244,63,94,0.42), inset 0 0 12px rgba(244,63,94,0.14);
    }
    .ts-chip[data-diff="veryhard"].active {
        border-color: #c026d3;
        color: #f5d0fe;
        background: rgba(192,38,211,0.18);
        box-shadow: 0 0 18px rgba(192,38,211,0.45), inset 0 0 12px rgba(192,38,211,0.16);
    }
    .ts-play {
        position: relative;
        width: 100%;
        margin: 16px 0 8px;
        padding: 15px 24px 14px;
        border-radius: 14px;
        cursor: pointer;
        border: 1.5px solid #67e8f9;
        background: linear-gradient(135deg, #22d3ee, #0891b2);
        color: #042a34;
        text-transform: uppercase;
        touch-action: manipulation;
        box-shadow: 0 0 24px rgba(34,211,238,0.5), 0 6px 18px rgba(0,0,0,0.5);
        opacity: 0;
        animation: ts-fade-in 0.5s ease 0.6s forwards, ts-play-pulse 1.7s ease-in-out 1.1s infinite;
    }
    .ts-play .ts-play-coin {
        display: block;
        font-size: 9px;
        font-weight: 800;
        letter-spacing: 0.28em;
        opacity: 0.75;
        margin-bottom: 3px;
    }
    .ts-play .ts-play-main {
        display: block;
        font-size: 19px;
        font-weight: 900;
        font-style: italic;
        letter-spacing: 0.16em;
    }
    .ts-play:hover {
        filter: brightness(1.08);
    }
    .ts-play:active {
        transform: scale(0.97) !important;
    }
    .deck-center-panel {
        display: none !important;
    }

        @keyframes ts-play-pulse {
            0%, 100% { box-shadow: 0 0 20px rgba(34,211,238,0.42), 0 6px 18px rgba(0,0,0,0.5); transform: scale(1); }
            50% { box-shadow: 0 0 40px rgba(34,211,238,0.8), 0 6px 22px rgba(0,0,0,0.5); transform: scale(1.02); }
        }
    .ts-hi {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        font-size: 9.5px;
        font-weight: 700;
        letter-spacing: 0.18em;
        text-transform: uppercase;
        color: #94a3b8;
        margin-top: 2px;
        opacity: 0;
        animation: ts-fade-in 0.6s ease 0.7s forwards;
    }
    .ts-hi b {
        color: #fbbf24;
        font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
        letter-spacing: 0;
        font-size: 13px;
    }
    .ts-options-toggle {
        margin-top: 14px;
        background: none;
        border: none;
        cursor: pointer;
        color: #64748b;
        font-size: 10px;
        font-weight: 700;
        letter-spacing: 0.15em;
        text-transform: uppercase;
        display: inline-flex;
        align-items: center;
        gap: 6px;
        transition: color 0.15s ease;
        touch-action: manipulation;
        opacity: 0;
        animation: ts-fade-in 0.6s ease 0.8s forwards;
    }
    .ts-options-toggle:hover {
        color: #38bdf8;
    }
    .ts-options-toggle .ts-caret {
        font-size: 8px;
        transition: transform 0.2s ease;
    }
    .ts-options-toggle.open .ts-caret {
        transform: rotate(180deg);
    }
    .ts-options {
        width: 100%;
        max-height: 0;
        overflow: hidden;
        opacity: 0;
        margin-top: 0;
        transition: max-height 0.3s ease, opacity 0.3s ease, margin-top 0.3s ease;
    }
    .ts-options.open {
        max-height: 400px;
        opacity: 1;
        margin-top: 12px;
    }
    .ts-quality-picker {
        width: 100%;
        margin-top: 2px;
        padding: 6px 7px;
        border: 1px solid rgba(56,189,248,0.16);
        border-radius: 10px;
        background: linear-gradient(180deg, rgba(15,23,42,0.72), rgba(2,6,23,0.62));
        box-sizing: border-box;
    }
    .ts-quality-picker-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        margin-bottom: 5px;
    }
    .ts-quality-picker-title {
        font-size: 9px;
        color: #94a3b8;
        text-transform: uppercase;
        font-weight: 800;
        letter-spacing: 0.12em;
    }
    .ts-quality-picker-mode {
        font-size: 9px;
        color: #38bdf8;
        font-weight: 800;
        letter-spacing: 0.06em;
        font-variant-numeric: tabular-nums;
    }
    .ts-quality-options {
        display: grid;
        grid-template-columns: repeat(6, minmax(0, 1fr));
        gap: 4px;
    }
    .ts-quality-option {
        appearance: none;
        min-width: 0;
        padding: 4px 2px;
        border: 1px solid rgba(148,163,184,0.18);
        border-radius: 7px;
        background: rgba(15,23,42,0.72);
        color: #94a3b8;
        font: 800 8px/1.1 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
        cursor: pointer;
        touch-action: manipulation;
        transition: border-color .15s ease, background .15s ease, color .15s ease, transform .12s ease, box-shadow .15s ease;
    }
    .ts-quality-option:hover {
        border-color: rgba(56,189,248,0.48);
        color: #e2e8f0;
    }
    .ts-quality-option:active { transform: scale(0.97); }
    .ts-quality-option.active {
        border-color: rgba(56,189,248,0.78);
        background: linear-gradient(180deg, rgba(14,116,144,0.42), rgba(8,47,73,0.56));
        color: #e0f2fe;
        box-shadow: 0 0 10px rgba(56,189,248,0.14), inset 0 0 10px rgba(56,189,248,0.05);
    }
    .ts-quality-option small {
        display: block;
        margin-top: 2px;
        font: 700 6.5px/1.1 system-ui, sans-serif;
        letter-spacing: 0.02em;
        color: #64748b;
    }
    .ts-quality-option.active small { color: #7dd3fc; }
    @media (max-width: 380px) {
        .ts-quality-options { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    }
    .ts-ship, #pause-ship {
        cursor: default;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
        outline: none;
        -webkit-focus-ring-color: transparent;
    }
    .ts-ship:active, #pause-ship:active, .ts-ship:focus, #pause-ship:focus {
        outline: none;
        transform: none;
        box-shadow: none;
    }
    .ts-ship {
        cursor: default;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }
    .ts-ship:active {
        transform: none;
    }
    .ts-options-card {
        background: rgba(15,23,42,0.65);
        border: 1px solid rgba(51,65,85,0.55);
        border-radius: 14px;
        padding: 10px;
        display: flex;
        flex-direction: column;
        gap: 7px;
    }
    .ts-opt-row {
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
    .ts-opt-row label {
        font-size: 9px;
        color: #94a3b8;
        text-transform: uppercase;
        font-weight: 700;
        letter-spacing: 0.05em;
    }
    .ts-options-card select.diffSelect,
    .sleek-card select.diffSelect {
        padding: 3px 6px;
        font-size: 9px;
        border-radius: 6px;
    }

        @keyframes ts-fade-in {
            from { opacity: 0; transform: translateY(8px); }
            to { opacity: 1; transform: translateY(0); }
        }

        @keyframes ts-drop-in {
            0% { opacity: 0; transform: translateY(-24px) scale(0.86); }
            60% { opacity: 1; }
            100% { opacity: 1; transform: translateY(0) scale(1); }
        }

        @keyframes ts-float {
            0%, 100% { transform: translateY(0); }
            50% { transform: translateY(-8px); }
        }

        @keyframes ts-flame {
            0% { transform: scaleY(0.78); opacity: 0.85; }
            100% { transform: scaleY(1.15); opacity: 1; }
        }
    .sleek-divider {
        width: 48px;
        height: 3px;
        background: rgba(6, 182, 212, 0.35);
        border-radius: 9999px;
        margin: 10px 0 12px 0;
    }
    .upgrade-ship-layout {
        position: relative;
        width: 100%;
        max-width: 700px;
        margin: 12px auto 14px;
        min-height: 320px;
        display: flex;
        justify-content: center;
        align-items: center;
        overflow: visible;
    }
    .upgrade-ship-art {
        width: 150px;
        height: 220px;
        object-fit: contain;
        filter: drop-shadow(0 0 14px rgba(56,189,248,.35));
        user-select: none;
        pointer-events: none;
        z-index: 1;
    }
    .upgrade-ship-glow {
        position: absolute;
        width: 155px;
        height: 155px;
        border-radius: 50%;
        background: radial-gradient(circle, rgba(34,211,238,.18), rgba(34,211,238,.04) 55%, transparent 72%);
        box-shadow: 0 0 35px rgba(34,211,238,.12);
        z-index: 0;
    }
    .upgrade-tabs {
        position: absolute;
        inset: 0;
        display: block;
        margin: 0;
        z-index: 3;
        pointer-events: none;
    }
    .upgrade-tab-btn {
        position: absolute;
        width: 122px;
        min-height: 50px;
        padding: 7px 8px;
        border: 1px solid rgba(56,189,248,.42);
        border-radius: 12px;
        background: rgba(8,15,30,.86);
        box-shadow: 0 0 18px rgba(14,165,233,.10), inset 0 0 18px rgba(15,23,42,.8);
        color: #cbd5e1;
        font-size: 10px;
        letter-spacing: .08em;
        text-transform: uppercase;
        cursor: pointer;
        pointer-events: auto;
        backdrop-filter: blur(5px);
    }
    .upgrade-tab-btn::after {
        content: "";
        display: block;
        margin: 5px auto 0;
        width: 42px;
        height: 2px;
        border-radius: 99px;
        background: rgba(56,189,248,.45);
    }
    .upgrade-tab-btn.active {
        color: #67e8f9;
        border-color: rgba(34,211,238,.9);
        background: rgba(8,47,73,.9);
        box-shadow: 0 0 22px rgba(34,211,238,.24), inset 0 0 14px rgba(34,211,238,.08);
    }
    .upgrade-tab-btn[data-tab="offense"] {
        top: 0;
        left: 50%;
        transform: translateX(-50%);
    }
    .upgrade-tab-btn[data-tab="defense"] {
        top: 50%;
        left: 0;
        transform: translateY(-50%);
    }
    .upgrade-tab-btn[data-tab="systems"] {
        top: 50%;
        right: 0;
        transform: translateY(-50%);
    }
    .upgrade-zone-line {
        position: absolute;
        height: 1px;
        background: linear-gradient(90deg, transparent, rgba(56,189,248,.45), transparent);
        opacity: .7;
        z-index: 0;
    }
    .upgrade-zone-line.offense {
        width: 90px;
        top: 58px;
        left: 50%;
        transform: translateX(-50%);
    }
    .upgrade-zone-line.defense {
        width: 70px;
        top: 50%;
        left: 112px;
        transform: rotate(0deg);
    }
    .upgrade-zone-line.systems {
        width: 70px;
        top: 50%;
        right: 112px;
        transform: rotate(0deg);
    }
    .upgrade-grid {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 7px;
    }
    .upgrade-card {
        background: rgba(8,15,30,.88);
        border-color: rgba(56,189,248,.28);
        box-shadow: 0 0 14px rgba(15,23,42,.55);
    }
    .upgrade-card button {
        border-color: rgba(34,211,238,.55);
        background: rgba(8,47,73,.72);
        color: #a5f3fc;
    }
    .upgrade-preview-fx {
        position: absolute;
        left: 50%;
        top: 50%;
        width: 150px;
        height: 220px;
        transform: translate(-50%, -50%);
        z-index: 2;
        pointer-events: none;
    }
    .upgrade-preview-fx > * {
        position: absolute;
        opacity: 0;
        pointer-events: none;
    }
    .preview-shield {
        left: 50%;
        top: 50%;
        width: 145px;
        height: 205px;
        transform: translate(-50%,-50%);
        border: 2px solid rgba(103,232,249,.9);
        border-radius: 48% 48% 45% 45%;
        box-shadow: 0 0 10px rgba(34,211,238,.8), inset 0 0 18px rgba(34,211,238,.18);
    }
    .preview-laser {
        left: 50%;
        top: 2px;
        width: 5px;
        height: 92px;
        transform: translateX(-50%);
        border-radius: 999px;
        background: linear-gradient(to bottom, rgba(255,255,255,.98), #67e8f9 25%, #22d3ee 70%, transparent);
        box-shadow: 0 0 8px #67e8f9, 0 0 20px rgba(34,211,238,.8);
        transform-origin: bottom center;
    }
    .preview-laser-left {
        width: 4px;
        left: 43%;
    }
    .preview-laser-right {
        width: 4px;
        left: 57%;
    }
    .preview-engine {
        bottom: 7px;
        width: 7px;
        height: 28px;
        border-radius: 0 0 50% 50%;
        background: linear-gradient(#fef9c3,#38bdf8,transparent);
        filter: blur(.5px);
    }
    .preview-engine-left {
        left: 31%;
    }
    .preview-engine-right {
        right: 31%;
    }
    .preview-impact {
        left: 50%;
        top: 44%;
        width: 22px;
        height: 22px;
        border: 2px solid #67e8f9;
        border-radius: 50%;
        transform: translate(-50%,-50%) scale(.4);
        box-shadow: 0 0 18px #22d3ee;
    }
    .upgrade-preview-fx.preview-damage .preview-impact, .upgrade-preview-fx.preview-crit .preview-impact {
        animation: upgrade-impact .55s ease-out infinite;
        opacity: 1;
    }
    .upgrade-preview-fx.preview-fireRate .preview-laser-main, .upgrade-preview-fx.preview-bulletSpeed .preview-laser-main {
        animation: upgrade-laser-pulse .22s linear infinite;
        opacity: 1;
    }
    .upgrade-preview-fx.preview-spread .preview-laser-left, .upgrade-preview-fx.preview-spread .preview-laser-right {
        animation: upgrade-wing-fire .48s ease-in-out infinite;
        opacity: 1;
    }
    .upgrade-preview-fx.preview-spread .preview-laser-main {
        opacity: .75;
    }
    .upgrade-preview-fx.preview-shield .preview-shield, .upgrade-preview-fx.preview-shieldHarvest .preview-shield, .upgrade-preview-fx.preview-shieldLeech .preview-shield {
        animation: upgrade-shield-pulse 1.1s ease-in-out infinite;
        opacity: 1;
    }
    .upgrade-preview-fx.preview-heatSink .preview-engine, .upgrade-preview-fx.preview-ventSpeed .preview-engine, .upgrade-preview-fx.preview-overheatThreshold .preview-engine {
        animation: upgrade-engine-pulse .65s ease-in-out infinite;
        opacity: 1;
    }
    .upgrade-preview-fx.preview-shieldLeech .preview-laser-main {
        animation: upgrade-laser-pulse .4s linear infinite;
        opacity: 1;
    }

    /* More HP previews the hull becoming tougher without inventing a new sprite. */
    .upgrade-preview-fx.preview-maxHp ~ .upgrade-ship-art,
    .upgrade-ship-layout.previewing .upgrade-ship-art {
        transition: filter 180ms ease;
    }
    .upgrade-ship-layout.previewing:has(#upgrade-preview-fx.preview-maxHp) .upgrade-ship-art {
        filter: drop-shadow(0 0 20px rgba(34,211,238,.65)) brightness(1.06) saturate(1.08);
    }

        @keyframes upgrade-laser-pulse {
            0% { transform: translateX(-50%) scaleY(.55); opacity: .25; }
            35% { transform: translateX(-50%) scaleY(1); opacity: 1; }
            100% { transform: translateX(-50%) scaleY(.55); opacity: .25; }
        }

        @keyframes upgrade-wing-fire {
            0%,100% { transform: scaleY(.35); opacity: .2; }
            45% { transform: scaleY(1); opacity: 1; }
        }

        @keyframes upgrade-impact {
            0% { transform: translate(-50%,-50%) scale(.35); opacity: 1; }
            100% { transform: translate(-50%,-50%) scale(2.5); opacity: 0; }
        }

        @keyframes upgrade-shield-pulse {
            0%,100% { transform: translate(-50%,-50%) scale(.96); opacity: .5; }
            50% { transform: translate(-50%,-50%) scale(1.04); opacity: 1; }
        }

        @keyframes upgrade-engine-pulse {
            0%,100% { transform: scaleY(.55); opacity: .35; }
            50% { transform: scaleY(1.35); opacity: 1; }
        }
    .upgrade-card.previewing {
        border-color: rgba(103,232,249,.9);
        box-shadow: 0 0 22px rgba(34,211,238,.2), inset 0 0 14px rgba(34,211,238,.08);
        transform: translateY(-2px);
    }
    .upgrade-card.upgrade-applied {
        border-color: rgba(251,191,36,.95);
        box-shadow: 0 0 28px rgba(251,191,36,.28), inset 0 0 18px rgba(251,191,36,.10);
        animation: upgrade-card-applied .6s ease-in-out 2;
    }
    .upgrade-ship-layout.previewing .upgrade-ship-art {
        filter: drop-shadow(0 0 18px rgba(56,189,248,.65));
    }
    .upgrade-ship-layout.upgrade-applied .upgrade-ship-art {
        filter: drop-shadow(0 0 26px rgba(103,232,249,.9)) brightness(1.12);
        animation: upgrade-ship-applied .8s ease-in-out 3;
    }
    .upgrade-preview-fx.upgrade-applied-fx .preview-shield {
        box-shadow: 0 0 20px rgba(34,211,238,.95), 0 0 42px rgba(34,211,238,.45), inset 0 0 22px rgba(34,211,238,.25);
    }
    .upgrade-preview-fx.upgrade-applied-fx .preview-laser {
        filter: brightness(1.35);
    }
    .upgrade-preview-fx.upgrade-applied-fx .preview-engine {
        filter: brightness(1.45) blur(.5px);
    }
    @keyframes upgrade-card-applied {
        0%,100% { transform: translateY(0); }
        50% { transform: translateY(-4px); }
    }
    @keyframes upgrade-ship-applied {
        0%,100% { transform: scale(1); }
        50% { transform: scale(1.045); }
    }
    @media (max-width: 699px) {
        .upgrade-preview-fx {
            width: 110px;
            height: 165px;
        }
    }

    html, body {
            width: 100%;
            height: 100%;
            min-height: 100%;
        }
        #game-container {
            position: fixed;
            inset: 0;
            width: 100vw;
            height: 100dvh;
            max-width: none !important;
            z-index: 1;
            justify-content: stretch;
            align-items: stretch;
        }
        #gameCanvas {
            width: 100vw !important;
            height: 100dvh !important;
            max-width: none;
            max-height: none;
            aspect-ratio: auto;
            border: 0;
            box-shadow: none;
        }
        #ui {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            z-index: 20;
            pointer-events: none;
        }
    #controls-deck {
        position: absolute;
        left: 0;
        bottom: 0;
        width: 100%;
        z-index: 20;
        margin: 0;
    }
    @media (max-width: 699px) {
        .upgrade-ship-layout {
            min-height: 250px;
            max-width: 340px;
            margin-top: 10px;
        }
        .upgrade-ship-art {
            width: 110px;
            height: 165px;
        }
        .upgrade-ship-glow {
            width: 120px;
            height: 120px;
        }
        .upgrade-tab-btn {
            width: 94px;
            min-height: 44px;
            font-size: 8px;
        }
        .upgrade-tab-btn[data-tab="offense"] {
            top: 0;
        }
        .upgrade-tab-btn[data-tab="defense"] {
            top: 50%;
            left: 0;
            transform: translateY(-50%);
        }
        .upgrade-tab-btn[data-tab="systems"] {
            top: 50%;
            right: 0;
            transform: translateY(-50%);
        }
        .upgrade-zone-line.offense {
            top: 50px;
        }
        .upgrade-zone-line.defense {
            top: 50%;
            left: 94px;
            width: 36px;
        }
        .upgrade-zone-line.systems {
            top: 50%;
            right: 94px;
            width: 36px;
        }
    }
    #ui {
        background: linear-gradient(180deg, rgba(3,10,24,.96), rgba(5,15,32,.82) 72%, rgba(5,15,32,.18));
        border-bottom: 1px solid rgba(103,232,249,.28);
        box-shadow: 0 4px 22px rgba(0,0,0,.28), inset 0 -1px 0 rgba(56,189,248,.08);
    }
    #ui::before {
        content: "";
        position: absolute;
        inset: 0;
        pointer-events: none;
        background: repeating-linear-gradient(90deg, transparent 0 42px, rgba(103,232,249,.025) 43px, transparent 44px);
        opacity: .7;
    }
    .hud-stat {
        position: relative;
        background: linear-gradient(145deg, rgba(15,35,58,.72), rgba(5,15,30,.5));
        border: 1px solid rgba(100,116,139,.25);
        border-right: 1px solid rgba(100,116,139,.25);
        border-radius: 6px;
        box-shadow: inset 0 0 10px rgba(56,189,248,.035);
        overflow: hidden;
    }
    .hud-stat::after {
        content: "";
        position: absolute;
        left: 7px;
        right: 7px;
        bottom: 0;
        height: 1px;
        background: linear-gradient(90deg, transparent, rgba(103,232,249,.45), transparent);
    }
    .hud-label {
        color: #7890a8;
        text-transform: uppercase;
    }
    .hud-value {
        text-shadow: 0 0 9px currentColor;
    }
    .hud-stat.score {
        border-color: rgba(34,211,238,.3);
    }
    .hud-stat.stage {
        border-color: rgba(167,139,250,.3);
    }
    .hud-stat.difficulty {
        border-color: rgba(74,222,128,.25);
    }
    .hud-stat.coins {
        border-color: rgba(251,191,36,.28);
    }
    .hud-stat.boss {
        border-color: rgba(248,113,113,.25);
    }
    .hud-meters {
        background: rgba(2,8,20,.62);
        border: 1px solid rgba(100,116,139,.25);
        border-radius: 6px;
    }
    .hud-meter-label {
        font-weight: 900;
        letter-spacing: .13em;
    }
    .hud-bar {
        border-color: rgba(148,163,184,.35);
        box-shadow: inset 0 1px 4px #000, 0 0 5px rgba(0,0,0,.35);
    }
    .hud-bar .shield-bar-fill {
        background: linear-gradient(90deg,#0284c7,#22d3ee,#a5f3fc);
        box-shadow: 0 0 5px #22d3ee, 0 0 12px rgba(34,211,238,.55);
    }
    .hud-bar .hp-bar-fill {
        box-shadow: 0 0 6px rgba(248,113,113,.65);
    }
    .hud-actions {
        flex-basis: 94px;
        gap: 5px !important;
    }
    .hud-action {
        border: 1px solid rgba(103,232,249,.24) !important;
        background: linear-gradient(145deg, rgba(15,35,58,.9), rgba(4,12,25,.9)) !important;
        box-shadow: inset 0 0 8px rgba(34,211,238,.05), 0 0 7px rgba(0,0,0,.35);
        color: #bae6fd !important;
    }
    .hud-action:hover {
        border-color: rgba(103,232,249,.65) !important;
        box-shadow: 0 0 12px rgba(34,211,238,.18), inset 0 0 10px rgba(34,211,238,.08);
    }
    @media (max-width:699px) {
        #ui {
            padding: 6px 6px 5px;
        }
        .hud-primary {
            gap: 3px;
        }
        .hud-stat {
            padding: 4px 5px 3px;
            border-radius: 5px;
        }
        .hud-label {
            font-size: 5.5px;
        }
        .hud-value {
            font-size: 11px;
        }
        .hud-meters {
            min-width: 118px;
            padding: 3px 5px;
        }
        .hud-actions {
            flex-basis: 76px;
        }
        .hud-action {
            width: 24px;
            height: 24px;
            font-size: 10px !important;
        }
    }
    #ui {
        min-height: 66px;
        padding: 8px 12px;
    }
    .hud-primary {
        flex: 1 1 auto;
        min-width: 0;
        align-items: stretch;
    }
    .hud-stat {
        flex: 1 1 0;
        min-width: 92px;
        min-height: 43px;
        padding: 7px 11px 6px;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }
    .hud-stat.score {
        flex-basis: 1.15;
    }
    .hud-stat.stage {
        flex-basis: .9;
    }
    .hud-stat.difficulty {
        flex-basis: 1.15;
    }
    .hud-stat.coins {
        flex-basis: 1.0;
    }
    .hud-stat.boss {
        flex-basis: 1.0;
    }
    .hud-label {
        font-size: 7px;
        margin-bottom: 6px;
        letter-spacing: .2em;
    }
    .hud-value {
        font-size: 15px;
        line-height: 1.05;
        overflow: visible;
        text-overflow: clip;
    }
    .hud-stat.difficulty .hud-value {
        font-size: 12px;
    }
    .hud-meter {
        padding: 4px 7px 5px;
    }
    .hud-meter-label {
        gap: 6px;
    }
    .hud-system-icon {
        width: 25px;
        height: 22px;
        flex-basis: 25px;
        font-size: 24px;
    }
    .shield-icon, .hull-icon {
        font-size: 24px;
    }
    @media (max-width: 980px) {
        #ui {
            min-height: 104px;
        }
        .hud-primary {
            flex: 1 1 100%;
            width: 100%;
        }
    }
    @media (max-width: 699px) {
        #ui {
            min-height: 126px;
            padding: 6px;
            gap: 5px;
        }
        .hud-primary {
            display: grid;
            grid-template-columns: repeat(2, minmax(0, 1fr));
            gap: 4px;
        }
        .hud-stat {
            min-width: 0;
            min-height: 39px;
            padding: 5px 7px;
        }
        .hud-stat.score {
            grid-column: span 2;
        }
        .hud-label {
            font-size: 6px;
            margin-bottom: 4px;
        }
        .hud-value {
            font-size: 12px;
        }
        .hud-stat.difficulty .hud-value {
            font-size: 10px;
        }
        .hud-meters {
            padding: 4px 5px;
        }
        .hud-meter {
            gap: 6px;
        }
        .hud-meter-label {
            font-size: 7px;
        }
        .hud-system-icon, .shield-icon, .hull-icon {
            font-size: 22px;
        }
    }
    #ui {
        display: flex;
    }
    .hud-meters {
        padding: 7px 10px !important;
    }
    .hud-meter-label {
        white-space: nowrap;
        overflow: visible;
    }
    .hud-actions {
        justify-content: flex-end;
    }
    .hud-action {
        width: 40px !important;
        height: 40px !important;
        font-size: 13px !important;
    }
    #pause-btn {
        font-size: 11px !important;
    }
    @media (max-width: 980px) {
        .hud-meters {
            flex: 1 1 270px !important;
            min-width: 250px !important;
        }
        .hud-actions {
            flex: 0 0 48px !important;
        }
    }
    @media (max-width: 699px) {
        .hud-meters {
            flex: 1 1 100% !important;
            min-width: 0 !important;
        }
        .hud-meter {
            grid-template-columns: 70px minmax(0,1fr) !important;
        }
        .hud-bar {
            height: 9px !important;
        }
        .hud-actions {
            flex: 0 0 44px !important;
            width: 44px;
        }
        .hud-action {
            width: 36px !important;
            height: 36px !important;
        }
    }
    #deck-joy-base {
        touch-action: none !important;
        -webkit-touch-callout: none;
        user-select: none;
        -webkit-user-select: none;
    }
    #deck-joy-base {
        position: relative;
    }
    #deck-joy-base::before {
        content: "";
        position: absolute;
        inset: -16px;
        border-radius: 50%;
        touch-action: none;
    }

    #ui .hud-label {
        font-size: 12px !important;
        letter-spacing: 1.5px !important;
    }
    #ui .hud-value {
        font-size: 21px !important;
        line-height: 1.05 !important;
    }
    #ui .hud-meters .hud-meter-label {
        font-size: 13px !important;
        letter-spacing: 1.1px !important;
    }
    @media (max-width: 700px) {
        #ui .hud-label {
            font-size: 10px !important;
        }
        #ui .hud-value {
            font-size: 18px !important;
        }
        #ui .hud-meters .hud-meter-label {
            font-size: 11px !important;
        }
    }

    .hud-system-icon {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 24px;
        transition: transform .08s ease, filter .08s ease, text-shadow .08s ease;
    }
    .shield-icon.damage-flash {
        color: #fff !important;
        filter: drop-shadow(0 0 5px #fff) drop-shadow(0 0 12px #22d3ee);
        text-shadow: 0 0 10px #67e8f9;
        transform: scale(1.35);
        animation: hudShieldHit .18s ease-out 0s 2;
    }
    .hull-icon.damage-flash {
        color: #fff !important;
        filter: drop-shadow(0 0 5px #fff) drop-shadow(0 0 12px #ef4444);
        text-shadow: 0 0 10px #ef4444;
        transform: scale(1.35);
        animation: hudHullHit .18s ease-out 0s 2;
    }

  @keyframes hudShieldHit { 50% { transform:scale(1.55) rotate(-8deg); } }

  @keyframes hudHullHit { 50% { transform:scale(1.55) rotate(8deg); } }

    .boss-timer-stat {
        position: relative;
        border: 2px solid rgba(56,189,248,.72) !important;
        background: linear-gradient(145deg, rgba(18,32,52,.9), rgba(5,10,20,.96));
        box-shadow: inset 0 0 16px rgba(56,189,248,.08), 0 0 8px rgba(56,189,248,.08);
        transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
    }
    .boss-timer-stat::before {
        content: "";
        position: absolute;
        inset: 0;
        padding: 2px;
        border-radius: inherit;
        background: conic-gradient(from -45deg, #38bdf8 var(--boss-progress,100%), rgba(56,189,248,.08) 0);
        -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
        -webkit-mask-composite: xor;
        mask-composite: exclude;
        pointer-events: none;
        opacity: .95;
        filter: drop-shadow(0 0 4px currentColor);
    }
    .boss-timer-stat::after {
        content: "";
        position: absolute;
        left: 8px;
        right: 8px;
        bottom: 3px;
        height: 1px;
        background: linear-gradient(90deg, transparent, currentColor, transparent);
        opacity: .45;
        pointer-events: none;
    }
    .boss-timer-stat .hud-countdown-value {
        position: relative;
        z-index: 2;
        display: block;
        font-weight: 900;
        text-align: center;
        color: #67e8f9;
        text-shadow: 0 0 8px currentColor, 0 0 16px rgba(34,211,238,.35);
    }
    .boss-timer-stat .hud-countdown-value .unit {
        color: #a5f3fc;
        font-size: .72em;
    }
    .boss-next-name {
        position: absolute;
        right: 7px;
        top: 5px;
        z-index: 3;
        max-width: 72%;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        font-size: 7px;
        font-weight: 900;
        letter-spacing: .08em;
        color: rgba(165,243,252,.72);
        text-transform: uppercase;
        pointer-events: none;
    }
    .boss-timer-stat.critical {
        border-color: rgba(239,68,68,1) !important;
        color: #ef4444;
        box-shadow: 0 0 18px rgba(239,68,68,.3), inset 0 0 20px rgba(239,68,68,.12);
        animation: bossBoxAlarm .55s ease-in-out infinite alternate;
    }
    .boss-timer-stat.critical::before {
        background: conic-gradient(from -45deg, #ef4444 var(--boss-progress,100%), rgba(239,68,68,.08) 0);
    }
    .boss-timer-stat.critical .hud-countdown-value {
        color: #fca5a5;
    }
    .boss-timer-stat.active {
        border-color: rgba(239,68,68,.95) !important;
        color: #ef4444;
        box-shadow: 0 0 14px rgba(239,68,68,.22), inset 0 0 16px rgba(239,68,68,.09);
    }
    .boss-timer-stat.active::before {
        background: conic-gradient(from -45deg, #ef4444 100%, rgba(239,68,68,.08) 0);
        animation: bossBorderScan 1.2s linear infinite;
    }
    .boss-timer-stat.active .hud-countdown-value {
        color: #f87171;
        animation: bossTextPulse .7s ease-in-out infinite alternate;
    }
    .boss-timer-stat.clear {
        border-color: rgba(249,115,22,.9) !important;
        color: #f97316;
    }
    .boss-timer-stat.clear .hud-countdown-value {
        color: #fb923c;
    }
    .boss-timer-stat.ready {
        border-color: rgba(34,197,94,.9) !important;
        color: #22c55e;
    }
    .boss-timer-stat.ready .hud-countdown-value {
        color: #4ade80;
    }

@keyframes bossBoxAlarm { from { filter:brightness(.95); } to { filter:brightness(1.28); } }

@keyframes bossBorderScan { 0% { opacity:.55; } 50% { opacity:1; } 100% { opacity:.55; } }

@keyframes bossTextPulse { from { transform:scale(.96); } to { transform:scale(1.05); } }
    @media (max-width:700px) {
        .boss-next-name {
            font-size: 6px;
            right: 5px;
            max-width: 68%;
        }
    }
    .boss-timer-stat .hud-label {
        font-size: 10px !important;
        letter-spacing: .16em;
    }
    .boss-timer-stat .boss-next-name {
        position: relative;
        right: auto;
        top: auto;
        display: block;
        text-align: center;
        color: #e0f2fe;
        text-shadow: 0 0 6px rgba(103,232,249,.55);
    }
    .boss-timer-stat .hud-countdown-value {
        letter-spacing: .06em;
    }
    .boss-timer-stat .hud-countdown-value .prefix {
        font-size: .62em;
        letter-spacing: .09em;
        margin-right: 3px;
        color: #a5f3fc;
    }

    .hud-primary {
        gap: 5px !important;
    }
    .hud-primary > .hud-stat:not(.boss) {
        min-width: 72px !important;
        flex: 0 1 auto !important;
        padding: 7px 9px !important;
    }
    .hud-primary > .hud-stat.score {
        min-width: 92px !important;
    }
    .hud-primary > .hud-stat.difficulty {
        min-width: 92px !important;
    }
    .hud-primary > .hud-stat.coins {
        min-width: 72px !important;
    }
    .boss-preview-wrap {
        border-radius: 4px;
        overflow: hidden;
        pointer-events: none;
    }
    #boss-preview-canvas {
        display: block;
    }
    .boss-timer-stat .hud-label {
        margin-bottom: 1px !important;
    }
    .boss-timer-stat .boss-next-name {
        margin-top: 0 !important;
        margin-bottom: 1px !important;
    }
    @media (max-width:700px) {
        .hud-primary > .hud-stat:not(.boss) {
            min-width: 0 !important;
            padding: 5px 7px !important;
        }
        .hud-primary > .hud-stat.score, .hud-primary > .hud-stat.difficulty {
            min-width: 0 !important;
        }
        .boss-preview-wrap {
            left: 5px;
            top: 5px;
        }
        .boss-timer-stat .hud-label, .boss-timer-stat .boss-next-name, .boss-timer-stat .hud-countdown-value {
            margin-left: 49px !important;
        }
    }

    .boss-timer-stat {
        flex-direction: column !important;
        justify-content: flex-start !important;
    }
    .boss-preview-wrap {
        position: relative !important;
        left: auto !important;
        top: auto !important;
        width: 40px !important;
        height: 24px !important;
        margin: 0 auto 1px !important;
        border: 0 !important;
        background: transparent !important;
        opacity: .95 !important;
        flex: 0 0 24px !important;
    }
    #boss-preview-canvas {
        width: 100% !important;
        height: 100% !important;
    }
    .boss-timer-stat .hud-label, .boss-timer-stat .boss-next-name, .boss-timer-stat .hud-countdown-value {
        margin-left: 0 !important;
        position: relative !important;
        right: auto !important;
        top: auto !important;
        display: block !important;
        text-align: center !important;
    }
    .boss-timer-stat .hud-label {
        font-size: 8px !important;
        line-height: 1 !important;
        margin: 0 0 1px !important;
    }
    @media (max-width:700px) {
        .boss-timer-stat {
            flex: 0 1 112px !important;
            padding: 3px 5px 4px !important;
        }
        .boss-preview-wrap {
            width: 34px !important;
            height: 20px !important;
            flex-basis: 20px !important;
        }
        .boss-timer-stat .hud-label {
            font-size: 7px !important;
        }
    }

    .hud-meters {
        width: 300px !important;
        box-sizing: border-box !important;
        gap: 8px !important;
    }
    .hud-meter {
        width: 100% !important;
        grid-template-columns: 72px minmax(0, 1fr) !important;
        gap: 8px !important;
        box-sizing: border-box !important;
    }
    .hud-meter-label {
        font-size: 12px !important;
    }
    .hud-bar {
        width: 100% !important;
        height: 12px !important;
    }
    @media (max-width: 700px) {
        .hud-meters {
            min-width: 0 !important;
        }
        .hud-meter {
            grid-template-columns: 68px minmax(0,1fr) !important;
        }
        .hud-bar {
            height: 10px !important;
        }
    }

    #ui {
        align-items: stretch !important;
    }
    #ui .hud-meters {
        height: 72px !important;
        min-height: 72px !important;
        box-sizing: border-box !important;
        align-self: stretch !important;
        flex: 0 0 300px !important;
        width: 300px !important;
    }
    #ui .hud-meters .hud-meter {
        flex: 1 1 0 !important;
        min-height: 0 !important;
    }
    @media (max-width: 980px) and (min-width: 701px) {
        #ui .hud-meters {
            height: 72px !important;
            min-height: 72px !important;
            flex: 1 1 270px !important;
            width: auto !important;
        }
    }
    @media (max-width: 700px) {
        #ui .hud-meters {
            height: 66px !important;
            min-height: 66px !important;
            margin-left: 0 !important;
            flex: 1 1 100% !important;
            width: 100% !important;
        }
    }

    #ui {
        gap: 0 !important;
    }
    .hud-meters {
        flex: 1 1 auto !important;
        min-width: 0 !important;
        margin-right: 0 !important;
    }
    .hud-actions {
        flex: 0 0 48px !important;
        width: 48px !important;
        margin-left: 0 !important;
    }
    @media (max-width: 700px) {
        .hud-meters {
            width: auto !important;
            flex: 1 1 auto !important;
        }
        .hud-actions {
            flex: 0 0 44px !important;
            width: 44px !important;
        }
    }

    #ui .hud-meters .hud-meter {
        grid-template-columns: 88px minmax(0,1fr) !important;
        gap: 8px !important;
    }
    #ui .hud-meters .hud-meter-label {
        white-space: nowrap !important;
        overflow: visible !important;
        min-width: 88px !important;
        display: flex !important;
        align-items: center !important;
    }
    #ui .hud-meters .hud-system-icon {
        flex: 0 0 auto !important;
        margin-right: 5px !important;
    }
    @media (max-width: 700px) {
        #ui .hud-meters .hud-meter {
            grid-template-columns: 78px minmax(0,1fr) !important;
            gap: 6px !important;
        }
        #ui .hud-meters .hud-meter-label {
            min-width: 78px !important;
        }
    }

@media (max-width: 700px) {
    #ui {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 0 !important;
        min-height: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
        background: transparent !important;
        border: 0 !important;
        box-shadow: none !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        overflow: visible !important;
        pointer-events: none !important;
        z-index: 12 !important;
    }

    #ui::before {
        display: none !important;
    }

    #ui .hud-primary {
        display: block !important;
        position: static !important;
    }

    #ui .hud-primary > .hud-stat:not(.coins),
    #ui .hud-meters {
        display: none !important;
    }

    #ui .hud-stat.coins {
        display: flex !important;
        position: absolute !important;
        top: max(8px, env(safe-area-inset-top)) !important;
        left: max(10px, env(safe-area-inset-left)) !important;
        min-width: 0 !important;
        min-height: 0 !important;
        width: auto !important;
        padding: 0 !important;
        margin: 0 !important;
        background: transparent !important;
        border: 0 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        overflow: visible !important;
        z-index: 2 !important;
    }

    #ui .hud-stat.coins::after {
        display: none !important;
    }

    #ui .hud-stat.coins .hud-label {
        display: none !important;
    }

    #ui .hud-stat.coins .hud-value {
        font-size: 15px !important;
        line-height: 1 !important;
        text-shadow: 0 0 8px rgba(251,191,36,.7) !important;
    }

    #ui .hud-actions {
        display: flex !important;
        position: absolute !important;
        top: max(6px, env(safe-area-inset-top)) !important;
        right: max(8px, env(safe-area-inset-right)) !important;
        width: auto !important;
        height: auto !important;
        min-width: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
        flex: none !important;
        z-index: 3 !important;
        pointer-events: auto !important;
    }

    /* Overheat is communicated by Nova instead of a separate red banner. */
    body.mobile-overheated::after,
    body.commander-screen-active.mobile-overheated::after {
        display: none !important;
    }

    body.mobile-overheated::after {
        content: "OVERHEAT";
        position: fixed;
        top: max(50px, calc(env(safe-area-inset-top) + 42px));
        left: 50%;
        transform: translateX(-50%);
        z-index: 9999;
        padding: 7px 14px;
        border: 2px solid #ef4444;
        border-radius: 10px;
        background: rgba(120, 10, 10, .9);
        color: #fff;
        font: 900 15px/1 sans-serif;
        letter-spacing: .14em;
        text-shadow: 0 0 10px rgba(255,255,255,.8);
        box-shadow: 0 0 18px rgba(239,68,68,.8);
        animation: mobile-overheat-pulse .45s infinite alternate;
        pointer-events: none;
    }

    @keyframes mobile-overheat-pulse {
        from { opacity: .72; transform: translateX(-50%) scale(.98); }
        to { opacity: 1; transform: translateX(-50%) scale(1.04); }
    }

    #ui #pause-btn {
        width: 34px !important;
        height: 34px !important;
        padding: 0 !important;
        margin: 0 !important;
        border-radius: 9px !important;
        font-size: 13px !important;
        background: rgba(5,15,30,.78) !important;
        border: 1px solid rgba(103,232,249,.4) !important;
        box-shadow: 0 2px 10px rgba(0,0,0,.35) !important;
        pointer-events: auto !important;
    }
}

.pause-menu-actions {
    width: 100%;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: stretch;
}
.pause-menu-actions .menu-btn {
    width: 100%;
}
.pause-exit-btn {
    opacity: .9;
}

#game-over-screen {
    z-index: 28;
    justify-content: flex-start;
    gap: 0;
    padding: 24px 20px;
    background: radial-gradient(ellipse at 50% 32%, rgba(54,9,9,0.93) 0%, rgba(2,6,23,0.96) 58%, rgba(2,6,23,0.98) 100%);
}
.ts-ship.ts-ship-broken {
    animation: ts-broken-drift 3.6s ease-in-out infinite;
    filter: drop-shadow(0 10px 18px rgba(248,113,113,0.35));
}
.ts-ship-broken .ts-ship-img {
    filter: drop-shadow(0 0 9px rgba(248,113,113,0.55)) grayscale(0.45) brightness(0.8) saturate(0.7);
}
@keyframes ts-broken-drift {
    0% { transform: scale(1.65) rotate(-14deg) translate(0, 0); }
    50% { transform: scale(1.65) rotate(-20deg) translate(-3px, 7px); }
    100% { transform: scale(1.65) rotate(-14deg) translate(0, 0); }
}
.go-smoke {
    position: absolute;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(148,163,184,0.6), rgba(100,116,139,0.15) 65%, rgba(100,116,139,0) 78%);
    filter: blur(1px);
    pointer-events: none;
    opacity: 0;
    animation: go-smoke-rise 2.1s ease-out infinite;
}
.go-smoke-1 { left: 34%; top: 46%; animation-delay: 0s; }
.go-smoke-2 { left: 52%; top: 52%; animation-delay: 0.7s; }
.go-smoke-3 { left: 44%; top: 40%; animation-delay: 1.4s; }
@keyframes go-smoke-rise {
    0% { opacity: 0; transform: translate(0, 0) scale(0.55); }
    18% { opacity: 0.75; }
    100% { opacity: 0; transform: translate(-16px, -48px) scale(1.7); }
}
.go-spark {
    position: absolute;
    left: 48%;
    top: 55%;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: radial-gradient(circle, #fef08a, #f97316 55%, rgba(249,115,22,0) 76%);
    pointer-events: none;
    animation: go-spark-flicker 0.35s steps(2) infinite;
}
@keyframes go-spark-flicker {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.25; transform: scale(0.55); }
}
@media (max-width: 700px) {
    .pause-menu-actions {
        max-width: min(320px, 86vw);
    }
}

#exit-confirm-modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0, 5, 15, .72);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 100;
}
#exit-confirm-modal.is-open { display: flex; }
.exit-confirm-card {
    width: min(360px, 90vw);
    padding: 22px 20px 18px;
    text-align: center;
    border: 1px solid rgba(103,232,249,.35);
    border-radius: 16px;
    background: rgba(7, 18, 35, .96);
    box-shadow: 0 16px 50px rgba(0,0,0,.55), 0 0 30px rgba(56,189,248,.12);
}
.exit-confirm-card h2 {
    margin: 0 0 8px;
    font-size: 20px;
    color: #e0f2fe;
}
.exit-confirm-card p {
    margin: 0 0 18px;
    font-size: 13px;
    line-height: 1.5;
    color: #94a3b8;
}
.exit-confirm-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}
.exit-confirm-actions .menu-btn { flex: 1; min-width: 0; }
#exit-confirm-yes { border-color: rgba(248,113,113,.55); }
@media (max-width: 700px) {
    .exit-confirm-card { width: min(340px, 88vw); }
}


#device-toast {
    position: fixed;
    left: 50%;
    top: max(14px, env(safe-area-inset-top, 0px));
    transform: translate(-50%, -12px);
    z-index: 140;
    max-width: min(420px, 90vw);
    padding: 10px 16px;
    border-radius: 999px;
    background: rgba(7, 18, 35, .96);
    border: 1px solid rgba(251, 191, 36, .5);
    color: #fef3c7;
    font-size: 12px;
    line-height: 1.4;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,.5), 0 0 20px rgba(251,191,36,.15);
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease, transform .25s ease;
}
#device-toast.is-visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

#graphics-auto-monitor {
    position: fixed;
    top: max(10px, env(safe-area-inset-top, 0px));
    left: max(10px, env(safe-area-inset-left, 0px));
    z-index: 125;
    display: none;
    flex-direction: column;
    gap: 3px;
    min-width: 132px;
    padding: 7px 9px;
    border-radius: 10px;
    background: rgba(7, 18, 35, .88);
    border: 1px solid rgba(56, 189, 248, .35);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 8px 24px rgba(0,0,0,.45);
    font-size: 10px;
    line-height: 1.5;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #94a3b8;
    pointer-events: auto;
    user-select: none;
}
#graphics-auto-monitor.is-visible {
    display: flex;
}
#graphics-auto-monitor.is-collapsed {
    min-width: 0;
    width: auto;
    padding: 4px 7px;
    gap: 0;
    border-radius: 8px;
}
#graphics-auto-monitor .gam-title {
    color: #38bdf8;
    font-weight: 700;
    font-size: 9px;
    margin-bottom: 1px;
}
#graphics-auto-monitor.is-collapsed .gam-title {
    display: none;
}
.wormhole-monitor-info {
    display: none;
}
#graphics-auto-monitor .wormhole-monitor-info.is-active {
    display: flex;
}
#graphics-auto-monitor .gam-compact-wormhole.wormhole-monitor-info.is-active {
    display: flex;
}
#graphics-auto-monitor .gam-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
}
#graphics-auto-monitor.is-collapsed .gam-row.gam-extra {
    display: none;
}
#graphics-auto-monitor .gam-row span:last-child {
    color: #e2e8f0;
    font-weight: 700;
}
#graphics-auto-monitor .gam-reason-row span:last-child {
    max-width: 150px;
    text-align: right;
    line-height: 1.25;
}
#graphics-auto-monitor .gam-row.gam-status span.gam-down { color: #f97316; }
#graphics-auto-monitor .gam-row.gam-status span.gam-up { color: #4ade80; }
#graphics-auto-monitor .gam-row.gam-status span.gam-steady { color: #94a3b8; }
#graphics-auto-monitor .gam-compact-row {
    display: none;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
    font-size: 10px;
}
#graphics-auto-monitor.is-collapsed .gam-compact-row {
    display: flex;
}
#graphics-auto-monitor .gam-quality-compact {
    color: #e2e8f0;
    font-weight: 800;
}
#graphics-auto-monitor .gam-director-compact {
    color: #e2e8f0;
}
#graphics-auto-monitor .gam-director-state {
    color: #94a3b8;
    font-weight: 700;
}
#graphics-auto-monitor .gam-spikes-compact {
    color: #fbbf24;
    font-weight: 800;
}
#graphics-auto-monitor .gam-expand-hit {
    position: absolute;
    inset: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    padding: 0;
}

#graphics-auto-monitor .gam-spikes-compact {
    display: none;
}
#graphics-auto-monitor.has-spikes .gam-spikes-compact {
    display: inline;
}

#graphics-auto-monitor.is-collapsed {
    min-width: 0;
    max-width: 150px;
    padding: 5px 8px;
}
#graphics-auto-monitor.is-collapsed .gam-compact-row {
    gap: 6px;
}

    .boss-timer-stat {
        height: 72px !important;
        padding: 5px 6px !important;
        display: grid !important;
        grid-template-rows: 1fr !important;
        align-items: center !important;
        box-sizing: border-box !important;
        text-align: center !important;
    }
    .boss-timer-stat .boss-preview-wrap {
        grid-column: 2 !important;
        grid-row: 1 !important;
        position: relative !important;
        inset: auto !important;
        margin: 0 !important;
        flex: none !important;
        align-self: center !important;
    }
    .boss-timer-stat #boss-preview-canvas {
        width: 100% !important;
        height: 100% !important;
        display: block !important;
    }
    .boss-timer-stat .hud-label {
        display: none !important;
    }
    .boss-timer-stat .boss-next-name {
        grid-column: 1 !important;
        grid-row: 1 !important;
        margin: 0 !important;
        align-self: center !important;
        line-height: 1.15 !important;
        letter-spacing: .05em !important;
        max-width: 100% !important;
    }
    .boss-timer-stat .hud-countdown-value {
        grid-column: 1 !important;
        grid-row: 1 !important;
        margin: 29px 0 0 !important;
        align-self: center !important;
        font-size: 12px !important;
        line-height: 1 !important;
    }
    @media (max-width:700px) {
        .boss-timer-stat {
            height: 66px !important;
        }
        .boss-timer-stat .hud-countdown-value {
            font-size: 10px !important;
            margin-top: 24px !important;
        }
    }

    #ui .hud-stat {
        min-height: 72px !important;
        height: 72px !important;
        box-sizing: border-box !important;
    }
    #ui .boss-timer-stat {
        min-height: 72px !important;
        height: 72px !important;
    }
    @media (max-width:700px) {
        #ui .hud-stat {
            min-height: 66px !important;
            height: 66px !important;
        }
        #ui .boss-timer-stat {
            min-height: 66px !important;
            height: 66px !important;
        }
    }

    .boss-timer-stat {
        flex: 0 0 250px !important;
        gap: 6px !important;
    }
    .boss-timer-stat .boss-next-name {
        font-size: 12px !important;
        white-space: nowrap !important;
        overflow: visible !important;
        text-overflow: clip !important;
    }
    @media (max-width:700px) {
        .boss-timer-stat .boss-next-name {
            font-size: 9px !important;
        }
    }

    .boss-timer-stat {
        min-width: 235px !important;
        width: 235px !important;
        flex-basis: 235px !important;
    }
    @media (max-width:700px) {
        .boss-timer-stat .boss-preview-wrap {
            transform: scale(1.28);
        }
        .boss-timer-stat {
            min-width: 195px !important;
            width: 195px !important;
            flex-basis: 195px !important;
        }
    }

    .boss-timer-stat .boss-preview-wrap {
        background: transparent !important;
        border: 0 !important;
        box-shadow: none !important;
        outline: none !important;
        filter: none !important;
        opacity: 1 !important;
    }
    .boss-timer-stat #boss-preview-canvas {
        background: transparent !important;
        box-shadow: none !important;
        border: 0 !important;
    }

    .boss-timer-stat {
        padding-right: 0 !important;
        column-gap: 0 !important;
        overflow: hidden !important;
    }
    .boss-timer-stat .boss-preview-wrap {
        transform-origin: center right !important;
    }
    @media (max-width:700px) {
        .boss-timer-stat {
            padding-right: 0 !important;
        }
    }

    #ui {
        column-gap: 0 !important;
    }
    #ui .hud-primary {
        flex: 0 1 auto !important;
        min-width: 0 !important;
        margin-right: 0 !important;
    }
    #ui .hud-meters {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    #ui .hud-actions {
        margin-left: auto !important;
    }
    @media (max-width:700px) {
        #ui {
            row-gap: 0 !important;
        }
        #ui .hud-primary {
            flex: 1 1 100% !important;
            width: 100% !important;
        }
        #ui .hud-meters {
            margin-left: 0 !important;
        }
    }

    .boss-timer-stat .boss-preview-wrap {
        transform: none !important;
    }

    .boss-timer-stat {
        grid-template-columns: minmax(0,1fr) 76px !important;
    }
    .boss-timer-stat .boss-preview-wrap {
        width: 76px !important;
        height: 52px !important;
        margin-right: -2px !important;
        justify-self: end !important;
        overflow: hidden !important;
    }
    @media (max-width:700px) {
        .boss-timer-stat {
            grid-template-columns: minmax(0,1fr) 62px !important;
        }
        .boss-timer-stat .boss-preview-wrap {
            width: 62px !important;
            height: 42px !important;
            margin-right: -2px !important;
        }
    }

    body.hud-compact-phone #ui {
        gap: 6px !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
        overflow: hidden !important;
    }
    body.hud-compact-phone #ui .hud-primary {
        display: flex !important;
        align-items: stretch !important;
        height: auto !important;
    }
    body.hud-compact-phone #ui .hud-stat {
        grid-column: unset !important;
        height: 76px !important;
        min-height: 76px !important;
        padding: 4px 4px !important;
        border-right: 0 !important;
        flex: 1 1 0 !important;
        min-width: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 2px !important;
        background: rgba(15, 23, 42, 0.4) !important;
        border-radius: 6px !important;
    }
    body.hud-compact-phone #ui .hud-stat .hud-label {
        display: block !important;
        font-size: 7px !important;
        letter-spacing: 0.08em !important;
        margin-bottom: 0 !important;
        max-width: 100% !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }
    body.hud-compact-phone #ui .hud-stat .hud-value {
        font-size: clamp(10px, 3.6vw, 15px) !important;
        letter-spacing: 0 !important;
        line-height: 1.1 !important;
        max-width: 100% !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        display: inline-block !important;
        text-align: center !important;
    }
    body.hud-compact-phone #ui .hud-stat.difficulty {
        display: none !important;
    }
    body.hud-compact-phone #ui .hud-stat.score .hud-value::before {
        content: "★";
        display: block;
        font-size: 11px;
        line-height: 1;
        margin-bottom: 2px;
    }
    body.hud-compact-phone #ui .hud-stat.stage .hud-value::before {
        content: "▲";
        display: block;
        font-size: 11px;
        line-height: 1;
        margin-bottom: 2px;
    }
    body.hud-compact-phone #ui .hud-stat.shield-status .hud-value::before {
        content: "🛡";
        display: block;
        font-size: 11px;
        line-height: 1;
        margin-bottom: 2px;
    }
    body.hud-compact-phone #ui .hud-stat.coins .coin-icon {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        line-height: 1 !important;
        overflow: visible !important;
    }
    body.hud-compact-phone #ui .hud-stat.coins {
        overflow: visible !important;
    }
    body.hud-compact-phone #ui .boss-timer-stat, body.hud-compact-phone .boss-timer-stat {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        grid-template-columns: none !important;
        width: auto !important;
        min-width: 0 !important;
        flex: 1.3 1 0 !important;
        height: auto !important;
        min-height: 76px !important;
        max-height: 80px !important;
        padding: 4px 4px !important;
        margin: 0 !important;
        gap: 2px !important;
        background: rgba(15, 23, 42, 0.4) !important;
        border-radius: 6px !important;
    }
    body.hud-compact-phone .boss-timer-stat .boss-preview-wrap {
        display: none !important;
    }
    body.hud-compact-phone .boss-timer-stat .boss-next-name {
        display: -webkit-box !important;
        position: static !important;
        font-size: 7px !important;
        line-height: 1.15 !important;
        margin: 0 !important;
        max-width: 100% !important;
        white-space: normal !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        overflow-wrap: break-word !important;
        word-break: break-word !important;
        -webkit-line-clamp: 2 !important;
        -webkit-box-orient: vertical !important;
    }
    body.hud-compact-phone .boss-timer-stat .hud-label {
        display: none !important;
    }
    body.hud-compact-phone .boss-timer-stat .hud-countdown-value {
        display: inline-block !important;
        font-size: 12px !important;
        letter-spacing: 0 !important;
        margin-top: 0 !important;
        max-width: 100% !important;
        white-space: normal !important;
        overflow: visible !important;
        text-overflow: clip !important;
        overflow-wrap: break-word !important;
        word-break: break-word !important;
        text-align: center !important;
        line-height: 1.15 !important;
    }
    body.hud-compact-phone .boss-timer-stat .hud-countdown-value::before {
        content: "👹";
        display: block;
        font-size: 0.9em;
        line-height: 1;
        margin-bottom: 2px;
    }
    body.hud-compact-phone .boss-timer-stat .hud-countdown-value .prefix {
        display: none !important;
    }
    body.hud-compact-phone #ui .hud-meters {
        flex: 0 1 92px !important;
        min-width: 70px !important;
        max-width: 92px !important;
        width: auto !important;
        gap: 4px !important;
        padding: 0 !important;
        height: auto !important;
        min-height: 0 !important;
        justify-content: center !important;
    }
    body.hud-compact-phone #ui .hud-meter {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        grid-template-columns: none !important;
        gap: 1px !important;
    }
    body.hud-compact-phone #ui .hud-meter-label {
        display: block !important;
        font-size: 7px !important;
        line-height: 1 !important;
        letter-spacing: 0.06em !important;
        text-align: left !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }
    body.hud-compact-phone #ui .hud-meter-label .hud-system-icon {
        display: none !important;
    }
    body.hud-compact-phone #ui .hud-bar {
        height: 9px !important;
        min-height: 9px !important;
    }
    body.hud-compact-phone #ui .hud-actions {
        min-width: 34px !important;
        width: 34px !important;
        height: 34px !important;
    }
    body.hud-compact-phone #ui .hud-action {
        width: 34px !important;
        height: 34px !important;
        min-width: 34px !important;
        min-height: 34px !important;
        font-size: 15px !important;
        padding: 0 !important;
        line-height: 34px !important;
    }

    body.hud-compact-phone #ui {
        background: transparent !important;
        border: 0 !important;
        box-shadow: none !important;
        min-height: 0 !important;
        height: auto !important;
        max-height: none !important;
        padding: 10px 12px !important;
        justify-content: space-between !important;
    }
    body.hud-compact-phone #ui::before {
        display: none !important;
    }
    body.hud-compact-phone #ui .hud-stat.difficulty, body.hud-compact-phone #ui .boss-timer-stat, body.hud-compact-phone #ui .hud-meters {
        display: none !important;
    }
    body.hud-compact-phone #ui .hud-primary {
        flex: 0 0 auto !important;
        width: auto !important;
        min-width: 0 !important;
        gap: 10px !important;
    }
    body.hud-compact-phone #ui .hud-stat.coins {
        height: auto !important;
        min-height: 0 !important;
        padding: 0 !important;
        border: 0 !important;
        background: transparent !important;
    }
    body.hud-compact-phone #ui .hud-stat.score,
    body.hud-compact-phone #ui .hud-stat.stage {
        height: auto !important;
        min-height: 0 !important;
        padding: 0 !important;
        border: 0 !important;
        background: transparent !important;
        flex-direction: row !important;
        align-items: center !important;
        gap: 3px !important;
    }
    body.hud-compact-phone #ui .hud-stat.score .hud-label,
    body.hud-compact-phone #ui .hud-stat.stage .hud-label {
        display: none !important;
    }
    body.hud-compact-phone #ui .hud-stat.score .hud-value,
    body.hud-compact-phone #ui .hud-stat.stage .hud-value {
        font-size: 10px !important;
    }
    body.hud-compact-phone #ui .hud-stat.score .hud-value::before,
    body.hud-compact-phone #ui .hud-stat.stage .hud-value::before {
        display: inline !important;
        margin-bottom: 0 !important;
        margin-right: 3px !important;
        font-size: 10px !important;
    }
    body.hud-compact-phone #ui .hud-stat.shield-status .hud-label {
        display: none !important;
    }
    body.hud-compact-phone #ui .hud-stat.shield-status .hud-value {
        font-size: 10px !important;
    }
    body.hud-compact-phone #ui .hud-stat.shield-status .hud-value::before {
        display: inline !important;
        margin-bottom: 0 !important;
        margin-right: 3px !important;
        font-size: 10px !important;
    }
    body.hud-compact-phone #ui .hud-stat.coins .hud-label {
        display: none !important;
    }
    body.hud-compact-phone #ui .hud-stat.coins .hud-value.coin-display {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        gap: 3px !important;
    }
    body.hud-compact-phone #ui .hud-stat.coins .coin-icon {
        font-size: 10px !important;
    }
    body.hud-compact-phone #ui .hud-stat.coins .hud-value {
        font-size: 10px !important;
    }
    body.hud-compact-phone #ui .hud-actions {
        flex: 0 0 auto !important;
        margin: 0 !important;
    }
    body.hud-compact-phone #ui #pause-btn {
        background: transparent !important;
        border: 0 !important;
        box-shadow: none !important;
    }
    body.hud-compact-phone #ui #pause-btn:active {
        background: rgba(255, 255, 255, 0.12) !important;
    }
    body.hud-compact-phone #controls-deck {
        display: flex !important;
    }
    body.hud-compact-phone #deck-fire-zone {
        display: flex !important;
        flex: 1 1 100% !important;
        min-height: 62px !important;
        width: 100% !important;
    }

    #ui .coin-icon, .coin-display .coin-icon {
        display: inline-block !important;
        width: 13px !important;
        height: 16px !important;
        min-width: 13px !important;
        min-height: 16px !important;
        vertical-align: middle !important;
        flex: 0 0 auto !important;
        filter: drop-shadow(0 0 3px rgba(245, 158, 11, 0.85));
    }
    body.hud-compact-phone #ui .hud-stat.coins .coin-icon {
        width: 13px !important;
        height: 16px !important;
        min-width: 13px !important;
        min-height: 16px !important;
    }

@media (max-width: 700px) {
    #ui .hud-primary > .hud-stat.score,
    #ui .hud-primary > .hud-stat.stage {
        display: flex !important;
        position: absolute !important;
        top: max(7px, env(safe-area-inset-top)) !important;
        min-width: 0 !important;
        min-height: 0 !important;
        width: auto !important;
        height: auto !important;
        padding: 0 !important;
        margin: 0 !important;
        background: transparent !important;
        border: 0 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        overflow: visible !important;
        flex: none !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 3px !important;
        z-index: 13 !important;
        pointer-events: none !important;
    }

    #ui .hud-primary > .hud-stat.score {
        left: 62px !important;
    }

    #ui .hud-primary > .hud-stat.stage {
        left: 128px !important;
    }

    #ui .hud-primary > .hud-stat.score .hud-label,
    #ui .hud-primary > .hud-stat.stage .hud-label {
        display: inline !important;
        font-size: 7px !important;
        line-height: 1 !important;
        margin: 0 !important;
        color: #94a3b8 !important;
        text-shadow: 0 0 6px rgba(2,6,23,.9) !important;
    }

    #ui .hud-primary > .hud-stat.score .hud-value,
    #ui .hud-primary > .hud-stat.stage .hud-value {
        display: inline !important;
        font-size: 13px !important;
        line-height: 1 !important;
        color: #e0f2fe !important;
        text-shadow: 0 0 8px rgba(56,189,248,.65) !important;
    }

    #ui .hud-primary > .hud-stat.stage .hud-value {
        color: #c4b5fd !important;
        text-shadow: 0 0 8px rgba(196,181,253,.65) !important;
    }

    #ui .hud-stat.coins {
        top: max(5px, env(safe-area-inset-top)) !important;
    }
}

body.hud-compact-phone #ui {
    overflow: visible !important;
}



/* Upgrade Center shortcut: same compact HUD language as Pause, stacked below it. */
#ui .hud-actions {
    flex-direction: column !important;
    gap: 5px !important;
    align-items: center !important;
}
#ui #upgrade-btn {
    width: 34px !important;
    height: 34px !important;
    padding: 0 !important;
    margin: 0 !important;
    border-radius: 9px !important;
    font-size: 13px !important;
    background: rgba(5,15,30,.78) !important;
    border: 1px solid rgba(251,191,36,.34) !important;
    color: #fde68a !important;
    box-shadow: 0 2px 10px rgba(0,0,0,.35) !important;
    pointer-events: auto !important;
}
#ui #upgrade-btn.has-upgrades {
    position: relative !important;
}
#ui #upgrade-btn.has-upgrades::after {
    content: attr(data-upgrade-count);
    position: absolute;
    right: -5px;
    top: -6px;
    min-width: 15px;
    height: 15px;
    padding: 0 3px;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: rgba(251,191,36,.96);
    color: #111827;
    border: 1px solid rgba(255,255,255,.55);
    font-size: 9px;
    font-weight: 900;
    line-height: 1;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(0,0,0,.35);
}
#ui #upgrade-btn.has-upgrades.nova-upgrade-guide::after {
    content: attr(data-upgrade-count);
}
#ui #upgrade-btn:hover {
    border-color: rgba(251,191,36,.7) !important;
    box-shadow: 0 0 12px rgba(251,191,36,.18) !important;
}
#ui #upgrade-btn.nova-upgrade-guide {
    position: relative !important;
    border-color: rgba(103,232,249,.95) !important;
    color: #ecfeff !important;
    box-shadow: 0 0 0 3px rgba(34,211,238,.18), 0 0 18px rgba(34,211,238,.42) !important;
    animation: nova-upgrade-guide-pulse 1.05s ease-in-out infinite;
    z-index: 3;
}
#ui #upgrade-btn.nova-upgrade-guide::after {
    content: attr(data-nova-hint);
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    white-space: nowrap;
    padding: 5px 8px;
    border: 1px solid rgba(103,232,249,.65);
    border-radius: 6px;
    background: rgba(3,15,30,.94);
    color: #cffafe;
    font-size: 8px;
    font-weight: 900;
    letter-spacing: .08em;
    pointer-events: none;
    box-shadow: 0 0 12px rgba(34,211,238,.22);
}
@keyframes nova-upgrade-guide-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}
.upgrade-return-btn { margin-top: 0; }
@media (max-width:699px) {
    #ui #upgrade-btn {
        width: 24px !important;
        height: 24px !important;
        border-radius: 7px !important;
        font-size: 11px !important;
    }
}
