* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: #000;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
    font-family: 'Roboto', sans-serif;
    /* Mobile: prevent touch gestures, text selection */
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

#game-container {
    position: relative;
    /* Fill viewport while preserving 4:3 aspect ratio */
    width: min(100vw, calc(100vh * 4 / 3));
    height: min(100vh, calc(100vw * 3 / 4));
    max-width: 800px;
    max-height: 600px;
}

/* On small screens, remove the max-width cap */
@media (max-width: 840px), (max-height: 640px) {
    #game-container {
        max-width: 100vw;
        max-height: 100vh;
    }
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: auto;
}

#scanlines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.08) 2px,
        rgba(0, 0, 0, 0.08) 4px
    );
    z-index: 10;
}

/* === TOUCH CONTROLS === */
#touch-controls {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 120px;
    z-index: 20;
    pointer-events: none;
    padding-bottom: env(safe-area-inset-bottom);
}

.touch-btn {
    position: absolute;
    pointer-events: auto;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(240, 60, 65, 0.12);
    border: 2px solid rgba(240, 60, 65, 0.3);
    color: rgba(240, 60, 65, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
}

.touch-btn:active,
.touch-btn.active {
    background: rgba(240, 60, 65, 0.25);
    border-color: rgba(240, 60, 65, 0.6);
    color: rgba(240, 60, 65, 0.9);
}

.touch-btn svg {
    width: 28px;
    height: 28px;
}

.touch-btn-wide {
    border-radius: 12px;
    width: auto;
    padding: 0 24px;
    height: 50px;
    font-family: 'Orbitron', sans-serif;
    font-size: 14px;
    font-weight: bold;
    letter-spacing: 2px;
}

#touch-left {
    left: 20px;
    bottom: 20px;
}

#touch-right {
    left: 90px;
    bottom: 20px;
}

#touch-fire {
    right: 20px;
    bottom: 20px;
}

#touch-confirm {
    left: 50%;
    transform: translateX(-50%);
    bottom: 20px;
}

/* Show touch controls on touch-primary devices */
@media (hover: none) and (pointer: coarse) {
    #touch-controls {
        display: block;
    }
}

/* Dev level-jump controls (skips with AlienTools unlocked) */
#dev-nav {
    position: fixed;
    left: 50%;
    bottom: 12px;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 16px;
    z-index: 9999;
    pointer-events: auto;
    font-family: Orbitron, sans-serif;
}
#dev-nav .dev-btn {
    background: rgba(20, 20, 20, 0.85);
    color: #f03c41;
    border: 1px solid #f03c41;
    padding: 6px 14px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 1px;
    cursor: pointer;
    border-radius: 3px;
}
#dev-nav .dev-btn:hover {
    background: #f03c41;
    color: #000;
}
#dev-nav #dev-level {
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 1px;
    min-width: 28px;
    text-align: center;
}

