/* ==========================================================================
   css/style.css - 教材ゲーミフィケーション学習Webアプリ Duolingo風デザイン v2.0
   マルチデバイス・レスポンシブ (PC・タブレット・スマホ最適化) & フィーバー演出強化
   ========================================================================== */

:root {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: #1e293b;
  --bg-hover: #334155;
  --border-color: #334155;
  
  --emerald-500: #10b981;
  --emerald-600: #059669;
  --emerald-700: #047857;
  --emerald-glow: rgba(16, 185, 129, 0.4);

  --indigo-500: #6366f1;
  --indigo-600: #4f46e5;
  --purple-500: #8b5cf6;
  --purple-600: #7c3aed;

  --amber-400: #fbbf24;
  --amber-500: #f59e0b;
  --amber-600: #d97706;

  --rose-500: #f43f5e;
  --rose-600: #e11d48;
  --rose-glow: rgba(244, 63, 94, 0.4);

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

  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Hiragino Sans", "Meiryo", sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  overflow-x: hidden;
  user-select: none;
}

/* ==========================================================================
   コンテナ & レスポンシブ幅制御
   ========================================================================== */
#app-container {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  min-height: 100dvh;
  background-color: var(--bg-primary);
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.7);
  transition: max-width 0.3s ease;
}

/* タブレット (768px 〜 1024px) */
@media (min-width: 768px) {
  #app-container {
    max-width: 768px;
  }
}

/* デスクトップ (> 1024px) */
@media (min-width: 1025px) {
  #app-container {
    max-width: 1140px;
  }
}

/* ==========================================================================
   全画面フィーバー縁エフェクト & VS演出オーバーレイ
   ========================================================================== */
#fever-screen-border {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 9998;
  transition: box-shadow 0.4s ease, border-color 0.4s ease;
}

/* レベル1: 3連続以上 青パルス */
#fever-screen-border.fever-lv1 {
  box-shadow: inset 0 0 35px rgba(56, 189, 248, 0.5);
  animation: pulseBlueFever 1.8s infinite ease-in-out;
}

/* レベル2: 5連続以上 炎パルス */
#fever-screen-border.fever-lv2 {
  box-shadow: inset 0 -45px 65px rgba(245, 158, 11, 0.6), inset 0 0 40px rgba(239, 68, 68, 0.5);
  animation: pulseFireFever 1.2s infinite ease-in-out;
}

/* レベル3: 10連続以上 レインボー */
#fever-screen-border.fever-lv3 {
  animation: rainbowBorder 3s infinite linear, pulseRainbow 1s infinite ease-in-out;
}

@keyframes pulseBlueFever {
  0%, 100% { box-shadow: inset 0 0 25px rgba(56, 189, 248, 0.35); }
  50% { box-shadow: inset 0 0 55px rgba(56, 189, 248, 0.7); }
}

@keyframes pulseFireFever {
  0%, 100% { box-shadow: inset 0 -35px 50px rgba(245, 158, 11, 0.5), inset 0 0 30px rgba(239, 68, 68, 0.4); }
  50% { box-shadow: inset 0 -60px 85px rgba(245, 158, 11, 0.8), inset 0 0 55px rgba(239, 68, 68, 0.7); }
}

@keyframes rainbowBorder {
  0% { box-shadow: inset 0 0 50px rgba(255, 0, 0, 0.6); }
  25% { box-shadow: inset 0 0 50px rgba(255, 230, 0, 0.6); }
  50% { box-shadow: inset 0 0 50px rgba(0, 255, 100, 0.6); }
  75% { box-shadow: inset 0 0 50px rgba(0, 150, 255, 0.6); }
  100% { box-shadow: inset 0 0 50px rgba(255, 0, 200, 0.6); }
}

/* ボスラッシュ限定「VS演出」オーバーレイ */
#boss-vs-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(10, 10, 15, 0.95);
  backdrop-filter: blur(8px);
  z-index: 10000;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  animation: fadeIn 0.2s ease;
}

#boss-vs-overlay.show {
  display: flex;
}

