/* UI styles */
#ui {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    color: #fff;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    z-index: 1000; /* Ensure UI container has proper z-index */
}

/* Independent Souls display at top center */
/* Przeliczone z px dla 1080p @ 125% scale (viewport 1536x864) */
.souls-display-independent {
    --frame-color: #3a2a28;
    --frame-inner: #2a1a18;
    --corner-color: #4a3a35;
    --diamond-color: #5a4a45;
    --text-color: #8a7a75;
    --souls-scale: 1;
    --texture: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='5' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");

    position: fixed;
    top: 0.8vh;
    left: 50%;
    transform: translateX(-50%) scale(var(--souls-scale));
    transform-origin: top center;
    z-index: 99999;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.souls-display-independent .diamond-row {
    display: flex;
    align-items: center;
    margin-top: 0.81vh;
}

.souls-display-independent .line {
    width: 1.82vw;
    height: 2px;
    background: var(--frame-color);
}

.souls-display-independent .diamond-small {
    width: 0.81vh;
    height: 0.81vh;
    border: 1px solid var(--corner-color);
    transform: rotate(45deg);
    margin: 0 0.32vh;
    background:
        var(--texture),
        linear-gradient(135deg, #0e060a 0%, #0a0406 100%);
    background-blend-mode: soft-light, normal;
}

.souls-display-independent .diamond-group {
    position: relative;
    width: 5.47vw;
    height: 6.48vh;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 0.36vw;
}

.souls-display-independent .diamond-side {
    position: absolute;
    width: 3.65vh;
    height: 3.65vh;
    border: 2px solid var(--corner-color);
    transform: rotate(45deg);
    background:
        var(--texture),
        linear-gradient(135deg, #0e060a 0%, #0a0406 100%);
    background-blend-mode: soft-light, normal;
    z-index: 1;
}

.souls-display-independent .diamond-side.left {
    left: 0.23vw;
}

.souls-display-independent .diamond-side.right {
    right: 0.23vw;
}

.souls-display-independent .diamond-center {
    position: absolute;
    width: 5.67vh;
    height: 5.67vh;
    border: 2px solid var(--frame-color);
    transform: rotate(45deg);
    background:
        var(--texture),
        radial-gradient(ellipse 60% 60% at 50% 50%, rgba(20, 10, 18, 0.12) 0%, transparent 70%),
        linear-gradient(135deg, #0e060a 0%, #0a0406 100%);
    background-blend-mode: soft-light, normal, normal;
    box-shadow: inset 0 0 0 4px var(--frame-inner);
    z-index: 2;
}

.souls-display-independent .diamond-content {
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--text-color);
    margin-top: 0.5vh;
}

.souls-display-independent .souls-label {
    font-family: 'SFPixelate', 'Courier New', monospace;
    font-size: 1.7vw;
    letter-spacing: 0.13vw;
    text-transform: uppercase;
    line-height: 1;
    color: #d8a8c0;
    text-shadow:
        1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000,
        2px 2px 4px rgba(0, 0, 0, 0.8),
        0 0 0.52vw rgba(200, 120, 160, 0.7),
        0 0 1.04vw rgba(180, 100, 140, 0.5);
}

.souls-display-independent #souls {
    font-family: 'SFPixelate', 'Courier New', monospace;
    font-size: 2.6vw;
    font-weight: bold;
    letter-spacing: 0.065vw;
    line-height: 1;
    margin-top: 0.1vh;
    color: #e0b8c8;
    text-shadow:
        1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000,
        2px 2px 4px rgba(0, 0, 0, 0.8),
        0 0 0.52vw rgba(200, 120, 160, 0.7),
        0 0 1.04vw rgba(180, 100, 140, 0.5);
}

.souls-display-independent .bottom-line {
    width: 2px;
    height: 1.22vh;
    background: var(--frame-color);
    margin-top: -0.41vh;
}

.souls-display-independent .bottom-diamond {
    width: 0.48vh;
    height: 0.48vh;
    border: 2px solid var(--diamond-color);
    transform: rotate(45deg);
    background:
        var(--texture),
        linear-gradient(135deg, #0e060a 0%, #0a0406 100%);
    background-blend-mode: soft-light, normal;
}

/* Hide souls display during splash and title screens */
.souls-display-independent.hidden-for-splash-title {
    display: none;
}



/* Wave and Enemies positioned around souls */
.wave-enemies-group {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 300px; /* Large gap to make space for souls in the middle */
    z-index: 1000; /* Same level as other UI elements */
    pointer-events: none;
    flex-shrink: 0;
    width: 700px; /* Fixed width to ensure proper spacing */
    justify-content: space-between;
}

/* Keep old classes for backward compatibility */
.souls-display-top {
    position: fixed;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 10px;
    background: radial-gradient(ellipse at center, 
        rgba(157, 78, 221, 0.3) 0%, 
        rgba(106, 76, 147, 0.2) 40%,
        rgba(0, 0, 0, 0.7) 100%
    );
    padding: 10px 25px;
    border-radius: 25px;
    border: 1px solid rgba(224, 170, 255, 0.5);
    box-shadow: 
        0 0 20px rgba(157, 78, 221, 0.4),
        inset 0 0 15px rgba(106, 76, 147, 0.2);
    z-index: 100;
    transition: all 0.3s ease;
}

.top-center-ui {
    position: fixed;
    top: 100px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 20px;
    z-index: 100;
}

/* Keep old souls display class for backward compatibility */
.souls-display-center {
    position: fixed;
    bottom: 60px; /* Above XP bar */
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 10px;
    background: radial-gradient(ellipse at center, 
        rgba(157, 78, 221, 0.3) 0%, 
        rgba(106, 76, 147, 0.2) 40%,
        rgba(0, 0, 0, 0.7) 100%
    );
    padding: 10px 25px;
    border-radius: 25px;
    border: 1px solid rgba(224, 170, 255, 0.5);
    box-shadow: 
        0 0 20px rgba(157, 78, 221, 0.4),
        inset 0 0 15px rgba(106, 76, 147, 0.2);
    z-index: 100;
    transition: all 0.3s ease;
}

.soul-icon {
    font-size: 1.85vh;
    color: #ffd700;
    text-shadow:
        0 0 0.52vw rgba(255, 215, 0, 0.8),
        0 0 1.04vw rgba(255, 215, 0, 0.4);
    animation: soulPulse 2s ease-in-out infinite;
    will-change: transform;
    transform: translateZ(0); /* Force GPU layer */
}

@keyframes soulPulse {
    0%, 100% { transform: scale3d(1, 1, 1); opacity: 0.9; }
    50% { transform: scale3d(1.1, 1.1, 1); opacity: 1; }
}

/* Souls gain animations */
@keyframes soulsGain {
    0% { 
        transform: translate3d(-50%, 0, 0) scale3d(1, 1, 1);
        box-shadow: 
            0 0 20px rgba(157, 78, 221, 0.4),
            inset 0 0 15px rgba(106, 76, 147, 0.2);
    }
    50% { 
        transform: translate3d(-50%, 0, 0) scale3d(1.15, 1.15, 1);
        box-shadow: 
            0 0 40px rgba(157, 78, 221, 0.8),
            0 0 60px rgba(224, 170, 255, 0.6),
            inset 0 0 25px rgba(106, 76, 147, 0.4);
    }
    100% { 
        transform: translate3d(-50%, 0, 0) scale3d(1, 1, 1);
        box-shadow: 
            0 0 20px rgba(157, 78, 221, 0.4),
            inset 0 0 15px rgba(106, 76, 147, 0.2);
    }
}

@keyframes soulsGainHorizontal {
    0% {
        transform: translateX(-50%) scale(var(--souls-scale, 1));
        box-shadow:
            0 0 0.78vw rgba(157, 78, 221, 0.2),
            inset 0 0 0.52vw rgba(106, 76, 147, 0.1);
    }
    50% {
        transform: translateX(-50%) scale(calc(var(--souls-scale, 1) * 1.15));
        box-shadow:
            0 0 2.08vw rgba(157, 78, 221, 0.8),
            0 0 3.13vw rgba(224, 170, 255, 0.6),
            inset 0 0 1.3vw rgba(106, 76, 147, 0.4);
    }
    100% {
        transform: translateX(-50%) scale(var(--souls-scale, 1));
        box-shadow:
            0 0 0.78vw rgba(157, 78, 221, 0.2),
            inset 0 0 0.52vw rgba(106, 76, 147, 0.1);
    }
}

@keyframes soulsGlow {
    0% {
        border-color: rgba(224, 170, 255, 0.5);
        background: radial-gradient(ellipse at center, 
            rgba(157, 78, 221, 0.3) 0%, 
            rgba(106, 76, 147, 0.2) 40%,
            rgba(0, 0, 0, 0.7) 100%
        );
    }
    50% {
        border-color: rgba(224, 170, 255, 0.9);
        background: radial-gradient(ellipse at center, 
            rgba(157, 78, 221, 0.6) 0%, 
            rgba(106, 76, 147, 0.4) 40%,
            rgba(0, 0, 0, 0.7) 100%
        );
    }
    100% {
        border-color: rgba(224, 170, 255, 0.5);
        background: radial-gradient(ellipse at center, 
            rgba(157, 78, 221, 0.3) 0%, 
            rgba(106, 76, 147, 0.2) 40%,
            rgba(0, 0, 0, 0.7) 100%
        );
    }
}

@keyframes soulsTextGlow {
    0%, 100% {
        text-shadow:
            0 0 0.52vw rgba(157, 78, 221, 0.6),
            0 0 1.04vw rgba(106, 76, 147, 0.4);
    }
    50% {
        text-shadow:
            0 0 1.04vw rgba(157, 78, 221, 1),
            0 0 1.56vw rgba(224, 170, 255, 0.8),
            0 0 2.08vw rgba(106, 76, 147, 0.6);
    }
}

@keyframes soulsIconBurst {
    0% {
        transform: scale3d(1, 1, 1);
        text-shadow:
            0 0 0.52vw rgba(255, 215, 0, 0.8),
            0 0 1.04vw rgba(255, 215, 0, 0.4);
    }
    50% {
        transform: scale3d(1.3, 1.3, 1);
        text-shadow:
            0 0 1.04vw rgba(255, 215, 0, 1),
            0 0 2.08vw rgba(157, 78, 221, 0.8),
            0 0 3.13vw rgba(224, 170, 255, 0.6);
    }
    100% {
        transform: scale3d(1, 1, 1);
        text-shadow:
            0 0 0.52vw rgba(255, 215, 0, 0.8),
            0 0 1.04vw rgba(255, 215, 0, 0.4);
    }
}

/* Souls gain trigger classes */
.souls-display-center.souls-gaining,
.souls-display-top.souls-gaining {
    animation: soulsGain 0.6s ease-out, soulsGlow 0.6s ease-out;
}

.souls-display-independent.souls-gaining {
    transform: translateX(-50%) scale(calc(var(--souls-scale) * 1.1));
    transform-origin: top center;
    animation: soulsGainHorizontal 0.6s ease-out, soulsGlow 0.6s ease-out;
}

.souls-display-center.souls-gaining .souls-text,
.souls-display-top.souls-gaining .souls-text,
.souls-display-independent.souls-gaining .souls-text {
    animation: soulsTextGlow 0.6s ease-out;
}

.souls-display-center.souls-gaining .soul-icon,
.souls-display-top.souls-gaining .soul-icon,
.souls-display-independent.souls-gaining .soul-icon {
    animation: soulsIconBurst 0.6s ease-out;
}

/* Floating souls text */
.souls-float-text {
    position: fixed;
    font-family: 'SFPixelate', 'Courier New', monospace;
    font-size: 1.67vh;
    font-weight: bold;
    color: rgba(224, 170, 255, 1);
    text-shadow:
        0 0 0.78vw rgba(157, 78, 221, 0.9),
        0 0 1.56vw rgba(106, 76, 147, 0.7),
        0 0 2.34vw rgba(224, 170, 255, 0.5),
        0.1vw 0.1vw 0.21vw rgba(0, 0, 0, 0.9);
    pointer-events: none;
    z-index: 150;
    animation: soulsFloatUpEnhanced 2.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
    text-align: center;
    white-space: nowrap;
    transform-origin: center center;
    filter: drop-shadow(0 0 0.52vw rgba(157, 78, 221, 0.6));
}

@keyframes soulsFloatUpEnhanced {
    0% {
        opacity: 0;
        transform: translateX(-50%) translateY(0.93vh) scale3d(0.6, 0.6, 1) rotateZ(-5deg);
        filter: drop-shadow(0 0 0.26vw rgba(157, 78, 221, 0.3)) blur(0.05vw);
    }
    15% {
        opacity: 1;
        transform: translateX(-50%) translateY(0.46vh) scale3d(0.9, 0.9, 1) rotateZ(0deg);
        filter: drop-shadow(0 0 0.52vw rgba(157, 78, 221, 0.6)) blur(0);
    }
    35% {
        opacity: 1;
        transform: translateX(-50%) translateY(-1.39vh) scale3d(1.2, 1.2, 1) rotateZ(2deg);
        filter: drop-shadow(0 0 1.04vw rgba(157, 78, 221, 0.9)) blur(0);
        color: rgba(255, 255, 255, 1);
        text-shadow:
            0 0 1.04vw rgba(224, 170, 255, 1),
            0 0 2.08vw rgba(157, 78, 221, 0.9),
            0 0 3.13vw rgba(106, 76, 147, 0.7),
            0.1vw 0.1vw 0.21vw rgba(0, 0, 0, 0.9);
    }
    65% {
        opacity: 0.9;
        transform: translateX(-50%) translateY(-3.24vh) scale3d(1.0, 1.0, 1) rotateZ(-1deg);
        filter: drop-shadow(0 0 0.78vw rgba(157, 78, 221, 0.7)) blur(0);
    }
    85% {
        opacity: 0.4;
        transform: translateX(-50%) translateY(-4.63vh) scale3d(0.8, 0.8, 1) rotateZ(1deg);
        filter: drop-shadow(0 0 0.52vw rgba(157, 78, 221, 0.4)) blur(0.03vw);
    }
    100% {
        opacity: 0;
        transform: translateX(-50%) translateY(-6.48vh) scale3d(0.5, 0.5, 1) rotateZ(0deg);
        filter: drop-shadow(0 0 0.26vw rgba(157, 78, 221, 0.2)) blur(0.1vw);
    }
}

.souls-text {
    font-size: max(12px, 1.48vh);
    font-weight: bold;
    font-family: 'SFPixelate', 'Courier New', monospace;
    color: rgba(224, 170, 255, 0.95);
    text-shadow:
        0 0 0.52vw rgba(157, 78, 221, 0.6),
        0 0 1.04vw rgba(106, 76, 147, 0.4);
}

.stat {
    background: rgba(0,0,0,0.7);
    padding: 8px 15px;
    border-radius: 5px;
    border: 1px solid #4a148c;
    width: 120px; /* Default width */
    text-align: center; /* Center the text within the fixed width */
    box-sizing: border-box; /* Include padding in width calculation */
    flex-shrink: 0; /* Prevent shrinking */
    overflow: hidden; /* Hide overflow if text is too long */
    white-space: nowrap; /* Prevent text wrapping */
    color: #fff; /* White text color */
    font-family: 'SFPixelate', 'Courier New', monospace;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
}

/* Wave stat - sized for 2 digits (Wave: 99) */
.stat-wave {
    width: 100px; /* Smaller width for 2-digit numbers */
}

/* Enemies stat - sized for 3 digits (Enemies: 999) */
.stat-enemies {
    width: 140px; /* Larger width for 3-digit numbers */
}

/* Level up screen - Vampire Survivors style */
#levelUpScreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    pointer-events: all;
    z-index: 1000;
    animation: levelUpFadeIn 0.3s ease-out;
    overflow: visible;
}

#levelUpScreen h2 {
    font-family: 'SFPixelate', 'Impact', 'Arial Black', sans-serif;
    font-size: 64px;
    font-weight: bold;
    text-align: center;
    margin: 40px 0 30px 0;
    color: #ffff00;
    text-shadow: 
        3px 3px 0px #000000,
        0 0 10px rgba(255, 255, 0, 0.8);
    letter-spacing: 4px;
    text-transform: uppercase;
    animation: levelUpPulse 1s ease-in-out infinite alternate;
}

/* Level up container - Vampire Survivors style */
.levelup-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    max-width: 100vw;
    max-height: 80vh;
    overflow: visible;
    padding: 0;
}

