:root {
    --gold-dark: #564310;
    --gold-deep: #372805;
    --gold-bronze: #2b2006;
    --gold: #C9A646;
    --gold-soft: #E8D29B;
    --gold-surface: #F7EBC8;

    --text-dark: #2C2418;
    --text-muted: #6B6255;

    --white: #FFFFFF;
    --ivory: #FFFDF8;
    --cream: #F8F4EA;
    --sand: #EEE6D6;
    --border: #DACFB8;

    --success: #15803D;
    --success-bg: #DCFCE7;
    --error: #B91C1C;
    --error-bg: #FEE2E2;

    --shadow-sm: 0 6px 18px rgba(111, 83, 16, 0.08);
    --shadow-md: 0 14px 34px rgba(111, 83, 16, 0.12);
    --shadow-lg: 0 18px 48px rgba(111, 83, 16, 0.16);

    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 22px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: "Inter", "Segoe UI", Arial, sans-serif;
    background:
        radial-gradient(circle at top left, rgba(139, 107, 22, 0.10), transparent 28%),
        linear-gradient(180deg, #fffdf8 0%, #f8f4ea 100%);
    color: var(--text-dark);
    line-height: 1.6;
}

img {
    max-width: 100%;
    display: block;
}

a {
    color: inherit;
    text-decoration: none;
}

.container {
    width: min(92%, 1280px);
    margin: 24px auto;
}

.topbar {
    background: linear-gradient(135deg, #ffffff 0%, #ffffff 30%, #564310 100%);
    color: #fffef8;
    padding: 16px 0;
    box-shadow: 0 12px 28px rgba(111, 83, 16, 0.18);
    border-bottom: 1px solid rgba(255, 244, 209, 0.25);
}

.topbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.brand-wrap {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 220px;
}

.brand-logo {
    width: 210px;
    max-width: 100%;
    height: auto;
    object-fit: contain;
}

.topbar-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.topbar-nav a {
    
    color: rgba(255, 252, 245, 0.96);
    background: linear-gradient(135deg, #000000 5%, #372805 10%, #A17E23 100%);
    padding: 10px 14px;
    border-radius: 999px;
    transition: 0.18s ease;
    font-weight: 700;
    font-size: 14px;
}

.topbar-nav a:hover {
    background: rgba(255, 248, 223, 0.18);
    color: #ffffff;
}

.card {
    background: linear-gradient(180deg, rgba(255,255,255,0.98) 0%, rgba(255,253,248,0.98) 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-md);
    margin-bottom: 20px;
}

.card-soft {
    background: linear-gradient(180deg, #fffdf8 0%, #fbf6ea 100%);
}

.hero-panel {
    background: linear-gradient(135deg, #000000 0%, #372805 60%, #A17E23 100%);
    color: #fffef8;
    border: 1px solid rgba(255, 245, 219, 0.25);
}

.hero-panel h1,
.hero-panel h2,
.hero-panel h3,
.hero-panel p {
    color: #fffef8;
}

h1, h2, h3 {
    margin-top: 0;
    color: var(--text-dark);
    letter-spacing: -0.02em;
}

h1 {
    font-size: 32px;
    margin-bottom: 12px;
}

h2 {
    font-size: 24px;
    margin-bottom: 12px;
}

h3 {
    font-size: 20px;
    margin-bottom: 10px;
}

.page-subtitle {
    color: var(--text-muted);
}

.form-group {
    margin-bottom: 18px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 700;
    color: var(--text-dark);
}

input[type="text"],
input[type="number"],
input[type="password"],
input[type="email"],
select,
textarea {
    width: 100%;
    padding: 13px 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fffefb;
    color: var(--text-dark);
    font-size: 15px;
    outline: none;
    transition: 0.18s ease;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--gold-dark);
    box-shadow: 0 0 0 4px rgba(139, 107, 22, 0.14);
}

textarea {
    resize: vertical;
    min-height: 120px;
}

button,
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 18px;
    border: none;
    border-radius: 999px;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: 0.18s ease;
    text-decoration: none;
}

.btn:hover,
button:hover {
    transform: translateY(-1px);
}

.btn,
button,
.btn-primary {
    background: linear-gradient(135deg, #8B6B16 0%, #372805 100%);
    color: #fffef8;
    box-shadow: 0 10px 24px rgba(139, 107, 22, 0.24);
}

.btn:hover,
button:hover,
.btn-primary:hover {
    background: linear-gradient(135deg, #6F5310 0%, #372805 100%);
}

.btn-secondary {
    background: linear-gradient(135deg, #372805 0%, #8B6B16 100%);
    color: #fffef8;
    box-shadow: 0 10px 20px rgba(139, 107, 22, 0.18);
}
.actions .btn-secondary {
    background: linear-gradient(135deg, #372805 0%, #8B6B16 100%);
    color: #fffef8;
    box-shadow: 0 10px 20px rgba(139, 107, 22, 0.18);
}
.btn-secondary:hover {
    background: linear-gradient(135deg, #372805 0%, #6F5310 100%);
}

.btn-light {
    background: #fffefb;
    color: var(--text-dark);
    border: 1px solid var(--border);
}

.btn-light:hover {
    background: #faf4e8;
}

.btn-danger {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    color: #ffffff;
}

.actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.actions form {
    margin: 0;
}

.alert {
    padding: 14px 16px;
    border-radius: 16px;
    margin-bottom: 18px;
    border: 1px solid transparent;
    font-weight: 600;
}

.alert-success {
    background: var(--success-bg);
    color: var(--success);
    border-color: #bbf7d0;
}

.alert-error {
    background: var(--error-bg);
    color: var(--error);
    border-color: #fecaca;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table thead th {
    background: #f7ecd1;
    color: #372805;
    font-size: 14px;
    font-weight: 800;
    border-bottom: 1px solid var(--border);
}

.table th,
.table td {
    padding: 14px;
    border-bottom: 1px solid #eadfc9;
    text-align: left;
    vertical-align: top;
}

.table tbody tr:hover {
    background: rgba(201, 166, 70, 0.06);
}

.table a {
    color: #8B6B16;
    font-weight: 700;
}

.table a:hover {
    text-decoration: underline;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
}

.badge-gold {
    background: rgba(139, 107, 22, 0.12);
    color: #7A5B12;
}

.badge-success {
    background: #dcfce7;
    color: #166534;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

img.preview-image {
    max-width: 180px;
    border-radius: 12px;
    border: 1px solid #d1d5db;
}

input[type="checkbox"] {
    width: auto;
}

@media (max-width: 768px) {
    .container {
        width: min(95%, 1280px);
        margin: 16px auto;
    }

    .topbar {
        padding: 12px 0;
    }

    .topbar .container {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .brand-wrap {
        justify-content: center;
        width: 100%;
    }

    .brand-logo {
        width: 170px;
        margin: 0 auto;
    }

    .topbar-nav {
        width: 100%;
        justify-content: center;
        gap: 8px;
    }

    .topbar-nav a {
        padding: 9px 12px;
        font-size: 13px;
    }

    .card {
        padding: 18px;
        border-radius: 18px;
    }

    h1 {
        font-size: 26px;
    }

    h2 {
        font-size: 21px;
    }

    .actions {
        width: 100%;
    }

    .actions .btn,
    .actions button,
    .actions a {
        width: 100%;
    }

    .table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
}

.exam-shell {
    display: grid;
    grid-template-columns: 90px 1fr;
    gap: 20px;
    align-items: start;
}

.exam-topbar {
    background: linear-gradient(135deg, #7A5B12 0%, #8B6B16 55%, #A17E23 100%);
    border-bottom: 1px solid rgba(255, 245, 219, 0.25);
    box-shadow: 0 8px 20px rgba(111, 83, 16, 0.16);
}

.exam-topbar-static {
    position: static;
    top: auto;
}

.exam-topbar-inner {
    width: min(94%, 1280px);
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 12px 0;
}

.exam-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
}

.exam-tool-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 14px;
    border: none;
    border-radius: 999px;
    background: rgba(255, 250, 236, 0.16);
    color: #fffef8;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    backdrop-filter: blur(6px);
    white-space: nowrap;
}

.exam-tool-btn:hover {
    background: rgba(255, 250, 236, 0.26);
}

.exam-tool-btn[disabled] {
    opacity: 0.45;
    cursor: not-allowed;
}

.tool-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    line-height: 1;
}

.tool-text {
    display: inline;
}

.timer-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 999px;
    background: rgba(255, 245, 219, 0.18);
    color: #fffef8;
    border: 1px solid rgba(255, 248, 229, 0.26);
    font-weight: 800;
    white-space: nowrap;
}

.question-sidebar {
    position: sticky;
    top: 20px;
    background: linear-gradient(180deg, #fffefb 0%, #fbf6ea 100%);
    border-radius: 18px;
    padding: 12px 10px;
    box-shadow: 0 8px 24px rgba(111, 83, 16, 0.10);
    border: 1px solid var(--border);
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    overflow-x: hidden;
}

.question-sidebar h3 {
    margin-bottom: 10px;
    color: var(--gold-deep);
    font-size: 14px;
    text-align: center;
}

.question-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.question-jump {
    position: relative;
    width: 100%;
    min-height: 42px;
    border: 1px solid #ddcfaf;
    border-radius: 12px;
    background: #fffdf7;
    cursor: pointer;
    font-weight: 700;
    color: var(--text-dark);
    font-size: 14px;
}

.question-jump.current {
    border-color: #8B6B16;
    box-shadow: inset 0 0 0 2px #8B6B16;
    background: #fcf5df;
}

.question-jump.answered::after {
    content: '✓';
    position: absolute;
    bottom: 3px;
    right: 5px;
    font-size: 11px;
    color: #15803D;
    font-weight: 800;
}

.question-jump.flagged::before {
    content: '⚑';
    position: absolute;
    top: 3px;
    left: 5px;
    font-size: 11px;
    color: #B45309;
    font-weight: 800;
}

.exam-main {
    background: linear-gradient(180deg, #fffefc 0%, #fffaf1 100%);
    border-radius: 20px;
    padding: 22px;
    box-shadow: 0 10px 30px rgba(111, 83, 16, 0.10);
    border: 1px solid var(--border);
}

.question-title {
    font-size: 28px;
    margin-bottom: 18px;
    color: var(--gold-deep);
}

.question-intro {
    background: #fdf6e6;
    border-left: 4px solid #C9A646;
    padding: 14px 16px;
    border-radius: 12px;
    margin-bottom: 18px;
    line-height: 1.7;
}

.exam-question-layout {
    display: grid;
    grid-template-columns: 1fr 260px;
    gap: 24px;
    align-items: start;
}

.question-text {
    font-size: 21px;
    line-height: 1.75;
    margin-bottom: 18px;
    color: var(--text-dark);
}

.answer-options {
    display: grid;
    gap: 14px;
}

.answer-option {
    border: 1px solid #dacfb8;
    border-radius: 16px;
    padding: 16px;
    cursor: pointer;
    transition: 0.18s ease;
    background: #fffefb;
}

.answer-option:hover {
    border-color: #8B6B16;
    transform: translateY(-1px);
}

.answer-option.selected {
    border-color: #8B6B16;
    background: #fcf5df;
    box-shadow: inset 0 0 0 1px #8B6B16;
}

.answer-option input {
    display: none;
}

.answer-option-label {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.answer-letter {
    min-width: 34px;
    height: 34px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    background: #eadfbf;
    color: #6F5310;
}

.answer-option.selected .answer-letter {
    background: #8B6B16;
    color: #fffef8;
}

.question-image-panel {
    text-align: center;
}

.question-image-thumb {
    width: 100%;
    max-width: 240px;
    border-radius: 14px;
    border: 1px solid #d8ccb3;
    cursor: zoom-in;
    box-shadow: 0 8px 22px rgba(111, 83, 16, 0.12);
}

.exam-bottom-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 24px;
    flex-wrap: wrap;
}

.exam-bottom-nav button {
    min-width: 150px;
}

.exam-footer-bar {
    display: flex;
    justify-content: flex-end;
    margin-top: 18px;
    font-weight: 800;
    color: #6F5310;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(44, 36, 24, 0.50);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-overlay.show {
    display: flex;
}

.modal-box {
    width: 100%;
    max-width: 560px;
    background: #fffefb;
    border-radius: 20px;
    padding: 22px;
    box-shadow: 0 22px 50px rgba(111, 83, 16, 0.20);
    border: 1px solid var(--border);
}

.image-modal-box {
    width: auto;
    max-width: 92vw;
    max-height: 92vh;
    padding: 10px;
    background: #fffefb;
    border-radius: 18px;
}

.image-modal-box img {
    max-width: 88vw;
    max-height: 84vh;
    border-radius: 12px;
}

.hidden-question-inputs {
    display: none;
}

@media (max-width: 992px) {
    .exam-shell {
        grid-template-columns: 1fr;
    }

    .question-sidebar {
        position: static;
        max-height: none;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 12px;
    }

    .question-sidebar h3 {
        text-align: left;
        margin-bottom: 10px;
    }

    .question-grid {
        display: flex;
        flex-direction: row;
        gap: 8px;
        min-width: max-content;
    }

    .question-jump {
        width: 48px;
        min-width: 48px;
        min-height: 44px;
    }

    .exam-question-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .exam-topbar-inner {
        width: min(96%, 1280px);
        flex-wrap: nowrap;
        gap: 8px;
        align-items: center;
    }

    .exam-toolbar {
        flex: 1;
        display: flex;
        align-items: center;
        gap: 6px;
        flex-wrap: nowrap;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .exam-toolbar::-webkit-scrollbar {
        display: none;
    }

    .exam-tool-btn {
        min-width: 44px;
        min-height: 44px;
        padding: 10px;
        gap: 0;
        flex: 0 0 auto;
    }

    .exam-tool-btn .tool-text {
        display: none;
    }

    .finish-btn-special {
        min-width: auto;
        padding: 10px 14px;
        gap: 6px;
    }

    .finish-btn-special .tool-text {
        display: inline;
        font-size: 13px;
    }
    

    .timer-badge {
        flex: 0 0 auto;
        min-height: 44px;
        padding: 10px 12px;
        font-size: 13px;
    }

    .question-sidebar {
        padding: 12px;
        border-radius: 16px;
    }

    .question-sidebar h3 {
        display: none;
    }

    .exam-main {
        padding: 16px;
    }

    .question-title {
        font-size: 24px;
        margin-bottom: 14px;
    }

    .question-text {
        font-size: 18px;
        line-height: 1.7;
    }

    .answer-option {
        padding: 14px;
        border-radius: 14px;
    }

    .answer-option-label {
        gap: 10px;
    }

    .answer-letter {
        min-width: 32px;
        height: 32px;
        font-size: 13px;
    }

    .question-image-panel {
        order: -1;
        margin-bottom: 10px;
    }

    .question-image-thumb {
        max-width: 100%;
        width: 100%;
    }

    .exam-bottom-nav {
        flex-direction: column;
    }

    .exam-bottom-nav button {
        width: 100%;
    }

    .exam-footer-bar {
        justify-content: center;
        text-align: center;
        font-size: 14px;
    }

    .modal-box {
        padding: 18px;
        border-radius: 18px;
    }
}

@media (max-width: 768px) {
    #flag-btn .tool-text {
        display: none;
    }
}
.result-question-btn {
    text-align: left;
    white-space: normal;
    line-height: 1.6;
}

#question-explanation-modal {
    align-items: center;
    justify-content: center;
}

#question-explanation-box {
    max-height: 88vh;
    width: min(92vw, 560px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.question-details-modal {
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.question-details-content {
    overflow-y: scroll;
    max-height: calc(90vh - 110px);
    padding-right: 10px;
    -webkit-overflow-scrolling: touch;
}

.question-details-content::-webkit-scrollbar {
    width: 8px;
}

.question-details-content::-webkit-scrollbar-track {
    background: #f3ead4;
    border-radius: 10px;
}

.question-details-content::-webkit-scrollbar-thumb {
    background: #8B6B16;
    border-radius: 10px;
}

.question-details-content {
    scrollbar-width: thin;
    scrollbar-color: #8B6B16 #f3ead4;
}