* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
html {
    overflow: hidden;
    height: 100%;
}
:root {
    --c1: #00f5ff;
    --c2: #ff2d78;
    --c3: #ffd700;
    --c4: #00ff7f;
    --bg: #000814;
    --panel: rgba(0, 12, 28, 0.95);
    --wall: #0055bb;
    --wall-glow: rgba(0, 100, 240, 0.8);
}
body {
    background: var(--bg);
    background-image:
        radial-gradient(
            ellipse 60% 60% at 20% 20%,
            rgba(0, 30, 80, 0.4) 0%,
            transparent 60%
        ),
        radial-gradient(
            ellipse 50% 50% at 80% 80%,
            rgba(40, 0, 60, 0.3) 0%,
            transparent 60%
        );
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    overflow: hidden;
    color: #fff;
    font-family: "Orbitron", monospace;
    user-select: none;
}

/* ---- SCREENS ---- */
.screen {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 8, 20, 0.97);
    z-index: 200;
}

/* MENU */
#menuCanvas {
    position: fixed;
    inset: 0;
    opacity: 0.15;
    pointer-events: none;
    z-index: 0;
}
.menu-content {
    z-index: 1;
    text-align: center;
}
.game-title {
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 900;
    letter-spacing: 0.25em;
    background: linear-gradient(
        135deg,
        var(--c1) 0%,
        #ffffff 50%,
        var(--c2) 100%
    );
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 20px var(--c1));
    line-height: 1;
    margin-bottom: 0.2em;
}
.game-sub {
    font-size: clamp(0.7rem, 1.5vw, 1rem);
    color: var(--c2);
    letter-spacing: 0.4em;
    text-shadow: 0 0 15px var(--c2);
    margin-bottom: 2.5rem;
}
.tagline {
    font-family: "Share Tech Mono", monospace;
    font-size: clamp(0.6rem, 1.2vw, 0.8rem);
    color: #55aacc;
    letter-spacing: 0.1em;
    margin-bottom: 2.5rem;
    line-height: 2;
}
.btn {
    padding: 14px 50px;
    background: transparent;
    border: 2px solid var(--c1);
    color: var(--c1);
    font-family: "Orbitron", monospace;
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow:
        0 0 20px rgba(0, 245, 255, 0.25),
        inset 0 0 20px rgba(0, 245, 255, 0.05);
    margin: 6px;
    min-width: 200px;
}
.btn:hover {
    background: rgba(0, 245, 255, 0.12);
    box-shadow:
        0 0 40px rgba(0, 245, 255, 0.5),
        inset 0 0 30px rgba(0, 245, 255, 0.1);
    transform: scale(1.04);
}
.btn.red {
    border-color: var(--c2);
    color: var(--c2);
    box-shadow: 0 0 20px rgba(255, 45, 120, 0.25);
}
.btn.red:hover {
    background: rgba(255, 45, 120, 0.12);
    box-shadow: 0 0 40px rgba(255, 45, 120, 0.5);
}

.controls-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 24px;
    font-family: "Share Tech Mono", monospace;
    font-size: 0.72rem;
    color: #445566;
    margin-top: 2rem;
    text-align: left;
}
.controls-grid .k {
    color: #00ccff;
    background: rgba(0, 100, 200, 0.15);
    border: 1px solid rgba(0, 100, 200, 0.4);
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 0.68rem;
}
.controls-grid .v {
    color: #778899;
}

.players-preview {
    display: flex;
    gap: 20px;
    margin: 1.5rem 0;
    justify-content: center;
}
.pcard {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 16px;
    background: rgba(0, 15, 30, 0.8);
    border: 1px solid;
    border-radius: 8px;
    font-size: 0.65rem;
    letter-spacing: 0.1em;
}
.pcard .pdot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    margin-bottom: 6px;
    position: relative;
}
.pdot::after {
    content: "";
    position: absolute;
    width: 10px;
    height: 10px;
    background: white;
    border-radius: 50%;
    top: 5px;
    left: 12px;
    opacity: 0.4;
}

/* GAME AREA */
#gameArea {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: center;
    padding: 10px;
    height: 100vh;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}
