:root {
    --bg-dark: #0f1923;
    --bg-sidebar: #1a242d;
    --accent-color: #00e701;
    --accent-hover: #00c201;
    --text-primary: #ffffff;
    --text-secondary: #b1b1b1;
    --input-bg: #2f3b47;
    --border-radius: 8px;
    --peg-color: #ffffff;
    --ball-color: #ffcc00;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100%;
}

/* Sidebar Styling */
.sidebar {
    width: 300px;
    background-color: var(--bg-sidebar);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
    z-index: 10;
}

.logo h1 {
    color: var(--accent-color);
    font-size: 2rem;
    text-align: center;
    text-shadow: 0 0 10px rgba(0, 231, 1, 0.5);
    margin-bottom: 20px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 600;
}

.input-wrapper {
    position: relative;
}

input[type="number"],
select {
    width: 100%;
    background-color: var(--input-bg);
    border: 1px solid transparent;
    border-radius: var(--border-radius);
    padding: 12px;
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
    transition: 0.2s;
}

input[type="number"]:focus,
select:focus {
    border-color: var(--accent-color);
}

.currency {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

.quick-bets {
    display: flex;
    gap: 5px;
}

.quick-bets button {
    flex: 1;
    background-color: var(--input-bg);
    border: none;
    border-radius: 4px;
    color: var(--text-secondary);
    padding: 5px;
    cursor: pointer;
    font-size: 0.8rem;
}

.quick-bets button:hover {
    background-color: #3e4b57;
    color: var(--text-primary);
}

.primary-btn {
    background-color: var(--accent-color);
    color: #000;
    border: none;
    border-radius: var(--border-radius);
    padding: 15px;
    font-size: 1.2rem;
    font-weight: 800;
    cursor: pointer;
    transition: 0.2s;
    text-transform: uppercase;
    box-shadow: 0 0 15px rgba(0, 231, 1, 0.4);
}

.primary-btn:hover {
    background-color: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 0 20px rgba(0, 231, 1, 0.6);
}

.primary-btn:active {
    transform: translateY(0);
}

.auto-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Custom Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--input-bg);
    transition: .4s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--accent-color);
}

input:checked+.slider:before {
    transform: translateX(26px);
}

.balance-display {
    margin-top: auto;
    background-color: var(--input-bg);
    padding: 15px;
    border-radius: var(--border-radius);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid #3e4b57;
}

#balance {
    color: var(--accent-color);
    font-weight: 700;
    font-size: 1.1rem;
}

/* Game Area Styling */
.game-area {
    flex: 1;
    display: flex;
    justify-content: center;
    /* align-items: center; Remove to allow top-scroll if needed */
    background: radial-gradient(circle at center, #1b2630 0%, #0f1923 100%);
    position: relative;
    padding: 20px;
    overflow: auto;
    /* Allow scrolling */
}

.canvas-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: min-content;
    /* Ensure container grows with canvas */
    margin: auto;
    /* Center in scrollable area */
}

#game-canvas {
    /* Border mainly for debugging, can remove later */
    /* border: 1px solid rgba(255,255,255,0.1); */
}

/* History Panel */
.history-panel {
    width: 250px;
    background-color: var(--bg-sidebar);
    border-left: 1px solid #2f3b47;
    display: flex;
    flex-direction: column;
}

.history-panel h3 {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid #2f3b47;
    font-size: 1rem;
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-item {
    background-color: var(--input-bg);
    padding: 10px;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    animation: slideIn 0.3s ease-out;
}

.history-item.win {
    border-left: 3px solid var(--accent-color);
}

.history-item.loss {
    border-left: 3px solid #ff4444;
}

.multiplier-badge {
    background-color: rgba(255, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8rem;
}

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

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

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-sidebar);
}

::-webkit-scrollbar-thumb {
    background: #2f3b47;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #3e4b57;
}

/* Responsive Design */
@media (max-width: 900px) {
    .app-container {
        flex-direction: column;
        height: auto;
        overflow-y: auto;
    }

    body {
        overflow-y: auto;
        /* Allow body scroll on mobile */
        height: auto;
    }

    .sidebar {
        width: 100%;
        order: 2;
        /* Controls below game */
        padding: 15px;
    }

    .game-area {
        order: 1;
        min-height: 60vh;
        /* Ensure game has space */
        padding: 10px;
    }

    .history-panel {
        width: 100%;
        order: 3;
        max-height: 300px;
        /* Limit height */
        border-left: none;
        border-top: 1px solid #2f3b47;
    }

    .control-group {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    .control-group label {
        margin-bottom: 0;
        margin-right: 10px;
    }

    .input-wrapper,
    select {
        flex: 1;
    }

    /* Stack the Play button and Auto toggle */
    #play-btn {
        width: 100%;
    }

    .auto-control {
        margin-top: 10px;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .quick-bets {
        flex-wrap: wrap;
    }

    .control-group {
        flex-direction: column;
        align-items: stretch;
    }

    .control-group label {
        margin-bottom: 5px;
    }
}