* {
    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;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

h1 {
    text-align: center;
    color: #333;
    margin-bottom: 30px;
    font-size: 2.5em;
}

.controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

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

input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #ddd;
    outline: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    transition: all 0.3s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    background: #764ba2;
    transform: scale(1.2);
}

select {
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 1em;
    cursor: pointer;
    transition: border-color 0.3s;
}

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

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

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 5px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    flex: 1;
    min-width: 120px;
}

.btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.stats {
    display: flex;
    justify-content: space-around;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
    margin-bottom: 30px;
}

.stat-item {
    text-align: center;
}

.stat-label {
    display: block;
    font-weight: 600;
    color: #555;
    margin-bottom: 5px;
}

#comparisons, #swaps, #time {
    font-size: 1.5em;
    font-weight: bold;
    color: #667eea;
}

.visualizer {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    height: 400px;
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 30px;
    gap: 2px;
}

.bar {
    flex: 1;
    background: linear-gradient(180deg, #667eea 0%, #764ba2 100%);
    border-radius: 2px 2px 0 0;
    transition: all 0.3s;
    position: relative;
    min-width: 2px;
}

.bar.comparing {
    background: linear-gradient(180deg, #ffd93d 0%, #ff9a00 100%);
}

.bar.swapping {
    background: linear-gradient(180deg, #ff6b6b 0%, #ee5a6f 100%);
}

.bar.sorted {
    background: linear-gradient(180deg, #4ecdc4 0%, #44a08d 100%);
}

.info {
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
}

.code-section {
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
    margin-bottom: 30px;
}

.code-section h2 {
    color: #667eea;
    margin-bottom: 15px;
}

.code-display {
    background: #1e1e1e;
    border-radius: 8px;
    padding: 15px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    overflow-x: auto;
    max-height: 400px;
    overflow-y: auto;
}

.code-line {
    color: #d4d4d4;
    padding: 2px 10px;
    transition: all 0.3s;
    white-space: pre;
}

.code-line.active {
    background: #264f78;
    border-left: 3px solid #ffd93d;
    padding-left: 7px;
    animation: pulse 0.5s ease-in-out;
}

@keyframes pulse {
    0%, 100% {
        background: #264f78;
    }
    50% {
        background: #3a6ea5;
    }
}

input[type="checkbox"] {
    margin-right: 8px;
    cursor: pointer;
    width: 18px;
    height: 18px;
    vertical-align: middle;
}

.info h2 {
    color: #667eea;
    margin-bottom: 15px;
}

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

.complexity {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 2px solid #ddd;
}

.complexity div {
    color: #555;
}

.complexity strong {
    color: #333;
}

@media (max-width: 768px) {
    h1 {
        font-size: 1.8em;
    }

    .controls {
        grid-template-columns: 1fr;
    }

    .visualizer {
        height: 300px;
    }
}
