/* --- CẤU HÌNH CHUNG --- */
html {
    -ms-touch-action: none;
}

body {
    margin: 0;
    padding: 0;
    background-color: #222; /* Màu nền khi chơi trên PC */
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
    font-family: 'Segoe UI', Helvetica, Arial, sans-serif;
}

/* --- KHUNG GIẢ LẬP ĐIỆN THOẠI --- */
/* --- KHUNG GIẢ LẬP ĐIỆN THOẠI (ĐÃ FIX) --- */
#GameDiv {
    position: relative;
    
    /* --- LOGIC CO GIÃN MỚI --- */
    /* Giữ tỷ lệ khung hình chuẩn 390/844 */
    aspect-ratio: 390 / 844; 

    /* Tính toán chiều rộng: Lấy giá trị nhỏ nhất giữa Chiều rộng màn hình VÀ (Chiều cao màn hình * tỷ lệ) */
    width: min(100vw, calc(100vh * (390 / 844)));
    
    /* Tính toán chiều cao: Lấy giá trị nhỏ nhất giữa Chiều cao màn hình VÀ (Chiều rộng màn hình * tỷ lệ ngược) */
    height: min(100vh, calc(100vw * (844 / 390)));
    
    /* --- CÁC THUỘC TÍNH CŨ --- */
    background-color: #000;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    overflow: hidden;
    margin: auto; /* Căn giữa phòng trường hợp flexbox lỗi */
}

#GameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    /* Quan trọng: Ngăn trình duyệt tự xử lý chạm, để game tự xử lý */
    touch-action: none; 
    user-select: none;
    -webkit-user-drag: none;
    outline: none;
}

/* --- MÀN HÌNH LOADING (SPLASH) --- */
#splash {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #171717 url('../../splash.png') no-repeat center; /* Sửa đường dẫn ảnh nếu cần */
    background-size: 40%;
    display: none; /* Mặc định ẩn, JS sẽ bật lên */
}

.progress-bar {
    position: absolute;
    left: 27.5%;
    top: 80%;
    height: 3px;
    padding: 0;
    width: 45%;
    border-radius: 2px;
    box-shadow: 0 1px 5px #000 inset, 0 1px 0 #444;
}

.progress-bar span {
    display: block;
    height: 100%;
    border-radius: 3px;
    transition: width .4s ease-in-out;
    background-color: #3dc5de;
}

.stripes span {
    background-size: 30px 30px;
    background-image: linear-gradient(135deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);
    animation: animate-stripes 1s linear infinite;
}

@keyframes animate-stripes {
    0% { background-position: 0 0; }
    100% { background-position: 60px 0; }
}

/* --- GIAO DIỆN ĐĂNG NHẬP (OVERLAY) --- */
#loginOverlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 999;
    transition: opacity 0.5s;
    opacity: 1;
    pointer-events: auto;
}

#loginOverlay.hidden {
    display: none !important;
    opacity: 0;
    pointer-events: none;
}

.login-box {
    width: 80%;
    background: #fff;
    padding: 25px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.login-box h2 {
    margin-top: 0;
    color: #4CAF50;
    margin-bottom: 20px;
}

.login-box input {
    width: 90%;
    padding: 12px;
    margin: 8px 0;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 14px;
    outline: none;
}

.login-box input:focus {
    border-color: #4CAF50;
}

.login-box button {
    width: 100%;
    padding: 12px;
    margin-top: 10px;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    color: white;
    transition: filter 0.2s;
}

.login-box button:hover {
    filter: brightness(1.1);
}

.btn-login { background-color: #FF9800; }
.btn-reg { background-color: #2196F3; }
.btn-guest { background-color: #607D8B; margin-top: 5px; font-size: 14px; padding: 8px; }

/* --- MOD MENU UI --- */
#modBtn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: red;
    color: white;
    border: 2px solid white;
    padding: 5px 12px;
    font-weight: bold;
    cursor: pointer;
    z-index: 9999;
    border-radius: 20px;
    box-shadow: 0 0 10px red;
    font-size: 12px;
    transition: transform 0.2s;
}

#modBtn:active {
    transform: scale(0.9);
}

#modMenu {
    position: absolute;
    top: 50px;
    right: 10px;
    width: 260px;
    background: rgba(0, 0, 0, 0.95);
    border: 2px solid #00ff00;
    border-radius: 10px;
    padding: 15px;
    color: #00ff00;
    z-index: 9998;
    display: none; /* Mặc định ẩn */
    text-align: left;
    user-select: none;
    max-height: 80%;
    overflow-y: auto; /* Cho phép cuộn nếu menu dài */
}

#modMenu h3 {
    margin: 0 0 15px 0;
    text-align: center;
    border-bottom: 1px solid #00ff00;
    padding-bottom: 5px;
    font-size: 16px;
    text-transform: uppercase;
}

.mod-group {
    margin-bottom: 15px;
    border: 1px dashed #555;
    padding: 8px;
    border-radius: 5px;
}

.mod-group label {
    display: block;
    font-size: 11px;
    color: #aaa;
    margin-bottom: 5px;
    font-weight: bold;
    text-transform: uppercase;
}

/* Nút bấm trong Menu Hack */
.mod-btn {
    width: 100%;
    margin: 5px 0;
    padding: 10px;
    background: #333;
    color: white;
    border: 1px solid #00ff00;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    border-radius: 5px;
    transition: all 0.2s;
}

.mod-btn:hover {
    background: #00ff00;
    color: black;
}

.mod-btn.danger {
    border-color: red;
    color: red;
}

.mod-btn.danger:hover {
    background: red;
    color: white;
}

/* Hàng nút icon ngang (Cộng vàng, kim cương...) */
.icon-btn-row {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin: 5px 0;
}

.mod-btn-icon {
    flex-grow: 1;
    width: auto;
    margin: 0;
    padding: 8px 0;
    font-size: 20px;
    background: #333;
    color: #fff;
    border: 1px solid #00ff00;
    cursor: pointer;
    border-radius: 5px;
    text-align: center;
    transition: all 0.2s;
}

.mod-btn-icon:hover {
    background: #00ff00;
    color: #000;
    transform: translateY(-2px);
}

#modStatus {
    font-size: 11px;
    color: yellow;
    text-align: center;
    margin-top: 10px;
    font-style: italic;
    border-top: 1px solid #333;
    padding-top: 5px;
}

/* --- RESPONSIVE MOBILE --- */
/* Khi chạy trên điện thoại thật thì Full màn hình */
/* --- RESPONSIVE MOBILE --- */
@media (max-width: 530px) {
    body {
        display: flex; /* Vẫn giữ flex để căn giữa nếu cần */
        background-color: #000;
    }
    #GameDiv {
        width: 100vw;   /* Full chiều ngang */
        height: 100dvh; /* Full chiều cao thực tế (trừ thanh địa chỉ trình duyệt) */
        
        /* Tắt shadow và bo góc trên mobile cho giống native app */
        box-shadow: none;
        border-radius: 0;
        
        /* Reset lại max-width/height để đảm bảo full màn */
        max-width: none;
        max-height: none;
        aspect-ratio: unset; /* Tắt tỷ lệ cố định để full màn hình điện thoại người chơi */
    }
}