/* DSA Game Styles - Modern Overhaul */

.game-container {
    max-width: 1200px;
    margin: 0 auto;
    color: white;
    font-family: 'Inter', sans-serif;
    padding-bottom: 50px;
    position: relative;
}

/* Animated background particles */
.game-container::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 30%, rgba(255, 0, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(0, 255, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 50% 50%, rgba(255, 255, 0, 0.05) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
    animation: backgroundPulse 8s ease-in-out infinite;
}

@keyframes backgroundPulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

.screen {
    display: none;
}

.screen.active {
    display: block;
    animation: fadeInSlide 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes fadeInSlide {
    from { 
        opacity: 0; 
        transform: translateY(30px) scale(0.95); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0) scale(1); 
    }
}

/* Menu Styles - Enhanced */
.level-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin-top: 40px;
}

.level-btn {
    background: linear-gradient(135deg, rgba(26, 26, 26, 0.95) 0%, rgba(20, 20, 30, 0.95) 100%);
    border: 2px solid transparent;
    padding: 28px;
    border-radius: 16px;
    cursor: pointer;
    text-align: left;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    color: white;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(10px);
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.level-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: left 0.6s;
}

.level-btn:hover::before {
    left: 100%;
}

.level-btn::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(135deg, #ff00ff, #00ffff, #ffff00, #ff00ff);
    background-size: 300% 300%;
    border-radius: 16px;
    z-index: -1;
    opacity: 0;
    transition: opacity 0.4s;
    animation: gradientShift 3s ease infinite;
}

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

.level-btn:hover::after {
    opacity: 1;
}

.level-btn:hover {
    transform: translateY(-8px) scale(1.03);
    border-color: #00ffff;
    box-shadow: 
        0 16px 48px rgba(0, 255, 255, 0.4),
        0 0 30px rgba(0, 255, 255, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.level-btn:active {
    transform: translateY(-4px) scale(1.01);
}

.level-btn h3 {
    margin: 0 0 12px 0;
    color: #00ffff;
    font-size: 1.4rem;
    font-weight: 700;
    text-shadow: 
        0 0 10px rgba(0, 255, 255, 0.5),
        0 0 20px rgba(0, 255, 255, 0.3);
    transition: all 0.3s;
    position: relative;
    z-index: 1;
}

.level-btn:hover h3 {
    color: #ffff00;
    text-shadow: 
        0 0 15px rgba(255, 255, 0, 0.7),
        0 0 30px rgba(255, 255, 0, 0.4);
    transform: translateX(5px);
}

.level-btn p {
    margin: 0;
    color: #bcdcff;
    font-size: 0.95rem;
    line-height: 1.6;
    position: relative;
    z-index: 1;
    transition: color 0.3s;
}

.level-btn:hover p {
    color: #ffffff;
}

/* Main Menu Special Styling */
#main-menu .level-btn {
    text-align: center;
    padding: 50px 40px;
    background: linear-gradient(135deg, rgba(0, 255, 255, 0.1) 0%, rgba(255, 0, 255, 0.1) 100%);
}

#main-menu .level-btn h3 {
    font-size: 2rem;
    margin-bottom: 20px;
    background: linear-gradient(135deg, #00ffff, #ff00ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#main-menu .level-btn:hover {
    background: linear-gradient(135deg, rgba(0, 255, 255, 0.2) 0%, rgba(255, 0, 255, 0.2) 100%);
}

/* Difficulty Modal Options */
.difficulty-options {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 30px;
}

.difficulty-btn {
    text-align: center;
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.difficulty-btn.easy { 
    border-color: #00ff00;
    background: linear-gradient(135deg, rgba(0, 255, 0, 0.1) 0%, rgba(0, 200, 0, 0.1) 100%);
}

.difficulty-btn.medium { 
    border-color: #ffff00;
    background: linear-gradient(135deg, rgba(255, 255, 0, 0.1) 0%, rgba(200, 200, 0, 0.1) 100%);
}

.difficulty-btn.hard { 
    border-color: #ff5555;
    background: linear-gradient(135deg, rgba(255, 85, 85, 0.1) 0%, rgba(200, 50, 50, 0.1) 100%);
}

.difficulty-btn.easy:hover { 
    background: linear-gradient(135deg, rgba(0, 255, 0, 0.2) 0%, rgba(0, 200, 0, 0.2) 100%);
    box-shadow: 0 0 30px rgba(0, 255, 0, 0.4);
}

.difficulty-btn.medium:hover { 
    background: linear-gradient(135deg, rgba(255, 255, 0, 0.2) 0%, rgba(200, 200, 0, 0.2) 100%);
    box-shadow: 0 0 30px rgba(255, 255, 0, 0.4);
}

.difficulty-btn.hard:hover { 
    background: linear-gradient(135deg, rgba(255, 85, 85, 0.2) 0%, rgba(200, 50, 50, 0.2) 100%);
    box-shadow: 0 0 30px rgba(255, 85, 85, 0.4);
}

/* HUD - Enhanced */
.hud {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 30px;
    background: linear-gradient(135deg, rgba(26, 26, 26, 0.95) 0%, rgba(20, 20, 30, 0.95) 100%);
    padding: 24px 32px;
    border-radius: 16px;
    border: 2px solid rgba(0, 255, 255, 0.3);
    backdrop-filter: blur(10px);
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.4),
        0 0 20px rgba(0, 255, 255, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
}

.hud::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, #00ffff, transparent);
    animation: scanline 2s linear infinite;
}

@keyframes scanline {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

#level-title {
    margin: 0 0 8px 0;
    color: #00ffff;
    font-size: 1.8rem;
    font-weight: 800;
    text-shadow: 
        0 0 10px rgba(0, 255, 255, 0.6),
        0 0 20px rgba(0, 255, 255, 0.4);
    letter-spacing: 1px;
}

#instructions {
    color: #bcdcff;
    font-size: 1rem;
    line-height: 1.5;
}