#gameCanvas {
    display: block;
    flex-shrink: 0;
    border: 2px solid rgba(0, 80, 180, 0.6);
    box-shadow:
        0 0 30px rgba(0, 80, 200, 0.4),
        0 0 80px rgba(0, 50, 150, 0.2);
    height: min(calc(100vh - 20px), calc(100vw - 225px));
    width: min(calc(100vh - 20px), calc(100vw - 225px));
    image-rendering: pixelated;
}

/* SIDEBAR HUD */
#hud {
    width: 205px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: calc(100vh - 20px);
    overflow: hidden;
}
/* Hide scrollbar globally */
::-webkit-scrollbar {
    width: 0;
    height: 0;
}
* {
    scrollbar-width: none;
}

/* ═══════════════════════════════════════════════════════
   MOBILE LAYOUT  (≤ 768 px)
   ═══════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    html,
    body {
        overflow: hidden;
        height: 100%;
    }

    #gameArea {
        padding: 0;
        gap: 0;
        height: 100vh;
        width: 100vw;
        align-items: flex-start;
        justify-content: flex-start;
    }
    #gameCanvas {
        width: 100vw !important;
        height: 100vh !important;
        max-width: 100vw !important;
        max-height: 100vh !important;
    }
    #hud {
        display: none !important;
    }

    #m-radar-btn {
        background: rgba(0, 10, 24, 0.85);
        border: 1px solid rgba(0, 200, 255, 0.35);
        border-radius: 8px;
        padding: 3px;
        cursor: pointer;
        touch-action: manipulation;
    }
    #m-radar-btn canvas {
        display: block;
        border-radius: 5px;
    }

    #m-status-panel {
        position: fixed;
        top: 8px;
        right: 8px;
        z-index: 300;
        width: 172px;
        display: none;
        flex-direction: column;
        gap: 3px;
        pointer-events: auto;
        opacity: 0.35;
        transition: opacity 0.3s;
    }
    #m-status-panel.active {
        opacity: 1.0;
    }
    .m-prow {
        background: rgba(0, 8, 20, 0.88);
        border: 1px solid rgba(0, 80, 160, 0.45);
        border-radius: 6px;
        padding: 4px 7px 4px 6px;
        display: flex;
        flex-direction: column;
        gap: 2px;
    }
    .m-prow-top {
        display: flex;
        align-items: center;
        gap: 5px;
    }
    .m-prow-dot {
        width: 9px;
        height: 9px;
        border-radius: 50%;
        flex-shrink: 0;
    }
    .m-prow-name {
        font-family: "Orbitron", monospace;
        font-size: 7.5px;
        font-weight: 700;
        letter-spacing: 0.08em;
        flex: 1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .m-prow-hp-text {
        font-family: "Share Tech Mono", monospace;
        font-size: 8px;
        min-width: 26px;
        text-align: right;
    }
    .m-prow-bar-wrap {
        height: 3px;
        background: #0d1e30;
        border-radius: 2px;
        overflow: hidden;
    }
    .m-prow-bar {
        height: 100%;
        border-radius: 2px;
        transition: width 0.25s;
    }
    .m-prow-bottom {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 3px;
    }
    .m-prow-score {
        font-family: "Share Tech Mono", monospace;
        font-size: 7px;
        color: #4a6070;
    }
    .m-prow-badge {
        font-family: "Share Tech Mono", monospace;
        font-size: 6px;
        padding: 0 3px;
        border-radius: 2px;
        letter-spacing: 0.04em;
    }

    #m-radar-popup {
        position: fixed;
        inset: 0;
        z-index: 500;
        background: rgba(0, 4, 14, 0.92);
        display: none;
        align-items: center;
        justify-content: center;
        flex-direction: column;
        gap: 14px;
    }
    #m-radar-popup canvas {
        border: 2px solid rgba(0, 200, 255, 0.5);
        border-radius: 10px;
        max-width: 90vw;
        max-height: 90vw;
        width: min(90vw, 90vh);
        height: min(90vw, 90vh);
    }
    #m-radar-close {
        background: rgba(0, 200, 255, 0.15);
        border: 1px solid rgba(0, 200, 255, 0.5);
        color: #00f5ff;
        font-family: "Orbitron", monospace;
        font-size: 11px;
        padding: 8px 28px;
        border-radius: 6px;
        cursor: pointer;
        touch-action: manipulation;
    }

    #m-dpad {
        position: fixed;
        bottom: 25px;
        left: 50%;
        transform: translateX(-50%) translateX(-50px);
        z-index: 300;
        display: grid;
        grid-template-columns: 65px 65px 65px;
        grid-template-rows: 65px 65px 65px;
        gap: 6px;
        user-select: none;
    }
    .m-dpad-btn {
        background: transparent;
        border: none;
        box-shadow: none;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
        transition: transform 0.05s, filter 0.05s;
        filter: drop-shadow(0px 8px 6px rgba(0,0,0,0.6));
    }
    .m-dpad-btn:active,
    .m-dpad-btn.pressed {
        transform: translateY(4px) scale(0.95);
        filter: drop-shadow(0px 2px 3px rgba(0,0,0,0.6));
    }
    .m-dpad-btn.up svg { transform: rotate(0deg); }
    .m-dpad-btn.right svg { transform: rotate(90deg); }
    .m-dpad-btn.down svg { transform: rotate(180deg); }
    .m-dpad-btn.left svg { transform: rotate(-90deg); }
    #m-dpad-up {
        grid-column: 2;
        grid-row: 1;
    }
    #m-dpad-left {
        grid-column: 1;
        grid-row: 2;
    }
    #m-dpad-mid {
        grid-column: 2;
        grid-row: 2;
        background: rgba(0, 15, 35, 0.7);
        border: 2px solid rgba(0, 100, 180, 0.3);
        border-radius: 50%;
        pointer-events: none;
    }
    #m-dpad-right {
        grid-column: 3;
        grid-row: 2;
    }
    #m-dpad-down {
        grid-column: 2;
        grid-row: 3;
    }

    #m-actions {
        position: fixed;
        bottom: 22px;
        right: 14px;
        z-index: 300;
        display: flex;
        flex-direction: column;
        gap: 8px;
    }
    .m-action-btn {
        width: 78px;
        height: 78px;
        background: transparent;
        border: none;
        box-shadow: none;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
        transition: transform 0.05s, filter 0.05s;
        filter: drop-shadow(0px 8px 6px rgba(0,0,0,0.6));
        margin-bottom: 6px;
    }
    .m-action-btn:active {
        transform: translateY(4px) scale(0.95);
        filter: drop-shadow(0px 2px 3px rgba(0,0,0,0.6));
    }
    #m-pause-btn {
        font-size: 18px;
        color: #88ccff;
        font-family: "Orbitron", monospace;
        font-weight: 700;
    }
}

.pcard-hud {
    background: rgba(0, 12, 25, 0.95);
    border: 1px solid rgba(0, 60, 120, 0.5);
    border-radius: 8px;
    padding: 9px 11px;
    transition: border-color 0.3s;
}
.pcard-hud.active {
    border-color: rgba(0, 245, 255, 0.4);
}
.pcard-hud.dead {
    opacity: 0.45;
}
.pcard-hud .ph {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 7px;
}
.pcard-hud .pavatar {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    flex-shrink: 0;
}
.pcard-hud .pname {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.15em;
    font-family: "Orbitron", monospace;
}
.pcard-hud .you-badge {
    font-size: 7px;
    padding: 1px 4px;
    background: rgba(0, 245, 255, 0.15);
    border: 1px solid rgba(0, 245, 255, 0.4);
    border-radius: 3px;
    color: var(--c1);
    margin-left: auto;
}
.hearts {
    font-size: 11px;
    margin-bottom: 4px;
}
.bombs-row {
    display: flex;
    gap: 2px;
    flex-wrap: wrap;
    margin-bottom: 5px;
}
.bomb-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}
.score-line {
    font-family: "Share Tech Mono", monospace;
    font-size: 10px;
    color: #556677;
}
.score-line span {
    color: #ddeeff;
    font-weight: bold;
}
.badges {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    margin-top: 4px;
    min-height: 14px;
}
.badge {
    font-size: 7px;
    padding: 1px 5px;
    border-radius: 3px;
    font-family: "Share Tech Mono", monospace;
    letter-spacing: 0.05em;
}

/* Mini-map */
#minimap-wrap {
    background: rgba(0, 12, 25, 0.95);
    border: 1px solid rgba(0, 60, 120, 0.5);
    border-radius: 8px;
    padding: 9px;
}
#minimap-wrap h4 {
    font-size: 7px;
    letter-spacing: 0.2em;
    color: #334455;
    margin-bottom: 6px;
    text-align: center;
}
#minimap {
    display: block;
    border-radius: 4px;
}

