/* ===================================
   語源で覚える英単語 - メインスタイル
   =================================== */

/* --- CSS変数 --- */
:root {
  --pink: #FF6B9D;
  --pink-light: #FFB3D1;
  --pink-pale: #FFF0F6;
  --purple: #C77DFF;
  --purple-light: #E8C4FF;
  --purple-pale: #F8F0FF;
  --blue: #74C0FC;
  --blue-light: #BAE3FF;
  --blue-pale: #F0F8FF;
  --mint: #69DB7C;
  --mint-light: #B2F2BB;
  --mint-pale: #F0FFF4;
  --yellow: #FFD43B;
  --yellow-light: #FFE8A3;
  --yellow-pale: #FFFBF0;
  --orange: #FFA94D;
  --orange-light: #FFD0A0;
  --coral: #FF6B6B;
  --coral-light: #FFB3B3;
  --white: #FFFFFF;
  --gray-50: #F9FAFB;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-300: #D1D5DB;
  --gray-400: #9CA3AF;
  --gray-500: #6B7280;
  --gray-600: #4B5563;
  --gray-700: #374151;
  --gray-800: #1F2937;
  --text-primary: #2D1B69;
  --text-secondary: #6B7280;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.12);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.15);
  --shadow-pink: 0 4px 16px rgba(255,107,157,0.3);
  --shadow-purple: 0 4px 16px rgba(199,125,255,0.3);
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  --radius-full: 9999px;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* --- リセット・ベース --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Meiryo', 'Noto Sans JP', sans-serif;
  background: linear-gradient(135deg, #FFF0F6 0%, #F8F0FF 50%, #F0F8FF 100%);
  min-height: 100vh;
  min-height: -webkit-fill-available;
  color: var(--text-primary);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* --- スクリーン管理 --- */
.screen {
  display: none;
  min-height: 100vh;
  min-height: -webkit-fill-available;
  position: relative;
}
.screen.active { display: block; }

/* ============================================
   スプラッシュスクリーン
   ============================================ */
#screen-splash {
  background: linear-gradient(160deg, #FF6B9D 0%, #C77DFF 60%, #74C0FC 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}
#screen-splash.active { display: flex; }

.splash-content {
  text-align: center;
  color: white;
  animation: splashFadeIn 0.8s var(--bounce) both;
}

@keyframes splashFadeIn {
  from { opacity: 0; transform: scale(0.7) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.splash-icon {
  font-size: 80px;
  display: block;
  margin-bottom: 16px;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.2));
  animation: floatIcon 2s ease-in-out infinite;
}

@keyframes floatIcon {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.splash-title {
  font-size: 28px;
  font-weight: 800;
  line-height: 1.3;
  margin-bottom: 8px;
  text-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.splash-subtitle {
  font-size: 14px;
  opacity: 0.85;
  margin-bottom: 40px;
}

.loading-dots {
  display: flex;
  gap: 8px;
  justify-content: center;
}
.loading-dots span {
  width: 10px; height: 10px;
  background: rgba(255,255,255,0.7);
  border-radius: 50%;
  animation: dotBounce 1.2s ease-in-out infinite;
}
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dotBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

/* ============================================
   ホーム画面
   ============================================ */
#screen-home {
  padding-bottom: 24px;
}

.home-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  background: white;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
}

.user-level {
  display: flex;
  align-items: center;
  gap: 10px;
}

.level-badge {
  background: linear-gradient(135deg, var(--pink), var(--purple));
  color: white;
  font-size: 13px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  white-space: nowrap;
  box-shadow: var(--shadow-pink);
}

.level-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.user-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.xp-bar-mini {
  width: 80px;
  height: 5px;
  background: var(--gray-200);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.xp-fill-mini {
  height: 100%;
  background: linear-gradient(90deg, var(--pink), var(--purple));
  border-radius: var(--radius-full);
  transition: width 0.8s var(--bounce);
  width: 0%;
}

.header-right {
  display: flex;
  gap: 4px;
}

.icon-btn {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.icon-btn:active { transform: scale(0.9); background: var(--gray-100); }

/* --- ストリーク・統計バー --- */
.stats-bar {
  display: flex;
  justify-content: space-around;
  padding: 14px 16px;
  background: linear-gradient(135deg, #FF6B9D22, #C77DFF22);
  border-bottom: 1px solid var(--gray-200);
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.stat-icon { font-size: 18px; }

.stat-value {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
}

.stat-label {
  font-size: 10px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* --- セクション共通 --- */
.home-main {
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.section {
  background: white;
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

.section-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 14px;
}

/* --- 難易度ボタン --- */
.difficulty-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.difficulty-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 10px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-md);
  background: white;
  cursor: pointer;
  transition: var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.difficulty-btn:active { transform: scale(0.96); }

.difficulty-btn.active {
  border-color: var(--pink);
  background: var(--pink-pale);
  box-shadow: var(--shadow-pink);
}

.diff-icon { font-size: 24px; }
.diff-name { font-size: 14px; font-weight: 700; color: var(--text-primary); }
.diff-desc { font-size: 10px; color: var(--text-secondary); }

.difficulty-btn.active .diff-name { color: var(--pink); }

/* --- モードタブ --- */
.mode-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.mode-tab {
  flex: 1;
  padding: 8px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-md);
  background: white;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.mode-tab.active {
  border-color: var(--purple);
  background: var(--purple-pale);
  color: var(--purple);
}

.mode-tab:active { transform: scale(0.96); }

/* --- 接頭語/接尾語グリッド --- */
.affix-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
  padding: 2px;
}

.affix-grid::-webkit-scrollbar { width: 4px; }
.affix-grid::-webkit-scrollbar-track { background: transparent; }
.affix-grid::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 4px; }

.affix-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 6px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-md);
  background: white;
  cursor: pointer;
  transition: var(--transition);
  -webkit-tap-highlight-color: transparent;
  position: relative;
  overflow: hidden;
}

.affix-btn:active { transform: scale(0.94); }

.affix-btn.selected {
  border-color: var(--purple);
  background: linear-gradient(135deg, var(--purple-pale), var(--pink-pale));
  box-shadow: var(--shadow-purple);
}

.affix-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
}

.affix-btn.selected .affix-name { color: var(--purple); }

.affix-count {
  font-size: 10px;
  color: var(--text-secondary);
}

.affix-accuracy {
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 9px;
  font-weight: 600;
  padding: 1px 4px;
  border-radius: var(--radius-full);
  background: var(--mint-light);
  color: #2f9e44;
}

.affix-accuracy.low { background: var(--coral-light); color: #c92a2a; }
.affix-accuracy.mid { background: var(--yellow-light); color: #e67700; }

/* 選択後のスタートボタン */
.affix-start-area {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.selected-info {
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
}

.selected-info strong { color: var(--purple); }

/* --- 苦手克服セクション --- */
.weak-section {
  padding: 16px;
  background: var(--yellow-pale);
  border-radius: var(--radius-md);
  border: 2px dashed var(--yellow);
  text-align: center;
}

.weak-info { margin-bottom: 14px; font-size: 14px; color: var(--text-secondary); }

/* --- デイリーチャレンジ --- */
.daily-challenge-card {
  background: linear-gradient(135deg, #FF6B9D, #C77DFF);
  border-radius: var(--radius-md);
  padding: 18px;
  color: white;
}

.dc-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.dc-icon { font-size: 28px; flex-shrink: 0; }

.dc-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 4px;
}

.dc-desc { font-size: 12px; opacity: 0.85; }

.dc-status {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  background: rgba(255,255,255,0.25);
  border-radius: var(--radius-full);
  white-space: nowrap;
  flex-shrink: 0;
}

.dc-status.completed {
  background: rgba(255,255,255,0.4);
}

.dc-btn {
  background: white !important;
  color: var(--pink) !important;
  width: 100%;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15) !important;
}

/* ============================================
   共通ボタン
   ============================================ */
.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  background: linear-gradient(135deg, var(--pink), var(--purple));
  color: white;
  border: none;
  border-radius: var(--radius-full);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-pink);
  transition: var(--transition);
  -webkit-tap-highlight-color: transparent;
  width: 100%;
}

.btn-primary:active { transform: scale(0.97); box-shadow: none; }
.btn-primary:disabled {
  background: var(--gray-300);
  box-shadow: none;
  cursor: not-allowed;
}

.btn-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  background: white;
  color: var(--purple);
  border: 2px solid var(--purple);
  border-radius: var(--radius-full);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.btn-secondary:active { transform: scale(0.97); background: var(--purple-pale); }

.btn-danger {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  background: white;
  color: var(--coral);
  border: 2px solid var(--coral-light);
  border-radius: var(--radius-full);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  margin-top: 20px;
  transition: var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.btn-danger:active { background: #FFF5F5; }

/* ============================================
   クイズ画面
   ============================================ */
#screen-quiz {
  background: linear-gradient(160deg, #FFF0F6 0%, #F8F0FF 100%);
  min-height: 100vh;
}

.quiz-header {
  display: flex;
  align-items: center;
  padding: 14px 16px 10px;
  gap: 12px;
  background: white;
  box-shadow: var(--shadow-sm);
}

.back-btn {
  background: none;
  border: none;
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-500);
  cursor: pointer;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}
.back-btn:active { background: var(--gray-100); }

.quiz-header-info { flex: 1; text-align: center; }

.quiz-mode-label {
  font-size: 18px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--pink), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.quiz-progress-text {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-secondary);
  white-space: nowrap;
}

.quiz-progress-bar {
  height: 6px;
  background: var(--gray-200);
}

.quiz-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--pink), var(--purple));
  transition: width 0.5s ease;
  width: 0%;
}