.stats-box {
    text-align: right;
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: flex-end;
}

#stats {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.4rem;
    color: #ff00ff;
    font-weight: 700;
    text-shadow: 
        0 0 10px rgba(255, 0, 255, 0.6),
        0 0 20px rgba(255, 0, 255, 0.4);
    padding: 8px 16px;
    background: rgba(255, 0, 255, 0.1);
    border-radius: 8px;
    border: 1px solid rgba(255, 0, 255, 0.3);
}

.btn-small {
    background: linear-gradient(135deg, rgba(68, 68, 68, 0.8) 0%, rgba(50, 50, 50, 0.8) 100%);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s;
    backdrop-filter: blur(10px);
}

.btn-small:hover {
    color: #00ffff;
    border-color: #00ffff;
    background: linear-gradient(135deg, rgba(0, 255, 255, 0.2) 0%, rgba(0, 200, 255, 0.2) 100%);
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.4);
    transform: translateY(-2px);
}

/* Playback Controls */
.controls-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-top: 30px;
    background: linear-gradient(135deg, rgba(26, 26, 26, 0.95) 0%, rgba(20, 20, 30, 0.95) 100%);
    padding: 16px 24px;
    border-radius: 16px;
    border: 2px solid rgba(0, 255, 255, 0.3);
    backdrop-filter: blur(10px);
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.4),
        0 0 20px rgba(0, 255, 255, 0.2);
}

.btn-control {
    background: linear-gradient(135deg, rgba(51, 51, 51, 0.9) 0%, rgba(40, 40, 40, 0.9) 100%);
    color: white;
    border: 2px solid rgba(0, 255, 255, 0.4);
    padding: 12px 24px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 700;
    font-size: 1rem;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.btn-control:hover {
    background: linear-gradient(135deg, rgba(0, 255, 255, 0.3) 0%, rgba(0, 200, 255, 0.3) 100%);
    border-color: #00ffff;
    box-shadow: 
        0 0 25px rgba(0, 255, 255, 0.5),
        0 4px 20px rgba(0, 0, 0, 0.4);
    transform: translateY(-2px) scale(1.05);
}

.btn-control:active {
    transform: translateY(0) scale(1);
}

/* Game Area - Enhanced */
#canvas-wrapper {
    background: linear-gradient(135deg, rgba(13, 13, 13, 0.95) 0%, rgba(8, 8, 18, 0.95) 100%);
    border-radius: 20px;
    border: 2px solid rgba(0, 255, 255, 0.3);
    min-height: 450px;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 50px;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(10px);
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.5),
        inset 0 0 50px rgba(0, 255, 255, 0.05);
}

