/* ======================================
   RESET
====================================== */

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


:root {

    --background: #f5f7fb;
    --surface: #ffffff;

    --text: #172033;
    --text-light: #778097;

    --primary: #315be8;
    --primary-dark: #2344b8;
    --primary-light: #edf1ff;

    --success: #179b68;
    --success-light: #e9f8f1;

    --error: #d84b4b;
    --error-light: #fceeee;

    --border: #e5e9f2;

    --shadow:
        0 18px 60px rgba(33, 48, 84, 0.08);

    --radius: 18px;
}


body {

    min-height: 100vh;

    background:
        radial-gradient(
            circle at top right,
            #edf1ff 0,
            transparent 35%
        ),
        var(--background);

    color: var(--text);

    font-family:
        Inter,
        Arial,
        Helvetica,
        sans-serif;
}


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

button {
    font: inherit;
}

[hidden] {
    display: none !important;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
    outline: 3px solid rgba(49, 91, 232, 0.3);
    outline-offset: 2px;
}

.site-header {
    position: relative;
    z-index: 10;
    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid var(--border);
}

.site-header-inner {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 20px;
    width: min(1180px, calc(100% - 40px));
    min-height: 72px;
    margin: auto;
}

.site-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    width: max-content;
    color: var(--text);
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 1.1px;
    text-decoration: none;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    color: white;
    background: var(--primary);
    border-radius: 9px;
    font-size: 16px;
    letter-spacing: 0;
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 5px;
}

.site-nav-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 38px;
    padding: 8px 13px;
    color: var(--text-light);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
}

.site-nav-item.active {
    color: var(--primary);
    background: var(--primary-light);
}

.site-nav-item:disabled {
    cursor: default;
}

.nav-soon {
    color: #8a93a7;
    font-size: 10px;
    font-weight: 600;
}

.account-area {
    position: relative;
    justify-self: end;
}

.account-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    min-height: 38px;
    padding: 8px 13px;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 11px;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
}

.account-trigger:hover,
.account-trigger.connected {
    border-color: #cbd5ff;
    background: #f8faff;
}

.account-icon {
    width: 19px;
    height: 19px;
    flex: none;
    color: var(--primary);
}

.account-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 270px;
    padding: 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow);
}

.account-menu > strong,
.account-email {
    display: block;
    overflow-wrap: anywhere;
}

.account-email {
    margin-top: 3px;
    color: var(--text-light);
    font-size: 12px;
}

.account-menu p {
    margin: 17px 0;
    padding-top: 15px;
    border-top: 1px solid var(--border);
    color: var(--text-light);
    font-size: 12px;
}

.account-menu p strong {
    color: var(--text);
}

.account-logout {
    width: 100%;
    padding: 10px;
    color: var(--text);
    background: #f8f9fc;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.account-logout:hover {
    background: var(--primary-light);
}

.modal-open {
    overflow: hidden;
}

.modal-overlay {
    position: fixed;
    z-index: 30;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(23, 32, 51, 0.38);
}

.login-dialog {
    position: relative;
    width: min(100%, 440px);
    max-height: calc(100vh - 36px);
    overflow: auto;
    padding: 32px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.login-dialog h2 {
    margin-bottom: 8px;
    font-size: 27px;
    letter-spacing: -0.7px;
}

.login-dialog > p {
    margin-bottom: 25px;
    color: var(--text-light);
    font-size: 14px;
    line-height: 1.55;
}

.modal-close {
    position: absolute;
    top: 17px;
    right: 18px;
    width: 32px;
    height: 32px;
    color: var(--text-light);
    background: transparent;
    border: 0;
    border-radius: 8px;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
}

.modal-close:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.login-dialog form {
    display: grid;
    gap: 9px;
}

.login-dialog label {
    margin-top: 8px;
    font-size: 13px;
    font-weight: 700;
}

.login-dialog input {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    background: #fafbfe;
    border: 1px solid var(--border);
    border-radius: 10px;
    font: inherit;
    font-size: 14px;
}

.login-dialog input:focus {
    border-color: var(--primary);
}

.login-dialog .primary-button {
    margin-top: 14px;
}

.login-dialog .primary-button:disabled {
    opacity: 0.7;
    cursor: wait;
}

.login-error {
    padding: 10px 12px;
    color: var(--error);
    background: var(--error-light);
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.45;
}

.site-toast {
    position: fixed;
    z-index: 40;
    right: 20px;
    bottom: 20px;
    max-width: min(380px, calc(100% - 40px));
    padding: 13px 17px;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--primary);
    border-radius: 11px;
    box-shadow: var(--shadow);
    font-size: 13px;
    line-height: 1.45;
}

