:root {
  --navy: #173b57;
  --navy-deep: #0d293d;
  --blue: #2d7fa8;
  --sky: #dff2fb;
  --green: #4c7b55;
  --green-soft: #e5f2e4;
  --gold: #e8b94f;
  --gold-soft: #fff4d2;
  --orange: #e7853b;
  --ink: #173042;
  --muted: #5f7180;
  --paper: #ffffff;
  --background: #f2f7f9;
  --border: #cfdee5;
  --danger: #a63636;
  --danger-soft: #fff0f0;
  --success: #267245;
  --success-soft: #e9f7ef;
  --shadow: 0 20px 60px rgba(23, 59, 87, 0.12);
  --radius: 22px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 0%, rgba(223, 242, 251, 0.95), transparent 35%),
    radial-gradient(circle at 90% 15%, rgba(255, 244, 210, 0.85), transparent 30%),
    var(--background);
  font-family: Inter, ui-rounded, "Segoe UI", Arial, sans-serif;
  line-height: 1.55;
}

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

.skip-link {
  position: fixed;
  left: 1rem;
  top: -5rem;
  z-index: 1000;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  color: white;
  background: var(--navy-deep);
}
.skip-link:focus { top: 1rem; }

.site-header {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2.1rem 0 1.1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.site-header h1 {
  margin: 0;
  color: var(--navy);
  font-size: clamp(1.45rem, 2.6vw, 2.25rem);
  line-height: 1.1;
}

.subtitle, .site-header .eyebrow { margin: 0.1rem 0 0; }
.subtitle { color: var(--muted); }

.brand-mark {
  width: 72px;
  height: 72px;
  position: relative;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 22px;
  color: white;
  background: linear-gradient(145deg, var(--blue), var(--navy));
  box-shadow: 0 12px 28px rgba(23, 59, 87, 0.22);
  overflow: hidden;
}
.brand-core { font-size: 2rem; z-index: 2; }
.brand-orbit {
  position: absolute;
  width: 48px;
  height: 25px;
  border: 2px solid rgba(255, 255, 255, 0.75);
  border-radius: 50%;
  transform: rotate(-25deg);
}
.brand-orbit::after {
  content: "";
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
  top: -3px;
  right: 7px;
}

.app-shell {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto 3rem;
}

.panel {
  border: 1px solid rgba(207, 222, 229, 0.9);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
  padding: clamp(1.25rem, 3vw, 2.5rem);
}

.screen { display: none; }
.screen.active { display: block; animation: fade-in 250ms ease both; }
.hidden { display: none !important; }

@keyframes fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(310px, 0.65fr);
  gap: clamp(1.5rem, 4vw, 3rem);
  align-items: start;
}

.eyebrow {
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.pill {
  display: inline-flex;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  color: var(--navy);
  background: var(--sky);
  font-size: 0.82rem;
  font-weight: 800;
}

h2 {
  margin: 0.6rem 0 0.7rem;
  color: var(--navy-deep);
  font-size: clamp(1.8rem, 4vw, 3.3rem);
  line-height: 1.08;
}

.lead {
  max-width: 760px;
  color: var(--muted);
  font-size: clamp(1rem, 1.7vw, 1.16rem);
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.9rem;
  margin-top: 1.8rem;
}

.feature-card {
  border: 1px solid var(--border);
  border-radius: 17px;
  padding: 1rem;
  background: linear-gradient(180deg, white, #f9fcfd);
}
.feature-card > span { font-size: 1.7rem; }
.feature-card h3 { margin: 0.45rem 0 0.25rem; color: var(--navy); font-size: 1rem; }
.feature-card p { margin: 0; color: var(--muted); font-size: 0.9rem; }

.student-card {
  position: sticky;
  top: 1rem;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 1.35rem;
  background: linear-gradient(155deg, #ffffff, #f3fafc);
}
.student-card h3 { margin: 0 0 1rem; color: var(--navy); }
.student-card label {
  display: block;
  margin: 0.8rem 0 0.3rem;
  color: var(--navy-deep);
  font-weight: 750;
}
.optional { color: var(--muted); font-size: 0.85rem; font-weight: 500; }

input, select {
  width: 100%;
  min-height: 48px;
  border: 1px solid #b9ccd6;
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
  color: var(--ink);
  background: white;
}
input:focus, select:focus, button:focus-visible {
  outline: 3px solid rgba(45, 127, 168, 0.25);
  outline-offset: 2px;
  border-color: var(--blue);
}
.input-error { border-color: var(--danger) !important; background: var(--danger-soft); }
.field-error { min-height: 1.2rem; margin: 0.25rem 0 0; color: var(--danger); font-size: 0.86rem; }

.privacy-note {
  margin: 1rem 0;
  border-left: 4px solid var(--green);
  padding: 0.8rem;
  border-radius: 0 10px 10px 0;
  color: var(--muted);
  background: var(--green-soft);
  font-size: 0.86rem;
}

.primary-button, .secondary-button, .icon-button {
  min-height: 46px;
  border-radius: 12px;
  padding: 0.72rem 1rem;
  font-weight: 800;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}
.primary-button:hover, .secondary-button:hover, .icon-button:hover { transform: translateY(-1px); }
.primary-button {
  border: 1px solid var(--navy);
  color: white;
  background: linear-gradient(145deg, var(--blue), var(--navy));
  box-shadow: 0 8px 20px rgba(23, 59, 87, 0.18);
}
.primary-button:hover { box-shadow: 0 11px 24px rgba(23, 59, 87, 0.25); }
.secondary-button, .icon-button {
  border: 1px solid #b8cbd5;
  color: var(--navy);
  background: white;
}
.secondary-button:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.full-width { width: 100%; margin-top: 0.55rem; }

.test-toolbar, .progress-meta, .question-topline, .navigation-row, .certificate-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}
.test-toolbar h2 { margin: 0; font-size: clamp(1.5rem, 3vw, 2.25rem); }
.icon-button { display: inline-flex; align-items: center; gap: 0.45rem; }

.progress-wrap { margin: 1.25rem 0 1.5rem; }
.progress-meta { margin-bottom: 0.45rem; color: var(--muted); font-size: 0.9rem; font-weight: 700; }
.progress-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e1ebef;
}
.progress-bar {
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--green), var(--gold));
  transition: width 220ms ease;
}

