/* ══════════════════════════════════════
   DESIGN TOKENS
══════════════════════════════════════ */
:root {
  --primary: #e8345a;
  --secondary: #3a86ff;
  --purple: #7c5cbf;
  --gold: #ffd700;
  --bg-dark: #090410;
  --bg-medium: #120820;
  --bg-card: rgba(255, 255, 255, 0.06);
  --glass: rgba(255, 255, 255, 0.04);
  --glass-border: rgba(255, 255, 255, 0.1);
  --text: #f0f0f5;
  --text-muted: #888899;
  --text-dim: #555566;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

/* ══════════════════════════════════════
   RESET & BASE
══════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  background: var(--bg-dark);
  color: var(--text);
  font-family: 'DM Sans', 'Noto Sans KR', sans-serif;
  font-size: 16px;
  line-height: 1.5;
  overflow: hidden;
}
button { cursor: pointer; border: none; background: none; color: inherit; font-family: inherit; font-size: inherit; }
a { color: var(--secondary); text-decoration: none; }
hr.settings-divider { border: none; border-top: 1px solid var(--glass-border); margin: 16px 0; }

/* ══════════════════════════════════════
   SCREEN SYSTEM
══════════════════════════════════════ */
.screen {
  display: none;
  flex-direction: column;
  height: 100dvh;
  overflow-y: auto;
  padding: 0;
  animation: fadeIn 0.25s ease;
}
.screen.active { display: flex; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ══════════════════════════════════════
   PROFILE SCREEN
══════════════════════════════════════ */
.hero {
  text-align: center;
  padding: 48px 24px 24px;
  background: linear-gradient(135deg, #1a0a2e 0%, #0d1f3c 100%);
}
.hero-flag { font-size: 48px; margin-bottom: 8px; }
.hero-title { font-size: 36px; font-weight: 700; color: var(--primary); }
.hero-subtitle { color: var(--text-muted); font-size: 14px; margin-top: 4px; }
.profile-section { padding: 24px; flex: 1; }
.section-title { font-size: 14px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 16px; }
.profile-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.profile-card {
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 20px 12px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
  backdrop-filter: blur(12px);
}
.profile-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.profile-avatar { font-size: 36px; margin-bottom: 8px; }
.profile-name { font-weight: 600; font-size: 15px; }

/* ══════════════════════════════════════
   LANGUAGE SELECTION SCREEN
══════════════════════════════════════ */
.screen-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--glass-border);
}
.screen-header h2 { font-size: 18px; font-weight: 600; }
.language-cards { display: flex; flex-direction: column; gap: 16px; padding: 24px; flex: 1; justify-content: center; }
.lang-card {
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 28px 24px;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.2s, transform 0.15s;
  backdrop-filter: blur(12px);
}
.lang-card:hover { border-color: var(--secondary); transform: translateY(-2px); }
.lang-flag { font-size: 48px; margin-bottom: 12px; }
.lang-name { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.lang-desc { color: var(--text-muted); font-size: 14px; }

/* ══════════════════════════════════════
   APP SCREEN & TAB SYSTEM
══════════════════════════════════════ */
#screen-app {
  display: none;
  flex-direction: column;
  height: 100dvh;
  position: relative;
}
#screen-app.active { display: flex; }
.tab-content { display: none; flex: 1; overflow-y: auto; padding-bottom: 80px; }
.tab-content.active { display: block; animation: fadeIn 0.2s ease; }

/* ══════════════════════════════════════
   APP HEADER
══════════════════════════════════════ */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 8px;
  font-size: 18px;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg-dark);
}

/* ══════════════════════════════════════
   HOME TAB
══════════════════════════════════════ */
.streak-card {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(232, 52, 90, 0.12);
  border: 1px solid rgba(232, 52, 90, 0.25);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 8px 16px;
}
.streak-fire { font-size: 24px; }
#streak-count { font-size: 28px; font-weight: 700; color: var(--primary); }
.streak-label { color: var(--text-muted); font-size: 13px; }
.goal-section { padding: 12px 16px; }
.goal-label { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }
.progress-bar-bg { background: rgba(255,255,255,0.08); border-radius: 6px; height: 8px; }
.progress-bar-fill { height: 100%; background: var(--primary); border-radius: 6px; transition: width 0.5s ease; }
.quickstart-btn { margin: 12px 16px; width: calc(100% - 32px); font-size: 16px; font-weight: 600; }
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  background: white; color: var(--primary); border-radius: 50px;
  font-size: 11px; font-weight: 700; padding: 2px 7px; margin-left: 8px;
}
.leaderboard-section { padding: 12px 16px; }
.leaderboard-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.leaderboard-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-card); border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm); padding: 10px 14px;
}
.leaderboard-rank { font-size: 18px; width: 28px; text-align: center; }
.leaderboard-avatar { font-size: 22px; }
.leaderboard-name { flex: 1; font-weight: 600; }
.leaderboard-pts { color: var(--gold); font-weight: 700; }
.leaderboard-streak { color: var(--text-muted); font-size: 12px; margin-left: 8px; }

