/* ========================================
   ALGORITHM UNIVERSE - DUAL THEME
   Dark Nordic & Light Day Theme
   4K & Responsive Support
   ======================================== */
@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;500;600;700&family=Fira+Code:wght@400;500;600&display=swap');

/* ========================================
   Theme Variables - Light (Default)
   ======================================== */
:root {
    /* Light Theme Colors (Default) */
    --bg-primary: #f8fafc;
    --bg-secondary: #f1f5f9;
    --bg-tertiary: #e2e8f0;
    --bg-card: rgba(255, 255, 255, 0.95);
    --bg-frost: rgba(59, 130, 246, 0.05);
    
    --ice-blue: #2563eb;
    --ice-cyan: #0891b2;
    --frost-white: #1e293b;
    --gold: #b45309;
    --bronze: #92400e;
    --blood-red: #dc2626;
    --rune-glow: #2563eb;
    --mist: rgba(59, 130, 246, 0.1);
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --text-rune: #2563eb;
    
    --cell-empty: #e2e8f0;
    --cell-wall: #94a3b8;
    --cell-start: #16a34a;
    --cell-end: #dc2626;
    --cell-visited: rgba(59, 130, 246, 0.3);
    --cell-path: #f59e0b;
    
    --bar-gradient: linear-gradient(90deg, #2563eb, #3b82f6);
    --bar-comparing: #d97706;
    --bar-swapping: #e11d48;
    --bar-sorted: #16a34a;
    
    --gradient-frost: linear-gradient(135deg, #dbeafe, #e0f2fe);
    --gradient-gold: linear-gradient(135deg, #fbbf24, #f59e0b);
    --gradient-rune: linear-gradient(135deg, #2563eb, #1d4ed8);
    
    --border-color: rgba(59, 130, 246, 0.2);
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    
    --font-norse: 'Cinzel', serif;
    --font-mono: 'Fira Code', monospace;
    --font-primary: 'Cinzel', serif;
    --font-secondary: 'Cinzel', serif;
    
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;
    
    --radius-sm: 2px;
    --radius-md: 4px;
    --radius-lg: 8px;
    --radius-xl: 12px;
}

/* ========================================
   Light Theme
   ======================================== */
[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-secondary: #f1f5f9;
    --bg-tertiary: #e2e8f0;
    --bg-card: rgba(255, 255, 255, 0.95);
    --bg-frost: rgba(59, 130, 246, 0.05);
    
    --ice-blue: #2563eb;
    --ice-cyan: #0891b2;
    --frost-white: #1e293b;
    --gold: #b45309;
    --bronze: #92400e;
    --blood-red: #dc2626;
    --rune-glow: #2563eb;
    --mist: rgba(59, 130, 246, 0.1);
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --text-rune: #2563eb;
    
    --cell-empty: #e2e8f0;
    --cell-wall: #94a3b8;
    --cell-start: #16a34a;
    --cell-end: #dc2626;
    --cell-visited: rgba(59, 130, 246, 0.3);
    --cell-path: #f59e0b;
    
    --bar-gradient: linear-gradient(90deg, #2563eb, #3b82f6);
    --bar-comparing: #d97706;
    --bar-swapping: #e11d48;
    --bar-sorted: #16a34a;
    
    --gradient-frost: linear-gradient(135deg, #dbeafe, #e0f2fe);
    --gradient-gold: linear-gradient(135deg, #fbbf24, #f59e0b);
    --gradient-rune: linear-gradient(135deg, #2563eb, #1d4ed8);
    
    --border-color: rgba(59, 130, 246, 0.2);
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

/* ========================================
   Reset & Base - 4K Support
   ======================================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: clamp(14px, 1vw, 18px);
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

@media (min-width: 2560px) {
    html { font-size: 20px; }
}

@media (min-width: 3840px) {
    html { font-size: 24px; }
}

body {
    font-family: var(--font-primary);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-synthesis: none;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
    transition: background 0.3s ease, color 0.3s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    width: 100%;
    max-width: 100vw;
    position: relative;
}


/* ========================================
   Theme Toggle Button
   ======================================== */
.theme-toggle {
    position: absolute;
    top: 1rem;
    left: 1rem;
    z-index: 1001;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.3s ease;
}

.theme-toggle:hover {
    border-color: var(--gold);
    transform: scale(1.05);
}

.theme-toggle .theme-icon {
    font-size: 1.2rem;
}

.theme-toggle .theme-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-family: var(--font-mono);
}

/* ========================================
   Background Effects
   ======================================== */
.background-effects {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
    transition: opacity 0.3s ease;
}

[data-theme="light"] .background-effects {
    opacity: 0.3;
}

.grid-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        linear-gradient(var(--mist) 1px, transparent 1px),
        linear-gradient(90deg, var(--mist) 1px, transparent 1px);
    background-size: 50px 50px;
    opacity: 0.3;
}

/* ========================================
   Audio Controls
   ======================================== */
.audio-controls {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 1001;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(10px);
}

.audio-toggle {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 0.25rem;
    transition: transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
}

.audio-toggle:hover {
    transform: scale(1.1);
}

.volume-icon {
    width: 20px;
    height: 20px;
    transition: all 0.3s ease;
}

/* Volume levels - show different waves based on volume */
.volume-icon.volume-muted .wave {
    opacity: 0 !important;
}

.volume-icon.volume-low .wave-1 {
    opacity: 1;
}

.volume-icon.volume-low .wave-2,
.volume-icon.volume-low .wave-3 {
    opacity: 0;
}

.volume-icon.volume-medium .wave-1,
.volume-icon.volume-medium .wave-2 {
    opacity: 1;
}

.volume-icon.volume-medium .wave-3 {
    opacity: 0;
}

.volume-icon.volume-high .wave-1,
.volume-icon.volume-high .wave-2,
.volume-icon.volume-high .wave-3 {
    opacity: 1;
}

/* Animation for sound waves */
.volume-icon.volume-low .wave-1,
.volume-icon.volume-medium .wave-1,
.volume-icon.volume-medium .wave-2,
.volume-icon.volume-high .wave-1,
.volume-icon.volume-high .wave-2,
.volume-icon.volume-high .wave-3 {
    animation: soundWave 1.5s ease-in-out infinite;
}

.volume-icon.volume-medium .wave-2,
.volume-icon.volume-high .wave-2 {
    animation-delay: 0.2s;
}

.volume-icon.volume-high .wave-3 {
    animation-delay: 0.4s;
}

@keyframes soundWave {
    0%, 100% {
        opacity: 0.3;
        transform: translateX(0);
    }
    50% {
        opacity: 1;
        transform: translateX(2px);
    }
}

#volumeSlider {
    width: 80px;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--bg-tertiary);
    border-radius: 2px;
    cursor: pointer;
}

#volumeSlider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--gold);
    cursor: pointer;
}

/* ========================================
   Header & Navigation
   ======================================== */
.main-header {
    position: relative;
    z-index: 10;
    padding: var(--spacing-lg) var(--spacing-xl);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    backdrop-filter: blur(10px);
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
    justify-content: center;
}

.logo-icon {
    font-size: 2rem;
    color: var(--gold);
}

.logo-text {
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    font-weight: 700;
    letter-spacing: 3px;
    text-transform: uppercase;
    background: linear-gradient(135deg, var(--frost-white), var(--ice-blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.algo-count {
    padding: 0.25rem 0.75rem;
    background: var(--gradient-gold);
    color: var(--bg-primary);
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    letter-spacing: 1px;
}

.main-nav {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
    justify-content: center;
}

.nav-btn {
    padding: 0.6rem 1.2rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-family: var(--font-norse);
    font-size: clamp(0.7rem, 1vw, 0.85rem);
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: var(--radius-md);
    text-transform: uppercase;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
}

.nav-btn:hover {
    background: var(--mist);
    color: var(--text-primary);
    border-color: var(--ice-blue);
}

.nav-btn.active {
    background: var(--gradient-gold);
    color: var(--bg-primary);
    border-color: var(--gold);
    font-weight: 600;
}

.main-header::after {
    content: '᛭ ᚱ ᚢ ᚾ ᛖ ᛊ ᛭';
    display: block;
    text-align: center;
    margin-top: var(--spacing-md);
    font-size: 0.6rem;
    letter-spacing: 5px;
    color: var(--text-muted);
    opacity: 0.5;
}

[data-theme="light"] .main-header::after {
    content: '• • • • • •';
}

/* ========================================
   Main Content
   ======================================== */
.main-content {
    position: relative;
    z-index: 5;
    padding: var(--spacing-xl);
    max-width: 2000px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}

@media (min-width: 3840px) {
    .main-content {
        max-width: 3200px;
    }
}

.section {
    display: none;
    padding: var(--spacing-xl);
    margin: 0;
    box-sizing: border-box;
}

.section.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.section::before {
    content: '᛭';
    display: block;
    text-align: center;
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: var(--spacing-lg);
    letter-spacing: 20px;
    opacity: 0.3;
}

[data-theme="light"] .section::before {
    content: '•';
}

/* ========================================
   Section Header
   ======================================== */
.section-header {
    text-align: center;
    margin-bottom: var(--spacing-2xl);
}

.section-header h1 {
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    font-weight: 700;
    letter-spacing: 3px;
    text-transform: uppercase;
    margin-bottom: var(--spacing-sm);
    color: var(--frost-white);
}

.section-header p {
    color: var(--text-secondary);
    font-size: clamp(0.85rem, 1.2vw, 1rem);
    font-style: italic;
}

/* ========================================
   Algorithm Grid
   ======================================== */
.algorithm-grid {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
    justify-content: center;
    margin: 0 0 var(--spacing-xl) 0;
    padding: 0;
}

.algo-btn {
    padding: 0.5rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-family: var(--font-norse);
    font-size: clamp(0.7rem, 1vw, 0.8rem);
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: var(--radius-md);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.algo-btn:hover {
    border-color: var(--ice-blue);
    color: var(--text-primary);
}

.algo-btn.active {
    background: var(--ice-blue);
    color: var(--bg-primary);
    border-color: var(--ice-blue);
    font-weight: 600;
}

/* ========================================
   Visualization Split Layout
   ======================================== */
.visualization-split {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: var(--spacing-xl);
}

@media (max-width: 1200px) {
    .visualization-split {
        grid-template-columns: 1fr;
    }
}

.viz-panel, .code-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: var(--spacing-lg);
    margin: 0;
    box-shadow: var(--shadow);
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0 0 var(--spacing-lg) 0;
    padding: 0 0 var(--spacing-md) 0;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: var(--spacing-md);
}

.panel-header h3 {
    font-size: clamp(0.9rem, 1.2vw, 1.1rem);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--gold);
}

.viz-panel::before,
.code-panel::before {
    content: '᛭';
    display: block;
    text-align: left;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: var(--spacing-sm);
    opacity: 0.3;
}

[data-theme="light"] .viz-panel::before,
[data-theme="light"] .code-panel::before {
    content: '•';
}

.viz-panel::after,
.code-panel::after {
    content: '᛭';
    display: block;
    text-align: right;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: var(--spacing-sm);
    opacity: 0.3;
}

[data-theme="light"] .viz-panel::after,
[data-theme="light"] .code-panel::after {
    content: '•';
}

/* ========================================
   Controls
   ======================================== */
.controls-inline {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--spacing-md);
}

.control-group {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin: 0;
    padding: 0;
}

.speed-multiplier {
    font-size: 0.85rem;
    color: var(--gold);
    font-weight: 600;
    margin-left: 4px;
    padding: 0;
}

.control-group label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

input[type="range"] {
    width: 80px;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--bg-tertiary);
    border-radius: 2px;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--ice-blue);
    cursor: pointer;
    transition: transform 0.2s;
}

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

select {
    padding: 0.4rem 0.8rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    border-radius: var(--radius-md);
    cursor: pointer;
}

select:focus {
    outline: none;
    border-color: var(--ice-blue);
}

/* ========================================
   Buttons
   ======================================== */
.btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    font-family: var(--font-norse);
    font-size: 0.8rem;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: var(--radius-md);
    text-transform: uppercase;
}

.btn-primary {
    background: var(--gradient-gold);
    color: var(--bg-primary);
    border-color: var(--gold);
    font-weight: 600;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(212, 165, 116, 0.3);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.btn-secondary:hover {
    background: var(--mist);
    color: var(--text-primary);
}

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
}

.btn-outline:hover {
    background: var(--mist);
    color: var(--text-primary);
}

.btn-large {
    padding: 0.75rem 2rem;
    font-size: 1rem;
}

/* ========================================
   Sorting Bars
   ======================================== */
.bars-container {
    display: flex;
    align-items: flex-end;
    justify-content: flex-start;
    gap: 2px;
    height: 300px;
    padding: var(--spacing-md);
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    overflow-x: auto;
    overflow-y: hidden;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    -webkit-overflow-scrolling: touch;
    position: relative;
    /* Ensure container doesn't expand beyond viewport */
    contain: layout style;
}

@media (min-width: 2560px) {
    .bars-container {
        height: 450px;
    }
}

.bar {
    flex: 0 0 auto;
    max-width: 30px;
    min-width: 2px;
    background: var(--bar-gradient);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    transition: height 0.05s ease, background 0.1s ease;
    /* Ensure bars maintain their width and don't shrink below minimum */
    flex-shrink: 0;
    flex-grow: 0;
}

.bar.comparing {
    background: var(--bar-comparing);
}

.bar.swapping {
    background: var(--bar-swapping);
}

.bar.sorted {
    background: var(--bar-sorted);
}

/* ========================================
   Size Presets
   ======================================== */
.size-presets {
    display: flex;
    gap: var(--spacing-xs);
    margin-top: var(--spacing-xs);
    flex-wrap: wrap;
}

.btn-preset {
    padding: 0.2rem 0.5rem;
    font-size: 0.7rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-mono);
}

.btn-preset:hover {
    background: var(--mist);
    color: var(--text-primary);
    border-color: var(--ice-blue);
}

.btn-preset.active {
    background: var(--ice-blue);
    color: var(--bg-primary);
    border-color: var(--ice-blue);
}

/* ========================================
   Comparison Feature
   ======================================== */
.compare-controls {
    margin-top: var(--spacing-md);
    padding: var(--spacing-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

.compare-selectors {
    display: flex;
    gap: var(--spacing-md);
    align-items: flex-end;
    flex-wrap: wrap;
}

.compare-selector {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
    flex: 1;
    min-width: 150px;
}

.compare-selector label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.compare-select {
    padding: 0.5rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    cursor: pointer;
}

.compare-select:hover {
    border-color: var(--ice-blue);
}

.compare-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-md);
    margin-top: var(--spacing-md);
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    min-width: 0;
}

@media (max-width: 1200px) {
    .compare-container {
        grid-template-columns: 1fr;
    }
}

.compare-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    display: flex;
    flex-direction: column;
    min-width: 0;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.compare-panel h4 {
    margin: 0 0 var(--spacing-md) 0;
    color: var(--ice-blue);
    font-size: 1rem;
    text-align: center;
    padding-bottom: var(--spacing-sm);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.compare-panel .bars-container.compare-bars {
    height: 300px;
    min-height: 300px;
    max-height: 300px;
    overflow-x: auto;
    overflow-y: hidden;
    flex-shrink: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    min-width: 0;
}

.compare-panel .bars-container.compare-bars .bar {
    flex: 0 0 auto;
    max-width: 20px;
    min-width: 0;
}

.compare-panel .tree-container.compare-tree,
.compare-panel .graph-container.compare-graph,
.compare-panel .dp-container.compare-dp,
.compare-panel .grid-container.compare-grid {
    height: 300px;
    min-height: 300px;
    max-height: 300px;
    overflow: auto;
    flex-shrink: 0;
    width: 100%;
    box-sizing: border-box;
}

.compare-selectors {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--spacing-md);
    align-items: flex-end;
}

.compare-actions {
    display: flex;
    gap: var(--spacing-sm);
    align-items: center;
    position: relative;
}

/* ========================================
   Stats Row
   ======================================== */
.stats-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-lg);
    margin-top: var(--spacing-lg);
    padding-top: var(--spacing-md);
    border-top: 1px solid var(--border-color);
}

