:root {
    --primary-color: #6366f1;
    --secondary-color: #10b981;
    --accent-color: #f59e0b;
    --success-color: #22c55e;
    --warning-color: #f97316;
    --danger-color: #ef4444;
    --animation-ease: cubic-bezier(0.4, 0, 0.2, 1);
    --animation-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* Light mode (default) */
:root:not([data-theme="dark"]) {
    --light-bg: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    --card-bg: rgba(255, 255, 255, 0.98);
    --card-shadow: 0 4px 6px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.1);
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-light: #94a3b8;
    --border-color: #e2e8f0;
    --hover-bg: rgba(99, 102, 241, 0.05);
    --button-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    --form-bg: rgba(255, 255, 255, 0.95);
    --form-input-bg: rgba(255, 255, 255, 0.98);
    --form-border: #e2e8f0;
    --select-bg: white;
    --select-border: #e2e8f0;
    --quiz-option-bg: white;
    --quiz-option-border: #e2e8f0;
    --checkbox-grid-bg: rgba(99, 102, 241, 0.05);
    --checkbox-pair-bg: rgba(255, 255, 255, 0.9);
    --white-bg: white;
    --footer-bg: rgba(255, 255, 255, 0.5);
}

/* Dark mode */
:root[data-theme="dark"] {
    --light-bg: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    --card-bg: rgba(30, 41, 59, 0.98);
    --card-shadow: 0 4px 6px rgba(0, 0, 0, 0.2), 0 1px 3px rgba(0, 0, 0, 0.3);
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-light: #94a3b8;
    --border-color: rgba(100, 116, 139, 0.3);
    --hover-bg: rgba(99, 102, 241, 0.1);
    --button-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    --form-bg: rgba(30, 41, 59, 0.8);
    --form-input-bg: rgba(15, 23, 42, 0.7);
    --form-border: rgba(100, 116, 139, 0.3);
    --select-bg: rgba(15, 23, 42, 0.7);
    --select-border: rgba(100, 116, 139, 0.4);
    --quiz-option-bg: rgba(30, 41, 59, 0.8);
    --quiz-option-border: rgba(100, 116, 139, 0.4);
    --checkbox-grid-bg: rgba(99, 102, 241, 0.08);
    --checkbox-pair-bg: rgba(30, 41, 59, 0.9);
    --white-bg: rgba(30, 41, 59, 0.95);
    --footer-bg: rgba(15, 23, 42, 0.8);
}

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

body {
    font-family: 'Poppins', 'Segoe UI', 'Arial', sans-serif;
    background: var(--light-bg);
    background-attachment: fixed;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    color: var(--text-primary);
    position: relative;
    overflow-x: hidden;
    line-height: 1.6;
}

/* Subtle background elements */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(circle at 20% 80%, rgba(99, 102, 241, 0.06) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(16, 185, 129, 0.06) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(245, 158, 11, 0.04) 0%, transparent 50%);
    z-index: -1;
    animation: float 25s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0px) rotate(0deg); opacity: 0.8; }
    50% { transform: translateY(-15px) rotate(3deg); opacity: 1; }
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 1.5rem;
    width: 100%;
    position: relative;
}

h1, h2, h3 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
    font-weight: 700;
}

h1 {
    font-size: 2.5rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 800;
    letter-spacing: -0.025em;
    animation: titleGlow 3s ease-in-out infinite alternate;
}

@keyframes titleGlow {
    from { filter: drop-shadow(0 0 2px rgba(99, 102, 241, 0.2)); }
    to { filter: drop-shadow(0 0 8px rgba(16, 185, 129, 0.3)); }
}

.card {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: var(--card-shadow);
    margin-bottom: 1.5rem;
    transition: all 0.3s var(--animation-ease);
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(99, 102, 241, 0.03), transparent);
    transition: left 0.6s;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.08), 0 6px 15px rgba(0, 0, 0, 0.06);
}

.card:hover::before {
    left: 100%;
}

.operation-switch {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 2rem;
    background: var(--hover-bg);
    border-radius: 12px;
    padding: 0.25rem;
    border: 1px solid var(--border-color);
}

.operation-btn {
    flex: 1;
    padding: 0.75rem 1rem;
    text-align: center;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    border-radius: 10px;
    transition: all 0.2s var(--animation-ease);
    background: transparent;
    color: var(--text-secondary);
    border: none;
    position: relative;
}

