/* ================================
   CSS VARIABLES & THEME SYSTEM
   ================================ */

:root {
    /* Light Theme (Default) */
    --primary: #8b5cf6;
    --primary-dark: #1d4ed8;
    --secondary: #10b981;
    --accent: #8b5cf6;
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-light: #64748b;
    --border: #e2e8f0;
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --code-bg: #1e293b;
    --code-text: #10b981;
    --sidebar-width: 300px;
    --header-height: auto;
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-lg: rgba(0, 0, 0, 0.15);
    --card-bg: #ffffff;
    --navbar-bg: #ffffff;
    --footer-bg: #f8fafc;
    --game-bg: #f8fafc;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
}

/* Dark Theme */
[data-theme="dark"] {
    --primary: #8b5cf6;
    --primary-dark: #2563eb;
    --secondary: #10b981;
    --accent: #a78bfa;
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-light: #94a3b8;
    --border: #334155;
    --success: #10b981;
    --error: #f87171;
    --warning: #f59e0b;
    --info: #60a5fa;
    --code-bg: #1e293b;
    --code-text: #10b981;
    --shadow: rgba(0, 0, 0, 0.3);
    --shadow-lg: rgba(0, 0, 0, 0.5);
    --card-bg: #1e293b;
    --navbar-bg: #1e293b;
    --footer-bg: #1e293b;
    --game-bg: #1a2332;
}

/* ================================
   GLOBAL STYLES
   ================================ */

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

html, body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 
         'Helvetica Neue', Arial, sans-serif;
    font-weight: 500;
    letter-spacing: -0.01em;
    line-height: 1.6;
    background: var(--bg-primary);
    min-height: 100vh;
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow-x: hidden;
    width: 100%;
    scroll-behavior: smooth;
}

.light-label {
    color: #f59e0b;
    transition: color 0.3s ease;
}

.dark-label {
    color: #8b5cf6;
    transition: color 0.3s ease;
}

[data-theme="dark"] .light-label {
    color: var(--text-secondary);
}

[data-theme="dark"] .dark-label {
    color: var(--primary);
}

/* ================================
   HERO SECTION (Quiz Version)
   ================================ */
.hero {
    text-align: center;
    padding: 4rem 2rem;
    background: linear-gradient(135deg, 
        rgba(139, 92, 246, 0.15), 
        rgba(16, 185, 129, 0.15));
    border-bottom: 2px solid var(--border);
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%238b5cf6' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    opacity: 0.3;
}

.hero-content {
    position: relative;
    z-index: 1;
    max-width: 800px;
    margin: 0 auto;
}

.hero h1 {
    font-size: 3rem;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: pulse 2s infinite;
}

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

.hero p {
    font-size: 1.25rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.hero-stats {
    display: flex;
    justify-content: center;
    gap: 3rem;
    flex-wrap: wrap;
    margin-top: 2rem;
}

.stat {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--bg-card);
    border-radius: 50px;
    box-shadow: 0 4px 12px var(--shadow);
    transition: transform 0.3s ease;
}

.stat:hover {
    transform: translateY(-4px);
}

.stat i {
    color: var(--primary);
    font-size: 1.25rem;
}

.stat span {
    font-weight: 600;
    color: var(--text-primary);
}

/* ================================
   GAME CONTAINER
   ================================ */

.game-container {
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 1rem;
    display: grid;
    grid-template-columns: minmax(220px, 280px) 1fr minmax(220px, 320px);
    gap: 1.5rem;
    min-height: 70vh;
    align-items: start;
    box-sizing: border-box;
    width: 100%;
}

/* ================================
   CHALLENGES SIDEBAR
   ================================ */

.challenges-sidebar {
    background: var(--card-bg);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    height: fit-content;
    position: sticky;
    top: 100px;
    box-shadow: 0 4px 6px -1px var(--shadow);
}

.challenges-sidebar h3 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}

.challenge-list {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    max-height: 520px;
    overflow-y: auto;
    padding-right: .5rem;
}

.challenge-list::-webkit-scrollbar {
    width: 6px;
}

.challenge-list::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 10px;
}

.challenge-list::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}

.challenge-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.3s ease;
    background: var(--bg-secondary);
}

.challenge-item:hover {
    background: var(--game-bg);
    transform: translateX(4px);
}

.challenge-item.active {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.1), rgba(16, 185, 129, 0.05));
    border-color: var(--primary);
    box-shadow: 0 2px 4px var(--shadow);
}

.challenge-item.completed {
    border-left: 4px solid var(--success);
}

.challenge-number {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    background: var(--card-bg);
    border: 1px solid var(--border);
    color: var(--text-primary);
    flex-shrink: 0;
}

