:root {
    --primary-color: #ff004c;
    --primary-glow: rgba(255, 0, 76, 0.4);
    --secondary-color: #00e5ff;
    --secondary-glow: rgba(0, 229, 255, 0.3);
    --bg-dark: #050507;
    --bg-surface: #101014;
    --bg-panel: rgba(20, 20, 26, 0.8);
    --gold: #ffcc00;
    --success: #00ff88;
    --card-radius: 24px;
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-dark);
    color: #fff;
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
    width: 100vw;
}

/* Background Pattern */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle at 50% 0%, rgba(255, 0, 76, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 0% 100%, rgba(0, 229, 255, 0.05) 0%, transparent 50%);
    z-index: -1;
}

.app-container {
    display: flex;
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    background-color: var(--bg-dark);
    position: relative;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    position: relative;
    border-left: 1px solid rgba(255, 255, 255, 0.05);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    background: var(--bg-dark);
    z-index: 2;
    max-width: 420px;
    margin: 0 auto;
}

/* Sidebar for Live Bettors - Mobile Optimized */
.bettors-sidebar {
    width: 75px;
    background: rgba(15, 15, 25, 0.4);
    backdrop-filter: blur(12px);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    z-index: 10;
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    box-shadow: 5px 0 15px rgba(0, 0, 0, 0.3);
}

.sidebar-header {
    padding: 8px 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.bettor-count,
.total-bet-pool {
    font-size: 0.7rem;
    gap: 4px;
}

.bettors-list {
    flex: 1;
    overflow-y: auto;
    padding: 5px;
    scrollbar-width: none;
}

.bettors-list::-webkit-scrollbar {
    display: none;
}

.bettor-item {
    flex-direction: column;
    gap: 4px;
    padding: 6px 4px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    margin-bottom: 6px;
    text-align: center;
}

.bettor-info {
    justify-content: center;
}

.bettor-avatar {
    width: 32px;
    height: 32px;
    border-width: 1.5px;
}

.bettor-name {
    display: none;
    /* User requested to hide name */
}

.bettor-amount {
    font-size: 0.65rem;
    white-space: nowrap;
}

.bettor-multiplier {
    font-size: 0.6rem;
    padding: 1px 4px;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }

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

/* Header */
.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: rgba(10, 10, 15, 0.85);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-wrap: nowrap;
    min-height: 52px;
    gap: 8px;
}

.wallet-display {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.01));
    padding: 8px 14px;
    border-radius: 50px;
    display: flex;
    align-items: center;
    gap: 7px;
    border: 1px solid rgba(255, 204, 0, 0.3);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    flex-shrink: 1;
    min-width: 0;
}

.wallet-icon {
    font-size: 1.1rem;
    filter: drop-shadow(0 0 5px var(--gold));
}

#wallet-balance {
    font-weight: 800;
    color: var(--gold);
    font-size: 0.95rem;
    letter-spacing: 0.5px;
}

.top-icons {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.icon-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ccc;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.icon-btn:active {
    transform: scale(0.9);
    background: rgba(255, 255, 255, 0.15);
}

.icon-btn.close {
    color: #ff4d4d;
    border-color: rgba(255, 77, 77, 0.3);
}

/* Multiplier Ticker */
.multiplier-ticker {
    display: flex;
    gap: 8px;
    padding: 8px 12px;
    overflow-x: auto;
    scrollbar-width: none;
    background: rgba(0, 0, 0, 0.4);
    min-height: 38px;
}

.ticker-item {
    background: rgba(0, 229, 255, 0.05);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--secondary-color);
    border: 1px solid var(--secondary-glow);
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Game Area */
.game-area {
    flex: 1.5;
    /* Reduced from 2 to allow more space for controls on small screens */
    position: relative;
    padding: 0;
    /* Remove padding for full coverage */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 200px;
    /* Ensure game area doesn't disappear */
}

.canvas-container {
    flex: 1;
    background: #080a0a;
    position: relative;
    overflow: hidden;
    border: none;
    box-shadow: inset 0 0 80px rgba(0, 0, 0, 0.6);
}

.multiplier-display {
    position: absolute;
    top: 45%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2.2rem;
    /* Reduced base size */
    font-weight: 900;
    color: #fff;
    text-shadow: 0 0 30px rgba(255, 255, 255, 0.3);
    z-index: 5;
    transition: transform 0.1s;
}

.game-status {
    position: absolute;
    top: calc(36% + 70px);
    left: 50%;
    transform: translateX(-50%);
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 2px;
    color: #fff;
    text-transform: uppercase;
    z-index: 6;
}

/* Timer Overlay */
.timer-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.timer-overlay.active {
    display: flex;
}

.timer-circle {
    position: relative;
    width: 140px;
    /* Scaled down */
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.timer-circle svg {
    position: absolute;
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.timer-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.1);
    stroke-width: 6;
}

.timer-progress {
    fill: none;
    stroke: var(--secondary-color);
    stroke-width: 6;
    stroke-linecap: round;
    stroke-dasharray: 283;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 0.1s linear;
    filter: drop-shadow(0 0 8px var(--secondary-glow));
}

.timer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.timer-label {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #fff;
    opacity: 0.8;
    margin-bottom: 3px;
    max-width: 65px;
}

.timer-value {
    font-size: 2.2rem;
    font-weight: 900;
    color: #fff;
    font-family: 'Inter', sans-serif;
    text-shadow: 0 0 15px var(--secondary-glow);
}

/* Stats Bar */
.stats-bar {
    display: flex;
    justify-content: space-around;
    padding: 8px 10px;
    /* Reduced */
    background: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.4));
}

