:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-soft: #eef4f1;
  --text: #1f2933;
  --muted: #607080;
  --line: #d8dfda;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --accent-soft: #dcefed;
  --success: #15803d;
  --success-soft: #dcfce7;
  --warning: #d97706;
  --warning-soft: #fff3d7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --shadow: 0 18px 48px rgba(31, 41, 51, 0.1);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(220, 239, 237, 0.7), rgba(246, 247, 244, 0) 320px),
    var(--bg);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

button,
a {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 64px;
  padding: 12px clamp(16px, 4vw, 40px);
  border-bottom: 1px solid rgba(216, 223, 218, 0.9);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(14px);
}

.brand {
  min-width: 0;
  padding: 0;
  border: 0;
  color: var(--text);
  background: transparent;
  font-size: clamp(1rem, 3.5vw, 1.2rem);
  font-weight: 800;
  text-align: left;
}

.global-timer {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 8px 22px rgba(31, 41, 51, 0.08);
}

.global-timer span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.global-timer strong,
.time-value {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

.global-timer.is-hidden {
  display: none;
}

.time-normal {
  color: var(--accent-strong);
}

.time-warning {
  color: var(--warning);
}

.time-danger,
.time-critical {
  color: var(--danger);
}

.time-critical {
  animation: timerBlink 1s step-end infinite;
}

@keyframes timerBlink {
  50% {
    opacity: 0.24;
  }
}

.app-shell {
  width: min(1280px, 100%);
  margin: 0 auto;
  padding: 28px clamp(16px, 4vw, 44px) 64px;
}

.view {
  display: grid;
  gap: 26px;
}

.hero {
  display: grid;
  gap: 8px;
  padding: 10px 0 4px;
}

.home-hero {
  display: grid;
  gap: 18px;
  align-items: center;
}

.eyebrow {
  margin: 0;
  color: var(--accent-strong);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 9vw, 4rem);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.35rem, 4vw, 2rem);
  line-height: 1.15;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 6px;
  font-size: 1rem;
  line-height: 1.25;
  letter-spacing: 0;
}

.lead {
  max-width: 66ch;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.tile-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.tile,
.category-button,
.answer-button,
.summary-card,
.dashboard-panel,
.result-panel,
.notice,
.empty-state {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.tile {
  display: grid;
  gap: 16px;
  align-items: center;
  justify-items: center;
  min-height: 300px;
  padding: 28px;
  color: inherit;
  text-align: center;
  text-decoration: none;
  box-shadow: 0 14px 36px rgba(31, 41, 51, 0.08);
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.tile:hover,
.tile:focus-visible,
.category-button:hover,
.category-button:focus-visible,
.answer-button:hover,
.answer-button:focus-visible {
  border-color: rgba(15, 118, 110, 0.55);
  box-shadow: 0 12px 30px rgba(15, 118, 110, 0.12);
  outline: none;
  transform: translateY(-1px);
}

.tile-symbol {
  display: grid;
  place-items: center;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 900;
}

.tile-symbol svg,
.progress-icon svg,
.footnote-icon svg,
.dashboard-note svg {
  width: 34px;
  height: 34px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tile-registration .tile-symbol {
  background: #e5efff;
  color: #1d4ed8;
}

.tile-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: min(100%, 190px);
  min-height: 48px;
  margin-top: 16px;
  padding: 10px 16px;
  border-radius: var(--radius);
  background: var(--accent);
  color: #ffffff;
  font-weight: 900;
}

.tile-cta.blue {
  background: #2563eb;
}

.tile p,
.category-button p,
.answer-button p {
  margin: 0;
  color: var(--muted);
}

.dashboard-panel,
.result-panel {
  padding: clamp(18px, 3vw, 28px);
  box-shadow: 0 14px 36px rgba(31, 41, 51, 0.08);
}

.dashboard-head,
.question-top,
.review-top,
.result-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.summary-card {
  padding: 14px;
  background: #fbfcfb;
}

.summary-card span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.summary-card strong {
  display: block;
  margin-top: 4px;
  font-size: 1.45rem;
  line-height: 1.1;
}

.progress-summary {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 10px 28px rgba(31, 41, 51, 0.08);
}

.progress-summary h2 {
  margin-bottom: 14px;
  font-size: 1.05rem;
}

.progress-summary-body {
  display: flex;
  align-items: center;
  gap: 18px;
}

.progress-summary-body p {
  margin: 0;
  color: var(--muted);
}

.progress-summary-body strong {
  display: block;
  color: var(--text);
}

.progress-ring {
  --progress: 0;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, var(--surface) 58%, transparent 60%),
    conic-gradient(var(--accent) calc(var(--progress) * 1%), var(--accent-soft) 0);
}

.progress-ring span {
  color: var(--text);
  font-size: 1.35rem;
  font-weight: 900;
}

.progress-list {
  display: grid;
  gap: 0;
  margin-top: 22px;
}

.progress-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 16px;
  align-items: center;
  padding: 18px 0;
  border-bottom: 1px solid rgba(216, 223, 218, 0.75);
}

.progress-row:last-child {
  border-bottom: 0;
}

.progress-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--accent-strong);
}

.progress-icon svg {
  width: 25px;
  height: 25px;
}

.progress-main {
  display: grid;
  gap: 8px;
}

.progress-main header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.progress-main b {
  min-width: 0;
  overflow-wrap: anywhere;
}

.progress-main strong {
  flex-shrink: 0;
  color: var(--accent-strong);
}

.progress-main small {
  flex-shrink: 0;
  color: var(--muted);
}

.bar {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e6ebe7;
}

