:root {
  --navy: #12263f;
  --navy-2: #203b5a;
  --paper: #ffffff;
  --canvas: #edf0f3;
  --ink: #15191e;
  --muted: #5e6873;
  --border: #9aa3ac;
  --light-border: #d7dce1;
  --button: #e8ebee;
  --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(900px, 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 32px; padding-left: 24px; }
.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(1120px, 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);
}
.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 80px; font-family: Georgia, "Times New Roman", serif; font-size: 1.16rem; line-height: 1.6; }
.question-content p { margin-top: 0; }
.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;
}
.question-stem { max-width: 980px; }
.question-index { margin-right: 8px; font-weight: 700; }

.qc-context { margin-bottom: 24px; text-align: center; }
.quantity-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; margin: 30px 0; }
.quantity-box { min-height: 112px; padding: 18px; text-align: center; border-top: 2px solid var(--ink); }
.quantity-box strong { display: block; margin-bottom: 12px; text-decoration: underline; text-underline-offset: 5px; }
.quantity-box span { display: block; }

.choices { display: grid; gap: 10px; max-width: 830px; margin-top: 26px; }
.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: 2px 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; }

.numeric-entry { margin-top: 30px; display: flex; align-items: center; gap: 12px; }
.numeric-entry input { width: 180px; padding: 12px; border: 2px solid #4d5964; font-size: 1.2rem; text-align: center; }

.fraction-entry { margin-top: 30px; display: grid; justify-content: center; gap: 7px; }
.fraction-entry input { width: 104px; padding: 9px 12px; border: 2px solid #4d5964; font-size: 1.2rem; text-align: center; }
.fraction-line { height: 2px; background: #252a2f; }

.data-block { max-width: 920px; margin: 0 auto 34px; padding: 22px; border: 1px solid #9da6ae; background: #fafbfc; font-size: 1rem; }
.data-title { margin: 0 0 18px; font-weight: 700; text-align: center; letter-spacing: .02em; }
.data-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; align-items: end; }
.data-table { width: 100%; border-collapse: collapse; font-family: Georgia, serif; }
.data-table th, .data-table td { padding: 7px 10px; border: 1px solid #2e353b; text-align: center; }
.data-table th { background: #eef1f3; }
.data-note { margin: 10px 0 0; text-align: center; font-size: .9rem; }

.compact-data { max-width: 690px; }
.bird-data { max-width: 820px; }
.bird-data .data-table td:first-child { text-align: left; font-weight: 700; }
.table-scroll { overflow-x: auto; }
.coordinate-plane { width: min(560px, 100%); margin: 0 auto 32px; padding: 10px 18px; border: 1px solid #9da6ae; background: #fafbfc; }
.coordinate-plane svg { display: block; width: 100%; height: auto; }
.normal-figure { width: min(790px, 100%); margin: 0 auto 30px; padding: 12px 18px 4px; border: 1px solid #9da6ae; background: #fafbfc; }
.normal-figure svg { display: block; width: 100%; height: auto; }
.geometry-figure { width: min(620px, 100%); margin: 0 auto 26px; padding: 8px 16px; border: 1px solid #9da6ae; background: #fafbfc; }
.geometry-figure svg { display: block; width: 100%; height: auto; }
.triangle-figure { width: min(470px, 100%); }

.internet-visuals { display: grid; grid-template-columns: .8fr 1.4fr; gap: 30px; align-items: center; }
.pie-panel, .europe-panel { min-width: 0; }
.pie-chart {
  width: min(260px, 85vw); aspect-ratio: 1; margin: 12px auto 0; position: relative; border: 2px solid #303840; border-radius: 50%;
  background: conic-gradient(#73869b 0 51%, #a4b1be 51% 80%, #e0e5ea 80% 85%, #c6d0d9 85% 100%);
}
.pie-chart::after { content: ""; position: absolute; inset: 46%; border-radius: 50%; background: #303840; }
.pie-label { position: absolute; z-index: 1; padding: 2px 4px; background: rgba(255,255,255,.84); font-family: Arial, sans-serif; font-size: .76rem; text-align: center; }
.pie-us { right: 5%; top: 45%; }.pie-europe { left: 5%; bottom: 23%; }.pie-japan { left: 7%; top: 24%; }.pie-rest { left: 37%; top: 6%; }
.internet-bars { height: 290px; display: grid; grid-template-columns: 42px 1fr; grid-template-rows: 1fr 48px; gap: 0 8px; font-family: Arial, sans-serif; }
.internet-bars .plot { padding-inline: 4px; }
.internet-bars .bar-wrap { width: 13%; }
.internet-bars .bar-wrap span { bottom: -47px; transform: rotate(-34deg); transform-origin: center; white-space: nowrap; font-size: .68rem; }

.bar-chart { height: 260px; display: grid; grid-template-columns: 42px 1fr; grid-template-rows: 1fr 34px; gap: 0 8px; font-family: Arial, sans-serif; }
.y-label { grid-row: 1; writing-mode: vertical-rl; transform: rotate(180deg); display: grid; place-items: center; font-size: .8rem; }
.plot { grid-column: 2; position: relative; display: flex; align-items: end; justify-content: space-around; padding: 0 12px; border-left: 2px solid #333; border-bottom: 2px solid #333; background: repeating-linear-gradient(to top, transparent 0, transparent calc(16.666% - 1px), #ccd2d7 calc(16.666% - 1px), #ccd2d7 16.666%); }
.bar-wrap { width: 19%; height: 100%; display: flex; align-items: end; justify-content: center; position: relative; }
.bar { width: 70%; background: #8995a0; border: 1px solid #30383f; }
.bar-wrap span { position: absolute; bottom: -29px; font-size: .78rem; }
.x-label { grid-column: 2; padding-top: 26px; text-align: center; font-size: .8rem; }

.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); }
.legend-box.incomplete { background: #fff; }
.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, .calculator::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; }

.calculator { width: 330px; padding: 0; border: 1px solid #34414c; border-radius: 3px; box-shadow: 0 12px 40px rgba(0,0,0,.35); }
.calculator-top { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; color: #fff; background: var(--navy); }
.calculator-top button { width: 30px; height: 30px; border: 0; color: #fff; background: transparent; font-size: 1.5rem; }
#calculatorDisplay { min-height: 70px; display: flex; align-items: end; justify-content: flex-end; padding: 16px; overflow: hidden; background: #f4f6f7; border-bottom: 1px solid #aab2b9; font-size: 1.75rem; font-variant-numeric: tabular-nums; }
.calculator-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: #9aa3aa; }
.calculator-grid button { min-height: 54px; border: 0; background: #fff; }
.calculator-grid button:hover { background: #e7ecef; }
.calculator-grid .equals { color: #fff; background: var(--blue); }

.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.06rem; }
  .quantity-grid, .data-layout { grid-template-columns: 1fr; }
  .internet-visuals { grid-template-columns: 1fr; }
  .quantity-grid { gap: 12px; }
  .data-block { padding: 12px; overflow-x: auto; }
  .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; }
}
