/* ================= CSS THEME VARIABLES (Global Centralized) ================= */
:root {
    --bg-main: #07090e;
    --bg-card: #0f1322;
    --bg-input: #0a0e17;
    --border-color: rgba(0, 210, 211, 0.3);
    --text-main: #ffffff;
    --text-muted: #94a3b8;
    
    /* Primary Accents */
    --accent-cyan: #00d2d3;
    --accent-blue: #0984e3;
    
    /* Global Rainbow Gradients for Theme Control */
    --rainbow-glow: linear-gradient(135deg, rgba(0, 210, 211, 0.3), rgba(168, 85, 247, 0.25), rgba(255, 202, 40, 0.25), rgba(255, 71, 87, 0.25));
    --rainbow-border: linear-gradient(135deg, #00d2d3, #a855f7, #ffca28, #ff4757);
    --btn-soft-rainbow: linear-gradient(135deg, rgba(0, 210, 211, 0.9), rgba(168, 85, 247, 0.9), rgba(255, 202, 40, 0.9), rgba(255, 71, 87, 0.9));
    
    /* Enhanced Distinct & Professional Header Background */
    --header-bg: linear-gradient(180deg, #131b2e 0%, #0c1220 100%);
    --header-box-shadow: 0 4px 35px rgba(0, 210, 211, 0.18);
    
    --success-color: #00d2d3;
}

/* ================= GLOBAL RESET & PERFORMANCE ================= */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Outfit', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    height: 100%;
    background-color: var(--bg-main);
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Custom Sleek Scrollbar */
::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}
::-webkit-scrollbar-track {
    background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

/* ================= TOP NAVBAR & HEADER SYSTEM (Enhanced Distinct Style) ================= */
.navbar {
    height: 54px;
    min-height: 54px;
    background: var(--header-bg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
    flex-shrink: 0;
    box-shadow: var(--header-box-shadow);
    backdrop-filter: blur(12px);
    position: relative;
    z-index: 99999;
    
    border-top: 2px solid transparent;
    border-bottom: 2px solid transparent;
    border-image: var(--rainbow-border) 1;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    font-size: 17px;
    background: var(--rainbow-border);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 0.8px;
    text-shadow: 0 0 25px rgba(0, 210, 211, 0.4);
}

.user-top-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
    z-index: 100000;
}

.balance-badge {
    background: rgba(0, 210, 211, 0.12);
    color: var(--accent-cyan);
    padding: 6px 14px;
    border-radius: 16px;
    font-weight: 700;
    border: 1px solid rgba(0, 210, 211, 0.4);
    font-size: 11px;
    box-shadow: inset 0 0 12px rgba(0, 210, 211, 0.15);
}

.auth-btn {
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
    border: none;
    color: #fff;
    padding: 7px 14px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s;
    box-shadow: 0 0 15px rgba(0, 210, 211, 0.35);
}
.auth-btn:hover {
    opacity: 0.95;
    transform: translateY(-1px);
    box-shadow: 0 0 20px rgba(0, 210, 211, 0.6);
}

/* ================= THREE DOT MENU & PROFESSIONAL CIRCLE BUTTON ================= */
.menu-dots {
    background: var(--bg-input);
    border: 1px solid rgba(0, 210, 211, 0.4);
    color: var(--accent-cyan);
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
    box-shadow: 0 0 12px rgba(0, 210, 211, 0.15);
}
.menu-dots:hover {
    background: rgba(0, 210, 211, 0.15);
    color: #fff;
    border-color: var(--accent-cyan);
    box-shadow: 0 0 18px rgba(0, 210, 211, 0.4);
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 54px;
    right: 0;
    background: var(--bg-card);
    border: 1px solid rgba(0, 210, 211, 0.4);
    border-radius: 12px;
    width: 200px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.8);
    padding: 6px 0;
    z-index: 999999 !important;
}
.dropdown-menu.show {
    display: block;
}
.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: 0.2s;
}
.dropdown-item i {
    color: var(--text-muted);
    font-size: 14px;
    transition: 0.2s;
}
.dropdown-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
}
.dropdown-item:hover i {
    color: var(--accent-cyan);
}
.dropdown-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.06);
    margin: 4px 0;
}