.bar-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--success));
  transition: width 180ms ease;
}

.dashboard-note {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
  margin-top: 18px;
  padding: 14px 16px;
  border: 1px solid rgba(37, 99, 235, 0.18);
  border-radius: var(--radius);
  background: #f5f8ff;
  color: #334155;
  font-size: 0.94rem;
}

.dashboard-note svg {
  width: 22px;
  height: 22px;
  color: #2563eb;
}

.category-grid {
  display: grid;
  gap: 10px;
}

.category-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  padding: 16px;
  color: inherit;
  text-align: left;
}

.category-button strong {
  overflow-wrap: anywhere;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--accent-strong);
  font-size: 0.82rem;
  font-weight: 800;
  white-space: nowrap;
}

.question-panel {
  display: grid;
  gap: 18px;
}

.exam-header,
.question-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 12px 34px rgba(31, 41, 51, 0.07);
}

.exam-header {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  padding: 16px;
}

.exam-header strong {
  font-size: 1.12rem;
}

.exam-header span {
  color: var(--muted);
  font-weight: 700;
}

.exam-header .exam-time {
  color: inherit;
}

.question-card {
  display: grid;
  gap: 18px;
  padding: 18px;
}

.question-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.question-text {
  margin: 0;
  font-size: clamp(1.15rem, 4.5vw, 1.6rem);
  font-weight: 800;
  line-height: 1.25;
}

.answer-list {
  display: grid;
  gap: 10px;
}

.answer-button {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: start;
  width: 100%;
  min-height: 58px;
  padding: 14px;
  color: inherit;
  text-align: left;
}

.answer-id {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--accent-strong);
  font-weight: 900;
}

.answer-button.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.answer-button.is-correct {
  border-color: rgba(21, 128, 61, 0.65);
  background: var(--success-soft);
}

.answer-button.is-wrong {
  border-color: rgba(220, 38, 38, 0.65);
  background: var(--danger-soft);
}

.answer-button.is-locked {
  cursor: default;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.notice-actions {
  margin-top: 10px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-weight: 800;
  text-decoration: none;
}

.button:hover,
.button:focus-visible {
  border-color: rgba(15, 118, 110, 0.55);
  outline: none;
}

.button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.button.success {
  border-color: var(--success);
  background: var(--success);
  color: #ffffff;
}

.button.warning {
  border-color: var(--warning);
  background: var(--warning);
  color: #ffffff;
}

.button.finish {
  margin-left: auto;
  border-color: var(--warning);
  background: var(--warning);
  color: #ffffff;
}

.button.danger {
  border-color: var(--danger);
  background: var(--danger);
  color: #ffffff;
}

.notice,
.empty-state {
  padding: 14px 16px;
}

.notice {
  border-color: rgba(217, 119, 6, 0.4);
  background: var(--warning-soft);
  color: #744300;
}

.notice.success {
  border-color: rgba(21, 128, 61, 0.35);
  background: var(--success-soft);
  color: #135c2c;
}

.notice.danger {
  border-color: rgba(220, 38, 38, 0.35);
  background: var(--danger-soft);
  color: #8f1d1d;
}

.notice.neutral {
  border-color: rgba(96, 112, 128, 0.28);
  background: #f8faf9;
  color: var(--muted);
}

.home-footnotes {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  margin-top: 4px;
}

.footnote-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 14px;
  min-height: 150px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
}

.footnote-card h2 {
  margin-bottom: 8px;
  color: var(--text);
  font-size: 1rem;
}

.footnote-card p {
  margin-bottom: 8px;
  font-size: 0.94rem;
}

.footnote-content {
  display: grid;
  grid-column: 2;
  align-content: space-between;
  gap: 10px;
}

.footnote-icon {
  display: grid;
  place-items: center;
  grid-row: span 2;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.72);
  color: var(--accent-strong);
}

.footnote-icon svg {
  width: 20px;
  height: 20px;
}

.footnote-green {
  border-color: rgba(15, 118, 110, 0.24);
  background: #f3fbf8;
}

.footnote-blue {
  border-color: rgba(37, 99, 235, 0.18);
  background: #f7faff;
}

.footnote-blue .footnote-icon {
  color: #1d4ed8;
}

.footnote-gold {
  border-color: rgba(217, 119, 6, 0.28);
  background: #fffaf2;
}

.footnote-gold .footnote-icon {
  color: var(--warning);
}

.footer-link {
  color: #1d4ed8;
  font-weight: 800;
}

.footer-muted {
  color: var(--muted);
}

.reset-confirm {
  margin-top: 12px;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.loading-view {
  display: grid;
  place-items: center;
  min-height: 320px;
  gap: 14px;
  color: var(--muted);
}

.loader {
  width: 38px;
  height: 38px;
  border: 4px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 900ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (min-width: 680px) {
  .tile-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stats-grid,
  .result-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .home-footnotes {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .exam-header {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: center;
  }
}

@media (min-width: 900px) {
  .home-hero {
    grid-template-columns: minmax(0, 1fr) 360px;
  }

  .tile-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .global-timer {
    justify-content: space-between;
    width: 100%;
  }

  .dashboard-head,
  .question-top,
  .review-top,
  .result-head {
    flex-direction: column;
  }

  .actions .button {
    flex: 1 1 100%;
  }

  .button.finish {
    margin-left: 0;
  }
}

.error-view {
  max-width: 40rem;
  margin: 4rem auto;
  padding: 2rem;
  text-align: center;
}

.error-view h1 {
  margin-bottom: 1rem;
}

.error-view a {
  display: inline-block;
  margin-top: 1rem;
}