/* Festival Balloon Crash — Sunset Sky Style */

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    /* Theme colors (also read by BalloonRenderer via getComputedStyle) */
    --theme-bg-1:       #ff9966;   /* sky top — peach */
    --theme-bg-2:       #ff5e7e;   /* sky mid — pink */
    --theme-bg-3:       #5a2a82;   /* sky bottom — twilight */
    --theme-cloud:      #fff1d6;
    --theme-balloon-1:  #e63946;   /* canopy stripe 1 */
    --theme-balloon-2:  #ff8c42;   /* canopy stripe 2 */
    --theme-basket:     #6b4423;
    --theme-accent:     #ffd60a;   /* multiplier glow */
    --theme-accent-2:   #ff8c42;
    --theme-danger:     #ff6b3d;
    --theme-extreme:    #ff2d55;

    --text-white:       #fff8ec;
    --text-muted:       rgba(255, 248, 236, 0.72);
    --text-dark:        #2b1247;

    --base-font: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: var(--base-font);
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(180deg,
        var(--theme-bg-1) 0%,
        var(--theme-bg-2) 50%,
        var(--theme-bg-3) 100%);
    min-height: calc(100dvh - 3.5rem);
    color: var(--text-white);
}

/* ============ SUNSET BACKDROP ============ */
#sunset-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(circle at 50% 95%, rgba(255, 221, 102, 0.65) 0%, transparent 35%),
        radial-gradient(circle at 20% 20%, rgba(255, 248, 200, 0.18) 0%, transparent 40%),
        radial-gradient(circle at 80% 30%, rgba(255, 130, 160, 0.22) 0%, transparent 45%);
}

/* ============ SCREENS ============ */
.screen {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: linear-gradient(180deg,
        var(--theme-bg-1) 0%,
        var(--theme-bg-2) 50%,
        var(--theme-bg-3) 100%);
    color: var(--text-white);
    z-index: 1000;
}

.screen.hidden { display: none; }

.loading-spinner {
    width: 3.25rem;
    height: 3.25rem;
    border: 0.2rem solid rgba(255, 255, 255, 0.25);
    border-top-color: var(--theme-accent);
    border-radius: 50%;
    animation: spinAnim 1s linear infinite;
}

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

#loading-screen p {
    margin-top: 1rem;
    color: var(--text-white);
    font-size: 0.95rem;
    letter-spacing: 0.06rem;
}

.login-content { text-align: center; }
.login-icon { font-size: 3.5rem; margin-bottom: 1rem; }
.login-content h2 { color: var(--theme-accent); margin-bottom: 0.5rem; }
.login-content p { color: var(--text-muted); }

/* ============ GAME CONTAINER ============ */
#game-container {
    width: 100%;
    max-width: 31rem;
    height: 100%;
    max-height: 56rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem 0.75rem;
    position: relative;
    z-index: 1;
}

#game-container.hidden { display: none; }

/* ============ HEADER ============ */
#game-header {
    width: 100%;
    padding: 0.4rem 0;
    display: flex;
    justify-content: center;
}

.balance-display {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.18) 0%, rgba(255, 255, 255, 0.05) 100%);
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 1.25rem;
    padding: 0.45rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    box-shadow: 0 0 1rem rgba(255, 200, 100, 0.25);
    backdrop-filter: blur(4px);
}

.balance-label { color: var(--text-muted); font-size: 0.75rem; letter-spacing: 0.03rem; }

#balance-value {
    color: var(--theme-accent);
    font-size: 1.25rem;
    font-weight: 700;
    min-width: 4.4rem;
    text-align: right;
    text-shadow: 0 0 0.6rem rgba(255, 214, 10, 0.55);
}

.balance-currency { color: var(--theme-accent-2); font-size: 0.7rem; font-weight: 700; }

/* ============ HISTORY BAR ============ */
.history-bar {
    width: 100%;
    display: flex;
    gap: 0.3rem;
    padding: 0.4rem 0.25rem;
    overflow-x: auto;
    scrollbar-width: none;
    min-height: 1.8rem;
}
.history-bar::-webkit-scrollbar { display: none; }

.history-item {
    flex-shrink: 0;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.2rem 0.55rem;
    border-radius: 1rem;
    background: rgba(0, 0, 0, 0.28);
    color: var(--text-white);
    border: 1px solid rgba(255, 255, 255, 0.18);
    letter-spacing: 0.02rem;
}

