:root {
  --bg: #f6efe5;
  --panel: #fffaf4;
  --ink: #1e2430;
  --muted: #646d7b;
  --line: #d7c7b1;
  --accent: #1f6b5b;
  --accent-2: #f0a84f;
  --danger: #bb4d44;
  --ok: #2d7a4b;
  --shadow: 0 16px 40px rgba(37, 33, 29, 0.1);
  --radius: 20px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  background:
    radial-gradient(circle at top left, rgba(240, 168, 79, 0.18), transparent 32%),
    linear-gradient(180deg, #f8f2e8 0%, #efe5d6 100%);
  color: var(--ink);
  min-height: 100vh;
}

button,
input {
  font: inherit;
}

#app {
  width: min(920px, calc(100vw - 24px));
  margin: 24px auto 40px;
}

.shell {
  background: var(--panel);
  border: 1px solid rgba(30, 36, 48, 0.08);
  border-radius: 28px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.hero {
  padding: 28px 24px 18px;
  background:
    linear-gradient(135deg, rgba(31, 107, 91, 0.92), rgba(16, 76, 89, 0.92)),
    linear-gradient(180deg, #1f6b5b, #104c59);
  color: #fff7f0;
}

.hero h1,
.hero h2,
.question-card h2,
.result-card h2 {
  margin: 0 0 10px;
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  line-height: 1.05;
}

.hero p,
.muted {
  color: var(--muted);
}

.hero p {
  color: rgba(255, 247, 240, 0.88);
  max-width: 48rem;
}

.progress-shell {
  margin-top: 12px;
  width: min(420px, 100%);
  height: 10px;
  background: rgba(255, 247, 240, 0.2);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #f0a84f, #f7d17b);
}

.hero-row,
.actions,
.topic-grid,
.history-list,
.choices,
.feedback-row {
  display: grid;
  gap: 12px;
}

.hero-row {
  margin-top: 18px;
}

.key-panel,
.panel,
.question-card,
.result-card,
.history-card {
  padding: 20px;
}

.key-panel,
.panel,
.question-card,
.result-card,
.history-card,
.choice,
.topic-pill {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.72);
}

.key-panel {
  margin-top: 18px;
  color: var(--ink);
}

.stack {
  display: grid;
  gap: 10px;
}

.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  cursor: pointer;
  transition: transform 120ms ease, opacity 120ms ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
  transform: none;
}

.btn-primary {
  background: var(--accent-2);
  color: #1f1611;
}

.btn-secondary {
  background: var(--accent);
  color: #fdf8f1;
}

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

.status-banner {
  margin: 16px 24px 0;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 0.96rem;
}

.status-banner.warn {
  background: rgba(240, 168, 79, 0.18);
  border: 1px solid rgba(240, 168, 79, 0.45);
}

.status-banner.ok {
  background: rgba(45, 122, 75, 0.12);
  border: 1px solid rgba(45, 122, 75, 0.32);
}

.layout {
  display: grid;
  gap: 16px;
  padding: 24px;
}

.topic-grid {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.topic-pill {
  padding: 14px;
}

.topic-pill strong,
.score strong {
  display: block;
  margin-bottom: 4px;
}

.question-card p,
.result-card p,
.history-card p,
.topic-pill p {
  margin: 0;
}

.choices {
  margin-top: 14px;
}

.choice {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
}

.choice input {
  margin: 0;
}

.feedback {
  margin-top: 16px;
  padding: 16px;
  border-radius: 18px;
}

.feedback.correct {
  background: rgba(45, 122, 75, 0.12);
}

.feedback.incorrect {
  background: rgba(187, 77, 68, 0.12);
}

.feedback-row {
  margin-top: 12px;
}

.score-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.score {
  border-radius: 16px;
  padding: 14px;
  background: rgba(31, 107, 91, 0.08);
}

.history-list {
  margin-top: 16px;
}

.history-row {
  display: grid;
  gap: 6px;
  padding: 14px;
  border-radius: 16px;
  background: rgba(16, 76, 89, 0.06);
}

.small {
  font-size: 0.92rem;
}

@media (max-width: 640px) {
  #app {
    width: calc(100vw - 16px);
    margin-top: 8px;
  }

  .hero,
  .layout {
    padding: 18px;
  }
}
