/* ==========================================================================
   フランカー課題 (Eriksen Flanker Task) スタイルシート
   CogLab 共通統一デザイン
   ========================================================================== */

:root {
  --bg-color: #0b0f17;
  --surface-color: #131b26;
  --surface-alt: #1a2434;
  --surface-border: #243247;
  --surface-hover: #223046;

  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --primary: #38bdf8;
  --primary-hover: #0ea5e9;
  --primary-glow: rgba(56, 189, 248, 0.25);

  --accent-congruent: #22c55e;
  --accent-congruent-bg: rgba(34, 197, 94, 0.12);
  --accent-incongruent: #ef4444;
  --accent-incongruent-bg: rgba(239, 68, 68, 0.12);
  --accent-neutral: #a855f7;
  --accent-neutral-bg: rgba(168, 85, 247, 0.12);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.55);

  --font-sans: 'Inter', 'Noto Sans JP', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-color);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* 共通ユーティリティ */
.d-none { display: none !important; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.text-center { text-align: center; }

/* CogLab 共通トップバー */
.coglab-top-bar {
  background: #06090e;
  border-bottom: 1px solid var(--surface-border);
  font-size: 13px;
  padding: 6px 16px;
}
.coglab-bar-inner {
  max-width: 1080px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
.coglab-badge {
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.coglab-app-links {
  display: flex;
  align-items: center;
  gap: 8px;
}
.coglab-app-link {
  color: var(--text-dim);
  text-decoration: none;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  transition: all 0.2s ease;
  font-weight: 500;
}
.coglab-app-link:hover {
  color: var(--text-main);
  background: var(--surface-alt);
}
.coglab-app-link.active {
  color: var(--primary);
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
  font-weight: 700;
}

/* レイアウト構成 */
.app-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ヘッダー */
.app-header {
  background-color: var(--surface-color);
  border-bottom: 1px solid var(--surface-border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}
.header-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  text-decoration: none;
}
.brand-icon {
  font-size: 28px;
  line-height: 1;
  filter: drop-shadow(0 0 10px rgba(56, 189, 248, 0.4));
}
.brand-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-main);
  line-height: 1.2;
}
.brand-badge {
  font-size: 11px;
  color: var(--primary);
  font-weight: 600;
  display: block;
}

/* ナビゲーションタブ */
.nav-tabs {
  display: flex;
  gap: 6px;
  background-color: var(--surface-alt);
  padding: 4px;
  border-radius: var(--radius-full);
  border: 1px solid var(--surface-border);
}
.nav-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.2s ease;
}
.nav-btn:hover {
  color: var(--text-main);
}
.nav-btn.active {
  background-color: var(--primary);
  color: #051322;
  box-shadow: 0 2px 8px var(--primary-glow);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.icon-toggle-btn {
  background: var(--surface-alt);
  border: 1px solid var(--surface-border);
  color: var(--text-main);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 16px;
}
.icon-toggle-btn:hover {
  background: var(--surface-hover);
  border-color: var(--primary);
}
.user-pill {
  font-size: 12px;
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-weight: 600;
}
.login-link-pill {
  font-size: 12px;
  background: var(--surface-alt);
  color: var(--text-muted);
  border: 1px solid var(--surface-border);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  text-decoration: none;
  font-weight: 600;
  transition: all 0.2s;
}
.login-link-pill:hover {
  color: var(--primary);
  border-color: var(--primary);
}

/* メインコンテナ */
.main-content {
  flex: 1;
  max-width: 1080px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 20px 60px;
}
.view-panel {
  display: none;
}
.view-panel.active {
  display: block;
}

/* パネルカード共通 */
.panel-card {
  background-color: var(--surface-color);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-md);
}