.operation-btn.active {
    background: var(--primary-color);
    color: white;
    box-shadow: var(--button-shadow);
    transform: scale(1.02);
}

.operation-btn:hover:not(.active) {
    background: rgba(99, 102, 241, 0.08);
    color: var(--primary-color);
    transform: translateY(-1px);
}

.operation-icon {
    font-size: 1.2em;
    margin-right: 0.5rem;
    display: inline-block;
    animation: iconFloat 2s ease-in-out infinite;
}

@keyframes iconFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-2px); }
}

.tabs {
    display: flex;
    justify-content: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tab {
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s var(--animation-bounce);
    font-weight: 600;
    text-align: center;
    min-width: 2.5rem;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    font-size: 0.9rem;
    position: relative;
}

.tab.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    box-shadow: var(--button-shadow);
    transform: scale(1.05);
}

.tab:hover:not(.active) {
    background: var(--hover-bg);
    color: var(--primary-color);
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.question {
    font-size: 3rem;
    text-align: center;
    margin: 2rem 0;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    animation: questionPulse 3s ease-in-out infinite;
}

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

.answer-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.input-field {
    font-size: 1.5rem;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    width: 6rem;
    text-align: center;
    border: 2px solid var(--border-color);
    background: var(--white-bg);
    color: var(--text-primary);
    font-weight: 700;
    transition: all 0.2s var(--animation-bounce);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.input-field:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1), 0 4px 12px rgba(99, 102, 241, 0.15);
    transform: scale(1.05);
}

button {
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, var(--primary-color), #5b5ff7);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.2s var(--animation-ease);
    box-shadow: var(--button-shadow);
    position: relative;
    overflow: hidden;
}

button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.4s;
}

button:hover {
    background: linear-gradient(135deg, #5856eb, #4f46e5);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.3);
}

button:hover::before {
    left: 100%;
}

button:active {
    transform: translateY(0);
}

.message {
    text-align: center;
    font-size: 1.25rem;
    margin: 1.5rem 0;
    min-height: 2rem;
    font-weight: 600;
    border-radius: 12px;
    padding: 1rem;
    transition: all 0.3s var(--animation-bounce);
    background: transparent;
    color: var(--text-secondary);
}

.message.correct {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.1), rgba(34, 197, 94, 0.05));
    color: #15803d;
    border: 1px solid rgba(34, 197, 94, 0.2);
    animation: successPulse 0.6s var(--animation-bounce);
}

.message.wrong {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), rgba(239, 68, 68, 0.05));
    color: #dc2626;
    border: 1px solid rgba(239, 68, 68, 0.2);
    animation: errorShake 0.5s ease-in-out;
}

@keyframes successPulse {
    0% { transform: scale(0.95); opacity: 0.8; }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes errorShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.emoji {
    font-size: 1.5rem;
    margin-right: 0.5rem;
    display: inline-block;
    animation: emojiFloat 0.6s var(--animation-bounce);
}

@keyframes emojiFloat {
    0% { transform: scale(0.8) rotate(-10deg); }
    50% { transform: scale(1.1) rotate(5deg); }
    100% { transform: scale(1) rotate(0deg); }
}

.stats {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin: 2rem 0;
    flex-wrap: wrap;
}

.stat-card {
    padding: 1.25rem;
    border-radius: 12px;
    text-align: center;
    min-width: 120px;
    background: var(--white-bg);
    border: 1px solid var(--border-color);
    transition: all 0.2s var(--animation-ease);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(99, 102, 241, 0.03), transparent);
    animation: statShimmer 4s ease-in-out infinite;
}

@keyframes statShimmer {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.progress-container, .timer-container {
    margin: 2rem 0;
    background: var(--white-bg);
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    transition: all 0.2s var(--animation-ease);
}

.progress-container:hover, .timer-container:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.progress-bar, .timer-bar {
    width: 100%;
    height: 8px;
    background: var(--hover-bg);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    transition: width 0.3s ease;
    border-radius: 4px;
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: progressShine 2s ease-in-out infinite;
}

@keyframes progressShine {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.timer-fill {
    height: 100%;
    background: var(--secondary-color);
    transition: width 0.1s linear;
    border-radius: 4px;
}

.timer-fill.warning {
    background: var(--warning-color);
}

.timer-fill.danger {
    background: var(--danger-color);
    animation: dangerPulse 0.5s ease-in-out infinite;
}

@keyframes dangerPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.quiz-options-container {
    width: 100%;
    margin: 2rem 0;
}

.quiz-options-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.quiz-option {
    padding: 1rem;
    font-size: 1.25rem;
    font-weight: 600;
    text-align: center;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s var(--animation-bounce);
    background: var(--quiz-option-bg);
    border: 2px solid var(--quiz-option-border);
    color: var(--text-primary) !important;
    position: relative;
    overflow: hidden;
}

.quiz-option::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(99, 102, 241, 0.1), transparent);
    transition: left 0.4s;
}

