/* ==========================================================
   MENU CHÍNH (MAIN MENU SCREEN) & NÚT ĐIỆN THOẠI NỔI
   ========================================================== */

/* 1. MÀN HÌNH MENU CHÍNH OVERLAY */
.main-menu-overlay {
    position: fixed;
    inset: 0;
    z-index: 9990;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #080402;
    background-image: 
        radial-gradient(circle at 50% 45%, #251307 0%, #120904 45%, #050201 100%),
        radial-gradient(rgba(245, 208, 97, 0.08) 1.2px, transparent 1.2px);
    background-size: 100% 100%, 26px 26px;
    overflow: hidden;
    transition: opacity 0.45s cubic-bezier(0.2, 0.75, 0.25, 1), transform 0.45s ease;
}

.main-menu-overlay.fade-out {
    opacity: 0;
    transform: scale(1.05);
    pointer-events: none;
}

/* 2. CÁC VẬT THỂ TRANG TRÍ CASINO 2D (CSS/SVG FLOAT) */
.menu-decorations {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.decor-item {
    position: absolute;
    filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.8));
    will-change: transform;
}

/* XÚC XẮC LƠ LỬNG */
.decor-dice-wrap {
    width: 52px;
    height: 52px;
    background: linear-gradient(145deg, #ffffff, #e6d3ad);
    border: 2px solid #f5d061;
    border-radius: 12px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    padding: 6px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.8), inset 0 2px 4px rgba(255,255,255,0.9);
}

