:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --success-color: #10b981;
    --error-color: #ef4444;
    --bg-gradient-start: #0f172a;
    --bg-gradient-end: #1e293b;
    --card-bg: #ffffff;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

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

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    color: var(--text-primary);
    line-height: 1.6;
}

header {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 2rem;
    text-align: center;
}

header h1 {
    color: #fff;
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -0.025em;
    background: linear-gradient(to right, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

section {
    width: 100%;
    text-align: center;
}

.quiz-card, #setup-card {
    background: var(--card-bg);
    border-radius: 1.5rem;
    padding: 3rem;
    box-shadow: var(--shadow-xl);
    animation: slideIn 0.5s ease-out;
}

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

#setup-card {
    max-width: 500px;
    margin: 0 auto;
}

#setup-card h2 {
    color: var(--text-primary);
    font-size: 1.875rem;
    font-weight: 700;
    margin-bottom: 2rem;
}

.form-group {
    margin-bottom: 1.5rem;
    text-align: left;
}

.form-group label {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.form-group input[type="number"] {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 0.75rem;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: #f9fafb;
}

.form-group input[type="number"]:focus {
    outline: none;
    border-color: var(--primary-color);
    background: white;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Styled select for source selection */
.form-group select,
#questionSource {
    width: 100%;
    padding: 0.875rem 2.75rem 0.875rem 1rem; /* extra right padding for chevron */
    border: 2px solid var(--border-color);
    border-radius: 0.75rem;
    font-size: 1rem;
    transition: all 0.25s ease;
    background-color: #f9fafb;
    color: var(--text-primary);
    /* Remove native arrows and add custom */
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image:
      url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' viewBox='0 0 24 24' stroke='%232563eb' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.85rem center;
    background-size: 1rem;
    cursor: pointer;
}

.form-group select:hover,
#questionSource:hover {
    border-color: var(--primary-color);
    background-color: #fff;
}

.form-group select:focus,
#questionSource:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: #fff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group select:disabled,
#questionSource:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.question-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.question-number {
    display: inline-block;
    background: linear-gradient(135deg, var(--primary-color), #7c3aed);
    color: white;
    padding: 0.5rem 1.25rem;
    border-radius: 2rem;
    font-weight: 600;
    font-size: 0.875rem;
}

.question-text {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2rem;
    line-height: 1.7;
    text-align: left;
}

.answers-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

.answer-option {
    display: flex;
    align-items: center;
    padding: 1.25rem;
    border: 2px solid var(--border-color);
    border-radius: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f9fafb;
    text-align: left;
    position: relative;
}

.answer-option:hover {
    border-color: var(--primary-color);
    background: white;
    transform: translateX(4px);
    box-shadow: var(--shadow-md);
}

.answer-option input[type="radio"],
.answer-option input[type="checkbox"] {
    width: 1.25rem;
    height: 1.25rem;
    margin-right: 1rem;
    cursor: pointer;
    accent-color: var(--primary-color);
    flex-shrink: 0;
}

.answer-option label {
    flex: 1;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-primary);
    user-select: none;
}

/* Rendre toute la zone cliquable */
.answer-option input[type="radio"] ~ label,
.answer-option input[type="checkbox"] ~ label {
    width: 100%;
}

.answer-option:has(input:checked) {
    border-color: var(--primary-color);
    background: #eff6ff;
}

.answer-option.correct {
    border-color: var(--success-color);
    background: #f0fdf4;
}

.answer-option.incorrect {
    border-color: var(--error-color);
    background: #fef2f2;
}

button {
    padding: 1rem 2.5rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), #7c3aed);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

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

.btn-secondary {
    background: white;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

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

.button-group {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 2rem;
}

#corrections {
    margin-top: 2rem;
    padding: 2rem;
    background: #fef2f2;
    border: 2px solid var(--error-color);
    border-radius: 1rem;
    animation: slideIn 0.3s ease-out;
}

#corrections h2 {
    color: var(--error-color);
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

#correct-answers {
    text-align: left;
    color: var(--text-primary);
}

#correct-answers p {
    margin-bottom: 1rem;
    font-size: 1.05rem;
}

#correct-answers span {
    font-weight: 600;
    color: var(--success-color);
}

.score-display {
    text-align: center;
    padding: 2rem;
}

.score-value {
    font-size: 4rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary-color), #7c3aed);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 1rem 0;
}

.score-label {
    font-size: 1.5rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.percentage {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
}

footer {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 1.5rem;
    text-align: center;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9rem;
}

/* Footer link to the grade calculator */
.footer-link{
    display: inline-block;
    margin-top: 0.25rem;
    padding: 0.5rem 0.9rem;
    background: linear-gradient(90deg, var(--primary-color), #7c3aed);
    color: white !important;
    border-radius: 0.6rem;
    text-decoration: none;
    font-weight: 700;
    box-shadow: 0 6px 18px rgba(37,99,235,0.18);
    transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
}
.footer-link:hover{
    transform: translateY(-3px);
    box-shadow: 0 12px 30px rgba(37,99,235,0.22);
    opacity: 0.98;
}
.footer-link:active{ transform: translateY(-1px); }


img {
    max-width: 100%;
    height: auto;
    border-radius: 1rem;
    margin: 1.5rem 0;
    box-shadow: var(--shadow-md);
}

.progress-bar {
    width: 100%;
    height: 0.5rem;
    background: var(--border-color);
    border-radius: 1rem;
    overflow: hidden;
    margin-bottom: 2rem;
}

/* Badge showing total number of questions */
.questions-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 3rem;
    height: 2.25rem;
    padding: 0 0.5rem;
    background: linear-gradient(135deg, #eef2ff, #e9d5ff);
    color: var(--text-primary);
    border-radius: 0.75rem;
    border: 1px solid var(--border-color);
    font-weight: 700;
}
.questions-badge.good {
    background: linear-gradient(135deg, #ecfdf5, #bbf7d0);
    border-color: rgba(16,185,129,0.25);
    color: #065f46;
}
.questions-badge.warn {
    background: linear-gradient(135deg, #fffbeb, #fecaca);
    border-color: rgba(239,68,68,0.15);
    color: #7c2d12;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), #7c3aed);
    transition: width 0.3s ease;
}

#corrections, #questions {
    display: none;
}

@media (max-width: 768px) {
    header h1 {
        font-size: 1.875rem;
    }
    
    .quiz-card, #setup-card {
        padding: 2rem 1.5rem;
    }
    
    .question-text {
        font-size: 1.1rem;
    }
    
    .answer-option {
        padding: 1rem;
    }
    
    button {
        padding: 0.875rem 2rem;
    }
    
    .button-group {
        flex-direction: column;
    }
    
    main {
        padding: 1rem;
    }
}