:root {
  --text: #222;
  --muted: #666;
  --border: #ddd;
  --bg: #fafaf7;
  --card: #fff;
  --accent: #2f5d8a;
  --correct: #2e7d32;
  --correct-bg: #e8f5e9;
  --wrong: #c62828;
  --wrong-bg: #ffebee;
}

* {
  box-sizing: border-box;
}

/* display を指定したクラスより hidden 属性を優先させる（これがないとボタンが消えない） */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  padding: 0 16px;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Hiragino Sans", "Yu Gothic UI", sans-serif;
  line-height: 1.6;
}

.site-header,
.quiz,
.page,
.site-footer {
  max-width: 640px;
  margin: 0 auto;
}

/* サブページのヘッダー（サイト名をトップへのリンクにする） */
.site-name {
  margin: 0;
  font-weight: bold;
}

.site-name a {
  color: inherit;
  text-decoration: none;
}

/* サブページの本文 */
.page h1 {
  font-size: 1.4rem;
}

.page h2 {
  margin-top: 32px;
  font-size: 1.1rem;
}

.page a {
  color: var(--accent);
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.site-header {
  padding: 32px 0 8px;
}

.site-header h1 {
  margin: 0;
  font-size: 1.5rem;
}

.home-link {
  color: inherit;
  text-decoration: none;
}

.lead {
  margin: 4px 0 0;
  color: var(--muted);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin: 16px 0;
}

.toolbar select {
  margin-left: 4px;
  padding: 4px 8px;
  font-size: 1rem;
}

.progress,
.score {
  margin: 0;
  color: var(--muted);
}

.progress {
  font-weight: bold;
}

#start-screen select {
  margin-left: 4px;
  padding: 4px 8px;
  font-size: 1rem;
}

/* 書き出し本文。原文の改行を活かし、明朝体で読ませる */
.opening {
  margin: 0 0 8px;
  padding: 24px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", serif;
  font-size: 1.15rem;
  line-height: 2;
  white-space: pre-wrap;
}

/* ヒントで表示した続きは、書き出しと区別できるよう薄い色にする */
.hint-text {
  color: var(--muted);
}

.hint-row {
  margin: 0 0 16px;
  text-align: right;
}

.secondary {
  padding: 6px 16px;
  background: transparent;
  border: 1px solid var(--accent);
  border-radius: 8px;
  color: var(--accent);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}

.secondary:disabled {
  opacity: 0.4;
  cursor: default;
}

.choices {
  display: grid;
  gap: 8px;
}

/* 左に番号、右に作品名と著者の2段 */
.choice {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 12px;
  align-items: center;
  width: 100%;
  padding: 12px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.choice:hover:not(:disabled) {
  border-color: var(--accent);
}

.choice:disabled {
  cursor: default;
}

.choice-key {
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 1.8em;
  height: 1.8em;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--muted);
  font-size: 0.85rem;
}

.choice-title {
  font-weight: bold;
}

.choice-author {
  color: var(--muted);
  font-size: 0.9rem;
}

/* タッチ操作の端末（スマホなど）ではキー番号は不要 */
@media (hover: none) {
  .choice {
    grid-template-columns: 1fr;
  }

  .choice-key {
    display: none;
  }
}

.choice.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.action {
  margin-top: 16px;
  min-width: 10em;
}

.primary:disabled {
  opacity: 0.4;
  cursor: default;
}

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

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

.result {
  margin: 16px 0 8px;
  font-weight: bold;
}

.result.is-correct {
  color: var(--correct);
}

.result.is-wrong {
  color: var(--wrong);
}

.source-link {
  margin: 0 0 16px;
}

.source-link a {
  color: var(--accent);
}

.primary,
.button {
  display: inline-block;
  padding: 10px 24px;
  border: none;
  border-radius: 8px;
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}

.primary {
  background: var(--accent);
  color: #fff;
}

.share {
  background: #000;
  color: #fff;
}

/* 結果画面 */
.final-score {
  margin: 24px 0 4px;
  font-size: 1.5rem;
  font-weight: bold;
}

.rank {
  margin: 0 0 24px;
  font-size: 1.1rem;
}

.history {
  margin: 0 0 24px;
  padding: 0;
  list-style: none;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.history li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  padding: 8px 16px;
  border-top: 1px solid var(--border);
}

.history li:first-child {
  border-top: none;
}

.history a {
  color: var(--accent);
}

.history-mark {
  width: 1.2em;
  font-weight: bold;
}

.history li.is-correct .history-mark {
  color: var(--correct);
}

.history li.is-wrong .history-mark {
  color: var(--wrong);
}

.history-author {
  color: var(--muted);
  font-size: 0.9rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.site-footer {
  padding: 48px 0 24px;
  color: var(--muted);
  font-size: 0.85rem;
}

.site-footer a {
  color: inherit;
}
