/**
 * Virtual Gamepad Styling (Console Diamond Layout: X, Y, A, B)
 * Bàn điều khiển ảo mô phỏng tay cầm Console (SNES / Switch / PlayStation).
 * 4 nút bố trí 4 góc hình thoi (Diamond): X ở trên, Y ở trái, B ở dưới, A ở phải.
 * Tối ưu hóa tuyệt đối không bị che khuất trên mọi kích cỡ màn hình điện thoại.
 */

.virtual-gamepad-overlay {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: none; /* Bật/tắt qua JS */
    flex-direction: column;
    justify-content: flex-end;
    padding: 6px 16px 18px 16px;
    pointer-events: none;
    z-index: 999;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    -webkit-touch-callout: none;
    transition: opacity 0.2s ease;
    box-sizing: border-box;
}

/* Cho phép tương tác với các nút */
.virtual-gamepad-overlay * {
    pointer-events: auto;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

/* ==================== HÀNG 1 (TRÊN): NÚT VAI L/R VÀ NÚT CHỨC NĂNG ==================== */
.gamepad-top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 8px;
    padding: 0 4px;
}

.shoulder-btn {
    width: 58px;
    height: 30px;
    border-radius: 15px;
    background: linear-gradient(180deg, #25334d, #141c2c);
    border: 2px solid #3c5277;
    color: #fff;
    font-family: monospace;
    font-size: 13px;
    font-weight: 900;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.6);
    cursor: pointer;
    transition: all 0.08s ease;
}

.shoulder-btn:active, .shoulder-btn.pressed {
    background: #00f0ff;
    color: #000;
    transform: translateY(2px);
    box-shadow: 0 0 12px rgba(0, 240, 255, 0.8);
}

.sys-buttons-bar {
    display: flex;
    gap: 6px;
    background: rgba(10, 14, 22, 0.85);
    padding: 4px 10px;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(6px);
}

.arc-sys-btn {
    background: #151c2a;
    border: 1px solid #28374f;
    border-radius: 10px;
    padding: 4px 8px;
    font-family: monospace;
    font-size: 10px;
    font-weight: bold;
    color: #e0e8f5;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    gap: 3px;
    transition: all 0.1s ease;
}

.arc-sys-btn:active, .arc-sys-btn.active {
    background: #00f0ff;
    color: #000;
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.8);
    transform: translateY(1px);
}