/* --- スコアバー --- */
.quiz-score-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: white;
  border-bottom: 1px solid var(--gray-100);
}

.score-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.score-icon { font-size: 18px; }

.combo-display {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--yellow-pale);
  border: 2px solid var(--yellow);
  border-radius: var(--radius-full);
  padding: 4px 12px;
  font-size: 14px;
  font-weight: 700;
  color: #e67700;
  transition: var(--transition);
}

.combo-display.active {
  background: var(--yellow-light);
  transform: scale(1.05);
}

.combo-icon { font-size: 16px; }
.combo-label { font-size: 12px; }

.hearts {
  display: flex;
  gap: 2px;
  font-size: 16px;
}

.heart.lost {
  filter: grayscale(100%);
  opacity: 0.4;
}

/* --- クイズコンテンツ --- */
.quiz-content {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.question-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  box-shadow: var(--shadow-md);
  text-align: center;
  animation: questionSlideIn 0.4s var(--bounce) both;
}

@keyframes questionSlideIn {
  from { opacity: 0; transform: translateY(-20px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.question-number {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.question-word {
  font-size: 36px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 12px;
  letter-spacing: -0.5px;
}

.question-etymology {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.etymology-tag {
  background: linear-gradient(135deg, var(--pink-pale), var(--purple-pale));
  border: 2px solid var(--pink-light);
  color: var(--pink);
  font-size: 13px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: var(--radius-full);
}

.etymology-separator {
  color: var(--gray-400);
  font-size: 16px;
  font-weight: 600;
}

.etymology-root {
  background: var(--blue-pale);
  border: 2px solid var(--blue-light);
  color: #1c7ed6;
  font-size: 13px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: var(--radius-full);
}

/* --- ヒントボタン・表示エリア --- */
.hint-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin: 4px 0 8px;
}

.btn-hint {
  background: linear-gradient(135deg, var(--pink-pale), var(--purple-pale));
  border: 2px solid var(--pink-light);
  border-radius: 20px;
  padding: 8px 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--purple);
  cursor: pointer;
  transition: var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.btn-hint:active:not(:disabled) { transform: scale(0.95); }

.btn-hint:disabled {
  opacity: 0.5;
  cursor: default;
}

.hint-display {
  display: none;
  background: linear-gradient(135deg, #FFF9E6, #FFFDE0);
  border: 2px solid #FFD43B;
  border-radius: var(--radius-md);
  padding: 10px 16px;
  font-size: 13px;
  color: #7C5C00;
  text-align: center;
  width: 100%;
  animation: hintFadeIn 0.35s ease both;
}

.hint-display.show { display: block; }

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

/* --- 選択肢グリッド --- */
.choices-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.choice-btn {
  padding: 16px 12px;
  border: 2.5px solid var(--gray-200);
  border-radius: var(--radius-md);
  background: white;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
  line-height: 1.4;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  -webkit-tap-highlight-color: transparent;
  animation: choiceFadeIn 0.3s ease both;
}

.choice-btn:nth-child(2) { animation-delay: 0.05s; }
.choice-btn:nth-child(3) { animation-delay: 0.1s; }
.choice-btn:nth-child(4) { animation-delay: 0.15s; }

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

.choice-btn:active:not(:disabled) { transform: scale(0.96); }

.choice-btn.correct {
  border-color: var(--mint);
  background: var(--mint-pale);
  color: #2f9e44;
  animation: correctPulse 0.5s var(--bounce);
}

@keyframes correctPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

.choice-btn.wrong {
  border-color: var(--coral);
  background: #FFF5F5;
  color: #c92a2a;
  animation: wrongShake 0.4s ease;
}

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

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

/* --- 解説パネル --- */
.explanation-panel {
  background: white;
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-md);
  display: none;
  animation: explainSlideUp 0.4s var(--bounce) both;
  border-top: 4px solid var(--mint);
}

.explanation-panel.show { display: block; }
.explanation-panel.wrong-panel { border-top-color: var(--coral); }

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

.explanation-correct-icon {
  font-size: 28px;
  text-align: center;
  margin-bottom: 8px;
}

.explanation-text {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 10px;
  text-align: center;
}

.explanation-breakdown {
  background: var(--gray-50);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 16px;
}

.explanation-breakdown strong { color: var(--text-primary); }

.btn-next {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--pink), var(--purple));
  color: white;
  border: none;
  border-radius: var(--radius-full);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  -webkit-tap-highlight-color: transparent;
  box-shadow: var(--shadow-pink);
}
.btn-next:active { transform: scale(0.97); }

/* ============================================
   結果画面
   ============================================ */
#screen-result {
  background: linear-gradient(160deg, #FFF0F6 0%, #F8F0FF 100%);
  overflow-y: auto;
}

.result-container {
  padding: 32px 20px 40px;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.result-emoji {
  font-size: 72px;
  animation: resultBounce 0.8s var(--bounce) both;
  animation-delay: 0.1s;
}

@keyframes resultBounce {
  from { opacity: 0; transform: scale(0.3) rotate(-10deg); }
  to { opacity: 1; transform: scale(1) rotate(0deg); }
}

.result-title {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-primary);
  text-align: center;
  animation: fadeInUp 0.5s ease both;
  animation-delay: 0.2s;
}

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

.result-score-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 24px 40px;
  text-align: center;
  box-shadow: var(--shadow-md);
  width: 100%;
  animation: fadeInUp 0.5s ease both;
  animation-delay: 0.3s;
}

.result-score {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  margin-bottom: 8px;
}

.result-score-num {
  font-size: 56px;
  font-weight: 900;
  background: linear-gradient(135deg, var(--pink), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.result-score-sep {
  font-size: 28px;
  color: var(--gray-400);
  font-weight: 300;
}

.result-score-total {
  font-size: 28px;
  color: var(--gray-400);
  font-weight: 600;
}

.result-accuracy {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-secondary);
}

.result-stats {
  display: flex;
  gap: 12px;
  width: 100%;
  animation: fadeInUp 0.5s ease both;
  animation-delay: 0.4s;
}

.result-stat {
  flex: 1;
  background: white;
  border-radius: var(--radius-md);
  padding: 14px 8px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rs-icon { font-size: 22px; }
.rs-value { font-size: 18px; font-weight: 800; color: var(--text-primary); }
.rs-label { font-size: 11px; color: var(--text-secondary); }

/* --- レベルアップバナー --- */
.level-up-banner {
  display: none;
  background: linear-gradient(135deg, var(--yellow), var(--orange));
  border-radius: var(--radius-md);
  padding: 16px 24px;
  width: 100%;
  text-align: center;
  color: white;
  gap: 8px;
  animation: levelUpPop 0.8s var(--bounce) both;
}

.level-up-banner.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

@keyframes levelUpPop {
  from { opacity: 0; transform: scale(0.5); }
  to { opacity: 1; transform: scale(1); }
}

.lu-icon { font-size: 28px; }
.lu-text { font-size: 18px; font-weight: 800; }
.lu-level { font-size: 22px; font-weight: 900; }

/* --- 間違えた問題リスト --- */
.wrong-answers {
  background: white;
  border-radius: var(--radius-lg);
  padding: 18px;
  width: 100%;
  box-shadow: var(--shadow-sm);
  animation: fadeInUp 0.5s ease both;
  animation-delay: 0.5s;
}

.wrong-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.wrong-item {
  border-bottom: 1px solid var(--gray-100);
  padding: 10px 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

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

.wrong-word {
  font-size: 18px;
  font-weight: 700;
  color: var(--coral);
}

.wrong-meaning {
  font-size: 13px;
  color: var(--text-secondary);
}

.wrong-etymology {
  font-size: 12px;
  color: var(--purple);
  font-style: italic;
}

/* --- 結果ボタン --- */
.result-buttons {
  display: flex;
  gap: 12px;
  width: 100%;
  animation: fadeInUp 0.5s ease both;
  animation-delay: 0.6s;
}

.result-buttons .btn-secondary,
.result-buttons .btn-primary {
  flex: 1;
}

/* ============================================
   プロフィール画面
   ============================================ */
#screen-profile {
  overflow-y: auto;
  background: linear-gradient(160deg, #FFF0F6 0%, #F8F0FF 100%);
}

.profile-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: white;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
}

.profile-header h2 {
  font-size: 18px;
  font-weight: 700;
}

.profile-content {
  padding: 20px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* レベルカード */
.profile-level-card {
  background: linear-gradient(135deg, #FF6B9D, #C77DFF);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  color: white;
  box-shadow: var(--shadow-pink);
}

.profile-avatar {
  font-size: 52px;
  background: rgba(255,255,255,0.2);
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.profile-level-info { flex: 1; }

.profile-level-badge {
  font-size: 20px;
  font-weight: 900;
  background: rgba(255,255,255,0.25);
  display: inline-block;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  margin-bottom: 4px;
}

.profile-title {
  font-size: 16px;
  font-weight: 700;
  opacity: 0.9;
  margin-bottom: 8px;
}

.xp-bar-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.xp-bar {
  height: 8px;
  background: rgba(255,255,255,0.3);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.xp-fill {
  height: 100%;
  background: white;
  border-radius: var(--radius-full);
  transition: width 1s var(--bounce);
}

.xp-text { font-size: 11px; opacity: 0.85; }

/* 統計カード */
.profile-stats-card,
.weak-roots-card,
.badges-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

.profile-stats-card h3,
.weak-roots-card h3,
.badges-card h3 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 14px;
}

.profile-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.ps-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: var(--gray-50);
  border-radius: var(--radius-md);
  padding: 12px 8px;
}

.ps-icon { font-size: 22px; }
.ps-value { font-size: 18px; font-weight: 800; color: var(--text-primary); }
.ps-label { font-size: 10px; color: var(--text-secondary); text-align: center; }

/* 苦手語根リスト */
.weak-root-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--gray-100);
}

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

.weak-root-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--coral);
  width: 60px;
  flex-shrink: 0;
}

.weak-root-bar-container { flex: 1; }

.weak-root-bar {
  height: 8px;
  background: var(--gray-200);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: 2px;
}

.weak-root-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--coral), var(--orange));
  border-radius: var(--radius-full);
}