@media (max-width: 650px) {
    .site-header-inner {
        grid-template-columns: 1fr auto;
        grid-template-areas: "brand account" "nav nav";
        gap: 4px 10px;
        width: calc(100% - 24px);
        padding: 9px 0;
    }

    .site-brand { grid-area: brand; }
    .site-nav { grid-area: nav; }
    .account-area { grid-area: account; }

    .account-trigger {
        width: 38px;
        padding: 8px;
    }

    .account-trigger-text {
        display: none;
    }

    .site-nav-item {
        min-height: 34px;
        padding: 6px 10px;
    }

    .login-dialog {
        padding: 28px 22px;
    }
}


.app {
    width: min(1180px, calc(100% - 40px));
    margin: auto;

    padding:
        55px 0
        70px;
}


.screen {
    display: none;
}


.screen.active {
    display: block;
}


.eyebrow {

    display: inline-block;

    margin-bottom: 12px;

    color: var(--primary);

    font-size: 12px;
    font-weight: 800;

    letter-spacing: 1.5px;
}


/* ======================================
   HEADER
====================================== */

.main-header {

    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 40px;

    margin-bottom: 65px;
}


.main-header h1 {

    margin-bottom: 14px;

    font-size: clamp(38px, 6vw, 72px);
    line-height: 0.98;

    letter-spacing: -3px;
}


.main-header p {

    max-width: 650px;

    color: var(--text-light);

    font-size: 17px;
    line-height: 1.7;
}


.header-score {

    flex-shrink: 0;

    min-width: 150px;

    padding: 18px 22px;

    background: var(--surface);

    border: 1px solid var(--border);
    border-radius: 16px;

    box-shadow: var(--shadow);
}


.header-score span {

    display: block;

    margin-bottom: 4px;

    color: var(--text-light);

    font-size: 12px;
}


.header-score strong {

    font-size: 24px;
}


/* ======================================
   SECTION TITLE
====================================== */

.section-heading {

    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 20px;

    margin-bottom: 25px;
}


.section-heading > div {

    display: flex;
    align-items: center;
    gap: 12px;
}


.section-number {

    color: var(--primary);

    font-weight: 800;
}


.section-heading h2 {

    font-size: 24px;
}


.section-heading p {

    color: var(--text-light);

    font-size: 14px;
}


/* ======================================
   PERIOD CARDS
====================================== */

.periods-grid {

    display: grid;

    grid-template-columns:
        repeat(4, minmax(0, 1fr));

    gap: 18px;
}


.period-card {

    position: relative;

    min-height: 250px;

    padding: 24px;
    padding-bottom: 78px;

    overflow: hidden;

    background: var(--surface);

    border: 1px solid var(--border);
    border-radius: var(--radius);

    box-shadow:
        0 8px 30px rgba(33, 48, 84, 0.04);

    transition:
        transform 0.2s ease,
        box-shadow 0.2s ease,
        border 0.2s ease;
}


.period-card.available {

    cursor: pointer;
}


.period-card.available:hover {

    transform: translateY(-5px);

    border-color: #cbd5ff;

    box-shadow:
        0 20px 45px rgba(49, 91, 232, 0.13);
}


.period-card.locked {

    opacity: 0.62;
}


