:root {
    /* Colors */
    --bg-dark: #0f121b;
    --bg-card: #1a1e29;
    --bg-sidebar: #151923;
    --text-primary: #ffffff;
    --text-secondary: #8b92a3;

    --primary: #00e701;
    /* Neon Green */
    --primary-hover: #00c201;
    --primary-glow: rgba(0, 231, 1, 0.4);

    --accent: #9d4edd;
    /* Neon Purple */
    --danger: #ff4d4d;
    --success: #00e701;

    /* Spacing & Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;

    --header-height: 70px;
    --sidebar-width: 240px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    overscroll-behavior-y: contain;
    /* Allow pull-to-refresh but contain bounce */
    overflow: auto;
    /* Enable scrolling for mobile refresh */
    height: 100vh;
}

h1,
h2,
h3,
.logo-text {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
}

#app {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    /* Container controls overflow, not body */
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    padding: 20px;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    transition: transform 0.3s ease;
    z-index: 100;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 40px;
    font-size: 24px;
    color: var(--primary);
    text-shadow: 0 0 10px var(--primary-glow);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    transition: all 0.2s;
}

.nav-item:hover,
.nav-item.active {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.nav-item.active {
    color: var(--primary);
    background: rgba(0, 231, 1, 0.1);
}

.user-area-section {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.user-email {
    padding: 0 10px;
    margin-bottom: 10px;
    font-size: 14px;
    color: var(--text-secondary);
    word-break: break-all;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.top-bar {
    height: var(--header-height);
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    /* Align balance to right */
    background: var(--bg-dark);
    z-index: 90;
    position: relative;
    /* For ticker positioning */
}

/* Ticker Styles */
.profit-message-ticker {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 400px;
    text-align: center;
    overflow: hidden;
    height: 30px;
    pointer-events: none;
    /* Let clicks pass through if needed */
}

/* Mobile Ticker Adjustment */
@media (max-width: 768px) {
    .profit-message-ticker {
        top: 60px;
        /* Push below header */
        width: 90%;
        background: rgba(15, 18, 27, 0.9);
        /* Semi-transparent background for readability */
        border-radius: 20px;
        z-index: 80;
        /* Below header z-index */
    }
}

.message-item {
    display: block;
    width: 100%;
    color: var(--primary);
    font-size: 14px;
    font-weight: 500;
    text-shadow: 0 0 5px var(--primary-glow);
    white-space: nowrap;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.5s ease;
    position: absolute;
    top: 5px;
}

.message-item.active {
    opacity: 1;
    transform: translateY(0);
}

.message-item strong {
    color: #fff;
    font-weight: 700;
}

.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    margin-right: auto;
    cursor: pointer;
}

.balance-display {
    background: var(--bg-card);
    padding: 8px 16px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-weight: 600;
}

.balance-display.hidden {
    display: none;
}

.currency-symbol {
    color: var(--primary);
}

.page-container {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    /* Smooth iOS scrolling */
    padding: 20px;
    scroll-behavior: smooth;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border-radius: var(--radius-md);
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.2s;
    font-family: 'Inter', sans-serif;
}

.btn:active {
    transform: scale(0.96);
}

.btn-primary {
    background: var(--primary);
    color: #000;
    box-shadow: 0 0 15px var(--primary-glow);
}

.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: 0 0 25px var(--primary-glow);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 14px;
}

.full-width {
    width: 100%;
}

/* Game Grid - FORCE 2 columns on mobile */
.game-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

.game-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 30px 20px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: transform 0.2s;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 140px;
}

.game-card:hover {
    transform: translateY(-5px);
    border-color: rgba(255, 255, 255, 0.1);
}

.game-card:active {
    transform: translateY(-2px);
}

/* Support Button */
.support-fab {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: black;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    z-index: 200;
    transition: transform 0.2s;
}

.support-fab:hover {
    transform: scale(1.1);
}

/* Utility */
.hidden {
    display: none !important;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-left-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 40px auto;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.modal-content {
    background: var(--bg-card);
    padding: 30px;
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 400px;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.1);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
}

.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 14px;
}

.input-group input {
    width: 100%;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 16px;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary);
}

.password-input-wrapper {
    position: relative;
    width: 100%;
}

.password-input-wrapper input {
    padding-right: 45px;
}

.toggle-password {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.toggle-password:hover {
    color: var(--primary);
}

.toggle-password svg {
    width: 20px;
    height: 20px;
}

.auth-switch {
    margin-top: 16px;
    text-align: center;
    font-size: 14px;
    color: var(--text-primary);
}

#auth-question {
    color: var(--text-primary);
    cursor: default;
}

#switch-auth-mode {
    color: var(--primary);
    cursor: pointer;
    font-weight: 600;
}

/* Auth Error Message */
.auth-error {
    background: rgba(255, 77, 77, 0.2);
    border: 1px solid var(--danger);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-bottom: 16px;
    color: #fff;
    font-size: 14px;
    line-height: 1.5;
}