/* ヒーローヘッダー */
.card-hero {
  text-align: center;
  max-width: 680px;
  margin: 0 auto 32px;
}
.hero-badge {
  display: inline-block;
  background: rgba(56, 189, 248, 0.14);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.35);
  font-size: 12px;
  font-weight: 700;
  padding: 4px 14px;
  border-radius: var(--radius-full);
  margin-bottom: 14px;
  letter-spacing: 0.04em;
}
.hero-title {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
  color: #ffffff;
}
.hero-desc {
  font-size: 15px;
  color: var(--text-muted);
  line-height: 1.7;
}

/* 設定グリッド */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 28px;
}
.setting-label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
}

.mode-select-buttons {
  display: flex;
  gap: 10px;
}
.mode-opt-btn {
  flex: 1;
  background: var(--surface-alt);
  border: 2px solid var(--surface-border);
  border-radius: var(--radius-md);
  padding: 14px 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.mode-opt-btn:hover {
  border-color: rgba(56, 189, 248, 0.5);
  background: var(--surface-hover);
}
.mode-opt-btn.active {
  border-color: var(--primary);
  background: rgba(56, 189, 248, 0.08);
  box-shadow: 0 0 16px var(--primary-glow);
}
.mode-opt-btn .opt-title {
  font-size: 15px;
  font-weight: 800;
}
.mode-opt-btn .opt-desc {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.3;
}

/* 刺激タイプ選択ボタン */
.stimulus-select-buttons {
  display: flex;
  gap: 10px;
}
.stimulus-opt-btn {
  flex: 1;
  background: var(--surface-alt);
  border: 2px solid var(--surface-border);
  border-radius: var(--radius-md);
  padding: 14px 12px;
  text-align: center;
  cursor: pointer;
  color: var(--text-main);
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stimulus-opt-btn:hover {
  border-color: rgba(56, 189, 248, 0.5);
  background: var(--surface-hover);
}
.stimulus-opt-btn.active {
  border-color: var(--primary);
  background: rgba(56, 189, 248, 0.08);
  box-shadow: 0 0 16px var(--primary-glow);
}
.stim-preview {
  font-size: 18px;
  font-weight: 800;
  font-family: var(--font-mono);
  letter-spacing: 0.1em;
  color: var(--primary);
}
.stim-name {
  font-size: 12px;
  color: var(--text-muted);
}

/* 操作ガイド */
.guide-box {
  background: var(--surface-alt);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  margin-bottom: 28px;
}
.guide-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 14px;
}
.guide-keys {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.guide-key-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.k-badge {
  background: #0f172a;
  color: #38bdf8;
  border: 1px solid #38bdf8;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 6px;
  box-shadow: 0 2px 0 #0284c7;
}
.k-desc {
  color: var(--text-main);
}
.guide-tip {
  font-size: 12px;
  color: var(--text-muted);
}

/* アクションボタン群 */
.start-actions {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
}
.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(135deg, #38bdf8 0%, #0284c7 100%);
  color: #041220;
  border: none;
  font-size: 16px;
  font-weight: 800;
  padding: 14px 32px;
  border-radius: var(--radius-full);
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(56, 189, 248, 0.4);
  transition: all 0.2s ease;
}
.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(56, 189, 248, 0.55);
}
.primary-btn:active {
  transform: translateY(0);
}
.primary-btn.pulse {
  animation: startPulse 2s infinite;
}
@keyframes startPulse {
  0%, 100% { box-shadow: 0 4px 18px rgba(56, 189, 248, 0.35); }
  50% { box-shadow: 0 6px 26px rgba(56, 189, 248, 0.65); }
}

.secondary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--surface-alt);
  color: var(--text-main);
  border: 1px solid var(--surface-border);
  font-size: 14px;
  font-weight: 700;
  padding: 14px 24px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.2s;
}
.secondary-btn:hover {
  background: var(--surface-hover);
  border-color: var(--text-muted);
}
.btn-sm {
  padding: 8px 16px;
  font-size: 12px;
}

/* ==============================================
   タスク実行中画面
   ============================================== */