.quiz-option:hover {
    border-color: var(--primary-color);
    background: var(--quiz-option-bg);
    filter: brightness(1.1);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.15);
}

.quiz-option:hover::before {
    left: 100%;
}

.quiz-option.correct {
    background: linear-gradient(135deg, var(--success-color), #16a34a);
    color: white !important;
    border-color: var(--success-color);
    animation: correctGlow 0.6s var(--animation-bounce);
}

.quiz-option.wrong {
    background: linear-gradient(135deg, var(--danger-color), #dc2626);
    color: white !important;
    border-color: var(--danger-color);
    animation: wrongShake 0.4s ease-in-out;
}

@keyframes correctGlow {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); }
    50% { transform: scale(1.02); box-shadow: 0 0 0 10px rgba(34, 197, 94, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

@keyframes wrongShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.celebration {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s;
}

.celebration.show {
    opacity: 1;
}

/* Success Ring Animation */
.success-ring {
    position: absolute;
    border: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: successRingExpand 1.5s ease-out forwards;
}

@keyframes successRingExpand {
    0% {
        width: 0;
        height: 0;
        opacity: 1;
        border-width: 8px;
    }
    100% {
        width: 300px;
        height: 300px;
        opacity: 0;
        border-width: 2px;
    }
}

/* Math Symbol Particles */
.math-particle {
    position: absolute;
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary-color);
    animation: mathParticleFloat 3s ease-out forwards;
    text-shadow: 0 0 10px rgba(99, 102, 241, 0.5);
}

@keyframes mathParticleFloat {
    0% {
        transform: translateY(0) rotate(0deg) scale(0.5);
        opacity: 1;
    }
    50% {
        transform: translateY(-150px) rotate(180deg) scale(1.2);
        opacity: 0.8;
    }
    100% {
        transform: translateY(-300px) rotate(360deg) scale(0.3);
        opacity: 0;
    }
}

/* Calculator Emoji Rain */
.calculator-emoji {
    position: absolute;
    font-size: 2.5rem;
    animation: calculatorRain 4s ease-out forwards;
    filter: drop-shadow(0 0 8px rgba(245, 158, 11, 0.6));
}

@keyframes calculatorRain {
    0% {
        transform: translateY(-100vh) rotate(0deg) scale(0.8);
        opacity: 1;
    }
    50% {
        transform: translateY(50vh) rotate(180deg) scale(1.1);
        opacity: 0.9;
    }
    100% {
        transform: translateY(120vh) rotate(360deg) scale(0.6);
        opacity: 0;
    }
}

/* Burst Particles */
.burst-particle {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: burstParticle 2s ease-out forwards;
}

@keyframes burstParticle {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(0) translateX(var(--burst-x)) translateY(var(--burst-y));
        opacity: 0;
    }
}

/* Achievement Badge */
.achievement-badge {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 1.5rem 2rem;
    border-radius: 20px;
    font-size: 1.5rem;
    font-weight: bold;
    text-align: center;
    box-shadow: 0 10px 30px rgba(99, 102, 241, 0.4);
    animation: achievementPop 2s ease-out forwards;
    border: 3px solid rgba(255, 255, 255, 0.3);
}

@keyframes achievementPop {
    0% {
        transform: translate(-50%, -50%) scale(0) rotate(-180deg);
        opacity: 0;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.2) rotate(0deg);
        opacity: 1;
    }
    80% {
        transform: translate(-50%, -50%) scale(1) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(0.9) rotate(0deg);
        opacity: 0;
    }
}

/* Sparkle Effects */
.sparkle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: linear-gradient(45deg, #fff, var(--accent-color));
    border-radius: 50%;
    animation: sparkleFloat 2.5s ease-out forwards;
    box-shadow: 0 0 6px var(--accent-color);
}