/* Upgrade grid */
.upgrade-grid {
    display: flex;
    flex-direction: row;
    gap: 15px;
    margin: 0 auto;
    width: 100%;
    overflow: visible;
    flex-wrap: nowrap;
    padding: 30px 10px;
    justify-content: center;
}


/* Single upgrade card - VS style */
.upgrade-card {
    background: linear-gradient(135deg, 
        rgba(40, 20, 80, 0.9) 0%,
        rgba(60, 30, 120, 0.8) 100%
    );
    border: 3px solid #4a0e78;
    border-radius: 12px;
    padding: 20px;
    cursor: var(--cm-cursor-action, pointer);
    position: relative;
    transition: all 0.2s ease-out;
    animation: cardSlideIn 0.4s ease-out;
    min-height: 120px;
    min-width: 280px;
    max-width: 320px;
    display: flex;
    align-items: center;
    gap: 15px;
    flex-shrink: 0;
    transform: scale(1); /* Bazowy stan dla płynnych animacji */
}

/* Number badge */
.upgrade-card::before {
    content: attr(data-key);
    position: absolute;
    top: -8px;
    right: -8px;
    background: linear-gradient(135deg, #ffff00, #ffaa00);
    color: #000;
    font-size: 16px;
    font-weight: bold;
    font-family: 'SFPixelate', 'Impact', 'Arial Black', sans-serif;
    padding: 8px;
    border-radius: 50%;
    min-width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    box-shadow: 
        0 4px 8px rgba(0, 0, 0, 0.5),
        0 0 20px rgba(255, 255, 0, 0.6);
    z-index: 2;
}

/* Icon area */
.upgrade-icon {
    font-size: 48px;
    color: #ffff00;
    text-shadow: 
        0 0 10px rgba(255, 255, 0, 0.8),
        2px 2px 4px rgba(0, 0, 0, 0.8);
    filter: drop-shadow(0 0 8px rgba(255, 255, 0, 0.5));
    min-width: 60px;
    text-align: center;
    background-size: 40px 40px;
    background-repeat: no-repeat;
    background-position: center;
    opacity: 0.9;
    position: relative;
}

/* Text area */
.upgrade-text {
    flex: 1;
}

.upgrade-title {
    font-family: 'SFPixelate', 'Impact', 'Arial Black', sans-serif;
    font-size: 18px;
    font-weight: bold;
    color: #ffffff;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    margin-bottom: 8px;
    letter-spacing: 1px;
}

.upgrade-description {
    font-family: 'SFPixelate', 'Arial', sans-serif;
    font-size: 14px;
    color: #cccccc;
    line-height: 1.3;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

/* Enhanced Level Up Styles for Impact Analysis */
.upgrade-card.with-impact {
    min-height: 160px;
    padding: 15px;
}

.upgrade-impact-details {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.affected-spells-section {
    margin-bottom: 8px;
}

.section-title {
    font-size: 12px;
    color: #ffd700;
    text-transform: uppercase;
    margin-bottom: 4px;
    font-weight: bold;
    letter-spacing: 0.5px;
}

.affected-spells-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.affected-spell {
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    color: #ccc;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.affected-spell-icon {
    width: 16px !important;
    height: 16px !important;
    flex-shrink: 0;
}

.affected-spell-name {
    font-size: 12px;
    white-space: nowrap;
}

.synergy-section {
    margin-bottom: 6px;
}

.enhanced-synergy, .potential-synergy {
    background: rgba(138, 43, 226, 0.1);
    border: 1px solid rgba(138, 43, 226, 0.3);
    border-radius: 3px;
    padding: 4px 6px;
    margin-bottom: 3px;
    font-size: 12px;
}

.synergy-name {
    font-weight: bold;
    color: #dda0dd;
    margin-bottom: 2px;
}

.synergy-description, .synergy-progress {
    color: #ccc;
    font-size: 12px;
    line-height: 1.2;
}

.no-affected-spells {
    font-size: 12px;
    color: #666;
    font-style: italic;
    text-align: center;
    padding: 8px;
}

/* Hover effect */
.upgrade-card:hover:where(body:not(.gamepad-active) *) {
    border-color: #00ff88;
    transform: scale(1.05);
    box-shadow: 
        0 0 30px rgba(0, 255, 136, 0.5),
        0 8px 25px rgba(0, 0, 0, 0.4);
    background: linear-gradient(135deg, 
        rgba(0, 255, 136, 0.2) 0%,
        rgba(40, 20, 80, 0.9) 100%
    );
}

.upgrade-card:hover:where(body:not(.gamepad-active) *)::before {
    background: linear-gradient(135deg, #00ff88, #ffff00);
    transform: scale(1.1);
    box-shadow: 
        0 4px 8px rgba(0, 0, 0, 0.5),
        0 0 25px rgba(0, 255, 136, 0.8);
}

.upgrade-card:hover:where(body:not(.gamepad-active) *) .upgrade-icon {
    color: #00ff88;
    text-shadow: 
        0 0 15px rgba(0, 255, 136, 0.8),
        2px 2px 4px rgba(0, 0, 0, 0.8);
    filter: drop-shadow(0 0 12px rgba(0, 255, 136, 0.7));
    animation: iconFloat 0.6s ease-in-out infinite alternate;
}

/* Selected state */
.upgrade-card.selected {
    border-color: #ffff00;
    transform: scale(1.08);
    box-shadow: 
        0 0 40px rgba(255, 255, 0, 0.8),
        0 0 80px rgba(255, 255, 0, 0.4),
        0 10px 30px rgba(0, 0, 0, 0.5);
    background: linear-gradient(135deg, 
        rgba(255, 255, 0, 0.3) 0%,
        rgba(255, 165, 0, 0.2) 50%,
        rgba(40, 20, 80, 0.9) 100%
    );
    animation: selectedGlow 1s ease-in-out infinite alternate;
    z-index: 10;
}

.upgrade-card.selected::before {
    background: linear-gradient(135deg, #ffffff, #ffff00);
    transform: scale(1.2);
    animation: selectedBadge 1s ease-in-out infinite alternate;
    z-index: 15;
}

.upgrade-card.selected .upgrade-icon {
    color: #ffff00;
    animation: selectedIconPulse 0.8s ease-in-out infinite alternate;
}

/* Sparkle effect for selected card */
.upgrade-card.selected::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.3) 2px, transparent 3px),
        radial-gradient(circle at 80% 70%, rgba(255, 255, 0, 0.4) 1px, transparent 2px),
        radial-gradient(circle at 40% 80%, rgba(255, 255, 255, 0.2) 2px, transparent 3px),
        radial-gradient(circle at 60% 20%, rgba(255, 255, 0, 0.3) 1px, transparent 2px);
    border-radius: 12px;
    pointer-events: none;
    animation: sparkle 2s ease-in-out infinite;
    z-index: 12;
}

.upgrade-option {
    background: rgba(75, 0, 130, 0.3);
    border: 2px solid rgba(147, 112, 219, 0.6);
    padding: 24px;
    margin: 12px 0;
    cursor: var(--cm-cursor-action, pointer);
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    border-radius: 15px;
    position: relative;
    overflow: hidden;
    box-shadow: 
        0 4px 15px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    transform: translateX(0) scale(1); /* Bazowy stan dla płynnych animacji */
}

/* Number indicators for keyboard shortcuts */
.upgrade-option::before {
    content: attr(data-number);
    position: absolute;
    top: 8px;
    right: 12px;
    background: rgba(255, 215, 0, 0.8);
    color: #000;
    font-size: 12px;
    font-weight: bold;
    padding: 4px 8px;
    border-radius: 50%;
    min-width: 20px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    opacity: 0.7;
    transition: opacity 0.3s;
}

/* Hover effect */
.upgrade-option:hover:where(body:not(.gamepad-active) *) {
    background: rgba(100, 25, 155, 0.4);
    border-color: rgba(0, 255, 136, 0.8);
    transform: translateX(5px) scale(1.02);
    box-shadow: 
        0 8px 25px rgba(0, 255, 136, 0.2),
        0 4px 15px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.upgrade-option:hover:where(body:not(.gamepad-active) *)::before {
    opacity: 1;
}

/* Selected state with enhanced glow */
.upgrade-option.selected {
    border-color: #ffd700;
    background: rgba(255, 215, 0, 0.2);
    transform: translateX(8px) scale(1.05);
    box-shadow: 
        0 0 30px rgba(255, 215, 0, 0.6),
        0 0 60px rgba(255, 215, 0, 0.3),
        0 8px 25px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
    animation: selectedPulse 1.5s ease-in-out infinite;
}

.upgrade-option.selected::before {
    background: rgba(255, 255, 255, 0.9);
    color: #000;
    opacity: 1;
    animation: numberGlow 1.5s ease-in-out infinite;
}

/* Shine effect on selection */
.upgrade-option.selected::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, 
        transparent 30%, 
        rgba(255, 255, 255, 0.1) 50%, 
        transparent 70%
    );
    animation: shine 2s ease-in-out infinite;
    pointer-events: none;
}

.upgrade-title {
    font-size: 20px;
    font-weight: bold;
    color: #dda0dd;
    margin-bottom: 8px;
    text-shadow: 
        0 0 5px rgba(221, 160, 221, 0.6),
        1px 1px 2px rgba(0, 0, 0, 0.8);
    font-family: 'SFPixelate', 'Georgia', serif;
    letter-spacing: 1px;
}

.upgrade-desc {
    font-size: 15px;
    color: #d8bfd8;
    line-height: 1.4;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.6);
    font-family: 'SFPixelate', 'Verdana', sans-serif;
}

