body {
    margin: 0;
    overflow: hidden;
    background-color: #111;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    font-family: Consolas, monospace; /* Giữ font đơn giản để tránh lỗi nếu không có 'Press Start 2P' */
    position: relative;
    color: #fff;
}

/* @import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap'); */


#gameCanvas {
    background-color: #0d0d0d;
    border: 3px solid #00ffff;
    box-shadow: 0 0 15px #00ffff, 0 0 30px #00ffff, 0 0 45px #00ffff;
    display: block;
}

/* --- UI MENU / GAME OVER (Cập nhật màu neon) --- */
#uiOverlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.9);
    color: #fff;
    z-index: 20;
    text-align: center;
}

#mainTitle {
    font-size: 3.5em;
    color: #ff00ff;
    text-shadow: 0 0 10px #ff00ff, 0 0 20px #ff00ff, 0 0 30px #ff00ff;
    margin-bottom: 25px;
    font-weight: bold;
    letter-spacing: 2px;
}

#gameOverMessage {
    font-size: 1.8em;
    color: #00ffff;
    text-shadow: 0 0 8px #00ffff, 0 0 15px #00ffff;
    margin-bottom: 35px;
}

#startButton, #guideButton, #backButton {
    padding: 18px 35px;
    margin: 12px;
    font-size: 1.3em;
    font-weight: bold;
    color: #fff;
    background-color: rgba(0, 0, 0, 0.6);
    border: 2px solid #ff00ff;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    box-shadow: 0 0 10px #ff00ff;
    /* FIX: Đảm bảo nút không bị ghi đè style mặc định của trình duyệt */
    -webkit-appearance: none; 
    -moz-appearance: none; 
    appearance: none; 
}

#startButton:hover, #guideButton:hover, #backButton:hover {
    background-color: rgba(255, 0, 255, 0.2);
    transform: scale(1.08);
    box-shadow: 0 0 15px #ff00ff, 0 0 30px #ff00ff;
    border-color: #00ffff;
}

#instructions {
    margin-top: 25px;
    font-size: 1.1em;
    color: #00ffff;
    text-shadow: 0 0 5px #00ffff;
}

/* --- HƯỚNG DẪN CHƠI --- */
#guideScreen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.98);
    color: #fff;
    z-index: 30;
    display: none;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    overflow-y: auto;
    text-align: left;
}

.guide-title {
    color: #ff00ff;
    text-shadow: 0 0 8px #ff00ff, 0 0 15px #ff00ff;
    margin-bottom: 20px;
}

.guide-content {
    max-width: 700px;
    line-height: 1.8;
    margin-bottom: 30px;
    padding: 15px;
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 10px;
    border: 1px solid #00ffff50;
}

.guide-content h3, .guide-content h4 {
    color: #00ffff;
    border-bottom: 1px solid #00ffff;
    padding-bottom: 8px;
    margin-top: 25px;
    text-shadow: 0 0 5px #00ffff;
}

.guide-content ul {
    list-style-type: none;
    padding-left: 0;
}
.guide-content ul li::before {
    content: '⚡';
    color: #ff00ff;
    display: inline-block;
    width: 1em;
    margin-left: -1em;
}

.guide-content strong {
    color: #ffcc00;
    text-shadow: 0 0 3px #ffcc00;
}

/* --- TỐI ƯU MÀN HÌNH NGANG (LANDSCAPE) & JOYSTICK --- */

/* 1. Yêu cầu xoay điện thoại dọc (Portrait) */
@media (orientation: portrait) {
    #uiOverlay, #gameCanvas, #mobileControls {
        display: none !important;
    }
    body::before {
        content: "Xin hãy xoay điện thoại ngang (Landscape) để chơi game!";
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: #000;
        color: #ff00ff;
        text-shadow: 0 0 10px #ff00ff;
        display: flex;
        justify-content: center;
        align-items: center;
        font-size: 1.8em;
        text-align: center;
        z-index: 99;
    }
}

/* 2. Thiết lập cho màn hình ngang nhỏ (Mobile Landscape) */
#mobileControls {
    display: none;
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

