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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: #f4f6f9;
    color: #1a1a2e;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 2rem 1rem;
}

.container {
    width: 100%;
    max-width: 800px;
}

/* ---- Screens ---- */
.screen {
    animation: fadeIn 0.3s ease;
}

.screen.hidden {
    display: none;
}

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

/* ---- Welcome ---- */
#welcome {
    text-align: center;
    padding-top: 3rem;
}

#welcome h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    color: #1a1a2e;
}

.subtitle {
    color: #555;
    margin-bottom: 2rem;
}

.name-field {
    margin-bottom: 1.5rem;
}

.name-field label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 600;
    color: #333;
}

.name-field input {
    width: 100%;
    max-width: 320px;
    padding: 0.7rem 1rem;
    border: 2px solid #ccc;
    border-radius: 8px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

.name-field input:focus {
    border-color: #3366cc;
}

/* ---- Quiz selector ---- */
.quiz-selector {
    margin-bottom: 1.5rem;
}

.quiz-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    max-width: 720px;
    margin: 0 auto;
}

.quiz-column {
    min-width: 0;
}

.column-heading {
    font-size: 1rem;
    font-weight: 700;
    color: #555;
    margin-bottom: 0.6rem;
    padding-bottom: 0.35rem;
    border-bottom: 2px solid #e0e0e0;
    text-align: center;
}

.quiz-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.quiz-empty {
    text-align: center;
    color: #aaa;
    font-size: 0.85rem;
    padding: 0.5rem;
}

.quiz-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 0.9rem 1.2rem;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
    text-align: left;
    font-size: 1rem;
    transition: border-color 0.2s, background 0.2s, transform 0.1s;
}

.quiz-card:hover {
    border-color: #b3c7f0;
    background: #f8faff;
}

.quiz-card.active {
    border-color: #3366cc;
    background: #edf2ff;
    box-shadow: 0 0 0 3px rgba(51, 102, 204, 0.15);
}

.quiz-card-title {
    font-weight: 600;
    color: #1a1a2e;
}

.quiz-card-meta {
    font-size: 0.85rem;
    color: #888;
    white-space: nowrap;
    margin-left: 1rem;
}

.quiz-error {
    color: #e3493b;
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

/* ---- Quiz title banner ---- */
.quiz-title-banner {
    margin-bottom: 1rem;
}

.quiz-badge {
    display: inline-block;
    padding: 0.3rem 1rem;
    border-radius: 20px;
    background: #3366cc;
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
}

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

.quiz-header .quiz-title-banner {
    margin-bottom: 0;
}

.btn-quit {
    background: none;
    border: 1px solid #ccc;
    border-radius: 6px;
    padding: 0.3rem 0.8rem;
    font-size: 0.85rem;
    color: #888;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
    flex-shrink: 0;
}

.btn-quit:hover {
    color: #e3493b;
    border-color: #e3493b;
}

/* ---- Buttons ---- */
.btn {
    display: inline-block;
    padding: 0.7rem 1.6rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    text-decoration: none;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: #3366cc;
    color: #fff;
}

.btn-primary:hover {
    background: #254da6;
}

.btn-success {
    background: #22a06b;
    color: #fff;
}

.btn-success:hover {
    background: #1a7d53;
}

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

.btn-outline {
    background: transparent;
    color: #3366cc;
    border: 2px solid #3366cc;
}

.btn-outline:hover {
    background: #e8eeff;
}

/* ---- Progress bar ---- */
.progress-bar {
    margin-bottom: 1.5rem;
}

.progress-text {
    font-size: 0.9rem;
    color: #666;
    display: block;
    margin-bottom: 0.4rem;
}

.progress-track {
    height: 6px;
    background: #ddd;
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: #3366cc;
    border-radius: 3px;
    transition: width 0.3s ease;
}

/* ---- Question card ---- */
.question-card {
    background: #fff;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    margin-bottom: 1.5rem;
}

.question-card h3 {
    font-size: 1.15rem;
    margin-bottom: 1.2rem;
    color: #1a1a2e;
}

.options {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.option:hover {
    border-color: #b3c7f0;
    background: #f8faff;
}

.option.selected {
    border-color: #3366cc;
    background: #edf2ff;
}

.option input[type="radio"] {
    display: none;
}

.option-letter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #e8eeff;
    color: #3366cc;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.option.selected .option-letter {
    background: #3366cc;
    color: #fff;
}

.option-text {
    font-size: 0.95rem;
}

/* ---- Nav buttons ---- */
.nav-buttons {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
}

.nav-buttons .btn:first-child {
    margin-right: auto;
}

/* ---- Results ---- */
#results h2 {
    text-align: center;
    margin-bottom: 1rem;
}

.score {
    text-align: center;
    margin-bottom: 1.5rem;
}

.score-text {
    font-size: 1.4rem;
    color: #1a1a2e;
}

.result-card {
    background: #fff;
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    border-left: 5px solid #22a06b;
}

.result-card.incorrect {
    border-left-color: #e3493b;
}

.result-card h4 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
    color: #1a1a2e;
}

.result-options {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.result-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.75rem;
    border-radius: 6px;
    border: 1px solid transparent;
}

.result-option.correct-answer {
    background: #e6f9ed;
    border-color: #b7e4c7;
}

.result-option.wrong-answer {
    background: #ffeaea;
    border-color: #f5b5b5;
}

.result-option .option-letter {
    width: 26px;
    height: 26px;
    font-size: 0.8rem;
}

.badge {
    display: inline-block;
    margin-left: auto;
    padding: 0.15rem 0.6rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-correct {
    background: #22a06b;
    color: #fff;
}

.badge-wrong {
    background: #e3493b;
    color: #fff;
}

/* ---- Toggle correct answers ---- */
.hide-answers .result-option.correct-answer {
    background: transparent;
    border-color: transparent;
}
.hide-answers .badge-correct {
    display: none;
}

/* ---- Results actions ---- */
.results-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

/* ---- Responsive ---- */
@media (max-width: 500px) {
    body {
        padding: 1rem 0.5rem;
    }

    #welcome h1 {
        font-size: 1.5rem;
    }

    .nav-buttons {
        flex-wrap: wrap;
    }

    .nav-buttons .btn {
        flex: 1;
        text-align: center;
    }

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