.boss-vs-warning {
  background: #dc2626;
  color: #ffffff;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 4px;
  padding: 8px 36px;
  border-radius: 4px;
  box-shadow: 0 0 30px #ef4444;
  margin-bottom: 30px;
  animation: strobeWarning 0.4s infinite alternate;
}

@keyframes strobeWarning {
  0% { transform: scale(0.98); opacity: 0.85; filter: brightness(1); }
  100% { transform: scale(1.02); opacity: 1; filter: brightness(1.4); }
}

.boss-vs-icon {
  font-size: 110px;
  margin-bottom: 20px;
  animation: bossZoomShake 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes bossZoomShake {
  0% { transform: scale(0.2) rotate(-15deg); opacity: 0; }
  60% { transform: scale(1.2) rotate(10deg); opacity: 1; }
  80% { transform: scale(0.95) rotate(-5deg); }
  100% { transform: scale(1) rotate(0deg); }
}

.boss-vs-title {
  font-size: 28px;
  font-weight: 900;
  color: #ffffff;
  text-shadow: 0 0 20px rgba(244, 63, 94, 0.8);
  margin-bottom: 8px;
}

.boss-vs-subtitle {
  font-size: 14px;
  color: #fca5a5;
  font-weight: 700;
}

/* ==========================================================================
   共通ヘッダー（ステータスバー）
   ========================================================================== */
#main-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(12px);
  border-bottom: 2px solid var(--border-color);
  padding: calc(var(--safe-top) + 8px) 18px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

@media (min-width: 1025px) {
  #main-header {
    padding: 12px 28px;
  }
}

.course-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.2s ease;
}

.course-badge:active {
  transform: scale(0.96);
}

.course-badge:hover {
  border-color: var(--emerald-500);
}

.stats-group {
  display: flex;
  align-items: center;
  gap: 14px;
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}

.stat-pill.streak {
  color: #ff9800;
  text-shadow: 0 0 10px rgba(255, 152, 0, 0.4);
}

.stat-pill.xp {
  color: var(--amber-400);
  text-shadow: 0 0 10px rgba(251, 191, 36, 0.4);
}

.stat-pill.rank {
  color: #38bdf8;
  font-size: 13px;
  background: rgba(56, 189, 248, 0.12);
  padding: 4px 10px;
  border-radius: 14px;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

/* PC専用ヘッダーナビリンク */
.desktop-nav-links {
  display: none;
  align-items: center;
  gap: 10px;
}

@media (min-width: 1025px) {
  .desktop-nav-links {
    display: flex;
  }
  #bottom-nav {
    display: none !important; /* PCではボトムナビを隠しヘッダーで操作 */
  }
}

.desktop-nav-btn {
  background: none;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.desktop-nav-btn:hover {
  background: var(--bg-hover);
  color: var(--text-main);
}

.desktop-nav-btn.active {
  background: rgba(16, 185, 129, 0.15);
  border-color: var(--emerald-500);
  color: var(--emerald-500);
}

/* ==========================================================================
   画面ビュー切り替え
   ========================================================================== */
.view-screen {
  flex: 1;
  display: none;
  flex-direction: column;
  padding-bottom: calc(var(--safe-bottom) + 72px);
  animation: fadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@media (min-width: 1025px) {
  .view-screen {
    padding-bottom: 40px;
  }
}

.view-screen.active {
  display: flex;
}

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

/* ==========================================================================
   SCR-02 学習マップ（すごろく画面 & PC 2カラムダッシュボード）
   ========================================================================== */
.map-view {
  padding: 16px 14px 100px;
  overflow-y: auto;
}

@media (min-width: 1025px) {
  .map-view {
    padding: 24px 28px 60px;
  }
}

/* 2カラムレイアウトコンテナ */
.map-desktop-container {
  display: flex;
  flex-direction: column;
  width: 100%;
}

@media (min-width: 1025px) {
  .map-desktop-container {
    flex-direction: row;
    gap: 36px;
    align-items: flex-start;
  }
  .map-left-pane {
    flex: 1;
    max-width: 660px;
  }
  .map-right-pane {
    width: 380px;
    position: sticky;
    top: 75px;
    display: flex;
    flex-direction: column;
    gap: 20px;
  }
}

/* 右側ダッシュボードコンポーネント */
.map-right-pane {
  display: none;
}

@media (min-width: 1025px) {
  .map-right-pane {
    display: flex;
  }
}

.dashboard-card {
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  border-radius: 20px;
  padding: 18px 20px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.dashboard-card-title {
  font-size: 13px;
  font-weight: 800;
  color: #38bdf8;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* 役職アバターカード */
.rank-avatar-card {
  display: flex;
  align-items: center;
  gap: 16px;
}

.rank-avatar-icon {
  font-size: 48px;
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.2), rgba(99, 102, 241, 0.2));
  border: 2px solid #38bdf8;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.3);
}

.rank-avatar-info {
  flex: 1;
}

.rank-avatar-name {
  font-size: 18px;
  font-weight: 900;
  color: #ffffff;
}

.rank-avatar-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.rank-progress-bar {
  width: 100%;
  height: 8px;
  background: #0f172a;
  border-radius: 6px;
  overflow: hidden;
}

.rank-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #38bdf8, #818cf8);
  border-radius: 6px;
  transition: width 0.4s ease;
}

/* ストリーク・ヒートマップ（GitHub草風 直近30日） */
.heatmap-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 6px;
  margin-top: 8px;
}

