:root {
    --bg-dark: #050511;
    --bg-deep: #0f0c29;
    --accent-glow: #bfa2db;
    --text-main: #f0f0f5;
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.08);
    --orb-core: #ffffff;
    --orb-aura: #8a2be2;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    /* Fallback */
    /* Dynamic background handling moved to JS/inline style with transition */
    background: radial-gradient(circle at center, var(--bg-deep), var(--bg-dark));
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    cursor: crosshair;
    transition: background 2s ease;
}

/* Aurora Borealis */
.aurora-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 60%;
    opacity: 0;
    pointer-events: none;
    z-index: 1;
    transition: opacity 5s ease;
    mix-blend-mode: color-dodge;
    filter: blur(40px);
}

.aurora-wave {
    position: absolute;
    top: -60%;
    left: -20%;
    width: 140%;
    height: 120%;
    background: linear-gradient(120deg, transparent, rgba(0, 255, 128, 0.4), rgba(138, 43, 226, 0.4), transparent);
    animation: aurora-flow 15s infinite alternate ease-in-out;
    border-radius: 50% 50% 50% 50% / 80% 80% 20% 20%;
    transform: rotate(-10deg);
}

.aurora-wave:nth-child(2) {
    top: -40%;
    left: -10%;
    animation-duration: 22s;
    animation-direction: alternate-reverse;
    background: linear-gradient(120deg, transparent, rgba(255, 0, 128, 0.3), rgba(0, 200, 255, 0.3), transparent);
}

@keyframes aurora-flow {
    0% {
        transform: rotate(-10deg) translateX(0) scaleY(1);
    }

    100% {
        transform: rotate(5deg) translateX(30px) scaleY(1.1);
    }
}

/* Comet Animation */
.comet {
    position: absolute;
    width: 200px;
    height: 2px;
    background: linear-gradient(to left, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.8), #fff);
    pointer-events: auto;
    z-index: 25;
    cursor: pointer;
    /* Trajectory is 45deg (Top-Left to Bottom-Right) */
    animation: comet-path 4s linear forwards;
}

.comet::after {
    content: '';
    position: absolute;
    right: 0;
    top: -2px;
    width: 6px;
    height: 6px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 0 10px #fff, 0 0 20px gold;
}

/* Shockwave */
.shockwave {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.03) 0%, transparent 60%);
    transform: translate(-50%, -50%) scale(0.5);
    opacity: 0;
    pointer-events: none;
    animation: shockwave-out 0.5s ease-out forwards;
    z-index: 3;
}

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

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

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

/* Layers */
#ambient-layer,
#particle-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

/* Central Orb */
.center-piece {
    position: relative;
    z-index: 10;
    cursor: pointer;
    transition: transform 0.1s cubic-bezier(0.4, 0, 0.2, 1);
}

.center-piece:active {
    transform: scale(0.95);
}

/* Central Orb */
.center-piece {
    position: relative;
    z-index: 10;
    cursor: pointer;
}

.center-piece:active .orb {
    /* Instead of moving, flash the shadow */
    box-shadow: 0 0 100px #fff, inset 0 0 40px #fff;
}

.orb {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, var(--orb-core), var(--orb-aura));
    box-shadow: 0 0 60px var(--orb-aura), inset 0 0 20px var(--orb-core);
    transition: box-shadow 0.1s;
    /* Fast response for click */
    z-index: 2;
}

/* Click Ripples */
.ripple {
    position: absolute;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.6);
    transform: translate(-50%, -50%) scale(0.5);
    pointer-events: none;
    animation: ripple-anim 0.6s ease-out forwards;
}

@keyframes ripple-anim {
    to {
        transform: translate(-50%, -50%) scale(3);
        opacity: 0;
        border-width: 0;
    }
}

/* HUD */
.hud {
    position: absolute;
    top: 10%;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    z-index: 20;
    pointer-events: none;
}

.score-container h1 {
    font-size: 4rem;
    font-weight: 200;
    letter-spacing: 2px;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
}

.score-container p {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    opacity: 0.6;
}

/* Upgrades Panel */
.panel-toggle {
    position: absolute;
    bottom: 2rem;
    right: 2rem;
    width: 50px;
    height: 50px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 30;
    transition: all 0.3s;
}

.panel-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: rotate(90deg);
}