@media (orientation: landscape) and (max-width: 1200px) {
    #mobileControls {
        display: block;
    }
    
    #leftControlArea {
        position: absolute;
        bottom: 10px;
        left: 20px;
        width: 150px;
        height: 150px;
        pointer-events: auto;
    }

    #rightControlArea {
        position: absolute;
        bottom: 10px;
        right: 20px;
        width: 150px;
        height: 150px;
        display: flex;
        flex-direction: column;
        justify-content: flex-end;
        align-items: flex-end;
        pointer-events: auto;
    }
    
    #gameCanvas {
        width: 100vw;
        height: 100vh;
        max-width: 100vw;
        max-height: 100vh;
        border-width: 0;
        box-shadow: none;
    }
    
    #instructions {
        display: none !important;
    }

    /* FIX: Đảm bảo nút mobile không bị ghi đè style mặc định của trình duyệt */
    .control-btn {
        -webkit-appearance: none; 
        -moz-appearance: none; 
        appearance: none; 
        touch-action: manipulation;
        border: none; 
        outline: none; 
    }

    /* Kích thước nút Bắn/Nạp - Style Neon */
    .action-btn {
        padding: 10px 15px;
        font-size: 1.1em;
        font-weight: bold;
        color: #fff;
        background-color: rgba(0, 0, 0, 0.6);
        border-radius: 50%;
        cursor: pointer;
        transition: all 0.2s ease-in-out;
        display: flex;
        justify-content: center;
        align-items: center;
    }
    .action-btn:active {
        transform: scale(0.9);
        box-shadow: 0 0 5px #fff;
    }

    #shootBtn {
        width: 80px;
        height: 80px;
        border: 2px solid #ff00ff;
        box-shadow: 0 0 10px #ff00ff, 0 0 20px #ff00ff80;
        margin-bottom: 10px;
    }
    #shootBtn:hover {
        background-color: rgba(255, 0, 255, 0.2);
        box-shadow: 0 0 15px #ff00ff, 0 0 30px #ff00ff;
    }

    #reloadBtn {
        width: 60px;
        height: 60px;
        font-size: 0.9em;
        border: 2px solid #00ffff;
        box-shadow: 0 0 10px #00ffff, 0 0 20px #00ffffff80;
    }
    #reloadBtn:hover {
        background-color: rgba(0, 255, 255, 0.2);
        box-shadow: 0 0 15px #00ffff, 0 0 30px #00ffff;
    }
}

/* --- CSS CHO JOYSTICK 360 độ (Neon) --- */
#joystickBase {
    width: 120px;
    height: 120px;
    background-color: rgba(0, 0, 0, 0.4);
    border: 3px solid #00ffff;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: auto;
    box-shadow: 0 0 10px #00ffff, 0 0 20px #00ffff80;
    backdrop-filter: blur(2px);
}

#joystickStick {
    width: 60px;
    height: 60px;
    background-color: rgba(255, 0, 255, 0.7);
    border: 2px solid #fff;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 8px #ff00ff, 0 0 15px #ff00ff;
    transition: background-color 0.1s ease-out;
}
/* Hiệu ứng khi Joystick được kéo */
#joystickStick.active {
    background-color: rgba(0, 255, 255, 0.7);
    box-shadow: 0 0 8px #00ffff, 0 0 15px #00ffff;
}


/* --- SCREEN SHAKE EFFECT (Rung màn hình) --- */
@keyframes shake-animation {
    0% { transform: translate(1px, 1px) rotate(0deg); }
    20% { transform: translate(-1px, -2px) rotate(-1deg); }
    40% { transform: translate(-3px, 0px) rotate(1deg); }
    60% { transform: translate(3px, 2px) rotate(0deg); }
    80% { transform: translate(1px, -1px) rotate(1deg); }
    100% { transform: translate(0px, 0px) rotate(0deg); }
}

/* Áp dụng shake trên chính canvas */
.shake {
    animation: shake-animation 0.2s cubic-bezier(.36,.07,.19,.97) both;
    transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
    perspective: 1000px;
}