:root {
  color-scheme: dark;
  --bg: #0c1120;
  --surface: #121a2d;
  --surface-raised: #172139;
  --line: #25314b;
  --muted: #8290ac;
  --text: #edf2ff;
  --accent: #9af56b;
  --accent-dark: #192b25;
  --purple: #a7a5ff;
  --danger: #ff8f9c;
  font-family: 'DM Sans', 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
  /* Long unbroken text (registry paths, hashes, URLs) wraps instead of widening the page.
     "anywhere" (unlike "break-word") also shrinks grid/flex columns that hold such text. */
  overflow-wrap: anywhere;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

button, input { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.page-glow { position: fixed; z-index: -1; width: 540px; height: 540px; border-radius: 50%; filter: blur(130px); opacity: .13; pointer-events: none; }
.page-glow-one { top: -260px; left: 18%; background: #6663df; }
.page-glow-two { right: -300px; bottom: -240px; background: #85ed5e; opacity: .08; }

.topbar { height: 82px; padding: 0 max(5.5vw, 24px); display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid rgba(147, 164, 196, .12); }
.brand { display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; }
.brand-mark { width: 39px; height: 39px; display: grid; place-items: center; border: 1px solid #495573; border-radius: 12px; font: 700 16px 'Space Grotesk', sans-serif; letter-spacing: -1px; }
.brand-mark span { color: var(--accent); font-size: 11px; vertical-align: top; }
.brand-copy { display: flex; flex-direction: column; gap: 2px; }
.brand-copy strong { font: 600 14px 'Space Grotesk', sans-serif; letter-spacing: .05em; }
.brand-copy small { color: #8491aa; font-size: 11px; }
.topbar-right { display: flex; align-items: center; gap: 26px; }
.secure-label, .help-link { color: #9aa7bf; font-size: 12px; text-decoration: none; }
.status-dot, .live-pill i { display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px rgba(154, 245, 107, .8); }
.help-link:hover { color: var(--accent); }

.shell { max-width: 1240px; margin: 0 auto; padding: 50px 38px 28px; }
.welcome-layout { min-height: 650px; display: grid; grid-template-columns: 1.05fr .85fr; gap: clamp(50px, 9vw, 130px); align-items: center; }
.eyebrow { display: flex; align-items: center; gap: 10px; color: var(--accent); font: 500 10px 'DM Mono', monospace; letter-spacing: .14em; }
.eyebrow-line { display: inline-block; width: 22px; height: 1px; background: currentColor; opacity: .7; }
h1, h2, p { margin-top: 0; }
.welcome-copy h1, .result-heading h1 { margin: 19px 0 20px; font: 600 clamp(54px, 6vw, 78px)/.99 'Space Grotesk', sans-serif; letter-spacing: -.065em; }
.welcome-copy h1 span { color: var(--accent); }
.lead { max-width: 440px; margin-bottom: 34px; color: #a1adc4; font-size: 15px; line-height: 1.75; }
.exam-facts { display: flex; gap: 35px; margin-bottom: 34px; }
.fact { display: grid; grid-template-columns: 24px auto; column-gap: 5px; align-items: center; }
.fact-icon { grid-row: span 2; color: var(--accent); font-size: 19px; }
.fact strong { font: 600 21px 'Space Grotesk', sans-serif; }
.fact small { color: var(--muted); font-size: 10px; }
.unit-pills { display: grid; gap: 10px; max-width: 400px; }
.unit-pills span { display: flex; align-items: center; gap: 11px; color: #a5b0c6; font-size: 12px; }
.unit-pills b { display: grid; width: 23px; height: 23px; place-items: center; border: 1px solid #303d58; border-radius: 7px; color: var(--purple); font: 500 9px 'DM Mono', monospace; }

.entry-card { padding: 30px 32px 23px; border: 1px solid #27334e; border-radius: 18px; background: linear-gradient(145deg, rgba(24, 34, 57, .98), rgba(17, 25, 43, .98)); box-shadow: 0 22px 80px rgba(0, 0, 0, .28); }
.card-topline { display: flex; align-items: center; justify-content: space-between; margin-bottom: 27px; }
.live-pill { padding: 7px 10px; border: 1px solid rgba(154, 245, 107, .19); border-radius: 20px; color: var(--accent); background: rgba(154, 245, 107, .06); font: 500 9px 'DM Mono', monospace; letter-spacing: .08em; }
.live-pill i { width: 5px; height: 5px; }
.seat-count { color: #8693ad; font: 10px 'DM Mono', monospace; }
.entry-card h2 { margin: 0 0 6px; font: 600 25px 'Space Grotesk', sans-serif; letter-spacing: -.03em; }
.card-subtitle { margin-bottom: 23px; color: #8c99b1; font-size: 12px; }
.field-label { display: block; margin: 15px 0 7px; color: #bdc7da; font-size: 11px; font-weight: 600; }
input { width: 100%; height: 43px; padding: 0 13px; border: 1px solid #2b3853; border-radius: 8px; outline: none; background: #0f1729; color: var(--text); font-size: 12px; transition: border-color .2s, box-shadow .2s; }
input::placeholder { color: #5e6b84; }
input:focus { border-color: #9af56b; box-shadow: 0 0 0 3px rgba(154, 245, 107, .08); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.form-error { margin: 12px 0 0; color: var(--danger); font-size: 11px; line-height: 1.5; }
.button { display: inline-flex; min-height: 42px; align-items: center; justify-content: center; gap: 14px; padding: 0 17px; border: 1px solid transparent; border-radius: 8px; font-size: 12px; font-weight: 700; transition: transform .18s, background .18s, border-color .18s; }
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: wait; opacity: .65; transform: none; }
.button-primary { background: var(--accent); color: #102015; }
.button-primary:hover { background: #b0fb8b; }
.button-wide { width: 100%; margin-top: 22px; }
.button-arrow { font-size: 17px; line-height: 1; }
.card-note { display: flex; align-items: center; justify-content: center; gap: 7px; margin-top: 18px; color: #7785a0; font-size: 10px; }
.card-note span { color: var(--accent); font-size: 15px; }

.site-footer { display: flex; justify-content: space-between; gap: 15px; margin-top: 34px; padding-top: 16px; border-top: 1px solid rgba(147, 164, 196, .12); color: #71809b; font: 9px 'DM Mono', monospace; letter-spacing: .02em; }
.site-footer i { display: inline-block; width: 3px; height: 3px; margin: 0 7px 2px; border-radius: 50%; background: #566580; }

.exam-header { display: flex; align-items: end; justify-content: space-between; margin: 8px 0 25px; }
.exam-heading { margin: 10px 0 0; font: 600 38px 'Space Grotesk', sans-serif; letter-spacing: -.05em; }
.accent-dot { color: var(--accent); }
.exam-header-meta { display: flex; align-items: center; gap: 20px; }
.student-chip { color: #a6b1c8; font-size: 11px; }
.timer-card { min-width: 112px; padding: 9px 13px; border: 1px solid #2e3b57; border-radius: 9px; background: #141d31; text-align: center; }
.timer-card small { display: block; margin-bottom: 3px; color: #8290ac; font: 8px 'DM Mono', monospace; letter-spacing: .08em; }
.timer-card strong { color: var(--accent); font: 600 21px 'DM Mono', monospace; }
.timer-card.urgent { border-color: rgba(255, 143, 156, .5); }
.timer-card.urgent strong { color: var(--danger); }
.fullscreen-warning { display: flex; justify-content: space-between; align-items: center; gap: 15px; margin-bottom: 16px; padding: 11px 14px; border: 1px solid rgba(255, 185, 92, .3); border-radius: 8px; background: rgba(255, 185, 92, .07); color: #e7bd80; font-size: 11px; }
.button-small { min-height: 32px; border-color: #6f5c3a; background: transparent; color: #f0c77e; font-size: 10px; }
.exam-progress { margin-bottom: 20px; }
.progress-label { display: flex; justify-content: space-between; margin-bottom: 8px; color: #8794ad; font: 10px 'DM Mono', monospace; }
.save-failed { color: var(--danger); }
.progress-track, .score-bar { height: 4px; overflow: hidden; border-radius: 4px; background: #26324b; }
.progress-track div, .score-bar div { height: 100%; border-radius: inherit; background: var(--accent); transition: width .25s ease; }
.exam-layout { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 17px; align-items: start; }
.question-card, .question-nav-card, .breakdown-card, .leaderboard-card { border: 1px solid #26334e; border-radius: 13px; background: rgba(19, 28, 47, .92); }
.question-card { min-height: 460px; padding: 26px 30px 19px; display: flex; flex-direction: column; }
.question-meta { display: flex; justify-content: space-between; align-items: center; }
.question-number { color: #8391aa; font: 10px 'DM Mono', monospace; letter-spacing: .1em; }
.question-tags { display: flex; gap: 6px; }
.tag { padding: 5px 8px; border: 1px solid #34415d; border-radius: 20px; color: #afb9cf; font: 9px 'DM Mono', monospace; }
.tag-scenario { border-color: rgba(167, 165, 255, .34); color: var(--purple); background: rgba(167, 165, 255, .06); }
.question-prompt { max-width: 760px; margin: 25px 0 20px; font: 500 clamp(18px, 2.3vw, 23px)/1.5 'Space Grotesk', sans-serif; letter-spacing: -.015em; }
.answer-options { display: grid; gap: 9px; }
.answer-option { width: 100%; display: flex; align-items: center; gap: 13px; padding: 12px 14px; border: 1px solid #2b3853; border-radius: 9px; background: #10182a; color: #c1cadb; text-align: left; font-size: 12px; line-height: 1.5; transition: border-color .17s, background .17s, color .17s; }
.answer-option:hover { border-color: #67748f; color: var(--text); }
.answer-option.selected { border-color: rgba(154, 245, 107, .65); background: rgba(154, 245, 107, .07); color: #efffe7; }
.option-letter { display: grid; width: 24px; height: 24px; flex: 0 0 24px; place-items: center; border: 1px solid #3a4762; border-radius: 7px; color: #9ba8c0; font: 10px 'DM Mono', monospace; }
.selected .option-letter { border-color: var(--accent); background: var(--accent); color: #14251b; }
.question-controls { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: 25px; }
.button-quiet { border-color: #303d59; background: transparent; color: #a6b2c8; }
.button-quiet:hover { border-color: #66748f; color: var(--text); }
.answered-copy { color: #76839b; font-size: 10px; }
.question-nav-card { padding: 17px 15px 15px; }
.nav-title { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.nav-title strong { font: 600 13px 'Space Grotesk', sans-serif; }
.nav-title span, .submit-hint { color: #7e8ba4; font-size: 9px; }
.question-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 5px; max-height: 274px; overflow: auto; padding: 1px 3px 4px 1px; scrollbar-color: #34415d transparent; scrollbar-width: thin; }
.question-grid button { aspect-ratio: 1; min-width: 0; padding: 0; border: 1px solid #2b3853; border-radius: 5px; background: #10182a; color: #8592aa; font: 9px 'DM Mono', monospace; }
.question-grid button:hover { border-color: #74819a; }
.question-grid button.active { border-color: var(--purple); color: var(--purple); box-shadow: inset 0 0 0 1px rgba(167, 165, 255, .25); }
.question-grid button.answered { border-color: #547345; background: rgba(154, 245, 107, .11); color: var(--accent); }
.question-grid button.active.answered { border-color: var(--accent); color: var(--accent); }
.nav-legend { display: flex; gap: 15px; margin: 13px 0 0; color: #8390a8; font-size: 9px; }
.nav-legend span { display: inline-flex; gap: 6px; align-items: center; }
.nav-legend i { width: 8px; height: 8px; border: 1px solid #2b3853; border-radius: 2px; }
.nav-legend .legend-answered { border-color: #547345; background: rgba(154, 245, 107, .32); }
.question-nav-card .button-wide { min-height: 39px; margin-top: 16px; font-size: 11px; }
.submit-hint { margin: 9px 0 0; text-align: center; }
.exam-unit-progress { display: grid; gap: 8px; margin-top: 13px; padding-top: 12px; border-top: 1px solid #26324a; }
.unit-progress-row { display: grid; grid-template-columns: 39px 1fr 30px; gap: 7px; align-items: center; color: #8e9bb2; font: 8px 'DM Mono', monospace; }
.unit-progress-row .unit-track { height: 4px; }
.unit-progress-value { text-align: right; }

.result-heading { margin: 4px 0 22px; text-align: center; }
.result-heading .eyebrow { justify-content: center; }
.result-heading h1 { margin: 12px 0 7px; font-size: 46px; }
.result-heading p { color: #91a0b9; font-size: 12px; }
.result-summary { display: grid; grid-template-columns: 1.5fr 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.score-card, .rank-card, .result-mini-card { min-height: 130px; padding: 19px 22px; border: 1px solid #2b3853; border-radius: 12px; background: #141d31; }
.score-kicker, .rank-kicker { color: #8b99b3; font: 9px 'DM Mono', monospace; letter-spacing: .1em; }
.score-main { margin: 8px 0 9px; }
.score-main strong { font: 600 37px 'Space Grotesk', sans-serif; letter-spacing: -.05em; }
.score-main span { color: #8794ac; font-size: 14px; }
.score-bar { width: min(100%, 300px); height: 5px; }
.score-percent { display: block; margin-top: 8px; color: var(--accent); font: 10px 'DM Mono', monospace; }
.rank-card { background: linear-gradient(130deg, rgba(167, 165, 255, .12), #141d31 75%); }
.rank-main { display: flex; align-items: baseline; gap: 5px; margin: 10px 0 2px; }
.rank-symbol { color: var(--purple); font: 18px 'DM Mono', monospace; }
.rank-main strong { font: 600 38px 'Space Grotesk', sans-serif; }
.rank-total { color: #8794ac; font-size: 10px; }
.reward-banner { display: grid; grid-template-columns: .65fr 1.35fr; gap: 12px; margin: -2px 0 14px; padding: 14px 18px; border: 1px solid #384367; border-radius: 11px; background: linear-gradient(110deg, rgba(154,245,107,.09), rgba(167,165,255,.08)); }
.reward-banner > div { display: grid; align-content: center; gap: 5px; }
.reward-kicker { color: #98a6bf; font: 8px 'DM Mono', monospace; letter-spacing: .1em; }
.reward-banner strong { color: var(--accent); font: 600 21px 'Space Grotesk', sans-serif; }
.reward-banner small { color: #96a2b9; font-size: 9px; }
.achievement-list { display: flex; flex-wrap: wrap; gap: 6px; }
.achievement-badge { padding: 6px 9px; border: 1px solid rgba(167,165,255,.38); border-radius: 20px; background: rgba(167,165,255,.08); color: #d3d0ff; font: 9px 'DM Mono', monospace; }
.achievement-empty { color: #808da6; font-size: 10px; }
.result-mini-card { display: flex; flex-direction: column; justify-content: center; align-items: center; }
.mini-icon { color: var(--accent); font-size: 19px; }
.result-mini-card strong { margin: 7px 0 2px; font: 600 18px 'DM Mono', monospace; }
.result-mini-card small { color: #8390a8; font-size: 10px; }
.result-columns { display: grid; grid-template-columns: .8fr 1.2fr; gap: 14px; }
.breakdown-card, .leaderboard-card { min-height: 226px; padding: 18px 20px; }
.section-title { display: flex; justify-content: space-between; align-items: end; margin-bottom: 17px; }
.section-title .eyebrow { font-size: 8px; }
.section-title h2 { margin: 5px 0 0; font: 600 17px 'Space Grotesk', sans-serif; }
.tiny-note { color: #76839a; font-size: 9px; }
.unit-breakdown { display: grid; gap: 15px; }
.unit-row { display: grid; grid-template-columns: 35px 1fr 46px; gap: 11px; align-items: center; }
.unit-code { color: var(--purple); font: 10px 'DM Mono', monospace; }
.unit-track { height: 5px; overflow: hidden; border-radius: 5px; background: #293650; }
.unit-track i { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.unit-score { color: #c7d0e0; font: 10px 'DM Mono', monospace; text-align: right; }
.table-wrap { max-height: 165px; overflow-y: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th { padding: 0 8px 9px; color: #72809a; font: 8px 'DM Mono', monospace; letter-spacing: .07em; }
td { padding: 8px; border-top: 1px solid #26324a; color: #aeb9cd; font-size: 10px; }
tr.current-result td { color: var(--accent); background: rgba(154, 245, 107, .045); }
td:first-child { color: var(--purple); font-family: 'DM Mono', monospace; }
td:last-child { white-space: nowrap; }
.review-details { margin-top: 14px; border: 1px solid #26334e; border-radius: 11px; background: rgba(19, 28, 47, .92); }
.review-details summary { padding: 15px 18px; cursor: pointer; color: #dce4f2; font: 600 13px 'Space Grotesk', sans-serif; }
.review-details summary span { margin-left: 9px; color: #7f8da5; font: 10px 'DM Sans', sans-serif; }
.answer-review { display: grid; gap: 9px; padding: 0 14px 14px; }
.review-item { padding: 12px; border: 1px solid #293650; border-radius: 8px; background: #10182a; }
.review-item h3 { margin: 0 0 7px; color: #cbd4e4; font: 500 11px/1.5 'DM Sans', sans-serif; }
.review-item p { margin: 4px 0 0; color: #93a0b8; font-size: 10px; line-height: 1.5; }
.review-item .correct-answer { color: var(--accent); }
.review-item .wrong-answer { color: var(--danger); }
.result-footer { display: flex; justify-content: space-between; margin: 18px 2px 0; color: #72809a; font: 9px 'DM Mono', monospace; }
.confirm-dialog { width: min(420px, calc(100vw - 32px)); padding: 27px; border: 1px solid #37445f; border-radius: 14px; background: #172139; color: var(--text); box-shadow: 0 20px 70px #0009; }
.confirm-dialog::backdrop { background: #050914bb; backdrop-filter: blur(3px); }
.dialog-icon { display: grid; width: 32px; height: 32px; place-items: center; border: 1px solid rgba(154, 245, 107, .4); border-radius: 10px; color: var(--accent); font: 600 15px 'Space Grotesk', sans-serif; }
.confirm-dialog h2 { margin: 17px 0 7px; font: 600 22px 'Space Grotesk', sans-serif; }
.confirm-dialog p { color: #94a1ba; font-size: 12px; line-height: 1.6; }
.dialog-actions { display: flex; justify-content: end; gap: 9px; margin-top: 21px; }

@media (max-width: 860px) {
  .shell { padding: 34px 25px 24px; }
  .welcome-layout { min-height: auto; gap: 40px; }
  .welcome-copy h1 { font-size: 60px; }
  .exam-layout { grid-template-columns: minmax(0, 1fr) 220px; gap: 12px; }
  .question-card { padding: 22px 20px 17px; }
  .question-grid { grid-template-columns: repeat(7, 1fr); }
}

@media (max-width: 680px) {
  .topbar { height: 70px; padding: 0 18px; }
  .brand-copy small { display: none; }
  .topbar-right { gap: 14px; }
  .secure-label { font-size: 0; }
  .status-dot { margin: 0; }
  .shell { padding: 28px 17px 20px; }
  .welcome-layout { grid-template-columns: 1fr; gap: 28px; }
  .welcome-copy h1 { font-size: 57px; }
  .lead { max-width: 500px; margin-bottom: 24px; font-size: 13px; }
  .exam-facts { gap: 25px; margin-bottom: 22px; }
  .unit-pills { display: none; }
  .entry-card { padding: 23px 21px 19px; }
  .site-footer { flex-direction: column; align-items: center; margin-top: 27px; font-size: 8px; }
  .exam-header { align-items: center; }
  .exam-heading { font-size: 29px; }
  .exam-header-meta { flex-direction: column-reverse; gap: 7px; align-items: end; }
  .student-chip { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .timer-card { min-width: 91px; padding: 7px 9px; }
  .timer-card strong { font-size: 18px; }
  .exam-layout { grid-template-columns: 1fr; }
  .question-card { min-height: 430px; }
  .question-nav-card { order: 2; }
  .question-grid { grid-template-columns: repeat(10, 1fr); max-height: 155px; }
  .question-grid button { font-size: 8px; }
  .nav-title { flex-direction: row; justify-content: space-between; align-items: baseline; }
  .fullscreen-warning { align-items: start; flex-direction: column; }
  .result-heading h1 { font-size: 35px; }
  .result-summary { grid-template-columns: 1fr 1fr; }
  .reward-banner { grid-template-columns: 1fr; gap: 12px; }
  .score-card { grid-column: span 2; min-height: 119px; }
  .rank-card, .result-mini-card { min-height: 112px; }
  .result-columns { grid-template-columns: 1fr; }
  .section-title { align-items: start; }
  .result-footer { flex-direction: column; gap: 7px; text-align: center; }
  .review-details summary span { display: block; margin: 6px 0 0; }
}

/* ---------------------------------------------------------------------------------------
   Responsive hardening: every screen from 320 px phones to large desktops.
   Verified by tests/responsive-test.mjs on 15 device profiles. */

/* Grid/flex children may shrink below their content's width, so long text wraps inside them. */
.welcome-layout > *, .exam-layout > *, .result-summary > *, .reward-banner > *,
.result-columns > *, .answer-review > *, .exam-header > *, .question-meta > *,
.question-controls > *, .field-row > * { min-width: 0; }
.answer-option > span:last-child { flex: 1 1 auto; min-width: 0; }

/* Keep line breaks typed in CSV questions (e.g. code snippets) and show them readably. */
.question-prompt, .answer-option > span:last-child, .review-item h3, .review-item p { white-space: pre-line; }
.question-prompt { max-width: 100%; }

/* Headings and labels that may hold long quiz titles or names wrap cleanly. */
.eyebrow { flex-wrap: wrap; row-gap: 4px; }
.exam-header { gap: 14px; flex-wrap: wrap; }
.exam-header > div:first-child { flex: 1 1 220px; }
.question-meta { gap: 10px; flex-wrap: wrap; }
.question-controls { gap: 10px; }
.table-wrap { overflow-x: auto; }
.result-footer, .site-footer { flex-wrap: wrap; }
.dialog-actions { flex-wrap: wrap; }
.confirm-dialog { max-height: calc(100dvh - 32px); overflow-y: auto; }

/* Phones */
@media (max-width: 680px) {
  .shell { padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right)); }
  .welcome-copy h1 { font-size: clamp(38px, 13vw, 57px); }
  .exam-facts { flex-wrap: wrap; gap: 16px 24px; }
  /* Header: title on top, then name + timer on one row that always fits. */
  .exam-header { flex-direction: column; align-items: stretch; gap: 10px; margin-bottom: 16px; }
  .exam-header > div:first-child { flex: none; }
  .exam-header-meta { flex-direction: row; justify-content: space-between; align-items: center; gap: 10px; }
  .student-chip { flex: 1 1 auto; min-width: 0; max-width: none; }
  .timer-card { flex: 0 0 auto; }
  .question-card { min-height: 0; padding: 18px 15px 15px; }
  .question-prompt { margin: 16px 0 16px; font-size: 17px; }
  .answer-option { min-height: 48px; padding: 12px; font-size: 14px; }
  .question-controls { padding-top: 18px; }
  .question-controls .button { flex: 1 1 0; padding: 0 10px; }
  .answered-copy { display: none; }
  .question-grid { grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); max-height: 200px; gap: 6px; }
  .question-grid button { font-size: 11px; }
  .progress-label { gap: 10px; }
  .result-summary { grid-template-columns: 1fr; }
  .score-card { grid-column: auto; }
  .review-item h3 { font-size: 13px; }
  .review-item p { font-size: 12px; }
  td, th { padding-left: 6px; padding-right: 6px; }
}

/* Very small phones (320–359 px) */
@media (max-width: 359px) {
  .topbar { padding: 0 12px; }
  .topbar-right { gap: 10px; }
  .help-link { font-size: 11px; }
  .brand-mark { width: 34px; height: 34px; }
  .timer-card { min-width: 84px; }
  .field-row { grid-template-columns: 1fr; gap: 0; }
}

/* Phones held sideways: short screens, keep the question in view. */
@media (max-height: 500px) and (orientation: landscape) {
  .topbar { height: 56px; }
  .shell { padding-top: 14px; }
  .exam-heading { font-size: 24px; }
  .question-card { min-height: 0; }
}

/* Touch screens (phones, tablets): comfortable tap targets, no iOS zoom on input focus. */
@media (pointer: coarse) {
  input, select, textarea { font-size: 16px; }
  input { height: 46px; }
  .button { min-height: 44px; }
  .button-small { min-height: 40px; }
  .question-grid { grid-template-columns: repeat(auto-fill, minmax(36px, 1fr)); }
  .question-grid button { min-height: 36px; }
  .help-link { display: inline-flex; align-items: center; min-height: 36px; }
  .review-details summary { min-height: 44px; }
  .answer-option { min-height: 48px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}

/* Previous / Next light up once the current question is answered */
.question-controls .button.nav-ready {
  border-color: #5fd4ff;
  background: rgba(95, 212, 255, .12);
  color: #8fe3ff;
  box-shadow: 0 0 0 1px rgba(95, 212, 255, .25), 0 0 16px rgba(95, 212, 255, .18);
}
.question-controls .button.nav-ready:hover { background: rgba(95, 212, 255, .2); color: #c4f1ff; }
.question-controls #next-button.nav-ready {
  border-color: var(--accent);
  background: var(--accent);
  color: #102015;
  font-weight: 600;
  box-shadow: 0 0 18px rgba(154, 245, 107, .35);
  animation: nav-ready-glow 1.6s ease-in-out 2;
}
.question-controls #next-button.nav-ready:hover { background: #b0fb8b; }
.question-controls .button.nav-ready:disabled { border-color: #303d59; background: transparent; color: #56627a; box-shadow: none; }
@keyframes nav-ready-glow { 50% { box-shadow: 0 0 26px rgba(154, 245, 107, .6); } }
@media (prefers-reduced-motion: reduce) { .question-controls #next-button.nav-ready { animation: none; } }

/* Screenshot / copy protection */
.exam-watermark {
  position: fixed; inset: 0; z-index: 40; pointer-events: none;
  background-repeat: repeat; background-position: center;
}
.exam-watermark[hidden] { display: none; }
.exam-shield {
  position: fixed; inset: 0; z-index: 2000;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  padding: 24px; text-align: center; cursor: pointer;
  background: #0b1120; color: #a6b2c8;
}
.exam-shield[hidden] { display: none; }
.exam-shield.shield-wifi { cursor: default; }
.exam-shield-steps {
  max-width: 520px; margin: 6px 0; padding-left: 22px; text-align: left;
  color: var(--text); font-size: 15px; line-height: 1.5;
}
.exam-shield-steps li { margin: 6px 0; }
.exam-shield-steps[hidden], #exam-shield-retry[hidden] { display: none; }
.connection-bar[hidden] { display: none; }
.exam-shield strong { color: var(--text); font: 600 clamp(20px, 5vw, 28px) 'Space Grotesk', sans-serif; }
#exam-view, #result-view { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
@media print {
  body > * { display: none !important; }
  body::before { content: "Printing is disabled for this exam."; display: block; padding: 40px; font: 20px sans-serif; color: #000; }
}

/* Connection panel fixed at the bottom-right corner of the student page */
.connection-bar {
  position: fixed; z-index: 50;
  right: max(12px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: stretch; gap: 8px;
  width: max-content; max-width: calc(100vw - 24px);
  padding: 10px 12px; border: 1px solid #33425f; border-radius: 12px;
  background: rgba(14, 21, 37, .96); box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
}
/* Room at the end of the page so the panel never covers Submit / Finish */
body { padding-bottom: 120px; }
.connection-state { display: inline-flex; align-items: center; gap: 9px; min-width: 0; color: #a6b2c8; font-size: 12px; }
.connection-state i { flex: none; width: 10px; height: 10px; border-radius: 50%; background: #8794ad; }
.connection-state.online { color: #c9f7b0; }
.connection-state.online i { background: var(--accent); box-shadow: 0 0 10px rgba(154, 245, 107, .8); }
.connection-state.offline { color: #ffb4a8; }
.connection-state.offline i { background: #ff6b5a; box-shadow: 0 0 10px rgba(255, 107, 90, .8); }
.connection-actions { display: flex; gap: 8px; }
.connection-actions .button { flex: 1 1 auto; min-height: 34px; padding: 0 12px; font-size: 11px; gap: 6px; white-space: nowrap; overflow-wrap: normal; }
.connection-short, .label-short { display: none; }
@media (pointer: coarse) { .connection-actions .button { min-height: 40px; } }
/* Phones / small windows: one compact row so it covers as little of the question as possible */
@media (max-width: 680px) {
  .connection-bar { flex-direction: row; align-items: center; gap: 8px; padding: 6px 6px 6px 10px; border-radius: 999px; }
  #connection-text, .label-long { display: none; }
  .connection-short, .label-short { display: inline; }
  .connection-state { font-size: 12px; font-weight: 600; }
  .connection-actions { gap: 6px; }
  .connection-actions .button { padding: 0 12px; border-radius: 999px; }
  body { padding-bottom: 84px; }
}

/* Shared devices: "Finish" on the result screen */
.result-footer { align-items: center; gap: 10px; }
.result-footer .button { font-size: 14px; }
@media (max-width: 680px) {
  .result-footer .button { width: 100%; justify-content: center; }
}

/* ---- Test list after registration ---- */
.tests-view { padding: 10px 0 30px; }
.tests-heading { text-align: center; margin-bottom: 26px; }
.tests-heading .eyebrow { justify-content: center; }
.tests-heading h1 { margin: 12px 0 8px; font-size: clamp(32px, 6vw, 46px); }
.tests-heading .lead { margin: 0 auto; color: #a6b2c8; font-size: 13px; }
.tests-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); gap: 18px; }
.test-card { display: flex; flex-direction: column; gap: 10px; padding: 22px; border: 1px solid #27334e; border-radius: 16px;
  background: linear-gradient(145deg, rgba(24, 34, 57, .98), rgba(17, 25, 43, .98)); box-shadow: 0 18px 60px rgba(0, 0, 0, .25); }
.test-card h2 { margin: 0; font: 600 19px/1.3 'Space Grotesk', sans-serif; color: var(--text); overflow-wrap: anywhere; }
.test-teacher { margin: 0; color: #a6b2c8; font-size: 12px; }
.test-teacher strong { color: #5fd4ff; font-weight: 600; }
.test-teacher span { color: #c9d4ea; font-family: ui-monospace, Consolas, monospace; }
.test-description { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.test-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }
.test-meta span { padding: 4px 9px; border: 1px solid #2b3856; border-radius: 999px; color: #c5cfe3; font-size: 11px; }
.test-start { width: 100%; justify-content: center; margin-top: 4px; }
.test-start:disabled { opacity: .55; cursor: not-allowed; }
.tests-empty { grid-column: 1 / -1; padding: 30px; border: 1px dashed #33405e; border-radius: 14px; text-align: center; color: #a6b2c8; }
.tests-footer { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 24px; }
#tests-error { margin: 0 0 16px; }
