/* ========================================= */
/* RESET & BASE                              */
/* ========================================= */
:root {
    --bg: #000000; --surface: #111111; --surface-hover: #1a1a1a;
    --primary: #00d4ff; --secondary: #a855f7; --text-main: #ffffff; --text-muted: #888888;
    --border: #222222; --glow: rgba(0, 212, 255, 0.3);
    --future: #ffaa00; --success: #00ff88; --danger: #ff4444;
    --icon-scale: 1; 
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { 
    font-family: -apple-system, 'Segoe UI', Roboto, sans-serif; 
    color: var(--text-main); line-height: 1.6; 
    background: var(--bg); 
    overflow: hidden; display: flex; flex-direction: column; height: 100vh; height: 100dvh;
}

#bgCanvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }

/* ========================================= */
/* NAVBAR                                    */
/* ========================================= */
.navbar { 
    position: relative; z-index: 100; 
    background: rgba(0,0,0,0.8); backdrop-filter: blur(10px); 
    padding: 0 20px; height: 60px; display: flex; align-items: center; justify-content: space-between; 
    border-bottom: 1px solid var(--border); flex-shrink: 0; 
}
.navbar-left { display: flex; align-items: center; gap: 30px; }
.navbar .logo { font-size: 20px; font-weight: bold; color: var(--primary); display: flex; align-items: center; gap: 8px; text-shadow: 0 0 10px var(--glow); text-decoration: none; z-index: 101; }
.navbar-right { display: flex; gap: 10px; align-items: center; }

.control-btn { 
    background: rgba(15, 15, 15, 0.8); border: 1px solid var(--border); 
    color: white; padding: 6px 12px; border-radius: 20px; 
    display: flex; justify-content: center; align-items: center; gap: 6px;
    cursor: pointer; transition: 0.3s; font-size: 12px; font-weight: bold;
}
.control-btn:hover { border-color: var(--primary); box-shadow: 0 0 15px var(--glow); }
.control-btn svg { width: 16px; height: 16px; fill: var(--primary); }

/* Language Selector — lá cờ rõ ràng */
.lang-selector { 
    display: flex; gap: 4px; background: rgba(0,0,0,0.65); 
    padding: 4px; border-radius: 24px; border: 1px solid var(--border); 
}
.lang-btn { 
    background: transparent; color: #aaa; border: none; 
    padding: 6px 12px; border-radius: 18px; cursor: pointer; 
    font-size: 13px; font-weight: 700; transition: 0.25s;
    display: flex; align-items: center; gap: 6px;
}
.lang-btn .flag { width: 24px; height: 16px; object-fit: cover; border-radius: 2px; box-shadow: 0 0 0 1px rgba(255,255,255,0.3); display: block; }
.lang-btn .lang-code { font-size: 12px; letter-spacing: 0.5px; }
.lang-btn:hover { color: #fff; background: rgba(255,255,255,0.06); }
.lang-btn.active { 
    background: var(--primary); color: #000; 
    box-shadow: 0 0 14px rgba(0, 212, 255, 0.5);
}
.lang-btn.active .lang-code { color: #000; }

/* Mode button */
.mode-btn {
    min-width: 90px;
    font-size: 12px !important;
}

/* ========================================= */
/* TOP MENU BAR (DROPDOWN)                   */
/* ========================================= */
.top-menu-bar {
    display: flex;
    gap: 5px;
    align-items: center;
    height: 100%;
}
.menu-group {
    position: relative;
    height: 100%;
    display: flex;
    align-items: center;
}
.menu-group-title {
    font-size: 13px;
    font-weight: bold;
    color: var(--text-muted);
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: 0.3s;
}
.menu-group:hover .menu-group-title, 
.menu-group.active .menu-group-title {
    color: var(--primary);
    background: rgba(0, 212, 255, 0.1);
}
/* Dropdown Menu */
.menu-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    background: rgba(15, 15, 15, 0.98);
    border: 1px solid var(--primary);
    border-radius: 12px;
    padding: 15px 8px 8px;
    display: none;
    flex-direction: column;
    gap: 2px;
    min-width: 200px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
    opacity: 0;
    transition: all 0.2s;
    margin-top: -5px;
}
.menu-group:hover .menu-dropdown,
.menu-group.active .menu-dropdown {
    display: flex;
    opacity: 1;
}
.menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    color: white;
    text-decoration: none;
    transition: 0.2s;
    font-size: 13px;
}
.menu-item:hover {
    background: rgba(0, 212, 255, 0.2);
    color: var(--primary);
}
.menu-item img { width: 20px; height: 20px; object-fit: contain; }

/* ========================================= */
/* KHU VỰC CHÍNH (VŨ TRỤ)                    */
/* ========================================= */
.main-content {
    position: relative;
    flex: 1;
    width: 100%;
    overflow: hidden;
}

.sun-chiri { 
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); 
    z-index: 10; width: 160px; height: 160px; 
    background: radial-gradient(circle, rgba(255, 204, 0, 0.4) 0%, rgba(255, 100, 0, 0.1) 50%, transparent 70%); 
    border-radius: 50%; display: flex; justify-content: center; align-items: center; 
    box-shadow: 0 0 100px rgba(255, 204, 0, 0.4); 
    pointer-events: none; 
    animation: sunPulse 4s infinite alternate;
}
.sun-chiri img { width: 110px; height: 110px; object-fit: contain; filter: drop-shadow(0 0 20px #ffcc00); }
@keyframes sunPulse { 
    from { box-shadow: 0 0 80px rgba(255, 204, 0, 0.3); transform: translate(-50%, -50%) scale(1); } 
    to { box-shadow: 0 0 150px rgba(255, 204, 0, 0.6); transform: translate(-50%, -50%) scale(1.05); } 
}

/* Hành tinh tính năng */
.floating-item {
    position: absolute; 
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    cursor: pointer; text-decoration: none; z-index: 5;
    transition: filter 0.2s, opacity 0.3s, transform 0.3s;
    will-change: left, top, transform;
    transform-origin: center center;
}
.item-content { display: flex; flex-direction: column; align-items: center; transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.floating-item:hover { z-index: 30; filter: drop-shadow(0 0 25px var(--primary)); }
.floating-item:hover .item-content { transform: scale(1.1); }
.floating-item.paused { opacity: 0.9; }

.hex-icon {
    width: 90px; height: 90px; 
    background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.15) 0%, rgba(20,20,20,0.95) 60%);
    border: 2px solid var(--border);
    border-radius: 50%;
    display: flex; justify-content: center; align-items: center;
    transition: 0.3s; position: relative;
    box-shadow: 
        inset -10px -10px 20px rgba(0,0,0,0.8),
        inset 10px 10px 20px rgba(255,255,255,0.05),
        0 0 15px rgba(0, 0, 0, 0.5);
}
.floating-item:hover .hex-icon { 
    border-color: var(--primary); 
    box-shadow: 
        inset -10px -10px 20px rgba(0,0,0,0.8), 
        inset 10px 10px 20px rgba(255,255,255,0.15), 
        0 0 30px var(--glow); 
}
.hex-icon img { width: 50px; height: 50px; object-fit: contain; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5)); }

