/* 謎解き解説サイト — デザインガイド準拠 */
:root {
  --bg-cream: #f5f5f0;
  --accent-crimson: #8b0000;
  --text: #1a1a18;
  --text-muted: #4a4a45;
  --card-bg: #fffcf7;
  --shadow: rgba(26, 26, 24, 0.08);
  --reveal-glow: rgba(255, 248, 220, 0.95);
  font-family: "Shippori Mincho", "Hiragino Mincho ProN", "Yu Mincho", "YuMincho",
    "MS PMincho", serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg-cream);
  color: var(--text);
  line-height: 1.75;
  font-size: 1rem;
}

.page {
  max-width: 42rem;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

.site-header {
  text-align: center;
  margin-bottom: 2rem;
  border-bottom: 1px solid rgba(139, 0, 0, 0.2);
  padding-bottom: 1.25rem;
}

.site-header h1 {
  margin: 0 0 0.35rem;
  font-size: clamp(1.35rem, 4vw, 1.75rem);
  font-weight: 700;
  color: var(--accent-crimson);
  letter-spacing: 0.04em;
}

.lede {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 1.25rem 1.35rem 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 4px 24px var(--shadow);
  border: 1px solid rgba(139, 0, 0, 0.12);
}

.card h2 {
  margin: 0 0 0.85rem;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--accent-crimson);
  letter-spacing: 0.06em;
}

/* 詩 — 行ごと nowrap、狭い画面は縮小 */
.poem {
  margin: 0;
  font-size: clamp(0.82rem, 2.8vw, 1.05rem);
  line-height: 2.1;
  text-align: center;
}

.poem-line {
  margin: 0 0 0.35rem;
}

.poem-line:last-child {
  margin-bottom: 0;
}

.poem-line-inner {
  display: inline-block;
  white-space: nowrap;
  max-width: 100%;
}

@media (max-width: 380px) {
  .poem {
    font-size: 0.78rem;
    line-height: 2;
  }
}

ruby {
  ruby-align: center;
}

rt {
  font-size: 0.55em;
  letter-spacing: 0.02em;
  color: var(--text-muted);
}

.mystery-slot {
  display: inline-block;
  min-width: 2em;
  text-align: center;
  font-weight: 700;
  color: var(--accent-crimson);
  letter-spacing: 0.05em;
}

.mystery-slot.is-solved {
  animation: mystery-pop 0.6s ease forwards;
}

@keyframes mystery-pop {
  0% {
    opacity: 0;
    transform: scale(0.92);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* ヒント */
.hint-list {
  margin: 0;
  padding-left: 0;
  list-style: none;
}

.hint-list li {
  margin-bottom: 0.75rem;
}

.hint-list li:last-child {
  margin-bottom: 0;
}

.hint-toggle {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--accent-crimson);
  background: transparent;
  color: var(--accent-crimson);
  padding: 0.45rem 0.9rem;
  border-radius: 8px;
  width: 100%;
  text-align: left;
  transition: background 0.2s, color 0.2s;
}

.hint-toggle:hover,
.hint-toggle:focus-visible {
  background: rgba(139, 0, 0, 0.08);
  outline: none;
}

.hint-toggle[aria-expanded="true"] {
  background: rgba(139, 0, 0, 0.12);
}

.hint-body {
  margin: 0.65rem 0 0;
  padding: 0.75rem 0.85rem;
  background: var(--bg-cream);
  border-radius: 8px;
  border-left: 3px solid var(--accent-crimson);
}

.chart-note {
  margin: 0 0 1rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.missing-label {
  color: var(--accent-crimson);
  font-weight: 600;
}

.gojuon-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -0.25rem;
  padding: 0.25rem;
}

.gojuon-grid {
  display: grid;
  grid-template-columns: repeat(10, minmax(1.6rem, 1fr));
  gap: 0.25rem;
  margin: 0 auto;
}

/* や行は や・(空)・ゆ・(空)・よ */
.gojuon-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  font-size: clamp(0.6rem, 2vw, 0.75rem);
  font-weight: 600;
  border: 1px solid rgba(26, 26, 24, 0.12);
  background: #fff;
  transition: background 0.25s, border-color 0.25s, box-shadow 0.35s, transform 0.2s;
}