.task-card {
  padding: 24px 28px;
  position: relative;
  min-height: 520px;
  display: flex;
  flex-direction: column;
}
.task-hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.hud-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.hud-badge {
  background: rgba(56, 189, 248, 0.15);
  color: var(--primary);
  border: 1px solid rgba(56, 189, 248, 0.3);
  font-size: 13px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: var(--radius-full);
}
.hud-trial-count {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-muted);
}
.hud-abort-btn {
  background: transparent;
  border: 1px solid var(--surface-border);
  color: var(--text-dim);
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}
.hud-abort-btn:hover {
  color: #ef4444;
  border-color: #ef4444;
}

.task-progress-track {
  width: 100%;
  height: 6px;
  background: var(--surface-alt);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: 14px;
}
.task-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #38bdf8, #22c55e);
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.rule-reminder {
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.rule-reminder strong {
  color: var(--primary);
}

/* 刺激提示ステージ */
.stimulus-stage {
  flex: 1;
  min-height: 260px;
  background: #080d14;
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  margin-bottom: 24px;
}

.fixation-cross {
  font-size: 52px;
  font-weight: 300;
  color: var(--text-dim);
  line-height: 1;
}

.stimulus-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}
.stimulus-char {
  font-family: var(--font-mono);
  font-size: 80px;
  font-weight: 900;
  line-height: 1;
  color: var(--text-muted);
  transition: all 0.08s ease;
}
.stimulus-char.target {
  color: #ffffff;
  text-shadow: 0 0 30px rgba(56, 189, 248, 0.8);
  transform: scale(1.1);
}

.countdown-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(11, 15, 23, 0.85);
}
.countdown-num {
  font-size: 80px;
  font-weight: 900;
  color: var(--primary);
  animation: popWord 0.4s ease-out;
}

.feedback-toast {
  position: absolute;
  top: 16px;
  right: 16px;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-weight: 800;
  font-size: 13px;
  font-family: var(--font-mono);
  pointer-events: none;
}
.feedback-toast.correct {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
  border: 1px solid #22c55e;
}
.feedback-toast.wrong {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border: 1px solid #ef4444;
}

/* 操作ボタン */
.response-controls {
  margin-top: auto;
}
.flanker-buttons-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.flanker-btn {
  background: var(--surface-alt);
  border: 2px solid var(--surface-border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-main);
  transition: all 0.1s ease;
  touch-action: manipulation;
}
.flanker-btn:active, .flanker-btn.active-press {
  transform: scale(0.97);
  border-color: var(--primary);
  box-shadow: 0 0 20px var(--primary-glow);
}
.flanker-btn .btn-k-hint {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.35);
  padding: 2px 8px;
  border-radius: 4px;
  margin-bottom: 6px;
  border: 1px solid rgba(255, 255, 255, 0.15);
}
.flanker-btn .btn-main-label {
  font-size: 20px;
  font-weight: 900;
}

/* ==============================================
   リザルト画面
   ============================================== */