.challenge-item.active .challenge-number {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border: none;
}

.challenge-info {
    flex: 1;
    min-width: 0;
}

.challenge-info .title {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.challenge-info .difficulty {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
}

.challenge-info .difficulty.beginner {
    color: var(--success);
}

.challenge-info .difficulty.intermediate {
    color: var(--warning);
}

.challenge-info .difficulty.advanced {
    color: var(--error);
}

.check-icon {
    color: var(--success);
    font-size: 1rem;
    flex-shrink: 0;
}

/* ======= Stats Display ======= */
.stats-display {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    flex-wrap: wrap;
    justify-content: flex-start;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    min-width: 110px;
    flex: 0 1 auto;
    white-space: nowrap;
}

.stat-item i {
    color: var(--primary);
}

.stat-item .label {
    color: var(--text-secondary);
}

.stat-item .value {
    font-weight: 600;
    color: var(--text-primary);
}

/* ======= Main Game Area ======= */
.game-main {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* REMOVED DUPLICATE .game-main .challenge-header STYLES */
/* They're defined in the section below */

/* ================================
   INDIVIDUAL CHALLENGE HEADER (inside game container)
   ================================ */

.challenge-header {
    background: var(--card-bg);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: 0 4px 6px -1px var(--shadow);
    margin: 0;
    text-align: left;
    width: 100%;
    border-left: 5px solid var(--accent);
}

.challenge-meta {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.difficulty-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.difficulty-badge.beginner {
    background: rgba(16, 185, 129, 0.12);
    color: var(--success);
}

.difficulty-badge.intermediate {
    background: rgba(245, 158, 11, 0.12);
    color: var(--warning);
}

.difficulty-badge.advanced {
    background: rgba(239, 68, 68, 0.12);
    color: var(--error);
}

.category-tag {
    padding: 4px 12px;
    background: var(--bg-secondary);
    border-radius: 20px;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.time-estimate {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

#challenge-title {
    font-size: 1.5rem;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

#challenge-description {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    line-height: 1.7;
}

.requirements {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.requirements h4 {
    font-size: 1.125rem;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}

#challenge-requirements {
    list-style: none;
    padding-left: 0;
}

#challenge-requirements li {
    padding: 0.5rem 0;
    padding-left: 1.5rem;
    position: relative;
    color: var(--text-secondary);
}

#challenge-requirements li:before {
    content: "→";
    position: absolute;
    left: 0;
    color: var(--primary);
}

/* ======= Code Editor ======= */
.code-panel {
    background: var(--card-bg);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: 0 4px 6px -1px var(--shadow);
}

.code-panel h3 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}

.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.editor-header label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1rem;
}

.run-btn {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: inline-flex;
    gap: .5rem;
    align-items: center;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px var(--shadow);
}

.run-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px var(--shadow);
}

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

#sql-editor {
    width: 100%;
    min-height: 180px;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.5;
    resize: vertical;
    color: var(--text-primary);
    transition: border-color 0.3s ease;
    box-sizing: border-box;
}

#sql-editor:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

/* ======= Results Panel ======= */
.results-panel {
    background: var(--card-bg);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: 0 4px 6px -1px var(--shadow);
}

.results-panel h3 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}

.results-content {
    min-height: 200px;
    max-height: 400px;
    overflow: auto;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 1rem;
}

/* Keep the spinner but add positioning */
.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

/* Add empty state styling */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* Add a loading container for when spinner is shown */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--text-secondary);
    height: 200px;
    gap: 1rem;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ======= Results Table ======= */
.results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.results-table th {
    background: var(--bg-secondary);
    padding: 0.75rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border);
    position: sticky;
    top: 0;
}

.results-table td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
}

.results-table tr:hover {
    background: var(--game-bg);
}

.results-message {
    padding: 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
}

.results-message.success {
    background: rgba(16, 185, 129, 0.1);
    border-left: 4px solid var(--success);
    color: var(--success);
}

.results-message.error {
    background: rgba(239, 68, 68, 0.1);
    border-left: 4px solid var(--error);
    color: var(--error);
}

/* ======= Info Sidebar ======= */
.info-sidebar {
    background: var(--card-bg);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    height: fit-content;
    position: sticky;
    top: 100px;
    box-shadow: 0 4px 6px -1px var(--shadow);
}

.info-sidebar h3 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}

.schema-card, .sample-card, .progress-card, .reference-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-bottom: 1rem;
}

.schema-card h4, .sample-card h4, .progress-card h4, .reference-card h4 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.schema-columns {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.schema-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px dashed var(--border);
}

