/* =========================================
   1. BASE RESET & TYPOGRAPHY
   ========================================= */
* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
    font-family: 'Arial', sans-serif; 
}

body { 
    background-color: #121212; 
    color: #fff; 
    min-height: 100vh; 
    overflow-x: hidden; 
}

.hidden { display: none !important; }
h2, h3 { letter-spacing: 1px; }

/* =========================================
   2. AUTH & PRIVACY SECTIONS
   ========================================= */
#auth-section { 
    width: 90%; 
    max-width: 400px; 
    margin: 10vh auto; 
    background: #1e1e1e; 
    padding: 30px; 
    border-radius: 12px; 
    text-align: center; 
    border: 1px solid #333; 
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    margin-bottom: 80px;
}

input { 
    width: 100%; 
    padding: 15px; 
    margin: 10px 0; 
    border-radius: 8px; 
    border: 1px solid #444; 
    background: #2a2a2a; 
    color: white; 
    font-size: 16px; 
}

input:focus {
    outline: 2px solid #27ae60;
    background-color: #333;
}

.link { display: block; margin-top: 15px; color: #3498db; cursor: pointer; }

.intro-box {
    margin-top: 25px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.03); 
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    text-align: left; 

    /* --- THE FIXES --- */
    height: auto !important;      /* Allow it to grow as long as the text is */
    max-height: none !important;  /* Remove any height caps */
    overflow: visible !important; /* Ensure no text is clipped */
    margin-bottom: 40px;          /* Add space so it doesn't touch the footer */
}

.intro-box h3 { color: #f1c40f; margin-bottom: 2px; }
.intro-box p { font-size: 0.9rem; line-height: 1.5; color: #ccc; margin-bottom: 2px; }
.intro-box ul { margin: 15px; margin-bottom: 2px; padding-left: 20px; color: #eee; font-size: 0.85rem; }
.signup-hook { font-style: italic; color: #2ecc71 !important; margin-top: 10px; }

#privacy-section {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10000; /* CRITICAL: Must be higher than your footer's 9999 */
    
    width: 90%;
    max-width: 800px;
    max-height: 85vh; /* Prevents the box from getting taller than the screen */
    overflow-y: auto; /* Adds a scrollbar inside the box if the policy is really long */
    
    padding: 30px;
    background: #1a1a1a; /* Made solid so the game table doesn't bleed through */
    border: 1px solid #f1c40f; /* Gives it a nice frame */
    border-radius: 15px;
    color: #eee;
    text-align: left;
    
    /* 🎯 MAGIC TRICK: This massive box-shadow creates a dark, semi-transparent backdrop over the whole screen without needing an extra HTML wrapper */
    box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.85); 
}

.policy-content h3 { color: #f1c40f; margin-top: 20px; }
.policy-content p { font-size: 0.95rem; line-height: 1.6; color: #ccc; }
.back-btn { background: none; border: 1px solid #f1c40f; color: #f1c40f; padding: 5px 15px; cursor: pointer; margin-bottom: 20px; border-radius: 5px; }


/* =========================================
   3. DESKTOP MAIN LAYOUT - FIXED NO-WRAP
   ========================================= */
.main-layout {
    display: flex;
    flex-direction: row; 
    flex-wrap: nowrap; /* 🚨 CRITICAL: Prevents sidebar from ever dropping below */
    align-items: flex-start; 
    gap: 20px;
    padding: 20px;
    padding-bottom: 100px; 
    width: 100%;
    max-width: 100vw;
    min-height: 100vh; 
}
/* 1. ALLOW INTERNAL SCROLLING */
.game-area { 
    flex: 3; 
    min-width: 0;
    background: radial-gradient(circle, #0a6c38 0%, #054020 100%); 
    border: 8px solid #402103; 
    border-radius: 20px; 
    
    /* THE FIX: Extra bottom padding (80px) ensures the last buttons 
       don't get stuck behind the wood border or footer when scrolling */
    padding: min(20px, 2vh) min(20px, 2vh) 80px min(20px, 2vh); 
    
    box-shadow: inset 0 0 50px rgba(0,0,0,0.5), 0 10px 30px rgba(0,0,0,0.5);
    
    display: flex;
    flex-direction: column;
    
    /* THE FIX: Start from the top so scrolling feels natural */
    justify-content: flex-start; 
    gap: 15px; 

    height: calc(100vh - 45px); 
    
    /* THE FIX: Enable vertical scrolling but hide horizontal */
    overflow-y: auto; 
    overflow-x: hidden;
}

/* Optional: Make the scrollbar look like it belongs in a casino (Dark/Slim) */
.game-area::-webkit-scrollbar {
    width: 8px;
}

.game-area::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
}

.game-area::-webkit-scrollbar-thumb {
    background: rgba(255, 215, 0, 0.3); /* Subtle Gold scrollbar */
    border-radius: 10px;
}

.game-area::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 215, 0, 0.5);
}

#side-panel {
    flex: 1; 
    flex-shrink: 0; /* 🚨 Prevents sidebar from getting squashed */
    flex-basis: 300px; /* Gives it a solid starting width */
    display: flex;
    flex-direction: column;
    background: #1a1a1a;
    padding: 20px;
    border-radius: 20px;
    border: 1px solid #333;
    /* Ensure the panel doesn't get taller than the screen if content is long */
    position: sticky;
    top: 20px;
}

/* =========================================
   4. GREEN TABLE ELEMENTS
   ========================================= */
/* --- CLEANER TABLE HEADER --- */
.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    /* margin-bottom: 15px; */
    margin-bottom: min(10px, 1vh);
}

.user-info {
    display: flex;
    align-items: center;
    gap: min(12px, 1vh);
}

.player-name-tag {
    color: #ffd700;
    font-weight: bold;
    font-size: min(1rem, 2vh);
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

/* --- THEME TOGGLE STYLING --- */
.theme-toggle-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 5px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.2s ease;
}

.theme-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

/* --- BUTTONS AESTHETICS --- */
.btn-action, .btn-secondary {
    border-radius: 6px;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 0 rgba(0,0,0,0.2); /* 3D effect */
    transition: all 0.1s active;
}

.btn-action:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 rgba(0,0,0,0.2);
}

