/* ============================================================
   Bubble Wrap Pop — Soft Pastel Style
   ============================================================ */

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

:root {
    /* Palette */
    --bg-soft:        #fef6f9;
    --bg-soft-2:      #fde9f0;
    --bg-card:        #ffffff;

    --bubble-blue:    #a4d8e1;
    --bubble-blue-2:  #c5e7ec;
    --bubble-pink:    #f5c6d6;
    --bubble-pink-2:  #fadbe5;
    --bubble-shadow:  rgba(141, 167, 184, 0.25);

    --popped:         #e8e6ec;
    --popped-edge:    #d4d1da;

    --accent-gold:    #ffd166;
    --accent-gold-2:  #ffb84d;
    --accent-silver:  #c0c8d0;
    --accent-silver-2:#e7ecf1;
    --accent-jackpot: #ff8fa3;
    --accent-jackpot-2:#ffb3c0;

    --text-primary:   #2d3142;
    --text-secondary: #8d8fa3;
    --text-muted:     #b8bac5;

    --success:        #6bcb77;
    --warn:           #ffb84d;
    --danger:         #ff6b8a;

    /* Shadows */
    --shadow-soft:    0 0.25rem 0.75rem rgba(141, 167, 184, 0.18);
    --shadow-bubble:  0 0.25rem 0.5rem rgba(141, 167, 184, 0.22), inset 0.15rem 0.15rem 0.4rem rgba(255,255,255,0.7);
    --shadow-card:    0 0.5rem 1.5rem rgba(141, 167, 184, 0.18);

    /* Radii */
    --r-sm: 0.5rem;
    --r-md: 0.75rem;
    --r-lg: 1.25rem;
    --r-pill: 999rem;

    /* Sizes */
    --max-width: 31rem;
}

html, body {
    width: 100%;
    min-height: 100%;
    font-family: 'Quicksand', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: var(--text-primary);
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
}

body {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    background:
        radial-gradient(ellipse at 20% 0%,  rgba(255, 209, 220, 0.55) 0%, transparent 55%),
        radial-gradient(ellipse at 80% 20%, rgba(195, 224, 240, 0.55) 0%, transparent 55%),
        linear-gradient(180deg, var(--bg-soft) 0%, var(--bg-soft-2) 100%);
    min-height: 100dvh;
    padding: 0.75rem 0.5rem;
    overflow-x: hidden;
}

/* ============ SCREENS ============ */
.screen {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: var(--bg-soft);
    color: var(--text-primary);
    z-index: 1000;
}

.screen.hidden { display: none; }

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

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

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

.login-content { text-align: center; padding: 0 1.5rem; }
.login-icon { font-size: 3.5rem; margin-bottom: 1rem; }
.login-content h2 { color: var(--text-primary); margin-bottom: 0.5rem; font-size: 1.4rem; }
.login-content p { color: var(--text-secondary); }

/* ============ GAME CONTAINER ============ */
#game-container {
    width: 100%;
    max-width: var(--max-width);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    padding: 0.5rem;
    position: relative;
    z-index: 1;
}

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

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

.balance-display {
    background: var(--bg-card);
    border: 0.075rem solid rgba(164, 216, 225, 0.5);
    border-radius: var(--r-pill);
    padding: 0.5rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    box-shadow: var(--shadow-soft);
}

.balance-label {
    color: var(--text-secondary);
    font-size: 0.75rem;
    letter-spacing: 0.03rem;
    text-transform: uppercase;
    font-weight: 600;
}

#balance-value {
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 700;
    min-width: 3.5rem;
    text-align: right;
    transition: transform 0.3s ease, color 0.3s ease;
}

.balance-currency {
    color: var(--accent-jackpot);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.05rem;
}

/* ============ TITLE ============ */
.game-title {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.2rem 0;
}

.title-bubble {
    color: var(--text-secondary);
    font-size: 0.85rem;
    letter-spacing: 0.15rem;
    text-transform: uppercase;
    font-weight: 600;
}