.floating-item .label { 
    font-size: 13px; font-weight: 800; margin-top: 8px; 
    color: #ffffff; text-shadow: 0 0 5px rgba(0,0,0,1);
    background: rgba(0,0,0,0.85); padding: 4px 10px; border-radius: 8px; white-space: nowrap; 
    border: 1px solid rgba(255,255,255,0.1); letter-spacing: 0.5px;
}
.floating-item:hover .label { background: var(--primary); color: #000; border-color: var(--primary); }

.floating-item.future .hex-icon { border-color: rgba(255, 170, 0, 0.3); }
.floating-item.future:hover .hex-icon { border-color: var(--future); box-shadow: 0 0 20px rgba(255, 170, 0, 0.4); }
.floating-item.future:hover .label { background: var(--future); color: #000; border-color: var(--future); }

/* Hiệu ứng Sao chổi chạm Icon */
.floating-item.impact {
    transform: scale(1.4) !important;
    filter: drop-shadow(0 0 30px #ffffff) !important;
    transition: all 0.3s ease-in-out !important;
    z-index: 50 !important;
}
.floating-item.impact .hex-icon {
    background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.5) 0%, rgba(255, 255, 255, 0.2) 60%) !important;
    border-color: #ffffff !important;
}

/* Trái đất & Mặt trăng */
.decor-item { position: absolute; pointer-events: none; z-index: 2; }
.earth-decor { 
    width: 60px; height: 60px; 
    background: url('/media/earth.gif') no-repeat center center; 
    background-size: cover; border-radius: 50%;
    filter: drop-shadow(0 0 15px #00d4ff); z-index: 3;
}
.moon-decor { 
    width: 20px; height: 20px; 
    background: url('/media/moon.gif') no-repeat center center; 
    background-size: cover; border-radius: 50%; 
    filter: drop-shadow(0 0 8px #ffffff); z-index: 3;
}

/* ========================================= */
/* CHẾ ĐỘ PHONE (LƯỚI NHIỀU HÀNG CỘT - APP STYLE) */
/* ========================================= */
.phone-mode {
    background: linear-gradient(180deg, #0a0a12 0%, #000000 100%);
}

.phone-mode .main-content {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 18px 12px !important;
    padding: 24px 16px 40px !important;
    align-content: start !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    height: calc(100vh - 60px - 40px) !important;
    max-height: calc(100dvh - 60px - 40px) !important;
    box-sizing: border-box !important;
    scrollbar-width: thin;
    scrollbar-color: var(--primary) transparent;
}

.phone-mode .main-content::-webkit-scrollbar {
    width: 6px;
}
.phone-mode .main-content::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 10px;
}

.phone-mode .sun-chiri, 
.phone-mode .decor-item,
.phone-mode .menu-group,
.phone-mode .astronaut { 
    display: none !important; 
}

.phone-mode #itemsContainer {
    display: contents !important; /* các icon trở thành con trực tiếp của grid */
}

.phone-mode .floating-item {
    position: relative !important;
    left: auto !important;
    top: auto !important;
    transform: none !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    opacity: 1 !important;
    z-index: auto !important;
    filter: none !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: flex-start !important;
    padding: 8px 4px !important;
    border-radius: 18px !important;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.2s !important;
}

.phone-mode .floating-item:hover,
.phone-mode .floating-item:active {
    background: rgba(0, 212, 255, 0.08);
    transform: scale(1.06) !important;
    z-index: 10 !important;
}

.phone-mode .item-content {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    width: 100% !important;
    transform: none !important;
}

.phone-mode .hex-icon {
    width: 92px !important;
    height: 92px !important;
    border-radius: 22px !important;
    background: linear-gradient(145deg, #2a2a2a, #1a1a1a) !important;
    border: 1px solid rgba(255,255,255,0.08) !important;
    margin: 0 auto 10px !important;
    box-shadow: 
        0 8px 20px rgba(0,0,0,0.45),
        inset 0 1px 0 rgba(255,255,255,0.08) !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    transition: all 0.25s ease !important;
}

.phone-mode .floating-item:hover .hex-icon {
    border-color: var(--primary) !important;
    box-shadow: 
        0 0 20px rgba(0, 212, 255, 0.35),
        0 8px 24px rgba(0,0,0,0.5),
        inset 0 1px 0 rgba(255,255,255,0.12) !important;
    transform: translateY(-2px);
}

.phone-mode .hex-icon img { 
    width: 48px !important; 
    height: 48px !important; 
    object-fit: contain !important;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
}

.phone-mode .label { 
    text-align: center !important; 
    font-size: 12px !important;
    font-weight: 600 !important;
    line-height: 1.25 !important;
    color: #e8e8e8 !important;
    background: transparent !important;
    border: none !important;
    padding: 0 2px !important;
    margin-top: 0 !important;
    white-space: normal !important;
    max-width: 100px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

.phone-mode .floating-item:hover .label {
    color: var(--primary) !important;
    background: transparent !important;
}

.phone-mode .floating-item.future .hex-icon {
    border-color: rgba(255, 170, 0, 0.25) !important;
}
.phone-mode .floating-item.future:hover .hex-icon {
    border-color: var(--future) !important;
    box-shadow: 0 0 18px rgba(255, 170, 0, 0.3) !important;
}
.phone-mode .floating-item.future:hover .label {
    color: var(--future) !important;
}

/* ========================================= */
/* PHI HÀNH GIA                              */
/* ========================================= */
.astronaut { 
    position: absolute; width: 60px; height: 60px; z-index: 15; 
    display: flex; flex-direction: column; align-items: center; justify-content: center; 
    transition: transform 0.2s; 
}
.astronaut-svg { width: 100%; height: 100%; filter: drop-shadow(0 0 10px var(--glow)); }
.astronaut-body { transition: fill 0.3s; }
.astronaut-label { 
    position: absolute; top: 110%; left: 50%; transform: translateX(-50%); 
    font-size: 10px; background: rgba(0,0,0,0.85); padding: 2px 6px; 
    border-radius: 4px; white-space: nowrap; border: 1px solid; pointer-events: none; 
}

/* ========================================= */
/* SETTINGS MODAL                            */
/* ========================================= */
.settings-modal {
    position: fixed; top: 70px; right: 20px;
    background: rgba(10, 10, 10, 0.95); backdrop-filter: blur(15px);
    border: 1px solid var(--primary); border-radius: 15px;
    padding: 25px; width: 340px; z-index: 10000;
    display: none; flex-direction: column; gap: 15px;
    box-shadow: 0 10px 40px rgba(0, 212, 255, 0.2);
    max-height: 80vh; overflow-y: auto;
}
.settings-modal.active { display: flex; }
.settings-modal h3 { color: var(--primary); margin-bottom: 5px; font-size: 18px; text-align: center;}
.settings-modal label { font-size: 13px; color: var(--text-muted); display: block; margin-bottom: 5px;}
.settings-modal input[type="text"] {
    width: 100%; padding: 10px; background: #000; border: 1px solid var(--border);
    border-radius: 8px; color: white; font-size: 14px;
}
.settings-modal input[type="text"]:focus { border-color: var(--primary); outline: none; }

.avatar-upload-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px;}
.avatar-preview { width: 50px; height: 50px; border-radius: 50%; background: #333; border: 2px solid var(--primary); overflow: hidden; display: flex; justify-content: center; align-items: center;}
.avatar-preview img { width: 100%; height: 100%; object-fit: cover;}
.btn-upload { background: #333; color: white; border: 1px solid #555; padding: 8px 12px; border-radius: 8px; cursor: pointer; font-size: 12px;}
.btn-upload:hover { background: var(--primary); color: black;}

.color-options { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 10px;}
.color-option {
    width: 30px; height: 30px; border-radius: 50%; cursor: pointer;
    border: 2px solid transparent; transition: 0.2s;
}
.color-option:hover { transform: scale(1.1); }
.color-option.selected { border-color: white; transform: scale(1.1); }

.slider-group-modal { display: flex; flex-direction: column; gap: 5px; margin-bottom: 10px;}
.slider-group-modal input[type=range] { width: 100%; -webkit-appearance: none; height: 6px; background: rgba(255,255,255,0.1); border-radius: 5px; outline: none;}
.slider-group-modal input[type=range]::-webkit-slider-thumb { height: 16px; width: 16px; border-radius: 50%; background: var(--primary); cursor: pointer; -webkit-appearance: none; box-shadow: 0 0 10px var(--primary); }
.slider-group-modal .value-display { color: var(--primary); font-weight: bold; float: right;}

.btn-save-settings {
    background: var(--primary); color: #000; border: none; padding: 12px;
    border-radius: 8px; font-weight: bold; cursor: pointer; font-size: 15px;
    transition: 0.3s;
}
.btn-save-settings:hover { background: var(--success); box-shadow: 0 0 15px var(--success); }
.btn-cancel-settings {
    background: transparent; color: #888; border: 1px solid #444; padding: 10px;
    border-radius: 8px; font-weight: bold; cursor: pointer; font-size: 14px;
    margin-top: 5px; transition: 0.3s;
}
.btn-cancel-settings:hover { background: #333; color: white; }

/* ========================================= */
/* HIỆU ỨNG PHI THUYỀN & NỔ                  */
/* ========================================= */
.ship {
    position: fixed; z-index: 9999; width: 60px; height: 60px;
    background: url('https://cdn-icons-png.flaticon.com/512/3212/3212608.png') no-repeat center center;
    background-size: contain; pointer-events: none; display: none; transform-origin: center;
    filter: drop-shadow(0 0 20px #ffaa00);
}
.explosion {
    position: fixed; z-index: 9999; width: 120px; height: 120px;
    border-radius: 50%; background: radial-gradient(circle, #fff, #ffaa00, #ff4444, transparent);
    pointer-events: none; display: none; transform: scale(0);
    animation: explodeAnim 0.6s forwards;
}
@keyframes explodeAnim { 0% { transform: scale(0); opacity: 1; } 100% { transform: scale(3); opacity: 0; } }

/* ========================================= */
/* MODAL OVERLAY (ĐĂNG NHẬP & NÂNG CẤP)      */
/* ========================================= */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); backdrop-filter: blur(5px); z-index: 10000; display: none; justify-content: center; align-items: center; }
.modal-overlay.active { display: flex; }
.modal-content { background: var(--surface); border: 2px solid var(--future); border-radius: 20px; padding: 40px; max-width: 400px; text-align: center; box-shadow: 0 0 40px rgba(255, 170, 0, 0.2); }
.modal-content h2 { color: var(--future); margin-bottom: 15px; font-size: 24px; }
.modal-content p { color: var(--text-muted); margin-bottom: 30px; font-size: 15px; }
.btn-modal { background: var(--future); color: #000; border: none; padding: 12px 30px; border-radius: 30px; font-weight: bold; font-size: 16px; cursor: pointer; transition: 0.3s; width: 100%; }

#loginModal { z-index: 10001; }
#loginModal .modal-content { border-color: var(--primary); box-shadow: 0 0 40px rgba(0, 212, 255, 0.3); }
#loginModal h2 { color: var(--primary); }
#loginModal input { width: 100%; padding: 12px; margin-bottom: 10px; background: #000; border: 1px solid var(--border); border-radius: 8px; color: white; }
#loginModal .btn-login-submit { background: var(--primary); color: #000; border: none; padding: 12px; border-radius: 8px; font-weight: bold; width: 100%; cursor: pointer; }

/* ========================================= */
/* MARQUEE (CHẠY DƯỚI CÙNG)                  */
/* ========================================= */
.bottom-marquee {
    width: 100%;
    overflow: hidden;
    white-space: nowrap;
    background: #000;
    border-top: 1px solid var(--border);
    padding: 8px 0;
    position: relative;
    z-index: 100;
    flex-shrink: 0;
}
.bottom-marquee-content {
    display: inline-block;
    animation: marquee-bottom 25s linear infinite;
    color: #888;
    font-size: 13px;
    font-family: monospace;
}
@keyframes marquee-bottom {
    0% { transform: translateX(100vw); }
    100% { transform: translateX(-100%); }
}

/* ========================================= */
/* RESPONSIVE (MOBILE)                       */
/* ========================================= */
@media (max-width: 768px) {
    .sun-chiri { width: 120px; height: 120px; }
    .sun-chiri img { width: 80px; height: 80px; }
    .hex-icon { width: 80px; height: 80px; }
    .hex-icon img { width: 40px; height: 40px; }
    .floating-item .label { font-size: 11px; padding: 2px 6px; }
    .settings-modal { width: 90%; right: 5%; }
    .navbar { padding: 10px; flex-direction: column; height: auto; gap: 10px; }
    .navbar-left { width: 100%; justify-content: space-between; }
    .top-menu-bar { display: none; }

    /* Phone mode luôn 4 cột */
    .phone-mode .main-content {
        grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
        gap: 14px 8px !important;
        padding: 16px 10px 30px !important;
        height: calc(100vh - 90px - 36px) !important;
        max-height: calc(100dvh - 90px - 36px) !important;
    }
    .phone-mode .hex-icon {
        width: 78px !important;
        height: 78px !important;
        border-radius: 18px !important;
    }
    .phone-mode .hex-icon img {
        width: 42px !important;
        height: 42px !important;
    }
    .phone-mode .label {
        font-size: 11px !important;
        max-width: 86px !important;
    }
}

@media (max-width: 420px) {
    /* Vẫn giữ 4 cột, chỉ thu nhỏ icon một chút */
    .phone-mode .main-content {
        grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
        gap: 12px 6px !important;
        padding: 12px 6px 24px !important;
    }
    .phone-mode .hex-icon {
        width: 70px !important;
        height: 70px !important;
        border-radius: 16px !important;
    }
    .phone-mode .hex-icon img {
        width: 38px !important;
        height: 38px !important;
    }
    .phone-mode .label {
        font-size: 10px !important;
        max-width: 78px !important;
    }
}

/* ========================================= */
/* COMMERCIAL POLISH — SPLASH / TOAST / FOOTER / SEARCH */
/* ========================================= */

/* Splash Screen */
.splash-screen {
    position: fixed; inset: 0; z-index: 99999;
    background: #000;
    display: flex; align-items: center; justify-content: center;
    transition: opacity 0.6s ease, visibility 0.6s;
}
.splash-screen.hide {
    opacity: 0; visibility: hidden; pointer-events: none;
}
.splash-content { text-align: center; }
.splash-logo {
    font-size: 64px;
    animation: splashPulse 1.4s ease-in-out infinite;
}
.splash-title {
    font-size: 28px; font-weight: 800; color: var(--primary);
    margin: 12px 0 24px; letter-spacing: 1px;
    text-shadow: 0 0 30px var(--glow);
}
.splash-bar {
    width: 180px; height: 4px; background: #222;
    border-radius: 4px; margin: 0 auto 16px; overflow: hidden;
}
.splash-bar-fill {
    height: 100%; width: 0%; background: linear-gradient(90deg, var(--primary), #00ff88);
    border-radius: 4px; animation: splashLoad 1.8s ease-out forwards;
}
.splash-text { color: #666; font-size: 13px; }
@keyframes splashPulse {
    0%, 100% { transform: scale(1); filter: drop-shadow(0 0 10px rgba(0,212,255,0.3)); }
    50% { transform: scale(1.08); filter: drop-shadow(0 0 25px rgba(0,212,255,0.6)); }
}
@keyframes splashLoad {
    0% { width: 0%; }
    100% { width: 100%; }
}

/* Phone Search Bar */
.phone-search-bar {
    display: none;
    position: sticky; top: 0; z-index: 90;
    padding: 12px 16px 8px;
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(12px);
}
.phone-mode .phone-search-bar { display: block; }
.phone-search-bar input {
    width: 100%; padding: 12px 16px;
    background: #111; border: 1px solid var(--border);
    border-radius: 14px; color: white; font-size: 14px;
    outline: none; transition: border-color 0.2s;
}
.phone-search-bar input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0,212,255,0.15);
}
.phone-search-bar input::placeholder { color: #666; }

/* Hidden when filtered */
.floating-item.search-hidden { display: none !important; }

/* Toast */
.toast {
    position: fixed; bottom: 80px; left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(15,15,20,0.95);
    border: 1px solid var(--primary);
    color: white; padding: 12px 24px;
    border-radius: 30px; font-size: 13px; font-weight: 500;
    z-index: 20000; opacity: 0; pointer-events: none;
    transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 8px 30px rgba(0,212,255,0.2);
    max-width: 90%; text-align: center;
    backdrop-filter: blur(10px);
}
.toast.show {
    opacity: 1; transform: translateX(-50%) translateY(0);
}

/* Footer */
.site-footer {
    flex-shrink: 0;
    background: #000;
    border-top: 1px solid var(--border);
    padding: 8px 16px;
    z-index: 100;
}
.footer-links {
    display: flex; align-items: center; justify-content: center;
    gap: 10px; flex-wrap: wrap;
    font-size: 12px; color: #555;
}
.footer-links a {
    color: #777; text-decoration: none; transition: color 0.2s;
}
.footer-links a:hover { color: var(--primary); }
.footer-copy { color: #444; }

/* Onboarding tip */
.onboard-tip {
    position: fixed; bottom: 100px; left: 50%;
    transform: translateX(-50%);
    z-index: 15000; max-width: 420px; width: 90%;
    display: none;
}
.onboard-tip.show { display: block; animation: tipIn 0.4s ease; }
.onboard-content {
    background: rgba(10,15,25,0.95);
    border: 1px solid var(--primary);
    border-radius: 14px; padding: 14px 40px 14px 16px;
    font-size: 13px; color: #ccc;
    box-shadow: 0 10px 40px rgba(0,212,255,0.15);
    position: relative;
    backdrop-filter: blur(12px);
}
.onboard-close {
    position: absolute; top: 8px; right: 10px;
    background: none; border: none; color: #888;
    font-size: 16px; cursor: pointer; padding: 4px;
}
.onboard-close:hover { color: white; }
@keyframes tipIn {
    from { opacity: 0; transform: translateX(-50%) translateY(12px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* User button */
.user-btn {
    background: rgba(0,212,255,0.12) !important;
    border-color: rgba(0,212,255,0.35) !important;
}
.user-btn.logged-in {
    background: rgba(0,255,136,0.12) !important;
    border-color: rgba(0,255,136,0.4) !important;
}

/* Modal polish */
.modal-desc { color: var(--text-muted); margin-bottom: 20px; font-size: 14px; }
.btn-text {
    background: transparent; border: none; color: #888;
    margin-top: 14px; cursor: pointer; font-size: 13px;
}
.btn-text:hover { color: white; }

/* Focus states for accessibility */
.control-btn:focus-visible,
.lang-btn:focus-visible,
.floating-item:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Phone mode adjustments for new elements */
.phone-mode .site-footer { display: none; }
.phone-mode .bottom-marquee { display: none; }
.phone-mode .main-content {
    height: calc(100vh - 60px - 56px) !important;
    max-height: calc(100dvh - 60px - 56px) !important;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .sun-chiri, .splash-logo, .floating-item { animation: none !important; }
    * { transition-duration: 0.01ms !important; }
}

/* ========================================= */
/* VISUAL POLISH v2 — Premium look           */
/* ========================================= */

/* Richer ambient background */
body::before {
    content: '';
    position: fixed; inset: 0; z-index: 0; pointer-events: none;
    background:
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(0, 100, 180, 0.15), transparent),
        radial-gradient(ellipse 60% 40% at 80% 80%, rgba(120, 40, 180, 0.08), transparent),
        radial-gradient(ellipse 50% 30% at 10% 60%, rgba(0, 180, 120, 0.06), transparent);
}

/* Navbar glass upgrade */
.navbar {
    background: rgba(0, 0, 0, 0.72) !important;
    backdrop-filter: blur(16px) saturate(1.4) !important;
    border-bottom: 1px solid rgba(0, 212, 255, 0.12) !important;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.4);
}
.navbar.scrolled {
    background: rgba(0, 0, 0, 0.9) !important;
    box-shadow: 0 4px 40px rgba(0, 212, 255, 0.08);
}

/* Logo pulse subtle */
.navbar .logo {
    transition: text-shadow 0.3s;
}
.navbar .logo:hover {
    text-shadow: 0 0 20px var(--primary), 0 0 40px rgba(0, 212, 255, 0.4);
}

/* Sun richer glow */
.sun-chiri {
    background: radial-gradient(circle, rgba(255, 220, 80, 0.5) 0%, rgba(255, 140, 0, 0.15) 40%, transparent 70%) !important;
    box-shadow: 0 0 120px rgba(255, 200, 50, 0.45), 0 0 60px rgba(255, 150, 0, 0.3) !important;
}
.sun-chiri img {
    filter: drop-shadow(0 0 30px #ffcc00) drop-shadow(0 0 10px #ffaa00) !important;
}

/* Floating items — premium hover */
.floating-item {
    transition: filter 0.3s, opacity 0.3s !important;
}
.floating-item .hex-icon {
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.3s, box-shadow 0.3s !important;
}
.floating-item:hover .hex-icon {
    transform: scale(1.12) translateY(-4px);
}
.floating-item .label {
    transition: all 0.25s ease !important;
}

/* Phone mode — staggered entrance */
.phone-mode .floating-item {
    animation: phoneItemIn 0.45s ease backwards;
}
.phone-mode .floating-item:nth-child(1) { animation-delay: 0.03s; }
.phone-mode .floating-item:nth-child(2) { animation-delay: 0.06s; }
.phone-mode .floating-item:nth-child(3) { animation-delay: 0.09s; }
.phone-mode .floating-item:nth-child(4) { animation-delay: 0.12s; }
.phone-mode .floating-item:nth-child(5) { animation-delay: 0.15s; }
.phone-mode .floating-item:nth-child(6) { animation-delay: 0.18s; }
.phone-mode .floating-item:nth-child(7) { animation-delay: 0.21s; }
.phone-mode .floating-item:nth-child(8) { animation-delay: 0.24s; }
.phone-mode .floating-item:nth-child(9) { animation-delay: 0.27s; }
.phone-mode .floating-item:nth-child(10) { animation-delay: 0.30s; }
.phone-mode .floating-item:nth-child(11) { animation-delay: 0.33s; }
.phone-mode .floating-item:nth-child(12) { animation-delay: 0.36s; }
.phone-mode .floating-item:nth-child(n+13) { animation-delay: 0.40s; }

@keyframes phoneItemIn {
    from { opacity: 0; transform: translateY(16px) scale(0.9); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Feature tooltip (desktop) */
.feature-tooltip {
    position: fixed; z-index: 5000;
    background: rgba(10, 12, 20, 0.95);
    border: 1px solid rgba(0, 212, 255, 0.35);
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 12px; color: #ddd;
    max-width: 220px;
    pointer-events: none;
    opacity: 0; transform: translateY(6px);
    transition: opacity 0.2s, transform 0.2s;
    backdrop-filter: blur(12px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}
.feature-tooltip.show {
    opacity: 1; transform: translateY(0);
}
.feature-tooltip b {
    color: var(--primary); display: block; margin-bottom: 4px; font-size: 13px;
}

/* Category header in phone mode */
.phone-category-header {
    grid-column: 1 / -1;
    font-size: 11px; font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    padding: 16px 4px 6px;
    border-bottom: 1px solid rgba(0, 212, 255, 0.15);
    margin-bottom: 4px;
    opacity: 0.85;
}

/* Control buttons richer */
.control-btn {
    transition: all 0.25s ease !important;
}
.control-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(0, 212, 255, 0.25);
}
.control-btn:active {
    transform: scale(0.96);
}

/* Mode transition overlay */
.mode-transition-overlay {
    position: fixed; inset: 0; z-index: 8000;
    background: #000;
    opacity: 0; pointer-events: none;
    transition: opacity 0.25s ease;
}
.mode-transition-overlay.active {
    opacity: 0.5; pointer-events: all;
}

/* Settings modal glass */
.settings-modal {
    background: rgba(8, 10, 18, 0.92) !important;
    backdrop-filter: blur(20px) saturate(1.3) !important;
    border: 1px solid rgba(0, 212, 255, 0.25) !important;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 40px rgba(0, 212, 255, 0.1) !important;
}

/* Login modal polish */
.modal-content {
    background: rgba(12, 14, 22, 0.95) !important;
    backdrop-filter: blur(20px) !important;
    border: 1px solid rgba(0, 212, 255, 0.3) !important;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.7), 0 0 50px rgba(0, 212, 255, 0.12) !important;
}
.modal-content input:focus {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.15);
}

/* Marquee subtle gradient fade */
.bottom-marquee {
    mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
}

/* Scrollbar global */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0, 212, 255, 0.3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0, 212, 255, 0.5); }

/* Selection color */
::selection {
    background: rgba(0, 212, 255, 0.35);
    color: white;
}

/* ========================================= */
/* THEMES: dark (default) / light / neon     */
/* ========================================= */
body.theme-light {
    --bg: #f0f2f5;
    --surface: #ffffff;
    --surface-hover: #e8eaed;
    --text-main: #1a1a2e;
    --text-muted: #5f6368;
    --border: #dadce0;
    --glow: rgba(0, 120, 255, 0.25);
    background: var(--bg) !important;
    color: var(--text-main);
}
body.theme-light::before {
    background:
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(0, 120, 255, 0.08), transparent),
        radial-gradient(ellipse 60% 40% at 80% 80%, rgba(100, 60, 180, 0.05), transparent);
}
body.theme-light .navbar {
    background: rgba(255,255,255,0.85) !important;
    border-bottom-color: var(--border) !important;
}
body.theme-light .navbar .logo { color: #0077cc; text-shadow: none; }
body.theme-light .control-btn {
    background: #fff; color: #333; border-color: var(--border);
}
body.theme-light .control-btn:hover { border-color: var(--primary); }
body.theme-light .lang-btn { color: #666; }
body.theme-light .lang-btn.active { background: var(--primary); color: #000; }
body.theme-light .bottom-marquee { background: #e8eaed; }
body.theme-light .bottom-marquee-content { color: #666; }
body.theme-light .site-footer { background: #e8eaed; }
body.theme-light .phone-mode .hex-icon {
    background: linear-gradient(145deg, #fff, #f0f0f0) !important;
    border-color: #ddd !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08) !important;
}
body.theme-light .phone-mode .label { color: #333 !important; text-shadow: none; }
body.theme-light .phone-category-header { color: #0077cc; border-bottom-color: rgba(0,120,255,0.2); }
body.theme-light .settings-modal,
body.theme-light .modal-content {
    background: #fff !important;
    color: #222;
    border-color: #ddd !important;
}
body.theme-light .splash-screen { background: #f0f2f5; }
body.theme-light .splash-title { color: #0077cc; }
body.theme-light #bgCanvas { opacity: 0.35; }

/* Neon theme */
body.theme-neon {
    --primary: #39ff14;
    --glow: rgba(57, 255, 20, 0.4);
    --secondary: #ff00ff;
    --future: #00ffff;
}
body.theme-neon .navbar .logo {
    color: #39ff14;
    text-shadow: 0 0 15px #39ff14, 0 0 30px rgba(57,255,20,0.5);
}
body.theme-neon .lang-btn.active {
    background: #39ff14; color: #000;
}
body.theme-neon .sun-chiri {
    box-shadow: 0 0 100px rgba(57, 255, 20, 0.4) !important;
}
body.theme-neon .floating-item:hover {
    filter: drop-shadow(0 0 20px #39ff14);
}

/* Install button */
.install-btn {
    background: rgba(0, 255, 136, 0.15) !important;
    border-color: rgba(0, 255, 136, 0.4) !important;
    color: #00ff88 !important;
}
.install-btn:hover {
    background: rgba(0, 255, 136, 0.25) !important;
}

/* Category header polish */
.phone-category-header {
    grid-column: 1 / -1 !important;
    font-size: 11px !important;
    font-weight: 700 !important;
    color: var(--primary) !important;
    text-transform: uppercase !important;
    letter-spacing: 1.5px !important;
    padding: 18px 6px 8px !important;
    border-bottom: 1px solid rgba(0, 212, 255, 0.18) !important;
    margin-bottom: 4px !important;
    opacity: 0.9 !important;
}

/* ========================================= */
/* BẢO MẬT GIAO DIỆN — chống copy cơ bản     */
/* ========================================= */
body, .main-content, .navbar, .floating-item, .hex-icon, .label,
.sun-chiri, .bottom-marquee, .site-footer, .splash-screen {
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    user-select: none !important;
    -webkit-touch-callout: none !important;
}

/* Vẫn cho gõ/chọn trong ô nhập */
input, textarea, [contenteditable="true"] {
    -webkit-user-select: text !important;
    user-select: text !important;
    -webkit-touch-callout: default !important;
}

/* Chống kéo ảnh / icon */
img, .hex-icon img, .sun-chiri img, a {
    -webkit-user-drag: none !important;
    user-drag: none !important;
    pointer-events: auto;
}

/* Watermark góc mờ — khó xóa khi chụp màn hình */
.ui-watermark {
    position: fixed;
    bottom: 48px;
    right: 12px;
    z-index: 50;
    font-size: 11px;
    color: rgba(0, 212, 255, 0.22);
    font-weight: 600;
    letter-spacing: 1px;
    pointer-events: none;
    user-select: none;
    text-shadow: 0 0 8px rgba(0,0,0,0.5);
}

/* PWA standalone: ẩn thanh thừa, full màn hình */
@media all and (display-mode: standalone) {
    .install-btn { display: none !important; }
    body { overscroll-behavior: none; }
}

/* Safe area cho notch / home indicator khi cài app */
body {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
}

/* ========================================= */
/* VŨ TRỤ TRÊN ĐIỆN THOẠI: thanh menu nhóm (Chat, Dịch Vụ, …) cuộn ngang, bấm để mở */
/* ========================================= */
@media (max-width: 768px) {
    body:not(.phone-mode) .navbar { gap: 8px; }
    body:not(.phone-mode) .navbar-left { display: contents; }
    body:not(.phone-mode) .navbar .logo { order: 0; align-self: flex-start; }
    body:not(.phone-mode) .navbar-right { order: 1; }
    body:not(.phone-mode) .top-menu-bar {
        display: flex; order: 2; align-self: stretch; width: 100%; max-width: 100%; height: auto; gap: 4px; padding: 2px 0 4px;
        overflow-x: auto; overflow-y: hidden; scrollbar-width: none; -webkit-overflow-scrolling: touch;
    }
    body:not(.phone-mode) .top-menu-bar::-webkit-scrollbar { display: none; }
    body:not(.phone-mode) .menu-group { height: auto; flex: none; }
    body:not(.phone-mode) .menu-group-title { padding: 9px 14px; min-height: 40px; display: flex; align-items: center; white-space: nowrap; font-size: 14px; -webkit-tap-highlight-color: transparent; }
    /* cảm ứng không có hover: chỉ mở khi bấm (.active) */
    body:not(.phone-mode) .menu-group:hover .menu-dropdown { display: none; opacity: 0; }
    body:not(.phone-mode) .menu-group.active .menu-dropdown {
        display: flex; opacity: 1; position: fixed; left: 10px; right: 10px; top: var(--dd-top, 150px); margin-top: 0;
        min-width: 0; max-height: calc(100dvh - var(--dd-top, 150px) - 20px); overflow-y: auto; z-index: 300; padding: 8px;
    }
    body:not(.phone-mode) .menu-group:hover:not(.active) .menu-group-title { color: var(--text-muted); background: none; }
    body:not(.phone-mode) .menu-item { min-height: 46px; font-size: 15px; padding: 10px 14px; }
    body:not(.phone-mode) .menu-item img { width: 26px; height: 26px; }
}