#canvas-wrapper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 30%, rgba(0, 255, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(255, 0, 255, 0.1) 0%, transparent 50%);
    pointer-events: none;
    animation: backgroundPulse 6s ease-in-out infinite;
}

/* Info Box */
.info-box {
    margin-top: 30px;
    background: linear-gradient(135deg, rgba(26, 26, 26, 0.95) 0%, rgba(20, 20, 30, 0.95) 100%);
    padding: 28px;
    border-radius: 16px;
    border: 2px solid rgba(0, 255, 0, 0.3);
    backdrop-filter: blur(10px);
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.4),
        0 0 20px rgba(0, 255, 0, 0.2);
    position: relative;
    overflow: hidden;
}

.info-box::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, #00ff00, #00ffff);
    animation: infoGlow 2s ease-in-out infinite;
}

@keyframes infoGlow {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; box-shadow: 0 0 20px #00ff00; }
}

.info-box h3 {
    margin-top: 0;
    color: #00ff00;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.4rem;
    font-weight: 700;
    text-shadow: 0 0 10px rgba(0, 255, 0, 0.5);
}

.info-box h3 .icon {
    font-size: 1.6rem;
    filter: drop-shadow(0 0 8px rgba(0, 255, 0, 0.6));
}

.info-box p {
    color: #e0e0e0;
    line-height: 1.8;
    margin-bottom: 0;
    font-size: 1rem;
}

/* --- Specific Game Elements --- */