.title-pop {
    color: var(--accent-jackpot);
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: 0.05rem;
    text-shadow: 0 0.15rem 0.4rem rgba(255, 143, 163, 0.35);
}

/* ============ STATS ROW ============ */
#stats-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-card);
    border-radius: var(--r-md);
    padding: 0.5rem 0.75rem;
    box-shadow: var(--shadow-soft);
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
    flex: 1;
}

.stat-label {
    font-size: 0.65rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06rem;
    font-weight: 700;
}

.stat-value {
    font-size: 1rem;
    color: var(--text-primary);
    font-weight: 700;
}

#current-multi { color: var(--accent-jackpot); }

/* ============ TIMER BAR ============ */
#timer-bar {
    width: 100%;
    height: 0.55rem;
    background: rgba(141, 167, 184, 0.15);
    border-radius: var(--r-pill);
    overflow: hidden;
    box-shadow: inset 0 0.1rem 0.2rem rgba(141, 167, 184, 0.12);
}

#timer-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, var(--success), #a8e2b1);
    border-radius: var(--r-pill);
    transition: width 0.95s linear, background 0.3s ease;
}

#timer-fill.warn {
    background: linear-gradient(90deg, var(--warn), #ffd699);
}

#timer-fill.danger {
    background: linear-gradient(90deg, var(--danger), #ffabc0);
}

#timer-bar.pulse {
    animation: timerPulse 1s ease-in-out infinite;
}

@keyframes timerPulse {
    0%, 100% { box-shadow: inset 0 0.1rem 0.2rem rgba(141, 167, 184, 0.12); }
    50%      { box-shadow: 0 0 0.6rem rgba(255, 107, 138, 0.6); }
}

/* ============ GRID ============ */
#grid-wrapper {
    position: relative;
    background: var(--bg-card);
    border-radius: var(--r-lg);
    padding: 0.75rem;
    box-shadow: var(--shadow-card);
    border: 0.075rem solid rgba(164, 216, 225, 0.3);
}

#bubble-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 0.35rem;
    padding: 0.25rem;
}

/* ============ BUBBLE ============ */
.bubble {
    position: relative;
    aspect-ratio: 1 / 1;
    border: none;
    cursor: pointer;
    padding: 0;
    background:
        radial-gradient(circle at 32% 28%, var(--bubble-blue-2) 0%, var(--bubble-blue) 55%, #87c4d0 100%);
    border-radius: 50%;
    box-shadow: var(--shadow-bubble);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
    overflow: visible;
    animation: bubbleAppear 0.4s ease-out backwards, bubbleBreathe 4s ease-in-out infinite;
}

.bubble.variant-pink {
    background:
        radial-gradient(circle at 32% 28%, var(--bubble-pink-2) 0%, var(--bubble-pink) 55%, #e09cb1 100%);
}

@keyframes bubbleAppear {
    0%   { opacity: 0; transform: scale(0.4); }
    100% { opacity: 1; transform: scale(1); }
}

@keyframes bubbleBreathe {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.02); }
}

.bubble:hover:not(.popped):not(.placeholder),
.bubble:active:not(.popped):not(.placeholder) {
    transform: scale(1.06);
    box-shadow:
        0 0.35rem 0.7rem rgba(141, 167, 184, 0.3),
        inset 0.2rem 0.2rem 0.5rem rgba(255,255,255,0.8);
}

.bubble.placeholder {
    cursor: default;
    opacity: 0.7;
    animation: bubbleAppear 0.4s ease-out backwards, bubbleBreathe 4s ease-in-out infinite;
}

/* Bubble shine (top-left highlight) */
.bubble-shine {
    position: absolute;
    top: 12%;
    left: 18%;
    width: 32%;
    height: 32%;
    background: radial-gradient(circle, rgba(255,255,255,0.85) 0%, rgba(255,255,255,0) 70%);
    border-radius: 50%;
    pointer-events: none;
}

/* Hidden reveal (prize icon) */
.bubble-reveal {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    opacity: 0;
    transform: scale(0.4);
    transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
}