.weak-root-stats {
  font-size: 11px;
  color: var(--text-secondary);
}

.no-data-text { font-size: 13px; color: var(--text-secondary); text-align: center; padding: 16px 0; }

/* バッジグリッド */
.badges-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.badge-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
}

.badge-icon {
  font-size: 32px;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--gray-100);
  transition: var(--transition);
}

.badge-item.earned .badge-icon {
  background: var(--yellow-light);
  box-shadow: 0 4px 12px rgba(255,212,59,0.4);
  animation: badgeShine 2s ease-in-out infinite;
}

@keyframes badgeShine {
  0%, 100% { box-shadow: 0 4px 12px rgba(255,212,59,0.4); }
  50% { box-shadow: 0 4px 20px rgba(255,212,59,0.7); }
}

.badge-item.locked .badge-icon { filter: grayscale(100%); opacity: 0.4; }

.badge-name { font-size: 10px; color: var(--text-secondary); line-height: 1.2; }
.badge-item.earned .badge-name { color: var(--text-primary); font-weight: 600; }

/* ============================================
   エフェクト・オーバーレイ
   ============================================ */
.effect-overlay {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 500;
  pointer-events: none;
  display: none;
}

.effect-overlay.show {
  display: flex;
  animation: effectPop 0.8s var(--bounce) both;
}