.stat-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-value {
    font-family: var(--font-mono);
    font-size: 1rem;
    color: var(--gold);
    font-weight: 600;
}

.time-format-select {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    margin-left: 8px;
    cursor: pointer;
}

/* ========================================
   Code Display
   ======================================== */
.language-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-xs);
}

.lang-tab {
    padding: 0.3rem 0.6rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.2s;
    border-radius: var(--radius-sm);
}

.lang-tab:hover {
    color: var(--text-primary);
    border-color: var(--ice-blue);
}

.lang-tab.active {
    background: var(--ice-blue);
    color: var(--bg-primary);
    border-color: var(--ice-blue);
}

/* Language Logo Icons */
.lang-logo {
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-right: 6px;
    vertical-align: middle;
    border-radius: 3px;
    flex-shrink: 0;
}

.lang-logo-svg {
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-right: 6px;
    vertical-align: middle;
    flex-shrink: 0;
}

.lang-logo-svg svg {
    width: 100%;
    height: 100%;
    display: block;
}

.lang-icon-img {
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-right: 6px;
    vertical-align: middle;
    flex-shrink: 0;
    object-fit: contain;
}

.python-logo {
    background: linear-gradient(135deg, #3776ab 0%, #ffd43b 50%, #3776ab 100%);
    position: relative;
    border-radius: 50%;
}

.python-logo::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 50%;
    height: 100%;
    background: #3776ab;
    border-radius: 50% 0 0 50%;
}

