/* Typing Trainer - Modern Minimal Dark Theme */
:root {
  --bg-color: #0b0f19;
  --surface-color: #151d2f;
  --surface-border: #222f49;
  --text-main: #f1f5f9;
  --text-muted: #64748b;
  --text-sub: #94a3b8;
  --accent-cyan: #00e5ff;
  --accent-green: #10b981;
  --accent-red: #ef4444;
  --accent-orange: #f59e0b;
  --key-bg: #1e293b;
  --key-border: #334155;
  --key-active: #0284c7;
}

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

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  user-select: none;
  overflow-x: hidden;
}

#app {
  width: 100%;
  max-width: 900px;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ヘッダー */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--surface-border);
  padding-bottom: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-badge {
  background: linear-gradient(135deg, #00e5ff, #3b82f6);
  color: #000;
  font-weight: 800;
  font-size: 0.85rem;
  padding: 4px 8px;
  border-radius: 6px;
  letter-spacing: 0.5px;
}

h1 {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.header-controls {
  display: flex;
  gap: 10px;
}

.btn-ctrl {
  background: var(--surface-color);
  border: 1px solid var(--surface-border);
  color: var(--text-sub);
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-ctrl:hover {
  background: var(--surface-border);
  color: var(--text-main);
}

.btn-ctrl.muted {
  color: var(--accent-red);
}

/* 苦手キー集中バー */
.focus-bar {
  background: var(--surface-color);
  border: 1px solid var(--surface-border);
  border-radius: 12px;
  padding: 12px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.focus-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-sub);
  display: flex;
  align-items: center;
  gap: 6px;
}

.focus-badges {
  display: flex;
  gap: 8px;
  align-items: center;
}

.badge-neutral {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.badge-weak {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  border-radius: 6px;
  padding: 2px 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.badge-key {
  font-weight: 700;
  color: #fca5a5;
  font-size: 0.9rem;
}

.badge-count {
  font-size: 0.75rem;
  color: var(--accent-red);
}

/* リアルタイムステータス */
.stats-bar {
  display: flex;
  justify-content: space-around;
  background: rgba(21, 29, 47, 0.5);
  border: 1px solid var(--surface-border);
  border-radius: 10px;
  padding: 10px;
}

.stat-item {
  text-align: center;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-main);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* タイピングステージ */
.stage {
  position: relative;
  background: var(--surface-color);
  border: 1px solid var(--surface-border);
  border-radius: 16px;
  padding: 36px 30px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 240px;
  justify-content: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

/* 今回の弱点克服ターゲット通知 */
.target-badge-container {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  margin-bottom: 4px;
}

.target-label {
  color: var(--accent-orange);
  font-weight: 600;
}

.target-key-pill {
  background: var(--accent-orange);
  color: #000;
  font-weight: 800;
  padding: 1px 8px;
  border-radius: 4px;
  font-size: 0.8rem;
}

/* テキスト表示部 */
.sentence-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sentence-text {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #ffffff;
  line-height: 1.3;
}

.sentence-kana {
  font-size: 1.1rem;
  color: var(--text-sub);
  letter-spacing: 1px;
}

.romaji-guide {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 1.5rem;
  letter-spacing: 2px;
  margin-top: 6px;
  display: flex;
  align-items: center;
}

.romaji-completed {
  color: var(--accent-cyan);
  font-weight: 600;
}

.expected-char {
  color: #ffffff;
  background: rgba(0, 229, 255, 0.25);
  border-bottom: 3px solid var(--accent-cyan);
  border-radius: 2px 2px 0 0;
  font-weight: 700;
  animation: pulse-cursor 0.9s infinite alternate;
}

.expected-char:empty {
  display: none;
}

@keyframes pulse-cursor {
  from { background: rgba(0, 229, 255, 0.15); }
  to { background: rgba(0, 229, 255, 0.45); }
}

.romaji-remaining {
  color: var(--text-muted);
}

/* キーボードUI ＆ 運指ガイド */
.keyboard-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

/* リアルタイム指ガイドバー */
.finger-guide-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  max-width: 580px;
  background: rgba(30, 41, 59, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 6px 14px;
  border-radius: 20px;
  margin-bottom: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.fg-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-guide-toggle {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #e2e8f0;
  border-radius: 12px;
  padding: 4px 12px;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.btn-guide-toggle:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: var(--accent-cyan);
  color: #ffffff;
}

.finger-guide-icon {
  font-size: 1rem;
}

.finger-guide-label {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.finger-guide-pill {
  font-weight: 700;
  padding: 3px 12px;
  border-radius: 12px;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
  transition: all 0.15s ease;
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* --- 手のビジュアルグラフィック（10本指イメージ） --- */
.hands-container {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 36px;
  margin-top: 14px;
  padding: 6px 0 10px 0;
  min-height: 95px;
}

.hand {
  display: flex;
  align-items: flex-end;
  gap: 5px;
}

.hands-space-gap {
  width: 24px;
}

.finger {
  width: 33px;
  background: #334155;
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px 16px 4px 4px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  padding-bottom: 8px;
  color: #94a3b8;
  font-size: 0.72rem;
  font-weight: 700;
  user-select: none;
  position: relative;
  transition: transform 0.12s ease, background 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

/* 自然な指の長さの比率 */
.finger-lp, .finger-rp { height: 56px; }  /* 小指 */
.finger-lr, .finger-rr { height: 74px; }  /* 薬指 */
.finger-lm, .finger-rm { height: 84px; }  /* 中指 */
.finger-li, .finger-ri { height: 72px; }  /* 人差し指 */
.finger-thumb { height: 44px; width: 34px; } /* 親指 */

.fn-name {
  pointer-events: none;
  font-size: 0.75rem;
}

/* 指がアクティブになった時のアニメーション ＆ 発光 */
.finger.active-finger {
  background: linear-gradient(180deg, #ff9800 0%, #f57c00 100%) !important;
  border-color: #ffe082 !important;
  color: #ffffff !important;
  font-weight: 900 !important;
  transform: translateY(-8px) scale(1.06) !important;
  box-shadow: 0 0 18px rgba(255, 152, 0, 0.85), 0 0 35px rgba(255, 152, 0, 0.45) !important;
  z-index: 5;
}

.finger.active-finger .fn-name {
  color: #ffffff !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

/* 指カラー定義（バッジ用・キー下線用・凡例用） */
.finger-pill-lp, .dot-lp { color: #f472b6 !important; background-color: rgba(244, 114, 182, 0.25) !important; border: 1px solid #f472b6 !important; }
.finger-pill-lr, .dot-lr { color: #fb923c !important; background-color: rgba(251, 146, 60, 0.25) !important; border: 1px solid #fb923c !important; }
.finger-pill-lm, .dot-lm { color: #facc15 !important; background-color: rgba(250, 204, 21, 0.25) !important; border: 1px solid #facc15 !important; }
.finger-pill-li, .dot-li { color: #4ade80 !important; background-color: rgba(74, 222, 128, 0.25) !important; border: 1px solid #4ade80 !important; }
.finger-pill-ri, .dot-ri { color: #38bdf8 !important; background-color: rgba(56, 189, 248, 0.25) !important; border: 1px solid #38bdf8 !important; }
.finger-pill-rm, .dot-rm { color: #818cf8 !important; background-color: rgba(129, 140, 248, 0.25) !important; border: 1px solid #818cf8 !important; }
.finger-pill-rr, .dot-rr { color: #c084fc !important; background-color: rgba(192, 132, 252, 0.25) !important; border: 1px solid #c084fc !important; }
.finger-pill-rp, .dot-rp { color: #fb7185 !important; background-color: rgba(251, 113, 133, 0.25) !important; border: 1px solid #fb7185 !important; }

/* 指ガイド凡例 */
.finger-legend {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.legend-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.legend-hand-label {
  font-weight: 700;
  color: var(--text-sub);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.dot-lp { background: #f472b6 !important; border-color: #f472b6 !important; }
.dot-lr { background: #fb923c !important; border-color: #fb923c !important; }
.dot-lm { background: #facc15 !important; border-color: #facc15 !important; }
.dot-li { background: #4ade80 !important; border-color: #4ade80 !important; }
.dot-ri { background: #38bdf8 !important; border-color: #38bdf8 !important; }
.dot-rm { background: #818cf8 !important; border-color: #818cf8 !important; }
.dot-rr { background: #c084fc !important; border-color: #c084fc !important; }
.dot-rp { background: #fb7185 !important; border-color: #fb7185 !important; }

.legend-sep {
  color: rgba(255, 255, 255, 0.2);
}

.kb-row {
  display: flex;
  gap: 6px;
}

.kb-row-0 {
  padding-left: 0;
}

.kb-row-1 {
  padding-left: 20px;
}

.kb-row-2 {
  padding-left: 34px;
}

.kb-row-3 {
  padding-left: 54px;
}

.kb-key {
  width: 44px;
  height: 44px;
  background: var(--key-bg);
  border: 1px solid var(--key-border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: var(--text-sub);
  font-weight: 600;
  font-size: 0.9rem;
  position: relative;
  transition: transform 0.08s ease, background-color 0.15s ease, border-color 0.15s ease;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.home-key .home-bump {
  width: 8px;
  height: 2px;
  background: var(--text-muted);
  position: absolute;
  bottom: 6px;
  border-radius: 1px;
}

/* キー下部の担当指ライン */
.kb-key::before {
  content: "";
  position: absolute;
  bottom: 2px;
  left: 6px;
  right: 6px;
  height: 2px;
  border-radius: 1px;
  opacity: 0.85;
}

/* 手のイメージモードの時はキーの色分けラインを完全に非表示にする */
.keyboard-section.mode-hands .kb-key::before {
  display: none !important;
}

.kb-key[data-finger="lp"]::before { background: #f472b6; }
.kb-key[data-finger="lr"]::before { background: #fb923c; }
.kb-key[data-finger="lm"]::before { background: #facc15; }
.kb-key[data-finger="li"]::before { background: #4ade80; }
.kb-key[data-finger="ri"]::before { background: #38bdf8; }
.kb-key[data-finger="rm"]::before { background: #818cf8; }
.kb-key[data-finger="rr"]::before { background: #c084fc; }
.kb-key[data-finger="rp"]::before { background: #fb7185; }

/* --- ヒートマップ（ミスしたキー：控えめで上品な警告表示） --- */
.kb-key.heat-low {
  background: rgba(245, 158, 11, 0.08);
  border-color: rgba(245, 158, 11, 0.4);
  color: #cbd5e1;
}
.kb-key.heat-low::after {
  content: "";
  position: absolute;
  top: 4px;
  right: 4px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent-orange);
}

.kb-key.heat-mid {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.5);
  color: #f1f5f9;
}
.kb-key.heat-mid::after {
  content: "";
  position: absolute;
  top: 4px;
  right: 4px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #f87171;
  box-shadow: 0 0 5px #ef4444;
}

.kb-key.heat-high {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.7);
  color: #ffffff;
}
.kb-key.heat-high::after {
  content: "";
  position: absolute;
  top: 4px;
  right: 4px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-red);
  box-shadow: 0 0 6px var(--accent-red);
}

/* --- 次に打つべきキー（最優先・圧倒的に目立たせる） --- */
.kb-key.active-next {
  background: linear-gradient(135deg, #00f2fe 0%, #00b4d8 100%) !important;
  border-color: #ffffff !important;
  color: #000000 !important;
  font-weight: 900 !important;
  z-index: 10 !important;
  animation: active-key-pulse 0.85s infinite alternate cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.kb-key.active-next::after {
  display: none !important; /* 次のキーになったら赤いドットは消す */
}

@keyframes active-key-pulse {
  0% {
    box-shadow: 0 0 16px rgba(0, 229, 255, 0.9), 0 0 32px rgba(0, 229, 255, 0.4), inset 0 0 4px rgba(255, 255, 255, 0.8);
    transform: translateY(-5px) scale(1.1);
  }
  100% {
    box-shadow: 0 0 28px rgba(0, 229, 255, 1.0), 0 0 50px rgba(0, 229, 255, 0.65), inset 0 0 8px rgba(255, 255, 255, 1);
    transform: translateY(-6px) scale(1.16);
  }
}

.kb-key.key-hit {
  background: var(--accent-cyan) !important;
  color: #000 !important;
  transform: translateY(2px) scale(0.95);
}

.kb-key.key-miss {
  background: var(--accent-red) !important;
  color: #fff !important;
  transform: translateY(2px) scale(0.95);
}

/* ミス時の画面シェイク */
.shake-error {
  animation: shake 0.2s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes shake {
  10%, 90% { transform: translate3d(-2px, 0, 0); }
  20%, 80% { transform: translate3d(4px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
  40%, 60% { transform: translate3d(4px, 0, 0); }
}

/* モーダルオーバーレイ（全画面中央・背景ぼかし） */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(11, 15, 25, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  z-index: 1000;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.modal-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.modal-card {
  background: #151d2f;
  border: 1px solid #283753;
  border-radius: 20px;
  padding: 36px 32px;
  max-width: 680px;
  width: 100%;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.7), 0 0 40px rgba(0, 229, 255, 0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  animation: modal-pop 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modal-pop {
  from {
    transform: scale(0.94) translateY(12px);
    opacity: 0;
  }
  to {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

.modal-card h2 {
  font-size: 1.8rem;
  margin-bottom: 12px;
  font-weight: 700;
  color: #fff;
}

.modal-card p {
  color: var(--text-sub);
  max-width: 480px;
  line-height: 1.6;
  margin-bottom: 24px;
  font-size: 0.95rem;
}

.btn-primary {
  background: linear-gradient(135deg, #00e5ff, #0284c7);
  color: #000;
  font-weight: 700;
  font-size: 1rem;
  padding: 12px 32px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(0, 229, 255, 0.3);
  transition: all 0.15s ease;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 229, 255, 0.45);
}

.btn-secondary {
  background: var(--surface-color);
  border: 1px solid var(--surface-border);
  color: var(--text-main);
  font-weight: 600;
  padding: 12px 24px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-secondary:hover {
  background: var(--surface-border);
}

/* リザルト画面専用パーツ */
.result-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
  width: 100%;
  max-width: 540px;
}

.res-stat-card {
  background: var(--surface-color);
  border: 1px solid var(--surface-border);
  border-radius: 10px;
  padding: 14px 10px;
}

.res-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.res-val {
  font-size: 1.6rem;
  font-weight: 700;
  color: #fff;
  margin-top: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.result-weak-section {
  width: 100%;
  max-width: 540px;
  margin-bottom: 24px;
}

.weak-title {
  font-size: 0.95rem;
  color: var(--accent-orange);
  font-weight: 600;
  margin-bottom: 10px;
}

.result-keys-list {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.result-key-card {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 8px;
  padding: 8px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.rk-letter {
  font-size: 1.6rem;
  font-weight: 800;
  color: #fca5a5;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.rk-detail {
  font-size: 0.75rem;
  color: var(--text-sub);
}

.no-weakness {
  color: var(--accent-green);
  font-size: 0.95rem;
}

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

/* 弱点克服演出（画面中央ポップアップ） */
.overcome-banner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.6);
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.95), rgba(5, 150, 105, 0.95));
  border: 2px solid #34d399;
  border-radius: 16px;
  padding: 14px 28px;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.6), 0 0 35px rgba(16, 185, 129, 0.65);
  z-index: 50;
  pointer-events: none;
  opacity: 0;
  animation: overcome-pop 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes overcome-pop {
  0% {
    transform: translate(-50%, -50%) scale(0.4);
    opacity: 0;
  }
  25% {
    transform: translate(-50%, -50%) scale(1.08);
    opacity: 1;
  }
  40% {
    transform: translate(-50%, -50%) scale(1.0);
    opacity: 1;
  }
  75% {
    transform: translate(-50%, -50%) scale(1.0);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -65%) scale(0.92);
    opacity: 0;
  }
}

.overcome-icon {
  font-size: 2.2rem;
  animation: overcome-bounce 0.6s ease-out;
}

@keyframes overcome-bounce {
  0% { transform: scale(0.4) rotate(-20deg); }
  50% { transform: scale(1.3) rotate(15deg); }
  100% { transform: scale(1.0) rotate(0deg); }
}

.overcome-text-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
}

.overcome-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: #a7f3d0;
  font-weight: 800;
}

.overcome-main {
  font-size: 1.35rem;
  font-weight: 800;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.overcome-pill {
  background: #ffffff;
  color: #065f46;
  font-weight: 900;
  padding: 2px 10px;
  border-radius: 6px;
  font-size: 1.2rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* キーボード上の克服発光エフェクト */
.kb-key.key-overcome {
  background: #10b981 !important;
  color: #ffffff !important;
  border-color: #6ee7b7 !important;
  box-shadow: 0 0 25px #10b981 !important;
  transform: translateY(-4px) scale(1.15) !important;
  transition: all 0.15s ease !important;
}

/* リザルト画面の克服セクション */
.result-overcome-section {
  width: 100%;
  max-width: 540px;
  margin-bottom: 20px;
}

.overcome-res-title {
  font-size: 0.95rem;
  color: var(--accent-green);
  font-weight: 700;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.result-overcome-list {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.overcome-badge-card {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.45);
  border-radius: 8px;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 0 15px rgba(16, 185, 129, 0.15);
}

.ob-key {
  font-size: 1.3rem;
  font-weight: 800;
  color: #6ee7b7;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.ob-label {
  font-size: 0.8rem;
  color: #a7f3d0;
  font-weight: 600;
}

/* --- モード選択カード（スタート画面） --- */
.mode-select-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 100%;
  margin: 16px 0 16px 0;
}

@media (max-width: 640px) {
  .mode-select-container {
    grid-template-columns: 1fr;
  }
}

.mode-card {
  background: rgba(30, 41, 59, 0.6);
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 12px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--text-main);
}

.mode-card:hover:not(:disabled) {
  background: rgba(30, 41, 59, 0.9);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-2px);
}

.mode-card.active {
  background: rgba(0, 229, 255, 0.08);
  border-color: var(--accent-cyan);
  box-shadow: 0 0 16px rgba(0, 229, 255, 0.25);
}

.mode-card:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.5);
}

.mode-icon {
  font-size: 1.6rem;
  line-height: 1;
}

.mode-name {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 2px;
}

.mode-card.active .mode-name {
  color: var(--accent-cyan);
}

.mode-desc {
  font-size: 0.7rem;
  color: var(--text-muted);
  line-height: 1.25;
}

/* --- ボス討伐モード（ステージ選択パネル） --- */
.boss-select-panel {
  width: 100%;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 14px 12px;
  margin-bottom: 18px;
  animation: fadeIn 0.2s ease;
}

.boss-panel-title {
  font-size: 0.88rem;
  font-weight: 800;
  color: #fbbf24;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  letter-spacing: 0.5px;
}

.boss-roster-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

@media (max-width: 680px) {
  .boss-roster-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
  }
}

@media (max-width: 480px) {
  .boss-roster-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.boss-card {
  background: rgba(30, 41, 59, 0.7);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 8px 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  user-select: none;
}

.boss-card:hover:not(.locked) {
  transform: translateY(-3px);
  border-color: rgba(255, 255, 255, 0.35);
  background: rgba(30, 41, 59, 0.95);
}

.boss-card.active {
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.14);
  box-shadow: 0 0 16px rgba(245, 158, 11, 0.4);
  transform: translateY(-2px);
}

.boss-card.locked {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(0.8);
}

.boss-card-icon {
  font-size: 1.5rem;
  margin-bottom: 2px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

.boss-card-name {
  font-size: 0.68rem;
  font-weight: 700;
  color: #ffffff;
  white-space: nowrap;
}

.boss-card-wpm {
  font-size: 0.65rem;
  color: #fbbf24;
  font-weight: 800;
  margin-top: 2px;
}

.boss-badge-pill {
  font-size: 0.58rem;
  font-weight: 800;
  padding: 2px 4px;
  border-radius: 5px;
  margin-top: 4px;
  white-space: nowrap;
}

.boss-badge-pill.cleared {
  background: rgba(16, 185, 129, 0.25);
  color: #6ee7b7;
  border: 1px solid #10b981;
}

.boss-badge-pill.challenging {
  background: rgba(245, 158, 11, 0.25);
  color: #fde68a;
  border: 1px solid #f59e0b;
}

.boss-badge-pill.locked {
  background: rgba(100, 116, 139, 0.2);
  color: #94a3b8;
  border: 1px solid #475569;
}

/* 次のボス挑戦ボタン */
.btn-boss-next {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #000000;
  font-weight: 800;
  box-shadow: 0 0 16px rgba(245, 158, 11, 0.45);
  animation: pulse-boss-btn 1.4s infinite alternate;
}

@keyframes pulse-boss-btn {
  from { transform: scale(1); box-shadow: 0 0 10px rgba(245, 158, 11, 0.3); }
  to { transform: scale(1.03); box-shadow: 0 0 22px rgba(245, 158, 11, 0.7); }
}

/* --- ゴーストレーストラック（対戦レーン） --- */
.ghost-track-container {
  width: 100%;
  max-width: 620px;
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 10px 16px 14px 16px;
  margin-bottom: 16px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.track-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 0.8rem;
}

.track-title-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.track-icon {
  font-size: 1rem;
}

.track-title {
  font-weight: 800;
  letter-spacing: 1px;
  color: #c084fc;
}

.ghost-target-wpm {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.ghost-diff {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.85rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.ghost-diff.ahead {
  color: #4ade80;
  background: rgba(74, 222, 128, 0.15);
}

.ghost-diff.behind {
  color: #f87171;
  background: rgba(239, 68, 68, 0.15);
}

.ghost-diff.neutral {
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
}

.track-actions-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-track-giveup {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-track-giveup:hover {
  background: rgba(239, 68, 68, 0.35);
  border-color: #ef4444;
  color: #ffffff;
  transform: translateY(-1px);
}

.btn-giveup {
  background: rgba(239, 68, 68, 0.15) !important;
  color: #fca5a5 !important;
  border: 1px solid rgba(239, 68, 68, 0.35) !important;
  font-weight: 700;
}

.btn-giveup:hover {
  background: rgba(239, 68, 68, 0.35) !important;
  border-color: #ef4444 !important;
  color: #ffffff !important;
  transform: translateY(-1px);
}

/* レースレーン本体 */
.track-lane {
  position: relative;
  height: 28px;
  display: flex;
  align-items: center;
}

.lane-bar {
  position: absolute;
  left: 0;
  right: 28px;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

.track-finish {
  position: absolute;
  right: 0;
  font-size: 1.1rem;
}

/* ランナー（自分 ＆ ゴースト） */
.runner {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  transition: left 0.12s linear;
  z-index: 2;
  pointer-events: none;
}

.player-runner {
  z-index: 3;
}

.ghost-runner {
  opacity: 0.9;
}

.runner-badge {
  font-size: 0.7rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 8px;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.player-runner .runner-badge {
  background: #00e5ff;
  color: #000000;
  border: 1px solid #ffffff;
}

.ghost-runner .runner-badge {
  background: #a855f7;
  color: #ffffff;
  border: 1px solid #d8b4fe;
}

/* --- リザルト画面のゴースト勝敗バナー --- */
.res-ghost-banner {
  width: 100%;
  max-width: 540px;
  border-radius: 12px;
  padding: 12px 18px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-weight: 800;
  font-size: 1.05rem;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.res-ghost-banner.win {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(5, 150, 105, 0.3));
  border: 1px solid #10b981;
  color: #6ee7b7;
}

.res-ghost-banner.lose {
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.2), rgba(126, 34, 206, 0.3));
  border: 1px solid #a855f7;
  color: #d8b4fe;
}

.res-ghost-banner.record {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.25), rgba(217, 119, 6, 0.35));
  border: 1px solid #f59e0b;
  color: #fde68a;
  animation: glow-record 1.5s infinite alternate;
}

@keyframes glow-record {
  from { box-shadow: 0 0 10px rgba(245, 158, 11, 0.3); }
  to { box-shadow: 0 0 25px rgba(245, 158, 11, 0.7); }
}

/* --- 広告枠スタイル（AdSense / アフィリエイト枠） --- */
.ad-slot-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 16px auto;
  width: 100%;
}

.ad-badge {
  font-size: 0.68rem;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  margin-bottom: 4px;
  text-align: center;
}

.ad-placeholder-box {
  width: 100%;
  max-width: 336px;
  min-height: 110px;
  background: rgba(30, 41, 59, 0.4);
  border: 1px dashed rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 12px;
  text-align: center;
  transition: all 0.2s ease;
}

.ad-placeholder-box.ad-horizontal {
  max-width: 728px;
  min-height: 85px;
}

.ad-ph-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-sub);
  margin-bottom: 2px;
}

.ad-ph-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.ad-bottom-slot {
  margin-top: 24px;
}

.ad-result-slot {
  margin-top: 16px;
  margin-bottom: 0;
}

/* --- フッター ＆ リンク --- */
footer {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: auto;
  padding: 24px 0 16px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 8px;
}

.footer-link-btn {
  background: none;
  border: none;
  color: var(--text-sub);
  font-size: 0.78rem;
  cursor: pointer;
  padding: 2px 4px;
  text-decoration: underline;
  transition: color 0.15s ease;
}

.footer-link-btn:hover {
  color: var(--accent-cyan);
}

.footer-sep {
  color: rgba(255, 255, 255, 0.2);
}

.copyright {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* --- プライバシーポリシー ＆ 利用規約 モーダル --- */
.policy-modal-card {
  max-width: 650px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  text-align: left;
  padding: 24px 28px;
}

.policy-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 12px;
  margin-bottom: 16px;
}

.policy-modal-header h3 {
  font-size: 1.2rem;
  color: #ffffff;
  margin: 0;
}

.policy-close-btn {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: var(--text-main);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all 0.15s ease;
}

.policy-close-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

.policy-modal-body {
  overflow-y: auto;
  font-size: 0.85rem;
  line-height: 1.7;
  color: var(--text-sub);
  padding-right: 8px;
}

.policy-modal-body h4 {
  color: #ffffff;
  font-size: 0.95rem;
  margin: 16px 0 6px 0;
}

.policy-modal-body p {
  margin-bottom: 12px;
}
