/* ===== Apple-inspired Design System ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --blue:       #0071e3;
  --blue-hover: #0077ed;
  --black:      #1d1d1f;
  --gray-1:     #424245;
  --gray-2:     #6e6e73;
  --gray-3:     #86868b;
  --gray-4:     #d2d2d7;
  --gray-5:     #e8e8ed;
  --gray-6:     #f5f5f7;
  --white:      #ffffff;
  --success:    #28a745;
  --danger:     #d93025;
  --warning:    #f59e0b;
  --radius-sm:  10px;
  --radius:     18px;
  --radius-lg:  24px;
}

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
               "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  background: var(--white);
  color: var(--black);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ===== ナビゲーション ===== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  height: 52px;
  display: flex;
  align-items: center;
  padding: 0 24px;
  justify-content: space-between;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  text-decoration: none;
}

.header-logo-icon {
  width: 22px;
  height: 22px;
  display: block;
}

.header-logo-text {
  font-size: 15px;
  font-weight: 600;
  color: var(--black);
  letter-spacing: -0.2px;
}

.header-logo-text span {
  font-size: 11px;
  font-weight: 400;
  color: var(--gray-3);
  display: block;
  line-height: 1.2;
}

.header-nav { display: flex; gap: 6px; }

.header-nav-btn {
  background: none;
  border: none;
  color: var(--gray-1);
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.15s;
}

.header-nav-btn:hover { background: var(--gray-6); }

/* ===== 非公式注記 ===== */
.unofficial-note {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 20px;
  font-size: 12px;
  color: var(--gray-3);
  letter-spacing: 0.01em;
  line-height: 1.5;
}

.unofficial-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gray-2);
  background: var(--gray-5);
  border: 1px solid var(--gray-4);
  padding: 2px 8px;
  border-radius: 20px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ===== コンテナ ===== */
.container {
  max-width: 920px;
  margin: 0 auto;
  padding: 0 24px 64px;
}

/* ===== ページ制御 ===== */
.page { display: none; }
.page.active { display: block; animation: fadeUp 0.4s cubic-bezier(0.25,0.46,0.45,0.94); }

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

/* ===== ホーム：ヒーロー ===== */
.home-hero {
  text-align: center;
  padding: 72px 20px 56px;
}

.home-hero-eyebrow {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--blue);
  margin-bottom: 16px;
}

.home-hero h1 {
  font-size: clamp(36px, 6vw, 60px);
  font-weight: 700;
  letter-spacing: -1.5px;
  line-height: 1.1;
  color: var(--black);
  margin-bottom: 18px;
}

.home-hero h1 em {
  font-style: normal;
  color: var(--blue);
}

.home-hero p {
  font-size: 17px;
  color: var(--gray-2);
  max-width: 480px;
  margin: 0 auto 40px;
  line-height: 1.7;
  font-weight: 400;
}

/* 統計 */
.home-stats {
  display: inline-flex;
  gap: 0;
  border: 1px solid var(--gray-5);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 0;
  background: var(--white);
}

.stat-item {
  padding: 20px 36px;
  text-align: center;
  border-right: 1px solid var(--gray-5);
}

.stat-item:last-child { border-right: none; }

.stat-num {
  font-size: 26px;
  font-weight: 700;
  color: var(--black);
  letter-spacing: -0.5px;
}

.stat-label {
  font-size: 12px;
  color: var(--gray-3);
  margin-top: 2px;
  font-weight: 500;
}

/* ===== モードカード ===== */
.mode-section {
  padding: 56px 0 0;
}

.section-eyebrow {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--blue);
  margin-bottom: 12px;
}

.section-title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--black);
  margin-bottom: 28px;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  padding-bottom: 8px; /* 影がクリップされないよう余白 */
}