.python-logo::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 50%;
    height: 100%;
    background: #ffd43b;
    border-radius: 0 50% 50% 0;
}

.java-logo {
    background: linear-gradient(135deg, #007396 0%, #ed8b00 100%);
    position: relative;
    clip-path: polygon(30% 0%, 70% 0%, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0% 70%, 0% 30%);
}

.java-logo::before {
    content: '☕';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 10px;
    line-height: 1;
}

.node-logo {
    background: linear-gradient(135deg, #339933 0%, #68a063 100%);
    position: relative;
    clip-path: polygon(30% 0%, 70% 0%, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0% 70%, 0% 30%);
}

.node-logo::before {
    content: 'N';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 10px;
    font-weight: bold;
    color: white;
    line-height: 1;
}

.deno-logo {
    background: #000000;
    position: relative;
    border-radius: 50%;
    overflow: hidden;
}

.deno-logo::before {
    content: '🦕';
    position: absolute;
    top: 60%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 10px;
    line-height: 1;
    filter: brightness(0) invert(1);
    z-index: 2;
}

.deno-logo::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        repeating-linear-gradient(0deg, transparent, transparent 1px, rgba(255,255,255,0.3) 1px, rgba(255,255,255,0.3) 2px);
    opacity: 0.5;
    pointer-events: none;
}

.cpp-logo {
    background: linear-gradient(135deg, #00599c 0%, #004482 50%, #00599c 100%);
    position: relative;
    clip-path: polygon(30% 0%, 70% 0%, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0% 70%, 0% 30%);
}

.cpp-logo::before {
    content: 'C++';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 7px;
    font-weight: bold;
    color: white;
    line-height: 1;
    white-space: nowrap;
}

.csharp-logo {
    background: linear-gradient(135deg, #239120 0%, #68217a 100%);
    position: relative;
    clip-path: polygon(30% 0%, 70% 0%, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0% 70%, 0% 30%);
}

.csharp-logo::before {
    content: 'C#';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 7px;
    font-weight: bold;
    color: white;
    line-height: 1;
    white-space: nowrap;
}

.c-logo {
    background: linear-gradient(135deg, #a8b9cc 0%, #00599c 100%);
    border-radius: 3px;
}

.c-logo::before {
    content: 'C';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 10px;
    font-weight: bold;
    color: white;
    line-height: 1;
}

.go-logo {
    background: #00add8;
    position: relative;
    border-radius: 3px;
    overflow: visible;
}

.go-logo::before {
    content: '🐹';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 12px;
    line-height: 1;
    filter: grayscale(0);
}

.rust-logo {
    background: #dea584;
    border-radius: 3px;
}

.rust-logo::before {
    content: '🦀';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 10px;
    line-height: 1;
}

.ts-logo {
    background: linear-gradient(135deg, #3178c6 0%, #235a97 100%);
    border-radius: 3px;
}

.ts-logo::before {
    content: 'TS';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 7px;
    font-weight: bold;
    color: white;
    line-height: 1;
}

.ruby-logo {
    background: linear-gradient(135deg, #cc342d 0%, #820000 100%);
    border-radius: 50%;
}

.ruby-logo::before {
    content: '💎';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 10px;
    line-height: 1;
}

.swift-logo {
    background: linear-gradient(135deg, #fa7343 0%, #ff4500 50%, #fa7343 100%);
    position: relative;
    border-radius: 3px;
    clip-path: polygon(0% 20%, 40% 0%, 100% 0%, 100% 80%, 60% 100%, 0% 100%);
}

.swift-logo::before {
    content: '⚡';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-45deg);
    font-size: 10px;
    line-height: 1;
    color: white;
    filter: drop-shadow(0 0 2px rgba(255,255,255,0.5));
}

.kotlin-logo {
    background: linear-gradient(135deg, #7F52FF 0%, #0095d5 30%, #ff6b00 60%, #ff1744 100%);
    position: relative;
    clip-path: polygon(25% 0%, 100% 0%, 100% 100%, 0% 100%, 0% 50%);
    overflow: hidden;
}

.kotlin-logo::before {
    content: 'K';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 11px;
    font-weight: 900;
    color: white;
    line-height: 1;
    font-family: var(--font-primary);
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
    letter-spacing: -1px;
    font-weight: 700;
}

.kotlin-logo::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        linear-gradient(45deg, transparent 25%, rgba(255,107,0,0.4) 25%, rgba(255,107,0,0.4) 35%, transparent 35%),
        linear-gradient(-45deg, transparent 25%, rgba(0,149,213,0.4) 25%, rgba(0,149,213,0.4) 35%, transparent 35%),
        linear-gradient(90deg, rgba(127,82,255,0.6) 0%, transparent 30%);
    pointer-events: none;
}

.js-logo {
    background: #f7df1e;
    border-radius: 3px;
    position: relative;
}

.js-logo::before {
    content: 'JS';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 7px;
    font-weight: bold;
    color: #000000;
    line-height: 1;
    font-family: var(--font-primary);
}

.php-logo {
    background: linear-gradient(135deg, #777bb4 0%, #4f5b93 100%);
    border-radius: 3px;
    position: relative;
}

.php-logo::before {
    content: 'PHP';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 6px;
    font-weight: bold;
    color: white;
    line-height: 1;
    font-family: var(--font-primary);
}

.elixir-logo {
    background: linear-gradient(135deg, #6e4a7e 0%, #4e2d5c 100%);
    border-radius: 3px;
    position: relative;
}

.elixir-logo::before {
    content: '~';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 12px;
    font-weight: bold;
    color: white;
    line-height: 1;
    font-family: var(--font-primary);
}

.code-container {
    position: relative;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    max-height: 300px;
    overflow-y: auto;
}

.code-actions {
    display: flex;
    gap: var(--spacing-xs);
    align-items: center;
    margin-top: var(--spacing-xs);
    margin-bottom: var(--spacing-xs);
}

.code-actions .btn-small {
    padding: 0.3rem 0.6rem;
    font-size: 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}

.code-actions .btn-small:hover {
    background: var(--mist);
    border-color: var(--ice-blue);
    color: var(--ice-blue);
}

.code-container pre {
    margin: 0;
}

.code-container code {
    font-family: var(--font-mono);
    font-size: clamp(0.75rem, 1vw, 0.85rem);
    color: var(--text-primary);
    white-space: pre-wrap;
    word-wrap: break-word;
    line-height: 1.6;
}

.copy-btn {
    position: absolute;
    top: var(--spacing-sm);
    right: var(--spacing-sm);
    padding: 0.3rem 0.5rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.8rem;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.copy-btn:hover {
    background: var(--mist);
    color: var(--text-primary);
}

/* ========================================
   Complexity Info
   ======================================== */
.complexity-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--spacing-md);
}

.complexity-item {
    background: var(--bg-secondary);
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.complexity-item label {
    display: block;
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: var(--spacing-xs);
}

.complexity-item span {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--ice-blue);
    font-weight: 600;
}

.complexity-item p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* ========================================
   Pathfinding Grid
   ======================================== */
.path-grid,
.grid-container {
    display: grid;
    gap: 1px;
    background: var(--bg-secondary);
    padding: var(--spacing-md);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    overflow-x: auto;
    overflow-y: auto;
    justify-content: center;
    max-height: 400px;
}

.cell {
    width: clamp(16px, 2vw, 22px);
    height: clamp(16px, 2vw, 22px);
    background: var(--cell-empty);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.1s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    font-weight: bold;
}

.cell.wall { background: var(--cell-wall); }
.cell.start { background: var(--cell-start); color: white; }
.cell.end { background: var(--cell-end); color: white; }
.cell.visited { background: var(--cell-visited); }
.cell.path { background: var(--cell-path); }
.cell.current { background: var(--gold); }

.grid-legend,
.legend {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-md);
    margin-top: var(--spacing-md);
    justify-content: center;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.legend-color.start { background: var(--cell-start); }
.legend-color.end { background: var(--cell-end); }
.legend-color.wall { background: var(--cell-wall); }
.legend-color.visited { background: var(--cell-visited); }
.legend-color.path { background: var(--cell-path); }

/* ========================================
   Tree & Graph SVG
   ======================================== */
.svg-container,
.tree-container,
.graph-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    overflow: auto;
    min-height: 350px;
}

.svg-container svg,
.tree-container svg,
.graph-container svg {
    width: 100%;
    height: 100%;
    min-height: 300px;
    display: block;
}

/* ========================================
   Programming Language Arena
   ======================================== */
.arena-controls {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-xl);
    padding: var(--spacing-lg);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
}

.arena-controls .control-group {
    flex-direction: column;
    align-items: flex-start;
}

.arena-controls .control-group label {
    margin-bottom: var(--spacing-sm);
}

.btn-small {
    padding: 0.3rem 0.6rem;
    font-size: 0.7rem;
}

.language-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
}

.lang-checkbox {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: 0.4rem 0.8rem;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.75rem;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.lang-checkbox:hover {
    background: var(--bg-tertiary);
}

.lang-checkbox input {
    cursor: pointer;
}

.lang-checkbox input:checked + .lang-icon-img {
    opacity: 1;
}

.lang-checkbox .lang-icon-img {
    width: 20px;
    height: 20px;
    margin-right: 0.5rem;
    opacity: 0.7;
    transition: opacity 0.2s;
    flex-shrink: 0;
    object-fit: contain;
}

.lang-checkbox:hover .lang-icon-img {
    opacity: 0.9;
}

.lang-checkbox input:checked ~ .lang-icon-img {
    opacity: 1;
}

/* ========================================
   Race Arena - Horizontal Bar Graph Style
   ======================================== */
.race-arena {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-xl);
}

.race-track-header {
    display: grid;
    grid-template-columns: 160px 1fr 150px 80px;
    gap: var(--spacing-md);
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: var(--spacing-md);
    align-items: center;
}

.race-track {
    display: grid;
    grid-template-columns: 160px 1fr 150px 80px;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    background: transparent;
    border-radius: var(--radius-lg);
    border: none;
    margin-bottom: var(--spacing-sm);
    transition: all 0.3s ease;
}

.race-track.winner {
    border-color: var(--gold);
    box-shadow: 0 0 20px rgba(212, 165, 116, 0.2);
}

.race-track.finished {
    opacity: 0.95;
}

.track-lang {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.track-lang .lang-icon-img {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    display: inline-block;
    flex-shrink: 0;
    object-fit: contain;
}

.track-lang .lang-symbol {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: bold;
    font-family: var(--font-mono);
    background: var(--bg-tertiary);
    border: 2px solid currentColor;
}

.track-lang .lang-name {
    font-size: 0.85rem;
    color: var(--text-primary);
    font-weight: 500;
}

.track-bar {
    position: relative;
    height: 50px;
    background: transparent;
    border-radius: var(--radius-md);
    overflow: visible;
    border: none;
    display: flex;
    align-items: center;
}

.track-runner {
    position: absolute;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: transparent;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: none;
    transition: left 0.05s linear, transform 0.1s ease, box-shadow 0.2s ease;
    z-index: 10;
    left: 0;
    transform: translateX(0);
}

.track-runner .runner-icon {
    width: 40px;
    height: 40px;
    display: inline-block;
    object-fit: contain;
    border-radius: 50%;
}

.track-runner .runner-symbol {
    font-size: 0.75rem;
    font-weight: bold;
    color: var(--bg-primary);
    font-family: var(--font-mono);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.track-runner:hover {
    transform: translateX(0) scale(1.1);
    box-shadow: none;
}

.track-time {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.5rem;
    flex-wrap: nowrap;
    min-width: 0;
}

.track-time .time-value {
    min-width: 90px;
    max-width: 120px;
    text-align: right;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
}

.track-time .time-format-select {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    flex-shrink: 0;
    min-width: 50px;
}

.track-position {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: bold;
    color: var(--gold);
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    min-width: 60px;
}

/* ========================================
   Arena Results
   ======================================== */
.arena-results {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: var(--spacing-xl);
    margin-bottom: var(--spacing-xl);
}

.arena-results h3 {
    text-align: center;
    font-size: 1.2rem;
    margin-bottom: var(--spacing-lg);
    color: var(--gold);
    letter-spacing: 2px;
}

.podium {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-xl);
}

.podium-place {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--spacing-lg);
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    min-width: 120px;
}

.podium-place.first {
    transform: translateY(-20px);
    border-color: var(--gold);
    box-shadow: 0 0 30px rgba(212, 165, 116, 0.2);
}

.podium-place .medal {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--gold);
    margin-bottom: var(--spacing-sm);
}

.podium-place .lang-name {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: var(--spacing-xs);
}

.podium-place .time {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-muted);
}

.speed-comparison {
    margin-top: var(--spacing-lg);
}

.speed-comparison h4 {
    font-size: 0.9rem;
    margin-bottom: var(--spacing-md);
    color: var(--text-secondary);
}

/* Complexity Graph Modal */
.complexity-graph-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    backdrop-filter: blur(5px);
}

.complexity-graph-content {
    background: var(--bg-card);
    border: 2px solid var(--gold);
    border-radius: var(--radius-xl);
    padding: var(--spacing-xl);
    max-width: 1000px;
    width: 95%;
    max-height: 95vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
}

.testing-badge {
    position: absolute;
    top: var(--spacing-md);
    right: var(--spacing-md);
    left: auto;
    background: linear-gradient(135deg, #d4a574, #8b6914);
    color: var(--bg-primary);
    padding: 0.3rem 0.8rem;
    border-radius: var(--radius-md);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.complexity-graph-content h3 {
    text-align: center;
    font-size: 1.5rem;
    margin-bottom: var(--spacing-sm);
    color: var(--text-primary);
}

.testing-message {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: var(--spacing-lg);
    font-style: italic;
}

.complexity-graph-container {
    margin: var(--spacing-lg) 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 500px;
    width: 100%;
    aspect-ratio: 16 / 9; /* Rectangular aspect ratio */
    max-width: 100%;
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
}

.complexity-graph-container svg {
    width: 100%;
    height: auto;
}

.close-complexity-graph {
    position: absolute;
    top: var(--spacing-md);
    left: var(--spacing-md);
    width: 35px;
    height: 35px;
    border: none;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 28px;
    line-height: 1;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10;
}

.close-complexity-graph:hover {
    background: var(--mist);
    transform: scale(1.1);
    color: var(--gold);
}

.speed-bar {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-sm);
}

.speed-lang {
    width: 120px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.speed-bar-fill {
    height: 20px;
    border-radius: var(--radius-md);
    transition: width 0.5s ease;
}

.speed-ratio {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ========================================
   Arena Info
   ======================================== */
.arena-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--spacing-lg);
}

.info-card {
    background: var(--bg-secondary);
    padding: var(--spacing-lg);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.info-card h4 {
    font-size: 0.9rem;
    color: var(--gold);
    margin-bottom: var(--spacing-md);
    letter-spacing: 1px;
}

.info-card p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.info-card ul {
    list-style: none;
}

.info-card li {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-sm);
    padding-left: var(--spacing-md);
    position: relative;
}

.info-card li::before {
    content: '᛭';
    position: absolute;
    left: 0;
    color: var(--text-muted);
    font-size: 0.6rem;
}

[data-theme="light"] .info-card li::before {
    content: '•';
}

/* ========================================
   DP Table
   ======================================== */
.dp-table,
.dp-container {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
    padding: var(--spacing-md);
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    min-height: 150px;
    max-height: 400px;
    overflow-y: auto;
    overflow-x: auto;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
}

.dp-cell {
    min-width: 50px;
    max-width: 100px;
    height: 40px;
    padding: 0.25rem 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-primary);
    transition: all 0.2s;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dp-cell.active {
    background: var(--ice-blue);
    color: var(--bg-primary);
    transform: scale(1.1);
}

.dp-cell.computed {
    background: var(--mist);
    border-color: var(--ice-blue);
}

/* ========================================
   String Visualization
   ======================================== */
.string-visualization,
.string-container {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    padding: var(--spacing-md);
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    max-height: 400px;
    overflow-y: auto;
    overflow-x: hidden;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
}

.math-container {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    padding: var(--spacing-md);
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    max-height: 400px;
    overflow-y: auto;
    overflow-x: hidden;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
}

.string-char {
    width: 30px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-primary);
    transition: all 0.1s;
}

.string-char.active {
    background: var(--bar-comparing);
    color: var(--bg-primary);
}

.string-char.matched {
    background: var(--bar-sorted);
    color: var(--bg-primary);
}

/* ========================================
   Search Items
   ======================================== */
.search-container {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
    padding: var(--spacing-md);
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    max-height: 400px;
    overflow-y: auto;
    overflow-x: hidden;
}

.search-container.compare-bars {
    max-height: 300px;
}

.search-item {
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-primary);
    transition: all 0.2s;
}

