#mtp-exam-app {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
    max-width: 1100px;
    margin: 0 auto;
    border: 1px solid #d0d0d0;
    border-radius: 6px;
    overflow: hidden;
    background: #fff;
}

/* Full-screen distraction-free mode: the exam app is moved to be a direct
   child of <body> by JS, and every other element on the page is hidden. */
body.mtp-fullscreen-active {
    overflow: hidden;
}

body.mtp-fullscreen-active > *:not(#mtp-exam-app) {
    display: none !important;
}

#mtp-exam-app.mtp-fullscreen-active {
    position: fixed;
    inset: 0;
    z-index: 999999;
    max-width: none;
    width: 100%;
    height: 100%;
    margin: 0;
    border: none;
    border-radius: 0;
    overflow-y: auto;
}

.mtp-exit-btn {
    background: rgba(255,255,255,0.15);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.4);
    width: 28px;
    height: 28px;
    line-height: 26px;
    text-align: center;
    border-radius: 50%;
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
    padding: 0;
}

.mtp-exit-btn:hover {
    background: #dc2626;
    border-color: #dc2626;
}

.mtp-exam-loading, .mtp-exam-error {
    padding: 40px;
    text-align: center;
    font-size: 12px;
}

.mtp-exam-error p {
    margin-bottom: 16px;
    color: #555;
}

.mtp-exam-error .mtp-exam-btn {
    display: inline-block;
    width: auto;
    padding: 10px 24px;
}

/* Instructions screen */
.mtp-instructions {
    padding: 24px;
}

.mtp-instructions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid #1e3a5f;
}

.mtp-instructions-header h2 {
    font-size: 12px;
    margin: 0;
    color: #1e3a5f;
}

.mtp-instructions-header .mtp-lang-toggle button {
    background: #f1f3f5;
    color: #333;
    border: 1px solid #ddd;
}

.mtp-instructions-header .mtp-lang-toggle button.mtp-lang-active {
    background: #1e3a5f;
    color: #fff;
}

.mtp-instructions-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}

.mtp-instructions-meta > div {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 10px 16px;
    min-width: 120px;
    text-align: center;
}

.mtp-instructions-meta span {
    display: block;
    font-size: 12px;
    text-transform: uppercase;
    color: #666;
    margin-bottom: 3px;
}

.mtp-instructions-meta strong {
    font-size: 12px;
    color: #1e3a5f;
}

.mtp-instructions h3 {
    font-size: 12px;
    margin: 16px 0 8px;
}

.mtp-instructions-list {
    padding-left: 20px;
    line-height: 1.7;
}

.mtp-instructions-list li {
    margin-bottom: 8px;
}

.mtp-instructions-name {
    display: block;
    margin: 16px 0;
}

.mtp-instructions-name span {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: #1e3a5f;
    margin-bottom: 6px;
}

.mtp-instructions-name input {
    width: 100%;
    max-width: 320px;
    padding: 9px 12px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 12px;
    box-sizing: border-box;
}

.mtp-instructions-agree {
    display: block;
    margin: 20px 0;
    padding: 12px;
    background: #fffbeb;
    border-radius: 6px;
    cursor: pointer;
}

.mtp-instructions-agree input {
    margin-right: 8px;
}

.mtp-instructions-actions {
    text-align: right;
}

.mtp-instructions-actions .mtp-exam-btn {
    font-size: 12px;
    padding: 12px 28px;
}

/* Header */
.mtp-exam-header {
    background: #1e3a5f;
    color: #fff;
    padding: 12px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.mtp-exam-title {
    font-size: 12px;
    font-weight: 700;
}

.mtp-exam-candidate {
    font-size: 12px;
    opacity: 0.85;
}

.mtp-section-label {
    font-size: 12px;
    margin-top: 4px;
    padding: 2px 8px;
    background: rgba(255,255,255,0.15);
    border-radius: 4px;
    display: inline-block;
}

.mtp-exam-header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.mtp-lang-toggle button {
    background: rgba(255,255,255,0.15);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.4);
    padding: 5px 10px;
    cursor: pointer;
    font-size: 12px;
    border-radius: 4px;
    margin-left: 4px;
}

.mtp-lang-toggle button.mtp-lang-active {
    background: #fff;
    color: #1e3a5f;
    font-weight: 700;
}

.mtp-timer {
    background: #0f2440;
    padding: 6px 14px;
    border-radius: 6px;
    text-align: center;
}

.mtp-timer-label {
    display: block;
    font-size: 12px;
    opacity: 0.8;
    text-transform: uppercase;
}

.mtp-timer-value {
    font-size: 12px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.mtp-timer-value.mtp-timer-warning {
    color: #ff6b6b;
}

/* Body layout */
.mtp-exam-body {
    display: flex;
    flex-wrap: wrap;
}

.mtp-exam-main {
    flex: 1 1 640px;
    padding: 20px;
    border-right: 1px solid #e5e5e5;
}

.mtp-exam-sidebar {
    flex: 0 0 260px;
    padding: 16px;
    background: #fafafa;
    max-height: 560px;
    display: flex;
    flex-direction: column;
}

/* Question box */
.mtp-q-number {
    font-weight: 700;
    color: #1e3a5f;
    margin-bottom: 10px;
    font-size: 13px;
}

.mtp-q-id {
    font-weight: 400;
    color: #888;
    font-size: 12px;
}

.mtp-q-text {
    font-size: 16px;
    line-height: 1.6;
    margin-bottom: 16px;
}

.mtp-q-option {
    display: block;
    padding: 10px 12px;
    margin-bottom: 8px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
    font-size: 14px;
}

.mtp-q-option:hover {
    background: #f5f8fc;
}

.mtp-q-option input {
    margin-right: 8px;
}

.mtp-q-option-letter {
    font-weight: 700;
}

/* Action buttons */
.mtp-exam-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 20px;
    border-top: 1px solid #eee;
    padding-top: 16px;
}