/* --- SIDE BETS CLEANUP --- */
.side-bets-container {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin: 15px 0;
    background: rgba(0, 0, 0, 0.2);
    padding: 15px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.05);
}

.side-bet {
    background: linear-gradient(145deg, rgba(40,40,40,0.8), rgba(20,20,20,0.8));
    border: 1px solid #444;
    padding: 12px;
    border-radius: 10px;
    min-width: 90px;
    text-align: center;
}

.side-bet label {
    color: #aaa;
    font-size: 0.7rem;
    display: block;
    margin-bottom: 4px;
}

/* --- LIGHT MODE REFINEMENT --- */
body.light-mode .theme-toggle-btn {
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.1);
    color: #333;
}


   .stats-bar { display: flex; justify-content: space-around; background: rgba(0,0,0,0.3); padding: 8px; border-radius: 8px; font-size: 0.9em; margin-bottom: 20px; }

.finance-group { display: flex; align-items: center; gap: 15px; }
.prominent-bet { background: #e67e22; color: white; padding: 8px 15px; border-radius: 20px; font-weight: bold; font-size: 1.1em; box-shadow: 0 4px 10px rgba(230, 126, 34, 0.4); border: 2px solid #d35400; }
.balance-badge { font-weight: bold; font-size: 1.2em; background: rgba(0,0,0,0.4); padding: 8px 15px; border-radius: 8px; }

.dealer-section, .player-section, .stats-bar { margin-bottom: min(10px, 1vh); text-align: center; }
/* .cards { display: flex; gap: 10px; justify-content: center; min-height: 120px; margin-top: 10px; flex-wrap: wrap; } */

/* =========================================
   4.5 THE JUMPING FIX (Add this if it's missing!)
   ========================================= */
/* This reserves the exact amount of vertical space the cards need, 
   so the buttons NEVER shift when cards are dealt. */
.cards {
    min-height: min(115px, 13vh); /* Matches the max height of your cards */
    display: flex; 
    gap: 10px; 
    justify-content: center; 
    flex-wrap: wrap; 
    margin-top: 5px;
}

.card {
    height: min(110px, 12vh); 
    width: min(75px, 8.2vh); 
    font-size: min(1.6rem, 3vh); background: white; color: #1a1a1a; 
    border-radius: 8px; display: flex; align-items: center; justify-content: center; 
    font-weight: bold; box-shadow: 2px 2px 10px rgba(0,0,0,0.3); 
    border: 1px solid #ccc; transition: transform 0.2s;
}
.card.red { color: #e74c3c; }
.card.black { color: #2c3e50; }
.hidden-card { background: repeating-linear-gradient(45deg, #2c3e50, #2c3e50 10px, #34495e 10px, #34495e 20px); color: white !important; border: 2px solid #ecf0f1; }

.card-animate { animation: dealCard 0.4s ease-out forwards; }
@keyframes dealCard {
    0% { opacity: 0; transform: translateY(-150px) translateX(-150px) rotate(15deg); }
    100% { opacity: 1; transform: translateY(0) translateX(0) rotate(0deg); }
}

.table-text {
    text-align: center; color: rgba(255, 255, 255, 0.35); font-size: min(0.85rem, 1.2vh); /* Shrinks text slightly */
    text-transform: uppercase; letter-spacing: 1px; margin: min(15px, 1.5vh) 0 min(10px, 1vh) 0;
    line-height: 1.4; pointer-events: none; 
}
.table-text span { color: rgba(241, 196, 15, 0.45); font-weight: bold; }

.message {
    /* 1. THE FIX: Let the box wrap exactly around the text */
    width: fit-content;
    min-height: 50px; 
    
    /* 2. THE FIX: Balanced padding so the text is centered inside the box */
    padding: 0.5rem 1.5rem;
    margin: 1rem auto; 
    
    /* 3. Typography & Glow */
    font-size: min(18px, 3vh); 
    font-weight: 900; 
    color: #ffd700; 
    text-align: center; 
    text-transform: uppercase; 
    letter-spacing: 2px; 
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.8), 0 0 20px rgba(255, 215, 0, 0.4);
    
    /* 4. Box Aesthetics */
    background: rgba(0, 0, 0, 0.65); 
    border-radius: 12px; 
    border: 2px solid rgba(255, 215, 0, 0.4); 
    
    /* 5. Perfect Centering Tool */
    display: flex;
    align-items: center;
    justify-content: center;

    animation: pulse-message 2s infinite alternate;
}
@keyframes pulse-message {
    0% { box-shadow: 0 0 5px rgba(255, 215, 0, 0.1); transform: scale(1); }
    100% { box-shadow: 0 0 25px rgba(255, 215, 0, 0.5); transform: scale(1.03); }
}

/* =========================================
   4.5 THE JUMPING FIX (Add this if it's missing!)
   ========================================= */
/* This reserves the exact amount of vertical space the cards need, 
   so the buttons NEVER shift when cards are dealt. */
.cards {
    min-height: min(115px, 13vh); /* Matches the max height of your cards */
    display: flex; 
    gap: 10px; 
    justify-content: center; 
    flex-wrap: wrap; 
    margin-top: 5px;
}

/* =========================================
   5. CONTROLS, BETTING & CHIPS
   ========================================= */
.controls { 
    display: flex; 
    justify-content: center; 
    gap: min(10px, 1.5vw); 
    
    /* THE POSITION FIX: This pushes the controls to the bottom, 
       anchoring them directly above the betting area */
    margin-top: auto; 
    margin-bottom: 10px;
    flex-wrap: wrap; 
}

.bet-actions {
    display: flex; 
    justify-content: center; 
    gap: min(10px, 1.5vw); 
    margin-top: min(10px, 1vh); 
    flex-wrap: wrap;
}

button { 
    cursor: pointer; 
    border: none; 
    border-radius: 8px; 
    font-weight: bold; 
    text-transform: uppercase; 
    transition: 0.2s; 
    
    /* THE SCALING FIX: clamp(Min Size, Responsive Size, Max Size) */
    padding: clamp(8px, 1.2vh, 14px) clamp(12px, 2vw, 24px); 
    font-size: clamp(12px, 1.6vh, 16px); 
}

button:disabled { 
    opacity: 0.5; 
    cursor: not-allowed; 
}

.btn-action { 
    background: #2980b9; 
    color: white; 
    flex: 1; 
    max-width: 140px; /* Slightly reduced so they don't get overly wide */
}
.btn-action.deal { background: #27ae60; }
.btn-action.stand { background: #c0392b; }

.btn-secondary { 
    background: #555; 
    color: white; 
    /* Ensures secondary buttons aren't as bulky as primary action buttons */
    padding: clamp(6px, 1vh, 10px) clamp(10px, 1.5vw, 15px);
    font-size: clamp(11px, 1.4vh, 14px);
}

.betting-area { 
    background: rgba(0,0,0,0.4); 
    padding: min(15px, 1.5vh); 
    border-radius: 12px; 
    text-align: center; 
    /* Removed margin-top: auto from here, it's on .controls now */
}

.chips-container { 
    display: flex; 
    justify-content: center; 
    gap: min(12px, 1.5vw); 
    margin-bottom: min(15px, 1.5vh); 
}

.chip {
    width: clamp(45px, 6vh, 60px); 
    height: clamp(45px, 6vh, 60px); 
    font-size: clamp(0.9rem, 1.5vh, 1.1rem); 
    border-radius: 50%; 
    background: #ecf0f1; 
    color: #2c3e50; 
    border: 5px dashed #e74c3c; 
    padding: 0; 
    box-shadow: 0 4px 8px rgba(0,0,0,0.5); 
}
.chip:nth-child(2) { border-color: #3498db; }
.chip:nth-child(3) { border-color: #9b59b6; background: #333; color: white; }

.side-bets-container { 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    gap: min(12px, 1vh); 
    margin: min(10px, 1vh) 0; 
    padding: min(10px, 1vh); 
    flex-wrap: wrap; 
}

.side-bet { 
    background: rgba(0, 0, 0, 0.4); 
    border: 1px solid rgba(255, 255, 255, 0.1); 
    padding: 8px 12px; 
    border-radius: 8px; 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    gap: 4px; 
    min-width: 90px; 
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.5); 
}

.side-bet label { 
    color: #f1c40f; 
    font-size: clamp(0.7rem, 1vh, 0.8rem); 
    text-transform: uppercase; 
    font-weight: bold; 
    letter-spacing: 1px; 
}

.side-bet-amount { 
    font-size: clamp(0.95rem, 1.5vh, 1.1rem); 
    font-weight: bold; 
    color: #fff; 
}

.reload-prominent { 
    background: linear-gradient(135deg, #f1c40f, #f39c12); 
    color: #121212; 
    width: 100%; 
    margin-top: 15px; 
    padding: clamp(10px, 1.5vh, 15px); 
    font-size: clamp(1rem, 1.5vh, 1.2rem); 
    box-shadow: 0 4px 15px rgba(241, 196, 15, 0.4); 
    border: 2px solid #f39c12; 
}

.reload-prominent:hover { 
    transform: translateY(-2px); 
    background: linear-gradient(135deg, #f39c12, #e67e22); 
}
/* =========================================
   6. SIDEBAR ELEMENTS
   ========================================= */
.user-msg-container { margin-bottom: 20px; padding: 15px; background: rgba(52, 152, 219, 0.1); border-left: 4px solid #3498db; border-radius: 4px; text-align: left; }
.welcome-line { margin: 0 0 10px 0; font-size: 1.5rem; font-weight: 800; color: #d9fffb; letter-spacing: -0.5px; line-height: 1.1; }
#pNamePara { display: block; font-weight: 500; line-height: 1.6; word-wrap: break-word; }

.sidebar-middle h3 { border-bottom: 2px solid #333; padding-bottom: 10px; margin-bottom: 10px; text-align: center; }
#leaderboard-list { list-style: none; }
#leaderboard-list li { display: flex; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid #333; font-size: 0.95rem; }
#leaderboard-list li span:last-child { color: #2ecc71; font-weight: bold; }

.logout-container { margin-top: auto; width: 100%; padding-top: 20px; display: flex; justify-content: center; }

/* Hide scrollbar for side panel */
#side-panel::-webkit-scrollbar { display: none; }
#side-panel { -ms-overflow-style: none; scrollbar-width: none; }

/* =========================================
   7. UTILITIES, TOGGLES & METERS
   ========================================= */
.auto-reload-container { display: flex; align-items: center; gap: 10px; margin: 5px 0; padding: 5px; background: rgba(255, 255, 255, 0.05); border-radius: 8px; }
.reload-label { font-size: 0.85rem; color: #ccc; }
.switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #444; transition: .4s; border-radius: 34px; }
.slider:before { position: absolute; content: ""; height: 16px; width: 16px; left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider { background-color: #2ecc71; }
input:checked + .slider:before { transform: translateX(18px); }

.meter-container { width: 100%; margin-top: 5px; margin-bottom: 10px; text-align: left; }
#strength-bar { height: 5px; width: 0%; border-radius: 2px; transition: width 0.3s ease, background-color 0.3s ease; }
#strength-text { font-size: 0.75rem; color: #888; margin-top: 4px; display: block; }
.weak { background-color: #e74c3c; width: 33%; }
.medium { background-color: #f1c40f; width: 66%; }
.strong { background-color: #2ecc71; width: 100%; }

.theme-toggle { position:relative; z-index:999; right: 10px; background: transparent; border: 1px solid #ccc; color: inherit; font-size: 0.8rem; padding: 5px 10px; }

/* =========================================
   8. TOAST NOTIFICATIONS
   ========================================= */
.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast { min-width: 250px; padding: 16px 20px; border-radius: 8px; color: #fff; font-weight: bold; font-size: 1rem; box-shadow: 0 4px 15px rgba(0,0,0,0.4); opacity: 0; transform: translateX(100%); animation: slideInRight 0.4s forwards, fadeOutToast 0.4s forwards 3s; pointer-events: auto; }
.toast.success { background-color: #2ecc71; border-left: 5px solid #27ae60; }
.toast.error { background-color: #e74c3c; border-left: 5px solid #c0392b; }
.toast.info { background-color: #3498db; border-left: 5px solid #2980b9; }

@keyframes slideInRight { to { opacity: 1; transform: translateX(0); } }
@keyframes fadeOutToast { to { opacity: 0; transform: translateY(-10px); } }

/* =========================================
   9. FOOTER
   ========================================= */
.footer-bar { position: fixed; bottom: 0; left: 0; width: 100%; height: 40px; background: #1a1a1a; border-top: 1px solid #333; display: flex; align-items: center; z-index: 9999; font-size: 0.8rem; color: #888; }
.footer-content { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 20px; display: flex; justify-content: space-between; align-items: center; }
.status-online { color: #2ecc71; font-weight: bold; }
.footer-links a, .link1 { color: #888; text-decoration: none; margin-left: 15px; cursor: pointer; transition: color 0.2s; }
.footer-links a:hover, .link1:hover { color: #fff; }

/* =========================================
   10. LIGHT MODE OVERRIDES
   ========================================= */
body.light-mode #privacy-section {
    background: #ffffff;
    color: #2c3e50;
    border-color: #bdc3c7;
    box-shadow: 0 0 0 100vmax rgba(255, 255, 255, 0.75); /* Whitish backdrop */
}
body.light-mode { background-color: #ecf0f1; color: #2c3e50; }
body.light-mode #auth-section, body.light-mode #side-panel { background: #ffffff; border: 1px solid #bdc3c7; box-shadow: 0 10px 20px rgba(0,0,0,0.05); }
body.light-mode input { background: #f8f9fa; border: 1px solid #ccc; color: #2c3e50; }
body.light-mode .game-area { background: radial-gradient(circle, #2ecc71 0%, #27ae60 100%); border-color: #8e44ad; }
body.light-mode .betting-area, body.light-mode .stats-bar { background: rgba(255, 255, 255, 0.2); }
body.light-mode .footer-bar { background: #ffffff; border-top: 1px solid #ccc; color: #555; }
body.light-mode .message { background: rgba(255, 255, 255, 0.9); color: #d35400; border-color: #d35400; text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); animation: pulse-message-light 2s infinite alternate; }
@keyframes pulse-message-light { 0% { box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1); transform: scale(1); } 100% { box-shadow: 0 10px 25px rgba(211, 84, 0, 0.4); transform: scale(1.03); } }
body.light-mode .user-msg-container { border-top: 1px solid #ccc; color: #555; margin-top: 20px; padding: 15px; background: rgba(52, 152, 219, 0.1); border-left: 4px solid #3498db; }
body.light-mode .welcome-line { color: #878787; }
body.light-mode .btn-action.deal { background: #007a08; }
body.light-mode .balance-badge { color: #f9f9f9; }
body.light-mode .reload-label { color: #3f3f3f; }
body.light-mode .intro-box { background: #dcdcdcbe; border: 1px solid rgba(221, 221, 221, 0.692); text-align: center; }
body.light-mode .intro-box p, body.light-mode .intro-box ul { color: #000000; }
body.light-mode .table-text { color: rgba(0, 0, 0, 0.4); }
body.light-mode .table-text span { color: rgba(211, 84, 0, 0.6); }

/* =========================================
   11. MOBILE RESPONSIVENESS
   ========================================= */
@media (max-width: 900px) {
    .main-layout { 
        flex-direction: column; 
        padding: 10px; 
        padding-bottom: 80px; 
    }
    
    .game-area { 
        width: 100%; 
        border-width: 5px; 
        padding: 15px 10px; 
    }
    
    #side-panel { 
        width: 100%; 
        margin-top: 10px; 
    }
    
    .card { width: 55px; height: 80px; font-size: 1.2rem; }
    
    /* Perfect 2x2 Grid for Mobile Game Controls */
    .controls { 
        display: grid; 
        grid-template-columns: 1fr 1fr; 
        gap: 10px; 
        width: 100%;
    }
    
    /* Forces all buttons to be the exact same size inside the grid */
    .controls button { 
        width: 100%; 
        max-width: 100%; 
        margin: 0; 
        padding: 12px 5px; /* Tighter padding */
        font-size: 0.95rem; /* Better text scaling */
    }

    .footer-content { justify-content: center; gap: 15px; padding: 0 10px; }
    .link1, .footer-links a { margin-left: 0 !important; }
    .footer-bar { font-size: 0.75rem; }


    /* 🎯 Shrink the felt text for mobile */
    .table-text {
        font-size: 0.65rem; /* Smaller font */
        margin: 10px 0 5px 0; /* Tighten the spacing */
        line-height: 1.3; /* Bring lines closer together */
        letter-spacing: 0.5px; /* Reduce character spacing */
    }

    .table-text br {
        display: block;
        content: "";
        margin-top: 4px;
    }

}

@media (max-width: 600px) {
    .table-header { flex-direction: column; gap: 10px; align-items: center; }
    .finance-group { width: 100%; justify-content: center; gap: 10px; }
    .prominent-bet, .balance-badge { font-size: 0.95rem; padding: 6px 12px; }
    .message { width: 100%; font-size: 1.3rem; padding: 0.5rem; }
    
    .chips-container { gap: 8px; }
    .chip { width: 50px; height: 50px; font-size: 0.9rem; border-width: 3px; }
    
    .bet-actions { flex-direction: column; gap: 5px; }
    .footer-links { display: none; }
}

@media (max-width: 600px) {
    /* Hide the middle line of the felt text on tiny phones to save space */
    .table-text br:nth-of-type(1),
    .table-text br:nth-of-type(2) {
        display: none;
    }
    
    /* Make the side-bet container even tighter */
    .side-bets-container {
        gap: 8px;
        margin: 10px 0;
    }
    
    .side-bet {
        min-width: 80px;
        padding: 5px 8px;
    }
}

/* Ensures side bet buttons look disabled when the property is set */
.side-bet button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    filter: grayscale(1);
}

.all-in-chip {
    background: #e67e22 !important;
    color: #fff !important;
    border: 5px solid #d35400 !important;
    font-size: 0.9rem !important;
    text-shadow: 0 0 5px rgba(0,0,0,0.5);
    animation: pulse-all-in 1.5s infinite;
}

@keyframes pulse-all-in {
    0% { box-shadow: 0 0 5px rgba(230, 126, 34, 0.5); }
    50% { box-shadow: 0 0 20px rgba(230, 126, 34, 0.8); }
    100% { box-shadow: 0 0 5px rgba(230, 126, 34, 0.5); }
}

/* Mobile tweak to ensure it fits */
@media (max-width: 600px) {
    .all-in-chip {
        font-size: 0.75rem !important;
    }
}

/* --- THE SIDEBAR (PC) --- */
#side-panel {
    flex: 1; 
    min-width: 250px;
    display: flex;
    flex-direction: column;
    background: #1a1a1a;
    padding: 20px;
    border-radius: 20px;
    border: 1px solid #333;
    /* On PC, this keeps it from being longer than the table */
    height: auto; 
}

/* --- THE LOGOUT BUTTON WRAPPER --- */
.logout-container {
    margin-top: auto; /* Pushes button to bottom on PC */
    width: 100%;
    padding: 20px 0; 
    display: flex;
    justify-content: center;
    /* CRITICAL: Ensure it sits above the footer */
    position: relative; 
    z-index: 10;
}

@media (max-width: 900px) {
    /* Allow the page to scroll down to the side panel, but lock the table size */
    body, .main-layout, #app-content {
        height: auto !important;
        min-height: 100vh;
        overflow-y: auto !important; 
    }

.game-area {
        height: calc(100dvh - 80px) !important; 
        min-height: 420px !important; 
        max-height: calc(100dvh - 80px) !important;
        
        display: flex;
        flex-direction: column;
        
        /* THE FIX: Allow vertical scrolling if cards push buttons down */
        overflow-y: auto !important; 
        overflow-x: hidden !important;
        
        /* THE FIX: Start from the top and use a gap instead of space-evenly */
        justify-content: flex-start !important;
        gap: 10px; 
        
        padding: 15px 10px 80px 10px !important; /* Added extra padding at the bottom so buttons don't hug the very edge when scrolling */
    }

    /* Optional: Hide the ugly scrollbar on the green felt while keeping the ability to swipe/scroll */
    .game-area::-webkit-scrollbar {
        display: none;
    }
    .game-area {
        -ms-overflow-style: none; 
        scrollbar-width: none; 
    }

    /* Dynamically shrink the cards based on screen height */
    .card {
        height: clamp(60px, 12vh, 85px) !important;
        width: clamp(42px, 8.5vh, 60px) !important;
        font-size: clamp(1rem, 2.5vh, 1.3rem) !important;
    }
    
    .cards {
        min-height: auto !important; /* Removes the hardcoded 120px gap */
        margin-top: 5px;
    }

    /* Compress margins heavily so everything fits inside the table */
    .dealer-section, .player-section { margin-bottom: 2px; }
    .stats-bar { margin-bottom: 5px; padding: 4px; }
    .betting-area { margin-top: 5px; padding: 8px; }
    .table-text { margin: 2px 0; font-size: 0.6rem; }
    .message { margin: 5px auto; min-height: auto; padding: 0.5rem; }

    /* The side panel drops below the table and behaves normally */
    #side-panel {
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
        margin-bottom: 60px; /* Keep it from touching the footer */
    }
}

/* Fixed the cramped mobile stats bar: Changed to a 2x2 readable grid */
    .stats-bar { 
        display: grid; 
        grid-template-columns: 1fr 1fr; 
        gap: 8px; 
        text-align: center; 
        font-size: 0.85rem; 
        padding: 10px;
    }

    @media (max-width: 900px) {
    .game-area {
        scrollbar-width: none; /* Firefox */
        -ms-overflow-style: none; /* IE/Edge */
    }
    .game-area::-webkit-scrollbar {
        display: none; /* Chrome/Safari */
    }
}


.btn-spin-roulette {
    /* 1. Dimensions & Centering */
    width: 95% !important;
    max-width: 400px !important;
    height: 60px;
    margin: 20px auto;
    
    /* 2. High-Stakes Aesthetics */
    background: linear-gradient(145deg, #f1c40f, #d4ac0d); /* Golden Gradient */
    color: #1a1a1a;
    font-family: 'Arial Black', sans-serif;
    font-size: 1.4rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 2px;
    
    /* 3. The "Glass & Gold" Look */
    border: 2px solid #fff;
    border-radius: 50px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    
    /* 4. Shadow & Depth */
    box-shadow: 
        0 8px 15px rgba(0, 0, 0, 0.4), 
        inset 0 -4px 0 rgba(0, 0, 0, 0.2),
        0 0 20px rgba(241, 196, 15, 0.4);
    
    /* 5. Animation Setup */
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    animation: pulse-glow 2s infinite;
}

/* --- THE EFFECTS --- */

/* A "Shinning Sweep" effect that passes over the button */
.btn-spin-roulette::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -60%;
    width: 50%;
    height: 200%;
    background: rgba(255, 255, 255, 0.4);
    transform: rotate(30deg);
    transition: none;
    animation: shine 4s infinite;
}

/* Hover State: Lift and brighten */
.btn-spin-roulette:hover {
    transform: translateY(-3px) scale(1.02);
    background: linear-gradient(145deg, #ffdb1f, #f1c40f);
    box-shadow: 0 12px 20px rgba(0, 0, 0, 0.5), 0 0 30px rgba(241, 196, 15, 0.6);
}

/* Active State: Press down effect */
.btn-spin-roulette:active {
    transform: translateY(2px) scale(0.98);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

/* --- THE ANIMATIONS --- */

@keyframes pulse-glow {
    0% { box-shadow: 0 0 10px rgba(241, 196, 15, 0.4); }
    50% { box-shadow: 0 0 25px rgba(241, 196, 15, 0.8), 0 0 40px rgba(241, 196, 15, 0.4); }
    100% { box-shadow: 0 0 10px rgba(241, 196, 15, 0.4); }
}

@keyframes shine {
    0% { left: -60%; }
    20% { left: 120%; }
    100% { left: 120%; }
}


/* =========================================
   ROULETTE WHEEL FIXES
   ========================================= */
/* =========================================
   FULL HEIGHT LAYOUT
   ========================================= */

.game-container {
    display: flex;
    flex-direction: column;
    /* Adjust '60px' to the exact height of your site's footer */
    min-height: calc(100vh - 60px); 
}

.game-area {
    display: flex;
    flex-direction: column;
    flex-grow: 1; 
    /* This pushes the wheel to the top and betting board to the bottom */
    justify-content: space-between; 
}

.betting-area {
    margin-top: auto; /* Pushes the betting area to the bottommost available space */
    padding-bottom: 15px;
}


.wheel-container {
    position: relative;
    /* 1. THE FIX: Lock the width/height to be identical */
    width: clamp(220px, 50vw, 320px); 
    height: clamp(220px, 50vw, 320px);
    
    /* 2. THE FIX: Force it to remain a perfect circle even if space is tight */
    aspect-ratio: 1 / 1; 
    flex-shrink: 0; 
    
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 10px auto; /* Centered */
}

/* Update your existing .wheel class to ensure it has position: relative */
.wheel {
    position: relative; /* 🟢 NEW: Crucial for anchoring the numbers */
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 12px solid #402103;
    box-sizing: border-box; 
    transform-origin: center center; 
    box-shadow: 0 10px 30px rgba(0,0,0,0.6), inset 0 0 20px rgba(0,0,0,0.8);
    transition: transform 3s cubic-bezier(0.25, 1, 0.25, 1); 
}

.wheel-marker {
    position: absolute;
    /* 🟢 Move the ball further down into the "pocket" so it rests below the number */
    top: 32px; 
    left: 50%;
    transform: translateX(-50%);
    
    /* 🟢 Slightly smaller so it doesn't overlap the text */
    width: 14px;
    height: 14px;
    background: radial-gradient(circle at 35% 35%, #ffffff 0%, #e0e0e0 50%, #999999 100%);
    border-radius: 50%;
    
    /* 🟢 3D shadow effects */
    box-shadow: 
        2px 4px 6px rgba(0, 0, 0, 0.6), 
        inset -2px -2px 4px rgba(0, 0, 0, 0.3);
        
    z-index: 10;
    
    /* 🟢 Keep the old yellow triangle invisible */
    color: transparent; 
    font-size: 0;
    text-shadow: none;
}

.result-display {
    position: absolute;
    width: 60px;
    height: 60px;
    background: radial-gradient(circle, #fffefe 0%, #cfcfcf 100%);
    border: 3px solid #f1c40f;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: bold;
    color: white;
    z-index: 5;
    box-shadow: 0 0 15px rgba(0,0,0,0.8);
}

/* Highlight the selected chip */
.r-chip.active {
    box-shadow: 0 0 15px #f1c40f, inset 0 0 10px rgba(255,255,255,0.5);
    transform: scale(1.1);
    border-color: #f1c40f;
}

/* =========================================
   ROULETTE HISTORY STYLES
   ========================================= */
.history-container {
    display: flex;
    justify-content: flex-start; 
    gap: 8px;
    margin-bottom: 10px;
    width: 100%;
    max-width: 400px;
    
    /* 🟢 THE FIX: Let it breathe and scroll horizontally */
    height: auto; 
    min-height: 45px;
    overflow-x: auto; 
    overflow-y: hidden;
    padding: 20px;
    
    /* Smooth mobile scrolling */
    -webkit-overflow-scrolling: touch; 
}

.history-number {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-weight: bold;
    color: white;
    font-size: 0.9rem;
    box-shadow: 0 2px 5px rgba(0,0,0,0.5), inset 0 0 5px rgba(255,255,255,0.2);
    flex-shrink: 0;
    
    /* The pop animation */
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

/* Color classes applied via JavaScript */
.history-red { background: #e74c3c; border: 2px solid #c0392b; }
.history-black { background: #2c3e50; border: 2px solid #1a252f; }
.history-green { background: #27ae60; border: 2px solid #2ecc71; }

@keyframes popIn {
    0% { transform: scale(0); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* =========================================
   ROULETTE BETTING BOARD FIXES
   ========================================= */
.table-wrapper {
    /* 🟢 THE FIX: Removed the buggy negative margin hacks */
    width: 100%;
    max-width: 100vw;
    background: #003d1e;
    padding: 20px 0;
    
    /* 🟢 Center the board cleanly */
    display: flex;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;

    /* Safety fallback: allows scroll on extremely tiny screens (< 320px) */
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

#roulette-board {
    display: flex;
    flex-direction: row; 
    background: rgba(0, 50, 20, 0.8);
    /* 🟢 Responsive padding to save space on mobile */
    padding: clamp(5px, 2vw, 10px);
    border-radius: 8px;
    border: 2px solid #f1c40f;
    box-shadow: 0 10px 20px rgba(0,0,0,0.5), inset 0 0 20px rgba(0,0,0,0.8);
    
    /* 🟢 Ensure it scales down and doesn't break out of the wrapper */
    max-width: 100%;
    box-sizing: border-box;
}

.r-numbers-grid {
    display: grid;
    /* 🟢 Lowered the minimum clamp from 30px to 22px so 12 columns fit on mobile */
    grid-template-columns: repeat(12, clamp(22px, 6.5vw, 40px));
    grid-template-rows: repeat(3, clamp(22px, 6.5vw, 40px));
    gap: 2px;
    margin-left: 2px;
}

/* 🟢 Consolidated the Zero block (removed the static 45px/139px duplicate) */
.r-cell.zero {
    width: clamp(22px, 6.5vw, 40px);
    height: calc((clamp(22px, 6.5vw, 40px) * 3) + 4px); 
    flex-shrink: 0;
}

.r-cell {
    /* Assuming you have base styles for .r-cell here like display:flex, etc. */
    transition: all 0.2s ease;
}

.r-cell:hover {
    transform: scale(1.1);
    z-index: 10;
    box-shadow: 0 0 10px #f1c40f;
    border-color: #f1c40f;
    border-radius: 4px;
}

/* Colors */
.r-red { background: #c0392b; }
.r-black { background: #1a252f; }
.r-green { background: #27ae60; }
/* =========================================
   WHEEL NUMBERS
   ========================================= */
.wheel-number-spoke {
    position: absolute;
    top: 0;
    left: 50%;
    width: 20px;
    margin-left: -10px; /* Centers the spoke perfectly */
    height: 50%; /* Reaches exactly from the top edge to the dead center */
    transform-origin: bottom center; /* Sets the pivot point to the center of the wheel */
    display: flex;
    justify-content: center;
    align-items: flex-start; /* Pushes the text to the outer edge of the wheel */
    padding-top: 4px; /* Space between the text and the wooden border */
    pointer-events: none; /* Prevents text from interfering with clicks */
}

.wheel-number-text {
    color: white;
    font-weight: bold;
    font-family: Arial, sans-serif;
    /* Scales the text down nicely on smaller screens */
    font-size: clamp(8px, 2.5vw, 13px); 
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
}

/* =========================================
   PLACED CHIPS ON THE BOARD
   ========================================= */
/* Ensure the grid cells can hold chips inside them */
.r-cell {
    position: relative; /* 🟢 NEW: Critical for keeping chips inside the box */
}

/* Red/Black buttons also need this so chips can sit on them */
.r-btn {
    position: relative;
}

.placed-chip {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: clamp(20px, 3vw, 26px);
    height: clamp(20px, 3vw, 26px);
    background: radial-gradient(circle, #f1c40f 0%, #d4ac0d 100%);
    border: 2px dashed #333;
    border-radius: 50%;
    color: black;
    font-size: clamp(9px, 1vw, 11px);
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none; /* 🟢 NEW: Stops the chip from blocking your next click! */
    z-index: 20;
    box-shadow: 2px 2px 6px rgba(0,0,0,0.6);
    
    /* Casino Drop Animation */
    animation: dropChip 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes dropChip {
    0% { transform: translate(-50%, -50%) scale(2); opacity: 0; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

/* =========================================
   📱 MOBILE OPTIMIZATION OVERRIDES
   ========================================= */

/* Prevent double-tap-to-zoom on mobile which ruins rapid betting */
.r-cell, .btn-spin-roulette, .r-chip {
    touch-action: manipulation;
}

/* Customize the scrollbar for the table wrapper so it looks like an app */
.table-wrapper::-webkit-scrollbar {
    height: 6px;
}
.table-wrapper::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}
.table-wrapper::-webkit-scrollbar-thumb {
    background: #f1c40f;
    border-radius: 4px;
}


/* =========================================
   📱 MOBILE OPTIMIZATION OVERRIDES
   ========================================= */

/* Prevent double-tap-to-zoom on mobile which ruins rapid betting */
.r-cell, .btn-spin-roulette, .r-chip {
    touch-action: manipulation;
}

/* Customize the scrollbar for the table wrapper so it looks like an app */
.table-wrapper::-webkit-scrollbar {
    height: 6px;
}
.table-wrapper::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}
.table-wrapper::-webkit-scrollbar-thumb {
    background: #f1c40f;
    border-radius: 4px;
}

.betting-areaRoulette {
    width: 100%;
}

/* 🟢 SINGLE, UNIFIED MOBILE MEDIA QUERY */
@media (max-width: 768px) {
    /* Force parents to stop squeezing the table */
    .game-container, .game-area, .betting-area {
        width: 100% !important;
        max-width: 100% !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        overflow-x: hidden; 
    }

    /* 1. Update the wrapper to simply center the board (No 50vw hacks) */
    .table-wrapper {
        width: 100% !important; /* Standard 100% */
        padding: 4rem 0 4rem 0 !important;
        display: flex !important;
        justify-content: center; /* Center the board on the screen */
        overflow-x: hidden !important; 
        
        /* Override any desktop positioning */
        position: static !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    #roulette-board {
        width: max-content;
        max-width: 96vw; /* Keep it inside the screen */
        padding: 5px;
    }

    /* 2. Scale the grid to the screen width, and FORBID shrinking */
    .r-numbers-grid {
        grid-template-columns: repeat(12, 7vw) !important; 
        grid-template-rows: repeat(3, 8vw) !important; 
        gap: 2px;
        /* 🟢 THE FIX: Stop flexbox from crushing it into a line! */
        flex-shrink: 0 !important; 
    }

    /* 3. Scale the Zero cell to match */
    .r-cell.zero {
        width: 7vw !important;
        height: calc((8vw * 3) + 4px) !important; 
        flex-shrink: 0 !important;
    }

    /* 4. Make the wheel bigger on mobile */
    .wheel-container {
        width: clamp(260px, 90vw, 380px);
        height: clamp(260px, 90vw, 380px);
        margin: 20px auto;
    }

    /* Ensure wheel text readability */
    .wheel-number-text {
        font-size: clamp(10px, 3.5vw, 14px);
    }

    /* 5. Scale down the chips so they fit inside the smaller boxes */
    .placed-chip {
        width: 4.5vw !important;
        height: 4.5vw !important;
        font-size: 2.2vw !important;
        /* Center text inside the chip */
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* 6. Make the action buttons span the width nicely */
    .controlsR {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 10px;
        width: 100%;
    }
    
    .btn-spin-roulette {
        width: 95% !important;
        max-width: 400px !important;
    }
}


.betting-areaRoulette {
    width: 100%;
}

/* THE WRAPPER: Handles centering and layout */
.roulette-container {
    display: flex;
    justify-content: center; 
    align-items: center;     
    gap: 15px;               /* Reduced gap for a tighter look */
    padding: 15px 10px;      /* Significantly reduced vertical padding */
    width: 100%;             
    box-sizing: border-box;
    margin: 0 auto;          /* Ensures the container itself is centered */
}

/* THE BUTTONS: Base styling */
.btn-actionR {
    cursor: pointer;
    padding: 12px 0;         /* Slightly slimmer padding */
    width: 180px;            /* Unified width that fits better on small screens */
    flex: none;              
    
    font-family: 'Segoe UI', Roboto, sans-serif;
    font-size: 1rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #ffffff;
    border-radius: 6px;
    transition: all 0.2s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    text-align: center;
    border: 2px solid transparent;
}

/* Red & Black specific colors */
.btn-actionR[data-bet="red"] {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%) !important;
    border-color: #ff5e4d !important;
}

.btn-actionR[data-bet="black"] {
    background: linear-gradient(135deg, #34495e 0%, #2c3e50 100%) !important;
    border-color: #4a627a !important;
}

/* Interaction States */
.btn-actionR:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
}

.btn-actionR:active {
    transform: translateY(1px);
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    .roulette-container {
        flex-direction: row;    /* Keeps them side-by-side unless screen is tiny */
        justify-content: center;
        gap: 10px;              /* Tightens space between buttons */
        padding: 10px 5px;      /* Minimal space before/after next divs */
    }
    
    .btn-actionR {
        width: 45%;             /* Uses percentage to fit perfectly side-by-side */
        min-width: 140px;       /* Prevents them from getting too small */
        font-size: 0.9rem;      /* Shrinks text slightly to fit */
    }
}

/* Extra Small screens (iPhone SE etc) */
@media (max-width: 350px) {
    .roulette-container {
        flex-direction: column; /* Stack only on very narrow screens */
    }
    .btn-actionR {
        width: 100%;
    }
}

#navOps {
    display: flex;
    justify-content: center;
    background: rgba(0, 0, 0, 0.8); /* Dark semi-transparent bar */
    padding: 10px;
    border-bottom: 2px solid #34495e;
    gap: 10px;
    position: sticky; /* Keeps nav at the top while scrolling */
    top: 0;
    z-index: 1000;
}

.nav-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #bdc3c7;
    padding: 8px 20px;
    font-family: 'Segoe UI', Roboto, sans-serif;
    font-weight: 600;
    text-transform: uppercase;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.3s ease;
}

/* Hover Effect */
.nav-btn:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.5);
}

/* The Active Game State */
.nav-btn.active {
    color: #ffffff;
    background: #3498db; /* You can change this to gold (#f1c40f) for a casino look */
    border-color: #3498db;
    box-shadow: 0 0 10px rgba(52, 152, 219, 0.5);
}

/* Mobile Tweaks */
@media (max-width: 480px) {
    #navOps {
        padding: 5px;
    }
    .nav-btn {
        flex: 1; /* Makes buttons equal width on mobile */
        font-size: 0.8rem;
        padding: 10px 5px;
    }
}