.history-item.win {
    background: linear-gradient(180deg, rgba(76, 200, 130, 0.85), rgba(40, 160, 100, 0.85));
    border-color: rgba(255, 255, 255, 0.4);
}

.history-item.crash {
    background: linear-gradient(180deg, rgba(255, 80, 80, 0.85), rgba(190, 40, 40, 0.85));
    border-color: rgba(255, 255, 255, 0.3);
}

/* ============ GAME AREA ============ */
.game-area {
    width: 100%;
    flex: 1;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0.4rem 0;
    min-height: 18rem;
}

#balloon-canvas {
    width: 100%;
    max-width: 25rem;
    height: auto;
    aspect-ratio: 400 / 360;
    border-radius: 1rem;
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.18),
        0 1.2rem 2rem rgba(0, 0, 0, 0.35);
    display: block;
}

/* ============ MULTIPLIER DISPLAY ============ */
.multiplier-display {
    position: absolute;
    top: 38%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 4rem;
    font-weight: 900;
    color: var(--theme-accent);
    text-shadow:
        0 0 1rem rgba(255, 214, 10, 0.7),
        0 0 2.4rem rgba(255, 214, 10, 0.4),
        0 0.15rem 0.4rem rgba(0, 0, 0, 0.55);
    letter-spacing: 0.05rem;
    line-height: 1;
    pointer-events: none;
    z-index: 5;
    transition: color 0.25s ease, text-shadow 0.25s ease, transform 0.2s ease;
}

.multiplier-display .mult-x {
    font-size: 2.4rem;
    margin-left: 0.15rem;
    opacity: 0.85;
}

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

.multiplier-display.danger {
    color: var(--theme-danger);
    text-shadow:
        0 0 1.1rem rgba(255, 107, 61, 0.75),
        0 0 2.6rem rgba(255, 107, 61, 0.5);
}

.multiplier-display.extreme {
    color: var(--theme-extreme);
    text-shadow:
        0 0 1.2rem rgba(255, 45, 85, 0.85),
        0 0 3rem rgba(255, 45, 85, 0.55);
    animation: extremePulse 0.6s ease-in-out infinite;
}

@keyframes extremePulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50%      { transform: translate(-50%, -50%) scale(1.07); }
}

/* ============ CRASH / WIN BANNERS ============ */
.crash-display, .win-display {
    position: absolute;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(160deg, rgba(20, 8, 36, 0.95) 0%, rgba(60, 20, 80, 0.95) 100%);
    padding: 1rem 2rem;
    border-radius: 1rem;
    text-align: center;
    z-index: 10;
    animation: bannerPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 0.5rem 1.6rem rgba(0, 0, 0, 0.5);
}

.crash-display { border: 2px solid var(--theme-extreme); }
.win-display   { border: 2px solid var(--theme-accent); }

.crash-display.hidden, .win-display.hidden { display: none; }

@keyframes bannerPop {
    0%   { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
    100% { transform: translate(-50%, -50%) scale(1);   opacity: 1; }
}

.crash-text {
    color: var(--theme-extreme);
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: 0.2rem;
    text-shadow: 0 0 0.8rem rgba(255, 45, 85, 0.6);
}

.crash-multiplier {
    color: var(--text-white);
    font-size: 1.3rem;
    font-weight: 700;
    margin-top: 0.25rem;
}

.win-text {
    color: var(--theme-accent);
    font-size: 1.3rem;
    font-weight: 800;
    letter-spacing: 0.2rem;
    text-shadow: 0 0 0.8rem rgba(255, 214, 10, 0.6);
}

.win-multiplier {
    color: var(--text-white);
    font-size: 1.4rem;
    font-weight: 700;
    margin-top: 0.2rem;
}

.win-amount {
    color: #6cf09c;
    font-size: 1.8rem;
    font-weight: 800;
    margin-top: 0.15rem;
    text-shadow: 0 0 0.7rem rgba(108, 240, 156, 0.5);
}

/* ============ BET CONTROLS ============ */
#bet-controls {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.4rem 0.25rem;
    flex-wrap: wrap;
}

#bet-controls.hidden { display: none; }

.bet-label {
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.07rem;
    text-transform: uppercase;
}

.bet-buttons { display: flex; gap: 0.35rem; }