/* Controls hint */
#ctrl-hint {
    background: rgba(0, 12, 25, 0.95);
    border: 1px solid rgba(0, 60, 120, 0.3);
    border-radius: 8px;
    padding: 9px 11px;
    font-family: "Share Tech Mono", monospace;
    font-size: 8.5px;
    color: #334455;
    line-height: 1.9;
}
#ctrl-hint .k {
    display: inline-block;
    padding: 0 4px;
    background: rgba(0, 100, 200, 0.15);
    border: 1px solid rgba(0, 100, 200, 0.3);
    border-radius: 3px;
    color: #4499cc;
    font-size: 8px;
}

/* GAME OVER */
#goTitle {
    font-size: clamp(1.8rem, 4vw, 2.8rem);
    font-weight: 900;
    margin-bottom: 0.3em;
}
#goSub {
    font-size: 0.8rem;
    letter-spacing: 0.3em;
    margin-bottom: 2rem;
    opacity: 0.7;
}
#goScores {
    font-family: "Share Tech Mono", monospace;
    font-size: 0.85rem;
    line-height: 2.2;
    margin-bottom: 2rem;
    text-align: center;
}
.go-score-row {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: center;
}

/* Scanline overlay */
body::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 999;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.04) 2px,
        rgba(0, 0, 0, 0.04) 4px
    );
}