.bubble-reveal.show {
    opacity: 1;
    transform: scale(1);
}

.bubble-reveal.prize-gold {
    filter: drop-shadow(0 0 0.5rem rgba(255, 209, 102, 0.85));
    animation: prizeSparkle 0.8s ease;
}

.bubble-reveal.prize-silver {
    filter: drop-shadow(0 0 0.4rem rgba(192, 200, 208, 0.85));
    animation: prizeSparkle 0.8s ease;
}

.bubble-reveal.prize-jackpot {
    filter: drop-shadow(0 0 0.7rem rgba(255, 143, 163, 0.9));
    animation: prizeSparkle 1s ease, jackpotPulse 1.6s ease-in-out infinite;
}

.bubble-reveal.missed {
    opacity: 0.55;
    filter: grayscale(0.4) drop-shadow(0 0 0.3rem rgba(141, 167, 184, 0.4));
    animation: revealMissed 0.45s ease-out;
}

@keyframes prizeSparkle {
    0%   { transform: scale(0.4) rotate(-15deg); opacity: 0; }
    50%  { transform: scale(1.25) rotate(8deg);  opacity: 1; }
    100% { transform: scale(1)    rotate(0);     opacity: 1; }
}

@keyframes jackpotPulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.12); }
}

@keyframes revealMissed {
    0%   { opacity: 0; transform: scale(0.6); }
    100% { opacity: 0.55; transform: scale(1); }
}

/* Popped state */
.bubble.popped {
    cursor: default;
    background: radial-gradient(circle at 50% 50%, var(--popped) 0%, var(--popped-edge) 100%);
    box-shadow: inset 0 0.15rem 0.3rem rgba(141, 167, 184, 0.25);
    animation: popAnim 0.28s ease-out forwards;
}

.bubble.popped .bubble-shine {
    opacity: 0;
}

@keyframes popAnim {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.2); }
    70%  { transform: scale(0.6); }
    100% { transform: scale(0.78); }
}

.bubble.show-missed {
    background: radial-gradient(circle at 50% 50%, #f0e7eb 0%, #d8d2dc 100%);
}

/* ============ POP PARTICLES ============ */
.pop-particle {
    position: fixed;
    width: 0.35rem;
    height: 0.35rem;
    background: rgba(164, 216, 225, 0.85);
    border-radius: 50%;
    pointer-events: none;
    transform: translate(-50%, -50%);
    animation: popParticle 0.6s ease-out forwards;
    z-index: 999;
}

@keyframes popParticle {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(0.3);
    }
}

/* ============ RESULT DISPLAY ============ */
#result-display {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-card);
    padding: 1.25rem 1.75rem;
    border-radius: var(--r-lg);
    box-shadow: 0 0.75rem 2rem rgba(141, 167, 184, 0.35);
    text-align: center;
    min-width: 16rem;
    z-index: 100;
    animation: resultPopup 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#result-display.hidden { display: none; }

#result-display.win {
    border: 0.125rem solid var(--accent-jackpot);
    box-shadow: 0 0.75rem 2rem rgba(255, 143, 163, 0.4);
}

#result-display.loss {
    border: 0.125rem solid rgba(141, 167, 184, 0.3);
}

@keyframes resultPopup {
    0%   { transform: translate(-50%, -50%) scale(0.7); opacity: 0; }
    60%  { transform: translate(-50%, -50%) scale(1.05); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

#result-icon {
    font-size: 2.5rem;
    line-height: 1;
    margin-bottom: 0.4rem;
}

#result-title {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: 0.1rem;
    margin-bottom: 0.6rem;
}

#result-display.win #result-title { color: var(--accent-jackpot); }

#result-breakdown {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

#result-multiplier {
    font-size: 0.9rem;
    color: var(--text-primary);
    font-weight: 700;
    margin-bottom: 0.3rem;
}

#result-amount {
    font-size: 2rem;
    color: var(--accent-gold-2);
    font-weight: 800;
    line-height: 1;
    text-shadow: 0 0.15rem 0.4rem rgba(255, 184, 77, 0.35);
}

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

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

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