/* Bubble Sort - Enhanced Bars */
.bar {
    width: 45px;
    margin: 0 6px;
    background: linear-gradient(180deg, #444 0%, #333 100%);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    border-radius: 8px 8px 0 0;
    position: relative;
    cursor: pointer;
    align-self: flex-end;
    box-shadow: 
        0 4px 15px rgba(0, 0, 0, 0.4),
        inset 0 -2px 10px rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.bar:hover {
    background: linear-gradient(180deg, #555 0%, #444 100%);
    transform: translateY(-5px) scale(1.05);
    box-shadow: 
        0 8px 25px rgba(0, 255, 255, 0.3),
        0 0 20px rgba(0, 255, 255, 0.2);
    border-color: rgba(0, 255, 255, 0.5);
}

.bar.selected {
    background: linear-gradient(180deg, #00ffff 0%, #00aaff 100%) !important;
    box-shadow: 
        0 0 30px rgba(0, 255, 255, 0.8),
        0 0 60px rgba(0, 255, 255, 0.4),
        inset 0 0 20px rgba(255, 255, 255, 0.3);
    border-color: #00ffff;
    transform: translateY(-8px) scale(1.1);
    animation: selectedPulse 1s ease-in-out infinite;
}

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

.bar.sorted {
    background: linear-gradient(180deg, #00ff00 0%, #00aa00 100%) !important;
    box-shadow: 
        0 0 25px rgba(0, 255, 0, 0.6),
        inset 0 0 15px rgba(255, 255, 255, 0.2);
    border-color: #00ff00;
    animation: sortedGlow 2s ease-in-out infinite;
}

@keyframes sortedGlow {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.9; }
}

.bar-value {
    position: absolute;
    bottom: -30px;
    width: 100%;
    text-align: center;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    color: #bcdcff;
    font-weight: 600;
    text-shadow: 0 0 5px rgba(188, 220, 255, 0.5);
}

/* Binary Search - Enhanced Cells */
.array-cell {
    width: 60px;
    height: 60px;
    border: 3px solid rgba(51, 51, 51, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 8px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.4rem;
    font-weight: 700;
    cursor: pointer;
    background: linear-gradient(135deg, rgba(26, 26, 26, 0.9) 0%, rgba(20, 20, 30, 0.9) 100%);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    position: relative;
    overflow: hidden;
}

.array-cell::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(0, 255, 255, 0.1) 0%, rgba(255, 0, 255, 0.1) 100%);
    opacity: 0;
    transition: opacity 0.3s;
}

.array-cell:hover {
    border-color: rgba(0, 255, 255, 0.6);
    transform: scale(1.1) rotate(5deg);
    box-shadow: 
        0 0 25px rgba(0, 255, 255, 0.4),
        0 8px 30px rgba(0, 0, 0, 0.5);
}

.array-cell:hover::before {
    opacity: 1;
}

.array-cell.active {
    border-color: #00ffff;
    background: linear-gradient(135deg, rgba(0, 255, 255, 0.3) 0%, rgba(0, 200, 255, 0.3) 100%);
    box-shadow: 0 0 30px rgba(0, 255, 255, 0.6);
    animation: activePulse 1.5s ease-in-out infinite;
}

@keyframes activePulse {
    0%, 100% { 
        box-shadow: 0 0 30px rgba(0, 255, 255, 0.6);
        transform: scale(1);
    }
    50% { 
        box-shadow: 0 0 40px rgba(0, 255, 255, 0.9);
        transform: scale(1.05);
    }
}

.array-cell.found {
    background: linear-gradient(135deg, #00ff00 0%, #00aa00 100%);
    color: #000;
    border-color: #00ff00;
    box-shadow: 
        0 0 40px rgba(0, 255, 0, 0.8),
        0 0 80px rgba(0, 255, 0, 0.4);
    animation: foundCelebration 0.6s ease-out;
}

@keyframes foundCelebration {
    0% { transform: scale(1) rotate(0deg); }
    50% { transform: scale(1.3) rotate(180deg); }
    100% { transform: scale(1) rotate(360deg); }
}

.array-cell.checked {
    background: linear-gradient(135deg, rgba(255, 0, 0, 0.4) 0%, rgba(200, 0, 0, 0.4) 100%);
    color: white;
    border-color: rgba(255, 0, 0, 0.6);
    opacity: 0.7;
}

/* BST Nodes - Enhanced */
.tree-container {
    position: relative;
    width: 100%;
    height: 500px;
    background: radial-gradient(circle at center, rgba(0, 255, 255, 0.05) 0%, transparent 70%);
    border-radius: 16px;
    padding: 20px;
}

.tree-node {
    position: absolute;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(26, 26, 26, 0.95) 0%, rgba(20, 20, 30, 0.95) 100%);
    border: 3px solid #00ffff;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 700;
    font-size: 1.1rem;
    color: white;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 2;
    cursor: pointer;
    box-shadow: 
        0 4px 20px rgba(0, 0, 0, 0.4),
        0 0 15px rgba(0, 255, 255, 0.3);
    backdrop-filter: blur(10px);
}

.tree-node:hover {
    transform: scale(1.2) rotate(360deg);
    box-shadow: 
        0 0 30px rgba(0, 255, 255, 0.8),
        0 0 60px rgba(0, 255, 255, 0.4),
        0 8px 30px rgba(0, 0, 0, 0.5);
    border-color: #ffff00;
    background: linear-gradient(135deg, rgba(0, 255, 255, 0.2) 0%, rgba(255, 0, 255, 0.2) 100%);
}

.tree-node.visited {
    background: linear-gradient(135deg, rgba(51, 51, 51, 0.8) 0%, rgba(40, 40, 40, 0.8) 100%);
    border-color: #666;
    color: #aaa;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.tree-node.target {
    border-color: #ff00ff;
    box-shadow: 
        0 0 25px rgba(255, 0, 255, 0.8),
        0 0 50px rgba(255, 0, 255, 0.4);
    animation: targetPulse 2s ease-in-out infinite;
}

@keyframes targetPulse {
    0%, 100% { 
        box-shadow: 
            0 0 25px rgba(255, 0, 255, 0.8),
            0 0 50px rgba(255, 0, 255, 0.4);
    }
    50% { 
        box-shadow: 
            0 0 35px rgba(255, 0, 255, 1),
            0 0 70px rgba(255, 0, 255, 0.6);
    }
}

.tree-node.found {
    background: linear-gradient(135deg, #00ff00 0%, #00aa00 100%);
    border-color: #00ff00;
    color: black;
    box-shadow: 
        0 0 40px rgba(0, 255, 0, 0.9),
        0 0 80px rgba(0, 255, 0, 0.5);
    animation: foundCelebration 0.8s ease-out;
}

/* BFS / Dijkstra Grid - Enhanced */
.grid-container {
    display: grid;
    gap: 6px;
    background: linear-gradient(135deg, rgba(17, 17, 17, 0.9) 0%, rgba(10, 10, 20, 0.9) 100%);
    padding: 15px;
    border-radius: 12px;
    border: 2px solid rgba(0, 255, 255, 0.2);
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.5),
        inset 0 0 30px rgba(0, 255, 255, 0.05);
}

.grid-cell {
    width: 35px;
    height: 35px;
    background: linear-gradient(135deg, rgba(34, 34, 34, 0.9) 0%, rgba(25, 25, 25, 0.9) 100%);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.75rem;
    font-weight: 700;
    position: relative;
    border: 2px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.grid-cell:hover {
    background: linear-gradient(135deg, rgba(51, 51, 51, 0.9) 0%, rgba(40, 40, 40, 0.9) 100%);
    transform: scale(1.15);
    box-shadow: 
        0 0 20px rgba(0, 255, 255, 0.4),
        0 4px 15px rgba(0, 0, 0, 0.4);
    border-color: rgba(0, 255, 255, 0.6);
    z-index: 10;
}

.grid-cell.wall {
    background: linear-gradient(135deg, #555 0%, #333 100%);
    cursor: not-allowed;
    border-color: rgba(255, 255, 255, 0.05);
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.5);
}

.grid-cell.start {
    background: linear-gradient(135deg, #00ffff 0%, #00aaff 100%);
    color: black;
    border-color: #00ffff;
    box-shadow: 
        0 0 25px rgba(0, 255, 255, 0.8),
        0 0 50px rgba(0, 255, 255, 0.4);
    animation: startPulse 2s ease-in-out infinite;
}

@keyframes startPulse {
    0%, 100% { 
        box-shadow: 
            0 0 25px rgba(0, 255, 255, 0.8),
            0 0 50px rgba(0, 255, 255, 0.4);
    }
    50% { 
        box-shadow: 
            0 0 35px rgba(0, 255, 255, 1),
            0 0 70px rgba(0, 255, 255, 0.6);
    }
}

.grid-cell.end {
    background: linear-gradient(135deg, #ff00ff 0%, #aa00aa 100%);
    color: white;
    border-color: #ff00ff;
    box-shadow: 
        0 0 25px rgba(255, 0, 255, 0.8),
        0 0 50px rgba(255, 0, 255, 0.4);
    animation: endPulse 2s ease-in-out infinite;
}

@keyframes endPulse {
    0%, 100% { 
        box-shadow: 
            0 0 25px rgba(255, 0, 255, 0.8),
            0 0 50px rgba(255, 0, 255, 0.4);
    }
    50% { 
        box-shadow: 
            0 0 35px rgba(255, 0, 255, 1),
            0 0 70px rgba(255, 0, 255, 0.6);
    }
}

.grid-cell.path {
    background: linear-gradient(135deg, #00ff00 0%, #00aa00 100%);
    border-color: #00ff00;
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.6);
}

.grid-cell.visited {
    background: linear-gradient(135deg, rgba(0, 68, 68, 0.8) 0%, rgba(0, 50, 50, 0.8) 100%);
    border-color: rgba(0, 255, 255, 0.4);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.3);
}

/* Dijkstra Cost styling */
.grid-cell.dijkstra {
    font-size: 0.7rem;
    color: #bcdcff;
    font-weight: 700;
}

.grid-cell.dijkstra:hover {
    color: #ffffff;
}

.grid-cell.dijkstra.start, .grid-cell.dijkstra.end {
    color: #000;
    font-weight: 900;
}

/* Modal - Enhanced */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
}

.modal.open {
    display: flex;
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
}

.modal-content {
    background: linear-gradient(135deg, rgba(26, 26, 26, 0.98) 0%, rgba(20, 20, 30, 0.98) 100%);
    padding: 40px;
    border-radius: 24px;
    border: 3px solid rgba(0, 255, 255, 0.5);
    position: relative;
    z-index: 1001;
    text-align: center;
    max-width: 500px;
    width: 90%;
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.7),
        0 0 40px rgba(0, 255, 255, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    animation: modalSlideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
}

.modal-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #ff00ff, #00ffff, #ffff00, #ff00ff);
    background-size: 300% 100%;
    animation: gradientShift 3s ease infinite;
}

@keyframes modalSlideUp {
    from { 
        opacity: 0; 
        transform: translateY(50px) scale(0.9); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0) scale(1); 
    }
}

.modal-content h2 {
    color: #00ff00;
    margin-top: 0;
    font-size: 2rem;
    font-weight: 800;
    text-shadow: 
        0 0 15px rgba(0, 255, 0, 0.6),
        0 0 30px rgba(0, 255, 0, 0.4);
    margin-bottom: 20px;
}

.stats-summary {
    margin: 25px 0;
    font-size: 1.2rem;
    color: #e0e0e0;
    background: linear-gradient(135deg, rgba(34, 34, 34, 0.9) 0%, rgba(25, 25, 25, 0.9) 100%);
    padding: 20px;
    border-radius: 12px;
    border: 2px solid rgba(0, 255, 255, 0.3);
    box-shadow: 
        0 4px 20px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.modal-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 30px;
    flex-wrap: wrap;
}

.btn-primary, .btn-secondary {
    padding: 14px 28px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 700;
    border: none;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: linear-gradient(135deg, #00ffff 0%, #00aaff 100%);
    color: #000;
    box-shadow: 
        0 4px 20px rgba(0, 255, 255, 0.4),
        0 0 30px rgba(0, 255, 255, 0.2);
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s;
}

.btn-primary:hover::before {
    left: 100%;
}

.btn-primary:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 
        0 8px 30px rgba(0, 255, 255, 0.6),
        0 0 50px rgba(0, 255, 255, 0.4);
}

.btn-secondary {
    background: linear-gradient(135deg, rgba(51, 51, 51, 0.9) 0%, rgba(40, 40, 40, 0.9) 100%);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.btn-secondary:hover {
    background: linear-gradient(135deg, rgba(68, 68, 68, 0.9) 0%, rgba(55, 55, 55, 0.9) 100%);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-3px) scale(1.05);
    box-shadow: 
        0 8px 25px rgba(0, 0, 0, 0.5),
        0 0 20px rgba(255, 255, 255, 0.2);
}

/* Tower of Hanoi - Enhanced */
.tower {
    width: 180px;
    height: 350px;
    position: relative;
    display: flex;
    justify-content: center;
    border-bottom: 6px solid rgba(51, 51, 51, 0.8);
    transition: all 0.3s;
    border-radius: 8px;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.2) 0%, transparent 100%);
}

