:root {
  color-scheme: light;
  --navy: #15324a;
  --blue: #176b87;
  --blue-dark: #10556d;
  --sky: #eaf5f8;
  --paper: #ffffff;
  --ink: #1c2730;
  --muted: #60717d;
  --line: #d7e1e6;
  --good: #18794e;
  --good-bg: #e8f6ef;
  --bad: #b42318;
  --bad-bg: #fff0ee;
  --warning: #b54708;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: linear-gradient(145deg, #eef7f8 0%, #f7fafb 48%, #e7f0f4 100%);
}

button, input { font: inherit; }

.app-shell {
  width: min(920px, calc(100% - 32px));
  margin: 0 auto;
  padding: 36px 0 48px;
}

.site-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--blue);
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; color: var(--navy); font-size: clamp(1.5rem, 4vw, 2.15rem); }
h2 { margin-bottom: 12px; color: var(--navy); font-size: clamp(1.55rem, 4vw, 2rem); }
h3 { color: var(--navy); }
p, li { line-height: 1.65; }

.exam-status {
  display: flex;
  gap: 10px;
  align-items: center;
  font-weight: 700;
}

#progress, #timer {
  min-width: 82px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.85);
  text-align: center;
}

#progress:empty, #timer:empty { display: none; }
#timer.timer-warning { color: var(--warning); border-color: #f2c185; background: #fff8eb; }

.card {
  padding: clamp(24px, 5vw, 52px);
  border: 1px solid rgba(21, 50, 74, .1);
  border-radius: 22px;
  background: var(--paper);
  box-shadow: 0 22px 55px rgba(21, 50, 74, .1);
}

.lead { color: var(--muted); font-size: 1.08rem; }
.question-label { margin-bottom: 10px; color: var(--blue); font-size: .83rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.question-prompt { margin-bottom: 26px; font-size: clamp(1.25rem, 3vw, 1.62rem); line-height: 1.45; }

.field { display: grid; gap: 8px; margin: 20px 0; }
.field label { color: var(--navy); font-weight: 700; }
.field input {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid #b8c7cf;
  border-radius: 10px;
  color: var(--ink);
  background: #fff;
}

.field input:focus, button:focus-visible, .option:focus-within {
  outline: 3px solid rgba(23, 107, 135, .24);
  outline-offset: 2px;
}

.options { display: grid; gap: 12px; margin: 24px 0 30px; }
.option {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: start;
  padding: 15px 17px;
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .15s;
}
.option:hover { border-color: #8fb5c3; background: #f8fcfd; transform: translateY(-1px); }
.option input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--blue); }
.option.correct { border-color: #79b99c; background: var(--good-bg); }
.option.incorrect { border-color: #e29d96; background: var(--bad-bg); }
.option-key { font-weight: 800; }

.actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 28px; }
button {
  min-height: 46px;
  padding: 11px 20px;
  border: 0;
  border-radius: 10px;
  color: #fff;
  background: var(--blue);
  font-weight: 750;
  cursor: pointer;
}
button:hover { background: var(--blue-dark); }
button:disabled { cursor: not-allowed; opacity: .45; }
.secondary-button { color: var(--navy); border: 1px solid var(--line); background: #fff; }
.secondary-button:hover { background: var(--sky); }

.error { margin: 12px 0 0; color: var(--bad); font-weight: 650; }
.connection-error {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  margin-top: 24px;
  padding: 16px;
  border: 1px solid #e29d96;
  border-radius: 12px;
  background: var(--bad-bg);
}
.connection-error .error { margin: 0; }
.rule-list { padding-left: 22px; }
.rule-list li + li { margin-top: 8px; }
.result-banner { margin: 20px 0; padding: 16px 18px; border-radius: 12px; font-weight: 800; }
.result-banner.correct { color: var(--good); background: var(--good-bg); }
.result-banner.incorrect { color: var(--bad); background: var(--bad-bg); }
.explanation { padding: 18px; border-left: 4px solid var(--blue); background: var(--sky); }

.result-certificate { padding: 8px; }
.certificate-heading { padding-bottom: 20px; border-bottom: 2px solid var(--navy); text-align: center; }
.score { margin: 30px 0 6px; color: var(--blue); font-size: clamp(3.5rem, 14vw, 6.5rem); font-weight: 850; line-height: 1; text-align: center; }
.score-caption { margin-bottom: 34px; color: var(--muted); text-align: center; }
.result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 28px 0; }
.result-item { padding: 15px; border: 1px solid var(--line); border-radius: 10px; }
.result-item span { display: block; margin-bottom: 5px; color: var(--muted); font-size: .8rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.assessment { margin: 26px 0; padding: 20px; border-radius: 12px; background: var(--sky); font-size: 1.08rem; }
.print-note { color: var(--muted); font-size: .9rem; }

@media (max-width: 620px) {
  .app-shell { width: min(100% - 20px, 920px); padding-top: 20px; }
  .site-header { align-items: flex-start; flex-direction: column; gap: 14px; }
  .exam-status { width: 100%; }
  #progress, #timer { flex: 1; }
  .card { border-radius: 16px; }
  .result-grid { grid-template-columns: 1fr; }
  .actions button { width: 100%; }
}

@media print {
  @page { size: A4; margin: 18mm; }
  body { min-height: auto; background: #fff; }
  .app-shell { width: 100%; margin: 0; padding: 0; }
  .site-header, .no-print, body > *:not(.app-shell) { display: none !important; }
  .card { padding: 0; border: 0; box-shadow: none; }
  .result-certificate { display: block; color: #000; }
  .result-item, .assessment { break-inside: avoid; }
}
