/* ===== GLOBAL STYLES ===== */
/* Reset and base styles for all elements */
*, *::before, *::after {
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* CSS Custom Properties for dynamic theming */
:root {
    --hue-neutral: 200;  /* Blue hue for neutral state */
    --hue-wrong: 0;      /* Red hue for wrong answers */
    --hue-correct: 145;  /* Green hue for correct answers */
}

/* ===== BODY AND LAYOUT ===== */
/* Main body styling with animated gradient background */
body {
    --hue: var(--hue-neutral);
    padding: 0;
    margin: 0;
    display: flex;
    width: 100vw;
    min-height: 100vh;
    justify-content: center;
    align-items: center;
    /* Dynamic gradient background that changes with quiz state */
    background: linear-gradient(135deg, 
        hsl(var(--hue), 100%, 20%) 0%,
        hsl(var(--hue), 80%, 25%) 50%,
        hsl(var(--hue), 60%, 30%) 100%);
    background-attachment: fixed;
    position: relative;
    overflow: hidden; /* Hide animated elements that go outside viewport */
}

body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 20% 80%, rgba(120, 119, 198, 0.3) 0%, transparent 50%),
                radial-gradient(circle at 80% 20%, rgba(255, 119, 198, 0.3) 0%, transparent 50%),
                radial-gradient(circle at 40% 40%, rgba(120, 219, 255, 0.3) 0%, transparent 50%);
    animation: float 20s ease-in-out infinite;
    z-index: -1;
}

@keyframes float {
    0%, 100% {
        transform: translate(-50px, -50px) rotate(0deg);
    }
    33% {
        transform: translate(50px, -100px) rotate(120deg);
    }
    66% {
        transform: translate(-100px, 50px) rotate(240deg);
    }
}

/* Dynamic body states for answer feedback */
body.correct {
    --hue: var(--hue-correct); /* Green theme for correct answers */
}

body.wrong {
    --hue: var(--hue-wrong); /* Red theme for wrong answers */
}