.period-number {

    display: flex;
    justify-content: space-between;
    align-items: center;

    margin-bottom: 45px;
}


.period-index {

    display: flex;
    align-items: center;
    justify-content: center;

    width: 40px;
    height: 40px;

    background: var(--primary-light);
    color: var(--primary);

    border-radius: 12px;

    font-size: 13px;
    font-weight: 800;
}


.period-status {

    color: var(--text-light);

    font-size: 11px;
    font-weight: 700;

    text-transform: uppercase;
    letter-spacing: 0.8px;
}


.available .period-status {

    color: var(--success);
}


.period-date {

    margin-bottom: 8px;

    font-size: 24px;
    font-weight: 800;

    letter-spacing: -1px;
}


.period-title {

    min-height: 42px;

    color: var(--text-light);

    font-size: 14px;
    line-height: 1.45;
}


.period-bottom {

    position: absolute;

    left: 24px;
    right: 24px;
    bottom: 16px;

    display: flex;
    flex-direction: column;
    gap: 10px;

    color: var(--text-light);

    font-size: 12px;
}


.period-bottom-row {

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}


.period-progress-track {

    width: 100%;
    height: 6px;

    overflow: hidden;

    background: #e5e9f3;

    border-radius: 50px;
}


.period-progress-bar {

    width: 0;
    height: 100%;

    background: var(--success);

    border-radius: 50px;

    transition: width 0.3s ease;
}


.general-quiz-row {

    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;

    margin-top: 22px;
}


#start-general-quiz,
#start-error-quiz {
    min-width: 220px;
}


.card-arrow {

    color: var(--primary);

    font-size: 20px;
}


/* ======================================
   QUIZ TOPBAR
====================================== */

.quiz-topbar {

    display: grid;

    grid-template-columns:
        1fr
        auto
        1fr;

    align-items: center;

    margin-bottom: 32px;
}


.icon-button {

    justify-self: start;

    padding: 10px 15px;

    color: var(--text);

    background: var(--surface);

    border: 1px solid var(--border);
    border-radius: 12px;

    cursor: pointer;
}


.quiz-period {

    text-align: center;
}


.quiz-period span,
.live-score span {

    display: block;

    margin-bottom: 2px;

    color: var(--text-light);

    font-size: 11px;

    text-transform: uppercase;
    letter-spacing: 1px;
}


.quiz-period strong {

    font-size: 18px;
}


.live-score {

    justify-self: end;

    text-align: right;
}


/* ======================================
   PROGRESS
====================================== */

.progress-wrapper {

    max-width: 850px;

    margin:
        0 auto
        22px;
}


.progress-info {

    display: flex;
    justify-content: space-between;

    margin-bottom: 9px;

    color: var(--text-light);

    font-size: 12px;
}


.progress-track {

    width: 100%;
    height: 7px;

    overflow: hidden;

    background: #e5e9f3;

    border-radius: 50px;
}


.progress-bar {

    width: 0%;
    height: 100%;

    background: var(--primary);

    border-radius: 50px;

    transition: width 0.3s ease;
}


/* ======================================
   QUESTION
====================================== */

.quiz-container {

    display: flex;
    justify-content: center;
}


.question-card {

    width: 100%;
    max-width: 850px;

    padding: 42px;

    background: var(--surface);

    border: 1px solid var(--border);
    border-radius: 24px;

    box-shadow: var(--shadow);
}


.question-meta {

    margin-bottom: 20px;
}


.category-badge {

    display: inline-block;

    padding:
        7px 11px;

    color: var(--primary);

    background: var(--primary-light);

    border-radius: 50px;

    font-size: 11px;
    font-weight: 800;

    text-transform: uppercase;
    letter-spacing: 0.6px;
}


.question-card h2 {

    margin-bottom: 28px;

    font-size: clamp(22px, 4vw, 31px);

    line-height: 1.3;
    letter-spacing: -0.8px;
}


/* ======================================
   ANSWERS
====================================== */

