:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --ink: #1f2733;
  --muted: #6b7785;
  --accent: #2563eb;
  --accent-soft: #e8f0fe;
  --border: #e3e8ed;
  --shadow: 0 2px 8px rgba(20, 30, 45, 0.06);
  --shadow-lg: 0 12px 40px rgba(20, 30, 45, 0.18);
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

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

/* ===== ヘッダー ===== */
.site-header {
  background: linear-gradient(135deg, #1e3a8a, #2563eb);
  color: #fff;
  padding: 40px 20px 32px;
  text-align: center;
}
.site-header h1 {
  margin: 0 0 8px;
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  letter-spacing: 0.02em;
}
.site-header p {
  margin: 0;
  opacity: 0.9;
  font-size: 0.98rem;
}

/* ===== 操作バー ===== */
.controls {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
}
.controls-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.controls input,
.controls select {
  font: inherit;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}
.controls input {
  flex: 1 1 220px;
  min-width: 0;
}
.controls input:focus,
.controls select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.count {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap;
}

/* ===== 一覧グリッド ===== */
.grid {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px 60px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
}

.card {
  font: inherit;
  text-align: left;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  padding: 0;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.card:hover,
.card:focus-visible {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  outline: none;
}
.card-visual {
  background: linear-gradient(160deg, #eef2f7, #dde6f0);
  padding: 14px;
  aspect-ratio: 5 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
}
.card-visual svg {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.card-visual .car-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
}
.card-body {
  padding: 14px 16px 18px;
}
.card-name {
  margin: 8px 0 2px;
  font-size: 1.12rem;
}
.card-en {
  margin: 0 0 6px;
  font-size: 0.78rem;
  color: var(--accent);
  font-weight: 600;
  letter-spacing: 0.01em;
}
.card-catch {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.badge {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 60px 20px;
  grid-column: 1 / -1;
}

/* ===== モーダル ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 35, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 300;
}
.modal[hidden] {
  display: none;
}
.modal-content {
  background: var(--surface);
  border-radius: var(--radius);
  max-width: 760px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: var(--shadow-lg);
}
.modal-close {
  position: sticky;
  top: 0;
  float: right;
  margin: 10px 10px 0 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.06);
  font-size: 1.3rem;
  cursor: pointer;
  line-height: 1;
  z-index: 2;
}
.modal-close:hover {
  background: rgba(0, 0, 0, 0.12);
}
.detail-visual {
  background: linear-gradient(160deg, #eef2f7, #dde6f0);
  padding: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.detail-visual svg,
.detail-visual .car-photo {
  width: 100%;
  max-width: 460px;
  height: auto;
}
.credit {
  margin: 0;
  padding: 8px 26px;
  font-size: 0.76rem;
  color: var(--muted);
  background: #f0f3f7;
  border-bottom: 1px solid var(--border);
}
.credit a {
  color: var(--accent);
}
.detail-info {
  padding: 22px 26px 32px;
}
.detail-name {
  margin: 10px 0 2px;
  font-size: 1.5rem;
}
.detail-en {
  margin: 0 0 10px;
  font-size: 0.95rem;
  color: var(--accent);
  font-weight: 600;
}
.detail-catch {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 1rem;
}
.detail-h {
  font-size: 1.02rem;
  margin: 22px 0 8px;
  padding-left: 10px;
  border-left: 4px solid var(--accent);
}
.detail-desc,
.detail-forwho {
  margin: 0;
}
.detail-forwho {
  background: var(--accent-soft);
  padding: 12px 16px;
  border-radius: 10px;
}
.feature-list {
  margin: 0;
  padding-left: 1.2em;
}
.feature-list li {
  margin-bottom: 4px;
}

/* スペック表 */
.spec {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  margin: 0 0 4px;
}
.spec > div {
  background: #fff;
  padding: 10px 14px;
}
.spec dt {
  font-size: 0.76rem;
  color: var(--muted);
  margin: 0;
}
.spec dd {
  margin: 2px 0 0;
  font-weight: 600;
  font-size: 0.95rem;
}

/* ===== 国産/輸入車トグル ===== */
.origin-toggle {
  display: flex;
  gap: 4px;
}
.origin-btn {
  font: inherit;
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.88rem;
  white-space: nowrap;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.origin-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 700;
}
.origin-btn:hover:not(.active) {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}

/* ===== クイズ起動ボタン（ヘッダー内） ===== */
.quiz-launch-btn {
  font: inherit;
  margin-top: 18px;
  padding: 10px 26px;
  background: rgba(255, 255, 255, 0.18);
  border: 2px solid rgba(255, 255, 255, 0.65);
  border-radius: 999px;
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: background 0.15s;
}
.quiz-launch-btn:hover {
  background: rgba(255, 255, 255, 0.32);
}

/* ===== クイズオーバーレイ ===== */
.quiz-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 35, 0.62);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 200;
}
.quiz-overlay[hidden] {
  display: none;
}
.quiz-content {
  background: var(--surface);
  border-radius: var(--radius);
  max-width: 560px;
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  padding: 28px 28px 32px;
  position: relative;
}
.quiz-close-btn {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.07);
  font-size: 1.3rem;
  cursor: pointer;
  line-height: 1;
}
.quiz-close-btn:hover {
  background: rgba(0, 0, 0, 0.14);
}
.quiz-heading {
  margin: 0 0 20px;
  font-size: 1.4rem;
  text-align: center;
}
.quiz-progress-text {
  display: block;
  font-size: 0.86rem;
  color: var(--muted);
  margin-bottom: 6px;
}
.quiz-progress-track {
  height: 6px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 18px;
}
.quiz-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.35s ease;
}
.quiz-image {
  background: linear-gradient(160deg, #eef2f7, #dde6f0);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
  min-height: 160px;
}
.quiz-image svg {
  width: 100%;
  max-width: 320px;
}
.quiz-car-img {
  width: 100%;
  max-width: 340px;
  height: 190px;
  object-fit: cover;
  border-radius: 8px;
}
.quiz-question-label {
  font-weight: 700;
  font-size: 1.08rem;
  text-align: center;
  margin: 0 0 12px;
}
.quiz-result-banner {
  text-align: center;
  font-weight: 700;
  padding: 10px 16px;
  border-radius: 10px;
  margin-bottom: 12px;
  font-size: 1rem;
}
.quiz-correct {
  background: #dcfce7;
  color: #166534;
}
.quiz-wrong {
  background: #fee2e2;
  color: #991b1b;
}
.quiz-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}
.quiz-choice {
  font: inherit;
  padding: 12px 10px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-size: 0.9rem;
  text-align: center;
  line-height: 1.4;
  transition: background 0.12s, border-color 0.12s;
}
.quiz-choice:hover:not(:disabled) {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.quiz-choice.correct {
  background: #dcfce7;
  border-color: #16a34a;
  color: #166534;
  font-weight: 700;
}
.quiz-choice.wrong {
  background: #fee2e2;
  border-color: #dc2626;
  color: #991b1b;
}
.quiz-choice:disabled {
  cursor: default;
}
.quiz-next-btn {
  font: inherit;
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.12s;
}
.quiz-next-btn:hover {
  background: #1d4ed8;
}
.quiz-final {
  text-align: center;
  padding: 12px 0 8px;
}
.quiz-final-label {
  font-size: 0.88rem;
  color: var(--muted);
  margin: 0 0 8px;
  letter-spacing: 0.04em;
}
.quiz-final-score {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 4px;
}
.quiz-score-big {
  font-size: 3.8rem;
  font-weight: 900;
  color: var(--accent);
  line-height: 1;
}
.quiz-score-sep {
  font-size: 1.5rem;
  color: var(--muted);
}
.quiz-score-pct {
  font-size: 1rem;
  color: var(--muted);
}
.quiz-score-msg {
  font-size: 1.06rem;
  font-weight: 600;
  margin: 16px 0 28px;
}
.quiz-retry-btn {
  font: inherit;
  padding: 12px 32px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 999px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.12s;
}
.quiz-retry-btn:hover {
  background: #1d4ed8;
}

/* ===== フッター ===== */
.site-footer {
  text-align: center;
  padding: 24px 20px 40px;
  color: var(--muted);
  font-size: 0.82rem;
}

@media (max-width: 520px) {
  .spec {
    grid-template-columns: 1fr;
  }
  .count {
    width: 100%;
    margin-left: 0;
  }
}

/* ===== ヘッダーの機能ボタン ===== */
.header-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 18px;
}
.header-actions .quiz-launch-btn {
  margin-top: 0;
}
.timeline-launch-btn {
  font: inherit;
  padding: 10px 26px;
  background: rgba(255, 255, 255, 0.18);
  border: 2px solid rgba(255, 255, 255, 0.65);
  border-radius: 999px;
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: background 0.15s;
}
.timeline-launch-btn:hover {
  background: rgba(255, 255, 255, 0.32);
}