@keyframes sparkleFloat {
    0% {
        transform: translateY(0) scale(0);
        opacity: 1;
    }
    50% {
        transform: translateY(-100px) scale(1);
        opacity: 1;
    }
    100% {
        transform: translateY(-200px) scale(0);
        opacity: 0;
    }
}

/* Number Rain */
.number-rain {
    position: absolute;
    font-size: 1.8rem;
    font-weight: bold;
    background: linear-gradient(135deg, var(--secondary-color), var(--accent-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: numberRainFall 3.5s ease-out forwards;
    text-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
}

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

.streak-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-left: 0.5rem;
    animation: streakPulse 2s ease-in-out infinite;
}

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

.history-container {
    margin-top: 2rem;
}

.history-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1rem;
}

.history-item {
    background: var(--white-bg);
    border: 1px solid var(--border-color);
    padding: 1rem;
    border-radius: 12px;
    font-size: 0.9rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: all 0.2s var(--animation-ease);
    position: relative;
    overflow: hidden;
}

.history-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(99, 102, 241, 0.05), transparent);
    transition: left 0.5s;
}

.history-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
}

.history-item:hover::before {
    left: 100%;
}

.history-score {
    font-weight: 700;
    font-size: 1.5rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.history-date {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-bottom: 0.25rem;
}

.history-type {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: center;
    margin-top: 0.25rem;
}

.history-title {
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text-primary);
    font-size: 1.25rem;
}

.footer {
    margin-top: auto;
    text-align: center;
    padding: 2rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
    background: var(--footer-bg);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border-color);
}

.footer-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s var(--animation-ease);
}

.footer-link:hover {
    color: #5856eb;
    text-shadow: 0 0 8px rgba(99, 102, 241, 0.3);
}

/* Dark Mode Toggle in Top Right Corner */
.dark-mode-toggle-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 100;
}

.dark-mode-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    padding: 0.4rem;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    width: 2rem;
    height: 2rem;
}

.dark-mode-toggle:hover {
    color: var(--text-primary);
    background: var(--hover-bg);
    border-color: var(--primary-color);
}

.dark-mode-toggle:active {
    transform: scale(0.98);
}

.dark-mode-toggle .toggle-icon {
    font-size: 1rem;
    transition: transform 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Responsive adjustments for dark mode toggle */
@media (max-width: 640px) {
    .dark-mode-toggle-container {
        top: 0.75rem;
        right: 0.75rem;
    }
    
    .dark-mode-toggle {
        padding: 0.35rem;
        width: 1.8rem;
        height: 1.8rem;
    }
    
    .dark-mode-toggle .toggle-icon {
        font-size: 0.9rem;
    }
}

.cookie-notice {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, var(--primary-color), #5b5ff7);
    color: white;
    z-index: 1000;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
}

.cookie-text {
    font-size: 0.9rem;
    line-height: 1.4;
    display: inline-block;
    width: calc(100% - 120px);
    vertical-align: middle;
}

.cookie-btn {
    background: var(--white-bg);
    color: var(--primary-color);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s var(--animation-bounce);
    font-size: 0.85rem;
    white-space: nowrap;
    display: inline-block;
    float: right;
    vertical-align: middle;
}

.cookie-btn:hover {
    background: #f8fafc;
    transform: scale(1.05);
}

.settings-container {
    margin-top: 2rem;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    background: var(--white-bg);
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    transition: all 0.2s var(--animation-ease);
}

.setting-row:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.setting-row .settings-label {
    font-weight: 600;
    flex: 1;
    color: var(--text-primary);
}

select.input-field {
    min-width: 180px;
    font-size: 0.9rem;
    padding: 0.5rem 0.75rem;
    background: var(--select-bg);
    border: 1px solid var(--select-border);
    border-radius: 8px;
    color: var(--text-primary) !important;
    font-weight: 700;
    transition: all 0.2s var(--animation-ease);
}

select.input-field:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
    background: var(--select-bg);
    filter: brightness(1.1);
}