.question-card {
  max-width: 900px;
  margin: 0 auto;
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: clamp(1rem, 3vw, 2rem);
  background: linear-gradient(180deg, white, #fbfdfe);
}
.question-topline { justify-content: flex-start; }
.question-icon {
  width: 68px;
  height: 68px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 19px;
  background: var(--gold-soft);
  font-size: 2rem;
}
.question-kicker { margin: 0; color: var(--green); font-weight: 800; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.1em; }
.question-card h3 { margin: 0.15rem 0 0; color: var(--navy); font-size: clamp(1.25rem, 3vw, 1.85rem); }

.formula-box {
  margin: 1.25rem 0;
  display: grid;
  grid-template-columns: minmax(220px, 0.65fr) minmax(0, 1.35fr);
  gap: 1rem;
  align-items: center;
  border: 1px solid #cbdde5;
  border-radius: 16px;
  padding: 1rem;
  background: var(--sky);
}
.formula-box span { display: block; color: var(--muted); font-size: 0.76rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.1em; }
.formula-box strong { display: block; margin-top: 0.15rem; color: var(--navy-deep); font-size: clamp(1.2rem, 3vw, 1.75rem); }
.formula-box p { margin: 0; color: #3d596b; }

.question-prompt { margin: 1.2rem 0; color: var(--ink); font-size: clamp(1.08rem, 2.2vw, 1.3rem); font-weight: 720; }
.answer-options { margin: 0; padding: 0; border: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.8rem; }
.answer-option { position: relative; }
.answer-option input { position: absolute; opacity: 0; pointer-events: none; }
.answer-option label {
  min-height: 66px;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border: 2px solid var(--border);
  border-radius: 15px;
  padding: 0.8rem 1rem;
  color: var(--navy-deep);
  background: white;
  font-weight: 800;
  cursor: pointer;
  transition: border 120ms ease, background 120ms ease, transform 120ms ease;
}
.answer-option label:hover { border-color: #8db6c9; transform: translateY(-1px); }
.answer-option input:checked + label { border-color: var(--blue); background: var(--sky); box-shadow: 0 0 0 3px rgba(45, 127, 168, 0.11); }
.answer-option input:focus-visible + label { outline: 3px solid rgba(45, 127, 168, 0.25); outline-offset: 2px; }
.answer-letter {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  color: white;
  background: var(--navy);
}

.question-help { min-height: 1.5rem; margin-top: 0.9rem; color: var(--danger); font-weight: 700; }
.navigation-row { max-width: 900px; margin: 1.25rem auto 0; }

.question-map-wrap { max-width: 900px; margin: 1rem auto 0; text-align: center; }
.text-button { border: 0; padding: 0.45rem; color: var(--blue); background: transparent; font-weight: 800; text-decoration: underline; text-underline-offset: 3px; }
.question-map { margin-top: 0.8rem; display: grid; grid-template-columns: repeat(10, 1fr); gap: 0.4rem; }
.map-button {
  aspect-ratio: 1;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--navy);
  background: white;
  font-weight: 800;
}
.map-button.answered { color: var(--success); border-color: #88c39f; background: var(--success-soft); }
.map-button.current { color: white; border-color: var(--navy); background: var(--navy); }

.notice {
  margin: 1.2rem 0;
  border-radius: 14px;
  padding: 1rem;
  color: var(--muted);
  background: #f4f8fa;
}
.notice.warning { color: #6d4d05; background: var(--gold-soft); border: 1px solid #ecd17f; }
.review-question-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 0.6rem; margin: 1rem 0 1.5rem; }
.review-jump {
  min-height: 48px;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--navy);
  background: white;
  font-weight: 800;
}
.review-jump.answered { color: var(--success); background: var(--success-soft); border-color: #9acbab; }
.review-jump.unanswered { color: var(--danger); background: var(--danger-soft); border-color: #e0aaaa; }

.results-hero { display: flex; align-items: center; gap: 1.25rem; }
.result-medal { width: 100px; height: 100px; display: grid; place-items: center; border-radius: 50%; background: var(--gold-soft); font-size: 3.5rem; }
.results-hero h2 { margin: 0.1rem 0; }
.results-hero .lead { margin: 0; }
.score-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin: 1.7rem 0; }
.score-card { border: 1px solid var(--border); border-radius: 17px; padding: 1.2rem; background: #fbfdfe; }
.score-card span { display: block; color: var(--muted); font-size: 0.82rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; }
.score-card strong { display: block; margin-top: 0.4rem; color: var(--navy); font-size: clamp(1.35rem, 3vw, 2rem); line-height: 1.1; }
.featured-score { background: linear-gradient(145deg, var(--navy), var(--blue)); }
.featured-score span, .featured-score strong { color: white; }
.action-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.7rem; }
.answer-review { margin-top: 1.5rem; border-top: 1px solid var(--border); padding-top: 1rem; }
.review-answer-card { margin: 0.75rem 0; border: 1px solid var(--border); border-left-width: 6px; border-radius: 13px; padding: 1rem; }
.review-answer-card.correct { border-left-color: var(--success); background: var(--success-soft); }
.review-answer-card.incorrect { border-left-color: var(--danger); background: var(--danger-soft); }
.review-answer-card h4 { margin: 0 0 0.35rem; color: var(--navy); }
.review-answer-card p { margin: 0.2rem 0; }
.restart-row { text-align: center; margin-top: 1.5rem; }
.danger-text { color: var(--danger); }

.certificate-panel { background: #eef4f6; }
.certificate-actions { margin-bottom: 1rem; }
.certificate-actions > div { display: flex; gap: 0.6rem; }
.certificate {
  width: min(100%, 1050px);
  aspect-ratio: 1.4545 / 1;
  margin: 0 auto;
  padding: 15px;
  color: var(--navy-deep);
  background: white;
  box-shadow: 0 14px 36px rgba(13, 41, 61, 0.18);
}
.certificate-border {
  height: 100%;
  position: relative;
  overflow: hidden;
  border: 8px double var(--navy);
  padding: clamp(1rem, 4vw, 3.2rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  background:
    linear-gradient(135deg, rgba(223,242,251,.7), transparent 22%),
    linear-gradient(315deg, rgba(255,244,210,.75), transparent 22%),
    #fffefa;
}
.certificate-corner { position: absolute; width: 150px; height: 150px; border: 2px solid rgba(232,185,79,.55); transform: rotate(45deg); }
.corner-one { top: -105px; left: -105px; }
.corner-two { top: -105px; right: -105px; }
.corner-three { bottom: -105px; left: -105px; }
.corner-four { bottom: -105px; right: -105px; }
.certificate-brand { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 0.4rem 0.7rem; }
.certificate-brand p { margin: 0; color: var(--navy); font-weight: 900; font-size: clamp(0.9rem, 2vw, 1.15rem); text-transform: uppercase; letter-spacing: 0.08em; }
.certificate-brand span { width: 100%; color: var(--green); font-weight: 750; font-size: clamp(0.65rem, 1.5vw, 0.85rem); }
.certificate-seal { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; color: white; background: var(--navy); }
.certificate-overline { margin: clamp(0.7rem, 2vw, 1.3rem) 0 0; color: var(--gold); font-size: clamp(0.75rem, 1.5vw, 1rem); font-weight: 900; letter-spacing: 0.2em; text-transform: uppercase; }
.certificate h3 { margin: 0.3rem 0 clamp(0.6rem, 2vw, 1.1rem); color: var(--navy); font-family: Georgia, serif; font-size: clamp(1.5rem, 4vw, 3.2rem); line-height: 1.05; }
.certificate-copy { margin: 0.3rem 0; max-width: 780px; color: #435c6c; font-family: Georgia, serif; font-size: clamp(0.75rem, 1.7vw, 1.1rem); }
.certificate-name { width: min(80%, 700px); margin: clamp(0.35rem, 1.4vw, 0.8rem) auto; border-bottom: 2px solid var(--gold); padding: 0 1rem 0.25rem; color: var(--navy-deep); font-family: "Brush Script MT", "Segoe Script", cursive; font-size: clamp(1.8rem, 5vw, 4.2rem); line-height: 1.08; }
.certificate-score-row { width: min(90%, 820px); margin: clamp(0.6rem, 2vw, 1.25rem) auto; display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid #d8c57b; border-bottom: 1px solid #d8c57b; }
.certificate-score-row > div { padding: clamp(0.45rem, 1.5vw, 0.9rem); }
.certificate-score-row > div + div { border-left: 1px solid #e7dcae; }
.certificate-score-row span { display: block; color: var(--muted); font-size: clamp(0.55rem, 1.1vw, 0.75rem); font-weight: 800; text-transform: uppercase; letter-spacing: 0.09em; }
.certificate-score-row strong { display: block; margin-top: 0.2rem; color: var(--navy); font-size: clamp(0.75rem, 1.7vw, 1.2rem); }
.certificate-footer { width: 100%; margin-top: auto; display: grid; grid-template-columns: 1fr auto 1fr; gap: 1rem; align-items: end; }
.signature-block span { display: block; min-height: 1.4em; border-bottom: 1px solid var(--navy); padding-bottom: 0.2rem; font-family: Georgia, serif; font-weight: 700; }
.signature-block small { display: block; margin-top: 0.25rem; color: var(--muted); font-size: clamp(0.5rem, 1.2vw, 0.72rem); }
.certificate-badge { width: clamp(62px, 10vw, 95px); aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; border: 3px solid var(--gold); border-radius: 50%; color: var(--navy); background: var(--gold-soft); line-height: 1; }
.certificate-badge span, .certificate-badge small { font-size: clamp(0.42rem, 0.9vw, 0.62rem); font-weight: 900; }
.certificate-badge strong { color: var(--gold); font-size: clamp(1rem, 2.5vw, 1.8rem); }
.certificate-id { margin: 0.45rem 0 -0.2rem; color: #84939c; font-size: clamp(0.45rem, 1vw, 0.65rem); }

.site-footer { width: min(1180px, calc(100% - 2rem)); margin: 0 auto; padding: 0 0 2rem; text-align: center; color: var(--muted); font-size: 0.86rem; }
.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }

@media (max-width: 900px) {
  .hero-grid { grid-template-columns: 1fr; }
  .student-card { position: static; }
  .feature-grid { grid-template-columns: 1fr; }
  .action-grid { grid-template-columns: repeat(2, 1fr); }
  .question-map { grid-template-columns: repeat(7, 1fr); }
}

@media (max-width: 650px) {
  .site-header { align-items: flex-start; padding-top: 1.1rem; }
  .brand-mark { width: 56px; height: 56px; border-radius: 17px; }
  .panel { padding: 1rem; border-radius: 17px; }
  .test-toolbar { align-items: flex-start; }
  .icon-button span { display: none; }
  .formula-box { grid-template-columns: 1fr; }
  .answer-options { grid-template-columns: 1fr; }
  .review-question-grid { grid-template-columns: repeat(4, 1fr); }
  .score-grid { grid-template-columns: 1fr; }
  .action-grid { grid-template-columns: 1fr; }
  .results-hero { align-items: flex-start; }
  .result-medal { width: 70px; height: 70px; font-size: 2.4rem; }
  .certificate-actions { align-items: stretch; flex-direction: column; }
  .certificate-actions > div { display: grid; grid-template-columns: 1fr 1fr; }
  .certificate { padding: 5px; }
  .certificate-border { border-width: 4px; padding: 0.7rem; }
  .certificate-score-row { width: 100%; }
  .certificate-footer { gap: 0.4rem; }
  .signature-block span { font-size: 0.52rem; }
  .question-map { grid-template-columns: repeat(5, 1fr); }
}

@media print {
  @page { size: landscape; margin: 0.25in; }
  body { background: white; }
  body * { visibility: hidden !important; }
  #certificateScreen, #certificateScreen * { visibility: visible !important; }
  #certificateScreen { display: block !important; position: absolute; inset: 0; padding: 0; border: 0; box-shadow: none; background: white; }
  .no-print, .site-header, .site-footer { display: none !important; }
  .certificate { width: 100%; height: 100%; max-width: none; margin: 0; padding: 0; box-shadow: none; }
  .certificate-border { break-inside: avoid; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}