/* ================= SOLID LIVE CHAT WIDGET ================= */
#toggleChatWidgetBtn {
    background: var(--accent-cyan) !important;
    color: #07090e !important;
    box-shadow: 0 4px 20px rgba(0, 210, 211, 0.4) !important;
}

#customLiveChatWidget {
    border: 1px solid rgba(0, 210, 211, 0.6) !important;
    background: var(--bg-card) !important;
    opacity: 1 !important;
    backdrop-filter: none !important;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.95) !important;
}

#customLiveChatWidget > div:first-child {
    background: var(--accent-cyan) !important;
    color: #07090e !important;
}

#customLiveChatWidget button#closeLiveChatBtn {
    color: #07090e !important;
}

#sendChatMessageBtn {
    background: var(--accent-cyan) !important;
    color: #07090e !important;
}

#chatMessageInput {
    background: var(--bg-input) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-main) !important;
}

#chatToastPopup {
    background: var(--bg-card) !important;
    border: 1px solid var(--accent-cyan) !important;
    color: var(--text-main) !important;
    opacity: 1 !important;
}
#chatToastPopup i {
    color: var(--accent-cyan) !important;
}

/* ================= MAIN LAYOUT ================= */
.main-layout {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 340px;
    grid-template-rows: 1fr;
    gap: 8px;
    padding: 8px;
    width: 100%;
    height: calc(100vh - 54px);
    overflow: hidden;
    position: relative;
    z-index: 1;
}

.left-column {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
    height: 100%;
    flex: 1;
}

.game-wrapper {
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid rgba(0, 210, 211, 0.4);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    flex: 1;
    min-height: 250px;
    transform: translateZ(0);
    box-shadow: 0 0 30px rgba(0, 210, 211, 0.2);
    z-index: 2;
}

.canvas-container {
    flex: 1;
    position: relative;
    background: #0d111a;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#crashCanvas {
    width: 100% !important;
    height: 100% !important;
    object-fit: fill;
    display: block;
}

/* Game Header Bar */
.game-header-bar {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 0 10px;
    background: rgba(12, 18, 33, 0.92);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 210, 211, 0.4);
    border-radius: 10px;
    z-index: 10;
    box-shadow: 0 4px 25px rgba(0, 0, 0, 0.6), inset 0 0 15px rgba(0, 210, 211, 0.1);
}

.game-header-history-btn, .game-header-network-status {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(20, 30, 50, 0.9);
    border: 1px solid rgba(0, 210, 211, 0.4);
    border-radius: 8px;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 0 12px rgba(0, 210, 211, 0.2);
    transition: 0.2s;
    flex-shrink: 0;
}
.game-header-history-btn:hover {
    background: rgba(0, 210, 211, 0.25);
    border-color: var(--accent-cyan);
    box-shadow: 0 0 18px rgba(0, 210, 211, 0.5);
}

/* ================= DRAG / GRAB SYSTEM FIX ================= */
.history-tabs-grab-wrapper {
    flex-grow: 1;
    display: flex;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
    -ms-overflow-style: none;
    cursor: grab;
    user-select: none;
    padding: 2px 4px;
}

.history-tabs-grab-wrapper:active {
    cursor: grabbing;
}

.history-tabs-grab-wrapper::-webkit-scrollbar {
    display: none;
}

