:root {
    --primary-blue: #2c3e50;
    --accent-blue: #3498db;
    --success-green: #2ecc71;
    --warning-red: #e74c3c;
    --bg-light: #f4f7f6;
    --text-main: #2c3e50;
    --card-shadow: 0 0.4rem 1.2rem rgba(0, 0, 0, 0.08);
}

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

html {
    font-size: clamp(12px, 0.85vw, 15px);
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-light);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

/* =========================
   Main Start Screen
========================= */

.main-screen {
    min-height: 100vh;
    background: var(--bg-light);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

.main-card {
    width: min(90vw, 620px);
    background: white;
    border-radius: 1.3rem;
    padding: clamp(2rem, 4vw, 3rem);
    text-align: center;
    box-shadow: var(--card-shadow);
}

.main-card h1 {
    font-size: clamp(2rem, 3vw, 3rem);
    color: var(--primary-blue);
    margin-bottom: 1rem;
}

.main-card p {
    font-size: 1rem;
    line-height: 1.6;
    color: #555;
    margin-bottom: 2rem;
}

/* =========================
   Exam Selection Menu
========================= */

.menu-group {
    margin: 1.5rem 0;
    text-align: left;
}

.menu-group h3 {
    margin-bottom: 0.8rem;
    color: var(--primary-blue);
    font-size: 1rem;
}

.menu-options {
    display: grid;
    gap: 0.8rem;
}

.exam-options {
    grid-template-columns: repeat(4, 1fr);
}

.difficulty-options {
    grid-template-columns: repeat(3, 1fr);
}

.menu-choice {
    padding: 0.9rem 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 0.7rem;
    background: white;
    color: var(--primary-blue);
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s ease;
}

.menu-choice:hover {
    border-color: var(--accent-blue);
    background: #f0f7ff;
}

.menu-choice.selected {
    background: var(--accent-blue);
    color: white;
    border-color: var(--accent-blue);
}

/* =========================
   App Layout
========================= */

.app-layout {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.exam-header {
    background: var(--primary-blue);
    color: white;
    min-height: 72px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 1rem 2rem;
    gap: 1rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    justify-self: start;
}

.brand {
    font-size: 1.7rem;
    font-weight: 800;
    letter-spacing: 0.03em;
}

.mode {
    font-size: 0.85rem;
    color: var(--accent-blue);
    font-weight: 700;
}

.header-actions {
    display: flex;
    gap: 0.8rem;
    justify-self: center;
}

.exam-stats {
    display: flex;
    justify-self: end;
    gap: 3rem;
}

.label {
    display: block;
    font-size: 0.65rem;
    color: #bdc3c7;
    margin-bottom: 0.2rem;
}

#timer,
#rank-badge {
    font-size: 1.1rem;
    font-weight: 800;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* =========================
   Question Map
========================= */

.nav-sidebar {
    background: white;
    border-bottom: 1px solid #ddd;
    padding: 1.5rem 2rem;
}

.nav-sidebar h3 {
    font-size: 1.15rem;
    margin-bottom: 1.2rem;
    color: var(--primary-blue);
}

.grid-container {
    display: grid;
    grid-template-columns: repeat(15, minmax(45px, 1fr));
    gap: 0.7rem;
    margin-bottom: 1.4rem;
}

.q-box {
    height: 52px;
    border: 1px solid #ddd;
    border-radius: 0.55rem;
    background: white;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.q-box:hover {
    border-color: var(--accent-blue);
}

.q-box.active {
    background: var(--accent-blue);
    color: white;
    border-color: var(--accent-blue);
}

.q-box.flagged {
    border: 2px solid var(--warning-red);
    color: var(--warning-red);
}

.legend {
    border-top: 1px solid #eee;
    padding-top: 1.2rem;
    display: flex;
    flex-direction: row;
    gap: 1.8rem;
}

.legend span {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.95rem;
    color: var(--text-main);
}

.dot {
    width: 0.6rem;
    height: 0.6rem;
    border-radius: 50%;
    display: inline-block;
}

.dot.current {
    background: var(--accent-blue);
}

.dot.flagged {
    background: var(--warning-red);
}

/* =========================
   Quiz Section
========================= */

.quiz-section {
    flex: 1;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-y: auto;
}

.progress-container,
.card,
.controls {
    width: min(100%, 820px);
}

.progress-container {
    height: 7px;
    background: #ddd;
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 1.6rem;
}

.progress-fill {
    height: 100%;
    width: 10%;
    background: var(--success-green);
    transition: width 0.3s ease;
}

/* Card */
.card {
    background: white;
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: var(--card-shadow);
    margin-bottom: 1.6rem;
}

.q-meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.9rem;
    margin-bottom: 2rem;
}

.badge {
    background: #ebf5fb;
    color: var(--accent-blue);
    padding: 0.45rem 0.8rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 800;
}

#q-number {
    display: block;
    width: 100%;
    text-align: center;
    font-size: 0.95rem;
    font-weight: 700;
    color: #555;
    margin: 0 auto 1.5rem auto;
}

.icon-btn {
    border: none;
    background: transparent;
    color: var(--warning-red);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
}

#question-text {
    font-size: clamp(1.25rem, 1.5vw, 1.65rem);
    line-height: 1.45;
    margin-bottom: 1.2rem;
    color: var(--primary-blue);
}

.options-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