.search-item.current {
    background: var(--bar-comparing);
    color: var(--bg-primary);
    transform: scale(1.1);
}

.search-item.checked {
    background: var(--mist);
    border-color: var(--ice-blue);
}

.search-item.found {
    background: var(--bar-sorted);
    color: var(--bg-primary);
    transform: scale(1.15);
}

.info-icon-btn {
    position: absolute;
    top: -8px;
    right: 0;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1px solid var(--ice-blue);
    background: var(--bg-tertiary);
    color: var(--ice-blue);
    font-size: 13px;
    font-weight: 600;
    font-style: italic;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    margin: 0;
    transition: all 0.2s;
    font-family: Georgia, serif;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.info-icon-btn:hover {
    background: var(--ice-blue);
    color: var(--bg-primary);
    border-color: var(--ice-blue);
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(147, 197, 253, 0.4);
}

.search-info-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10002;
    backdrop-filter: blur(5px);
}

.search-info-modal-content {
    background: var(--bg-card);
    border: 2px solid var(--gold);
    border-radius: var(--radius-xl);
    padding: var(--spacing-xl);
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
}

.search-info-close-btn {
    position: absolute;
    top: var(--spacing-md);
    left: var(--spacing-md);
    width: 35px;
    height: 35px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 28px;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.search-info-close-btn:hover {
    background: var(--mist);
    color: var(--gold);
    transform: scale(1.1);
}

.search-info-modal-content h2 {
    text-align: center;
    font-size: 1.8rem;
    margin-bottom: var(--spacing-lg);
    color: var(--text-primary);
}

.search-info-content {
    color: var(--text-primary);
}

.search-info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.search-info-item {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
    padding: var(--spacing-sm);
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.search-info-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.search-info-value {
    font-size: 1rem;
    color: var(--text-primary);
    font-weight: 600;
    font-family: var(--font-mono);
}

.search-info-array {
    margin-bottom: var(--spacing-lg);
    padding: var(--spacing-md);
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.search-info-array-preview {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--text-primary);
    line-height: 1.6;
    word-break: break-word;
    max-height: 200px;
    overflow-y: auto;
    padding: var(--spacing-sm);
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
}

.search-info-note {
    padding: var(--spacing-md);
    background: var(--bg-frost);
    border-left: 3px solid var(--gold);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
}

/* ========================================
   Footer
   ======================================== */
.main-footer {
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-sm);
}

.feedback-btn {
    margin-top: var(--spacing-md);
    padding: 0.5rem 1rem;
    background: var(--mist);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-family: var(--font-norse);
    font-size: 0.85rem;
    transition: all 0.3s;
}

.feedback-btn:hover {
    background: var(--gold);
    color: var(--bg-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(212, 165, 116, 0.3);
}

/* ========================================
   Feedback Modal
   ======================================== */
.feedback-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10001;
    backdrop-filter: blur(5px);
}

.feedback-modal-content {
    background: var(--bg-card);
    border: 2px solid var(--gold);
    border-radius: var(--radius-xl);
    padding: var(--spacing-xl);
    max-width: 500px;
    width: 90%;
    position: relative;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
}

.feedback-close-btn {
    position: absolute;
    top: var(--spacing-md);
    left: var(--spacing-md);
    width: 35px;
    height: 35px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 28px;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.feedback-close-btn:hover {
    background: var(--mist);
    color: var(--gold);
    transform: scale(1.1);
}

.feedback-modal-content h2 {
    text-align: center;
    font-size: 1.8rem;
    margin-bottom: var(--spacing-xs);
    color: var(--text-primary);
}

.feedback-subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: var(--spacing-lg);
}

.star-rating {
    display: flex;
    justify-content: center;
    gap: var(--spacing-xs);
    margin-bottom: var(--spacing-sm);
    font-size: 2.5rem;
}

.star {
    color: var(--border-color);
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.star:hover,
.star.active {
    color: var(--gold);
    transform: scale(1.2);
    text-shadow: 0 0 10px rgba(212, 165, 116, 0.5);
}

.rating-text {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: var(--spacing-md);
    min-height: 1.5rem;
}

.feedback-textarea {
    width: 100%;
    padding: var(--spacing-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-primary);
    font-size: 0.9rem;
    resize: vertical;
    margin-bottom: var(--spacing-lg);
    box-sizing: border-box;
}

.feedback-textarea:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 2px rgba(212, 165, 116, 0.2);
}

.feedback-email {
    width: 100%;
    padding: var(--spacing-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-primary);
    font-size: 0.9rem;
    margin-bottom: var(--spacing-lg);
}

.feedback-email:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 2px rgba(212, 165, 116, 0.2);
}

