:root {
    --circle-primary-color: #EB5E28;
    --circle-secondary-color: #FFFFFF;
    --circle-primary-color-rgb: 235, 94, 40;
    --circle-size: 50px;
    --circle-gap: 8px;
}

.circlecontainer {
    display: grid;
    grid-template-columns: repeat(auto-fill, var(--circle-size));
    grid-auto-rows: var(--circle-size);
    gap: var(--circle-gap);
    width: calc(100vw + 100px);
    height: calc(100vh + 100px);
    position: fixed;        
    z-index: 1;
    pointer-events: none; /* Allow clicks to pass through to elements below */
    overflow: visible; /* Allow circles to visibly extend outside container */
    justify-content: center;
    align-content: center;
    top: -50px;
    left: -50px;
    padding: 0;
}

.circle {
    width: var(--circle-size);
    height: var(--circle-size);
    border-radius: 50%;
    border: 1px solid rgba(170, 170, 170, 0.1);
    transition: border-color 0.2s ease-out, background-color 0.2s ease-out, transform 0.2s ease-out, box-shadow 0.2s ease-out, opacity 0.3s ease-out;
    pointer-events: auto; /* Make circles clickable */
    will-change: transform, opacity, background-color, border-color, box-shadow; /* Optimize for animations */
    contain: layout paint style; /* Containment for performance */
    position: relative;
}

/* Bomb styling */
.circle.bomb {
    animation: bomb-pulse 1.5s infinite alternate;
    box-shadow: 0 0 12px rgba(var(--circle-primary-color-rgb), 0.5);
    border-width: 2px;
    z-index: 3;
    position: relative;
}

@keyframes bomb-pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 8px rgba(var(--circle-primary-color-rgb), 0.4);
    }
    100% {
        transform: scale(1.15);
        box-shadow: 0 0 16px rgba(var(--circle-primary-color-rgb), 0.6);
    }
}

@keyframes ripple {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(3.5);
        opacity: 0;
    }
}

.circle.clicked {
    animation: ripple 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    z-index: 2;
}

/* Performance optimizations for mobile devices */
@media (max-width: 768px) {
    :root {
        --circle-size: 40px;
        --circle-gap: 6px;
    }
}

/* Further reduce size on very small screens */
@media (max-width: 480px) {
    :root {
        --circle-size: 30px;
        --circle-gap: 5px;
    }
}

/* Animation for UI elements */
.ripple-animate {
    animation: ui-ripple-effect 0.55s cubic-bezier(0.12, 0.6, 0.38, 1.35) forwards;
    will-change: transform;
    position: relative;
    z-index: 5;
}

@keyframes ui-ripple-effect {
    0% {
        transform: translate(0, 0) rotate(0) scale(1);
    }
    12% {
        transform: translate(calc(var(--move-x, 0) * 0.4), calc(var(--move-y, 0) * 0.4)) rotate(calc(var(--rotate, 0) * 0.4)) scale(calc(1 - 0.05));
    }
    28% {
        transform: translate(var(--move-x, 0), var(--move-y, 0)) rotate(var(--rotate, 0)) scale(var(--scale, 1));
        filter: brightness(1.25) contrast(1.12);
    }
    65% {
        transform: translate(calc(var(--move-x, 0) * 0.3), calc(var(--move-y, 0) * 0.3)) rotate(calc(var(--rotate, 0) * 0.3)) scale(calc(1.01 + ((var(--scale, 1) - 1) * 0.3)));
        filter: brightness(1.15);
    }
    100% {
        transform: translate(0, 0) rotate(0) scale(1);
        filter: brightness(1);
    }
}

/* Add subtle box-shadow to enhance 3D effect during animation */
.ripple-animate::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.75);
    opacity: 0;
    border-radius: inherit;
    pointer-events: none;
    animation: shadow-pulse 0.55s cubic-bezier(0.12, 0.6, 0.38, 1.35) forwards;
    z-index: -1;
}

@keyframes shadow-pulse {
    0% {
        opacity: 0;
    }
    28% {
        opacity: 1;
    }
    100% {
        opacity: 0;
    }
}