:root {
    --bg-color: #050505;
    --neon-pink: #FF00FF;
    --neon-cyan: #00FFFF;
    --neon-green: #00FF00;
    --neon-purple: #BC13FE;
    --fever-gold: #FFD700;
    --fever-red: #FF0000;
    --finisher-alert: #FF3300; 
}

body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100svh; /* Small Viewport Height */
    background-color: var(--bg-color);
    font-family: sans-serif;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    transition: background-color 0.2s;
    
    display: flex;
    flex-direction: column;
    /* Hard Top Padding for Safety */
    padding-top: calc(env(safe-area-inset-top) + 20px);
}

/* Top Bar */
#top-bar {
    width: 100%;
    height: 80px; /* Fixed height */
    background-color: rgba(20, 20, 20, 0.95);
    flex-shrink: 0;
    z-index: 90;
    padding-top: 0; /* Handled by body */
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.status-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    width: 100%;
    color: #FFF;
    font-size: 20px;
    font-weight: bold;
    font-family: 'Courier New', monospace;
    box-sizing: border-box;
}

#score, #combo {
    text-shadow: 0 0 10px rgba(255,255,255,0.3);
}

/* Bars stacked at bottom of Top Bar */
#fever-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 6px;
    background: rgba(50, 0, 0, 0.5);
    z-index: 92;
    display: none;
    top: auto;
}

#item-bar {
    position: absolute;
    bottom: 6px; /* Stack on top of fever bar */
    left: 0;
    width: 100%;
    height: 6px;
    background: rgba(0, 0, 50, 0.5);
    z-index: 91;
    display: none;
    top: auto;
}

#fever-progress {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #FF0000, #FFD700, #FF0000);
    background-size: 200% 100%;
    animation: fever-bar-shine 0.5s linear infinite;
    transform-origin: left;
}

#item-progress {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #00FFFF, #BC13FE, #00FFFF);
    background-size: 200% 100%;
    animation: fever-bar-shine 0.5s linear infinite;
    transform-origin: left;
}

body.fever-mode #fever-bar { display: block; }
body.item-active #item-bar { display: block; }

@keyframes fever-bar-shine {
    0% { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}

/* Fever Mode Styles */
body.fever-mode {
    animation: fever-strobe 0.1s infinite; 
}

@keyframes fever-strobe {
    0% { background-color: #1a0000; }
    50% { background-color: #330000; }
    100% { background-color: #1a0000; }
}

body.fever-mode .bubble {
    border-color: var(--fever-red);
}

body.fever-mode .bubble.popped {
    background-color: var(--fever-gold) !important;
    opacity: 0.9; 
}

/* Game Container */
#app {
    flex: 1; 
    display: flex;
    flex-wrap: wrap;
    justify-content: center; /* Center Horizontal */
    align-content: center; /* Center Vertical */
    width: 100%;
    height: auto; 
    overflow: hidden;
    padding: 5px; /* Side padding */
    box-sizing: border-box;
    border-top: 5px solid red; /* Debug Border */
}

/* Ad Container */
#ad-container {
    width: 100%;
    height: 60px;
    flex-shrink: 0;
    background-color: #1a1a1a;
    z-index: 50;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #555;
    font-size: 14px;
    font-weight: bold;
    padding-bottom: env(safe-area-inset-bottom);
    box-sizing: content-box; 
}

/* Optimized Bubble */
.bubble {
    position: relative;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    cursor: pointer;
    transition: transform 0.1s ease-out, opacity 0.2s ease, background-color 0.2s ease;
    will-change: transform;
    box-sizing: border-box;
    margin: 2px;
}

.bubble::before {
    content: '';
    position: absolute;
    top: 15%;
    left: 15%;
    width: 25%;
    height: 25%;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255,255,255,0.7) 0%, rgba(255,255,255,0) 70%);
    opacity: 0.6;
    pointer-events: none;
}

.bubble::after {
    content: '';
    position: absolute;
    bottom: 10%;
    right: 10%;
    width: 30%;
    height: 30%;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0) 70%);
    opacity: 0.3;
    pointer-events: none;
}

.bubble.popped {
    transform: scale(0.9);
    opacity: 0.4;
    border-color: rgba(255, 255, 255, 0.1);
    background-color: var(--bubble-color);
}

.bubble.popped::before {
    opacity: 0.1;
}

/* Finisher Mode */
.bubble.finisher-ready {
    border-color: var(--finisher-alert) !important;
    background-color: rgba(255, 51, 0, 0.2);
    animation: finisher-pulse 0.5s infinite alternate;
}

@keyframes finisher-pulse {
    from { transform: scale(1); filter: brightness(1.2); }
    to { transform: scale(1.05); filter: brightness(1.5); }
}

/* Item Bubble */
.bubble.has-item {
    border-color: #FFF !important;
    background-color: rgba(255, 255, 255, 0.3);
}
.item-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #FFF;
    font-size: 24px;
    text-shadow: 0 0 10px #FFF;
    animation: star-pulse 0.5s infinite alternate;
    pointer-events: none;
    z-index: 5;
}

@keyframes star-pulse {
    from { transform: translate(-50%, -50%) scale(1); opacity: 0.8; }
    to { transform: translate(-50%, -50%) scale(1.3); opacity: 1; }
}

/* Rave Effect */
body.effect-rave {
    animation: rave-bg 2s linear infinite;
}
body.effect-rave .bubble {
    animation: rave-bubble 0.5s linear infinite;
}
@keyframes rave-bg {
    0% { filter: hue-rotate(0deg); }
    100% { filter: hue-rotate(360deg); }
}
@keyframes rave-bubble {
    0% { filter: brightness(1); }
    50% { filter: brightness(2); }
    100% { filter: brightness(1); }
}

/* Heavy Effect */
body.effect-heavy {
    --bg-color: #000;
}

/* Canvas & Overlay */
#particle-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

#flash-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    opacity: 0;
    pointer-events: none;
    z-index: 20;
    will-change: opacity;
}

/* Shockwave */
#shockwave {
    position: fixed;
    top: 50%;
    left: 50%;
    width: 150vmax;
    height: 150vmax;
    border-radius: 50%;
    background: radial-gradient(circle, transparent 30%, rgba(255,255,255,0.5) 40%, transparent 60%);
    transform: translate(-50%, -50%) scale(0);
    pointer-events: none;
    z-index: 15;
    opacity: 0;
}

.shockwave-active {
    animation: shockwave-ripple 0.4s ease-out forwards;
}

@keyframes shockwave-ripple {
    0% { transform: translate(-50%, -50%) scale(0); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 0; }
}

/* Shake Animation */
@keyframes shake-anim {
    0% { transform: translate(0, 0); }
    25% { transform: translate(-4px, 4px); }
    50% { transform: translate(4px, -4px); }
    75% { transform: translate(-4px, 4px); }
    100% { transform: translate(0, 0); }
}

.shake {
    animation: shake-anim 0.05s cubic-bezier(.36,.07,.19,.97) both;
}
