/* Level Select Menu Styles */
#levelSelectMenu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(26, 26, 45, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 200;
    font-family: 'Cairo', sans-serif;
    transition: opacity 0.5s ease;
}

#levelSelectMenu.hidden {
    display: none !important;
    opacity: 0;
}

#levelSelectMenu h1 {
    font-size: 4em;
    margin-bottom: 30px;
    color: #a32858;
    text-shadow: 4px 4px 0 #000;
}

.level-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    width: 80%;
    max-width: 1000px;
    max-height: 70vh;
    overflow-y: auto;
    padding: 20px;
}

.level-card {
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 20px;
    color: white;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex;
    flex-direction: column;
    gap: 15px;
    position: relative;
    overflow: hidden;
}

.level-card:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.3);
}

.level-card.locked {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(0.5);
}

.level-card.locked:hover {
    background: rgba(0, 0, 0, 0.4);
    transform: none;
    box-shadow: none;
    border-color: rgba(255, 255, 255, 0.1);
}

.locked-msg {
    font-size: 0.85em;
    color: #ff6b6b;
    margin-top: 5px;
}

.level-title {
    font-size: 1.8em;
    font-weight: bold;
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.level-stars .star {
    position: relative !important;
    display: inline-block;
    animation: none !important;
    background: transparent !important;
    box-shadow: none !important;
    width: auto !important;
    height: auto !important;
    font-size: 1.5em;
    margin-right: 2px;
    color: #555;
}

.level-stars .star.filled {
    color: #ffd700;
    text-shadow: 0 0 5px #ffd700;
}

.level-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.checkmark {
    color: #00e756;
    font-size: 1.5em;
    text-shadow: 0 0 10px #00e756;
}

/* ========================================
   THEMED LEVEL CARDS
   ======================================== */

/* Training Level - Warm Sanaa Rooftop Theme */
.level-card.training-card {
    background: linear-gradient(135deg, rgba(180, 120, 80, 0.8) 0%, rgba(140, 90, 60, 0.9) 100%);
    border: 2px solid #d4a574;
    box-shadow: 0 0 15px rgba(212, 165, 116, 0.3), inset 0 0 30px rgba(255, 200, 150, 0.1);
}

.level-card.training-card .level-title {
    color: #ffe4c4;
    text-shadow: 0 0 10px rgba(255, 200, 150, 0.5);
}

.level-card.training-card .training-badge {
    font-size: 0.9em;
    color: #ffd4a8;
    padding: 5px 10px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    text-shadow: 0 0 5px rgba(255, 200, 150, 0.5);
}

.level-card.training-card:hover {
    background: linear-gradient(135deg, rgba(200, 140, 90, 0.9) 0%, rgba(160, 110, 70, 0.95) 100%);
    border-color: #e8c098;
    box-shadow: 0 0 25px rgba(212, 165, 116, 0.5), inset 0 0 40px rgba(255, 200, 150, 0.2);
}

/* Water Level - Deep Ocean Theme with Random Bubbles */
.level-card.water-card {
    background: linear-gradient(180deg, #0a2a3a 0%, #051520 100%);
    border: 2px solid #2da8d8;
    box-shadow: 0 0 15px rgba(45, 168, 216, 0.3), inset 0 0 30px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.level-card.water-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 300%;
    height: 100%;
    background: linear-gradient(90deg,
            transparent 0%,
            rgba(45, 168, 216, 0.08) 25%,
            rgba(125, 227, 244, 0.12) 50%,
            rgba(45, 168, 216, 0.08) 75%,
            transparent 100%);
    animation: waterWave 4s ease-in-out infinite;
    pointer-events: none;
}

@keyframes waterWave {

    0%,
    100% {
        transform: translateX(0);
    }

    50% {
        transform: translateX(33%);
    }
}

/* Water bubbles - created dynamically via JS */
.water-bubble {
    position: absolute;
    width: 6px;
    height: 6px;
    background: radial-gradient(circle, rgba(125, 227, 244, 0.6) 0%, rgba(45, 168, 216, 0.2) 70%, transparent 100%);
    border-radius: 50%;
    pointer-events: none;
    animation: bubbleFloat linear infinite;
}

@keyframes bubbleFloat {
    0% {
        transform: translateY(0) translateX(0);
        opacity: 0;
    }

    10% {
        opacity: 0.8;
    }

    90% {
        opacity: 0.4;
    }

    100% {
        transform: translateY(-120px) translateX(var(--drift, 10px));
        opacity: 0;
    }
}

.level-card.water-card .level-title {
    color: #7de3f4;
    text-shadow: 0 0 10px rgba(45, 168, 216, 0.5);
    position: relative;
    z-index: 1;
}

.level-card.water-card .level-stars .star.filled {
    color: #4dbfce;
    text-shadow: 0 0 8px #2da8d8;
}

.level-card.water-card .level-info,
.level-card.water-card .level-meta {
    position: relative;
    z-index: 1;
}

.level-card.water-card:hover {
    background: linear-gradient(180deg, #10405a 0%, #082030 100%);
    border-color: #50c8f0;
    box-shadow: 0 0 25px rgba(45, 168, 216, 0.5), inset 0 0 40px rgba(45, 168, 216, 0.2);
}

/* Temple Level - Cobblestone Theme */
.level-card.temple-card {
    background:
        repeating-linear-gradient(0deg,
            transparent,
            transparent 8px,
            rgba(0, 0, 0, 0.3) 8px,
            rgba(0, 0, 0, 0.3) 9px),
        repeating-linear-gradient(90deg,
            transparent,
            transparent 15px,
            rgba(0, 0, 0, 0.2) 15px,
            rgba(0, 0, 0, 0.2) 16px),
        linear-gradient(135deg, #4a4a5e 0%, #35354a 50%, #2a2a3d 100%);
    border: 2px solid #606080;
    box-shadow: 0 0 15px rgba(96, 96, 128, 0.3), inset 0 0 30px rgba(0, 0, 0, 0.4);
    position: relative;
}

.level-card.temple-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(ellipse 3px 3px at 5px 5px, rgba(80, 80, 100, 0.3), transparent),
        radial-gradient(ellipse 2px 2px at 20px 12px, rgba(60, 60, 80, 0.2), transparent),
        radial-gradient(ellipse 4px 2px at 35px 8px, rgba(70, 70, 90, 0.25), transparent),
        radial-gradient(ellipse 2px 3px at 50px 15px, rgba(65, 65, 85, 0.2), transparent);
    pointer-events: none;
    opacity: 0.8;
}

/* Temple vignette effect */
.level-card.temple-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(ellipse at center, transparent 40%, rgba(0, 0, 0, 0.4) 100%);
    pointer-events: none;
    border-radius: 13px;
}

.level-card.temple-card .level-title {
    color: #b0b0d0;
    text-shadow: 0 0 10px rgba(96, 96, 128, 0.4), 2px 2px 4px rgba(0, 0, 0, 0.5);
    position: relative;
    z-index: 1;
}

.level-card.temple-card .level-stars .star.filled {
    color: #a6a6de;
    text-shadow: 0 0 8px rgba(163, 163, 222, 0.5);
}

.level-card.temple-card .level-info,
.level-card.temple-card .level-meta {
    position: relative;
    z-index: 1;
}

.level-card.temple-card:hover {
    background:
        repeating-linear-gradient(0deg,
            transparent,
            transparent 8px,
            rgba(0, 0, 0, 0.25) 8px,
            rgba(0, 0, 0, 0.25) 9px),
        repeating-linear-gradient(90deg,
            transparent,
            transparent 15px,
            rgba(0, 0, 0, 0.15) 15px,
            rgba(0, 0, 0, 0.15) 16px),
        linear-gradient(135deg, #5a5a70 0%, #45455a 50%, #38384d 100%);
    border-color: #7878a0;
    box-shadow: 0 0 25px rgba(96, 96, 128, 0.5), inset 0 0 40px rgba(0, 0, 0, 0.3);
}

/* Space Level - Deep Space Starfield Theme */
.level-card.space-card {
    background: radial-gradient(ellipse at center, #0c1525 0%, #050a12 100%);
    border: 2px solid #5dade2;
    box-shadow: 0 0 15px rgba(93, 173, 226, 0.3), inset 0 0 30px rgba(93, 173, 226, 0.1);
    position: relative;
    overflow: hidden;
}

/* Space stars - created dynamically via JS */
.space-star {
    position: absolute;
    border-radius: 50%;
    background: #fff;
    pointer-events: none;
    animation: twinkle ease-in-out infinite;
}

.space-star.moving {
    animation: starDrift ease-in-out infinite alternate, twinkle ease-in-out infinite;
}

@keyframes twinkle {

    0%,
    100% {
        opacity: var(--min-opacity, 0.3);
    }

    50% {
        opacity: var(--max-opacity, 1);
    }
}

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

    100% {
        transform: translate(var(--drift-x, -10px), var(--drift-y, 5px));
    }
}

.level-card.space-card .level-title {
    color: #aed6f1;
    text-shadow: 0 0 10px rgba(93, 173, 226, 0.5);
    position: relative;
    z-index: 1;
}

.level-card.space-card .level-stars .star.filled {
    color: #85c1e9;
    text-shadow: 0 0 8px #5dade2;
}

.level-card.space-card .level-info,
.level-card.space-card .level-meta {
    position: relative;
    z-index: 1;
}

.level-card.space-card:hover {
    background: radial-gradient(ellipse at center, #101d30 0%, #080e18 100%);
    border-color: #7dc8f0;
    box-shadow: 0 0 25px rgba(93, 173, 226, 0.5), inset 0 0 40px rgba(93, 173, 226, 0.2);
}

/* Matrix Level - Special Green Glitch Design with Rain Effect */
.level-card.matrix-card {
    background: linear-gradient(135deg, rgba(0, 40, 0, 0.9) 0%, rgba(0, 15, 0, 0.95) 100%);
    border: 2px solid #00ff41;
    box-shadow: 0 0 15px rgba(0, 255, 65, 0.3), inset 0 0 30px rgba(0, 255, 65, 0.1);
    animation: matrixGlitch 3s infinite;
    position: relative;
    overflow: hidden;
}

/* Matrix rain characters - created dynamically via JS */
.matrix-rain-char {
    position: absolute;
    font-family: 'Courier New', monospace;
    font-size: 10px;
    color: #00ff41;
    text-shadow: 0 0 5px #00ff41;
    pointer-events: none;
    opacity: 0;
    animation: matrixRainFall linear infinite;
}

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

    5% {
        opacity: var(--char-opacity, 0.7);
    }

    95% {
        opacity: var(--char-opacity, 0.5);
    }

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

.level-card.matrix-card .level-title {
    color: #00ff41;
    text-shadow: 0 0 10px #00ff41, 2px 0 0 rgba(255, 0, 0, 0.3), -2px 0 0 rgba(0, 255, 255, 0.3);
    animation: textGlitch 2s infinite;
}

.level-card.matrix-card .glitch-star {
    color: #00ff41;
    text-shadow: 0 0 8px #00ff41;
    animation: starFlicker 0.5s infinite;
}

.level-card.matrix-card .matrix-stars-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 2px;
}

.level-card.matrix-card .overflow-star {
    color: #ff0040;
    text-shadow: 0 0 10px #ff0040;
    animation: overflowPulse 0.3s infinite alternate;
}

.level-card.matrix-card .glitch-error {
    color: #ff0040;
    font-weight: bold;
    font-size: 1.2em;
    text-shadow: 0 0 15px #ff0040;
    animation: infinityGlitch 0.5s infinite;
    position: relative;
    top: 6px;
}

.level-card.matrix-card:hover {
    background: linear-gradient(135deg, rgba(0, 80, 0, 0.9) 0%, rgba(0, 40, 0, 0.95) 100%);
    border-color: #40ff70;
    box-shadow: 0 0 25px rgba(0, 255, 65, 0.5), inset 0 0 40px rgba(0, 255, 65, 0.2);
}

.level-card.matrix-card:hover .level-title {
    color: #40ff70;
    text-shadow: 0 0 15px #40ff70, 2px 0 0 rgba(255, 0, 0, 0.4), -2px 0 0 rgba(0, 255, 255, 0.4);
}

.level-card.matrix-card:hover .glitch-star {
    color: #40ff70;
    text-shadow: 0 0 12px #40ff70;
}

.level-card.matrix-card .matrix-error-msg {
    color: #ff0040;
    font-family: 'Courier New', monospace;
    font-size: 0.6em;
    margin-top: 5px;
    text-shadow: 0 0 5px #ff0040;
    animation: errorBlink 0.8s infinite;
    letter-spacing: 1px;
}

@keyframes overflowPulse {
    0% {
        opacity: 0.5;
        transform: scale(0.9);
    }

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

@keyframes infinityGlitch {

    0%,
    100% {
        transform: scale(1) rotate(0deg);
    }

    25% {
        transform: scale(1.2) rotate(5deg);
        color: #00ff41;
    }

    50% {
        transform: scale(0.9) rotate(-5deg);
    }

    75% {
        transform: scale(1.3) rotate(3deg);
        color: #ffff00;
    }
}

@keyframes errorBlink {

    0%,
    49% {
        opacity: 1;
    }

    50%,
    100% {
        opacity: 0.3;
    }
}

@keyframes matrixGlitch {

    0%,
    90%,
    100% {
        transform: translate(0);
    }

    92% {
        transform: translate(-2px, 1px);
    }

    94% {
        transform: translate(2px, -1px);
    }

    96% {
        transform: translate(-1px, 2px);
    }

    98% {
        transform: translate(1px, -2px);
    }
}

@keyframes textGlitch {

    0%,
    85%,
    100% {
        opacity: 1;
    }

    86% {
        opacity: 0.8;
        transform: skewX(5deg);
    }

    87% {
        opacity: 1;
        transform: skewX(0);
    }

    88% {
        opacity: 0.9;
        transform: skewX(-3deg);
    }

    89% {
        opacity: 1;
        transform: skewX(0);
    }
}

@keyframes starFlicker {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

@keyframes glitchChar {

    0%,
    100% {
        content: '¿';
        opacity: 0.8;
    }

    25% {
        opacity: 0.4;
    }

    50% {
        opacity: 1;
    }

    75% {
        opacity: 0.6;
    }
}

@keyframes corruptFlash {

    0%,
    100% {
        opacity: 0.3;
    }

    50% {
        opacity: 0.7;
        color: #ff0040;
    }
}

.level-list::-webkit-scrollbar {
    width: 8px;
}

.level-list::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

.level-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.level-list::-webkit-scrollbar-thumb:hover {
    background: #a32858;
}