.mode-switch {
    display: flex;
    gap: 0.25rem;
    justify-content: center;
    margin: 2rem 0;
    background: var(--hover-bg);
    padding: 0.25rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.mode-switch button {
    flex: 1;
    max-width: 120px;
    background: transparent;
    color: var(--text-secondary);
    border: none;
    font-weight: 600;
    transition: all 0.2s var(--animation-bounce);
    padding: 0.5rem 1rem;
    border-radius: 10px;
    font-size: 0.9rem;
}

.mode-switch button.active {
    background: var(--primary-color);
    color: white;
    box-shadow: var(--button-shadow);
    transform: scale(1.05);
}

.mode-switch button:hover:not(.active) {
    background: rgba(99, 102, 241, 0.08);
    color: var(--primary-color);
    transform: scale(1.02);
}

/* Responsive Design */
@media (max-width: 640px) {
    .container {
        padding: 1rem;
    }
    .question {
        font-size: 2.5rem;
    }
    .input-field {
        font-size: 1.25rem;
        width: 5rem;
    }
    .tab {
        padding: 0.4rem 0.8rem;
        font-size: 0.85rem;
    }
    h1 {
        font-size: 2rem;
    }
    .quiz-options-grid {
        grid-template-columns: 1fr;
    }
    .stats {
        flex-direction: column;
        align-items: center;
    }
}

/* Werkblad.html specific styles */
.form-section {
    margin-bottom: 1.5rem;
}

.form-group {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    background: var(--form-bg);
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid var(--form-border);
    transition: all 0.2s var(--animation-ease);
}

.form-group:hover {
    background: var(--form-bg);
    filter: brightness(1.1);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.15);
}

.form-group label {
    font-weight: 600;
    flex: 1;
    color: var(--text-primary) !important;
    font-size: 1rem;
    margin-right: 1rem;
    min-width: 200px;
    align-self: center;
}

.form-group select,
.form-group input[type="text"],
.form-group input[type="number"] {
    min-width: 200px;
    font-size: 1rem;
    padding: 0.75rem;
    border-radius: 12px;
    border: 2px solid var(--form-border);
    background: var(--form-input-bg);
    color: var(--text-primary) !important;
    font-weight: 700;
    transition: all 0.2s var(--animation-bounce);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.form-group select:focus,
.form-group input[type="text"]:focus,
.form-group input[type="number"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2), 0 4px 12px rgba(99, 102, 241, 0.25);
    transform: scale(1.02);
    background: var(--form-input-bg);
    filter: brightness(1.1);
}

/* Tab buttons styling */
.tabs-container {
    display: flex;
    justify-content: center;
    margin-bottom: 2rem;
}

.tab-buttons {
    display: flex;
    gap: 0.25rem;
    background: var(--hover-bg);
    border-radius: 12px;
    padding: 0.25rem;
    border: 1px solid var(--border-color);
}

.tab-btn {
    flex: 1;
    padding: 0.75rem 1.5rem;
    text-align: center;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    border-radius: 10px;
    transition: all 0.2s var(--animation-bounce);
    background: transparent;
    color: var(--text-secondary);
    border: none;
    position: relative;
    overflow: hidden;
}

.tab-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(99, 102, 241, 0.1), transparent);
    transition: left 0.4s;
}

.tab-btn.active {
    background: linear-gradient(135deg, var(--primary-color), #5b5ff7);
    color: white;
    box-shadow: var(--button-shadow);
    transform: scale(1.02);
}

.tab-btn:hover:not(.active) {
    background: rgba(99, 102, 241, 0.08);
    color: var(--primary-color);
    transform: translateY(-1px);
}

.tab-btn:hover::before {
    left: 100%;
}

/* Custom checkbox grid styling */
.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 6px;
    width: 100%;
    max-width: 280px;
    margin: 0;
    background: var(--checkbox-grid-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px;
    flex-shrink: 0;
}

.checkbox-pair {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6px;
    background: var(--checkbox-pair-bg);
    border-radius: 6px;
    transition: all 0.2s var(--animation-ease);
    border: 1px solid var(--border-color);
    min-height: 32px;
    box-sizing: border-box;
    max-width: 48px;
    cursor: pointer;
}

.checkbox-pair:hover {
    background: var(--white-bg);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.15);
    transform: translateY(-1px);
}

.checkbox-pair input {
    margin: 0 0 4px 0;
    padding: 0;
    accent-color: var(--primary-color);
    width: 14px;
    height: 14px;
}

.checkbox-pair label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary) !important;
    cursor: pointer;
    margin: 0;
    line-height: 1;
    text-align: center;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Preview and print styles */
#preview-section {
    display: none;
}