.dice-pip {
    width: 8px;
    height: 8px;
    background: #1a1a1a;
    border-radius: 50%;
    margin: auto;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.6);
}
.dice-pip.red { background: #dc2626; }

.decor-dice-1 {
    top: 12%;
    left: 8%;
    animation: floatBob1 6s ease-in-out infinite, diceSlowSpin 14s linear infinite;
}
.decor-dice-2 {
    bottom: 14%;
    right: 8%;
    animation: floatBob2 7s ease-in-out infinite, diceSlowSpinRev 16s linear infinite;
}
.decor-dice-3 {
    top: 22%;
    right: 14%;
    transform: scale(0.85);
    animation: floatBob3 8s ease-in-out infinite;
}

/* QUÂN BÀI TÂY (A♠, K♥, Q♦, J♣) */
.decor-card {
    width: 68px;
    height: 98px;
    background: linear-gradient(160deg, #fffdfa 0%, #f4ede1 100%);
    border: 2px solid #e2c070;
    border-radius: 8px;
    padding: 5px 6px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: 0 12px 30px rgba(0,0,0,0.85), inset 0 1px 2px rgba(255,255,255,0.9);
}
.decor-card .card-corner {
    font-size: 11px;
    font-weight: 900;
    line-height: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.decor-card .card-corner.bottom { transform: rotate(180deg); }
.decor-card .card-center {
    margin: auto;
    font-size: 24px;
}
.decor-card.red-suit { color: #dc2626; border-color: #f87171; }
.decor-card.black-suit { color: #171717; border-color: #d4af37; }

.decor-card-ace {
    bottom: 22%;
    left: 6%;
    transform: rotate(-18deg);
    animation: floatBob2 7.5s ease-in-out infinite;
}
.decor-card-king {
    top: 15%;
    left: 20%;
    transform: rotate(14deg);
    animation: floatBob1 6.5s ease-in-out infinite;
}
.decor-card-queen {
    bottom: 18%;
    right: 18%;
    transform: rotate(20deg);
    animation: floatBob3 8.5s ease-in-out infinite;
}
.decor-card-jack {
    top: 28%;
    right: 6%;
    transform: rotate(-12deg);
    animation: floatBob1 7s ease-in-out infinite;
}

/* ĐỒNG CHIP CASINO (1K, 10K, 100K, 500K) */
.decor-chip {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 3px dashed rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 11px;
    color: #fff;
    box-shadow: 0 8px 24px rgba(0,0,0,0.85), inset 0 0 10px rgba(0,0,0,0.5);
}
.decor-chip.chip-1k { background: radial-gradient(circle, #475569, #1e293b); top: 38%; left: 4%; animation: floatBob3 6.8s infinite ease-in-out; }
.decor-chip.chip-10k { background: radial-gradient(circle, #2563eb, #1e3a8a); bottom: 10%; left: 24%; animation: floatBob1 8s infinite ease-in-out; }
.decor-chip.chip-100k { background: radial-gradient(circle, #059669, #064e3b); top: 10%; right: 26%; animation: floatBob2 7.2s infinite ease-in-out; }
.decor-chip.chip-500k { background: radial-gradient(circle, #7c3aed, #4c1d95); bottom: 28%; right: 5%; animation: floatBob1 7.8s infinite ease-in-out; }

/* ĐỒNG TIỀN VÀNG MAY MẮN (GOLD COINS) */
.decor-coin {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #fff5c0, #f5d061 50%, #b8860b 85%);
    border: 2px solid #ffe694;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #5c3c0a;
    font-weight: 950;
    font-size: 14px;
    box-shadow: 0 0 14px rgba(245, 208, 97, 0.6), inset 0 2px 4px rgba(255,255,255,0.8);
}
.decor-coin-1 { top: 48%; left: 16%; animation: floatBob1 5.5s infinite ease-in-out, coinTwinkle 3s infinite alternate; }
.decor-coin-2 { bottom: 35%; left: 12%; animation: floatBob3 6.2s infinite ease-in-out, coinTwinkle 2.5s infinite alternate; }
.decor-coin-3 { top: 44%; right: 15%; animation: floatBob2 5.8s infinite ease-in-out, coinTwinkle 3.2s infinite alternate; }
.decor-coin-4 { bottom: 8%; right: 28%; animation: floatBob1 7s infinite ease-in-out, coinTwinkle 2.8s infinite alternate; }

/* KEYFRAMES CHUYỂN ĐỘNG FLOAT */
@keyframes floatBob1 {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-16px) rotate(4deg); }
}
@keyframes floatBob2 {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-20px) rotate(-5deg); }
}
@keyframes floatBob3 {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-14px) rotate(3deg); }
}
@keyframes diceSlowSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
@keyframes diceSlowSpinRev {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(-360deg); }
}
@keyframes coinTwinkle {
    0% { filter: drop-shadow(0 0 10px rgba(245,208,97,0.4)); }
    100% { filter: drop-shadow(0 0 22px rgba(255,235,140,0.9)); }
}

/* 3. KHỐI TRUNG TÂM MENU */
.menu-content-box {
    position: relative;
    z-index: 10;
    max-width: 480px;
    width: 90%;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: clamp(16px, 3vw, 28px);
    background: radial-gradient(circle at center, rgba(35, 20, 10, 0.78), rgba(12, 7, 4, 0.94));
    border: 2px solid rgba(212, 175, 55, 0.55);
    border-radius: 28px;
    box-shadow: 
        0 25px 70px rgba(0, 0, 0, 0.96),
        0 0 40px rgba(212, 175, 55, 0.18),
        inset 0 1px 3px rgba(255, 235, 170, 0.3);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.menu-title-wrap {
    margin-bottom: 20px;
}

.menu-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 12px;
    background: linear-gradient(90deg, rgba(82, 59, 20, 0.8), rgba(22, 18, 12, 0.9));
    border: 1px solid rgba(245, 208, 97, 0.6);
    border-radius: 999px;
    font-size: 10px;
    font-weight: 800;
    color: #fce49b;
    letter-spacing: 1.5px;
    margin-bottom: 8px;
    box-shadow: 0 0 14px rgba(212, 175, 55, 0.25);
}

.menu-main-title {
    font-size: clamp(28px, 6vw, 44px);
    font-weight: 950;
    line-height: 1.1;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    background: linear-gradient(180deg, #ffffff 0%, #fff0a8 28%, #f5d061 58%, #b8860b 85%, #64450a 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 4px 18px rgba(212, 175, 55, 0.65)) drop-shadow(0 2px 6px rgba(0, 0, 0, 0.9));
    margin: 0;
}

.menu-sub-title {
    margin-top: 6px;
    font-size: clamp(9px, 1.8vw, 11px);
    font-weight: 800;
    color: #d1b87d;
    letter-spacing: 2px;
    text-transform: uppercase;
    opacity: 0.9;
}

/* 4. CÁC NÚT BẤM MENU XẾP DỌC */
.menu-buttons-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    max-width: 360px;
}

.menu-btn {
    position: relative;
    width: 100%;
    min-height: 52px;
    padding: 8px 16px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    text-align: left;
    transition: transform 180ms ease, box-shadow 220ms ease, filter 180ms ease;
    cursor: pointer;
    touch-action: manipulation;
}
.menu-btn:hover:not(:disabled):not(.disabled) {
    transform: translateY(-2px) scale(1.02);
    filter: brightness(1.1);
}
.menu-btn:active:not(:disabled):not(.disabled) {
    transform: translateY(1px) scale(0.98);
}

.menu-btn .btn-icon-wrap {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.menu-btn .btn-text-wrap {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.menu-btn .btn-main-label {
    font-size: 14px;
    font-weight: 900;
    letter-spacing: 0.8px;
    text-transform: uppercase;
}

.menu-btn .btn-sub-label {
    font-size: 10px;
    opacity: 0.82;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Nút CHƠI GAME (Lớn nhất, nổi bật trung tâm) */
.menu-btn-play {
    background: linear-gradient(135deg, #3d1c06 0%, #78350f 50%, #b45309 100%);
    border: 2px solid #f59e0b;
    color: #fef3c7;
    min-height: 58px;
    box-shadow: 0 10px 32px rgba(245, 158, 11, 0.45), inset 0 1px 3px rgba(255,255,255,0.4);
}
.menu-btn-play .btn-icon-wrap {
    width: 40px;
    height: 40px;
    font-size: 18px;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #000;
    box-shadow: 0 0 14px rgba(245, 158, 11, 0.7);
}
.menu-btn-play .btn-main-label {
    font-size: 16px;
    font-weight: 900;
    letter-spacing: 1.2px;
}
.menu-btn-play.pulse-glow {
    animation: menuPulseGold 2.2s infinite ease-in-out;
}

/* Nút ĐĂNG XUẤT (Trên Menu chính khi đã đăng nhập) */
.menu-btn-logout {
    background: linear-gradient(135deg, #251217 0%, #170a0e 100%);
    border: 1px solid #f43f5e;
    color: #fecdd3;
    box-shadow: 0 6px 16px rgba(244, 63, 94, 0.25);
}
.menu-btn-logout .btn-icon-wrap {
    background: linear-gradient(135deg, #f43f5e, #be123c);
    color: #fff;
    box-shadow: 0 0 8px rgba(244, 63, 94, 0.5);
}

/* Nút LOAD GAME (Sáng khi có dữ liệu) */
.menu-btn-load {
    background: linear-gradient(135deg, #2a1a08 0%, #170e04 100%);
    border: 2px solid #f5d061;
    color: #ffe894;
    box-shadow: 0 8px 24px rgba(245, 208, 97, 0.25), inset 0 1px 2px rgba(255,255,255,0.3);
}
.menu-btn-load .btn-icon-wrap {
    background: linear-gradient(135deg, #d4af37, #855e17);
    color: #000;
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.6);
}
.menu-btn-load.pulse-glow {
    animation: menuPulseGold 2.2s infinite ease-in-out;
}
@keyframes menuPulseGold {
    0%, 100% { box-shadow: 0 0 15px rgba(245, 208, 97, 0.3), inset 0 1px 2px rgba(255,255,255,0.3); }
    50% { box-shadow: 0 0 28px rgba(245, 208, 97, 0.65), inset 0 1px 4px rgba(255,255,255,0.6); }
}

/* Nút VÀO GAME (Start Game) */
.menu-btn-start {
    background: linear-gradient(135deg, #b91c1c 0%, #7f1d1d 60%, #450a0a 100%);
    border: 2px solid #ef4444;
    color: #fff;
    box-shadow: 0 8px 24px rgba(239, 68, 68, 0.35), inset 0 1px 2px rgba(255,255,255,0.3);
}
.menu-btn-start .btn-icon-wrap {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #000;
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.6);
}
.menu-btn-start.pulse-glow {
    animation: menuPulseRed 2.2s infinite ease-in-out;
}
@keyframes menuPulseRed {
    0%, 100% { box-shadow: 0 0 15px rgba(239, 68, 68, 0.35); }
    50% { box-shadow: 0 0 28px rgba(239, 68, 68, 0.75); }
}

/* Nút RESTART GAME */
.menu-btn-restart {
    background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
    border: 1px solid #4b5563;
    color: #d1d5db;
    box-shadow: 0 6px 16px rgba(0,0,0,0.4);
}
.menu-btn-restart .btn-icon-wrap {
    background: #374151;
    color: #9ca3af;
}

/* Nút ỦNG HỘ ADMIN */
.menu-btn-donate {
    background: linear-gradient(135deg, #2d131f 0%, #1a0a12 100%);
    border: 1px solid #db2777;
    color: #fbcfe8;
    box-shadow: 0 6px 18px rgba(219, 39, 119, 0.25);
}
.menu-btn-donate .btn-icon-wrap {
    background: linear-gradient(135deg, #ec4899, #be185d);
    color: #fff;
    box-shadow: 0 0 8px rgba(236, 72, 153, 0.5);
}

.menu-footer-note {
    margin-top: 14px;
    font-size: 9px;
    color: #78716c;
    letter-spacing: 0.5px;
}

/* 5. MODAL HỘP THOẠI TRONG MENU (CONFIRM & DONATE) */
.menu-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 9995;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: fadeInModal 0.2s ease both;
}
@keyframes fadeInModal {
    from { opacity: 0; }
    to { opacity: 1; }
}

.menu-modal-card {
    background: #18110b;
    border: 2px solid #d4af37;
    border-radius: 24px;
    width: 100%;
    max-width: 420px;
    padding: 22px;
    box-shadow: 0 25px 60px rgba(0,0,0,0.95), 0 0 30px rgba(212, 175, 55, 0.25);
    color: #fff;
    text-align: center;
    animation: zoomInCard 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes zoomInCard {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-icon-header {
    font-size: 42px;
    margin-bottom: 8px;
}
.modal-title {
    font-size: 16px;
    font-weight: 900;
    color: #f5d061;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-bottom: 6px;
}
.modal-desc {
    font-size: 12px;
    color: #d1d5db;
    line-height: 1.5;
    margin-bottom: 18px;
}

.modal-actions {
    display: flex;
    gap: 10px;
}
.modal-btn-cancel {
    flex: 1;
    min-height: 42px;
    background: #262626;
    border: 1px solid #404040;
    border-radius: 12px;
    color: #a3a3a3;
    font-weight: 800;
    font-size: 12px;
}
.modal-btn-confirm {
    flex: 1;
    min-height: 42px;
    background: linear-gradient(135deg, #dc2626, #991b1b);
    border: 1px solid #ef4444;
    border-radius: 12px;
    color: #fff;
    font-weight: 900;
    font-size: 12px;
    box-shadow: 0 0 14px rgba(220, 38, 38, 0.4);
}

/* MODAL DONATE RIÊNG */
.donate-card {
    text-align: left;
    max-width: 450px;
}
.donate-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(212, 175, 55, 0.25);
    border-radius: 12px;
    gap: 8px;
}
.donate-label-wrap {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.donate-tag {
    font-size: 8px;
    font-weight: 800;
    color: #a8a29e;
    letter-spacing: 0.8px;
}
.donate-val {
    font-size: 13px;
    color: #fff;
    word-break: break-all;
}
.donate-copy-btn {
    padding: 6px 12px;
    background: linear-gradient(135deg, #78521c, #452d0a);
    border: 1px solid #f5d061;
    border-radius: 8px;
    color: #fce49b;
    font-size: 11px;
    font-weight: 800;
    white-space: nowrap;
    transition: all 0.2s ease;
}
.donate-copy-btn:hover {
    background: linear-gradient(135deg, #a16e25, #63400e);
    box-shadow: 0 0 10px rgba(245, 208, 97, 0.4);
}
.donate-copy-btn.copied {
    background: #065f46 !important;
    border-color: #34d399 !important;
    color: #a7f3d0 !important;
}

/* 6. NÚT ĐIỆN THOẠI NỔI DRAG & DROP */
#floatingPhoneBtn {
    touch-action: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
    transition: filter 0.2s, transform 260ms cubic-bezier(0.34, 1.56, 0.64, 1);
    filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.42));
}

#floatingPhoneBtn button {
    border-radius: 24px;
    box-shadow: 0 8px 26px rgba(212, 175, 55, 0.24);
}

#floatingPhoneBtn:not(.dragging) button:hover {
    box-shadow: 0 10px 30px rgba(245, 208, 97, 0.4);
}

#floatingPhoneBtn.dragging {
    filter: drop-shadow(0 0 12px rgba(251, 191, 36, 0.9));
}

#floatingPhoneBtn.dragging button {
    transform: scale(1.08);
    cursor: grabbing !important;
}

#floatingPhoneBtn.dragging button > div {
    pointer-events: none;
}

#floatingPhoneBtn.snapping {
    transition: left 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), top 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* TỐI ƯU MENU TRÊN MOBILE LANDSCAPE (CHIỀU CAO <= 500PX) */
@media (max-height: 500px) {
    .menu-content-box {
        padding: 10px 16px;
        max-width: 440px;
    }
    .menu-title-wrap {
        margin-bottom: 8px;
    }
    .menu-badge {
        padding: 2px 8px;
        font-size: 8px;
        margin-bottom: 4px;
    }
    .menu-main-title {
        font-size: 24px;
    }
    .menu-sub-title {
        font-size: 8px;
        margin-top: 2px;
    }
    .menu-buttons-list {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 6px;
        max-width: 420px;
    }
    .menu-btn {
        min-height: 40px;
        padding: 4px 10px;
        gap: 8px;
        border-radius: 12px;
    }
    .menu-btn .btn-icon-wrap {
        width: 28px;
        height: 28px;
        font-size: 13px;
    }
    .menu-btn .btn-main-label {
        font-size: 11px;
    }
    .menu-btn .btn-sub-label {
        font-size: 8px;
    }
    .menu-footer-note {
        margin-top: 6px;
        font-size: 8px;
    }

    /* Thu nhỏ các vật thể trang trí trên màn hình thấp */
    .decor-dice-wrap { width: 36px; height: 36px; }
    .dice-pip { width: 5px; height: 5px; }
    .decor-card { width: 48px; height: 70px; }
    .decor-card .card-center { font-size: 16px; }
    .decor-chip { width: 36px; height: 36px; font-size: 8px; }
    .decor-coin { width: 24px; height: 24px; font-size: 10px; }
}