.mode-card {
  background: var(--gray-6);
  border-radius: var(--radius);
  padding: 32px 28px;
  cursor: pointer;
  transition: transform 0.25s cubic-bezier(0.25,0.46,0.45,0.94),
              background 0.2s,
              box-shadow 0.25s;
  border: none;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mode-card:hover {
  background: var(--white);
  transform: translateY(-4px);
  box-shadow: 0 8px 30px rgba(0,0,0,0.1);
}

.mode-card-icon {
  width: 52px;
  height: 52px;
  background: rgba(0, 113, 227, 0.08);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}
.mode-card-icon svg {
  width: 28px;
  height: 28px;
  color: var(--blue);
}

.mode-card-title {
  font-size: 19px;
  font-weight: 700;
  color: var(--black);
  letter-spacing: -0.3px;
}

.mode-card-desc {
  font-size: 14px;
  color: var(--gray-2);
  line-height: 1.65;
  font-weight: 400;
}

.mode-card-link {
  font-size: 14px;
  font-weight: 600;
  color: var(--blue);
  margin-top: auto;
  padding-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ===== 分野別セクション ===== */
.category-section {
  margin-top: 56px;
  padding-top: 56px;
  border-top: 1px solid var(--gray-5);
}

.category-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}

.category-chip {
  background: var(--white);
  border: 1.5px solid var(--gray-4);
  color: var(--gray-1);
  padding: 8px 18px;
  border-radius: 30px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  transition: all 0.15s;
}

.category-chip:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.category-chip.active {
  background: var(--blue);
  border-color: var(--blue);
  color: var(--white);
}

/* ===== 履歴 ===== */
.history-section {
  margin-top: 56px;
  padding-top: 56px;
  border-top: 1px solid var(--gray-5);
}

.history-empty {
  color: var(--gray-3);
  font-size: 14px;
  padding: 24px 0;
}

.history-list { display: flex; flex-direction: column; gap: 10px; }

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--gray-6);
  border-radius: var(--radius-sm);
}

.history-item-mode {
  font-size: 14px;
  font-weight: 600;
  color: var(--black);
}

.history-item-date {
  font-size: 12px;
  color: var(--gray-3);
  margin-top: 2px;
}

.history-score-badge {
  font-size: 15px;
  font-weight: 700;
  padding: 4px 14px;
  border-radius: 20px;
}