/* ══════════════════════════════════════
   LEARN TAB
══════════════════════════════════════ */
.category-list { display: flex; flex-direction: column; gap: 10px; padding: 8px 16px; }
.category-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--bg-card); border: 1px solid var(--glass-border);
  border-radius: var(--radius); padding: 16px; cursor: pointer;
  transition: border-color 0.2s;
}
.category-card:hover { border-color: var(--secondary); }
.category-emoji { font-size: 28px; }
.category-info { flex: 1; }
.category-name { font-weight: 600; font-size: 15px; }
.category-count { color: var(--text-muted); font-size: 12px; margin-top: 2px; }
.category-arrow { color: var(--text-muted); }

/* ══════════════════════════════════════
   PRACTICE TAB
══════════════════════════════════════ */
.practice-grid { display: flex; flex-direction: column; gap: 12px; padding: 12px 16px; }
.practice-card {
  display: flex; align-items: center; gap: 16px;
  background: var(--bg-card); border: 1px solid var(--glass-border);
  border-radius: var(--radius); padding: 18px; cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
}
.practice-card:hover { border-color: var(--primary); transform: translateX(4px); }
.practice-icon { font-size: 32px; }
.practice-name { font-weight: 600; font-size: 16px; }
.practice-desc { color: var(--text-muted); font-size: 13px; margin-top: 2px; }

/* ══════════════════════════════════════
   GAMES TAB
══════════════════════════════════════ */
.games-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 12px 16px; }
.game-card {
  background: rgba(255, 215, 0, 0.08); border: 1px solid rgba(255, 215, 0, 0.2);
  border-radius: var(--radius); padding: 24px 12px; text-align: center;
  cursor: pointer; transition: transform 0.15s, border-color 0.2s;
}
.game-card:hover { transform: translateY(-3px); border-color: var(--gold); }
.game-icon { font-size: 40px; margin-bottom: 10px; }
.game-name { font-weight: 600; font-size: 14px; }

/* ══════════════════════════════════════
   CULTURE TAB
══════════════════════════════════════ */
.culture-list { display: flex; flex-direction: column; gap: 12px; padding: 8px 16px; }
.culture-card {
  background: var(--bg-card); border: 1px solid var(--glass-border);
  border-radius: var(--radius); padding: 18px; cursor: pointer;
  transition: border-color 0.2s;
}
.culture-card:hover { border-color: var(--purple); }
.culture-card-header { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.culture-emoji { font-size: 28px; }
.culture-title { font-weight: 600; font-size: 16px; }
.culture-category { color: var(--text-muted); font-size: 12px; }
.culture-preview { color: var(--text-muted); font-size: 13px; line-height: 1.5; }

/* ══════════════════════════════════════
   STATS TAB
══════════════════════════════════════ */
.stats-content { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.stat-card {
  background: var(--bg-card); border: 1px solid var(--glass-border);
  border-radius: var(--radius); padding: 20px;
}
.stat-value { font-size: 36px; font-weight: 700; color: var(--secondary); }
.stat-label { color: var(--text-muted); font-size: 14px; margin-top: 4px; }

/* ══════════════════════════════════════
   BOTTOM TAB NAVIGATION
══════════════════════════════════════ */
.tab-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: 64px; background: rgba(9, 4, 16, 0.95);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--glass-border);
  display: flex; align-items: center;
  padding: 0; z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.tab-btn {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 2px; height: 100%; color: var(--text-dim);
  transition: color 0.2s;
}
.tab-btn.active { color: var(--primary); }
.tab-icon { font-size: 20px; line-height: 1; }
.tab-label { font-size: 10px; font-weight: 500; }

/* ══════════════════════════════════════
   SESSION OVERLAY
══════════════════════════════════════ */
.overlay {
  position: fixed; inset: 0; z-index: 200;
  background: var(--bg-dark);
  display: flex; flex-direction: column;
  animation: fadeIn 0.2s ease;
}
.overlay.hidden { display: none; }
.overlay-header { border-bottom: 1px solid var(--glass-border); }
.session-progress-container { height: 4px; background: rgba(255,255,255,0.08); }
.session-progress-bar { height: 100%; background: var(--primary); transition: width 0.4s ease; }
.session-content {
  flex: 1; overflow-y: auto; display: flex;
  flex-direction: column; align-items: center;
  justify-content: center; padding: 24px 16px;
  gap: 16px;
}

/* Settings overlay has a centered card */
.overlay-card {
  background: var(--bg-medium); border: 1px solid var(--glass-border);
  border-radius: var(--radius); padding: 24px;
  margin: auto; width: calc(100% - 32px); max-width: 420px;
}
.settings-label { font-size: 13px; color: var(--text-muted); margin-bottom: 6px; display: block; }
.settings-input {
  width: 100%; background: var(--bg-card); border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm); color: var(--text); padding: 10px 14px;
  font-size: 16px; font-family: inherit;
}