.action-buttons {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.action-buttons button {
    flex: 1;
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    background: linear-gradient(135deg, var(--primary-color), #5b5ff7);
    color: white;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.2s var(--animation-ease);
    box-shadow: var(--button-shadow);
    position: relative;
    overflow: hidden;
}

.action-buttons button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.4s;
}

.action-buttons button:hover {
    background: linear-gradient(135deg, #5856eb, #4f46e5);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.3);
}

.action-buttons button:hover::before {
    left: 100%;
}

#worksheet-preview {
    margin-top: 1.5rem;
    max-height: 600px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    padding: 1rem;
    border-radius: 12px;
    background-color: var(--white-bg);
    box-shadow: var(--card-shadow);
}

/* Exercise sheet styles */
.exercise-sheet {
    width: 210mm;
    margin: 0 auto 2rem auto;
    background-color: var(--white-bg);
    padding: 2cm 1.5cm 1.5cm 1.5cm;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    position: relative;
    border-radius: 8px;
    color: var(--text-primary);
    box-sizing: border-box;
}

.exercise-title {
    text-align: center;
    margin-bottom: 1rem;
    font-size: 1.3rem;
    font-weight: bold;
    color: var(--text-primary);
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
}

.exercise-grid {
    display: grid;
    gap: 1rem;
    font-size: 1rem;
    color: var(--text-primary);
}

.exercise {
    padding: 0.4rem 0;
    color: var(--text-primary);
}

.exercise-problem {
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    color: var(--text-primary);
    font-weight: 600;
    line-height: 1.4;
}

.answer-space {
    display: inline-block;
    width: 3rem;
    margin-left: 0.5rem;
    position: relative;
}

.answer-space::after {
    content: "....................";
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 100%;
    letter-spacing: 1px;
    color: var(--text-primary) !important;
    font-size: 0.8rem;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
}

.answers-sheet {
    page-break-before: always;
    background-color: var(--white-bg);
    color: var(--text-primary);
}

/* Number checkboxes style */
.number-checkboxes {
    display: block;
    width: 200px;
    text-align: left;
}

/* Print styles for werkblad */
@media print {
    @page {
        size: A4;
        margin: 0;
    }

    body {
        margin: 0;
        padding: 0;
    }

    #form-section, .site-logo, .footer, .action-buttons {
        display: none;
    }

    /* Hide dark mode toggle in print */
    button[aria-label*="Switch to"], .dark-mode-toggle-container {
        display: none !important;
    }

    #preview-section {
        display: block;
        margin: 0;
        padding: 0;
    }

    #worksheet-preview {
        max-height: none;
        overflow: visible;
        border: none;
        padding: 0;
        margin: 0;
    }

    .exercise-sheet {
        box-shadow: none;
        margin: 0;
        padding: 1cm 0.8cm 0.6cm 0.8cm;
        page-break-after: always;
        height: auto;
    }

    .exercise-grid {
        gap: 0.6rem;
    }

    /* Ultra-compact for 3 columns */
    .exercise-grid[style*="repeat(3"] {
        gap: 0.4rem;
    }

    .exercise {
        padding: 0.2rem 0;
    }

    /* Ultra-compact exercise padding for 3 columns */
    .exercise-grid[style*="repeat(3"] .exercise {
        padding: 0.15rem 0;
    }

    .exercise-problem {
        font-size: 1rem;
        line-height: 1.2;
    }

    /* Ultra-compact for 3 columns */
    .exercise-grid[style*="repeat(3"] .exercise-problem {
        font-size: 0.95rem;
        line-height: 1.1;
    }

    .exercise-title {
        margin-bottom: 0.8rem;
        font-size: 1.2rem;
    }

    /* Smaller title for 3-column layouts */
    .exercise-sheet:has(.exercise-grid[style*="repeat(3"]) .exercise-title {
        margin-bottom: 0.6rem;
        font-size: 1.1rem;
    }

    .answers-sheet {
        page-break-before: always;
    }

    .answer-space::after {
        content: "....................";
        position: absolute;
        bottom: -5px;
        left: 0;
        width: 100%;
        letter-spacing: 1px;
        color: var(--text-primary) !important;
        font-size: 0.8rem;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }

    /* Compact answer space for 3 columns */
    .exercise-grid[style*="repeat(3"] .answer-space::after {
        content: "................";
        font-size: 0.7rem;
    }

    /* Structured worksheet specific optimizations */
    .exercise-sheet {
        min-height: 26cm; /* Ensure consistent page height */
    }

    /* Table headers in structured worksheets */
    .exercise[style*="grid-column: 1 / span"] {
        margin-top: 0.6rem !important;
        margin-bottom: 0.3rem !important;
        padding-bottom: 0.15rem !important;
        border-bottom: 1px solid #ccc !important;
        font-size: 0.95rem !important;
        background: #f8f9fa !important;
        color: #000 !important;
        print-color-adjust: exact !important;
        -webkit-print-color-adjust: exact !important;
    }

    /* First table header on page should have less top margin */
    .exercise-grid > .exercise[style*="grid-column: 1 / span"]:first-child {
        margin-top: 0.3rem !important;
    }

    /* Ultra-compact spacing for 3-column structured worksheets */
    .exercise-grid[style*="repeat(3"] .exercise[style*="grid-column: 1 / span"] {
        margin-top: 0.4rem !important;
        margin-bottom: 0.2rem !important;
        font-size: 0.9rem !important;
        padding-bottom: 0.1rem !important;
    }

    .exercise-grid[style*="repeat(3"] .exercise[style*="grid-column: 1 / span"]:first-child {
        margin-top: 0.15rem !important;
    }

    /* Ensure structured worksheets fit properly on A4 */
    .exercise-sheet:has(.exercise[style*="grid-column: 1 / span"]) {
        padding: 0.7cm 0.6cm 0.4cm 0.6cm;
    }

    /* 2-column structured worksheets optimized padding */
    .exercise-sheet:has(.exercise-grid[style*="repeat(2"]) {
        padding: 0.6cm 0.5cm 0.35cm 0.5cm;
    }

    /* 3-column structured worksheets need even more compact spacing */
    .exercise-sheet:has(.exercise-grid[style*="repeat(3"]) {
        padding: 0.5cm 0.4cm 0.3cm 0.4cm;
    }

    /* More compact exercise spacing for structured worksheets */
    .exercise-sheet:has(.exercise[style*="grid-column: 1 / span"]) .exercise {
        padding: 0.15rem 0;
    }

    .exercise-sheet:has(.exercise-grid[style*="repeat(2"]) .exercise {
        padding: 0.12rem 0;
    }

    .exercise-sheet:has(.exercise-grid[style*="repeat(3"]) .exercise {
        padding: 0.1rem 0;
    }

    /* Optimized spacing for 2-column layouts */
    .exercise-grid[style*="repeat(2"] {
        gap: 0.5rem;
    }

    .exercise-grid[style*="repeat(2"] .exercise {
        padding: 0.18rem 0;
    }

    .exercise-grid[style*="repeat(2"] .exercise-problem {
        font-size: 0.98rem;
        line-height: 1.15;
    }

    .exercise-grid[style*="repeat(2"] .answer-space::after {
        content: "..................";
        font-size: 0.75rem;
    }

    /* 2-column structured worksheet optimizations */
    .exercise-grid[style*="repeat(2"] .exercise[style*="grid-column: 1 / span"] {
        margin-top: 0.5rem !important;
        margin-bottom: 0.25rem !important;
        font-size: 0.95rem !important;
        padding-bottom: 0.12rem !important;
    }

    .exercise-grid[style*="repeat(2"] .exercise[style*="grid-column: 1 / span"]:first-child {
        margin-top: 0.2rem !important;
    }

    /* Structured worksheet specific optimizations */
    .exercise-sheet:has(.exercise[style*="grid-column: 1 / span"]) {
        padding: 0.7cm 0.6cm 0.4cm 0.6cm;
    }

    /* 3-column structured worksheets need even more compact spacing */
    .exercise-sheet:has(.exercise-grid[style*="repeat(3"]) {
        padding: 0.5cm 0.4cm 0.3cm 0.4cm;
    }

    /* Ensure all exercise text is dark black for printing */
    .exercise-problem {
        color: #000 !important;
        print-color-adjust: exact !important;
        -webkit-print-color-adjust: exact !important;
    }

    .exercise {
        color: #000 !important;
        print-color-adjust: exact !important;
        -webkit-print-color-adjust: exact !important;
    }

    /* Ensure exercise title is dark for printing */
    .exercise-title {
        color: #000 !important;
        print-color-adjust: exact !important;
        -webkit-print-color-adjust: exact !important;
    }

    /* Ensure answer spaces are dark for printing */
    .answer-space::after {
        color: #000 !important;
        print-color-adjust: exact !important;
        -webkit-print-color-adjust: exact !important;
    }
}

/* Hide dark mode toggle when preview is active */
.preview-active button[aria-label*="Switch to"], .preview-active .dark-mode-toggle-container {
    display: none !important;
}