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

body {
    background: #111;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    -webkit-user-select: none;
    user-select: none;
    touch-action: none;
}

#game {
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    aspect-ratio: 2 / 3;
}

/* --- Desktop --- */
@media (pointer: fine) {
    #game {
        width: 512px;
        height: 768px;
        border: 2px solid #333;
    }

    #touch-controls {
        display: none !important;
    }
}

/* --- Mobile --- */
@media (pointer: coarse) {
    #game {
        max-width: 100vw;
        max-height: 100vh;
        max-height: 100dvh;
        width: auto;
        height: 100vh;
        height: 100dvh;
        border: none;
    }

    #touch-controls {
        display: flex;
        justify-content: space-between;
        align-items: flex-end;
        width: 100%;
        padding: 0 16px 28px;
        position: fixed;
        bottom: 0;
        left: 0;
        pointer-events: none;
        z-index: 10;
    }

    #joystick-zone {
        pointer-events: auto;
        width: 140px;
        height: 140px;
        position: relative;
    }

    #joystick-base {
        width: 120px;
        height: 120px;
        border-radius: 50%;
        background: rgba(255,255,255,0.08);
        border: 2px solid rgba(255,255,255,0.15);
        position: absolute;
        bottom: 0;
        left: 0;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    #joystick-knob {
        width: 46px;
        height: 46px;
        border-radius: 50%;
        background: rgba(255,255,255,0.2);
        border: 2px solid rgba(255,255,255,0.3);
        position: absolute;
        transition: none;
    }

    #btn-zone {
        pointer-events: auto;
        display: flex;
        gap: 12px;
        align-items: flex-end;
    }

    .touch-btn {
        border: none;
        border-radius: 50%;
        color: #fff;
        font-weight: bold;
        font-family: monospace;
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }

    #btn-fire {
        width: 72px;
        height: 72px;
        font-size: 22px;
        background: rgba(100,170,255,0.25);
        border: 2px solid rgba(100,170,255,0.4);
    }

    #btn-fire:active, #btn-fire.active {
        background: rgba(100,170,255,0.5);
    }

    #btn-special {
        width: 54px;
        height: 54px;
        font-size: 16px;
        background: rgba(255,100,100,0.25);
        border: 2px solid rgba(255,100,100,0.4);
        margin-bottom: 40px;
    }

    #btn-special:active, #btn-special.active {
        background: rgba(255,100,100,0.5);
    }
}