/* Gamepad hints for level up screen */
#levelUpScreen .gamepad-hints {
    position: absolute;
    bottom: -60px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    border: 2px solid rgba(138, 43, 226, 0.6);
    border-radius: 12px;
    padding: 10px 20px;
    font-family: 'SFPixelate', 'Courier New', monospace;
    font-size: 12px;
    color: #dda0dd;
    white-space: nowrap;
    display: flex;
    gap: 15px;
    align-items: center;
    animation: fadeInHints 0.5s ease-out;
}

#levelUpScreen .gamepad-hints .hint-item {
    color: #ccc;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

#levelUpScreen .gamepad-hints .hint-item:first-child {
    color: #ffd700;
    font-weight: bold;
}

/* Animations */
@keyframes levelUpAppear {
    0% {
        opacity: 0;
        transform: translate3d(-50%, -50%, 0) scale3d(0.8, 0.8, 1) rotateY(20deg);
    }
    50% {
        transform: translate3d(-50%, -50%, 0) scale3d(1.05, 1.05, 1) rotateY(-5deg);
    }
    100% {
        opacity: 1;
        transform: translate3d(-50%, -50%, 0) scale3d(1, 1, 1) rotateY(0deg);
    }
}

@keyframes borderGlow {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

@keyframes particleFloat {
    0% { transform: translate3d(0, 0px, 0) rotate(0deg); }
    50% { transform: translate3d(0, -10px, 0) rotate(180deg); }
    100% { transform: translate3d(0, 0px, 0) rotate(360deg); }
}

@keyframes titlePulse {
    0%, 100% { 
        text-shadow: 
            0 0 10px rgba(221, 160, 221, 0.8),
            0 0 20px rgba(138, 43, 226, 0.6),
            2px 2px 4px rgba(0, 0, 0, 0.8);
    }
    50% { 
        text-shadow: 
            0 0 20px rgba(221, 160, 221, 1),
            0 0 40px rgba(138, 43, 226, 0.8),
            2px 2px 4px rgba(0, 0, 0, 0.8);
    }
}

@keyframes selectedPulse {
    0%, 100% { 
        box-shadow: 
            0 0 30px rgba(255, 215, 0, 0.6),
            0 0 60px rgba(255, 215, 0, 0.3),
            0 8px 25px rgba(0, 0, 0, 0.4),
            inset 0 1px 0 rgba(255, 255, 255, 0.3);
    }
    50% { 
        box-shadow: 
            0 0 40px rgba(255, 215, 0, 0.8),
            0 0 80px rgba(255, 215, 0, 0.4),
            0 8px 25px rgba(0, 0, 0, 0.4),
            inset 0 1px 0 rgba(255, 255, 255, 0.4);
    }
}

@keyframes numberGlow {
    0%, 100% { 
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    }
    50% { 
        box-shadow: 
            0 2px 4px rgba(0, 0, 0, 0.3),
            0 0 10px rgba(255, 215, 0, 0.8);
    }
}

@keyframes shine {
    0% { transform: translate3d(-200%, -200%, 0) rotate(45deg); }
    100% { transform: translate3d(200%, 200%, 0) rotate(45deg); }
}

@keyframes selectedConfirm {
    0% { 
        transform: translate3d(8px, 0, 0) scale3d(1.05, 1.05, 1);
        box-shadow: 
            0 0 30px rgba(255, 215, 0, 0.6),
            0 0 60px rgba(255, 215, 0, 0.3),
            0 8px 25px rgba(0, 0, 0, 0.4),
            inset 0 1px 0 rgba(255, 255, 255, 0.3);
    }
    50% { 
        transform: translate3d(8px, 0, 0) scale3d(1.08, 1.08, 1);
        box-shadow: 
            0 0 50px rgba(0, 255, 0, 0.8),
            0 0 100px rgba(0, 255, 0, 0.4),
            0 8px 25px rgba(0, 0, 0, 0.4),
            inset 0 1px 0 rgba(255, 255, 255, 0.4);
        border-color: #00ff00;
        background: linear-gradient(135deg, 
            rgba(0, 255, 0, 0.3) 0%,
            rgba(0, 255, 255, 0.2) 50%,
            rgba(0, 255, 0, 0.3) 100%
        );
    }
    100% { 
        transform: translate3d(8px, 0, 0) scale3d(1.05, 1.05, 1);
        box-shadow: 
            0 0 30px rgba(255, 215, 0, 0.6),
            0 0 60px rgba(255, 215, 0, 0.3),
            0 8px 25px rgba(0, 0, 0, 0.4),
            inset 0 1px 0 rgba(255, 255, 255, 0.3);
    }
}

/* Game over screen */
#gameOverScreen {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(20, 10, 30, 0.95);
    border: 3px solid #8b008b;
    border-radius: 10px;
    padding: 30px;
    text-align: center;
    display: none;
    pointer-events: all;
    color: #fff;
}