.heatmap-day {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 4px;
  background: #334155;
  transition: all 0.2s ease;
  position: relative;
}

.heatmap-day.active {
  background: var(--emerald-500);
  box-shadow: 0 0 8px var(--emerald-glow);
}

.heatmap-day:hover {
  transform: scale(1.2);
  z-index: 5;
}

/* クイック統計 */
.quick-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.quick-stat-item {
  background: rgba(15, 23, 42, 0.6);
  border-radius: 14px;
  padding: 12px;
  text-align: center;
}

.quick-stat-val {
  font-size: 20px;
  font-weight: 900;
  color: #ffffff;
}

.quick-stat-lbl {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 700;
  margin-top: 2px;
}

/* マップ本体 (すごろくパス) */
.chapter-section {
  margin-bottom: 32px;
}

.chapter-banner {
  background: linear-gradient(135deg, #1e293b, #0f172a);
  border: 2px solid var(--indigo-600);
  border-radius: 20px;
  padding: 16px 18px;
  margin-bottom: 24px;
  box-shadow: 0 8px 24px rgba(79, 70, 229, 0.2);
  position: relative;
  overflow: hidden;
}

.chapter-banner::after {
  content: '';
  position: absolute;
  top: -30%;
  right: -20%;
  width: 140px;
  height: 140px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.25), transparent);
  border-radius: 50%;
  pointer-events: none;
}

.chapter-tag {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  color: #818cf8;
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.chapter-title {
  font-size: 18px;
  font-weight: 800;
  color: #ffffff;
}

.nodes-path {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  position: relative;
  padding: 10px 0;
}

.node-wrapper:nth-child(4n + 1) { transform: translateX(0); }
.node-wrapper:nth-child(4n + 2) { transform: translateX(-48px); }
.node-wrapper:nth-child(4n + 3) { transform: translateX(0); }
.node-wrapper:nth-child(4n + 4) { transform: translateX(48px); }

.node-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  z-index: 2;
  transition: transform 0.2s ease;
}

.node-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  cursor: pointer;
  position: relative;
  transition: all 0.15s ease;
  border: none;
  outline: none;
}

.node-btn.locked {
  background: #334155;
  box-shadow: 0 6px 0 #1e293b;
  color: #64748b;
  cursor: not-allowed;
}

.node-btn.unlocked {
  background: linear-gradient(180deg, #10b981, #059669);
  box-shadow: 0 6px 0 #047857, 0 10px 20px var(--emerald-glow);
  color: #ffffff;
  animation: pulseNode 2s infinite ease-in-out;
}

.node-btn.unlocked:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #047857;
}

.node-btn.cleared {
  background: linear-gradient(180deg, #10b981, #059669);
  box-shadow: 0 6px 0 #047857;
  color: #ffffff;
}

.node-btn.cleared:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #047857;
}