.feedback-actions {
    display: flex;
    gap: var(--spacing-md);
    justify-content: center;
}

.feedback-success {
    text-align: center;
    color: var(--gold);
    font-weight: 600;
    margin-top: var(--spacing-md);
    font-size: 1rem;
}

.main-footer {
    text-align: center;
    padding: var(--spacing-xl);
    color: var(--text-muted);
    font-size: 0.8rem;
    border-top: 1px solid var(--border-color);
    font-family: var(--font-norse);
    letter-spacing: 1px;
}

.main-footer::before {
    content: '᛭ ᚠ ᚢ ᚦ ᚨ ᚱ ᚲ ᚷ ᚹ ᚺ ᚾ ᛁ ᛃ ᛇ ᛈ ᛉ ᛊ ᛏ ᛒ ᛖ ᛗ ᛚ ᛝ ᛞ ᛟ ᛭';
    display: block;
    margin-bottom: var(--spacing-md);
    font-size: 0.6rem;
    letter-spacing: 3px;
    color: var(--text-muted);
    opacity: 0.5;
}

[data-theme="light"] .main-footer::before {
    content: '• • • • • • • • • • • •';
}

.footer-author {
    margin-top: var(--spacing-md);
    font-size: 0.75rem;
    color: var(--text-muted);
    opacity: 0.8;
}

