:root {
  --color-bg: #f5f1e8;
  --color-surface: #ffffff;
  --color-text: #2b2620;
  --color-muted: #766f63;
  --color-primary: #8b3a3a;
  --color-primary-dark: #6f2e2e;
  --color-accent: #c8a13a;
  --color-correct: #3f7d4f;
  --color-correct-bg: #e6f2e8;
  --color-wrong: #b0413e;
  --color-wrong-bg: #fbe9e8;
  --color-border: #e2dccd;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.7;
}

.app {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 16px 60px;
  min-height: 100vh;
}

.app-header h1 {
  font-size: 1.25rem;
  text-align: center;
  color: var(--color-primary-dark);
  margin: 8px 0 28px;
}

.screen { animation: fadein 0.25s ease; }
.hidden { display: none !important; }

@keyframes fadein {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.lead {
  text-align: center;
  font-size: 1.05rem;
  margin-bottom: 32px;
}

.btn {
  display: block;
  width: 100%;
  padding: 14px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--color-primary);
  color: #fff;
  box-shadow: 0 3px 0 var(--color-primary-dark);
}
.btn-primary:hover { opacity: 0.95; }

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-primary-dark);
  border: 2px solid var(--color-primary);
  margin-top: 12px;
}

.progress-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--color-muted);
  margin-bottom: 6px;
}

.category-badge {
  background: var(--color-accent);
  color: #fff;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}

.progress-bar {
  height: 8px;
  background: var(--color-border);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 20px;
}
.progress-fill {
  height: 100%;
  background: var(--color-primary);
  width: 0%;
  transition: width 0.3s ease;
}

.question-image-wrap {
  margin-bottom: 16px;
  text-align: center;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 10px;
}
.question-image-wrap img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
}

.question-text {
  font-size: 1.05rem;
  white-space: pre-wrap;
  margin: 0 0 20px;
  color: var(--color-text);
}

.choices {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.choice-btn {
  text-align: left;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 2px solid var(--color-border);
  background: var(--color-surface);
  font-size: 0.98rem;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.08s ease;
  display: flex;
  gap: 10px;
}
.choice-btn:hover:not(:disabled) {
  border-color: var(--color-primary);
}
.choice-btn:active:not(:disabled) { transform: scale(0.99); }

.choice-num {
  flex-shrink: 0;
  font-weight: 700;
  color: var(--color-primary);
}

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

.choice-btn.correct {
  background: var(--color-correct-bg);
  border-color: var(--color-correct);
}
.choice-btn.correct .choice-num { color: var(--color-correct); }

.choice-btn.wrong {
  background: var(--color-wrong-bg);
  border-color: var(--color-wrong);
}
.choice-btn.wrong .choice-num { color: var(--color-wrong); }

.feedback {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-weight: 700;
  text-align: center;
}
.feedback.correct {
  background: var(--color-correct-bg);
  color: var(--color-correct);
}
.feedback.wrong {
  background: var(--color-wrong-bg);
  color: var(--color-wrong);
}

.explanation {
  background: #faf6ec;
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-accent);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 20px;
  font-size: 0.92rem;
  color: var(--color-text);
  line-height: 1.7;
}

.result-summary {
  text-align: center;
  font-size: 1.4rem;
  font-weight: 700;
  margin: 20px 0 4px;
}
.result-rate {
  text-align: center;
  color: var(--color-muted);
  margin-bottom: 24px;
}

.perfect-message {
  text-align: center;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--color-primary-dark);
  background: #fff6e0;
  border: 2px dashed var(--color-accent);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
}

.result-buttons { margin-top: 8px; }