@keyframes effectPop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.3); }
  60% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
  80% { transform: translate(-50%, -50%) scale(0.95); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1) translateY(-30px); }
}

.effect-content {
  background: white;
  border-radius: var(--radius-xl);
  padding: 20px 28px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  border: 3px solid var(--mint);
}

.effect-content.correct-content { border-color: var(--mint); }

.effect-icon { font-size: 40px; margin-bottom: 4px; }
.effect-text { font-size: 24px; font-weight: 800; color: var(--mint); }
.xp-gained { font-size: 16px; font-weight: 700; color: var(--purple); margin-top: 4px; }

/* コンボエフェクト */
.combo-effect {
  position: fixed;
  top: 30%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 501;
  pointer-events: none;
  display: none;
}

.combo-effect.show {
  display: flex;
  animation: comboFloat 1s ease both;
}

@keyframes comboFloat {
  0% { opacity: 0; transform: translateX(-50%) scale(0.5) translateY(20px); }
  30% { opacity: 1; transform: translateX(-50%) scale(1.2) translateY(0); }
  70% { opacity: 1; transform: translateX(-50%) scale(1) translateY(-10px); }
  100% { opacity: 0; transform: translateX(-50%) scale(0.8) translateY(-40px); }
}

.combo-effect-text {
  background: linear-gradient(135deg, var(--yellow), var(--orange));
  color: white;
  font-size: 22px;
  font-weight: 900;
  padding: 10px 20px;
  border-radius: var(--radius-full);
  box-shadow: 0 4px 20px rgba(255,169,77,0.5);
  white-space: nowrap;
}

