* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 30px;
    color: white;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

.controls {
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    margin-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: center;
    justify-content: center;
}

.control-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.control-group label {
    font-weight: 600;
    color: #555;
    font-size: 0.9rem;
}

select {
    padding: 8px 12px;
    border: 2px solid #e1e8ed;
    border-radius: 5px;
    background: white;
    font-size: 1rem;
    transition: all 0.3s ease;
}

select:focus {
    outline: none;
    border-color: #667eea;
}

input[type="range"] {
    width: 140px;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: #e1e8ed;
    border-radius: 3px;
    outline: none;
    cursor: pointer;
    transition: all 0.3s ease;
}

input[type="range"]:hover {
    background: #d5dae1;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: linear-gradient(45deg, #667eea, #764ba2);
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.3);
    transition: all 0.2s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 3px 8px rgba(102, 126, 234, 0.4);
}

input[type="range"]::-webkit-slider-thumb:active {
    transform: scale(0.95);
}

/* Firefox */
input[type="range"]::-moz-range-track {
    width: 100%;
    height: 6px;
    cursor: pointer;
    background: #e1e8ed;
    border-radius: 3px;
    border: none;
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: linear-gradient(45deg, #667eea, #764ba2);
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.3);
    transition: all 0.2s ease;
}

input[type="range"]::-moz-range-thumb:hover {
    transform: scale(1.1);
}

/* Edge/IE */
input[type="range"]::-ms-track {
    width: 100%;
    height: 6px;
    cursor: pointer;
    background: transparent;
    border-color: transparent;
    color: transparent;
}

input[type="range"]::-ms-fill-lower {
    background: #e1e8ed;
    border-radius: 3px;
}

input[type="range"]::-ms-fill-upper {
    background: #e1e8ed;
    border-radius: 3px;
}

input[type="range"]::-ms-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: linear-gradient(45deg, #667eea, #764ba2);
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.3);
}

#size-value, #speed-value {
    font-weight: bold;
    color: #667eea;
    min-width: 20px;
    text-align: center;
}

.button-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

button {
    padding: 12px 20px;
    border: none;
    border-radius: 5px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#generate-btn {
    background: #3498db;
    color: white;
}

#generate-btn:hover {
    background: #2980b9;
    transform: translateY(-2px);
}

#start-btn {
    background: #2ecc71;
    color: white;
}

#start-btn:hover {
    background: #27ae60;
    transform: translateY(-2px);
}

#stop-btn {
    background: #e74c3c;
    color: white;
}

#stop-btn:hover:not(:disabled) {
    background: #c0392b;
    transform: translateY(-2px);
}

#reset-btn {
    background: #f39c12;
    color: white;
}

#reset-btn:hover {
    background: #e67e22;
    transform: translateY(-2px);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.info-panel {
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    margin-bottom: 20px;
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

.algorithm-info h3 {
    color: #667eea;
    font-size: 1.5rem;
    margin-bottom: 10px;
}

.algorithm-info p {
    line-height: 1.6;
    margin-bottom: 15px;
    color: #666;
}

.complexity {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.complexity span {
    background: #f8f9fa;
    padding: 8px 12px;
    border-radius: 5px;
    font-size: 0.9rem;
    border-left: 4px solid #667eea;
}

.stats {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.stat {
    display: flex;
    justify-content: space-between;
    padding: 10px 15px;
    background: #f8f9fa;
    border-radius: 5px;
    border-left: 4px solid #2ecc71;
}

.stat-label {
    font-weight: 600;
    color: #555;
}

.stat span:last-child {
    font-weight: bold;
    color: #2ecc71;
}

.visualization-container {
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    margin-bottom: 20px;
    text-align: center;
}

#visualization-canvas {
    border: 2px solid #e1e8ed;
    border-radius: 5px;
    background: white;
}

.legend {
    background: none;
    padding: 10px 0;
    margin-bottom: 15px;
    border-bottom: 1px solid #e1e8ed;
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 3px;
    border: 2px solid rgba(0,0,0,0.1);
}

.legend-item span {
    font-size: 0.9rem;
    font-weight: 600;
    color: #555;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    header h1 {
        font-size: 2rem;
    }

    .controls {
        flex-direction: column;
        gap: 15px;
    }

    .button-group {
        justify-content: center;
    }

    .info-panel {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .complexity {
        flex-direction: column;
        gap: 10px;
    }

    .legend {
        gap: 15px;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.5rem;
    }

    .button-group {
        flex-direction: column;
        width: 100%;
    }

    button {
        width: 100%;
    }

    .legend {
        flex-direction: column;
        align-items: center;
    }
}

/* Animation classes */
.highlight {
    animation: pulse 0.5s ease-in-out;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.fade-in {
    animation: fadeIn 0.3s ease-in;
}

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