.option-btn {
    width: 100%;
    text-align: left;
    padding: 1rem;
    border: 2px solid #eee;
    border-radius: 0.65rem;
    background: white;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1.4;
    transition: all 0.2s ease;
}

.option-btn:hover {
    border-color: var(--accent-blue);
    background: #f0f7ff;
}

.option-btn.selected {
    background: var(--accent-blue);
    color: white;
    border-color: var(--accent-blue);
}

/* =========================
   Buttons
========================= */

.controls {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
}

.btn {
    padding: 0.75rem 1.6rem;
    border-radius: 0.55rem;
    border: none;
    font-size: 0.95rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn.primary {
    background: var(--accent-blue);
    color: white;
}

.btn.primary:hover {
    background: #2980b9;
}

.btn.secondary {
    background: #bdc3c7;
    color: white;
}

.btn.secondary:hover {
    background: #aab2b7;
}

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

/* =========================
   Modals
========================= */

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    z-index: 99;
}

.modal-content {
    width: min(90vw, 440px);
    background: white;
    border-radius: 1rem;
    padding: 2.2rem;
    text-align: center;
    box-shadow: var(--card-shadow);
}

.modal-content h1 {
    color: var(--primary-blue);
    font-size: 1.8rem;
    margin-bottom: 1rem;
}

.score-circle {
    width: 125px;
    height: 125px;
    border-radius: 50%;
    border: 0.65rem solid var(--accent-blue);
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 1.4rem auto;
    color: var(--primary-blue);
}

#final-score {
    font-size: 2.4rem;
    font-weight: 900;
}

.score-circle small {
    font-size: 0.85rem;
    font-weight: 700;
}

#final-rank-title {
    color: var(--primary-blue);
    font-size: 1.3rem;
    margin-bottom: 0.8rem;
}

#result-text,
#pause-text {
    font-size: 1rem;
    line-height: 1.5;
    margin-bottom: 1.3rem;
    color: #555;
}

.modal-actions {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 1.2rem;
}

.modal-actions .btn {
    min-width: 110px;
}

/* =========================
   Review / Explanation Screen
========================= */

.review-screen {
    min-height: 100vh;
    background: var(--bg-light);
    padding: 2rem;
}

.review-card {
    width: min(95vw, 950px);
    margin: 0 auto;
    background: white;
    border-radius: 1.2rem;
    padding: 2rem;
    box-shadow: var(--card-shadow);
}

.review-card h1 {
    color: var(--primary-blue);
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.review-subtitle {
    color: #666;
    margin-bottom: 1.8rem;
    font-size: 1rem;
}

.review-list {
    display: grid;
    gap: 1.3rem;
}

.review-item {
    border: 2px solid #eee;
    border-left: 6px solid var(--warning-red);
    border-radius: 0.9rem;
    padding: 1.4rem;
    background: #fff;
}

.review-item h3 {
    color: var(--warning-red);
    margin-bottom: 0.8rem;
}

.review-question {
    font-weight: 700;
    color: var(--primary-blue);
    margin-bottom: 1rem;
    line-height: 1.5;
}

.review-item p {
    margin-bottom: 0.5rem;
    line-height: 1.5;
}

.review-explanation {
    background: #f4f7f6;
    border-radius: 0.75rem;
    padding: 1rem;
    margin-top: 1rem;
    line-height: 1.5;
}

.correct-all {
    border-left-color: var(--success-green);
}

.correct-all h3 {
    color: var(--success-green);
}

.review-actions {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 2rem;
}

/* =========================
   Hidden
========================= */

.hidden {
    display: none !important;
}

/* =========================
   Responsive
========================= */

@media (max-width: 900px) {
    .exam-header {
        height: auto;
        grid-template-columns: 1fr;
        justify-items: start;
        gap: 1rem;
        padding: 1.2rem;
    }

    .header-actions {
        justify-self: start;
    }

    .exam-stats {
        justify-self: start;
        gap: 2rem;
    }

    .grid-container {
        grid-template-columns: repeat(5, 1fr);
    }

    .q-box {
        height: 52px;
    }

    .quiz-section {
        padding: 1.4rem;
    }

    .progress-container,
    .card,
    .controls {
        width: min(100%, 720px);
    }

    .exam-options {
        grid-template-columns: repeat(2, 1fr);
    }

    .difficulty-options {
        grid-template-columns: repeat(1, 1fr);
    }
}

@media (max-width: 600px) {
    html {
        font-size: 12px;
    }

    .exam-stats {
        width: 100%;
        justify-content: space-between;
        gap: 1rem;
    }

    .nav-sidebar {
        padding: 1.2rem;
    }

    .grid-container {
        grid-template-columns: repeat(5, 1fr);
        gap: 0.6rem;
    }

    .q-box {
        height: 44px;
    }

    .legend {
        flex-direction: row;
        gap: 1.2rem;
    }

    .card {
        padding: 1.4rem;
    }

    .q-meta {
        flex-direction: column;
        align-items: flex-start;
    }

    #question-text {
        font-size: 1.35rem;
    }

    .controls,
    .review-actions,
    .modal-actions {
        flex-direction: column;
    }

    .controls .btn,
    .review-actions .btn,
    .modal-actions .btn {
        width: 100%;
    }

    .exam-options,
    .difficulty-options {
        grid-template-columns: 1fr;
    }
}