.tower:hover {
    border-bottom-color: rgba(0, 255, 255, 0.6);
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.3);
}

.tower.selected {
    border-bottom-color: #00ffff;
    background: linear-gradient(180deg, rgba(0, 255, 255, 0.15) 0%, transparent 100%);
    box-shadow: 
        0 0 30px rgba(0, 255, 255, 0.5),
        inset 0 0 20px rgba(0, 255, 255, 0.1);
}

.tower-pole {
    position: absolute;
    bottom: 0;
    width: 8px;
    height: 280px;
    background: linear-gradient(180deg, #666 0%, #444 100%);
    border-radius: 4px 4px 0 0;
    z-index: 1;
    box-shadow: 
        0 0 10px rgba(0, 0, 0, 0.5),
        inset 0 0 10px rgba(255, 255, 255, 0.1);
}

.disks-container {
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    height: 100%;
    z-index: 2;
    padding-bottom: 0;
}

.disk {
    height: 30px;
    border-radius: 6px;
    border: 2px solid rgba(0, 0, 0, 0.4);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    margin-bottom: 3px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.9rem;
    font-weight: 700;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 
        0 4px 15px rgba(0, 0, 0, 0.4),
        inset 0 2px 5px rgba(255, 255, 255, 0.2);
    position: relative;
}

.disk::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.2) 0%, transparent 50%);
    border-radius: 6px;
}