.score-high { background: #d1fae5; color: #065f46; }
.score-mid  { background: #fef3c7; color: #92400e; }
.score-low  { background: #fee2e2; color: #991b1b; }

/* ===== ボタン ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 24px;
  border-radius: 980px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  white-space: nowrap;
  text-decoration: none;
}

.btn-primary {
  background: var(--blue);
  color: var(--white);
}

.btn-primary:hover {
  background: var(--blue-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--gray-6);
  color: var(--black);
}

.btn-secondary:hover { background: var(--gray-5); }

.btn-lg { padding: 16px 32px; font-size: 16px; }
.btn-block { width: 100%; border-radius: var(--radius-sm); }

/* ===== 試験設定 ===== */
.exam-setup {
  padding: 56px 0;
  max-width: 640px;
  margin: 0 auto;
}

.setup-title {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -1px;
  margin-bottom: 8px;
  color: var(--black);
}

.setup-subtitle {
  font-size: 16px;
  color: var(--gray-2);
  margin-bottom: 40px;
}

.setup-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}

.setup-options {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 32px;
}

.setup-option {
  background: var(--gray-6);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  padding: 20px 12px;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
}

.setup-option:hover { background: var(--gray-5); }

.setup-option.selected {
  background: #e8f0fe;
  border-color: var(--blue);
}

.setup-option-num {
  font-size: 22px;
  font-weight: 700;
  color: var(--black);
}

.setup-option-label {
  font-size: 12px;
  color: var(--gray-3);
  margin-top: 4px;
}

.setup-info {
  background: var(--gray-6);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  font-size: 14px;
  color: var(--gray-2);
  line-height: 1.7;
  margin-bottom: 28px;
}

.setup-actions { display: flex; gap: 12px; }

/* ===== クイズ ===== */
.quiz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 0 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.quiz-progress-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.quiz-count {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-2);
}

.quiz-category-tag {
  background: #e8f0fe;
  color: var(--blue);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
}

.timer {
  font-size: 17px;
  font-weight: 700;
  color: var(--black);
  background: var(--gray-6);
  padding: 8px 18px;
  border-radius: 20px;
  font-variant-numeric: tabular-nums;
  transition: background 0.3s, color 0.3s;
}

.timer.warning { background: #fef3c7; color: #92400e; }
.timer.danger  { background: #fee2e2; color: var(--danger); }

.quiz-progress-bar {
  height: 3px;
  background: var(--gray-5);
  border-radius: 2px;
  margin-bottom: 28px;
  overflow: hidden;
}

.quiz-progress-fill {
  height: 100%;
  background: var(--blue);
  border-radius: 2px;
  transition: width 0.4s cubic-bezier(0.25,0.46,0.45,0.94);
}

/* 問題カード */
.question-card {
  background: var(--white);
  border: 1px solid var(--gray-5);
  border-radius: var(--radius-lg);
  padding: 36px 36px 28px;
  margin-bottom: 16px;
  animation: fadeUp 0.3s ease;
}

.question-num {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--blue);
  margin-bottom: 14px;
}

.question-text {
  font-size: 19px;
  font-weight: 600;
  color: var(--black);
  line-height: 1.55;
  margin-bottom: 28px;
  letter-spacing: -0.2px;
}

/* 選択肢 */
.options-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.option-btn {
  width: 100%;
  text-align: left;
  background: var(--gray-6);
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  font-size: 15px;
  font-weight: 500;
  font-family: inherit;
  color: var(--black);
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  line-height: 1.5;
}

.option-btn:hover:not(:disabled) {
  background: #e8f0fe;
  border-color: var(--blue);
  color: var(--black);
}

.option-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  min-width: 28px;
  background: var(--white);
  border-radius: 50%;
  font-size: 13px;
  font-weight: 700;
  color: var(--gray-2);
  border: 1.5px solid var(--gray-4);
  flex-shrink: 0;
  margin-top: 1px;
}

.option-btn:hover:not(:disabled) .option-label {
  border-color: var(--blue);
  color: var(--blue);
}

.option-btn.correct {
  background: #d1fae5;
  border-color: #059669;
}

.option-btn.correct .option-label {
  background: #059669;
  border-color: #059669;
  color: var(--white);
}

.option-btn.wrong {
  background: #fee2e2;
  border-color: var(--danger);
}

.option-btn.wrong .option-label {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--white);
}

.option-btn.correct-answer {
  background: #d1fae5;
  border-color: #059669;
}

.option-btn.correct-answer .option-label {
  background: #059669;
  border-color: #059669;
  color: var(--white);
}

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

/* 試験モード：選択済み（正誤は非表示） */
.option-btn.exam-selected {
  background: #EEF2FF;
  border-color: var(--blue);
}
.option-btn.exam-selected .option-label {
  background: var(--blue);
  border-color: var(--blue);
  color: var(--white);
}

/* 解説ボックス */
.explanation-box {
  background: #f0f7ff;
  border-radius: var(--radius-sm);
  padding: 18px 22px;
  margin-top: 20px;
  font-size: 14px;
  color: var(--gray-1);
  line-height: 1.75;
  display: none;
  border-left: 3px solid var(--blue);
}

.explanation-box.show { display: block; }

.explanation-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--blue);
  margin-bottom: 8px;
}

/* フィードバック */
.practice-feedback {
  text-align: center;
  padding: 14px;
  border-radius: var(--radius-sm);
  margin-top: 14px;
  font-size: 16px;
  font-weight: 700;
  display: none;
}

