/* ===== BASE STYLES ===== */
body {
    margin: 0;
    overflow-x: hidden;
    font-family: 'Arial', sans-serif;
    background: #f0f0f0;
    color: #333;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ===== GAME CONTAINER ===== */
#gameContainer {
    display: flex;
    justify-content: center;
    padding: 10px;
    flex-grow: 1;
}

#gameArea {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 60%;
    max-width: 800px;
}

#sidePanel {
    width: 35%;
    max-width: 400px;
    margin-left: 20px;
    display: flex;
    flex-direction: column;
}

/* ===== TYPOGRAPHY ===== */
h1, h2 {
    margin: 10px 0;
    text-align: center;
}

h1 {
    font-size: clamp(1.5rem, 4vw, 2.5rem);
}

h2 {
    font-size: 1.5rem;
    color: #444;
}

/* ===== CANVAS ===== */
canvas {
    background: linear-gradient(to bottom, #444, #222);
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    width: 100%;
    height: auto;
    aspect-ratio: 16/9;
}

/* ===== PANELS ===== */
#controls, #leaderboard, #history {
    width: 100%;
    margin: 10px 0;
    padding: 15px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

#settingsPanel {
    position: sticky;
    top: 10px;
    background: white;
    padding: 10px;
    border-radius: 5px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
    z-index: 100;
    width: 100%;
    margin: 0 0 10px 0;
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
}

/* ===== BUTTONS ===== */
button {
    padding: 12px 25px;
    font-size: 16px;
    margin: 8px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s;
}

#betButton {
    background: #4CAF50;
    color: white;
}

#betButton:hover {
    background: #45a049;
}

#cashOutButton {
    background: #f39c12;
    color: white;
}

#cashOutButton:hover {
    background: #e67e22;
}

#cashOutButton:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.touch-btn {
    padding: 15px 25px;
    background: #4CAF50;
    color: white;
    border-radius: 5px;
    font-size: 18px;
    user-select: none;
    text-align: center;
    flex: 1;
    margin: 0 5px;
}

.game-alert {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    z-index: 300;
    max-width: 80%;
    text-align: center;
}

.game-alert button {
    padding: 8px 20px;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    margin-top: 15px;
}

/* ===== FORM ELEMENTS ===== */
input[type="number"] {
    padding: 8px;
    text-align: center;
    border-radius: 5px;
    border: 1px solid #ddd;
}

#betAmount {
    width: 80px;
}

/* ===== STATS ===== */
.stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin: 15px 0;
}

.stat-box {
    background: #f8f8f8;
    padding: 10px;
    border-radius: 5px;
    text-align: center;
}

/* ===== PROGRESS BAR ===== */
.progress-container {
    width: 100%;
    background-color: #ddd;
    border-radius: 5px;
    margin: 10px 0;
}

.progress-bar {
    height: 20px;
    background-color: #4CAF50;
    border-radius: 5px;
    width: 0%;
    transition: width 0.3s;
}

/* ===== HISTORY ===== */
.history-item {
    padding: 5px;
    border-bottom: 1px solid #eee;
}

.win {
    color: #4CAF50;
}

.loss {
    color: #e74c3c;
}

/* ===== TOOLTIPS ===== */
.tooltip {
    position: relative;
    display: inline-block;
    cursor: help;
}

.tooltip .tooltiptext {
    visibility: hidden;
    width: 200px;
    background-color: #555;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 5px;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    margin-left: -100px;
    opacity: 0;
    transition: opacity 0.3s;
}

.tooltip:hover .tooltiptext {
    visibility: visible;
    opacity: 1;
}

/* ===== BONUS ===== */
#bonusInfo {
    display: none;
    background: gold;
    padding: 10px;
    border-radius: 5px;
    margin: 10px 0;
}

.bonus-active {
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 215, 0, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(255, 215, 0, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(255, 215, 0, 0);
    }
}

/* ===== BET CONTROLS ===== */
#betControls {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
}

.bet-options {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    margin: 20px 0;
}

.bet-option {
    margin: 10px;
    text-align: center;
}

.bet-option input {
    width: 50px;
    margin: 0 5px;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 1200px) {
    #gameContainer {
        flex-direction: column;
        align-items: center;
    }

    #gameArea, #sidePanel {
        width: 95%;
        margin-left: 0;
    }
}

@media (max-width: 768px) {
    .stats {
        grid-template-columns: 1fr 1fr;
    }

    #betControls {
        flex-direction: column;
    }

    #betAmount {
        width: 100%;
        margin-bottom: 10px;
    }

    #touchControls {
        display: flex;
    }
}

@media (max-width: 480px) {
    .stats {
        grid-template-columns: 1fr;
    }

    button {
        padding: 10px 15px;
        font-size: 14px;
    }

    #settingsPanel {
        flex-direction: column;
    }

    #settingsPanel button {
        margin: 5px 0;
        width: 100%;
    }
}