/* ============================================
   モーダル
   ============================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 600;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

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

.modal-content {
  background: white;
  border-radius: var(--radius-xl);
  padding: 28px 24px;
  width: 100%;
  max-width: 340px;
  box-shadow: var(--shadow-lg);
  animation: modalPop 0.4s var(--bounce) both;
  text-align: center;
}

@keyframes modalPop {
  from { opacity: 0; transform: scale(0.7); }
  to { opacity: 1; transform: scale(1); }
}

.modal-content h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 10px;
}

.modal-content p { font-size: 14px; color: var(--text-secondary); margin-bottom: 20px; }

.modal-buttons {
  display: flex;
  gap: 10px;
}

.modal-buttons .btn-secondary,
.modal-buttons .btn-danger {
  flex: 1;
  margin-top: 0;
}

/* --- レベルアップモーダル --- */
.levelup-modal-content {
  background: linear-gradient(160deg, #FFF0F6, #F8F0FF);
}

.levelup-stars { font-size: 36px; margin-bottom: 8px; }
.levelup-title {
  font-size: 28px;
  font-weight: 900;
  background: linear-gradient(135deg, var(--pink), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}
.levelup-level {
  font-size: 56px;
  font-weight: 900;
  color: var(--yellow);
  text-shadow: 0 4px 12px rgba(255,212,59,0.4);
  margin-bottom: 4px;
}
.levelup-title-text {
  font-size: 20px;
  font-weight: 700;
  color: var(--purple);
  margin-bottom: 20px;
}

/* ============================================
   音声ボタン
   ============================================ */
.quiz-header-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sound-toggle-btn {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  line-height: 1;
  opacity: 1;
}
.sound-toggle-btn:active { background: var(--gray-100); }
.sound-toggle-btn.sound-off { opacity: 0.4; }

.quiz-sound-btn {
  font-size: 18px;
}

.question-word-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.speak-word-btn {
  background: var(--pink-pale);
  border: 2px solid var(--pink-light);
  border-radius: var(--radius-full);
  width: 36px;
  height: 36px;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}
.speak-word-btn:active {
  background: var(--pink-light);
  transform: scale(0.92);
}
.speak-word-btn.speaking {
  animation: speakPulse 0.6s ease infinite alternate;
}
@keyframes speakPulse {
  from { box-shadow: 0 0 0 0 rgba(255,107,157,0.4); }
  to   { box-shadow: 0 0 0 8px rgba(255,107,157,0); }
}

/* ============================================
   ユーティリティ
   ============================================ */
.hidden { display: none !important; }

/* スクロールバー */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 4px; }

/* セーフエリア対応 */
@supports (padding: env(safe-area-inset-bottom)) {
  #screen-home { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
  #screen-result .result-container { padding-bottom: calc(40px + env(safe-area-inset-bottom)); }
}

/* タブレット・デスクトップ対応 */
@media (min-width: 480px) {
  .home-main, .quiz-content, .result-container, .profile-content {
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
  }
  .quiz-header, .quiz-progress-bar, .quiz-score-bar { max-width: 480px; margin: 0 auto; }
  .home-header, .stats-bar { max-width: 480px; margin: 0 auto; }
}

@media (min-width: 768px) {
  body { background: linear-gradient(135deg, #F8F0FF 0%, #FFF0F6 100%); }
  .screen { max-width: 480px; margin: 0 auto; box-shadow: var(--shadow-lg); min-height: 100vh; }
}