.practice-feedback.correct { background: #d1fae5; color: #065f46; display: block; }
.practice-feedback.wrong   { background: #fee2e2; color: #991b1b; display: block; }

/* 次へボタン（カード内） */
.next-btn-wrap {
  margin-top: 20px;
}

.btn-next {
  width: 100%;
  border-radius: var(--radius-sm);
  padding: 16px;
  font-size: 16px;
  font-weight: 700;
}

/* ===== 結果画面 ===== */
.result-hero {
  text-align: center;
  padding: 64px 24px 48px;
}

.result-emoji { font-size: 64px; margin-bottom: 16px; }

.result-title {
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -1px;
  color: var(--black);
  margin-bottom: 8px;
}

.result-subtitle {
  font-size: 15px;
  color: var(--gray-3);
  margin-bottom: 32px;
}

.result-score-ring {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: var(--gray-6);
  border: 6px solid var(--blue);
  margin-bottom: 20px;
}

.result-score {
  font-size: 48px;
  font-weight: 800;
  color: var(--black);
  letter-spacing: -2px;
  line-height: 1;
}

.result-score-label {
  font-size: 13px;
  color: var(--gray-3);
  font-weight: 500;
  margin-top: 2px;
}

.result-pass {
  display: inline-block;
  font-size: 14px;
  font-weight: 600;
  padding: 8px 20px;
  border-radius: 20px;
}

.result-pass.pass { background: #d1fae5; color: #065f46; }
.result-pass.fail { background: #fee2e2; color: #991b1b; }

/* 統計カード */
.result-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 0 0 40px;
}

.result-stat-card {
  background: var(--gray-6);
  border-radius: var(--radius-sm);
  padding: 24px 16px;
  text-align: center;
}

.result-stat-num {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--black);
}

.result-stat-label {
  font-size: 12px;
  color: var(--gray-3);
  font-weight: 500;
  margin-top: 4px;
}

/* カテゴリ別 */
.category-results {
  border: 1px solid var(--gray-5);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 24px;
}

.category-results .section-title {
  font-size: 18px;
  margin-bottom: 20px;
}

.category-result-item { margin-bottom: 16px; }
.category-result-item:last-child { margin-bottom: 0; }

.category-result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.category-result-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--black);
}

.category-result-score {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-2);
}

.category-bar {
  height: 6px;
  background: var(--gray-5);
  border-radius: 3px;
  overflow: hidden;
}

.category-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.8s cubic-bezier(0.25,0.46,0.45,0.94);
}

/* レビューリスト */
.review-list {
  border: 1px solid var(--gray-5);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 32px;
  text-align: left;
}

.review-list .section-title {
  font-size: 18px;
  margin-bottom: 4px;
}

.review-item {
  border-bottom: 1px solid var(--gray-6);
  padding: 14px 0;
  font-size: 14px;
}

.review-item:last-child { border-bottom: none; }

.review-item-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 4px;
}

.review-icon { font-size: 16px; min-width: 20px; }

.review-question {
  font-weight: 600;
  color: var(--black);
  line-height: 1.5;
}

.review-answer {
  margin-left: 30px;
  font-size: 13px;
  color: var(--gray-2);
  line-height: 1.6;
}

.review-correct-text { color: var(--success); font-weight: 500; }
.review-wrong-text   { color: var(--danger);  font-weight: 500; }

.review-explanation {
  margin-top: 8px;
  margin-left: 30px;
  font-size: 13px;
  color: var(--gray-2);
  background: #f0f7ff;
  border-left: 3px solid var(--blue);
  padding: 8px 12px;
  border-radius: 0 6px 6px 0;
  line-height: 1.65;
}

/* 結果アクション */
.result-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  padding-bottom: 60px;
}

/* ===== カウントダウン ===== */
.countdown-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.countdown-overlay.show { display: flex; }

.countdown-box {
  background: var(--white);
  border-radius: 28px;
  padding: 52px 72px;
  text-align: center;
}

.countdown-num {
  font-size: 88px;
  font-weight: 800;
  color: var(--blue);
  line-height: 1;
  letter-spacing: -4px;
  animation: pulse 1s ease infinite;
}

.countdown-text {
  font-size: 16px;
  color: var(--gray-3);
  margin-top: 8px;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.04); }
}

/* ===== レスポンシブ ===== */
@media (max-width: 700px) {
  .mode-grid { grid-template-columns: 1fr; }
  .setup-options { grid-template-columns: repeat(2, 1fr); }
  .result-stats { grid-template-columns: 1fr; }
  .home-stats { flex-direction: column; border: none; gap: 24px; }
  .stat-item { border: 1px solid var(--gray-5); border-radius: var(--radius-sm); padding: 16px 24px; }
  .container { padding: 0 16px 48px; }
  .question-card { padding: 24px 20px; }
  .question-text { font-size: 16px; }
  .option-btn { font-size: 14px; }
}