/* ===== 自動車史タイムライン ===== */
.tl-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 15, 25, 0.72);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 20px;
  z-index: 200;
}
.tl-overlay[hidden] {
  display: none;
}
.tl-panel {
  background: #0f1620;
  color: #e6ebf2;
  border-radius: var(--radius);
  width: 100%;
  max-width: 1200px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}
.tl-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-wrap: wrap;
}
.tl-title {
  margin: 0;
  font-size: 1.3rem;
}
.tl-stats {
  margin: 4px 0 0;
  font-size: 0.82rem;
  color: #9aa7b8;
}
.tl-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}
.tl-select {
  font: inherit;
  font-size: 0.9rem;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: #1a2431;
  color: #e6ebf2;
}
.tl-play-btn {
  font: inherit;
  font-weight: 700;
  font-size: 0.9rem;
  padding: 8px 16px;
  border-radius: 999px;
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
.tl-play-btn:hover {
  background: #1d4ed8;
}
.tl-play-btn.playing {
  background: #ef4444;
}
.tl-close-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 1.3rem;
  cursor: pointer;
  line-height: 1;
}
.tl-close-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* 動力の凡例 */
.tl-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.tl-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-size: 0.8rem;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: transparent;
  color: #c6d0dc;
  cursor: pointer;
  transition: all 0.15s;
}
.tl-legend-item:hover {
  background: rgba(255, 255, 255, 0.06);
}
.tl-legend-item.active {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.4);
}
.tl-legend-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
}