.btn-coin-slot {
    background: linear-gradient(135deg, #ffb700, #cc8800);
    color: #000;
    border-color: #ffe066;
    font-weight: 900;
}

/* ==================== HÀNG 2 (DƯỚI): JOYSTICK VÀ CỤM PHÍM CONSOLE DIAMOND ==================== */
.gamepad-main-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

/* Cần gạt bên trái (Góc dưới bên trái) */
.gamepad-left-zone {
    display: flex;
    justify-content: center;
    align-items: center;
}

.joystick-base {
    width: 120px;
    height: 120px;
    background: radial-gradient(circle, #1a2336 20%, #0d121c 80%, #06080d 100%);
    border: 3px solid #2a3c5e;
    border-radius: 50%;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 
        0 8px 18px rgba(0, 0, 0, 0.7),
        inset 0 3px 6px rgba(255, 255, 255, 0.1),
        inset 0 -3px 6px rgba(0, 0, 0, 0.9);
}

.joystick-base::before {
    content: "▲\A◄  ►\A▼";
    white-space: pre-wrap;
    text-align: center;
    font-size: 11px;
    line-height: 32px;
    color: rgba(0, 240, 255, 0.25);
    position: absolute;
    font-family: monospace;
    pointer-events: none;
}

.joystick-stick {
    width: 56px;
    height: 56px;
    background: radial-gradient(circle at 35% 35%, #ff4b6e, #cc0033 60%, #66001a 100%);
    border-radius: 50%;
    border: 2px solid #ff7799;
    box-shadow: 
        0 5px 12px rgba(0, 0, 0, 0.6),
        inset 0 3px 5px rgba(255, 255, 255, 0.4),
        0 0 10px rgba(255, 0, 85, 0.4);
    position: absolute;
    transform: translate(0px, 0px);
    transition: transform 0.04s ease-out;
}

/* ==================== CỤM 4 NÚT CONSOLE DIAMOND (X, Y, A, B) ==================== */
.gamepad-right-zone {
    display: flex;
    justify-content: center;
    align-items: center;
}

.action-cluster.console-diamond {
    position: relative;
    width: 130px;
    height: 130px;
}

/* Nút bấm tròn phong cách Console / Gamepad */
.action-cluster.console-diamond .arc-btn {
    position: absolute;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: monospace;
    font-size: 17px;
    font-weight: 900;
    color: #ffffff;
    cursor: pointer;
    box-shadow: 
        0 5px 12px rgba(0, 0, 0, 0.7),
        inset 0 3px 5px rgba(255, 255, 255, 0.4),
        inset 0 -3px 5px rgba(0, 0, 0, 0.6);
    transition: transform 0.05s ease, filter 0.05s ease;
}

/* Nút X: Ở TRÊN (Top) - Xanh dương đậm */
.action-cluster.console-diamond .btn-console-x {
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    background: radial-gradient(circle at 35% 35%, #00b4d8, #0077b6);
    border-color: #90e0ef;
    box-shadow: 0 4px 10px rgba(0, 180, 216, 0.45);
}
.action-cluster.console-diamond .btn-console-x:active,
.action-cluster.console-diamond .btn-console-x.pressed {
    transform: translateX(-50%) translateY(2px) scale(0.95);
    filter: brightness(1.25);
}

/* Nút Y: Ở BÊN TRÁI (Left) - Vàng hoàng kim */
.action-cluster.console-diamond .btn-console-y {
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    background: radial-gradient(circle at 35% 35%, #ffb700, #cc8800);
    border-color: #ffe066;
    color: #221100;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 10px rgba(255, 183, 0, 0.45);
}
.action-cluster.console-diamond .btn-console-y:active,
.action-cluster.console-diamond .btn-console-y.pressed {
    transform: translateY(-50%) translateY(2px) scale(0.95);
    filter: brightness(1.25);
}

/* Nút A: Ở BÊN PHẢI (Right) - Xanh ngọc / Xanh lá */
.action-cluster.console-diamond .btn-console-a {
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    background: radial-gradient(circle at 35% 35%, #2ec4b6, #0f8577);
    border-color: #cbf3f0;
    box-shadow: 0 4px 10px rgba(46, 196, 182, 0.45);
}
.action-cluster.console-diamond .btn-console-a:active,
.action-cluster.console-diamond .btn-console-a.pressed {
    transform: translateY(-50%) translateY(2px) scale(0.95);
    filter: brightness(1.25);
}

/* Nút B: Ở DƯỚI (Bottom) - Đỏ neon */
.action-cluster.console-diamond .btn-console-b {
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    background: radial-gradient(circle at 35% 35%, #ff3366, #b3003b);
    border-color: #ff6699;
    box-shadow: 0 4px 10px rgba(255, 51, 102, 0.45);
}
.action-cluster.console-diamond .btn-console-b:active,
.action-cluster.console-diamond .btn-console-b.pressed {
    transform: translateX(-50%) translateY(2px) scale(0.95);
    filter: brightness(1.25);
}

/* ==================== NÚT BẬT/TẮT NÚT ẢO NỔI (ĐẶT Ở GÓC TRÊN) ==================== */
.float-gamepad-toggle {
    position: fixed;
    top: 50px;
    right: 10px;
    z-index: 1000;
    background: rgba(14, 20, 30, 0.88);
    border: 1px solid rgba(0, 240, 255, 0.4);
    color: #00f0ff;
    padding: 5px 9px;
    border-radius: 16px;
    font-family: monospace;
    font-size: 10px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    gap: 4px;
}

.float-gamepad-toggle:active {
    background: #00f0ff;
    color: #000;
}

/* ==================== TỐI ƯU HÓA RESPONSIVE MOBILE ==================== */

/* Khi xoay ngang màn hình điện thoại (Landscape) */
@media (max-height: 550px) and (orientation: landscape) {
    .virtual-gamepad-overlay {
        padding: 4px 12px 10px 12px;
    }
    .gamepad-top-row {
        margin-bottom: 2px;
    }
    .joystick-base {
        width: 105px;
        height: 105px;
    }
    .joystick-stick {
        width: 48px;
        height: 48px;
    }
    .action-cluster.console-diamond {
        width: 115px;
        height: 115px;
    }
    .action-cluster.console-diamond .arc-btn {
        width: 38px;
        height: 38px;
        font-size: 15px;
    }
}

/* Khi cầm dọc điện thoại (Portrait) */
@media (max-width: 600px) and (orientation: portrait) {
    .virtual-gamepad-overlay {
        padding: 4px 8px 14px 8px;
    }
    .joystick-base {
        width: 115px;
        height: 115px;
    }
    .action-cluster.console-diamond {
        width: 125px;
        height: 125px;
    }
    .action-cluster.console-diamond .arc-btn {
        width: 42px;
        height: 42px;
        font-size: 16px;
    }
}