/* History Modal */
.history-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(7, 9, 14, 0.88);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999999;
}
.history-modal-content {
    width: 90%;
    max-width: 480px;
    background: var(--bg-card);
    border: 1px solid rgba(0, 210, 211, 0.6);
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 30px 60px rgba(0,0,0,0.95);
}
.history-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: rgba(15, 23, 42, 0.9);
    border-bottom: 1px solid rgba(0, 210, 211, 0.3);
    font-weight: 700;
    color: var(--accent-cyan);
}
.history-modal-close-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    transition: 0.2s;
}
.history-modal-close-btn:hover {
    background: #ff4757;
}
.history-modal-body {
    padding: 16px;
    max-height: 320px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: 8px;
}

/* ================= BETTING SECTION & REFINED CONTROLS ================= */
.betting-section {
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid rgba(0, 210, 211, 0.4);
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
    box-shadow: 0 6px 25px rgba(0,0,0,0.5);
}

/* Container for Bet Controls Columns */
.bet-controls-grid {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    width: 100%;
}

/* Individual Control Group with Labels Outside & Above */
.control-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.field-label {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 700;
    margin-left: 2px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Bet Amount Column (Slightly Larger / Balanced Width) */
.bet-input-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1.2; /* Thora bara size */
    min-width: 160px;
}

.bet-input-wrapper {
    display: flex;
    align-items: center;
    background: var(--bg-input);
    border: 1px solid rgba(0, 210, 211, 0.35);
    border-radius: 8px;
    padding: 3px;
}

.bet-input {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-main);
    text-align: center;
    font-size: 13px;
    font-weight: 700;
    outline: none;
}

/* Smaller Quick Selector Amount Buttons */
.quick-increments {
    display: flex;
    gap: 4px;
    width: 100%;
}

.quick-btn {
    flex: 1;
    min-height: 28px;
    padding: 4px 4px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(0, 210, 211, 0.25);
    color: var(--text-main);
    border-radius: 6px;
    font-size: 10px;
    font-weight: 700;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s ease-in-out;
    display: flex;
    align-items: center;
    justify-content: center;
}
.quick-btn:hover {
    background: rgba(0, 210, 211, 0.15);
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
}

/* Auto Cash Out Column (Smaller from both Left & Right, Compact Design) */
.auto-cash-group {
    flex: 0.8;
    min-width: 110px;
    max-width: 130px;
}

.auto-cash-wrapper {
    display: flex;
    align-items: center;
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.9), rgba(30, 27, 75, 0.8));
    border: 1px solid rgba(168, 85, 247, 0.4);
    border-radius: 8px;
    padding: 6px 10px;
    justify-content: space-between;
    box-shadow: inset 0 0 10px rgba(168, 85, 247, 0.15);
    height: 35px;
}

.auto-input {
    width: 100%;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 13px;
    font-weight: 800;
    text-align: center;
    outline: none;
}

select {
    background: rgba(255, 255, 255, 0.04) !important;
    color: #fff !important;
    outline: none;
    border: 1px solid rgba(0, 210, 211, 0.3);
    border-radius: 8px;
    padding: 6px;
}
select option {
    background: var(--bg-card) !important;
}

.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    flex-shrink: 0;
}
.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: #1e293b;
    transition: 0.2s;
    border-radius: 22px;
    border: 1px solid rgba(255,255,255,0.1);
}
.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: #ffffff;
    transition: 0.2s;
    border-radius: 50%;
}
input:checked + .slider {
    background-color: #22c55e !important;
    box-shadow: 0 0 12px rgba(34, 197, 94, 0.6);
}
input:checked#autoCashoutToggle + .slider {
    background-color: var(--accent-cyan) !important;
    box-shadow: 0 0 12px rgba(0, 210, 211, 0.6);
}
input:checked + .slider:before {
    transform: translateX(18px);
}

/* ================= BALANCED GAME BET & CASH OUT BUTTONS ================= */
.place-bet-btn {
    background: var(--btn-soft-rainbow);
    border: none;
    color: #07090e;
    padding: 10px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
    text-transform: uppercase;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    transition: 0.2s;
    box-shadow: 0 4px 20px rgba(0, 210, 211, 0.25);
}
.place-bet-btn:hover {
    opacity: 0.95;
    box-shadow: 0 6px 25px rgba(0, 210, 211, 0.4);
    transform: translateY(-1px);
}

