:root {
  color-scheme: light;
  --bg: #f6f7f2;
  --ink: #13211f;
  --muted: #60706b;
  --line: #d8dfd8;
  --panel: #ffffff;
  --brand: #0f766e;
  --brand-dark: #0b5f59;
  --warn: #b42318;
  --ok: #067647;
  --gold: #b7791f;
  --shadow: 0 18px 48px rgba(19, 33, 31, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
}

body {
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

button,
select,
textarea {
  font: inherit;
}

.app-shell {
  width: min(100%, 720px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 16px 26px;
}

.topbar,
.quiz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 34px;
}

.view {
  display: none;
  margin-top: 18px;
}

.view.active {
  display: block;
}

.stat-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 18px 0;
}

.stat-strip div,
.score-summary div {
  min-height: 82px;
  padding: 14px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 22px rgba(19, 33, 31, 0.06);
}

.stat-strip strong,
.score-summary strong {
  display: block;
  font-size: clamp(22px, 8vw, 32px);
  line-height: 1;
}

.stat-strip span,
.score-summary span,
.field span,
.mode-card small,
.import-box p,
.question-meta,
#resultSummary,
#scoreSyncStatus,
.score-meta {
  color: var(--muted);
}

.field {
  display: grid;
  gap: 7px;
  margin: 12px 0 18px;
  font-weight: 700;
}

select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
}

select {
  min-height: 48px;
  padding: 0 12px;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.mode-card {
  display: grid;
  min-height: 146px;
  padding: 15px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 8px 22px rgba(19, 33, 31, 0.06);
}

.mode-card strong {
  align-self: end;
  font-size: 22px;
}

.mode-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #e5f2ef;
  color: var(--brand-dark);
  font-weight: 900;
}

.import-box {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.import-box summary {
  font-weight: 800;
}

textarea {
  min-height: 130px;
  padding: 12px;
  resize: vertical;
}

.question-panel,
.result-card {
  margin-top: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.question-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
}

#questionTitle {
  font-size: 21px;
  line-height: 1.28;
  margin: 8px 0 16px;
}

.statements {
  display: grid;
  gap: 12px;
}

.statement {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf9;
}

.statement.correct {
  border-color: rgba(6, 118, 71, 0.35);
  background: #edf8f3;
}

.statement.wrong {
  border-color: rgba(180, 35, 24, 0.35);
  background: #fff1ef;
}

.statement-label {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #e7ece8;
  font-weight: 900;
}

.statement-text {
  line-height: 1.35;
}

.choice-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  grid-column: 2;
  margin-top: 8px;
}

.choice {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
}

.choice.selected {
  border-color: var(--brand);
  background: #e5f2ef;
  color: var(--brand-dark);
}

.answer-note {
  grid-column: 2;
  color: var(--muted);
  font-size: 13px;
}

.quiz-actions,
.result-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.result-actions {
  grid-template-columns: 1fr 1fr;
}

button {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.primary {
  background: var(--brand);
  color: white;
  font-weight: 900;
}

.secondary,
.ghost {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font-weight: 800;
}

.ghost {
  min-height: 42px;
  padding: 0 12px;
}

.icon-button {
  width: 44px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel);
  color: var(--brand-dark);
  font-size: 22px;
  font-weight: 900;
}

.timer {
  min-width: 76px;
  min-height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #13211f;
  color: white;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.progress-track {
  height: 8px;
  margin: 14px 0 0;
  border-radius: 999px;
  overflow: hidden;
  background: #dce4de;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--brand);
  transition: width 0.2s ease;
}

.result-card {
  text-align: center;
}

.result-card h2 {
  font-size: 48px;
  margin: 8px 0;
}

.score-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 14px 0;
}

.history-panel {
  margin-top: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.history-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.history-title h2 {
  font-size: 22px;
}

.score-history {
  display: grid;
  gap: 10px;
}

.score-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf9;
}

.score-row strong {
  display: block;
  margin-bottom: 5px;
}

.score-value {
  display: grid;
  place-items: center;
  min-width: 64px;
  min-height: 48px;
  border-radius: 8px;
  background: #e5f2ef;
  color: var(--brand-dark);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.empty-state {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 380px) {
  .app-shell {
    padding-inline: 12px;
  }

  .mode-grid {
    grid-template-columns: 1fr;
  }

  .quiz-actions,
  .result-actions,
  .score-summary {
    grid-template-columns: 1fr;
  }

  .statement {
    grid-template-columns: 24px 1fr;
    padding: 10px;
  }

  .choice-row,
  .answer-note {
    grid-column: 1 / -1;
  }
}
