/* ==========================================================================
   MHEnt. GAME THEME (THE ESPORT GREEN EDITION - V2.0 PRO MAX)
   Tone màu chủ đạo: Xanh Lục Bảo (#10b981) - Tối ưu Glassmorphism & Mobile
   ========================================================================== */

:root { 
    --hub-color: #10b981 !important; 
    --hub-bg: rgba(16, 185, 129, 0.1) !important; 
    --hub-hover: #059669 !important;
}

/* --- NAVBAR OVERRIDES --- */
.navbar { border-bottom: 1px solid rgba(16, 185, 129, 0.15); }
.logo-name, .nav-links a:hover { color: var(--hub-color) !important; }
.avt-img, .user-avatar { border-color: var(--hub-color) !important; }
.menu-toggle svg { stroke: var(--hub-color) !important; }
.app-switcher-btn { color: inherit; }
.app-switcher-menu, .account-dropdown { border: 1px solid rgba(16, 185, 129, 0.2) !important; }
.dropdown-menu::before { border-top: 1px solid rgba(16, 185, 129, 0.2) !important; border-left: 1px solid rgba(16, 185, 129, 0.2) !important; }
.dropdown-item:hover { color: var(--hub-color) !important; }
.dropdown-item::before { background: var(--hub-color); }

.btn-theme { border-color: var(--hub-color) !important; color: var(--hub-color) !important; }
.btn-theme:hover { background: var(--hub-bg); }
.btn-login { background: var(--hub-color) !important; color: white !important; }
.btn-login:hover { background: var(--hub-hover) !important; }

body.dark-mode .navbar { border-bottom: 1px solid rgba(16, 185, 129, 0.2); }
body.dark-mode .app-switcher-menu, body.dark-mode .account-dropdown { border: 1px solid rgba(16, 185, 129, 0.2) !important; }
body.dark-mode .btn-theme { border-color: var(--hub-color) !important; color: var(--hub-color) !important; }
body.dark-mode .logo-name { color: white !important; }
body.dark-mode .nav-links a:hover, body.dark-mode .dropdown-item:hover { color: var(--hub-color) !important; }
body.dark-mode .user-name { color: rgba(255, 255, 255, 0.8) !important; }
body.dark-mode .dropdown-item::before { background: var(--hub-color); }

.btn-back { color: var(--hub-color) !important; border: 1px solid var(--hub-color) !important; }
.btn-back:hover { background: var(--hub-bg) !important; }