.result-header {
  text-align: center;
  margin-bottom: 24px;
}
.result-badge {
  display: inline-block;
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.35);
  font-size: 12px;
  font-weight: 700;
  padding: 4px 14px;
  border-radius: var(--radius-full);
  margin-bottom: 10px;
}
.result-title {
  font-size: 26px;
  font-weight: 800;
  color: #ffffff;
}
.result-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* 総合ランクカード */
.rank-card {
  background: linear-gradient(135deg, #162032 0%, #0e1724 100%);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  margin-bottom: 24px;
}
.rank-badge-circle {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: radial-gradient(circle, #38bdf8 0%, #0284c7 100%);
  color: #051322;
  font-size: 38px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 24px rgba(56, 189, 248, 0.5);
  flex-shrink: 0;
}
.rank-badge-circle.rank-s {
  background: radial-gradient(circle, #f59e0b 0%, #d97706 100%);
  color: #1f1203;
  box-shadow: 0 0 28px rgba(245, 158, 11, 0.6);
}
.rank-badge-circle.rank-a {
  background: radial-gradient(circle, #38bdf8 0%, #0284c7 100%);
  color: #041220;
}
.rank-badge-circle.rank-b {
  background: radial-gradient(circle, #10b981 0%, #059669 100%);
  color: #022013;
}
.rank-badge-circle.rank-c {
  background: radial-gradient(circle, #a855f7 0%, #7c3aed 100%);
  color: #1c052e;
}
.rank-badge-circle.rank-d {
  background: radial-gradient(circle, #64748b 0%, #475569 100%);
  color: #0b0f17;
}

.rank-details { flex: 1; }
.rank-title {
  font-size: 18px;
  font-weight: 800;
  color: #ffffff;
  margin-bottom: 4px;
}
.rank-comment {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
}

/* メトリクスグリッド */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}
.metric-card {
  background: var(--surface-alt);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
}
.metric-card.highlight {
  border-color: rgba(56, 189, 248, 0.5);
  background: rgba(56, 189, 248, 0.05);
}
.metric-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.metric-value-row {
  display: flex;
  align-items: baseline;
  gap: 4px;
  margin-bottom: 4px;
}
.metric-value {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 800;
  color: #ffffff;
}
.metric-unit {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 700;
}
.metric-sub {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: auto;
}

/* 条件別比較バー */
.condition-compare-card {
  background: var(--surface-alt);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 24px;
}
.card-subtitle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.section-subheading {
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
}
.subheading-note {
  font-size: 11px;
  color: var(--text-muted);
}

.condition-bars {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.cond-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cond-meta {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 700;
}
.cond-name.congruent { color: var(--accent-congruent); }
.cond-name.incongruent { color: var(--accent-incongruent); }
.cond-name.neutral { color: var(--accent-neutral); }
.cond-rt { font-family: var(--font-mono); color: #ffffff; }
.cond-acc { font-family: var(--font-mono); color: var(--text-muted); font-size: 12px; }

.cond-bar-track {
  width: 100%;
  height: 10px;
  background: #0d141f;
  border-radius: var(--radius-full);
  overflow: hidden;
  border: 1px solid var(--surface-border);
}
.cond-bar {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.6s ease-out;
}
.cond-bar.congruent { background: var(--accent-congruent); }
.cond-bar.incongruent { background: var(--accent-incongruent); }
.cond-bar.neutral { background: var(--accent-neutral); }

/* チャートカード */
.chart-card {
  background: var(--surface-alt);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 24px;
}
.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 10px;
}
.chart-title {
  font-size: 14px;
  font-weight: 700;
}
.chart-legend {
  display: flex;
  gap: 14px;
  font-size: 11px;
  color: var(--text-muted);
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.dot.congruent { background: var(--accent-congruent); }
.dot.incongruent { background: var(--accent-incongruent); }
.dot.neutral { background: var(--accent-neutral); }
.dot.error { background: #64748b; }

.chart-svg-container {
  width: 100%;
  overflow-x: auto;
  min-height: 180px;
}
.timeline-svg {
  width: 100%;
  height: 180px;
}

/* アコーディオン & テーブル */
.trial-details-accordion {
  background: var(--surface-alt);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  margin-bottom: 24px;
  overflow: hidden;
}
.details-summary {
  padding: 14px 20px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  color: var(--text-muted);
  user-select: none;
}
.details-summary:hover {
  color: var(--text-main);
}
.table-responsive {
  width: 100%;
  overflow-x: auto;
}
.trial-table, .history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  text-align: left;
}
.trial-table th, .trial-table td,
.history-table th, .history-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--surface-border);
}
.trial-table th, .history-table th {
  background: #0f1724;
  color: var(--text-muted);
  font-weight: 700;
}
.trial-table td, .history-table td {
  color: var(--text-main);
  font-family: var(--font-mono);
}
.trial-table tr:last-child td,
.history-table tr:last-child td {
  border-bottom: none;
}
.badge-cond {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 700;
}
.badge-cond.congruent { background: var(--accent-congruent-bg); color: var(--accent-congruent); }
.badge-cond.incongruent { background: var(--accent-incongruent-bg); color: var(--accent-incongruent); }
.badge-cond.neutral { background: var(--accent-neutral-bg); color: var(--accent-neutral); }

/* アクションボタン */
.result-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}
.share-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(135deg, #a855f7 0%, #7c3aed 100%);
  color: #ffffff;
  border: none;
  font-size: 14px;
  font-weight: 700;
  padding: 14px 24px;
  border-radius: var(--radius-full);
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(168, 85, 247, 0.4);
  transition: all 0.2s;
}
.share-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(168, 85, 247, 0.6);
}

/* ==============================================
   履歴・科学解説画面
   ============================================== */
.history-header, .science-header {
  margin-bottom: 24px;
}
.section-title {
  font-size: 22px;
  font-weight: 800;
  color: #ffffff;
  margin-bottom: 6px;
}
.section-subtitle {
  font-size: 13px;
  color: var(--text-muted);
}

.history-chart-card {
  background: var(--surface-alt);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  padding: 20px;
}
.history-svg-container {
  width: 100%;
  height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chart-placeholder {
  color: var(--text-dim);
  font-size: 13px;
}

/* 科学解説 */
.science-article {
  color: #cbd5e1;
  font-size: 15px;
  line-height: 1.8;
}
.science-article h3 {
  font-size: 18px;
  font-weight: 800;
  color: #ffffff;
  margin: 28px 0 12px;
  border-left: 4px solid var(--primary);
  padding-left: 12px;
}
.science-article p { margin-bottom: 16px; }
.science-article ul { margin-left: 20px; margin-bottom: 20px; }
.science-article li { margin-bottom: 8px; }
.science-callout {
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: var(--radius-md);
  padding: 18px 22px;
  margin: 20px 0;
}
.science-callout h4 {
  color: #38bdf8;
  font-size: 15px;
  font-weight: 800;
  margin-bottom: 8px;
}
.math-formula-box {
  background: #0f172a;
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-sm);
  padding: 14px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 16px;
  color: var(--primary);
  margin: 16px 0;
}

.tips-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 18px;
}
.tip-card {
  background: var(--surface-alt);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  padding: 18px;
}
.tip-num {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 800;
  color: var(--primary);
  display: block;
  margin-bottom: 6px;
}
.tip-card h4 {
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 8px;
}
.tip-card p {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 0;
}

/* フッター */
.app-footer {
  border-top: 1px solid var(--surface-border);
  background: #06090e;
  padding: 24px 20px;
  margin-top: auto;
}
.footer-inner {
  max-width: 1080px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12px;
  color: var(--text-dim);
}
.footer-links {
  display: flex;
  gap: 16px;
}
.footer-links a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s;
}
.footer-links a:hover {
  color: var(--primary);
}

/* トースト通知 */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1e293b;
  color: #ffffff;
  padding: 10px 20px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
  z-index: 1000;
  border: 1px solid var(--surface-border);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* レスポンシブ */
@media (max-width: 768px) {
  .header-inner { padding: 10px 14px; }
  .brand-title { font-size: 17px; }
  .nav-btn .nav-label { display: none; }
  .nav-btn { padding: 6px 10px; }
  .main-content { padding: 16px 12px 40px; }
  .panel-card { padding: 20px 16px; }
  .hero-title { font-size: 22px; }
  .settings-grid { grid-template-columns: 1fr; gap: 16px; }
  .mode-select-buttons, .stimulus-select-buttons { flex-direction: column; }
  .guide-keys { flex-direction: column; gap: 8px; }
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .tips-grid { grid-template-columns: 1fr; }
  .rank-card { flex-direction: column; text-align: center; }
  .stimulus-char { font-size: 52px; }
  .stimulus-display { gap: 8px; }
}