.footer-author .author-name {
    color: var(--gold);
    font-weight: 600;
    letter-spacing: 2px;
}

.visitor-stats {
    margin: var(--spacing-md) 0;
    padding: var(--spacing-sm) var(--spacing-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-xs);
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.visitor-stats-row {
    display: flex;
    justify-content: center;
    gap: var(--spacing-lg);
    flex-wrap: wrap;
    width: 100%;
}

.visitor-stats span {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.visitor-stats strong {
    color: var(--ice-blue);
    font-weight: 600;
    font-family: var(--font-mono);
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    position: relative;
    background: var(--bg-card);
    border: 2px solid var(--gold);
    border-radius: var(--radius-xl);
    padding: var(--spacing-2xl);
    max-width: 600px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(212, 165, 116, 0.3);
    animation: slideUp 0.4s ease;
}

.modal-close {
    position: absolute;
    top: var(--spacing-md);
    right: var(--spacing-md);
    font-size: 2rem;
    color: var(--text-secondary);
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
    line-height: 1;
}

.modal-close:hover {
    background: var(--bg-tertiary);
    color: var(--gold);
    transform: rotate(90deg);
}

.coming-soon-content {
    text-align: center;
    padding: var(--spacing-lg);
}

.coming-soon-icon {
    font-size: 4rem;
    margin: var(--spacing-lg) 0;
    animation: pulse 2s ease-in-out infinite;
}

.coming-soon-title {
    font-family: var(--font-primary);
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 700;
    color: var(--gold);
    margin-bottom: var(--spacing-lg);
    text-transform: uppercase;
    letter-spacing: 3px;
    text-shadow: 0 2px 10px rgba(212, 165, 116, 0.3);
    background: linear-gradient(135deg, var(--gold), var(--ice-blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.coming-soon-text {
    font-family: var(--font-primary);
    font-size: clamp(1.1rem, 2.5vw, 1.5rem);
    color: var(--text-primary);
    line-height: 1.8;
    margin-bottom: var(--spacing-md);
}

.coming-soon-text strong {
    color: var(--ice-blue);
    font-weight: 700;
    font-size: 1.2em;
    text-shadow: 0 1px 3px rgba(147, 197, 253, 0.3);
}

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

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

/* ========================================
   Responsive Design
   ======================================== */
@media (max-width: 1200px) {
    .visualization-split {
        grid-template-columns: 1fr;
    }
    
    .viz-panel.wide,
    .code-panel.narrow {
        grid-column: 1;
    }
}

@media (max-width: 768px) {
    html {
        font-size: 14px;
    }

    .main-header {
        padding: var(--spacing-sm) var(--spacing-md);
        flex-wrap: wrap;
        gap: var(--spacing-sm);
    }
    
    .logo {
        flex-direction: column;
        align-items: center;
        gap: 0.25rem;
    }
    
    .logo-text {
        font-size: clamp(0.9rem, 4vw, 1.2rem);
    }
    
    .algo-count {
        font-size: 0.6rem;
    }
    
    .main-nav {
        flex-wrap: wrap;
        gap: var(--spacing-xs);
        justify-content: center;
    }
    
    .nav-btn {
        padding: 0.5rem 0.8rem;
        font-size: 0.7rem;
        min-width: auto;
        min-height: 44px; /* Touch target */
    }
    
    .section-header h1 {
        font-size: clamp(1.2rem, 5vw, 1.5rem);
    }
    
    .section-header p {
        font-size: 0.85rem;
    }
    
    .visualization-split {
        grid-template-columns: 1fr;
        gap: var(--spacing-md);
    }
    
    .viz-panel, .code-panel {
        padding: var(--spacing-md);
    }
    
    .controls-inline {
        flex-direction: column;
        gap: var(--spacing-sm);
        align-items: stretch;
    }
    
    .btn-group {
        flex-direction: column;
        width: 100%;
    }
    
    .btn {
        width: 100%;
        padding: 0.75rem;
        font-size: 0.9rem;
        min-height: 44px; /* Touch target */
    }
    
    .control-group {
        margin-bottom: var(--spacing-md);
    }
    
    .control-group label {
        font-size: 0.85rem;
        margin-bottom: var(--spacing-xs);
    }
    
    .control-group select,
    .control-group input[type="range"] {
        width: 100%;
        padding: 0.6rem;
        font-size: 0.9rem;
        min-height: 44px; /* Touch target */
    }
    
    /* Size presets mobile */
    .size-presets {
        flex-wrap: wrap;
        gap: var(--spacing-xs);
        justify-content: center;
    }
    
    .btn-preset {
        min-height: 44px; /* Touch target */
        padding: 0.5rem 0.8rem;
        font-size: 0.8rem;
    }
    
    /* Compare containers mobile */
    .compare-container {
        grid-template-columns: 1fr !important;
        gap: var(--spacing-md);
    }
    
    .compare-panel {
        padding: var(--spacing-sm);
        min-width: 0;
        overflow: hidden;
    }
    
    .compare-panel h4 {
        font-size: 0.85rem;
        white-space: normal;
        word-break: break-word;
        padding-bottom: var(--spacing-xs);
    }
    
    .compare-panel .bars-container.compare-bars,
    .compare-panel .tree-container.compare-tree,
    .compare-panel .graph-container.compare-graph,
    .compare-panel .dp-container.compare-dp,
    .compare-panel .grid-container.compare-grid {
        height: 200px;
        min-height: 200px;
        max-height: 200px;
    }
    
    .compare-selectors {
        grid-template-columns: 1fr !important;
        gap: var(--spacing-sm);
    }
    
    .compare-selector {
        min-width: 0;
        width: 100%;
    }
    
    .compare-select {
        width: 100%;
        min-height: 44px; /* Touch target */
        font-size: 0.85rem;
    }
    
    .compare-actions {
        flex-direction: column;
        width: 100%;
        gap: var(--spacing-sm);
    }
    
    .compare-actions .btn {
        width: 100%;
        min-height: 44px;
    }
    
    /* Info buttons mobile */
    .info-icon-btn {
        width: 28px;
        height: 28px;
        font-size: 14px;
        min-width: 28px;
        min-height: 28px;
    }
    
    /* Modals mobile */
    .modal-overlay,
    .search-info-modal,
    .feedback-modal,
    .complexity-graph-modal {
        padding: var(--spacing-sm);
        align-items: flex-start;
        padding-top: var(--spacing-lg);
    }
    
    .modal-content,
    .search-info-modal-content,
    .feedback-modal-content,
    .complexity-graph-content {
        width: 95% !important;
        max-width: 95% !important;
        padding: var(--spacing-md);
        max-height: 90vh;
        margin: 0;
    }
    
    .modal-close,
    .search-info-close-btn,
    .feedback-close-btn,
    .close-complexity-graph {
        width: 40px;
        height: 40px;
        min-width: 40px;
        min-height: 40px;
        font-size: 24px;
    }
    
    .search-info-grid {
        grid-template-columns: 1fr !important;
        gap: var(--spacing-sm);
    }
    
    .language-checkboxes {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-xs);
    }
    
    .lang-checkbox {
        padding: 0.5rem;
        font-size: 0.7rem;
        min-height: 44px; /* Touch target */
    }
    
    .lang-checkbox .lang-icon-img {
        width: 16px;
        height: 16px;
    }
    
    .arena-controls {
        flex-direction: column;
        align-items: stretch;
        gap: var(--spacing-md);
    }
    
    .race-track-header {
        display: none;
    }
    
    .race-track {
        grid-template-columns: 1fr;
        text-align: center;
        gap: var(--spacing-sm);
        padding: var(--spacing-sm);
    }
    
    .track-lang {
        justify-content: center;
        flex-direction: column;
        gap: var(--spacing-xs);
    }
    
    .track-lang .lang-icon-img {
        width: 28px;
        height: 28px;
    }
    
    .track-bar {
        height: 40px;
        margin: var(--spacing-sm) 0;
    }
    
    .track-time {
        flex-direction: column;
        gap: var(--spacing-xs);
        align-items: center;
    }
    
    .track-time .time-value {
        min-width: auto;
        max-width: 100%;
        text-align: center;
        font-size: 0.9rem;
    }
    
    .track-time .time-format-select {
        width: 100%;
        max-width: 100px;
        min-height: 44px; /* Touch target */
        padding: 0.4rem;
        font-size: 0.8rem;
    }
    
    .track-time .time-value {
        font-size: 0.85rem;
    }
    
    .track-position {
        font-size: 0.9rem;
    }
    
    .podium {
        flex-direction: column;
        align-items: center;
        gap: var(--spacing-md);
    }
    
    .podium-place {
        width: 100%;
        max-width: 200px;
    }
    
    .podium-place.first {
        transform: none;
        order: -1;
    }
    
    .arena-info {
        grid-template-columns: 1fr;
        gap: var(--spacing-md);
    }
    
    .info-card {
        padding: var(--spacing-md);
    }
    
    .audio-controls {
        position: relative;
        top: auto;
        right: auto;
        margin-top: var(--spacing-md);
        width: 100%;
        justify-content: center;
    }
    
    .theme-toggle {
        position: relative;
        top: auto;
        left: auto;
        margin-bottom: var(--spacing-md);
        width: 100%;
        justify-content: center;
    }
    
    .code-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .code-container pre {
        font-size: 0.75rem;
        padding: var(--spacing-md);
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-sm);
    }
    
    .stat-item {
        padding: var(--spacing-sm);
        font-size: 0.8rem;
    }
    
    /* Search container mobile */
    .search-container {
        max-height: 250px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .search-item {
        width: 35px;
        height: 35px;
        font-size: 0.7rem;
    }
    
    /* Grid container mobile */
    .grid-container {
        max-height: 300px;
        overflow-x: auto;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Tree/Graph containers mobile */
    .tree-container,
    .graph-container {
        max-height: 300px;
        overflow: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* DP container mobile */
    .dp-container {
        max-height: 300px;
        overflow-x: auto;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 480px) {
    html {
        font-size: 12px;
    }

    .main-content {
        padding: var(--spacing-sm);
        overflow-x: hidden;
    }
    
    .main-header {
        padding: var(--spacing-sm);
    }
    
    .logo {
        gap: 0.2rem;
    }
    
    .logo-icon {
        font-size: 1.2rem;
    }
    
    .logo-text {
        font-size: 0.9rem;
    }
    
    .algo-count {
        font-size: 0.55rem;
    }
    
    .main-nav {
        gap: 0.25rem;
    }
    
    .nav-btn {
        padding: 0.4rem 0.5rem;
        font-size: 0.6rem;
        letter-spacing: 0.5px;
        min-height: 44px; /* Touch target */
    }
    
    .section-header {
        padding: var(--spacing-md) var(--spacing-sm);
    }
    
    .section-header h1 {
        font-size: 1.1rem;
        margin-bottom: var(--spacing-xs);
    }
    
    .section-header p {
        font-size: 0.75rem;
    }
    
    .bars-container {
        height: 180px;
        padding: var(--spacing-sm);
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .bar {
        min-width: 3px;
        font-size: 0.6rem;
    }
    
    .cell {
        width: 12px;
        height: 12px;
        font-size: 0.6rem;
    }
    
    .grid-container {
        gap: 2px;
        padding: var(--spacing-sm);
        max-height: 250px;
    }
    
    /* Compare panels small mobile */
    .compare-panel {
        padding: var(--spacing-xs);
    }
    
    .compare-panel h4 {
        font-size: 0.75rem;
    }
    
    .compare-panel .bars-container.compare-bars,
    .compare-panel .tree-container.compare-tree,
    .compare-panel .graph-container.compare-graph,
    .compare-panel .dp-container.compare-dp,
    .compare-panel .grid-container.compare-grid {
        height: 150px;
        min-height: 150px;
        max-height: 150px;
    }
    
    .compare-selectors {
        gap: var(--spacing-xs);
    }
    
    .compare-select {
        font-size: 0.75rem;
        padding: 0.4rem;
    }
    
    .language-checkboxes {
        grid-template-columns: 1fr;
    }
    
    .lang-checkbox {
        padding: 0.6rem;
        font-size: 0.75rem;
        min-height: 44px; /* Touch target */
    }
    
    .track-lang .lang-name {
        font-size: 0.75rem;
    }
    
    .track-bar {
        height: 35px;
    }
    
    .track-runner {
        width: 35px;
        height: 35px;
    }
    
    .track-runner .runner-icon {
        width: 28px;
        height: 28px;
    }
    
    .btn {
        padding: 0.7rem;
        font-size: 0.85rem;
        min-height: 44px; /* Touch target size */
    }
    
    .btn-preset {
        min-height: 44px;
        padding: 0.4rem 0.6rem;
        font-size: 0.7rem;
    }
    
    .control-group select,
    .control-group input[type="range"] {
        min-height: 44px; /* Touch target size */
        font-size: 0.9rem;
    }
    
    .code-container pre {
        font-size: 0.7rem;
        line-height: 1.4;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .stat-item {
        padding: var(--spacing-xs);
        font-size: 0.75rem;
    }
    
    .info-card {
        padding: var(--spacing-sm);
        font-size: 0.8rem;
    }
    
    .info-card h4 {
        font-size: 0.9rem;
    }
    
    .podium-place {
        padding: var(--spacing-sm);
        font-size: 0.8rem;
    }
    
    .speed-comparison {
        font-size: 0.75rem;
    }
    
    /* Modals small mobile */
    .modal-content,
    .search-info-modal-content,
    .feedback-modal-content,
    .complexity-graph-content {
        width: 98% !important;
        max-width: 98% !important;
        padding: var(--spacing-sm);
        max-height: 95vh;
    }
    
    .modal-content h2,
    .search-info-modal-content h2,
    .feedback-modal-content h2 {
        font-size: 1.2rem;
    }
    
    .search-info-grid {
        grid-template-columns: 1fr !important;
    }
    
    /* Info buttons small mobile */
    .info-icon-btn {
        width: 24px;
        height: 24px;
        font-size: 12px;
        min-width: 24px;
        min-height: 24px;
    }
    
    /* Search items small mobile */
    .search-item {
        width: 30px;
        height: 30px;
        font-size: 0.65rem;
    }
    
    /* Tree/Graph SVG small mobile */
    .tree-container svg,
    .graph-container svg {
        min-height: 200px;
    }
}

/* ========================================
   4K / Ultra Wide Support
   ======================================== */
@media (min-width: 2560px) {
    .main-content {
        max-width: 2400px;
    }
    
    .bars-container {
        height: 500px;
    }
    
    .bar {
        max-width: 50px;
    }
    
    .cell {
        width: 28px;
        height: 28px;
    }
}

@media (min-width: 3840px) {
    .main-content {
        max-width: 3400px;
        padding: var(--spacing-2xl);
    }
    
    .bars-container {
        height: 700px;
    }
    
    .bar {
        max-width: 70px;
    }
    
    .cell {
        width: 36px;
        height: 36px;
        font-size: 0.9rem;
    }
    
    .race-track {
        padding: var(--spacing-lg);
    }
    
    .track-bar {
        height: 40px;
    }
}

/* ========================================
   Playground Section
   ======================================== */
.playground-container {
    max-width: 100%;
    margin: 0 auto;
}

.playground-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--spacing-md);
    padding: var(--spacing-lg);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    margin-bottom: var(--spacing-lg);
}

.playground-actions {
    display: flex;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
}

.playground-select {
    padding: 0.5rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    cursor: pointer;
}

.playground-select:hover {
    border-color: var(--ice-blue);
}

.playground-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
}

@media (max-width: 1200px) {
    .playground-split {
        grid-template-columns: 1fr;
    }
}

.playground-editor-panel,
.playground-output-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: var(--spacing-lg);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    min-height: 500px;
    max-height: 600px;
}

.editor-info {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.code-editor-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin-top: var(--spacing-md);
}

.playground-editor {
    flex: 1;
    width: 100%;
    min-height: 400px;
    padding: var(--spacing-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    line-height: 1.6;
    resize: none;
    outline: none;
    tab-size: 4;
    -moz-tab-size: 4;
}

.playground-editor:focus {
    border-color: var(--ice-blue);
    box-shadow: 0 0 0 2px rgba(147, 197, 253, 0.1);
}

.playground-editor::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
}

.playground-output {
    flex: 1;
    padding: var(--spacing-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    line-height: 1.6;
    overflow-y: auto;
    max-height: 450px;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.output-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    text-align: center;
}

.output-placeholder p {
    margin: var(--spacing-sm) 0;
}

.output-hint {
    font-size: 0.8rem;
    opacity: 0.7;
}

.output-line {
    padding: 0.25rem 0;
    border-bottom: 1px solid rgba(147, 197, 253, 0.1);
}

.output-line:last-child {
    border-bottom: none;
}

.output-log {
    color: var(--text-primary);
}

.output-error {
    color: var(--blood-red);
}

.output-warn {
    color: var(--gold);
}

.output-info {
    color: var(--ice-cyan);
}

.output-success {
    color: #22c55e;
}

.playground-templates {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: var(--spacing-lg);
    box-shadow: var(--shadow);
}

.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-md);
    margin-top: var(--spacing-md);
}

.template-btn {
    padding: var(--spacing-md);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.template-btn:hover {
    background: var(--mist);
    color: var(--text-primary);
    border-color: var(--ice-blue);
    transform: translateY(-2px);
}

.template-btn:active {
    transform: translateY(0);
}

@media (max-width: 768px) {
    .playground-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .playground-actions {
        width: 100%;
        justify-content: stretch;
    }

    .playground-actions .btn {
        flex: 1;
    }

    .playground-editor-panel,
    .playground-output-panel {
        min-height: 300px;
        max-height: 400px;
    }

    .playground-editor {
        min-height: 250px;
    }

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

/* ========================================
   Ultra-Small Mobile (320px)
   ======================================== */
@media (max-width: 320px) {
    html {
        font-size: 11px;
    }
    
    .main-content {
        padding: var(--spacing-xs);
    }
    
    .main-header {
        padding: var(--spacing-xs);
    }
    
    .logo {
        gap: 0.15rem;
    }
    
    .logo-icon {
        font-size: 1rem;
    }
    
    .logo-text {
        font-size: 0.85rem;
        letter-spacing: 1px;
    }
    
    .algo-count {
        font-size: 0.5rem;
        padding: 0.15rem 0.4rem;
    }
    
    /* Horizontal scrolling navigation */
    .main-nav {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
        gap: 0.2rem;
        padding-bottom: var(--spacing-xs);
        justify-content: flex-start;
    }
    
    .main-nav::-webkit-scrollbar {
        display: none;
    }
    
    .nav-btn {
        flex-shrink: 0;
        padding: 0.35rem 0.5rem;
        font-size: 0.55rem;
        min-height: 40px;
        white-space: nowrap;
    }
    
    .section-header h1 {
        font-size: 0.95rem;
        letter-spacing: 1px;
    }
    
    .section-header p {
        font-size: 0.7rem;
    }
    
    /* Algorithm grid - 2 columns compact */
    .algorithm-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-xs);
    }
    
    .algo-btn {
        padding: 0.35rem 0.4rem;
        font-size: 0.6rem;
        min-height: 40px;
        text-align: center;
    }
    
    /* Panels */
    .viz-panel, .code-panel {
        padding: var(--spacing-sm);
    }
    
    .panel-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--spacing-xs);
    }
    
    .panel-header h3 {
        font-size: 0.8rem;
    }
    
    .controls-inline {
        width: 100%;
    }
    
    .control-group {
        flex-wrap: wrap;
        width: 100%;
    }
    
    .control-group label {
        font-size: 0.65rem;
    }
    
    input[type="range"] {
        width: 100%;
    }
    
    .btn {
        font-size: 0.7rem;
        padding: 0.5rem;
        min-height: 40px;
    }
    
    /* Language tabs scrollable */
    .language-tabs {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 0.15rem;
    }
    
    .language-tabs::-webkit-scrollbar {
        display: none;
    }
    
    .lang-tab {
        flex-shrink: 0;
        padding: 0.25rem 0.4rem;
        font-size: 0.6rem;
        min-height: 36px;
    }
    
    .lang-icon-img {
        width: 12px;
        height: 12px;
        margin-right: 3px;
    }
    
    /* Bars container */
    .bars-container {
        height: 150px;
        padding: var(--spacing-xs);
    }
    
    /* Stats */
    .stats-row {
        flex-direction: column;
        gap: var(--spacing-xs);
    }
    
    .stat-item {
        justify-content: space-between;
        width: 100%;
    }
    
    .stat-label {
        font-size: 0.65rem;
    }
    
    .stat-value {
        font-size: 0.85rem;
    }
    
    /* Code container */
    .code-container {
        max-height: 200px;
        padding: var(--spacing-xs);
    }
    
    .code-container code {
        font-size: 0.65rem;
    }
    
    /* Algorithm info */
    .algorithm-info .info-grid {
        grid-template-columns: 1fr;
    }
    
    .info-item {
        padding: var(--spacing-xs);
    }
    
    .info-label {
        font-size: 0.6rem;
    }
    
    .info-value {
        font-size: 0.75rem;
    }
    
    /* Search container */
    .search-container {
        max-height: 200px;
    }
    
    .search-item {
        width: 28px;
        height: 28px;
        font-size: 0.6rem;
    }
    
    /* Grid cells */
    .cell {
        width: 14px;
        height: 14px;
        font-size: 0.5rem;
    }
    
    .legend {
        flex-wrap: wrap;
        gap: var(--spacing-xs);
    }
    
    .legend-item {
        font-size: 0.6rem;
    }
    
    .legend-color {
        width: 12px;
        height: 12px;
    }
    
    /* Comparison panels */
    .compare-controls {
        padding: var(--spacing-xs);
    }
    
    .compare-select {
        font-size: 0.7rem;
        min-height: 40px;
    }
    
    .compare-panel h4 {
        font-size: 0.75rem;
    }
    
    .compare-panel .bars-container.compare-bars {
        height: 150px;
        min-height: 150px;
        max-height: 150px;
    }
    
    /* Tree and Graph containers */
    .tree-container,
    .graph-container {
        min-height: 200px;
        max-height: 250px;
    }
    
    /* DP cells */
    .dp-cell {
        min-width: 35px;
        max-width: 50px;
        height: 30px;
        font-size: 0.6rem;
    }
    
    /* String chars */
    .string-char {
        width: 22px;
        height: 26px;
        font-size: 0.7rem;
    }
}

/* ========================================
   Print Styles
   ======================================== */
@media print {
    .background-effects,
    .audio-controls,
    .theme-toggle {
        display: none;
    }
    
    body {
        background: white;
        color: black;
    }
}