/* Animations */
@keyframes pulse-glow {
    0%,
    100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}
@keyframes float-in {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}
.menu-content {
    animation: float-in 0.6s ease both;
}

/* ───── SPECTATOR / DEAD-OR-WINNER OVERLAY ───── */
#spectator-overlay {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(
        135deg,
        rgba(0, 12, 28, 0.96),
        rgba(0, 24, 48, 0.96)
    );
    border: 1px solid rgba(0, 245, 255, 0.45);
    border-radius: 14px;
    padding: 22px 28px;
    text-align: center;
    z-index: 250;
    box-shadow:
        0 0 40px rgba(0, 245, 255, 0.3),
        0 0 80px rgba(0, 245, 255, 0.15);
    animation: float-in 0.35s ease both;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    max-width: 90vw;
}
#spectator-overlay.is-visible {
    display: flex;
}
#so-title {
    font-family: "Orbitron", monospace;
    font-weight: 900;
    font-size: clamp(1.4rem, 3.5vw, 2rem);
    letter-spacing: 0.18em;
    color: #ff2d78;
    text-shadow: 0 0 18px rgba(255, 45, 120, 0.6);
}
#spectator-overlay.victory #so-title {
    color: #ffd700;
    text-shadow: 0 0 18px rgba(255, 215, 0, 0.7);
}
#so-sub {
    font-family: "Share Tech Mono", monospace;
    font-size: 12px;
    color: rgba(220, 235, 255, 0.85);
    letter-spacing: 0.12em;
    line-height: 1.6;
    max-width: 360px;
}
#so-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 6px;
}
#so-buttons .btn {
    padding: 9px 16px;
    font-size: 13px;
    letter-spacing: 0.1em;
}
@media (max-width: 768px) {
    #spectator-overlay {
        top: 28%;
        padding: 16px 18px;
    }
    #so-title {
        font-size: 1.1rem;
    }
    #so-sub {
        font-size: 11px;
    }
}