/* ボスノード */
.node-btn.boss {
  width: 84px;
  height: 84px;
  border-radius: 28px;
  background: linear-gradient(180deg, #f43f5e, #be123c);
  box-shadow: 0 8px 0 #9f1239, 0 12px 25px rgba(244, 63, 94, 0.4);
  color: #fff;
  font-size: 34px;
}

.node-btn.boss.locked {
  background: #334155;
  box-shadow: 0 6px 0 #1e293b;
  color: #64748b;
}

.node-btn.boss:not(.locked):active {
  transform: translateY(4px);
  box-shadow: 0 4px 0 #9f1239;
}

.node-btn.boss.cleared {
  background: linear-gradient(180deg, #8b5cf6, #6d28d9);
  box-shadow: 0 8px 0 #5b21b6, 0 10px 20px rgba(139, 92, 246, 0.4);
}

@keyframes pulseNode {
  0% { transform: scale(1); filter: drop-shadow(0 0 4px rgba(16, 185, 129, 0.6)); }
  50% { transform: scale(1.06); filter: drop-shadow(0 0 12px rgba(16, 185, 129, 0.9)); }
  100% { transform: scale(1); filter: drop-shadow(0 0 4px rgba(16, 185, 129, 0.6)); }
}

.node-stars {
  position: absolute;
  top: -8px;
  display: flex;
  gap: 2px;
  font-size: 13px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

.node-label {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  max-width: 130px;
  color: var(--text-main);
  line-height: 1.3;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

.node-page-badge {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 600;
}

/* ==========================================================================
   SCR-03 問題解答画面 (クイズセッション & PCワイド/キーボード操作)
   ========================================================================== */
.quiz-view {
  padding: 0 16px 24px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

@media (min-width: 768px) {
  .quiz-view {
    max-width: 740px;
    margin: 0 auto;
    width: 100%;
    padding: 0 24px 32px;
  }
}

.quiz-header {
  padding: calc(var(--safe-top) + 12px) 0 8px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.quiz-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.quiz-progress-track {
  flex: 1;
  height: 14px;
  background: var(--bg-secondary);
  border-radius: 10px;
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.4);
}

.quiz-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #10b981, #34d399);
  border-radius: 10px;
  transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 0 8px var(--emerald-glow);
}

/* フィーバーゲージ */
.fever-gauge-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0 12px;
  font-size: 12px;
  font-weight: 800;
  color: var(--amber-400);
}

.fever-track {
  flex: 1;
  height: 6px;
  background: #1e293b;
  border-radius: 4px;
  overflow: hidden;
}

.fever-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #38bdf8, #f59e0b, #ef4444);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.quiz-combo-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.4);
  color: var(--amber-400);
  font-size: 12px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 12px;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.quiz-combo-badge.pop {
  transform: scale(1.3);
}

.quiz-combo-badge.fever-x15 {
  background: linear-gradient(135deg, rgba(236, 72, 153, 0.3), rgba(245, 158, 11, 0.3));
  border-color: #ec4899;
  color: #f472b6;
  animation: pulseNode 1s infinite alternate;
}

.challenge-banner {
  background: linear-gradient(90deg, rgba(236, 72, 153, 0.2), rgba(139, 92, 246, 0.2));
  border: 1px solid rgba(236, 72, 153, 0.5);
  border-radius: 12px;
  padding: 8px 14px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 800;
  color: #f472b6;
}

.quiz-card {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.question-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.question-type-tag {
  font-size: 11px;
  font-weight: 800;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.12);
  padding: 4px 10px;
  border-radius: 8px;
}

.question-page-tag {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
}

.question-prompt {
  font-size: 19px;
  font-weight: 700;
  line-height: 1.55;
  color: var(--text-main);
  margin-bottom: 24px;
}

@media (min-width: 768px) {
  .question-prompt {
    font-size: 21px;
  }
}

/* 4択・○× 選択肢エリア (タブレット/PCで2×2グリッド展開) */
.options-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

@media (min-width: 768px) {
  .options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }
}

.option-btn {
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  box-shadow: 0 4px 0 var(--border-color);
  border-radius: 16px;
  padding: 16px 18px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
}

.option-btn:hover {
  border-color: #475569;
  background: rgba(51, 65, 85, 0.7);
}

.option-btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--border-color);
}