/* 年表本体（横スクロール） */
.tl-board {
  flex: 1;
  min-height: 0;
  display: flex;
  gap: 16px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 18px 22px 22px;
  scroll-behavior: smooth;
}
.tl-decade {
  flex: 0 0 300px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 12px;
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px);
  animation: tlFadeIn 0.4s ease forwards;
}
@keyframes tlFadeIn {
  to { opacity: 1; transform: none; }
}
.tl-decade-head {
  padding: 12px 14px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(255, 255, 255, 0.02);
}
.tl-decade-label {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 0.01em;
}
.tl-decade-label small {
  font-size: 0.9rem;
  color: #9aa7b8;
  margin-left: 2px;
}
.tl-decade-count {
  float: right;
  font-size: 0.78rem;
  color: #9aa7b8;
  margin-top: 10px;
}
.tl-mix {
  display: flex;
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
  margin-top: 10px;
  background: rgba(255, 255, 255, 0.06);
}
.tl-mix-seg {
  min-width: 2px;
}
.tl-decade-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-auto-rows: 158px; /* 行高さを固定してカードの潰れを防ぐ */
  gap: 10px;
  align-content: start;
}
.tl-car-name {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tl-car {
  font: inherit;
  text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-left: 3px solid var(--fuel, #94a3b8);
  background: #16202c;
  color: #e6ebf2;
  border-radius: 9px;
  padding: 0 0 8px;
  cursor: pointer;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  transition: transform 0.12s, box-shadow 0.12s, background 0.12s;
}
.tl-car:hover {
  transform: translateY(-3px);
  background: #1c2937;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}
/* 画像は固定高さで確実に表示（aspect-ratio 非対応ブラウザでも潰れない）*/
.tl-car-visual {
  display: block;
  width: 100%;
  height: 88px;
  flex: none;
  background: linear-gradient(160deg, #223042, #1a2634);
  overflow: hidden;
}
.tl-car-visual img,
.tl-car-visual svg {
  width: 100%;
  height: 88px;
  object-fit: cover;
  display: block;
}
/* 年バッジは画像の上に絶対配置 */
.tl-car-year {
  position: absolute;
  top: 6px;
  left: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #fff;
  background: var(--fuel, #94a3b8);
  padding: 1px 8px;
  border-radius: 999px;
  z-index: 1;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}
.tl-car-name {
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.3;
  margin: 8px 8px 0;
}
.tl-car-en {
  font-size: 0.68rem;
  color: #8fa0b3;
  margin: 2px 8px 0;
}
.tl-hint {
  margin: 0;
  padding: 8px 22px 14px;
  font-size: 0.76rem;
  color: #8b97a6;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.tl-empty {
  color: #9aa7b8;
  padding: 40px;
  margin: auto;
}

/* スクロールバー（暗い背景に合わせる） */
.tl-board::-webkit-scrollbar,
.tl-decade-body::-webkit-scrollbar {
  height: 10px;
  width: 8px;
}
.tl-board::-webkit-scrollbar-thumb,
.tl-decade-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 8px;
}

@media (max-width: 640px) {
  .tl-overlay { padding: 0; }
  .tl-panel { border-radius: 0; }
  .tl-decade { flex-basis: 78vw; }
}