.disk:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 
        0 8px 25px rgba(0, 255, 255, 0.4),
        0 0 30px rgba(0, 255, 255, 0.2);
}

/* Visualization Styles - Enhanced */
#viz-canvas {
    transition: all 0.3s ease;
    border: 2px solid rgba(0, 255, 255, 0.3);
    border-radius: 16px;
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.5),
        inset 0 0 30px rgba(0, 255, 255, 0.05);
}

#viz-speed, #viz-size {
    -webkit-appearance: none;
    width: 120px;
    height: 8px;
    background: linear-gradient(90deg, #333 0%, #444 100%);
    border-radius: 4px;
    outline: none;
    border: 1px solid rgba(0, 255, 255, 0.3);
}

#viz-speed::-webkit-slider-thumb, #viz-size::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, #00ffff 0%, #00aaff 100%);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 
        0 0 15px rgba(0, 255, 255, 0.6),
        0 4px 10px rgba(0, 0, 0, 0.3);
    transition: all 0.3s;
}

#viz-speed::-webkit-slider-thumb:hover, #viz-size::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 
        0 0 25px rgba(0, 255, 255, 0.9),
        0 6px 15px rgba(0, 0, 0, 0.4);
}

#viz-speed::-moz-range-thumb, #viz-size::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, #00ffff 0%, #00aaff 100%);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 
        0 0 15px rgba(0, 255, 255, 0.6),
        0 4px 10px rgba(0, 0, 0, 0.3);
}