.schema-row:last-child {
    border-bottom: none;
}

.column-name {
    font-family: 'Consolas', monospace;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.column-type {
    font-size: 0.75rem;
    color: var(--text-light);
    background: var(--card-bg);
    padding: 2px 6px;
    border-radius: 4px;
}

.sample-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;
}

.sample-table th, .sample-table td {
    padding: 0.5rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

.sample-table th {
    background: var(--card-bg);
    font-weight: 600;
    color: var(--text-primary);
}

.sample-table td {
    color: var(--text-secondary);
}

.sample-info {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 0.5rem;
    text-align: center;
}

.progress-row {
    margin-bottom: 0.75rem;
}

.progress-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
    font-size: 0.875rem;
}

.progress-label span:first-child {
    color: var(--text-secondary);
}

.progress-label span:last-child {
    color: var(--text-primary);
    font-weight: 600;
}

.progress-bar {
    height: 8px;
    background: var(--card-bg);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
}

.progress-fill.overall {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
}

.progress-fill.current {
    background: linear-gradient(135deg, var(--accent), var(--warning));
}

.reference-item {
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px dashed var(--border);
}

.reference-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.reference-code {
    display: block;
    font-family: 'Consolas', monospace;
    font-size: 0.75rem;
    background: var(--card-bg);
    padding: 6px 8px;
    border-radius: 4px;
    margin-bottom: 4px;
    color: var(--text-primary);
    overflow-x: auto;
}

.reference-desc {
    font-size: 0.75rem;
    color: var(--text-light);
}

/* ======= Navigation Buttons ======= */
.nav-buttons {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.nav-btn {
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--card-bg);
    cursor: pointer;
    display: inline-flex;
    gap: .5rem;
    align-items: center;
    font-weight: 500;
    color: var(--text-primary);
    transition: all 0.3s ease;
}

.nav-btn:hover:not(:disabled) {
    background: var(--bg-secondary);
    transform: translateY(-2px);
}

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

.nav-btn.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    border: none;
    box-shadow: 0 2px 4px var(--shadow);
}

.nav-btn.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    border: none;
    box-shadow: 0 2px 4px var(--shadow);
}

.nav-btn.btn-secondary {
    background: var(--bg-secondary);
    border-color: var(--border);
}

.nav-btn.btn-hint {
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.2);
    color: var(--warning);
}

.nav-btn.btn-hint:hover {
    background: rgba(245, 158, 11, 0.2);
}

/* ================================
   RESPONSIVE DESIGN
   ================================ */

/* Large tablets and small laptops */
@media (max-width: 1200px) {
    .game-container {
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 0 20px;
        max-width: 100%;
    }
    
    .challenges-sidebar,
    .info-sidebar {
        position: static;
        max-height: 300px;
        overflow-y: auto;
    }
    
    .challenges-sidebar {
        order: 1;
    }
    
    .game-main {
        order: 2;
    }
    
    .info-sidebar {
        order: 3;
    }
}

/* Tablets and smaller */
@media (max-width: 992px) {
    .hero {
        padding: 5rem 1.5rem 3rem;
    }
    
    .hero-title {
        font-size: 2.8rem;
    }
    
    .hero-description {
        font-size: 1.2rem;
        padding: 0 1rem;
    }
    
    .stat-card {
        padding: 1.25rem 1.75rem;
        min-width: 140px;
    }
    
    .stat-number {
        font-size: 2.25rem;
    }
}

/* Mobile devices */
@media (max-width: 768px) {
    .hero {
        padding: 4rem 1rem 2.5rem;
    }
    
    .hero-title {
        font-size: 2.2rem;
        margin-bottom: 1rem;
    }
    
    .hero-description {
        font-size: 1.1rem;
        margin-bottom: 2rem;
    }
    
    .hero-stats {
        gap: 1rem;
    }
    
    .stat-card {
        padding: 1rem 1.5rem;
        min-width: 120px;
        flex: 1;
        max-width: 180px;
    }
    
    .stat-number {
        font-size: 2rem;
    }
    
    .stat-label {
        font-size: 0.85rem;
    }
    
    /* Game container adjustments */
    .game-container {
        padding: 0 15px;
        margin: 1rem auto;
        gap: 1rem;
    }
    
    /* Fix for the inner challenge header */
    .challenge-header {
        margin: 0;
        padding: 20px;
        width: 100%;
    }
    
    /* Navigation buttons */
    .nav-buttons {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .nav-buttons > div {
        display: flex;
        gap: 0.75rem;
        width: 100%;
    }
    
    .nav-btn {
        width: 100%;
        justify-content: center;
    }
    
    /* Stats display - keep items in 1 line */
    .stats-display {
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 10px;
        padding: 10px;
        justify-content: space-between;
        overflow-x: auto;
    }
    
    .stat-item {
        min-width: 100px;
        white-space: nowrap;
        flex-direction: column;
        align-items: center;
        gap: 4px;
        font-size: 0.85rem;
        width: auto;
        flex: 0 0 auto;
    }
    
    .stat-item i {
        font-size: 1.1rem;
    }
    
    .stat-item .label {
        font-size: 0.8rem;
        text-align: center;
    }
    
    .stat-item .value {
        font-size: 0.9rem;
        font-weight: 700;
    }
    
    /* Ensure all panels fit within screen */
    .challenges-sidebar,
    .info-sidebar,
    .code-panel,
    .results-panel {
        padding: 20px;
        width: 100%;
        box-sizing: border-box;
    }
    
    #sql-editor {
        min-height: 150px;
        font-size: 13px;
    }
    
    .challenge-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .time-estimate {
        margin-left: 0;
    }
    
    #challenge-title {
        font-size: 1.4rem;
    }
    
    [data-theme="dark"] .toggle-thumb {
        transform: translateX(18px);
    }
}

