:root {
  color-scheme: light;
  --ink: #18202a;
  --muted: #5b6470;
  --line: #d9e1e8;
  --soft: #eef4f7;
  --paper: #fbfdfe;
  --accent: #0d7c66;
  --accent-strong: #075f4d;
  --gold: #c79018;
  --danger: #b3261e;
  --ok: #207245;
  --shadow: 0 18px 45px rgba(24, 32, 42, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background:
    linear-gradient(135deg, rgba(13, 124, 102, 0.12), transparent 34%),
    linear-gradient(315deg, rgba(199, 144, 24, 0.14), transparent 35%),
    #f6f9fb;
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  overflow: hidden;
}

button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app-shell {
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: clamp(10px, 2vh, 18px);
  height: 100dvh;
  padding: clamp(10px, 2vw, 22px);
}

.topbar {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  min-height: 70px;
}

.top-author {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.2;
  margin: 6px 0 0;
}

.eyebrow {
  color: var(--accent-strong);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0 0 5px;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  font-size: clamp(1.1rem, 2.8vw, 2rem);
  line-height: 1.05;
  margin-bottom: 0;
}

h2 {
  font-size: clamp(1.2rem, 3vw, 2.15rem);
  line-height: 1.12;
}

.timer-card,
.start-panel,
.question-card,
.guide-panel,
.score-panel,
.review-list {
  background: rgba(251, 253, 254, 0.94);
  border: 1px solid rgba(217, 225, 232, 0.92);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.timer-card {
  min-width: 142px;
  padding: 10px 14px;
  text-align: right;
}

.timer-card span {
  color: var(--muted);
  display: block;
  font-size: 0.76rem;
  margin-bottom: 2px;
}

.timer-card strong {
  color: var(--accent-strong);
  display: block;
  font-size: clamp(1.2rem, 3vw, 1.8rem);
}

.timer-card.warning strong {
  color: var(--danger);
}

.visitor-stats {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: flex-start;
}

.visitor-stats div {
  align-items: center;
  background: rgba(251, 253, 254, 0.78);
  border: 1px solid rgba(217, 225, 232, 0.92);
  border-radius: 8px;
  display: inline-flex;
  gap: 8px;
  min-height: 36px;
  padding: 7px 12px;
}

.visitor-stats span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.visitor-stats strong {
  color: var(--accent-strong);
  font-size: 0.95rem;
}

.screen {
  min-height: 0;
}

.hidden {
  display: none !important;
}

.start-screen {
  align-items: stretch;
  display: grid;
  gap: clamp(12px, 2vw, 20px);
  grid-template-columns: minmax(0, 1.2fr) minmax(270px, 0.8fr);
}

.intro-copy {
  align-self: center;
  max-width: 760px;
}

.intro-copy p:not(.eyebrow) {
  color: var(--muted);
  font-size: clamp(0.98rem, 1.6vw, 1.18rem);
  line-height: 1.52;
  max-width: 68ch;
}

.start-panel {
  align-content: center;
  display: grid;
  gap: 12px;
  padding: clamp(16px, 4vw, 28px);
}

.stat {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  padding: 14px;
}

.stat span {
  color: var(--muted);
}

.stat strong {
  color: var(--accent-strong);
}

.quiz-screen {
  display: grid;
  gap: clamp(10px, 2vw, 18px);
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  min-height: 0;
}

.guide-panel {
  display: grid;
  gap: 12px;
  grid-template-rows: auto auto 1fr auto auto;
  min-height: 0;
  padding: 14px;
}

.guide-header,
.question-meta,
.actions,
.result-actions {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.guide-header span,
.question-meta span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.progress-track {
  background: #dde6ea;
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
}

#progress-fill {
  background: linear-gradient(90deg, var(--accent), var(--gold));
  height: 100%;
  transition: width 180ms ease;
  width: 0;
}

.question-map {
  align-content: start;
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.map-btn {
  aspect-ratio: 1;
  background: #ffffff;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 1rem;
  padding: 0;
}

.map-btn.answered {
  background: rgba(13, 124, 102, 0.1);
  border-color: rgba(13, 124, 102, 0.45);
  color: var(--accent-strong);
}

.map-btn.current {
  background: var(--accent);
  color: #ffffff;
}

.legend {
  display: grid;
  gap: 6px;
  grid-template-columns: 1fr;
}

.legend span {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 0.8rem;
  gap: 6px;
}

.dot {
  border-radius: 999px;
  display: inline-block;
  height: 10px;
  width: 10px;
}

.dot.current {
  background: var(--accent);
}

.dot.answered {
  background: rgba(13, 124, 102, 0.35);
}

.dot.pending {
  background: #ffffff;
  border: 1px solid var(--line);
}

.question-card {
  display: grid;
  gap: clamp(10px, 2vh, 16px);
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  min-height: 0;
  padding: clamp(14px, 2.6vw, 28px);
  transform-origin: center;
  will-change: transform, opacity, filter;
}

#question-text {
  font-size: clamp(1.05rem, 2vw, 1.55rem);
  line-height: 1.25;
  margin: 0;
  overflow-wrap: anywhere;
}

.question-label {
  font-size: 1.05rem;
  font-weight: 800;
  margin: 0;
}

.options {
  display: grid;
  gap: 10px;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.option {
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  display: grid;
  gap: 10px;
  grid-template-columns: 32px 1fr;
  font-size: 1.03rem;
  line-height: 1.35;
  min-height: 48px;
  padding: 10px 12px;
  text-align: left;
}

.option:hover {
  border-color: rgba(13, 124, 102, 0.6);
}

.option.selected {
  background: rgba(13, 124, 102, 0.1);
  border-color: var(--accent);
}

.option-letter {
  align-items: center;
  background: transparent;
  border-radius: 0;
  display: inline-flex;
  font-weight: 800;
  height: auto;
  justify-content: center;
  width: auto;
}

.primary-btn,
.secondary-btn,
.ghost-btn {
  min-height: 42px;
  padding: 10px 16px;
}

.primary-btn {
  background: var(--accent);
  color: #ffffff;
}

.primary-btn:hover {
  background: var(--accent-strong);
}

.secondary-btn {
  background: #ffffff;
  border: 1px solid var(--accent);
  color: var(--accent-strong);
}

.ghost-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
}

.results-screen {
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(280px, 0.8fr) minmax(0, 1.2fr);
  min-height: 0;
}

.score-panel {
  align-content: center;
  display: grid;
  gap: 12px;
  padding: clamp(16px, 3vw, 28px);
}

.score-panel p:not(.eyebrow) {
  color: var(--muted);
  line-height: 1.45;
}

.review-list {
  display: grid;
  gap: 10px;
  min-height: 0;
  overflow: auto;
  padding: 12px;
}

.review-item {
  background: #ffffff;
  border: 1px solid var(--line);
  border-left: 5px solid var(--danger);
  border-radius: 8px;
  padding: 12px;
}

.review-item.correct {
  border-left-color: var(--ok);
}

.review-item h3 {
  font-size: 0.96rem;
  margin: 0 0 8px;
}

.review-item p {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.38;
  margin-bottom: 6px;
}

@media (max-width: 760px) {
  body {
    overflow: auto;
  }

  .app-shell {
    gap: 8px;
    height: auto;
    min-height: 100dvh;
    padding: 8px;
  }

  .topbar {
    min-height: 54px;
  }

  .topbar .eyebrow {
    display: none;
  }

  h1 {
    font-size: 1rem;
  }

  .top-author {
    font-size: 0.68rem;
    margin-top: 4px;
  }

  .timer-card {
    min-width: 104px;
    padding: 7px 10px;
  }

  .timer-card span {
    font-size: 0.68rem;
  }

  .visitor-stats {
    gap: 6px;
  }

  .visitor-stats div {
    flex: 1;
    justify-content: space-between;
    min-height: 32px;
    padding: 6px 8px;
  }

  .visitor-stats span {
    font-size: 0.68rem;
  }

  .visitor-stats strong {
    font-size: 0.82rem;
  }

  .start-screen,
  .results-screen {
    grid-template-columns: 1fr;
  }

  .intro-copy {
    align-self: end;
  }

  .intro-copy p:not(.eyebrow) {
    font-size: 0.92rem;
    line-height: 1.35;
  }

  .start-panel {
    align-content: start;
    padding: 12px;
  }

  .quiz-screen {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
  }

  .guide-panel {
    gap: 6px;
    grid-template-rows: auto auto auto;
    padding: 8px;
  }

  .question-map {
    grid-template-columns: repeat(10, 1fr);
    max-height: 134px;
    overflow: auto;
  }

  .legend,
  .guide-panel .secondary-btn {
    display: none;
  }

  .map-btn {
    font-size: 0.72rem;
  }

  .question-card {
    gap: 8px;
    grid-template-rows: auto auto auto auto auto;
    min-height: auto;
    padding: 10px;
  }

  #question-text {
    font-size: 0.98rem;
    line-height: 1.24;
  }

  .question-label {
    font-size: 0.95rem;
  }

  .option {
    font-size: 0.9rem;
    gap: 8px;
    grid-template-columns: 28px 1fr;
    min-height: 42px;
    padding: 7px 8px;
  }

  .option-letter {
    height: 28px;
    width: 28px;
  }

  .actions {
    gap: 8px;
  }

  .options {
    overflow: visible;
    padding-right: 0;
  }

  .actions button,
  .result-actions button {
    flex: 1;
    min-height: 38px;
    padding: 8px 10px;
  }
}

@media (max-height: 620px) {
  .topbar {
    min-height: 44px;
  }

  .timer-card span,
  .question-meta span,
  .guide-header span {
    font-size: 0.7rem;
  }

  .question-card,
  .guide-panel {
    padding: 8px;
  }

  .option {
    font-size: 0.82rem;
    min-height: 36px;
    padding: 6px 8px;
  }

  .primary-btn,
  .secondary-btn,
  .ghost-btn {
    min-height: 34px;
    padding: 6px 10px;
  }

  .question-map {
    gap: 4px;
  }

  .map-btn {
    font-size: 0.88rem;
  }
}