.option-btn.selected {
  border-color: var(--indigo-500);
  background: rgba(99, 102, 241, 0.18);
  box-shadow: 0 4px 0 var(--indigo-600);
  color: #ffffff;
}

.option-content-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.option-badge {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  flex-shrink: 0;
}

/* キーボードショートカットヒントバッジ (PC表示時) */
.keyboard-hint {
  display: none;
  font-size: 11px;
  font-weight: 800;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 2px 6px;
}

@media (min-width: 1025px) {
  .keyboard-hint {
    display: inline-block;
  }
}

/* 穴埋め (fill_in) */
.fillin-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 24px;
}

.fillin-sentence {
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  border-radius: 18px;
  padding: 20px;
  font-size: 18px;
  line-height: 1.7;
  color: var(--text-main);
}

.fillin-slot {
  display: inline-block;
  min-width: 90px;
  height: 36px;
  vertical-align: middle;
  background: rgba(16, 185, 129, 0.1);
  border: 2px dashed var(--emerald-500);
  border-radius: 10px;
  text-align: center;
  line-height: 32px;
  font-weight: 800;
  color: #34d399;
  padding: 0 12px;
  margin: 0 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.fillin-slot.empty {
  color: var(--text-dim);
}

.chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  padding: 10px 0;
}

.chip-btn {
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  box-shadow: 0 4px 0 var(--border-color);
  border-radius: 14px;
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.15s ease;
}

.chip-btn:hover {
  border-color: #475569;
}

.chip-btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--border-color);
}

.chip-btn.selected {
  opacity: 0.35;
  cursor: not-allowed;
  transform: translateY(3px);
  box-shadow: none;
}

/* 組み合わせ (matching) */
.matching-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.matching-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.match-card {
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  box-shadow: 0 3px 0 var(--border-color);
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.4;
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.match-card:hover {
  border-color: #475569;
}

.match-card:active {
  transform: translateY(2px);
}

.match-card.selected {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.18);
  box-shadow: 0 3px 0 #0284c7;
}

.match-card.matched {
  border-color: var(--emerald-500);
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  cursor: default;
  opacity: 0.8;
}

.match-card.wrong {
  border-color: var(--rose-500);
  background: rgba(244, 63, 94, 0.2);
  animation: shake 0.4s ease;
}

/* 並び替え (sorting) */
.sorting-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
}

.sorting-tray-label {
  font-size: 12px;
  font-weight: 800;
  color: var(--text-muted);
}