.answers-container {

    display: grid;
    gap: 12px;
}


.answer-button {

    display: grid;

    grid-template-columns:
        42px
        1fr;

    align-items: center;
    gap: 14px;

    width: 100%;

    padding: 13px 16px;

    color: var(--text);

    background: #fafbfe;

    border: 1px solid var(--border);
    border-radius: 14px;

    text-align: left;

    cursor: pointer;

    transition:
        border 0.18s ease,
        background 0.18s ease,
        transform 0.18s ease;
}


.answer-button:hover:not(:disabled) {

    transform: translateX(4px);

    border-color: #bcc8f8;

    background: #f6f8ff;
}


.answer-letter {

    display: flex;
    align-items: center;
    justify-content: center;

    width: 36px;
    height: 36px;

    background: white;

    border: 1px solid var(--border);
    border-radius: 10px;

    font-weight: 800;
}


.answer-text {

    line-height: 1.45;
}


.answer-button.correct {

    background: var(--success-light);

    border-color: #70cfa9;
}


.answer-button.correct .answer-letter {

    color: white;

    background: var(--success);

    border-color: var(--success);
}


.answer-button.wrong {

    background: var(--error-light);

    border-color: #eda4a4;
}


.answer-button.wrong .answer-letter {

    color: white;

    background: var(--error);

    border-color: var(--error);
}


.answer-button:disabled {

    cursor: default;
}


/* ======================================
   FEEDBACK
====================================== */

.feedback {

    display: none;

    grid-template-columns:
        38px
        1fr;

    gap: 13px;

    margin-top: 22px;

    padding: 18px;

    border-radius: 14px;
}


.feedback.visible {

    display: grid;
}


.feedback.success {

    background: var(--success-light);
}


.feedback.error,
.feedback.skipped {

    background: var(--error-light);
}


.feedback.skipped {

    background: #eef2f8;
}


.feedback-icon {

    display: flex;
    align-items: center;
    justify-content: center;

    width: 34px;
    height: 34px;

    border-radius: 50%;

    font-weight: 900;
}


.feedback.success .feedback-icon {

    color: white;

    background: var(--success);
}


.feedback.error .feedback-icon,
.feedback.skipped .feedback-icon {

    color: white;

    background: var(--error);
}


.feedback.skipped .feedback-icon {

    background: #6c7690;
}


.feedback strong {

    display: block;

    margin-bottom: 6px;
}


.feedback p {

    color: #566078;

    font-size: 14px;
    line-height: 1.6;
}


/* ======================================
   QUESTION FOOTER
====================================== */

.question-footer {

    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;

    margin-top: 28px;
}


.memory-tip {

    color: var(--text-light);

    font-size: 12px;
}


.primary-button,
.secondary-button {

    padding:
        13px
        20px;

    border-radius: 12px;

    font-weight: 700;

    cursor: pointer;
}


.primary-button {

    color: white;

    background: var(--primary);

    border: none;
}


.primary-button:hover {

    background: var(--primary-dark);
}


#next-question {

    display: none;
}


#next-question.visible {

    display: inline-block;
}


.secondary-button {

    color: var(--text);

    background: white;

    border: 1px solid var(--border);
}


/* ======================================
   RESULT
====================================== */

.result-card {

    max-width: 670px;

    margin: 30px auto;

    padding: 50px;

    text-align: center;

    background: var(--surface);

    border: 1px solid var(--border);
    border-radius: 26px;

    box-shadow: var(--shadow);
}


.result-card h1 {

    margin-bottom: 30px;

    font-size: 42px;
}


.score-circle {

    display: flex;
    align-items: center;
    justify-content: center;

    width: 190px;
    height: 190px;

    margin:
        0 auto
        16px;

    border: 12px solid var(--primary-light);
    border-radius: 50%;
}


.score-circle strong {

    font-size: 58px;

    letter-spacing: -3px;
}


.score-circle span {

    color: var(--text-light);

    font-size: 20px;
}


