:root {
    /* Sorting visualization colors - kept as requested */
    --color-initial: #f26e6e; /* Light Red */
    --color-sorted: #63dc63;  /* Light Green */
    --color-highlight: #f1cd00; /* Gold */
    
    /* Black & white theme */
    --color-bg: #000000;
    --color-surface: #1a1a1a;
    --color-surface-light: #2a2a2a;
    --color-text-primary: #ffffff;
    --color-text-secondary: #cccccc;
    --color-text-muted: #888888;
    --color-border: #333333;
    --color-border-light: #444444;
    
    /* Button colors - elegant and functional */
    --color-primary: #0d3a6e;      /* Blue - primary actions */
    --color-success: #004e1f;      /* Green - positive actions */
    --color-warning: #460000;      /* Orange - caution actions */
    --color-secondary: #272727;    /* Gray - secondary actions */
}

/* ================================================================= */
/* Global Styles */
/* ================================================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: var(--color-bg);
    color: var(--color-text-primary);
    font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
    line-height: 1.6;
    min-height: 100vh;
}

main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ================================================================= */
/* Header */
/* ================================================================= */
header {
    text-align: center;
    padding: 2rem 0;
    margin-bottom: 2rem;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 600;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, var(--color-text-primary), var(--color-text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.divider {
    width: 100px;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--color-border-light), transparent);
    margin: 0 auto;
}

/* ================================================================= */
/* Control Panels */
/* ================================================================= */
.control-panel {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    margin-bottom: 2rem;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.panel-header {
    background: var(--color-surface-light);
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--color-border);
}

.panel-header h2 {
    font-size: 1.125rem;
    font-weight: 500;
    color: var(--color-text-primary);
}

.panel-content {
    padding: 1.5rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2rem;
    justify-content: center;
}

/* ================================================================= */
/* Input Groups */
/* ================================================================= */
.input-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    min-width: 120px;
}

.input-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ================================================================= */
/* Select Styling */
/* ================================================================= */
select {
    background: var(--color-surface-light);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    color: var(--color-text-primary);
    font-family: inherit;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 120px;
}

select:hover {
    border-color: var(--color-border-light);
}

select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(74, 158, 255, 0.2);
}

select option {
    background: var(--color-surface-light);
    color: var(--color-text-primary);
}

/* ================================================================= */
/* Input Slots */
/* ================================================================= */
.input-slots {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
    justify-content: center;
}

.input-slots input {
    width: 40px;
    height: 40px;
    text-align: center;
    background: var(--color-surface-light);
    border: 1px solid var(--color-border);
    color: var(--color-text-primary);
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.input-slots input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(74, 158, 255, 0.2);
}

.input-slots input::-webkit-outer-spin-button,
.input-slots input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* ================================================================= */
/* Button Styling */
/* ================================================================= */
.button-group {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: center;
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.btn:active:not(:disabled) {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* Button Variants */
.btn-primary {
    background: var(--color-primary);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #2c5ea9;
}

.btn-success {
    background: var(--color-success);
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: #0b7636;
}

.btn-warning {
    background: var(--color-warning);
    color: white;
}

.btn-warning:hover:not(:disabled) {
    background: #741c1c;
}

.btn-secondary {
    background: var(--color-secondary);
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #5a6268;
}

/* Special state for autoplay button */
#autoplay-btn.paused {
    background: var(--color-warning);
}

#autoplay-btn.paused:hover:not(:disabled) {
    background: #741c1c;
}

/* ================================================================= */
/* Animation Zone */
/* ================================================================= */
.animation-container {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.step-explanation {
    text-align: center;
    min-height: 50px;
    padding: 1rem;
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
}

.step-explanation p {
    font-size: 1rem;
    color: var(--color-text-secondary);
    margin: 0;
}

.animation-zone {
    position: relative;
    min-height: 40vh;
    overflow-x: auto;
    padding-bottom: 20px;
}

/* ================================================================= */
/* Array Elements */
/* ================================================================= */
.array-container {
    display: inline-flex;
    flex: 0 0 auto;
    position: absolute;
}

.array-element {
    height: 45px;
    width: 45px;
    margin: 0 2px;
    background: var(--color-initial);
    text-align: center;
    font-weight: 600;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1rem;
    border-radius: 6px;
    color: #000;
    transition: background 0.5s ease, transform 0.5s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.array-element.sorted {
    background: var(--color-sorted);
}

.array-element.highlight {
    background: var(--color-highlight);
    transform: scale(1.1);
    box-shadow: 0 4px 16px rgba(255, 215, 0, 0.3);
}

/* ================================================================= */
/* Responsive Design */
/* ================================================================= */
@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }
    
    main {
        padding: 0 15px;
    }
    
    .panel-content {
        flex-direction: column;
        gap: 1.5rem;
    }
    
    .button-group {
        flex-direction: column;
        width: 100%;
        max-width: 300px;
    }
    
    .btn {
        width: 100%;
    }
    
    .array-element {
        width: 40px;
        height: 40px;
        font-size: 0.875rem;
        margin: 0 1px;
    }
    
    .input-slots input {
        width: 35px;
        height: 35px;
        font-size: 0.875rem;
    }
}

@media (max-width: 480px) {
    header {
        padding: 1.5rem 0;
        margin-bottom: 1.5rem;
    }
    
    header h1 {
        font-size: 1.75rem;
    }
    
    .control-panel {
        margin-bottom: 1.5rem;
    }
    
    .panel-content {
        padding: 1rem;
        gap: 1rem;
    }
    
    .animation-zone {
        min-height: 30vh;
        padding-bottom: 20px;
    }
    
    .array-element {
        width: 35px;
        height: 35px;
        font-size: 0.75rem;
        margin: 0 1px;
    }
}