.nav-right { display: flex !important; align-items: center !important; gap: 15px !important; }
.user-section { display: flex !important; align-items: center !important; justify-content: flex-end !important; gap: 15px !important; margin: 0 !important; padding: 0 !important; }
.app-switcher-container { position: relative !important; display: flex !important; align-items: center !important; margin: 0 !important; }
.app-switcher-btn { cursor: pointer !important; display: flex !important; align-items: center !important; justify-content: center !important; color: #555; transition: color 0.3s; }
.app-switcher-btn:hover { color: var(--hub-color); }
body.dark-mode .app-switcher-btn { color: #e2e8f0; }
body.dark-mode .app-switcher-btn:hover { color: var(--hub-color); }

.profile-trigger { display: flex !important; align-items: center !important; gap: 10px !important; cursor: pointer !important; }
.footer-link { text-decoration: none; color: var(--hub-color); font-weight: 800; font-size: 13.5px; }
.user-name:hover { color: var(--hub-color); }

.app-item.active { background: var(--hub-bg); border-color: var(--hub-color); color: var(--hub-color) !important; }
body.dark-mode .app-item.active { background: var(--hub-bg); border-color: var(--hub-color); color: var(--hub-color) !important; }
body.dark-mode .user-name, body.dark-mode .logo-name { color: var(--hub-color) !important; }

#btn-back-to-top { background-color: var(--hub-color) !important; box-shadow: 0 4px 10px var(--hub-bg); }
.btn-primary { box-shadow: 0 5px 15px var(--hub-bg); }

/* --- GAME HOMEPAGE HERO & TOOLS --- */
.hero { 
    margin-top: 70px !important; /* Đẩy toàn bộ Hero xuống 70px để né Navbar cố định trên PC */
    background: linear-gradient(135deg, #a7f3d0 0%, #34d399 100%); 
    padding: 60px 5% 50px 5% !important; /* Cân chỉnh lại khoảng trống trên dưới cho thoáng mắt */
    text-align: center; 
    border-bottom: 1px solid var(--border-color); 
    box-sizing: border-box;
}
body.dark-mode .hero { 
    background: linear-gradient(135deg, #064e3b 0%, #0f172a 100%); 
}
.hero h1 { font-size: 38px; color: #1e293b; margin: 0 0 10px 0; font-weight: 900; }
body.dark-mode .hero h1 { color: white; }
.hero h1 span { color: var(--hub-color); }
body.dark-mode .hero h1 span { color: #34d399; }
.small-description { font-size: 15px; color: #64748b; margin: 0 0 35px 0; font-weight: 700; display: block; }
body.dark-mode .small-description { color: #cbd5e1; }
.btn-primary { background: var(--hub-color); border-color: var(--hub-color); color: white; padding: 12px 28px; border-radius: 30px; font-weight: 800; transition: all 0.3s ease; display: inline-block; text-decoration: none; }
.btn-primary:hover { background: var(--hub-hover); border-color: var(--hub-hover); transform: translateY(-3px); }

.tools-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 30px; margin-top: 40px; }
.tool-card { background: #fff; border-radius: 20px; padding: 40px 30px; box-shadow: 0 10px 30px rgba(0,0,0,0.03); text-align: center; cursor: pointer; transition: 0.4s; border: 2px solid #f1f5f9; display: flex; flex-direction: column; align-items: center; position: relative; overflow: hidden; }
.tool-card:hover { transform: translateY(-10px); border-color: var(--hub-color); box-shadow: 0 20px 40px var(--hub-bg); }
.tool-icon-wrapper { width: 80px; height: 80px; border-radius: 20px; background: var(--hub-bg); color: var(--hub-color); display: flex; align-items: center; justify-content: center; font-size: 35px; margin-bottom: 25px; transition: 0.4s; transform: rotate(-5deg); }
.tool-card:hover .tool-icon-wrapper { background: var(--hub-color); color: white; transform: rotate(5deg) scale(1.1); border-radius: 50%; }
.tool-title { font-size: 24px; font-weight: 900; color: #1e293b; margin: 0 0 15px 0; }
.tool-desc { color: #64748b; font-size: 15px; font-weight: 700; margin: 0; line-height: 1.6; }
.game-badge { position: absolute; top: 15px; right: -30px; background: #ef4444; color: white; padding: 5px 30px; font-size: 12px; font-weight: 900; transform: rotate(45deg); box-shadow: 0 2px 10px rgba(239, 68, 68, 0.4); text-transform: uppercase; letter-spacing: 1px; }
body.dark-mode .tool-card { background: #1e293b; border-color: #334155; }
body.dark-mode .tool-title { color: #f8fafc; }
body.dark-mode .tool-desc { color: #94a3b8; }
.app-icon svg { width: 26px; height: 26px; stroke-width: 1.5; transition: 0.3s; }
.app-item:hover .app-icon svg { transform: scale(1.1); }
body.dark-mode .app-icon svg { color: #e2e8f0; }

/* --- GAME LOBBY STYLES (DÙNG CHO SẢNH CHỜ CỜ VUA / CỜ TƯỚNG) --- */
.lobby-container { max-width: 1000px; margin: 40px auto; padding: 0 20px; display: grid; grid-template-columns: 1fr 1fr; gap: 30px; }
.action-card { background: #fff; border-radius: 20px; padding: 40px 30px; text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,0.03); border: 2px solid transparent; transition: 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
body.dark-mode .action-card { background: #1e293b; box-shadow: 0 10px 30px rgba(0,0,0,0.2); }
.action-card:hover { border-color: var(--hub-color); transform: translateY(-5px); box-shadow: 0 15px 35px var(--hub-bg); }
.action-icon { font-size: 55px; color: var(--hub-color); margin-bottom: 20px; transition: 0.3s; }
.action-card:hover .action-icon { transform: scale(1.1); }
.action-title { font-size: 24px; font-weight: 900; margin-bottom: 15px; color: #1e293b; }
body.dark-mode .action-title { color: #f8fafc; }
.room-input { width: 100%; padding: 15px; font-size: 24px; font-weight: 900; text-align: center; letter-spacing: 8px; border: 2px solid #e2e8f0; border-radius: 12px; margin-bottom: 20px; outline: none; background: #f8fafc; color: var(--hub-color); transition: 0.3s; }
.room-input::placeholder { letter-spacing: 1px; font-weight: 600; color: #94a3b8; font-size: 16px; }
.room-input:focus { border-color: var(--hub-color); background: #fff; box-shadow: 0 4px 15px var(--hub-bg); }
body.dark-mode .room-input { background: #0f172a; border-color: #334155; }
body.dark-mode .room-input:focus { background: #1e293b; }
.btn-chess, .btn-xiangqi { background: var(--hub-color); color: white; border: none; padding: 16px 30px; font-size: 16px; font-weight: 900; border-radius: 12px; cursor: pointer; width: 100%; transition: 0.3s; box-shadow: 0 4px 15px var(--hub-bg); text-transform: uppercase; }
.btn-chess:hover, .btn-xiangqi:hover { background: var(--hub-hover); transform: translateY(-2px); box-shadow: 0 8px 20px var(--hub-bg); }
.btn-chess:disabled, .btn-xiangqi:disabled { background: #94a3b8; cursor: not-allowed; transform: none; box-shadow: none; }
.room-list-container { grid-column: 1 / -1; background: #fff; border-radius: 20px; padding: 30px; box-shadow: 0 10px 30px rgba(0,0,0,0.03); border: 1px solid #f1f5f9; }
body.dark-mode .room-list-container { background: #1e293b; border-color: #334155; }
.room-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; margin-top: 20px; }
.room-item { border: 2px solid #e2e8f0; border-radius: 15px; padding: 20px; display: flex; justify-content: space-between; align-items: center; transition: 0.3s; background: #f8fafc; }
body.dark-mode .room-item { border-color: #334155; background: #0f172a; }
.room-item:hover { border-color: var(--hub-color); background: #fff; box-shadow: 0 10px 25px var(--hub-bg); transform: translateY(-3px); }
body.dark-mode .room-item:hover { background: #1e293b; }
.host-info { display: flex; align-items: center; gap: 12px; }
.host-avt { width: 45px; height: 45px; border-radius: 50%; border: 2px solid #e2e8f0; object-fit: cover; }
.room-item:hover .host-avt { border-color: var(--hub-color); }
.host-name { font-weight: 800; font-size: 16px; color: #1e293b; margin: 0 0 4px 0; }
body.dark-mode .host-name { color: #f8fafc; }
.room-id-badge { background: #e2e8f0; color: #475569; font-size: 12px; font-weight: 800; padding: 4px 10px; border-radius: 8px; letter-spacing: 1px; }
body.dark-mode .room-id-badge { background: #334155; color: #cbd5e1; }
.room-item:hover .room-id-badge { background: var(--hub-bg); color: var(--hub-color); }
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(15, 23, 42, 0.85); backdrop-filter: blur(5px); z-index: 9999; display: none; justify-content: center; align-items: center; opacity: 0; transition: 0.3s; }
.modal-overlay.active { display: flex; opacity: 1; }
.modal-box { background: #1e293b; border: 2px solid #334155; border-radius: 20px; width: 90%; max-width: 500px; padding: 30px; transform: translateY(20px); transition: 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); box-shadow: 0 20px 50px rgba(0,0,0,0.5); position: relative; }
.modal-overlay.active .modal-box { transform: translateY(0); }
.modal-close { position: absolute; top: 20px; right: 20px; font-size: 24px; color: #64748b; cursor: pointer; transition: 0.2s; background: none; border: none; }
.modal-close:hover { color: #ef4444; }
.setting-group { margin-bottom: 20px; text-align: left; }
.setting-group label { display: block; font-weight: 800; color: #cbd5e1; margin-bottom: 10px; font-size: 14px; }
.setting-select { width: 100%; padding: 12px 15px; border-radius: 12px; background: #0f172a; border: 2px solid #334155; color: white; font-size: 15px; font-weight: 700; outline: none; transition: 0.3s; font-family: 'Nunito', sans-serif; cursor: pointer; }
.setting-select:focus { border-color: var(--hub-color); box-shadow: 0 0 0 4px var(--hub-bg); }

/* ==============================================================
   ⚡ TỐI ƯU TRÊN ĐIỆN THOẠI (< 768px)
   ============================================================== */
@media (max-width: 1024px) { 
    body.game-play-page { overflow: auto; } 
    .battle-arena { display: flex; flex-direction: column; gap: 20px; padding: 15px; } 
    .center-panel { order: -1; } 
    .chess-board { aspect-ratio: 1/1; height: auto; max-width: 95vw; } 
    .side-section { min-height: 250px; } 
}

@media (max-width: 900px) { 
    .lobby-container { grid-template-columns: 1fr; } 
    .tools-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } 
}

@media screen and (max-width: 768px) {
    /* Khóa cứng tọa độ neo của App Switcher vào góc trên phải màn hình */
    .dropdown-menu.app-switcher-menu,
    .dropdown-menu.account-dropdown {
        position: fixed !important;
        top: 55px !important;
        right: 12px !important;
        left: auto !important;
        width: 280px !important;
        max-width: calc(100vw - 24px) !important;
        margin: 0 !important;
        transform-origin: top right !important;
    }
}

@media (max-width: 640px) { 
    .hero { padding: 50px 16px 40px 16px; margin-top: 55px; } 
    .hero h1 { font-size: clamp(24px, 7vw, 32px); line-height: 1.2; } 
    .small-description { font-size: 14px; } 
    .tools-grid { grid-template-columns: 1fr; } 
    .tool-card { padding: 24px 18px; } 
    .lobby-container { padding: 0 12px; margin: 20px auto; } 
    .room-grid { grid-template-columns: 1fr; } 
    .room-item { flex-direction: column; align-items: flex-start; gap: 12px; } 
    .btn-chess, .btn-xiangqi { font-size: 14px; padding: 14px 20px; } 
    .app-switcher-container { margin-right: 8px !important; } 
    .match-header { padding: 10px 12px; } 
    .room-info { flex-wrap: wrap; gap: 8px; } 
    .player-card { padding: 12px; } 
    .player-timer { font-size: 18px; padding: 8px 10px; } 
    .tool-header, .side-header { font-size: 13px; } 
    .board-overlay h2 { font-size: 20px; } 
    .set-result-title { font-size: 2.2rem; } 
    .set-countdown-text { font-size: 4rem; } 
}

@media screen and (max-width: 768px) {
    .hero { 
        margin-top: 55px !important; /* Bù vừa đủ 55px cho Navbar nhỏ trên mobile */
        padding: 40px 16px 30px 16px !important; 
    }
}

/* --- Layout Panels --- */
.left-panel, .right-panel {
    display: flex;
    flex-direction: column;
    gap: 15px;
}