.souls-earned {
    font-size: 24px;
    color: #dda0dd;
    margin: 20px 0;
}

.restart-btn {
    background: #4a148c;
    color: #fff;
    border: none;
    padding: 10px 30px;
    font-size: 18px;
    cursor: var(--cm-cursor-action, pointer);
    border-radius: 5px;
    transition: all 0.3s;
    transform: scale(1); /* Bazowy stan dla płynnych animacji */
}

.restart-btn:hover:where(body:not(.gamepad-active) *) {
    background: #6a1b9a;
    transform: scale(1.1);
}

/* Gamepad selection for restart buttons */
.restart-btn.gamepad-selected {
    border: 2px solid #ffd700 !important;
    background: #6a1b9a !important;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.8) !important;
    transform: scale(1.05) !important;
}

/* Game Over - wrapper for upgrade badge */
.gameover-btn-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.gameover-upgrades-badge {
    font-family: 'SFPixelate', 'Courier New', monospace;
    font-size: 15px;
    font-weight: bold;
    color: #ffffff;
    text-shadow: 0 0 10px #ffd700, 0 0 20px #ff8c00;
    white-space: nowrap;
    margin-bottom: 8px;
    animation: gameoverBadgePulse 1.5s ease-in-out infinite;
}

@keyframes gameoverBadgePulse {
    0%, 100% { opacity: 1; text-shadow: 0 0 10px #ffd700, 0 0 20px #ff8c00; }
    50% { opacity: 0.8; text-shadow: 0 0 15px #ffd700, 0 0 30px #ff8c00, 0 0 40px #ffd700; }
}

/* Glow na przycisku gdy są ulepszenia */
.gameover-btn-wrapper.has-upgrades .restart-btn {
    animation: gameoverButtonGlow 1.5s ease-in-out infinite;
    border: 2px solid #ffd700 !important;
}

@keyframes gameoverButtonGlow {
    0%, 100% {
        box-shadow: 0 0 15px rgba(255, 215, 0, 0.5), 0 0 30px rgba(255, 140, 0, 0.3);
    }
    50% {
        box-shadow: 0 0 25px rgba(255, 215, 0, 0.8), 0 0 50px rgba(255, 140, 0, 0.5);
    }
}

/* Game Over screen gamepad hints positioning */
#gameOverScreen .gamepad-hints {
    position: absolute;
    bottom: -80px; /* Position below the game over screen */
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.95);
    border: 2px solid #8b008b;
    border-radius: 12px;
    padding: 12px 20px;
    font-family: 'SFPixelate', 'Serif', serif;
    font-size: 12px;
    color: #dda0dd;
    box-shadow: 
        0 0 20px rgba(0, 0, 0, 0.7),
        inset 0 0 10px rgba(139, 0, 139, 0.2);
    animation: fadeInHints 0.5s ease-out;
    white-space: nowrap;
    display: flex;
    gap: 15px;
    align-items: center;
}