.mtp-exam-btn {
    padding: 9px 16px;
    border: none;
    border-radius: 5px;
    font-weight: 600;
    cursor: pointer;
    font-size: 12px;
}

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

.mtp-btn-mark { background: #a855f7; color: #fff; }
.mtp-btn-clear { background: #f1f3f5; color: #333; }
.mtp-btn-prev { background: #e5e7eb; color: #333; }
.mtp-btn-save { background: #16a34a; color: #fff; }
.mtp-btn-submit { background: #dc2626; color: #fff; margin-left: auto; }

/* Palette */
.mtp-palette-legend {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
    font-size: 12px;
}

.mtp-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.mtp-legend-dot {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    display: inline-block;
}

.mtp-palette-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    grid-auto-rows: min-content;
    align-content: start;
    align-items: start;
    justify-items: stretch;
    gap: 6px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 5px 4px 4px 5px;
    flex: 1 1 auto;
}

.mtp-palette-cell {
    width: 100%;
    aspect-ratio: 1 / 1;
    min-width: 0;
    border: none;
    border-radius: 4px;
    font-weight: 700;
    cursor: pointer;
    color: #fff;
    font-size: 12px;
    padding: 0;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mtp-palette-cell.mtp-palette-current {
    outline: 2px solid #1e3a5f;
    outline-offset: 1px;
}

/* Status colors (shared by legend dots + palette cells) */
.mtp-status-not_visited { background: #9ca3af; }
.mtp-status-not_answered { background: #ef4444; }
.mtp-status-answered { background: #16a34a; }
.mtp-status-marked { background: #a855f7; }
.mtp-status-answered_marked { background: #7c3aed; }

/* Result screen */
.mtp-result-wrap {
    padding: 20px;
}

.mtp-result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
}

.mtp-result-header .mtp-lang-toggle button {
    background: #f1f3f5;
    color: #333;
    border: 1px solid #ddd;
}

.mtp-result-header .mtp-lang-toggle button.mtp-lang-active {
    background: #1e3a5f;
    color: #fff;
}

.mtp-result-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-bottom: 24px;
}

.mtp-result-stat {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px 18px;
    min-width: 110px;
    text-align: center;
}

.mtp-result-stat span {
    display: block;
    font-size: 12px;
    text-transform: uppercase;
    color: #666;
    margin-bottom: 4px;
}

.mtp-result-stat strong {
    font-size: 12px;
}

.mtp-result-score strong {
    color: #1e3a5f;
}

.mtp-stat-correct { color: #16a34a; }
.mtp-stat-wrong { color: #dc2626; }

.mtp-review-item {
    border: 1px solid #e5e7eb;
    border-left: 5px solid #9ca3af;
    border-radius: 6px;
    padding: 14px 16px;
    margin-bottom: 12px;
}

.mtp-review-correct { border-left-color: #16a34a; }
.mtp-review-wrong { border-left-color: #dc2626; }
.mtp-review-skipped { border-left-color: #9ca3af; }

.mtp-review-q {
    margin-bottom: 8px;
}

.mtp-opt-correct {
    color: #16a34a;
    font-weight: 700;
}

.mtp-opt-wrong {
    color: #dc2626;
    font-weight: 700;
    text-decoration: line-through;
}

.mtp-review-meta {
    margin-top: 8px;
    font-size: 12px;
    color: #444;
}

.mtp-review-explanation {
    margin-top: 8px;
    padding: 8px 10px;
    background: #fffbeb;
    border-radius: 5px;
    font-size: 12px;
}

@media (max-width: 780px) {
    #mtp-exam-app {
        font-size: 12px;
    }
    .mtp-exam-header {
        padding: 8px 10px;
    }
    .mtp-exam-header-right {
        gap: 8px;
    }
    .mtp-exam-body {
        flex-direction: column;
    }
    .mtp-exam-main {
        border-right: none;
        border-bottom: 1px solid #e5e5e5;
        padding: 12px;
    }
    .mtp-exam-sidebar {
        order: -1;
        padding: 10px;
        max-height: 220px;
    }
    .mtp-palette-legend {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 10px;
        font-size: 12px;
    }
    .mtp-palette-grid {
        grid-template-columns: repeat(8, 1fr);
        gap: 6px;
    }
    .mtp-exam-actions {
        gap: 6px;
    }
    .mtp-exam-btn {
        flex: 1 1 45%;
        padding: 10px 8px;
        font-size: 12px;
    }
    .mtp-btn-submit {
        margin-left: 0;
        flex-basis: 100%;
        order: 10;
    }
    .mtp-q-text {
        font-size: 15px;
    }
    .mtp-q-option {
        font-size: 13px;
    }
    .mtp-instructions {
        padding: 14px;
    }
    .mtp-instructions-meta {
        gap: 8px;
    }
    .mtp-instructions-meta > div {
        min-width: 90px;
        padding: 8px 10px;
    }
    .mtp-result-summary {
        gap: 8px;
    }
    .mtp-result-stat {
        min-width: 80px;
        padding: 8px 10px;
    }
}

@media (max-width: 420px) {
    .mtp-palette-grid {
        grid-template-columns: repeat(6, 1fr);
    }
    .mtp-exam-title {
        font-size: 12px;
    }
    .mtp-exam-candidate {
        font-size: 12px;
    }
}
