/* Global Reset & Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    user-select: none;
}

body {
    background-color: #0f0f13;
    color: #ffffff;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* Main Container */
.game-container {
    width: 100%;
    max-width: 1200px;
    height: 90vh;
    display: flex;
    gap: 20px;
    padding: 20px;
}

/* Sidebar (Betting Controls) */
.sidebar {
    width: 350px;
    background: #1a1a21;
    border-radius: 16px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    border: 1px solid #2a2a35;
}

.logo-area {
    font-size: 24px;
    font-weight: 800;
    color: #eebb4d;
    /* Monkey Yellow/Gold */
    text-align: center;
    margin-bottom: 10px;
    letter-spacing: 1px;
}

.balance-card {
    background: #23232d;
    padding: 15px;
    border-radius: 12px;
    text-align: center;
    border: 1px solid #333340;
}

.balance-label {
    font-size: 12px;
    color: #888899;
    margin-bottom: 4px;
}

.balance-amount {
    font-size: 24px;
    font-weight: bold;
    color: #ffffff;
}

.bet-controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.input-group label {
    display: block;
    font-size: 12px;
    color: #888899;
    margin-bottom: 8px;
}

.bet-input-wrapper {
    position: relative;
    display: flex;
    background: #0b0b0f;
    border-radius: 8px;
    border: 1px solid #333340;
    padding: 2px;
}

.bet-input {
    flex: 1;
    background: transparent;
    border: none;
    color: white;
    font-size: 18px;
    padding: 12px;
    text-align: right;
    font-weight: bold;
    outline: none;
}

.currency-addon {
    padding: 12px;
    color: #888899;
    font-weight: bold;
}