.final-percentage {

    margin-bottom: 24px;

    color: var(--primary);

    font-size: 20px;
    font-weight: 800;
}


.result-card h2 {

    margin-bottom: 10px;
}


.result-card > p {

    max-width: 520px;

    margin: auto;

    color: var(--text-light);

    line-height: 1.65;
}


.result-stats {

    display: grid;

    grid-template-columns:
        repeat(3, 1fr);

    gap: 12px;

    margin-top: 35px;
}


.stat-card {

    padding: 18px;

    background: #f8f9fc;

    border-radius: 14px;
}


.stat-card span {

    display: block;

    margin-bottom: 6px;

    color: var(--text-light);

    font-size: 11px;
}


.stat-card strong {

    font-size: 24px;
}


.result-actions {

    display: flex;
    justify-content: center;
    gap: 12px;

    margin-top: 30px;
}


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

@media (max-width: 900px) {

    .periods-grid {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }

}


@media (max-width: 650px) {

    .app {

        width: calc(100% - 24px);

        padding-top: 30px;
    }


    .main-header {

        align-items: flex-start;
        flex-direction: column;

        margin-bottom: 40px;
    }


    .main-header h1 {

        letter-spacing: -2px;
    }


    .header-score {

        width: 100%;
    }


    .section-heading {

        align-items: flex-start;
        flex-direction: column;
    }


    .periods-grid {

        grid-template-columns: 1fr;
    }


    .quiz-topbar {

        grid-template-columns:
            1fr
            1fr;
    }


    .quiz-period {

        display: none;
    }


    .question-card {

        padding:
            28px
            20px;
    }


    .question-footer {

        align-items: stretch;
        flex-direction: column;
    }


    .primary-button {

        width: 100%;
    }


    .result-card {

        padding:
            38px
            20px;
    }


    .result-stats {

        grid-template-columns: 1fr;
    }


    .result-actions {

        flex-direction: column;
    }

}

/* ======================================
   QUESTION TYPE
====================================== */

.question-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}


.type-badge {
    display: inline-block;

    padding: 7px 11px;

    color: #6c7690;

    background: #f1f3f8;

    border-radius: 50px;

    font-size: 11px;
    font-weight: 800;

    text-transform: uppercase;
    letter-spacing: 0.6px;
}


.type-badge.multiple {
    color: #7657c8;
    background: #f1edff;
}


.question-instruction {
    display: none;

    margin-top: -16px;
    margin-bottom: 22px;

    color: var(--text-light);

    font-size: 13px;
    line-height: 1.5;
}


.question-instruction.visible {
    display: block;
}


/* ======================================
   MULTI SELECT
====================================== */

.answer-button.selected {
    border-color: var(--primary);
    background: var(--primary-light);
}


.answer-button.selected .answer-letter {
    color: white;
    background: var(--primary);
    border-color: var(--primary);
}


.answer-button.correct.selected .answer-letter,
.answer-button.correct .answer-letter {
    color: white;
    background: var(--success);
    border-color: var(--success);
}


.answer-button.wrong.selected .answer-letter,
.answer-button.wrong .answer-letter {
    color: white;
    background: var(--error);
    border-color: var(--error);
}


/* ======================================
   QUESTION ACTIONS
====================================== */

.question-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}


#validate-answer,
#skip-question {
    display: none;
}


#validate-answer.visible,
#skip-question.visible {
    display: inline-block;
}


#validate-answer:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}


#next-question {
    display: none;
}


#next-question.visible {
    display: inline-block;
}


@media (max-width: 650px) {

    .question-actions {
        width: 100%;
        flex-direction: column;
    }

    .question-actions button {
        width: 100%;
    }

}


.attempt-label {

    margin-bottom: 22px;

    color: var(--text-light);

    font-size: 13px;
    font-weight: 700;
}


@media (max-width: 650px) {

    #start-general-quiz,
    #start-error-quiz {
        width: 100%;
    }

}