.gojuon-cell.is-empty {
  visibility: hidden;
  pointer-events: none;
  border: none;
  background: transparent;
}

.gojuon-cell.is-used {
  background: rgba(139, 0, 0, 0.06);
  border-color: rgba(139, 0, 0, 0.25);
  color: var(--text);
}

.gojuon-cell.is-missing {
  background: rgba(139, 0, 0, 0.14);
  border-color: var(--accent-crimson);
  color: var(--accent-crimson);
  box-shadow: inset 0 0 0 1px rgba(139, 0, 0, 0.2);
}

.gojuon-cell.is-answer-highlight {
  animation: cell-glow 1.1s ease forwards;
}

@keyframes cell-glow {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 220, 150, 0);
    background: rgba(139, 0, 0, 0.14);
  }
  40% {
    box-shadow: 0 0 20px 4px rgba(255, 230, 180, 0.85);
    background: rgba(255, 248, 220, 0.95);
    border-color: #b8860b;
    color: var(--accent-crimson);
  }
  100% {
    box-shadow: 0 0 12px 2px rgba(255, 235, 200, 0.5);
    background: rgba(255, 250, 235, 0.9);
    border-color: var(--accent-crimson);
  }
}

.chart-legend {
  margin: 1rem 0 0;
  font-size: 0.82rem;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.legend-used::before,
.legend-missing::before {
  content: "";
  display: inline-block;
  width: 0.65rem;
  height: 0.65rem;
  margin-right: 0.35rem;
  vertical-align: middle;
  border-radius: 2px;
}

.legend-used::before {
  background: rgba(139, 0, 0, 0.08);
  border: 1px solid rgba(139, 0, 0, 0.25);
}

.legend-missing::before {
  background: rgba(139, 0, 0, 0.14);
  border: 1px solid var(--accent-crimson);
}

/* 選択肢 */
.choices {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.65rem;
}

@media (min-width: 480px) {
  .choices {
    grid-template-columns: repeat(4, 1fr);
  }
}

.choice-btn {
  font: inherit;
  cursor: pointer;
  padding: 0.65rem 0.5rem;
  border-radius: 8px;
  border: 1px solid rgba(139, 0, 0, 0.35);
  background: #fff;
  color: var(--text);
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
}

.choice-btn:hover,
.choice-btn:focus-visible {
  background: rgba(139, 0, 0, 0.06);
  border-color: var(--accent-crimson);
  outline: none;
}

.choice-btn.is-correct {
  border-color: var(--accent-crimson);
  background: rgba(139, 0, 0, 0.1);
  color: var(--accent-crimson);
  font-weight: 700;
}

.choice-btn.is-wrong {
  opacity: 0.55;
}

.feedback {
  min-height: 1.5em;
  margin: 1rem 0 0;
  font-size: 0.95rem;
  color: var(--accent-crimson);
}

/* 解説 — フェードイン＋明るい背景 */
.card--reveal {
  animation: explain-enter 0.9s ease forwards;
}

@keyframes explain-enter {
  from {
    opacity: 0;
    transform: translateY(8px);
    box-shadow: 0 4px 24px var(--shadow);
  }
  to {
    opacity: 1;
    transform: translateY(0);
    box-shadow: 0 8px 40px rgba(255, 220, 160, 0.35), 0 4px 24px var(--shadow);
  }
}

.card--reveal .explain-body {
  animation: explain-text 1s ease 0.15s both;
}

@keyframes explain-text {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.answer-line {
  margin: 0 0 0.85rem;
  font-size: 1.05rem;
}

.answer-label {
  font-weight: 600;
  color: var(--text-muted);
}

.answer-word {
  color: var(--accent-crimson);
  font-size: 1.15em;
}

.explain-body p {
  margin: 0;
}

.reveal-actions {
  text-align: center;
  margin: 0.5rem 0 0;
}

.btn-secondary {
  font: inherit;
  cursor: pointer;
  padding: 0.55rem 1.1rem;
  border-radius: 8px;
  border: 1px dashed var(--accent-crimson);
  background: transparent;
  color: var(--accent-crimson);
  font-size: 0.9rem;
}

.btn-secondary:hover,
.btn-secondary:focus-visible {
  background: rgba(139, 0, 0, 0.06);
  outline: none;
}
