:root {
    --bg-color: #0f172a;
    --core-color: #3b82f6;
    --core-glow: rgba(59, 130, 246, 0.5);
    --particle-color: #f472b6;
    --text-color: #e2e8f0;
    --panel-bg: rgba(30, 41, 59, 0.8);
    --accent-color: #22d3ee;
}

* {
    box-sizing: border-box;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    /* Shield Ring (Restored) */
}

.shield-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    pointer-events: none;
    z-index: 15;
    background-color: transparent;
    transition: border-width 0.2s, opacity 0.2s;
}

#shield-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 15;
}

/* Prevent selection while clicking furiously */


body,
html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    /* Ensure strictly no scrolling */
    touch-action: none;
    /* Disable default touch actions like pinch-zoom */
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    position: fixed;
    /* Lock body in place on mobile */
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    /* Let clicks pass through to game elements */
    z-index: 100;
    /* Increased to be above particles (20) */
}

#score-container {
    position: absolute;
    top: 2rem;
    left: 50%;
    transform: translateX(-50%);
    font-size: 3rem;
    font-weight: bold;
    text-shadow: 0 0 20px var(--core-glow);
    pointer-events: auto;
    z-index: 100;
}

.label {
    font-size: 1rem;
    opacity: 0.7;
    font-weight: normal;
}

#upgrades-panel {
    position: absolute;
    right: 2rem;
    top: 2rem;
    bottom: 2rem;
    width: 300px;
    background: var(--panel-bg);
    backdrop-filter: blur(10px);
    border-radius: 1rem;
    padding: 1rem;
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 110;
    /* Ensure panel is above everything else in UI layer */
}

#upgrades-list {
    overflow-y: auto;
    flex: 1;
    padding-right: 5px;
    /* Space for scrollbar */
    touch-action: pan-y;
    /* Allow vertical scrolling */
}

/* Custom Scrollbar for Webkit */
#upgrades-list::-webkit-scrollbar {
    width: 6px;
}

#upgrades-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

#upgrades-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

#upgrades-panel .panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
}

#upgrades-panel h2 {
    margin: 0;
    border-bottom: none;
    padding-bottom: 0;
}

#reset-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 0.8rem;
    transition: all 0.2s;
}

#reset-btn:hover {
    background: rgba(255, 50, 50, 0.2);
    color: #ff5555;
    border-color: #ff5555;
}

.upgrade-item {
    background: rgba(255, 255, 255, 0.05);
    margin-bottom: 0.5rem;
    padding: 0.8rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.upgrade-item:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(-2px);
}

.upgrade-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(1);
}

.upgrade-name {
    font-weight: bold;
    display: block;
    color: var(--accent-color);
}

.upgrade-cost {
    font-size: 0.9rem;
    color: #ffd700;
}

.upgrade-desc {
    font-size: 0.8rem;
    opacity: 0.7;
    display: block;
    margin-top: 0.2rem;
}

/* PLAY AREA */
#play-area {
    position: absolute;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.core-object {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 120px;
    height: 120px;
    background: var(--core-color);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 50px var(--core-glow);
    cursor: pointer;
    transition: transform 0.1s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 5;
}

.core-object:active {
    transform: translate(-50%, -50%) scale(0.9);
}

.particle {
    position: absolute;
    width: 30px;
    height: 30px;
    background: var(--particle-color);
    border-radius: 50%;
    cursor: pointer;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 10px rgba(244, 114, 182, 0.5);
    z-index: 20;
    /* Ensure on top */
}

/* Expanded clickable area */
.particle::after {
    content: '';
    position: absolute;
    top: -25px;
    left: -25px;
    right: -25px;
    bottom: -25px;
    border-radius: 50%;
    z-index: 1;
}

.particle:hover {
    transform: translate(-50%, -50%) scale(1.1);
    background: #fbcfe8;
    box-shadow: 0 0 20px rgba(244, 114, 182, 0.8);
}

@keyframes float {

    0%,
    100% {
        margin-top: 0;
    }

    50% {
        margin-top: -10px;
    }
}

@keyframes particlePulse {

    0%,
    100% {
        width: 30px;
        height: 30px;
    }

    50% {
        width: 24px;
        height: 24px;
    }
}

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

    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

.sparkle {
    position: absolute;
    pointer-events: none;
    animation: fadeAndRise 1s forwards;
    color: white;
    font-weight: bold;
    font-size: 1.2rem;
    text-shadow: 0 0 5px black;
    z-index: 200;
}

@keyframes fadeAndRise {
    0% {
        opacity: 1;
        transform: translateY(0);
    }

    100% {
        opacity: 0;
        transform: translateY(-50px);
    }
}

#mobile-upgrade-btn {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: var(--panel-bg);
    color: var(--accent-color);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    z-index: 1000;
    backdrop-filter: blur(5px);
    display: none;
    /* Hidden by default on desktop */
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    transition: all 0.2s;
    pointer-events: auto;
}

#mobile-upgrade-btn:hover {
    background: rgba(30, 41, 59, 1);
    transform: scale(1.05);
}

#mobile-upgrade-btn:active {
    transform: scale(0.95);
}

#mute-btn {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background: var(--panel-bg);
    color: var(--text-color);
    border: 1px solid rgba(255, 255, 255, 0.2);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    z-index: 1000;
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    transition: all 0.2s;
    pointer-events: auto;
}

#mute-btn:hover {
    background: rgba(30, 41, 59, 1);
    transform: scale(1.1);
}

#mute-btn:active {
    transform: scale(0.9);
}

#close-panel-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 1.2rem;
    cursor: pointer;
    display: none;
}

/* Mobile Responsive Styles */
@media (max-width: 768px) {
    #mobile-upgrade-btn {
        display: block;
    }

    #upgrades-panel {
        display: none;
        /* Hidden by default on mobile */
        top: auto;
        bottom: 70px;
        /* Above the button */
        right: 10px;
        width: calc(100% - 20px);
        max-width: 350px;
        max-height: 60vh;
        z-index: 110;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
    }

    #upgrades-panel.open {
        display: flex;
        /* Keep flex layout for scrolling */
    }

    #close-panel-btn {
        display: block;
    }

    /* Mobile Text Optimizations */
    .upgrade-name {
        font-size: 0.9rem;
        /* Smaller title */
        white-space: nowrap;
        /* Force single line if possible */
        overflow: hidden;
        text-overflow: ellipsis;
        /* Ellipsis if still too long */
    }

    .upgrade-desc {
        font-size: 0.75rem;
    }

    .upgrade-item {
        padding: 0.6rem;
        /* Compact padding */
    }
}

@keyframes rainbow-glow {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

/* Cursor Ring */
#cursor-ring {
    position: absolute;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    pointer-events: none;
    z-index: 500;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
    display: none;
    /* Shown by JS */
    transition: width 0.2s, height 0.2s;
}

#cursor-ring.pulse-active {
    animation: ringClickPulse 0.3s ease-out;
}

@keyframes ringClickPulse {
    0% {
        border-color: rgba(255, 255, 255, 1);
        box-shadow: 0 0 20px rgba(255, 255, 255, 0.8);
    }

    100% {
        border-color: rgba(255, 255, 255, 0.5);
        box-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
    }
}