.sorting-tray {
  min-height: 90px;
  background: rgba(30, 41, 59, 0.6);
  border: 2px dashed var(--indigo-500);
  border-radius: 16px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sorting-item {
  background: var(--bg-secondary);
  border: 2px solid var(--indigo-600);
  box-shadow: 0 3px 0 #3730a3;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  animation: fadeIn 0.2s ease;
}

.sorting-item .item-num {
  font-size: 12px;
  color: #a5b4fc;
  font-weight: 800;
  margin-right: 8px;
}

.sorting-pool {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sorting-chip {
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  box-shadow: 0 3px 0 var(--border-color);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.15s ease;
}

.sorting-chip:hover {
  border-color: #475569;
}

.sorting-chip:active {
  transform: translateY(2px);
}

.sorting-chip.placed {
  opacity: 0.3;
  cursor: not-allowed;
  transform: translateY(2px);
  box-shadow: none;
}

/* クイズボトムアクション */
.quiz-action-bar {
  margin-top: auto;
  padding-top: 16px;
}

.primary-btn {
  width: 100%;
  background: linear-gradient(180deg, #10b981, #059669);
  border: none;
  border-radius: 18px;
  padding: 16px;
  font-size: 17px;
  font-weight: 800;
  color: #ffffff;
  cursor: pointer;
  box-shadow: 0 5px 0 #047857;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.primary-btn:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #047857;
}

.primary-btn:disabled {
  background: #334155;
  box-shadow: 0 4px 0 #1e293b;
  color: #64748b;
  cursor: not-allowed;
  transform: none;
}

/* ==========================================================================
   解説シート（即座フィードバックボトムシート）
   ========================================================================== */
.feedback-sheet {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%) translateY(105%);
  width: 100%;
  max-width: 740px;
  background: var(--bg-secondary);
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  padding: 24px 20px calc(var(--safe-bottom) + 20px);
  z-index: 100;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.7);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.feedback-sheet.show {
  transform: translateX(-50%) translateY(0);
}

.feedback-sheet.correct {
  background: #064e3b;
  border-top: 3px solid var(--emerald-500);
}

.feedback-sheet.wrong {
  background: #4c0519;
  border-top: 3px solid var(--rose-500);
}

.feedback-title {
  font-size: 20px;
  font-weight: 900;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.feedback-sheet.correct .feedback-title {
  color: #34d399;
}

.feedback-sheet.wrong .feedback-title {
  color: #fb7185;
}

.feedback-answer {
  font-size: 15px;
  font-weight: 700;
  color: #fecdd3;
  margin-bottom: 10px;
}

.feedback-explanation {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-main);
  background: rgba(0, 0, 0, 0.2);
  padding: 12px;
  border-radius: 12px;
  margin-bottom: 12px;
}

.feedback-page {
  font-size: 12px;
  font-weight: 700;
  color: #cbd5e1;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ==========================================================================
   SCR-04 リザルト画面
   ========================================================================== */
.result-view {
  padding: calc(var(--safe-top) + 24px) 20px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  overflow-y: auto;
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
}

.result-trophy {
  font-size: 72px;
  margin-bottom: 12px;
  animation: bounceTrophy 1.5s infinite ease-in-out;
}

@keyframes bounceTrophy {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-10px) scale(1.08); }
}

.result-title {
  font-size: 28px;
  font-weight: 900;
  color: #ffffff;
  margin-bottom: 6px;
}

.result-subtitle {
  font-size: 15px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.result-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  width: 100%;
  margin-bottom: 24px;
}

.result-stat-card {
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  border-radius: 18px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.result-stat-val {
  font-size: 24px;
  font-weight: 900;
}

.result-stat-val.xp { color: var(--amber-400); }
.result-stat-val.acc { color: var(--emerald-500); }
.result-stat-val.streak { color: #ff9800; }
.result-stat-val.stars { color: #facc15; }

.result-stat-lbl {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}

.result-streak-card {
  width: 100%;
  background: linear-gradient(135deg, rgba(255, 152, 0, 0.15), rgba(245, 158, 11, 0.05));
  border: 2px solid rgba(255, 152, 0, 0.4);
  border-radius: 18px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 28px;
  text-align: left;
}

.streak-fire-big {
  font-size: 40px;
}

/* ==========================================================================
   SCR-05 弱点復習画面 (PC 2ペイン分割)
   ========================================================================== */
.review-view {
  padding: 20px 16px 100px;
  overflow-y: auto;
}

@media (min-width: 1025px) {
  .review-view {
    padding: 24px 28px 60px;
  }
}

.review-desktop-container {
  display: flex;
  flex-direction: column;
  width: 100%;
}

@media (min-width: 1025px) {
  .review-desktop-container {
    flex-direction: row;
    gap: 32px;
    align-items: flex-start;
  }
  .review-list-pane {
    flex: 1;
  }
  .review-detail-pane {
    width: 440px;
    position: sticky;
    top: 75px;
  }
}

.section-header {
  margin-bottom: 20px;
}

.section-title {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 6px;
}

.section-desc {
  font-size: 13px;
  color: var(--text-muted);
}

.weakness-card {
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  border-radius: 16px;
  padding: 16px 18px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.weakness-card:hover {
  border-color: #475569;
  background: rgba(51, 65, 85, 0.7);
}

.weakness-card.selected {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.12);
}

.weakness-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 800;
  color: var(--rose-500);
  margin-bottom: 8px;
}

.weakness-prompt {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.5;
  margin-bottom: 8px;
}

.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-muted);
}

.empty-state .icon {
  font-size: 48px;
  margin-bottom: 12px;
}

/* ==========================================================================
   SCR-06 設定 & 復活の呪文画面
   ========================================================================== */
.settings-view {
  padding: 20px 16px 100px;
  overflow-y: auto;
  max-width: 680px;
  margin: 0 auto;
  width: 100%;
}

.settings-group {
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  border-radius: 18px;
  padding: 18px 20px;
  margin-bottom: 20px;
}

.settings-group-title {
  font-size: 14px;
  font-weight: 800;
  color: #38bdf8;
  margin-bottom: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.setting-row:last-child {
  border-bottom: none;
}

.setting-label {
  font-size: 15px;
  font-weight: 700;
}

/* トグルスイッチ */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 28px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #334155;
  transition: 0.25s;
  border-radius: 28px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: 0.25s;
  border-radius: 50%;
}

input:checked + .toggle-slider {
  background-color: var(--emerald-500);
}

input:checked + .toggle-slider:before {
  transform: translateX(22px);
}

/* 復活の呪文エリア */
.spell-box {
  background: #0f172a;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 14px;
  font-family: monospace;
  font-size: 13px;
  font-weight: 700;
  color: #38bdf8;
  word-break: break-all;
  letter-spacing: 1px;
  margin-bottom: 12px;
  text-align: center;
}

.spell-textarea {
  width: 100%;
  height: 60px;
  background: #0f172a;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 10px;
  color: var(--text-main);
  font-family: monospace;
  font-size: 13px;
  resize: none;
  margin-bottom: 10px;
}

.secondary-btn {
  background: var(--bg-hover);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.15s ease;
  width: 100%;
}

.secondary-btn:hover {
  background: #475569;
}

.secondary-btn:active {
  transform: scale(0.98);
}

.danger-btn {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid var(--rose-500);
  color: #fca5a5;
  border-radius: 14px;
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  width: 100%;
}

.danger-btn:active {
  transform: scale(0.98);
}

/* ==========================================================================
   ボトムナビゲーションバー (モバイル用)
   ========================================================================== */
#bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: rgba(15, 23, 42, 0.96);
  backdrop-filter: blur(12px);
  border-top: 2px solid var(--border-color);
  display: flex;
  justify-content: space-around;
  padding: 6px 0 calc(var(--safe-bottom) + 6px);
  z-index: 50;
}