/* ══════════════════════════════════════
   FLASHCARD (3D Flip)
══════════════════════════════════════ */
.flashcard-container {
  perspective: 1000px;
  width: 100%; max-width: 340px;
  cursor: pointer;
}
.flashcard {
  position: relative;
  width: 100%; padding-top: 65%;
  transform-style: preserve-3d;
  transition: transform 0.5s ease;
  border-radius: var(--radius);
}
.flashcard.flipped { transform: rotateY(180deg); }
.flashcard-front,
.flashcard-back {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 24px; text-align: center;
}
.flashcard-back { transform: rotateY(180deg); }
.flashcard-word { font-size: 36px; font-weight: 700; }
.flashcard-romanization { color: var(--text-muted); font-size: 16px; margin-top: 6px; }
.flashcard-translation { font-size: 28px; font-weight: 600; color: var(--secondary); }
.flashcard-example { color: var(--text-muted); font-size: 14px; margin-top: 10px; font-style: italic; }
.flashcard-example-tr { color: var(--text-dim); font-size: 13px; margin-top: 4px; }

/* ══════════════════════════════════════
   QUIZ
══════════════════════════════════════ */
.quiz-question {
  font-size: 36px; font-weight: 700; text-align: center;
  margin-bottom: 24px; width: 100%;
}
.quiz-options {
  display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 380px;
}
.quiz-option {
  background: var(--bg-card); border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm); padding: 14px 18px;
  font-size: 15px; text-align: left;
  transition: background 0.2s, border-color 0.2s;
}
.quiz-option:hover { border-color: var(--secondary); }
.quiz-option.correct { background: rgba(46, 213, 115, 0.2); border-color: #2ed573; }
.quiz-option.wrong   { background: rgba(232, 52, 90, 0.2);  border-color: var(--primary); }

/* ══════════════════════════════════════
   SRS RATING BUTTONS
══════════════════════════════════════ */
.rating-buttons {
  display: flex; gap: 8px; flex-wrap: wrap; justify-content: center;
  width: 100%; max-width: 400px;
}
.rating-btn {
  flex: 1; min-width: 80px; padding: 12px 8px;
  border-radius: var(--radius-sm); font-size: 13px; font-weight: 600;
  transition: transform 0.15s;
}
.rating-btn:hover { transform: translateY(-2px); }
.btn-again { background: rgba(232, 52, 90, 0.25); border: 1px solid var(--primary); color: var(--primary); }
.btn-hard  { background: rgba(255,165,0,0.2);    border: 1px solid orange;           color: orange; }
.btn-good  { background: rgba(58,134,255,0.2);   border: 1px solid var(--secondary); color: var(--secondary); }
.btn-great { background: rgba(46,213,115,0.2);   border: 1px solid #2ed573;          color: #2ed573; }

/* ══════════════════════════════════════
   TOAST
══════════════════════════════════════ */
.toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  background: rgba(30, 15, 50, 0.95); border: 1px solid var(--glass-border);
  border-radius: 24px; padding: 10px 20px; font-size: 14px; z-index: 999;
  backdrop-filter: blur(12px); white-space: nowrap;
  animation: toastIn 0.3s ease;
}
.toast.hidden { display: none; }
@keyframes toastIn { from { opacity:0; transform: translateX(-50%) translateY(8px); } to { opacity:1; transform: translateX(-50%) translateY(0); } }

/* ══════════════════════════════════════
   UTILITIES
══════════════════════════════════════ */
.hidden { display: none !important; }
.text-center { text-align: center; width: 100%; }
.mt-10 { margin-top: 10px; }
.mt-20 { margin-top: 20px; }
.btn-primary {
  background: var(--primary); color: white;
  border-radius: var(--radius-sm); padding: 13px 24px;
  font-weight: 600; font-size: 15px; width: 100%;
  transition: opacity 0.2s, transform 0.15s;
}
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-secondary {
  background: var(--bg-card); border: 1px solid var(--glass-border);
  color: var(--text); border-radius: var(--radius-sm); padding: 12px 20px;
  font-weight: 500; font-size: 15px;
  transition: border-color 0.2s;
}
.btn-secondary:hover { border-color: var(--secondary); }
.icon-btn {
  background: rgba(255,255,255,0.08); border: none;
  border-radius: 50%; width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; cursor: pointer;
  transition: background 0.2s;
}
.icon-btn:hover { background: rgba(255,255,255,0.14); }

/* ══════════════════════════════════════
   SCROLLBAR (webkit)
══════════════════════════════════════ */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--glass-border); border-radius: 2px; }