/* Knapsack Challenge - Enhanced */
.knapsack-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.item-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 20px;
    width: 100%;
    margin-top: 30px;
}

.knapsack-item {
    background: linear-gradient(135deg, rgba(34, 34, 34, 0.9) 0%, rgba(25, 25, 25, 0.9) 100%);
    border: 3px solid rgba(68, 68, 68, 0.8);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    backdrop-filter: blur(10px);
    box-shadow: 
        0 4px 20px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
}

.knapsack-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(0, 255, 255, 0.1) 0%, rgba(255, 0, 255, 0.1) 100%);
    opacity: 0;
    transition: opacity 0.3s;
}

.knapsack-item:hover {
    border-color: rgba(0, 255, 255, 0.6);
    transform: translateY(-8px) scale(1.05);
    box-shadow: 
        0 8px 30px rgba(0, 255, 255, 0.4),
        0 0 40px rgba(0, 255, 255, 0.2);
}

.knapsack-item:hover::before {
    opacity: 1;
}

.knapsack-item.selected {
    border-color: #00ffff;
    background: linear-gradient(135deg, rgba(0, 255, 255, 0.2) 0%, rgba(0, 200, 255, 0.2) 100%);
    box-shadow: 
        0 0 30px rgba(0, 255, 255, 0.6),
        0 8px 35px rgba(0, 255, 255, 0.3);
    transform: scale(1.08);
}

.knapsack-stats {
    font-size: 1.4rem;
    font-family: 'JetBrains Mono', monospace;
    color: white;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.6) 0%, rgba(20, 20, 30, 0.6) 100%);
    padding: 16px 32px;
    border-radius: 12px;
    margin-bottom: 20px;
    display: flex;
    gap: 40px;
    border: 2px solid rgba(0, 255, 255, 0.3);
    box-shadow: 
        0 4px 20px rgba(0, 0, 0, 0.4),
        0 0 20px rgba(0, 255, 255, 0.2);
    font-weight: 700;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

/* Selection Sort - Enhanced */
.bar.sorted {
    animation: sortedGlow 2s ease-in-out infinite;
}

/* Responsive Design */
@media (max-width: 768px) {
    .level-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .level-btn {
        padding: 20px;
    }
    
    .hud {
        flex-direction: column;
        gap: 20px;
    }
    
    .stats-box {
        align-items: flex-start;
        text-align: left;
    }
    
    #canvas-wrapper {
        padding: 30px 20px;
        min-height: 350px;
    }
    
    .bar {
        width: 35px;
        margin: 0 4px;
    }
    
    .array-cell {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }
    
    .grid-cell {
        width: 28px;
        height: 28px;
        font-size: 0.65rem;
    }
}