@media (min-width: 768px) {
  #bottom-nav {
    max-width: 768px;
  }
}

.nav-tab-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  padding: 6px 14px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.nav-tab-btn .nav-icon {
  font-size: 22px;
}

.nav-tab-btn.active {
  color: var(--emerald-500);
}

.nav-tab-btn.active .nav-icon {
  transform: scale(1.1);
}

/* ==========================================================================
   SCR-00: ログイン画面
   ========================================================================== */
.login-view {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 40px 24px;
  text-align: center;
}

.login-brand-icon {
  font-size: 64px;
  margin-bottom: 16px;
  animation: bounceTrophy 2s infinite ease-in-out;
}

.login-title {
  font-size: 28px;
  font-weight: 900;
  color: #ffffff;
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.login-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 32px;
  max-width: 340px;
}

.login-form-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  border-radius: 24px;
  padding: 26px 22px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.pw-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.pw-input {
  width: 100%;
  background: #0f172a;
  border: 2px solid var(--border-color);
  border-radius: 16px;
  padding: 14px 44px 14px 16px;
  font-size: 16px;
  color: var(--text-main);
  outline: none;
  transition: border-color 0.2s ease;
}

.pw-input:focus {
  border-color: var(--emerald-500);
}

.pw-toggle-btn {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 6px;
  line-height: 1;
}

.remember-me-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  text-align: left;
}

.remember-me-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--emerald-500);
  cursor: pointer;
}

.login-error-msg {
  color: #fb7185;
  font-size: 13px;
  font-weight: 700;
  min-height: 18px;
  text-align: center;
}

/* ==========================================================================
   モーダル & トースト
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}

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

.modal-card {
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  border-radius: 24px;
  padding: 24px;
  max-width: 440px;
  width: 100%;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
  animation: popModal 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes popModal {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  background: rgba(30, 41, 59, 0.95);
  border: 1px solid var(--emerald-500);
  color: #ffffff;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  z-index: 9999;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

.shake {
  animation: shake 0.4s ease;
}