.bet-btn {
    width: 3rem;
    height: 2.1rem;
    background: var(--bg-card);
    border: 0.075rem solid rgba(164, 216, 225, 0.5);
    border-radius: var(--r-md);
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.18s ease;
    font-family: inherit;
}

.bet-btn:hover:not(:disabled) {
    border-color: var(--bubble-blue);
    color: var(--text-primary);
    background: var(--bubble-blue-2);
}

.bet-btn.active {
    background: linear-gradient(160deg, var(--accent-jackpot) 0%, var(--accent-jackpot-2) 100%);
    color: #ffffff;
    border-color: var(--accent-jackpot);
    box-shadow: 0 0.15rem 0.5rem rgba(255, 143, 163, 0.4);
}

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

/* ============ ACTION BUTTON ============ */
#action-button {
    width: 100%;
    max-width: 14rem;
    align-self: center;
    height: 3.25rem;
    background: linear-gradient(160deg, var(--accent-jackpot) 0%, var(--accent-jackpot-2) 60%, var(--accent-gold) 100%);
    border: none;
    border-radius: var(--r-pill);
    cursor: pointer;
    box-shadow:
        0 0.4rem 1rem rgba(255, 143, 163, 0.4),
        inset 0 0.1rem 0 rgba(255, 255, 255, 0.4);
    transition: transform 0.16s ease, box-shadow 0.16s ease;
    margin: 0.25rem auto 0;
    font-family: inherit;
}

#action-button:hover:not(:disabled) {
    transform: translateY(-0.1rem);
    box-shadow: 0 0.6rem 1.5rem rgba(255, 143, 163, 0.55);
}

#action-button:active:not(:disabled) {
    transform: translateY(0);
}

#action-button:disabled {
    background: linear-gradient(160deg, #d8d4dd 0%, #c8c4cd 100%);
    box-shadow: 0 0.15rem 0.4rem rgba(141, 167, 184, 0.2);
    cursor: not-allowed;
}

#action-text {
    color: #ffffff;
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: 0.15rem;
    text-transform: uppercase;
    text-shadow: 0 0.1rem 0.2rem rgba(0, 0, 0, 0.15);
}

#action-button:disabled #action-text {
    color: rgba(255, 255, 255, 0.7);
    text-shadow: none;
}

/* ============ MESSAGE ============ */
#message-display {
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    padding: 0.6rem 1.25rem;
    border-radius: var(--r-pill);
    border: 0.075rem solid var(--accent-jackpot);
    box-shadow: 0 0.4rem 1rem rgba(255, 143, 163, 0.3);
    z-index: 2000;
    white-space: nowrap;
}

#message-display.hidden { display: none; }

#message-text {
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 600;
}

/* ============ WIN PARTICLES ============ */
#particles-container {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1500;
    overflow: hidden;
}

.win-particle {
    position: absolute;
    font-size: 1.2rem;
    animation: winParticleFall 2s ease-out forwards;
}

@keyframes winParticleFall {
    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: 26rem) {
    #bubble-grid { gap: 0.25rem; }
    .bubble-reveal { font-size: 0.95rem; }
    .title-pop { font-size: 1.3rem; }
    .title-bubble { font-size: 0.75rem; }
    .stat-value { font-size: 0.9rem; }
    .stat-label { font-size: 0.6rem; }
    .bet-btn { width: 2.7rem; height: 2rem; font-size: 0.8rem; }
    #action-button { height: 3rem; }
    #action-text { font-size: 0.95rem; }
}

@media (max-width: 22rem) {
    body { padding: 0.5rem 0.25rem; }
    #grid-wrapper { padding: 0.5rem; }
    #bubble-grid { gap: 0.2rem; }
    .bubble-reveal { font-size: 0.85rem; }
}

@media (max-height: 44rem) {
    .game-title { display: none; }
    #stats-row { padding: 0.4rem 0.6rem; }
}