.upgrades-panel {
    position: absolute;
    right: -320px;
    /* Hidden state */
    top: 0;
    width: 300px;
    height: 100%;
    background: rgba(10, 10, 20, 0.8);
    backdrop-filter: blur(20px);
    border-left: 1px solid var(--glass-border);
    padding: 2rem;
    z-index: 25;
    transition: right 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.upgrades-panel.open {
    right: 0;
}

.upgrades-panel h2 {
    font-weight: 300;
    margin-bottom: 2rem;
    font-size: 1.5rem;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 1rem;
}

.upgrade-item {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

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

.upgrade-item.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.upgrade-name {
    font-weight: 600;
    display: block;
}

.upgrade-cost {
    color: var(--accent-glow);
    font-size: 0.85rem;
}

.upgrade-count {
    float: right;
    font-size: 0.8rem;
    opacity: 0.5;
}

/* Floating Text (for +1s) */
.floater {
    position: absolute;
    font-size: 1.2rem;
    font-weight: bold;
    color: rgba(255, 255, 255, 0.8);
    pointer-events: none;
    animation: floatUp 1s ease-out forwards;
}

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

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

/* Upgrade Visuals */
.firefly {
    position: absolute;
    width: 4px;
    height: 4px;
    background: #ffff00;
    border-radius: 50%;
    box-shadow: 0 0 10px #ffff00;
    animation: drift 20s linear infinite, blink 3s ease-in-out infinite alternate;
}

@keyframes drift {
    0% {
        transform: translate(0, 0);
        opacity: 0;
    }

    10% {
        opacity: 1;
    }

    90% {
        opacity: 1;
    }

    100% {
        transform: translate(var(--dx), var(--dy));
        opacity: 0;
    }
}

/* Rain Droplet Visuals */
.rain-drop {
    position: absolute;
    top: -50px;
    width: 1px;
    height: 50px;
    background: linear-gradient(to bottom, transparent, rgba(173, 216, 230, 0.6));
    animation: fall linear forwards;
    pointer-events: none;
    z-index: 1;
}

@keyframes fall {
    to {
        transform: translateY(110vh);
    }
}

/* Lotus Visuals */
.lotus {
    position: absolute;
    width: 40px;
    height: 40px;
    border-radius: 50% 0 50% 50%;
    background: radial-gradient(circle at 30% 30%, #ffb7b2, #ff6961);
    box-shadow: 0 0 15px rgba(255, 105, 97, 0.6);
    transform: rotate(45deg);
    animation: bloom 6s ease-in-out infinite alternate;
    pointer-events: none;
    z-index: 5;
}

@keyframes bloom {
    0% {
        transform: rotate(45deg) scale(0.9);
        opacity: 0.8;
    }

    100% {
        transform: rotate(45deg) scale(1.1);
        opacity: 1;
        box-shadow: 0 0 25px rgba(255, 105, 97, 0.9);
    }
}

/* Golden Spark */
.golden-spark {
    position: absolute;
    width: 20px;
    height: 20px;
    background: #ffd700;
    border-radius: 50%;
    box-shadow: 0 0 15px #ffd700, 0 0 30px #ffaa00;
    cursor: pointer;
    z-index: 25;
    animation: float-across 10s linear forwards;
}

.golden-spark:hover {
    transform: scale(1.3);
    box-shadow: 0 0 30px #fff, 0 0 50px #ffd700;
}

@keyframes float-across {
    0% {
        left: -50px;
        opacity: 0;
    }

    10% {
        opacity: 1;
    }

    90% {
        opacity: 1;
    }

    100% {
        left: 110vw;
        opacity: 0;
    }
}

/* Notification Toast */
.notification-area {
    position: absolute;
    bottom: 20%;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    pointer-events: none;
    z-index: 30;
    width: 90%;
    max-width: 400px;
    align-items: center;
}

.toast {
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 1rem 2rem;
    border-radius: 50px;
    color: #fff;
    font-size: 0.95rem;
    font-weight: 300;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transform: translateY(20px);
    animation: toast-in-out 6s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
    text-align: center;
}

@keyframes toast-in-out {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }

    10% {
        opacity: 1;
        transform: translateY(0);
    }

    85% {
        opacity: 1;
        transform: translateY(0);
    }

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

/* Satellite (Orbiting Moon) */
.satellite-container {
    position: absolute;
    width: 300px;
    height: 300px;
    pointer-events: none;
    z-index: 5;
    animation: orbit 15s linear infinite;
    display: flex;
    justify-content: center;
    align-items: center;
}

.satellite {
    position: absolute;
    top: 0;
    width: 12px;
    height: 12px;
    background: #64748b;
    border-radius: 50%;
    box-shadow: inset -3px -3px 5px rgba(0, 0, 0, 0.5), 0 0 10px rgba(100, 116, 139, 0.4);
}

@keyframes orbit {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@keyframes comet-path {
    0% {
        transform: translate(-20vw, -20vh) rotate(45deg);
        opacity: 0;
    }

    10% {
        opacity: 1;
    }

    90% {
        opacity: 1;
    }

    100% {
        transform: translate(120vw, 120vh) rotate(45deg);
        opacity: 0;
    }
}

/* Starlight */
.star-field {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    opacity: 0;
    transition: opacity 5s ease;
}

.star {
    position: absolute;
    width: 2px;
    height: 2px;
    background: #fff;
    border-radius: 50%;
    animation: twinkle 4s infinite ease-in-out alternate;
    box-shadow: 0 0 2px #fff;
}

@keyframes twinkle {
    0% {
        opacity: 0.2;
        transform: scale(0.8);
    }

    100% {
        opacity: 1;
        transform: scale(1.5);
        box-shadow: 0 0 5px #fff;
    }
}

/* Cursor Trail */
.trail-dot {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--accent-glow);
    box-shadow: 0 0 5px var(--accent-glow);
    border-radius: 50%;
    pointer-events: none;
    z-index: 50;
    opacity: 0.8;
    animation: fade-trail 0.6s linear forwards;
}

@keyframes fade-trail {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }

    100% {
        transform: scale(0.1);
        opacity: 0;
    }
}

/* Score Bounce */
.score-bump {
    animation: score-pop 0.1s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes score-pop {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.15);
    }

    100% {
        transform: scale(1);
    }
}