.place-bet-btn.bet-placed,
.place-bet-btn[data-state="placed"] {
    background: linear-gradient(135deg, #eab308, #ca8a04) !important;
    color: #07090e !important;
    box-shadow: 0 4px 20px rgba(234, 179, 8, 0.35) !important;
}

.place-bet-btn.cash-out,
.place-bet-btn[data-state="cashout"] {
    background: linear-gradient(135deg, #f43f5e, #e11d48) !important;
    color: #ffffff !important;
    box-shadow: 0 4px 20px rgba(244, 63, 94, 0.35) !important;
}

/* ================= RIGHT SIDEBAR ================= */
.sidebar-section {
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid rgba(0, 210, 211, 0.4);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
    min-width: 0;
    box-shadow: 0 6px 25px rgba(0,0,0,0.5);
}

.stats-summary {
    display: flex;
    justify-content: space-around;
    padding: 10px 6px;
    background: var(--bg-input);
    border-bottom: 1px solid rgba(0, 210, 211, 0.25);
    font-size: 10px;
    color: var(--text-muted);
    text-align: center;
    flex-shrink: 0;
}
.stats-summary span {
    display: block;
    color: var(--accent-cyan);
    font-weight: 800;
    font-size: 11px;
}

.sidebar-tabs {
    display: flex;
    background: var(--bg-main);
    padding: 3px;
    border-bottom: 1px solid rgba(0, 210, 211, 0.25);
    flex-shrink: 0;
}
.side-tab {
    flex: 1;
    background: var(--bg-card);
    border: none;
    color: var(--text-muted);
    padding: 8px 4px;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    text-align: center;
    transition: 0.2s;
}
.side-tab.active {
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
    color: #fff;
    box-shadow: 0 0 15px rgba(0, 210, 211, 0.5);
}

.bets-list-container {
    flex: 1;
    overflow-y: auto;
    padding: 6px;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
}

/* ================= MODALS & MODERN INTERIOR REDESIGN ================= */
.auth-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    backdrop-filter: blur(8px);
}
.auth-modal-container {
    background: var(--bg-card) !important;
    border: 1px solid rgba(0, 210, 211, 0.5) !important;
    width: 92%;
    max-width: 420px;
    border-radius: 16px;
    padding: 22px;
    color: var(--text-main) !important;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.95), 0 0 25px rgba(0, 210, 211, 0.2) !important;
}

.auth-modal-container h2,
.auth-modal-container h3,
.auth-modal-container h4 {
    color: var(--text-main) !important;
    font-weight: 800 !important;
}
.auth-modal-container label {
    color: var(--text-muted) !important;
    font-size: 12px !important;
    font-weight: 600 !important;
}
.auth-modal-container input, 
.auth-modal-container select {
    background: var(--bg-input) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-main) !important;
    border-radius: 10px !important;
    padding: 10px 12px !important;
}
.auth-modal-container input:focus, 
.auth-equal-container select:focus {
    border-color: var(--accent-cyan) !important;
    box-shadow: 0 0 12px rgba(0, 210, 211, 0.3) !important;
}

input::-webkit-outer-spin-button, input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* ================= MOBILE RESPONSIVENESS ================= */
@media (max-width: 900px) {
    html, body {
        overflow-y: auto !important;
        height: auto !important;
    }
    .main-layout {
        display: flex;
        flex-direction: column;
        height: auto;
        overflow: visible;
    }
    .left-column {
        height: auto;
        overflow: visible;
    }
    /* Canvas Area increased by ~25% for mobile screens */
    .game-wrapper {
        height: 320px;
        min-height: 320px;
        flex: unset;
    }
    .sidebar-section {
        height: auto !important;
        min-height: 280px;
        max-height: 380px;
        margin-bottom: 10px;
    }
}