.stat-item {
    text-align: center;
}

.stat-label {
    font-size: 0.65rem;
    color: #777;
    font-weight: 700;
    margin-bottom: 3px;
    display: block;
}

.stat-value {
    font-weight: 800;
    font-size: 1rem;
}

#today-win {
    color: var(--success);
}

#last-result {
    color: var(--secondary-color);
}

/* Betting Section */
.betting-section {
    background: #111116;
    padding: 8px 12px;
    /* Reduced */
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    box-shadow: 0 -8px 25px rgba(0, 0, 0, 0.8);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.selected-bet-display {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    font-weight: 900;
    font-size: 1.2rem;
    margin-bottom: 15px;
    color: #fff;
}

.clear-btn {
    background: rgba(255, 77, 77, 0.2);
    border: 1px solid rgba(255, 77, 77, 0.4);
    color: #ff4d4d;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.clear-btn:hover {
    background: rgba(255, 77, 77, 0.4);
    transform: scale(1.1);
}

#current-bet-amount {
    color: var(--gold);
}

.chips-container {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 15px;
}

.chip {
    flex: 1;
    max-width: 55px;
    /* Prevent huge chips */
    aspect-ratio: 1;
    background: radial-gradient(circle, #2a2a32 0%, #15151a 100%);
    border: 3px dashed rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
    position: relative;
}

.chip::after {
    content: '';
    position: absolute;
    inset: 4px;
    border: 1px solid rgba(255, 255, 255, 0.03);
    border-radius: 50%;
}

.chip.active {
    border-style: solid;
    border-color: var(--primary-color);
    box-shadow: 0 0 25px var(--primary-glow), 0 10px 20px rgba(0, 0, 0, 0.6);
    background: radial-gradient(circle, var(--primary-color) 0%, #15151a 100%);
}

.bet-actions {
    display: flex;
    gap: 15px;
}

.action-btn {
    flex: 1;
    border: none;
    border-radius: 16px;
    font-weight: 900;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    margin: 20px auto;
    height: auto;
    padding: 10px 30px;
}

.bet-btn {
    background: linear-gradient(180deg, #00d2ff, #008cff);
    color: white;
    box-shadow: 0 6px 25px rgba(0, 140, 255, 0.4);
}

.bet-btn:active:not(:disabled) {
    transform: translateY(4px);
    box-shadow: 0 2px 10px rgba(0, 140, 255, 0.4);
}

.bet-btn.cancel-state {
    background: linear-gradient(180deg, #ff4d4d, #d32f2f);
    box-shadow: 0 6px 25px rgba(211, 47, 47, 0.4);
}

.cashout-btn {
    background: linear-gradient(180deg, #ff9800, #f44336);
    color: white;
    box-shadow: 0 6px 25px rgba(244, 67, 54, 0.4);
}

.cashout-btn:active:not(:disabled) {
    transform: translateY(4px);
    box-shadow: 0 2px 10px rgba(244, 67, 54, 0.4);
}

.action-btn:disabled {
    background: #222;
    color: #444;
    box-shadow: none;
    cursor: not-allowed;
}

#game-canvas {
    width: 100%;
    height: 100%;
}

.btn-sub {
    font-size: 0.85rem;
    font-weight: 700;
    opacity: 0.9;
    margin-top: 2px;
}

/* Modals - Redesigned */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(15px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.3s;
}

.modal.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: var(--bg-surface);
    width: 100%;
    max-width: 400px;
    border-radius: 30px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.8);
    transform: translateY(30px);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal.active .modal-content {
    transform: translateY(0);
}

.modal-header {
    padding: 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
}

.modal-header h2 {
    font-size: 1.4rem;
    font-weight: 900;
    background: linear-gradient(90deg, #fff, #888);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.close-modal {
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.modal-body {
    padding: 25px;
    max-height: 450px;
    overflow-y: auto;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: rgba(255, 255, 255, 0.03);
    margin-bottom: 12px;
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.history-val {
    font-weight: 900;
    font-size: 1.1rem;
}

.rule-card {
    display: flex;
    align-items: center;
    gap: 15px;
    background: rgba(255, 255, 255, 0.03);
    padding: 15px;
    margin-bottom: 12px;
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.rule-icon {
    font-size: 1.5rem;
    background: rgba(255, 255, 255, 0.05);
    width: 45px;
    height: 45px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.rule-card p {
    font-size: 0.95rem;
    line-height: 1.4;
    color: #bbb;
}

/* Lucky Winners Modal */
.lucky-modal {
    max-width: 450px;
    padding: 0;
    overflow: hidden;
    background: linear-gradient(180deg, #0a2d5e 0%, #051630 100%);
}

.lucky-header {
    background: linear-gradient(90deg, #1e5799 0%, #2989d8 50%, #207cca 100%);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    position: relative;
    justify-content: space-between;
}

.lucky-header h2 {
    color: #fff;
    margin: 0;
    font-size: 1.4rem;
    -webkit-text-fill-color: initial;
    background: none;
}

.trophy-icon {
    font-size: 1.8rem;
    filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.5));
}

.lucky-body {
    padding: 10px;
    background: rgba(0, 0, 0, 0.2);
}

.lucky-table {
    width: 100%;
    border-collapse: collapse;
}

.lucky-table th {
    text-align: left;
    color: #6a89cc;
    font-size: 0.75rem;
    padding: 10px 5px;
    text-transform: uppercase;
}

.lucky-table td {
    padding: 8px 5px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.lucky-reward,
.lucky-invest {
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 800;
    font-size: 0.85rem;
}

.lucky-reward {
    color: #fff;
}

.lucky-invest {
    color: var(--gold);
}

.lucky-type {
    background: #1e5799;
    color: #fff;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 800;
    box-shadow: 0 0 10px rgba(30, 87, 153, 0.5);
}

.lucky-user {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    font-weight: 600;
}

.lucky-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 1px solid #fff;
}

/* Balance Modal */
.balance-modal {
    text-align: center;
    padding: 30px;
}

.balance-icon {
    font-size: 3.5rem;
    margin-bottom: 15px;
    color: var(--primary-color);
}

/* Responsive Sidebar */
@media (max-width: 800px) {
    .bettors-sidebar {
        width: 60px;
        top: 0;
    }

    .bettor-avatar {
        width: 28px;
        height: 28px;
    }

    .bettor-amount {
        font-size: 0.6rem;
    }
}

/* Responsive adjustments */
@media (max-height: 740px) {
    .stats-bar {
        padding: 4px 10px;
    }

    .betting-section {
        padding: 6px 12px;
    }

    .selected-bet-display {
        margin-bottom: 6px;
        font-size: 1rem;
    }

    .chips-container {
        margin-bottom: 8px;
        gap: 6px;
    }

    .chip {
        max-width: 44px;
        font-size: 0.65rem;
    }

    .action-btn {
        height: 48px;
        border-radius: 10px;
        text-align: center;
        margin: 20px auto;
        padding: 0 30px;
    }

    .multiplier-display {
        font-size: 1.6rem;
    }

    .timer-circle {
        width: 110px;
        height: 110px;
    }

    .timer-value {
        font-size: 1.6rem;
    }

    .bettors-sidebar {
        width: 60px;
    }

    .bettor-avatar {
        width: 26px;
        height: 26px;
    }
}

@media (max-height: 600px) {
    .stats-bar {
        padding: 2px 10px;
    }

    .stat-value {
        font-size: 0.8rem;
    }

    .betting-section {
        padding: 4px 10px;
    }

    .selected-bet-display {
        margin-bottom: 2px;
        font-size: 0.9rem;
    }

    .chips-container {
        gap: 4px;
        margin-bottom: 4px;
    }

    .chip {
        max-width: 32px;
    }

    .action-btn {
        height: 38px;
        border-radius: 8px;
        font-size: 0.7rem;
    }

    .btn-sub {
        font-size: 0.6rem;
    }

    .multiplier-display {
        font-size: 1.3rem;
    }

    .top-header {
        min-height: 36px;
        padding: 2px 8px;
    }

    .wallet-display {
        padding: 2px 6px;
    }
}

/* Mobile header responsiveness */
@media (max-width: 400px) {
    .top-header {
        padding: 6px 8px;
        gap: 6px;
    }

    .wallet-display {
        padding: 6px 10px;
        gap: 5px;
    }

    .wallet-icon {
        font-size: 0.9rem;
    }

    #wallet-balance {
        font-size: 0.88rem;
        letter-spacing: 0;
    }

    .top-icons {
        gap: 5px;
    }

    .icon-btn {
        width: 32px;
        height: 32px;
        border-radius: 9px;
        font-size: 0.85rem;
    }
}

@media (max-width: 320px) {
    #wallet-balance {
        font-size: 0.78rem;
    }

    .wallet-display {
        padding: 5px 8px;
    }

    .icon-btn {
        width: 28px;
        height: 28px;
        font-size: 0.75rem;
    }

    .chips-container {
        gap: 4px;
    }

    .chip {
        font-size: 0.65rem;
    }
}