:root {
    color-scheme: dark;
    --ink: #f4f7f8;
    --muted: #9caab3;
    --panel: #17232b;
    --panel-soft: #1d2d36;
    --line: #31434e;
    --accent: #f4b942;
    --accent-dark: #d99817;
    --green: #39c281;
    --red: #ff6565;
    --background: #0d151a;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(circle at 78% 5%, rgba(244, 185, 66, .11), transparent 31rem),
        var(--background);
}

button, select { font: inherit; }
button { cursor: pointer; }

.site-header {
    min-height: 52px;
    padding: 6px clamp(12px, 3vw, 42px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    background: rgba(13, 21, 26, .88);
    backdrop-filter: blur(16px);
}

.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-mark {
    width: 34px; height: 34px; display: grid; place-items: center;
    color: #101820; background: var(--accent); border-radius: 9px; font-size: 1.15rem; font-weight: 900;
}
.brand strong, .brand small { display: block; line-height: 1; }
.brand strong { font-size: .95rem; }
.brand small { margin-top: 3px; color: var(--muted); letter-spacing: .07em; text-transform: uppercase; font-size: .62rem; }

.exam-meta { display: flex; align-items: center; gap: 7px; }
.badge, .timer { padding: 6px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); font-size: .82rem; }
.timer { min-width: 70px; text-align: center; font-size: .95rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.exit-button { padding: 6px 9px; color: #dce4e8; border: 1px solid #526772; border-radius: 8px; background: transparent; font-size: .82rem; font-weight: 750; }
.exit-button:hover { color: var(--accent); border-color: var(--accent); }

main { width: min(1280px, calc(100% - 24px)); margin: 0 auto; }
.start-view { padding: clamp(48px, 9vh, 104px) 0 60px; display: grid; grid-template-columns: 1.25fr .75fr; gap: 42px 72px; }
.hero-copy { align-self: center; }
.eyebrow { margin: 0 0 12px; color: var(--accent); font-weight: 800; letter-spacing: .12em; text-transform: uppercase; font-size: .78rem; }
h1 { margin: 0; max-width: 820px; font-size: clamp(2.5rem, 5.6vw, 5.3rem); line-height: .98; letter-spacing: -.055em; }
.lead { max-width: 700px; margin: 28px 0 0; color: #c0cbd1; font-size: clamp(1.05rem, 1.8vw, 1.3rem); line-height: 1.65; }
.source-notice { max-width: 700px; margin: 20px 0 0; padding: 13px 15px; display: flex; gap: 11px; align-items: flex-start; color: #cdd7dc; border: 1px solid rgba(57, 194, 129, .35); border-radius: 11px; background: rgba(57, 194, 129, .08); line-height: 1.45; }
.source-notice > span:first-child { color: var(--green); font-weight: 900; }
.source-notice a { color: #7fe0ae; font-weight: 750; }

.start-card { align-self: center; padding: 30px; display: grid; gap: 12px; border: 1px solid var(--line); border-radius: 22px; background: linear-gradient(145deg, var(--panel-soft), var(--panel)); box-shadow: 0 24px 70px rgba(0, 0, 0, .25); }
.start-card label { margin-top: 5px; color: #d7dfe3; font-size: .9rem; font-weight: 700; }
.mode-picker { margin: 0 0 8px; padding: 0; display: grid; gap: 9px; border: 0; }
.mode-picker legend { margin-bottom: 8px; color: #d7dfe3; font-size: .9rem; font-weight: 700; }
.mode-option { position: relative; margin: 0 !important; }
.mode-option input { position: absolute; opacity: 0; pointer-events: none; }
.mode-option span { padding: 13px 14px; display: block; border: 1px solid #405661; border-radius: 10px; background: #111d23; cursor: pointer; }
.mode-option strong, .mode-option small { display: block; }
.mode-option small { margin-top: 4px; color: var(--muted); font-weight: 400; line-height: 1.35; }
.mode-option input:checked + span { border-color: var(--accent); background: rgba(244, 185, 66, .11); box-shadow: inset 3px 0 0 var(--accent); }
.mode-option input:focus-visible + span { outline: 3px solid rgba(244, 185, 66, .38); outline-offset: 2px; }
.check-option { margin-top: 10px !important; display: flex; gap: 11px; align-items: flex-start; cursor: pointer; }
.check-option input { width: 18px; height: 18px; margin: 2px 0 0; flex: 0 0 auto; accent-color: var(--accent); }
.check-option span, .check-option strong, .check-option small { display: block; }
.check-option strong { color: var(--ink); font-size: .87rem; }
.check-option small { margin-top: 3px; color: var(--muted); font-weight: 400; line-height: 1.4; }
select { width: 100%; padding: 14px 16px; color: var(--ink); border: 1px solid #49606d; border-radius: 10px; background: #111d24; }
select:focus, button:focus-visible { outline: 3px solid rgba(244, 185, 66, .38); outline-offset: 2px; }
.primary-button { min-height: 50px; padding: 12px 22px; border: 0; border-radius: 10px; color: #11181c; background: var(--accent); font-weight: 900; transition: transform .15s, background .15s; }
.primary-button:hover { background: #ffca61; transform: translateY(-1px); }
.primary-button:disabled { cursor: not-allowed; opacity: .42; transform: none; }
.start-card .primary-button { margin-top: 14px; }
.form-note { margin: 6px 0 0; color: var(--muted); font-size: .78rem; line-height: 1.5; }

.rules-grid { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.rules-grid article { padding: 22px; display: flex; align-items: center; gap: 18px; border-top: 1px solid var(--line); }
.rules-grid strong { color: var(--accent); font-size: 2.5rem; line-height: 1; }
.rules-grid span { color: var(--muted); line-height: 1.45; }

.exam-view { height: calc(100dvh - 52px); min-height: 500px; padding: 10px 0; display: flex; flex-direction: column; overflow: hidden; }
.progress-row { display: flex; justify-content: space-between; align-items: end; gap: 20px; }
.progress-row > div:first-child { display: grid; gap: 3px; }
.progress-row .eyebrow { margin: 0; }
.question-time { text-align: right; }
.question-time span { display: block; color: var(--muted); font-size: .82rem; }
.question-time strong { font-size: 1.7rem; font-variant-numeric: tabular-nums; }
.progress-track { flex: 0 0 auto; height: 3px; margin: 7px 0 10px; overflow: hidden; border-radius: 4px; background: #24333c; }
.progress-track span { display: block; height: 100%; background: var(--accent); transition: width .3s; }

.question-card { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(360px, .92fr); overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); box-shadow: 0 18px 50px rgba(0, 0, 0, .2); }
.media-stage { width: 100%; height: 100%; min-width: 0; min-height: 0; display: grid; place-items: center; overflow: hidden; background: #080d10; border-right: 1px solid var(--line); }
.media-stage img, .media-stage video { display: block; width: 100%; height: 100%; max-width: 100%; max-height: 100%; object-fit: contain; }
.media-placeholder { padding: 40px; color: #72828c; text-align: center; }
.media-placeholder svg { width: 50px; height: 50px; margin-bottom: 12px; opacity: .7; }
.media-placeholder strong, .media-placeholder span { display: block; }
.media-placeholder span { margin-top: 6px; font-size: .84rem; }
.question-content { min-width: 0; min-height: 0; padding: clamp(14px, 2vw, 24px); overflow-y: auto; overscroll-behavior: contain; }
.question-number { margin: 0 0 6px; color: var(--muted); font-size: .78rem; }
.question-content h2 { margin: 0; font-size: clamp(1.15rem, 2vw, 1.65rem); line-height: 1.28; letter-spacing: -.02em; }
.reading-notice { margin-top: 15px; padding: 12px 14px; color: #d9e0e4; border: 1px dashed #4b626f; border-radius: 10px; background: rgba(255, 255, 255, .025); }
.answers { margin-top: 16px; display: grid; gap: 8px; }
.answer-button { width: 100%; padding: 12px 14px; display: flex; gap: 12px; align-items: center; text-align: left; color: var(--ink); border: 1px solid #405661; border-radius: 10px; background: #111d23; transition: border .15s, background .15s, transform .15s; }
.answer-button:hover { border-color: #7d929d; transform: translateY(-1px); }
.answer-button.selected { border-color: var(--accent); background: rgba(244, 185, 66, .12); box-shadow: inset 4px 0 0 var(--accent); }
.answer-letter { width: 31px; height: 31px; flex: 0 0 31px; display: grid; place-items: center; color: #11181c; border-radius: 50%; background: #dce4e8; font-weight: 900; }
.answer-button.selected .answer-letter { background: var(--accent); }
.answer-button.correct { border-color: var(--green); background: rgba(57, 194, 129, .13); box-shadow: inset 4px 0 0 var(--green); }
.answer-button.correct .answer-letter { background: var(--green); }
.answer-button.incorrect { border-color: var(--red); background: rgba(255, 101, 101, .12); box-shadow: inset 4px 0 0 var(--red); }
.answer-button.incorrect .answer-letter { background: var(--red); }
.answer-button:disabled { cursor: default; transform: none; }
.binary-answers { grid-template-columns: 1fr 1fr; }
.binary-answers .answer-button { justify-content: center; font-size: 1.2rem; font-weight: 900; }

.exam-actions { position: static; flex: 0 0 auto; margin-top: 7px; padding: 0 2px; display: flex; justify-content: space-between; align-items: center; gap: 20px; border: 0; background: transparent; }
.exam-actions .primary-button { min-height: 42px; padding: 9px 18px; }
.exam-actions p { margin: 0; color: var(--muted); font-size: .85rem; }

.result-view { max-width: 980px; margin: 0 auto; padding: clamp(60px, 10vh, 110px) 0; text-align: center; }
.result-view h1 { margin: 0 auto; font-size: clamp(2.4rem, 6vw, 4.5rem); }
.result-icon { width: 82px; height: 82px; margin: 0 auto 24px; display: grid; place-items: center; border-radius: 50%; font-size: 2.5rem; font-weight: 900; }
.result-icon.pass { color: #081910; background: var(--green); }
.result-icon.fail { color: #210808; background: var(--red); }
.result-score { margin: 20px 0 32px; color: #dce3e6; font-size: 1.4rem; }
.result-stats { margin-bottom: 32px; display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; background: var(--panel); }
.result-stats div { padding: 24px 15px; border-right: 1px solid var(--line); }
.result-stats div:last-child { border: 0; }
.result-stats strong, .result-stats span { display: block; }
.result-stats strong { font-size: 2rem; }
.result-stats span { margin-top: 5px; color: var(--muted); font-size: .82rem; }
.result-review-section { margin-top: 48px; text-align: left; }
.result-review-heading { margin-bottom: 16px; display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.result-review-heading .eyebrow { margin-bottom: 5px; }
.result-review-heading h2 { margin: 0; font-size: clamp(1.55rem, 3vw, 2.2rem); }
.review-legend { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.review-legend span, .review-status { padding: 5px 8px; border-radius: 7px; font-size: .74rem; font-weight: 800; }
.review-legend .correct { color: #83e9b5; background: rgba(57, 194, 129, .13); }
.review-legend .incorrect { color: #ff9b9b; background: rgba(255, 101, 101, .12); }
.result-review { display: grid; gap: 10px; }
.review-item { padding: 16px 18px; border: 1px solid var(--line); border-left-width: 4px; border-radius: 11px; background: var(--panel); }
.review-item.correct { border-left-color: var(--green); }
.review-item.incorrect { border-left-color: var(--red); }
.review-item-header { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.review-item-header > strong { font-size: .86rem; }
.review-item.correct .review-status { color: #83e9b5; background: rgba(57, 194, 129, .13); }
.review-item.incorrect .review-status { color: #ff9b9b; background: rgba(255, 101, 101, .12); }
.review-question { margin: 12px 0; color: #e5ebee; line-height: 1.45; }
.review-answer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.review-answer-grid > div { padding: 10px 12px; border-radius: 8px; background: #111d23; }
.review-answer-grid span, .review-answer-grid strong { display: block; }
.review-answer-grid span { margin-bottom: 4px; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; }
.review-answer-grid strong { font-size: .88rem; line-height: 1.4; }
.review-answer-grid .correct-answer { border: 1px solid rgba(57, 194, 129, .3); }

.error-box { position: fixed; right: 20px; bottom: 20px; max-width: 430px; padding: 16px 20px; color: #fff; border: 1px solid #a73b3b; border-radius: 10px; background: #742929; box-shadow: 0 15px 50px rgba(0,0,0,.35); }

@media (max-width: 760px) {
    main { width: min(100% - 24px, 1180px); }
    .site-header { min-height: 50px; padding: 6px 10px; }
    .brand small { display: none; }
    .exam-meta { gap: 6px; }
    .exit-button, .badge, .timer { padding: 8px; }
    .exit-button { font-size: 0; }
    .exit-button::after { content: 'Menu'; font-size: .8rem; }
    .timer { min-width: 68px; font-size: 1rem; }
    .start-view { padding-top: 42px; grid-template-columns: 1fr; gap: 28px; }
    .rules-grid { grid-template-columns: 1fr; }
    .rules-grid article { padding: 14px 4px; }
    .exam-view { height: auto; min-height: calc(100dvh - 50px); overflow: visible; }
    .question-card { display: block; overflow: hidden; }
    .media-stage { height: clamp(155px, 27vh, 230px); min-height: 155px; border-right: 0; border-bottom: 1px solid var(--line); }
    .question-content { overflow: visible; }
    .progress-row { align-items: center; }
    .question-time span { max-width: 150px; }
    .binary-answers, .result-stats { grid-template-columns: 1fr; }
    .result-stats div { border-right: 0; border-bottom: 1px solid var(--line); }
    .exam-actions { align-items: stretch; flex-direction: column; }
    .exam-actions .primary-button { width: 100%; }
    .result-review-heading, .review-item-header { align-items: flex-start; flex-direction: column; }
    .review-legend { justify-content: flex-start; }
    .review-answer-grid { grid-template-columns: 1fr; }
}