.quick-bets {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.quick-btn {
    background: #2a2a35;
    border: none;
    color: #fff;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
    font-weight: 500;
}

.quick-btn:hover {
    background: #3a3a45;
}

/* Action Button */
.main-btn {
    width: 100%;
    padding: 18px;
    border-radius: 12px;
    border: none;
    font-size: 20px;
    font-weight: 800;
    cursor: pointer;
    text-transform: uppercase;
    transition: all 0.2s;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.btn-bet {
    background: linear-gradient(135deg, #28a745 0%, #208e3b 100%);
    color: white;
}

.btn-bet:hover {
    filter: brightness(1.1);
}

.btn-bet:active {
    transform: scale(0.98);
}

.btn-cashout {
    background: linear-gradient(135deg, #ffc107 0%, #ff9800 100%);
    color: black;
}

.btn-cashout:hover {
    filter: brightness(1.1);
}

.btn-waiting {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    color: white;
    opacity: 0.8;
    cursor: not-allowed;
}

/* History */
.history-section {
    margin-top: auto;
}

.history-title {
    font-size: 12px;
    color: #666;
    margin-bottom: 8px;
}

.history-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    height: 70px;
    overflow: hidden;
    align-content: flex-start;
}

.history-pill {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: bold;
    background: #2a2a35;
    color: #aaa;
}

.history-pill.win {
    background: rgba(40, 167, 69, 0.2);
    color: #28a745;
}

.history-pill.loss {
    background: rgba(220, 53, 69, 0.2);
    color: #dc3545;
}

.history-pill.big-win {
    background: rgba(255, 193, 7, 0.2);
    color: #ffc107;
    text-shadow: 0 0 5px rgba(255, 193, 7, 0.5);
}

/* Game Stage */
.stage-area {
    flex: 1;
    background: #111;
    border-radius: 16px;
    position: relative;
    overflow: hidden;
    border: 1px solid #2a2a35;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

/* Background & Objects */
.background-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('bg_tree.jpg') repeat-y center top;
    background-size: cover;
    z-index: 1;
    /* We will animate background-position-y in JS for infinite scroll */
}

/* Monkey */
.monkey-container {
    position: absolute;
    bottom: 20%;
    left: 50%;
    transform: translateX(-50%);
    width: 300px;
    height: 300px;
    z-index: 5;
    transition: bottom 0.2s linear;
}

@keyframes climb {
    0% {
        transform: translateY(0) scaleY(1) rotate(0deg);
    }

    25% {
        transform: translateY(2px) scaleY(0.95) scaleX(1.05) rotate(-1deg);
    }

    50% {
        transform: translateY(0) scaleY(1) rotate(0deg);
    }

    75% {
        transform: translateY(-4px) scaleY(1.05) scaleX(0.95) rotate(1deg);
    }

    100% {
        transform: translateY(0) scaleY(1) rotate(0deg);
    }
}

/* Speed up animation for more vigorous climbing */
.monkey-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: brightness(1.05);
    animation: climb 0.4s infinite linear;
}

/* Central HUD */
.hud-layer {
    position: absolute;
    inset: 0;
    z-index: 10;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    pointer-events: none;
}

.multiplier-display {
    font-size: 8rem;
    font-weight: 900;
    color: #ffffff;
    text-shadow: 0 0 30px rgba(0, 0, 0, 0.8);
    font-variant-numeric: tabular-nums;
    letter-spacing: -2px;
}

.multiplier-display.crashed {
    color: #dc3545;
    text-shadow: 0 0 30px rgba(220, 53, 69, 0.4);
}

.status-text {
    font-size: 1.5rem;
    font-weight: 600;
    margin-top: 10px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: #eebb4d;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

.profit-popup {
    position: absolute;
    top: 40%;
    background: rgba(40, 167, 69, 0.9);
    color: white;
    padding: 15px 30px;
    border-radius: 50px;
    font-size: 24px;
    font-weight: bold;
    transform: translateY(20px);
    opacity: 0;
    transition: all 0.3s ease-out;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.profit-popup.show {
    transform: translateY(0);
    opacity: 1;
}

/* Loading/Countdown Bar */
.progress-bar-container {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    z-index: 20;
}

.progress-bar {
    height: 100%;
    background: #eebb4d;
    width: 0%;
    transition: width 0.1s linear;
}

/* Responsive */
/* Responsive */
@media (max-width: 800px) {
    .game-container {
        flex-direction: column-reverse; /* Controls at bottom for mobile */
        padding: 0;
        height: 100vh;
        gap: 0;
    }

    .sidebar {
        width: 100%;
        border-radius: 24px 24px 0 0; /* Rounded top corners only */
        padding: 20px;
        flex-shrink: 0;
        z-index: 50; /* Ensure controls are above background if overlap */
        box-shadow: 0 -4px 20px rgba(0,0,0,0.5);
    }

    .stage-area {
        border-radius: 0;
        border: none;
        box-shadow: none;
    }
    
    .monkey-container {
        width: 250px;
        height: 250px;
        bottom: 15%;
    }

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

@media (max-width: 480px) {
    .sidebar {
        padding: 15px;
        gap: 12px;
    }

    .logo-area {
        font-size: 18px;
        margin-bottom: 5px;
    }

    .balance-card {
        padding: 10px;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    .balance-label { margin-bottom: 0; }
    .balance-amount { font-size: 18px; }

    .bet-controls {
        gap: 10px;
    }

    .input-group label {
        display: none; /* Hide label to save space on very small screens */
    }

    .quick-bets {
        grid-template-columns: repeat(3, 1fr); /* 3 columns for easier tapping */
    }

    .quick-btn {
        padding: 10px 5px;
        font-size: 13px;
    }

    .main-btn {
        padding: 15px;
        font-size: 18px;
    }

    /* Adjust game area */
    .monkey-container {
        width: 200px; /* Smaller monkey for mobile */
        height: 200px;
        bottom: 10%;
    }

    .multiplier-display {
        font-size: 4rem; /* Smaller font to fit */
    }
    
    .status-text {
        font-size: 1rem;
    }

    .history-list {
        height: 40px; /* Compact history */
        flex-wrap: nowrap; /* Horizontal scroll if needed */
        overflow-x: auto;
        overflow-y: hidden;
    }
    
    .history-section {
        margin-top: 5px;
    }
}