#gameOverScreen .gamepad-hints .hint-item {
    color: #ccc;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    margin: 0;
}

#gameOverScreen .gamepad-hints .hint-item:first-child {
    color: #ffd700;
    font-weight: bold;
    border-right: 1px solid rgba(139, 0, 139, 0.5);
    padding-right: 15px;
    margin-right: 0;
}

@keyframes fadeInHints {
    from { 
        opacity: 0; 
        transform: translateX(-50%) translateY(10px);
    }
    to { 
        opacity: 1; 
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes ornamentGlow {
    0%, 100% { 
        text-shadow: 0 0 5px rgba(221, 160, 221, 0.8);
    }
    50% { 
        text-shadow: 
            0 0 10px rgba(221, 160, 221, 1),
            0 0 20px rgba(138, 43, 226, 0.8);
    }
}

@keyframes levelSymbolPulse {
    0%, 100% { 
        text-shadow: 0 0 10px rgba(255, 215, 0, 0.8);
        transform: scale3d(1, 1, 1);
    }
    50% { 
        text-shadow: 
            0 0 20px rgba(255, 215, 0, 1),
            0 0 40px rgba(255, 215, 0, 0.6);
        transform: scale3d(1.05, 1.05, 1);
    }
}

@keyframes borderFlow {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes titleGlow {
    0%, 100% { opacity: 0.3; transform: scale3d(1, 1, 1); }
    50% { opacity: 0.6; transform: scale3d(1.02, 1.02, 1); }
}

@keyframes pageGlow {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 0.9; }
}

@keyframes symbolPulse {
    0%, 100% { 
        text-shadow: 0 0 5px rgba(255, 215, 0, 0.8);
        transform: scale3d(1, 1, 1);
    }
    50% { 
        text-shadow: 
            0 0 15px rgba(255, 215, 0, 1),
            0 0 25px rgba(255, 215, 0, 0.6);
        transform: scale3d(1.1, 1.1, 1);
    }
}

@keyframes categoryIconPulse {
    0%, 100% { 
        text-shadow: 
            0 0 10px rgba(255, 215, 0, 0.8),
            0 0 20px rgba(255, 215, 0, 0.4);
        transform: scale3d(1, 1, 1);
    }
    50% { 
        text-shadow: 
            0 0 20px rgba(255, 215, 0, 1),
            0 0 40px rgba(255, 215, 0, 0.6);
        transform: scale3d(1.05, 1.05, 1);
    }
}

@keyframes progressGlow {
    0%, 100% { 
        box-shadow: 
            0 0 15px rgba(255, 215, 0, 0.5),
            inset 0 0 5px rgba(255, 255, 255, 0.3);
    }
    50% { 
        box-shadow: 
            0 0 25px rgba(255, 215, 0, 0.8),
            inset 0 0 8px rgba(255, 255, 255, 0.4);
    }
}

@keyframes progressShine {
    0% { transform: translate3d(-100%, 0, 0); }
    100% { transform: translate3d(100%, 0, 0); }
}

@keyframes spellEntryAppear {
    0% { 
        opacity: 0; 
        transform: translate3d(0, 30px, 0) scale3d(0.9, 0.9, 1);
    }
    100% { 
        opacity: 1; 
        transform: translate3d(0, 0, 0) scale3d(1, 1, 1);
    }
}

@keyframes spellIconGlow {
    0%, 100% { 
        text-shadow: 
            0 0 15px rgba(255, 215, 0, 0.8),
            0 0 30px rgba(255, 215, 0, 0.4);
        transform: scale(1);
    }
    50% { 
        text-shadow: 
            0 0 25px rgba(255, 215, 0, 1),
            0 0 50px rgba(255, 215, 0, 0.6);
        transform: scale(1.05);
    }
}

/* Vampire Survivors style animations */
@keyframes levelUpFadeIn {
    0% { 
        opacity: 0; 
        background: rgba(0, 0, 0, 0.7);
    }
    100% { 
        opacity: 1; 
        background: rgba(0, 0, 0, 0.9);
    }
}

@keyframes levelUpPulse {
    0% { 
        text-shadow: 
            3px 3px 0px #000000,
            0 0 10px rgba(255, 255, 0, 0.8);
        transform: scale3d(1, 1, 1);
    }
    100% { 
        text-shadow: 
            3px 3px 0px #000000,
            0 0 20px rgba(255, 255, 0, 1),
            0 0 40px rgba(255, 255, 0, 0.6);
        transform: scale3d(1.02, 1.02, 1);
    }
}

@keyframes cardSlideIn {
    0% { 
        opacity: 0; 
        transform: translate3d(0, 30px, 0) scale3d(0.8, 0.8, 1);
    }
    100% { 
        opacity: 1; 
        transform: translate3d(0, 0, 0) scale3d(1, 1, 1);
    }
}

@keyframes iconFloat {
    0% { transform: translate3d(0, 0px, 0); }
    100% { transform: translate3d(0, -3px, 0); }
}

@keyframes selectedGlow {
    0% { 
        box-shadow: 
            0 0 40px rgba(255, 255, 0, 0.8),
            0 0 80px rgba(255, 255, 0, 0.4),
            0 10px 30px rgba(0, 0, 0, 0.5);
    }
    100% { 
        box-shadow: 
            0 0 50px rgba(255, 255, 0, 1),
            0 0 100px rgba(255, 255, 0, 0.6),
            0 12px 35px rgba(0, 0, 0, 0.6);
    }
}

@keyframes selectedBadge {
    0% { 
        box-shadow: 
            0 4px 8px rgba(0, 0, 0, 0.5),
            0 0 25px rgba(255, 255, 0, 0.8);
    }
    100% { 
        box-shadow: 
            0 6px 12px rgba(0, 0, 0, 0.6),
            0 0 35px rgba(255, 255, 0, 1),
            0 0 60px rgba(255, 255, 255, 0.4);
    }
}

@keyframes selectedIconPulse {
    0% { 
        text-shadow: 
            0 0 15px rgba(255, 255, 0, 0.8),
            2px 2px 4px rgba(0, 0, 0, 0.8);
        filter: drop-shadow(0 0 12px rgba(255, 255, 0, 0.7));
        transform: scale3d(1, 1, 1);
    }
    100% { 
        text-shadow: 
            0 0 25px rgba(255, 255, 0, 1),
            0 0 50px rgba(255, 255, 0, 0.6),
            2px 2px 4px rgba(0, 0, 0, 0.8);
        filter: drop-shadow(0 0 20px rgba(255, 255, 0, 1));
        transform: scale3d(1.05, 1.05, 1);
    }
}

@keyframes sparkle {
    0% { 
        opacity: 0.8;
        background-size: 100% 100%;
    }
    50% { 
        opacity: 1;
        background-size: 120% 120%;
    }
    100% { 
        opacity: 0.8;
        background-size: 100% 100%;
    }
}

/* One shared version label for every menu, matching the main menu. */
#versionIndicator {
    position: fixed;
    bottom: 0;
    right: 0;
    background: none;
    border: 0;
    padding: 0;
    color: #c8ad7e;
    font: clamp(18px, 1.3vw, 26px) 'SFPixelate', monospace;
    pointer-events: none;
    z-index: 1000000;
}