.container {
    width: 800px;
    max-width: 90%;
    background: linear-gradient(145deg, #ffffff 0%, #f8f9fa 100%);
    border-radius: 20px;
    padding: 2.5rem;
    box-shadow: 
        0 20px 40px rgba(0, 0, 0, 0.1),
        0 8px 16px rgba(0, 0, 0, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    transition: all 0.3s ease;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

header {
    text-align: center;
    margin-bottom: 2rem;
}

header h1 {
    margin: 0 0 1rem 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 2.5rem;
    font-weight: 700;
    text-align: center;
    letter-spacing: -0.02em;
}

.progress {
    background: #f0f0f0;
    border-radius: 20px;
    padding: 1rem;
    font-weight: 600;
    color: #666;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.progress-bar {
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #45a049);
    width: 0%;
    transition: width 0.5s ease;
    border-radius: 4px;
}

.timer {
    color: #e74c3c;
    font-weight: bold;
}

.high-score {
    text-align: center;
    color: #27ae60;
    font-weight: 600;
    margin: 1rem 0;
    padding: 0.5rem;
    background: #e8f5e8;
    border-radius: 8px;
}

.instructions {
    text-align: center;
    color: #666;
    margin: 1rem 0;
    font-style: italic;
}

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

.theme-toggle {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 50%;
    width: 55px;
    height: 55px;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    color: white;
}

.theme-toggle:hover {
    transform: scale(1.1) rotate(10deg);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

/* Dark Mode Styles */
body.dark-mode {
    background: linear-gradient(135deg, 
        hsl(var(--hue), 100%, 8%) 0%,
        hsl(var(--hue), 80%, 12%) 50%,
        hsl(var(--hue), 60%, 15%) 100%);
    background-attachment: fixed;
}

body.dark-mode .container {
    background: linear-gradient(145deg, #2c3e50 0%, #34495e 100%);
    color: #ecf0f1;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

body.dark-mode h1 {
    background: linear-gradient(135deg, #74b9ff 0%, #0984e3 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

body.dark-mode .progress {
    background: #34495e;
    color: #bdc3c7;
}

body.dark-mode .instructions {
    color: #bdc3c7;
}

body.dark-mode .high-score {
    background: #27ae60;
    color: white;
}

body.dark-mode .theme-toggle {
    border-color: #7f8c8d;
    color: #f39c12;
}

body.dark-mode .theme-toggle:hover {
    border-color: #f39c12;
}

.setup-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
    transition: all 0.4s ease;
    transform: translateY(0);
    opacity: 1;
}

.setup-container.hide {
    opacity: 0;
    transform: translateY(-20px);
    pointer-events: none;
}

.setup-section h3 {
    margin: 0 0 1rem 0;
    color: #333;
    font-size: 1.2rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.setup-section h3::before {
    content: '⚙️';
    font-size: 1rem;
}

.select-input {
    width: 100%;
    padding: 15px 20px;
    border: 2px solid #e1e8ed;
    border-radius: 12px;
    font-size: 1rem;
    background: linear-gradient(145deg, #ffffff 0%, #f8f9fa 100%);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.select-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    transform: translateY(-1px);
}

.explanation {
    margin-top: 1rem;
    padding: 1rem;
    background: #f8f9fa;
    border-left: 4px solid #007bff;
    border-radius: 4px;
    font-size: 0.9rem;
    line-height: 1.5;
    animation: slideIn 0.3s ease;
}

.explanation.correct {
    background: #d4edda;
    border-color: #28a745;
    color: #155724;
}

.explanation.wrong {
    background: #f8d7da;
    border-color: #dc3545;
    color: #721c24;
}

body.dark-mode .setup-section h3 {
    color: #ecf0f1;
}

body.dark-mode .select-input {
    background: #34495e;
    color: #ecf0f1;
    border-color: #7f8c8d;
}

body.dark-mode .explanation {
    background: #34495e;
    color: #bdc3c7;
}

body.dark-mode .explanation.correct {
    background: #27ae60;
    color: white;
}

body.dark-mode .explanation.wrong {
    background: #e74c3c;
    color: white;
}

/* ===== MOBILE RESPONSIVENESS ===== */
@media (max-width: 768px) {
    .container {
        max-width: 95%;
        padding: 1.5rem;
        margin: 1rem;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .setup-container {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        margin-bottom: 1.5rem;
    }
    
    .btn-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .btn {
        padding: 18px 20px;
        font-size: 1rem;
        text-align: left;
    }
    
    .start-btn, .next-btn {
        font-size: 1.1rem;
        padding: 16px 25px;
        min-width: 140px;
    }
    
    .progress {
        padding: 0.8rem;
    }
    
    .progress-info {
        font-size: 0.9rem;
    }
    
    .timer {
        font-size: 0.9rem;
    }
    
    .theme-toggle {
        width: 45px;
        height: 45px;
        font-size: 1.3rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 1rem;
        border-radius: 15px;
    }
    
    header h1 {
        font-size: 1.8rem;
    }
    
    .header-top {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .btn {
        padding: 16px 18px;
        font-size: 0.95rem;
    }
    
    .explanation {
        font-size: 0.85rem;
        padding: 0.8rem;
    }
}

#question-container {
    transition: all 0.4s ease;
    transform: translateY(0);
    opacity: 1;
}

#question-container.hide {
    opacity: 0;
    transform: translateY(-20px);
    pointer-events: none;
}





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

.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #ff6b6b;
    animation: confetti-fall 3s linear forwards;
}

.confetti:nth-child(2n) { background: #4ecdc4; }
.confetti:nth-child(3n) { background: #45b7d1; }
.confetti:nth-child(4n) { background: #f9ca24; }
.confetti:nth-child(5n) { background: #6c5ce7; }

@keyframes confetti-fall {
    0% {
        transform: translateY(-100vh) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

.timer.warning {
    color: #e74c3c;
    animation: pulse 1s infinite;
}

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

.btn-grid {
    display: grid;
    grid-template-columns: repeat(2, auto);
    gap: 10px;
    margin: 20px 0;
}

.btn {
    --hue: var(--hue-neutral);
    border: none;
    background: linear-gradient(135deg, hsl(var(--hue), 100%, 50%) 0%, hsl(var(--hue), 100%, 60%) 100%);
    border-radius: 12px;
    padding: 15px 25px;
    color: white;
    outline: none;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1rem;
    font-weight: 500;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.3s, height 0.3s;
}

.btn:active::before {
    width: 300px;
    height: 300px;
}

.btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

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

.btn.correct {
    --hue: var(--hue-correct);
    color: black;
}

.btn.wrong {
    --hue: var(--hue-wrong);
}

.start-btn, .next-btn {
    font-size: 1.2rem;
    font-weight: 600;
    padding: 18px 35px;
    min-width: 180px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 15px;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

.controls {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 2rem;
}

.hide {
    display: none;
}

.particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    animation: particleFloat 15s infinite linear;
}

.particle:nth-child(1) {
    left: 10%;
    animation-delay: 0s;
    animation-duration: 12s;
}

.particle:nth-child(2) {
    left: 20%;
    animation-delay: 2s;
    animation-duration: 18s;
}

.particle:nth-child(3) {
    left: 40%;
    animation-delay: 4s;
    animation-duration: 14s;
}

.particle:nth-child(4) {
    left: 60%;
    animation-delay: 6s;
    animation-duration: 16s;
}

.particle:nth-child(5) {
    left: 80%;
    animation-delay: 8s;
    animation-duration: 20s;
}

.particle:nth-child(6) {
    left: 90%;
    animation-delay: 10s;
    animation-duration: 13s;
}

@keyframes particleFloat {
    0% {
        transform: translateY(100vh) scale(0);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(-100vh) scale(1);
        opacity: 0;
    }
}

body.dark-mode .particle {
    background: rgba(116, 185, 255, 0.4);
}