:root {
  --navy: #12263f;
  --navy-2: #203b5a;
  --paper: #ffffff;
  --canvas: #edf0f3;
  --ink: #15191e;
  --muted: #5e6873;
  --border: #9aa3ac;
  --light-border: #d7dce1;
  --blue: #0b5da8;
  --mark: #f3cf56;
  --focus: #ffbf47;
  font-family: Arial, Helvetica, sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--canvas); color: var(--ink); font-size: 16px; }
button, input { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
#app { min-height: 100vh; display: grid; grid-template-rows: auto 1fr auto; }

.test-header {
  min-height: 72px;
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  color: #fff;
  background: var(--navy);
  border-bottom: 5px solid #74879a;
}
.header-title { display: flex; align-items: center; gap: 24px; padding: 13px 24px; }
.section-name { font-size: 1.2rem; font-weight: 700; }
.header-title > span:last-child { color: #dbe4ed; border-left: 1px solid #6b7d91; padding-left: 24px; }
.header-tools { display: flex; border-left: 1px solid #6b7d91; }
.header-button {
  min-width: 120px;
  padding: 10px 18px;
  border: 0;
  border-left: 1px solid #6b7d91;
  color: #fff;
  background: var(--navy-2);
  font-weight: 700;
}
.header-button:hover { background: #2d4d70; }
.header-button small { display: block; margin-top: 3px; color: #d7e0e9; font-size: .73rem; font-weight: 400; }
#timer { font-variant-numeric: tabular-nums; }
#timer.warning { color: #ffd65c; }

main { min-height: 0; }
.screen { min-height: calc(100vh - 149px); padding: 34px clamp(20px, 5vw, 72px); }
.start-screen, .result-screen { display: grid; place-items: center; }
.instruction-card, .score-card, .review-card {
  width: min(920px, 100%);
  padding: clamp(28px, 5vw, 52px);
  border: 1px solid var(--border);
  background: var(--paper);
  box-shadow: 0 3px 12px rgba(18, 38, 63, .12);
}
.kicker { margin: 0 0 9px; color: var(--navy-2); font-size: .9rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
h1 { margin: 0; color: var(--navy); font-size: clamp(2rem, 5vw, 3.4rem); line-height: 1.08; }
.rule { height: 4px; margin: 24px 0 28px; background: var(--navy); }
.instruction-card p, .instruction-card li { line-height: 1.6; }
.instruction-card ul { margin: 24px 0 18px; padding-left: 24px; }
.source-note { margin: 0 0 28px; color: var(--muted); font-size: .9rem; }
.start-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: flex-end; }

.primary-button, .secondary-button, .footer-button {
  min-height: 44px;
  padding: 10px 22px;
  border: 1px solid #66717c;
  border-radius: 3px;
  font-weight: 700;
}
.primary-button { color: #fff; background: var(--blue); border-color: #06477f; }
.primary-button:hover { background: #084e89; }
.secondary-button, .footer-button { color: var(--ink); background: linear-gradient(#fff, #dfe4e8); }
.secondary-button:hover, .footer-button:hover { background: #dce2e7; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.exam-screen { background: #fff; }
.question-shell { width: min(1140px, 100%); margin: 0 auto; }
.question-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 14px;
  border-bottom: 2px solid var(--navy);
  color: var(--navy);
}
.question-status > div { display: flex; align-items: center; gap: 12px; }
.section-badge { padding: 4px 9px; border: 1px solid #9eabb7; border-radius: 999px; color: var(--muted); font-size: .78rem; font-weight: 700; }
.mark-control { display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 700; }
.mark-control input { width: 20px; height: 20px; accent-color: #ad7d00; }
.question-content { padding: 30px 0 86px; font-family: Georgia, "Times New Roman", serif; font-size: 1.15rem; line-height: 1.7; }
.directions {
  margin-bottom: 25px;
  padding: 12px 15px;
  border: 1px solid #68747f;
  background: #f3f5f7;
  font-family: Arial, Helvetica, sans-serif;
  font-size: .93rem;
  font-weight: 700;
  line-height: 1.4;
}
.passage-card {
  max-width: 980px;
  margin: 0 0 30px;
  padding: 24px clamp(20px, 4vw, 36px);
  border: 1px solid #b9c1c8;
  background: #fafbfc;
}
.passage-label { margin: 0 0 13px; color: var(--navy-2); font-family: Arial, sans-serif; font-size: .78rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.passage-card p { margin: 0; }
.passage-card p + p { margin-top: 1em; }
.question-stem { max-width: 980px; margin: 0 0 24px; }
.blank-token { display: inline-block; min-width: 7.2em; padding: 0 .3em; border-bottom: 2px solid currentColor; color: transparent; user-select: none; }

.choices { display: grid; gap: 9px; max-width: 900px; margin-top: 18px; }
.choice {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 12px;
  align-items: start;
  padding: 11px 14px;
  border: 1px solid transparent;
  border-radius: 3px;
  cursor: pointer;
}
.choice:hover { background: #f2f5f7; border-color: #c8cfd5; }
.choice input { width: 19px; height: 19px; margin: 3px 0 0; accent-color: var(--navy); }
.choice-key { width: 27px; height: 27px; display: grid; place-items: center; border: 1.5px solid var(--ink); border-radius: 50%; font-family: Arial, sans-serif; font-size: .85rem; line-height: 1; }
.multi .choice-key { border-radius: 0; }
.choice-text { padding-top: 1px; }

.blank-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 22px; max-width: 980px; margin-top: 28px; }
.blank-group { padding: 18px; border: 1px solid #aeb7bf; background: #fafbfc; }
.blank-group h3 { margin: 0 0 12px; color: var(--navy); font-family: Arial, sans-serif; font-size: .92rem; }
.blank-group .choice { grid-template-columns: 31px 1fr; padding: 8px 6px; }

.test-footer {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  border-top: 1px solid #858f98;
  background: #dce1e5;
}
.footer-left, .footer-right { display: flex; gap: 10px; }
.footer-button.next { min-width: 100px; color: #fff; background: var(--navy-2); border-color: var(--navy); }
.footer-button:disabled { opacity: .45; cursor: not-allowed; }

.review-screen { background: var(--canvas); }
.review-card { margin: 0 auto; }
.review-summary { margin: 22px 0; color: var(--muted); font-size: 1.05rem; }
.review-legend { display: flex; flex-wrap: wrap; gap: 20px; margin: 24px 0; font-size: .9rem; }
.review-legend span { display: flex; align-items: center; gap: 7px; }
.legend-box { width: 18px; height: 18px; display: inline-block; border: 1px solid #6b757e; background: #fff; }
.legend-box.answered { background: #dbe9f5; }
.legend-box.marked { background: var(--mark); }
.review-group + .review-group { margin-top: 24px; }
.review-group h2 { margin: 0 0 10px; color: var(--navy); font-size: 1rem; }
.review-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.review-question { min-height: 58px; border: 1px solid #7e8891; background: #fff; font-weight: 700; }
.review-question.answered { background: #dbe9f5; }
.review-question.marked { box-shadow: inset 0 0 0 5px var(--mark); }
.review-note { margin: 22px 0 0; color: var(--muted); }

.modal { width: min(520px, calc(100% - 30px)); padding: 0; border: 1px solid #6f7880; box-shadow: 0 15px 50px rgba(0, 0, 0, .35); }
.modal::backdrop { background: rgba(10, 20, 32, .45); }
.modal form { padding: 28px; }
.modal h2 { margin: 0 0 14px; color: var(--navy); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 26px; }

.score-card { text-align: center; }
.score-display { width: 240px; height: 240px; margin: 34px auto; display: flex; flex-direction: column; align-items: center; justify-content: center; border: 9px solid var(--navy); border-radius: 50%; }
.score-display > span { color: var(--muted); font-weight: 700; }
.score-display strong { margin-top: 5px; color: var(--navy); font-size: 4.7rem; line-height: 1; }
.score-display small { margin-left: 7px; font-size: 1.15rem; }
.result-details { display: grid; grid-template-columns: 1fr 1fr; max-width: 520px; margin: 0 auto 26px; border: 1px solid var(--light-border); }
.result-details div { padding: 18px; }
.result-details div + div { border-left: 1px solid var(--light-border); }
.result-details span, .result-details strong { display: block; }
.result-details span { color: var(--muted); font-size: .86rem; }
.result-details strong { margin-top: 6px; color: var(--navy); font-size: 1.25rem; }
.score-note { max-width: 620px; margin: 0 auto 28px; color: var(--muted); line-height: 1.55; }

@media (max-width: 720px) {
  .test-header { min-height: 64px; }
  .header-title { padding: 10px 14px; gap: 10px; }
  .section-name { font-size: 1rem; }
  .header-title > span:last-child { display: none; }
  .header-button { min-width: 88px; padding: 8px; font-size: .82rem; }
  .screen { padding: 22px 14px; }
  .question-content { font-size: 1.04rem; }
  .question-status > div { align-items: flex-start; flex-direction: column; gap: 5px; }
  .passage-card { padding: 18px; }
  .blank-groups { grid-template-columns: 1fr; }
  .review-grid { grid-template-columns: repeat(3, 1fr); }
  .test-footer { padding: 10px 12px; }
  .footer-button { padding-inline: 14px; }
  .result-details { grid-template-columns: 1fr; }
  .result-details div + div { border-left: 0; border-top: 1px solid var(--light-border); }
}

@media print {
  .test-header, .test-footer, .start-screen, .review-screen, .result-screen, dialog { display: none !important; }
  .exam-screen { display: block !important; padding: 0; }
}
