:root {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-raised: #1e222b;
  --border: #2a2f3a;
  --text: #e6e9ef;
  --muted: #8b93a3;
  --accent: #d97757;
  --accent-soft: rgba(217, 119, 87, 0.14);
  --correct: #3fb96f;
  --correct-soft: rgba(63, 185, 111, 0.12);
  --wrong: #e05260;
  --wrong-soft: rgba(224, 82, 96, 0.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] { display: none !important; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  justify-content: center;
  padding: 24px 16px;
  line-height: 1.6;
}

.app {
  width: 100%;
  max-width: 720px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.app-header h1 {
  font-size: 1.15rem;
  font-weight: 650;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.score {
  font-size: 0.85rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.progress-track {
  height: 6px;
  border-radius: 3px;
  background: var(--surface-raised);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.25s ease;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.scenario-chip {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 4px 10px;
  border-radius: 999px;
}

.counter {
  font-size: 0.85rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.question-text {
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.55;
}

code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.85em;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 5px;
  padding: 0.08em 0.35em;
}

.options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.option-btn {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.option-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.option-btn:disabled {
  cursor: default;
}

.option-letter {
  font-weight: 700;
  color: var(--muted);
  flex-shrink: 0;
}

.option-btn.correct {
  border-color: var(--correct);
  background: var(--correct-soft);
}

.option-btn.correct .option-letter { color: var(--correct); }

.option-btn.wrong {
  border-color: var(--wrong);
  background: var(--wrong-soft);
}

.option-btn.wrong .option-letter { color: var(--wrong); }

.explanation {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  font-size: 0.92rem;
  color: var(--muted);
}

.explanation > strong {
  display: block;
  margin-bottom: 6px;
  color: var(--text);
}

.explanation .verdict-correct { color: var(--correct); }
.explanation .verdict-wrong { color: var(--wrong); }

.app-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: auto;
}

.footer-hint {
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
}

.primary-btn {
  font: inherit;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.primary-btn:hover { opacity: 0.88; }
.primary-btn:disabled { opacity: 0.35; cursor: default; }

.ghost-btn {
  font: inherit;
  font-weight: 500;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 16px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.ghost-btn:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--muted);
}

.ghost-btn:disabled { opacity: 0.35; cursor: default; }

.summary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 40px 24px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-align: center;
}

.summary h2 { font-size: 1.3rem; }

.summary-score {
  color: var(--muted);
  font-size: 1.05rem;
}

.error {
  color: var(--wrong);
  text-align: center;
  padding: 24px;
}

@media (max-width: 520px) {
  .card { padding: 18px; }
  .footer-hint { display: none; }
}

@media (max-height: 700px) {
  body { padding: 12px 16px; }
  .app { gap: 10px; }
  .app-header h1 { font-size: 1rem; }
  .card { padding: 14px 16px; gap: 10px; }
  .question-text { font-size: 1rem; }
  .option-btn { padding: 9px 12px; font-size: 0.9rem; }
  .explanation { padding-top: 10px; font-size: 0.85rem; }
  .summary { padding: 20px; }
  .app-footer .ghost-btn,
  .app-footer .primary-btn { padding: 8px 14px; }
}
