:root {
  --bg: #f5f1ea;
  --bg-card: #ffffff;
  --primary: #8b1e3f;
  --primary-dark: #6b1730;
  --accent: #c9a96e;
  --text: #2a2a2a;
  --text-muted: #6a6a6a;
  --border: #e3dccf;
  --correct: #3a8a4f;
  --correct-bg: #e6f3e9;
  --wrong: #b8453c;
  --wrong-bg: #fbe9e7;
  --shadow: 0 4px 16px rgba(60, 30, 20, 0.08);
}

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

body {
  font-family: "Yu Mincho", "游明朝", "Hiragino Mincho ProN", "ヒラギノ明朝 ProN W3", serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  text-align: center;
  padding: 28px 16px 22px;
  box-shadow: var(--shadow);
}

header h1 {
  font-size: 1.9rem;
  letter-spacing: 0.1em;
  margin-bottom: 4px;
}

header .subtitle {
  font-size: 0.9rem;
  opacity: 0.85;
  letter-spacing: 0.05em;
}

main {
  flex: 1;
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  padding: 24px 16px 60px;
}

.controls {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: flex-end;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1 1 180px;
}

.control-group label {
  font-size: 0.8rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.control-group select {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  background: #fff;
  font-family: inherit;
  cursor: pointer;
}

.primary-btn, .secondary-btn {
  padding: 10px 18px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.2s, background 0.2s;
  letter-spacing: 0.05em;
}

.primary-btn {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
}

.primary-btn:hover {
  background: var(--primary-dark);
  box-shadow: 0 4px 10px rgba(139, 30, 63, 0.3);
}

.secondary-btn {
  background: #efe8db;
  color: var(--text);
  border: 1px solid var(--border);
}

.secondary-btn:hover {
  background: #e3dccf;
}

.primary-btn:active, .secondary-btn:active { transform: translateY(1px); }
.secondary-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  background: var(--bg-card);
  padding: 14px;
  border-radius: 12px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 0.85rem;
}

.stat-label {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.stat span:last-child {
  font-weight: bold;
  font-size: 1.1rem;
  color: var(--text);
}

.progress-bar {
  grid-column: 1 / -1;
  height: 6px;
  background: #efe8db;
  border-radius: 4px;
  overflow: hidden;
  margin-top: 6px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--primary));
  width: 0%;
  transition: width 0.4s ease;
}

.quiz .card {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 28px 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.category-tag {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-size: 0.78rem;
  padding: 3px 12px;
  border-radius: 14px;
  letter-spacing: 0.08em;
  margin-bottom: 14px;
}

.question {
  font-size: 1.18rem;
  line-height: 1.9;
  padding: 12px 0 22px;
  border-bottom: 2px dashed var(--border);
  min-height: 80px;
  font-weight: 500;
}

.choices {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 18px;
}

.choice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: #fafaf7;
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 1rem;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  line-height: 1.65;
  color: var(--text);
  width: 100%;
}

.choice:hover:not(:disabled) {
  background: #fff;
  border-color: var(--accent);
  transform: translateY(-1px);
}

.choice:active:not(:disabled) { transform: translateY(0); }

.choice .marker {
  flex-shrink: 0;
  background: var(--bg);
  color: var(--primary);
  font-weight: bold;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  margin-top: 2px;
  border: 1px solid var(--border);
}

.choice .text {
  flex: 1;
}

.choice:disabled { cursor: default; }

.choice.is-correct {
  background: var(--correct-bg);
  border-color: var(--correct);
  color: var(--correct);
  font-weight: 600;
}
.choice.is-correct .marker {
  background: var(--correct);
  color: #fff;
  border-color: var(--correct);
}

.choice.is-wrong {
  background: var(--wrong-bg);
  border-color: var(--wrong);
  color: var(--wrong);
}
.choice.is-wrong .marker {
  background: var(--wrong);
  color: #fff;
  border-color: var(--wrong);
}

.choice.is-faded { opacity: 0.55; }

.feedback {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 8px;
  font-weight: 600;
  text-align: center;
  font-size: 1.05rem;
  animation: fadeIn 0.25s ease;
}

.feedback.correct { background: var(--correct-bg); color: var(--correct); border: 1px solid var(--correct); }
.feedback.wrong { background: var(--wrong-bg); color: var(--wrong); border: 1px solid var(--wrong); }

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

.nav-actions {
  display: flex;
  justify-content: space-between;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.welcome {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.welcome h2 {
  color: var(--primary);
  margin-bottom: 14px;
  font-size: 1.2rem;
  letter-spacing: 0.05em;
}

.welcome ol {
  padding-left: 22px;
  margin-bottom: 16px;
}

.welcome ol li { margin-bottom: 6px; }

.note {
  font-size: 0.85rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.total-info {
  margin-top: 14px;
  text-align: center;
  font-size: 1rem;
}

.total-info strong {
  color: var(--primary);
  font-size: 1.6rem;
  margin: 0 4px;
  font-family: serif;
}

.result {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 30px 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  text-align: center;
}

.result h2 {
  color: var(--primary);
  margin-bottom: 18px;
  letter-spacing: 0.1em;
}

.result-stats {
  display: flex;
  justify-content: center;
  gap: 28px;
  margin-bottom: 16px;
}

.result-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 1.4rem;
  font-weight: 600;
}

.result-stat .big { font-size: 2rem; }

.result-stat:nth-child(1) .big { color: var(--correct); }
.result-stat:nth-child(2) .big { color: var(--wrong); }
.result-stat:nth-child(3) .big { color: var(--primary); }

.result-message {
  margin: 16px 0 22px;
  color: var(--text-muted);
  font-style: italic;
}

.result-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.hidden { display: none !important; }

footer {
  text-align: center;
  padding: 16px;
  font-size: 0.85rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  background: var(--bg-card);
}

@media (max-width: 600px) {
  header h1 { font-size: 1.4rem; }
  .quiz .card { padding: 22px 16px; }
  .question { font-size: 1.05rem; }
  .choice { font-size: 0.95rem; padding: 12px 12px; }
  .stats { font-size: 0.75rem; }
}