.bet-btn {
    width: 3rem;
    height: 2rem;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 0.4rem;
    color: var(--text-white);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
    backdrop-filter: blur(3px);
}

.bet-btn:hover:not(:disabled) {
    border-color: var(--theme-accent);
    background: rgba(255, 214, 10, 0.18);
}

.bet-btn.active {
    background: linear-gradient(160deg, var(--theme-accent) 0%, var(--theme-accent-2) 100%);
    color: var(--text-dark);
    border-color: rgba(255, 255, 255, 0.5);
    box-shadow: 0 0.15rem 0.7rem rgba(255, 214, 10, 0.5);
}

.bet-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* ============ ACTION BUTTON (LAUNCH / CASH OUT) ============ */
#action-button {
    width: 18rem;
    max-width: 90%;
    height: 3.6rem;
    background: linear-gradient(160deg, var(--theme-balloon-2) 0%, var(--theme-balloon-1) 100%);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 2rem;
    cursor: pointer;
    box-shadow:
        0 0.3rem 1.4rem rgba(230, 57, 70, 0.45),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    transition: all 0.18s ease;
    margin: 0.55rem 0 0.3rem;
}

#action-button:hover:not(:disabled) {
    transform: translateY(-0.12rem);
    box-shadow: 0 0.5rem 1.9rem rgba(255, 140, 66, 0.55);
}

#action-button:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 0.15rem 0.6rem rgba(230, 57, 70, 0.3);
}

#action-button.cashout {
    background: linear-gradient(160deg, #ffd60a 0%, #ff8c42 60%, #e63946 100%);
    animation: cashoutGlow 1.4s ease-in-out infinite;
}

#action-button.disabled-look,
#action-button:disabled {
    background: linear-gradient(160deg, #4a3a55 0%, #2c2238 100%);
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: none;
    cursor: not-allowed;
    animation: none;
}

@keyframes cashoutGlow {
    0%, 100% { box-shadow: 0 0.3rem 1.4rem rgba(255, 214, 10, 0.5); }
    50%      { box-shadow: 0 0.3rem 2.4rem rgba(230, 57, 70, 0.8); }
}

#action-text {
    color: var(--text-dark);
    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: 0.18rem;
}

#action-button.disabled-look #action-text,
#action-button:disabled #action-text {
    color: #888;
}

/* ============ GAME TITLE ============ */
.game-title {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
    padding: 0.25rem 0 0.4rem;
}

.title-small {
    color: rgba(255, 248, 236, 0.55);
    font-size: 0.7rem;
    letter-spacing: 0.12rem;
    text-transform: uppercase;
}

.title-big {
    color: var(--theme-accent);
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: 0.12rem;
    text-shadow: 0 0 0.8rem rgba(255, 214, 10, 0.45);
}

/* ============ MESSAGE DISPLAY ============ */
#message-display {
    position: absolute;
    bottom: 9rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(20, 8, 36, 0.94);
    padding: 0.5rem 1.3rem;
    border-radius: 0.5rem;
    border: 1px solid rgba(255, 214, 10, 0.4);
    z-index: 100;
    white-space: nowrap;
}

#message-display.hidden { display: none; }
#message-text { color: var(--text-white); font-size: 0.85rem; }

/* ============ PARTICLES (DOM overlay) ============ */
#particles-container {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1000;
}

.particle {
    position: absolute;
    font-size: 1.3rem;
    animation: particleFall 2s ease-out forwards;
}

@keyframes particleFall {
    0%   { opacity: 1; transform: translateY(0) rotate(0deg) scale(1); }
    100% { opacity: 0; transform: translateY(80vh) rotate(540deg) scale(0.3); }
}

/* ============ RESPONSIVE ============ */
@media (max-width: 25rem) {
    .multiplier-display { font-size: 3.2rem; }
    .multiplier-display .mult-x { font-size: 1.9rem; }
    #action-button { width: 14rem; height: 3.2rem; }
    #action-text { font-size: 1.05rem; }
    .bet-btn { width: 2.65rem; height: 1.85rem; font-size: 0.8rem; }
}

@media (max-height: 44rem) {
    .game-area { min-height: 15rem; }
    .multiplier-display { font-size: 3rem; top: 40%; }
    .game-title { padding: 0.1rem 0; }
}

/* === clone palette override === */
body { filter: hue-rotate(60deg) saturate(110%); }