/* Small phones (480px and below) */
@media (max-width: 480px) {
    .hero {
        padding: 3.5rem 1rem 2rem;
    }
    
    .hero-title {
        font-size: 1.9rem;
    }
    
    .hero-description {
        font-size: 1rem;
    }
    
    .game-container {
        padding: 0 10px;
        margin: 0.5rem auto;
    }
    
    .challenge-header {
        padding: 15px;
    }
    
    #challenge-title {
        font-size: 1.3rem;
        line-height: 1.4;
    }
    
    #challenge-description {
        font-size: 0.95rem;
        line-height: 1.6;
    }
    
    .difficulty-badge,
    .category-tag,
    .time-estimate {
        font-size: 0.8rem;
        padding: 3px 10px;
    }
    
    .requirements h4 {
        font-size: 1rem;
    }
    
    #challenge-requirements li {
        font-size: 0.9rem;
        padding-left: 1.2rem;
    }
    
    .nav-buttons > div {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .run-btn {
        padding: 0.75rem 1.2rem;
        font-size: 0.9rem;
    }
    
    .results-content {
        max-height: 300px;
        padding: 15px;
    }
    
    /* Stats display adjustments for very small screens */
    .stats-display {
        gap: 6px;
        padding: 8px;
    }
    
    .stat-item {
        min-width: 85px;
        font-size: 0.75rem;
    }
    
    .stat-item i {
        font-size: 1rem;
    }
    
    .hero-stats {
        flex-direction: column;
        align-items: center;
        width: 100%;
    }
    
    .stat-card {
        width: 100%;
        max-width: 250px;
    }
}

/* Extra small phones (360px and below) */
@media (max-width: 360px) {
    .hero {
        padding: 3rem 0.75rem 1.5rem;
    }
    
    .hero-title {
        font-size: 1.7rem;
    }
    
    .hero-description {
        font-size: 0.95rem;
    }
    
    .game-container {
        padding: 0 8px;
    }
    
    .challenges-sidebar,
    .info-sidebar,
    .code-panel,
    .results-panel {
        padding: 12px;
    }
    
    #sql-editor {
        padding: 12px;
        font-size: 12px;
    }
}

/* ================================
   UTILITY CLASSES
   ================================ */

.hidden {
    display: none !important;
}

.text-success {
    color: var(--success);
}

.text-warning {
    color: var(--warning);
}

.text-error {
    color: var(--error);
}

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

.bg-success {
    background: rgba(16, 185, 129, 0.1);
}

.bg-warning {
    background: rgba(245, 158, 11, 0.1);
}

.bg-error {
    background: rgba(239, 68, 68, 0.1);
}

.bg-info {
    background: rgba(59, 130, 246, 0.1);
}

/* Fix for horizontal scrolling issues */
.game-container * {
    max-width: 100%;
}

/* Ensure tables don't overflow */
.results-table,
.sample-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
}

/* Fix for code editor overflow */
#sql-editor,
.results-content,
.reference-code {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Center align for challenge items on mobile */
@media (max-width: 768px) {
    .challenge-item {
        padding: 12px;
    }
    
    .challenge-number {
        width: 32px;
        height: 32px;
        font-size: 0.9rem;
    }
    
    .challenge-info .title {
        font-size: 0.9rem;
    }
    
    .challenge-info .difficulty {
        font-size: 0.7rem;
    }
}

/* Loading animation */
@keyframes spin {
    to { transform: rotate(360deg); }
}