.auth-error.hidden {
    display: none;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        transform: translateX(-100%);
        height: 100%;
        box-shadow: 5px 0 15px rgba(0, 0, 0, 0.5);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .mobile-menu-toggle {
        display: block;
    }

    .main-content {
        width: 100%;
    }

    /* Keep 2 columns on mobile */
    .game-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Wallet Section Mobile Fixes */
    .wallet-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-bottom: 15px;
    }

    .tab-content {
        min-height: auto;
        padding: 10px;
        overflow: visible;
    }

    .deposit-info,
    .withdraw-form {
        padding: 10px;
    }

    .input-group {
        margin-bottom: 8px;
    }

    .btn.full-width {
        margin-top: 5px;
        margin-bottom: 10px;
        padding: 10px 20px;
    }

    .page-container {
        padding: 12px;
        padding-bottom: 20px;
        max-height: calc(100vh - var(--header-height));
        overflow-y: auto;
    }

    /* Optimize wallet elements for mobile */
    .page-header {
        display: none;
        /* Hide header to save space */
    }

    .page-header h1 {
        font-size: 20px;
    }

    .qr-section {
        margin: 5px 0;
    }

    .qr-section h3 {
        display: none;
        /* Hide "Scan QR Code" text */
    }

    .qr-section img {
        width: 100px;
        height: 100px;
    }

    .address-section {
        margin-bottom: 5px;
    }

    .currency-selector {
        margin-bottom: 5px;
    }

    .currency-selector label,
    .address-section label,
    .input-group label {
        font-size: 12px;
        margin-bottom: 2px;
    }

    .select-trigger,
    .address-copy input,
    .input-group input {
        padding: 6px 10px;
        font-size: 13px;
        height: 36px;
    }

    .btn-copy {
        padding: 6px 10px;
    }
}

/* Extra small phones - wallet optimization */
@media (max-width: 375px) {
    .page-header {
        display: none !important;
    }

    .wallet-tabs {
        margin-bottom: 5px;
    }

    .tab-btn {
        padding: 6px 12px;
        font-size: 12px;
    }

    .qr-section {
        margin: 5px 0;
    }

    .qr-section h3 {
        display: none !important;
    }

    .qr-section img {
        width: 100px;
        height: 100px;
    }

    .deposit-info,
    .withdraw-form {
        padding: 8px;
    }

    .tab-content {
        padding: 5px;
    }

    .currency-selector,
    .address-section {
        margin-bottom: 8px;
    }

    .currency-selector label,
    .address-section label {
        font-size: 11px;
        margin-bottom: 4px;
    }

    .select-trigger,
    .address-copy input {
        padding: 8px 10px;
        font-size: 13px;
    }

    .btn-copy {
        padding: 8px 10px;
    }

    .input-group {
        margin-bottom: 8px;
    }

    .input-group label {
        font-size: 11px;
        margin-bottom: 4px;
    }

    .input-group input {
        padding: 8px;
        font-size: 13px;
    }

    .btn.full-width {
        margin-top: 10px;
        margin-bottom: 10px;
        padding: 10px 16px;
        font-size: 13px;
    }

    .page-container {
        padding: 10px;
        padding-bottom: 20px;
    }
}

/* Larger screens - limit to 3 columns max for better aesthetics */
@media (min-width: 769px) {
    .game-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 25px;
        max-width: 1000px;
        /* Better use of space on desktop */
    }

    .game-card {
        min-height: 180px;
        padding: 40px 20px;
    }
}

/* ===== WALLET STYLES ===== */
.page-header {
    margin-bottom: 30px;
}

.page-header h1 {
    font-size: 28px;
    font-family: 'Outfit', sans-serif;
}

.wallet-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.05);
}

.tab-btn {
    padding: 12px 24px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-content {
    max-width: 600px;
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

.currency-selector {
    margin-bottom: 25px;
}

.currency-selector label {
    display: block;
    margin-bottom: 10px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
}

.custom-select {
    position: relative;
    width: 100%;
}

.select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: border-color 0.2s;
}

.select-trigger:hover {
    border-color: rgba(255, 255, 255, 0.2);
}

.select-trigger i {
    width: 20px;
    height: 20px;
    color: var(--text-secondary);
}

.select-options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    margin-top: 5px;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: all 0.3s;
    z-index: 10;
}

.select-options.show {
    max-height: 300px;
    opacity: 1;
}

.option {
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.2s;
}

.option:hover {
    background: rgba(255, 255, 255, 0.05);
}

.deposit-info {
    background: var(--bg-card);
    padding: 25px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.qr-section {
    text-align: center;
    margin: 25px 0;
}

.qr-section h3 {
    font-size: 16px;
    margin-bottom: 15px;
    color: var(--text-secondary);
}

.qr-section img {
    width: 200px;
    height: 200px;
    border-radius: var(--radius-md);
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.address-section {
    margin-bottom: 25px;
}

.address-section label {
    display: block;
    margin-bottom: 10px;
    color: var(--text-secondary);
    font-size: 14px;
}

.address-copy {
    display: flex;
    gap: 10px;
}

.address-copy input {
    flex: 1;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
}

.btn-copy {
    padding: 12px 16px;
    background: rgba(0, 231, 1, 0.1);
    border: 1px solid rgba(0, 231, 1, 0.3);
    border-radius: var(--radius-sm);
    color: var(--primary);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-copy:hover {
    background: rgba(0, 231, 1, 0.2);
}

.btn-copy i {
    width: 20px;
    height: 20px;
}

.withdraw-form {
    background: var(--bg-card);
    padding: 25px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.success-message {
    background: rgba(0, 231, 1, 0.1);
    border: 1px solid var(--success);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-bottom: 20px;
    color: #fff;
    font-size: 14px;
    line-height: 1.5;
}

.error-message {
    background: rgba(255, 77, 77, 0.2);
    border: 1px solid var(--danger);
}

.success-message.hidden {
    display: none;
}