/* ============================================================
   B1 English Listening Game - Premium Design System
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=Space+Grotesk:wght@400;500;600;700&display=swap');

/* ---- CSS Custom Properties (Design Tokens) ---- */
:root {
  /* Primary palette */
  --primary: #6C5CE7;
  --primary-light: #A29BFE;
  --primary-dark: #4834D4;
  --primary-glow: rgba(108, 92, 231, 0.4);

  /* Accent colors */
  --accent-green: #00D2A0;
  --accent-green-glow: rgba(0, 210, 160, 0.3);
  --accent-orange: #F39C12;
  --accent-orange-glow: rgba(243, 156, 18, 0.3);
  --accent-red: #E74C3C;
  --accent-red-glow: rgba(231, 76, 60, 0.3);
  --accent-blue: #00B4D8;
  --accent-blue-glow: rgba(0, 180, 216, 0.3);
  --accent-pink: #FD79A8;
  --accent-pink-glow: rgba(253, 121, 168, 0.3);

  /* Background layers */
  --bg-base: #0A0A1A;
  --bg-surface: #12122A;
  --bg-card: #1A1A3E;
  --bg-card-hover: #222255;
  --bg-elevated: #252552;
  --bg-overlay: rgba(10, 10, 26, 0.85);

  /* Text */
  --text-primary: #EEEEF5;
  --text-secondary: #9D9DB8;
  --text-muted: #5E5E7A;
  --text-accent: #A29BFE;

  /* Borders */
  --border-subtle: rgba(108, 92, 231, 0.15);
  --border-active: rgba(108, 92, 231, 0.4);
  --border-glow: rgba(108, 92, 231, 0.6);

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px var(--primary-glow);
  --shadow-glow-green: 0 0 20px var(--accent-green-glow);

  /* Radii */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-smooth: 350ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Font sizes */
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 2rem;
  --text-4xl: 2.5rem;
  --text-5xl: 3.5rem;
}

/* ---- Reset & Base ---- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---- Animated Background ---- */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(108, 92, 231, 0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 80%, rgba(0, 210, 160, 0.06) 0%, transparent 60%),
    radial-gradient(ellipse at 50% 50%, rgba(0, 180, 216, 0.04) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
  animation: bgPulse 15s ease-in-out infinite alternate;
}

@keyframes bgPulse {
  0% {
    opacity: 0.6;
  }

  50% {
    opacity: 1;
  }

  100% {
    opacity: 0.7;
  }
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-surface);
}

::-webkit-scrollbar-thumb {
  background: var(--primary-dark);
  border-radius: var(--radius-full);
}

/* ---- App Container ---- */
#app {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  min-height: 100vh;
}

/* ---- Header ---- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 24px;
}

.app-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  text-decoration: none;
}

.logo-icon {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--primary), var(--accent-blue));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: var(--shadow-glow);
  transition: var(--transition-smooth);
}

.app-logo:hover .logo-icon {
  transform: scale(1.1) rotate(5deg);
}

.logo-text {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: var(--text-xl);
  background: linear-gradient(135deg, var(--text-primary), var(--primary-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.logo-badge {
  background: linear-gradient(135deg, var(--accent-green), var(--accent-blue));
  color: white;
  font-size: var(--text-xs);
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  letter-spacing: 0.5px;
}

.header-stats {
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  padding: 8px 14px;
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: 600;
  border: 1px solid var(--border-subtle);
  transition: var(--transition-fast);
}

.stat-chip:hover {
  border-color: var(--border-active);
}

.stat-chip .icon {
  font-size: 16px;
}

.stat-chip .value {
  color: var(--primary-light);
}

/* ---- Screens ---- */
.screen {
  display: none;
  animation: fadeSlideUp 0.4s ease;
}

.screen.active {
  display: block;
}

@keyframes fadeSlideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---- Home Screen ---- */
.welcome-hero {
  text-align: center;
  padding: 40px 0 50px;
}

.welcome-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: var(--text-4xl);
  font-weight: 800;
  margin-bottom: 12px;
  line-height: 1.2;
}

.welcome-title .gradient {
  background: linear-gradient(135deg, var(--primary-light), var(--accent-blue), var(--accent-green));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.welcome-subtitle {
  color: var(--text-secondary);
  font-size: var(--text-lg);
  max-width: 500px;
  margin: 0 auto 24px;
}

.daily-tip {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px 24px;
  display: inline-block;
  max-width: 600px;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  animation: fadeIn 0.6s ease 0.3s both;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

/* ---- Progress Card ---- */
.progress-section {
  margin-bottom: 40px;
}

.progress-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 28px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 20px;
  position: relative;
  overflow: hidden;
}

.progress-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--accent-blue), var(--accent-green), var(--accent-orange));
}

.progress-item {
  text-align: center;
}

.progress-item .label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

.progress-item .value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: var(--text-3xl);
  font-weight: 700;
  color: var(--primary-light);
}

.progress-item .sub {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  margin-top: 4px;
}

.xp-bar-container {
  grid-column: 1 / -1;
  margin-top: 8px;
}

.xp-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.xp-bar {
  width: 100%;
  height: 8px;
  background: var(--bg-base);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.xp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent-blue));
  border-radius: var(--radius-full);
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.xp-bar-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }

  100% {
    transform: translateX(100%);
  }
}

/* ---- Game Mode Cards ---- */
.modes-section h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: var(--text-2xl);
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text-primary);
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 40px;
}

.mode-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 28px;
  cursor: pointer;
  transition: var(--transition-smooth);
  position: relative;
  overflow: hidden;
}

.mode-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: var(--radius-lg);
  transition: var(--transition-smooth);
  opacity: 0;
}

.mode-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-active);
  box-shadow: var(--shadow-lg);
}

.mode-card.dictation::before {
  background: linear-gradient(135deg, rgba(108, 92, 231, 0.1), transparent);
}

.mode-card.fillblank::before {
  background: linear-gradient(135deg, rgba(0, 180, 216, 0.1), transparent);
}

.mode-card.dialogue::before {
  background: linear-gradient(135deg, rgba(0, 210, 160, 0.1), transparent);
}

.mode-card.speed::before {
  background: linear-gradient(135deg, rgba(243, 156, 18, 0.1), transparent);
}

.mode-card:hover::before {
  opacity: 1;
}

.mode-card-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
}

.mode-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  flex-shrink: 0;
}

.dictation .mode-icon {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  box-shadow: 0 0 15px var(--primary-glow);
}

.fillblank .mode-icon {
  background: linear-gradient(135deg, var(--accent-blue), #0077B6);
  box-shadow: 0 0 15px var(--accent-blue-glow);
}

.dialogue .mode-icon {
  background: linear-gradient(135deg, var(--accent-green), #00A080);
  box-shadow: 0 0 15px var(--accent-green-glow);
}

.speed .mode-icon {
  background: linear-gradient(135deg, var(--accent-orange), #E67E22);
  box-shadow: 0 0 15px var(--accent-orange-glow);
}

.mode-card-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: var(--text-lg);
  font-weight: 600;
}

.mode-card-desc {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: 16px;
  line-height: 1.5;
}

.mode-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.mode-difficulty {
  display: flex;
  gap: 4px;
}

.diff-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}

.diff-dot.active {
  background: var(--primary-light);
}

.mode-play-btn {
  background: transparent;
  border: 1px solid var(--border-active);
  color: var(--primary-light);
  padding: 6px 16px;
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}

.mode-play-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* ---- Achievements Section ---- */
.achievements-section {
  margin-bottom: 40px;
}

.achievements-section h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: var(--text-2xl);
  font-weight: 700;
  margin-bottom: 20px;
}

.achievements-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.achievement-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
  transition: var(--transition-smooth);
  opacity: 0.5;
}

.achievement-card.unlocked {
  opacity: 1;
  border-color: var(--accent-green);
  box-shadow: 0 0 12px var(--accent-green-glow);
}

.achievement-icon {
  font-size: 32px;
  margin-bottom: 8px;
}

.achievement-name {
  font-weight: 600;
  font-size: var(--text-sm);
  margin-bottom: 4px;
}

.achievement-desc {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* ---- Game Screen ---- */
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.game-info {
  display: flex;
  align-items: center;
  gap: 16px;
}

.game-mode-label {
  font-family: 'Space Grotesk', sans-serif;
  font-size: var(--text-xl);
  font-weight: 700;
}

.game-progress {
  display: flex;
  align-items: center;
  gap: 10px;
}

.game-progress-bar {
  width: 200px;
  height: 6px;
  background: var(--bg-base);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.game-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent-green));
  border-radius: var(--radius-full);
  transition: width 0.5s ease;
}

.game-progress-text {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  font-weight: 500;
}

.game-score {
  display: flex;
  align-items: center;
  gap: 12px;
}

.score-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  padding: 8px 16px;
  border-radius: var(--radius-full);
  font-weight: 600;
  font-size: var(--text-sm);
  border: 1px solid var(--border-subtle);
}

.streak-badge {
  background: linear-gradient(135deg, var(--accent-orange), #E67E22);
  color: white;
  border: none;
}

.streak-badge.active {
  animation: streakPulse 1s ease-in-out;
}

@keyframes streakPulse {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.15);
  }
}

.btn-quit {
  background: transparent;
  border: 1px solid var(--accent-red);
  color: var(--accent-red);
  padding: 8px 16px;
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-quit:hover {
  background: var(--accent-red);
  color: white;
}

/* ---- Game Content Area ---- */
.game-content {
  max-width: 800px;
  margin: 0 auto;
}

/* Audio Player Widget */
.audio-player {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 32px;
  text-align: center;
  margin-bottom: 28px;
  position: relative;
  overflow: hidden;
}

.audio-player::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle at center, var(--primary-glow), transparent 70%);
  opacity: 0;
  transition: opacity 0.5s ease;
}

.audio-player.playing::before {
  opacity: 0.3;
  animation: audioPulse 2s ease-in-out infinite;
}

@keyframes audioPulse {

  0%,
  100% {
    opacity: 0.2;
  }

  50% {
    opacity: 0.4;
  }
}

.audio-wave {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 50px;
  margin-bottom: 20px;
}

.wave-bar {
  width: 4px;
  height: 10px;
  background: var(--primary-light);
  border-radius: var(--radius-full);
  transition: height 0.15s ease;
}

.audio-player.playing .wave-bar {
  animation: waveAnim 1.2s ease-in-out infinite;
}

.wave-bar:nth-child(1) {
  animation-delay: 0s;
}

.wave-bar:nth-child(2) {
  animation-delay: 0.1s;
}

.wave-bar:nth-child(3) {
  animation-delay: 0.2s;
}

.wave-bar:nth-child(4) {
  animation-delay: 0.3s;
}

.wave-bar:nth-child(5) {
  animation-delay: 0.4s;
}

.wave-bar:nth-child(6) {
  animation-delay: 0.3s;
}

.wave-bar:nth-child(7) {
  animation-delay: 0.2s;
}

.wave-bar:nth-child(8) {
  animation-delay: 0.1s;
}

.wave-bar:nth-child(9) {
  animation-delay: 0s;
}

.wave-bar:nth-child(10) {
  animation-delay: 0.1s;
}

.wave-bar:nth-child(11) {
  animation-delay: 0.2s;
}

.wave-bar:nth-child(12) {
  animation-delay: 0.3s;
}

.wave-bar:nth-child(13) {
  animation-delay: 0.4s;
}

.wave-bar:nth-child(14) {
  animation-delay: 0.3s;
}

.wave-bar:nth-child(15) {
  animation-delay: 0.2s;
}

@keyframes waveAnim {

  0%,
  100% {
    height: 10px;
  }

  50% {
    height: 40px;
  }
}

.audio-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 16px;
  position: relative;
  z-index: 1;
}

.btn-audio {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
  box-shadow: 0 4px 16px var(--primary-glow);
}

.btn-audio:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 24px var(--primary-glow);
}

.btn-audio:active {
  transform: scale(0.95);
}

.btn-audio.small {
  width: 40px;
  height: 40px;
  font-size: 16px;
  background: var(--bg-elevated);
  box-shadow: none;
}

.btn-audio.small:hover {
  background: var(--primary-dark);
}

.speed-label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  position: relative;
  z-index: 1;
}

.speed-slider {
  -webkit-appearance: none;
  width: 120px;
  height: 4px;
  background: var(--bg-base);
  border-radius: var(--radius-full);
  outline: none;
}

.speed-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  box-shadow: 0 0 8px var(--primary-glow);
}

.hint-badge {
  display: inline-block;
  background: var(--bg-elevated);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  color: var(--text-muted);
  position: relative;
  z-index: 1;
}

.plays-left {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 8px;
  position: relative;
  z-index: 1;
}

/* ---- Input Area ---- */
.input-area {
  margin-bottom: 24px;
}

.dictation-input {
  width: 100%;
  background: var(--bg-card);
  border: 2px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  font-size: var(--text-lg);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  transition: var(--transition-fast);
  outline: none;
  resize: none;
  min-height: 80px;
}

.dictation-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.dictation-input::placeholder {
  color: var(--text-muted);
}

/* ---- Options Grid ---- */
.options-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.option-btn {
  background: var(--bg-card);
  border: 2px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  text-align: left;
  font-size: var(--text-base);
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition-smooth);
  position: relative;
  overflow: hidden;
  font-family: 'Inter', sans-serif;
}

.option-btn:hover {
  border-color: var(--primary);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
}

.option-btn .option-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  font-weight: 700;
  font-size: var(--text-sm);
  color: var(--primary-light);
  margin-right: 12px;
}

.option-btn.correct {
  border-color: var(--accent-green);
  background: rgba(0, 210, 160, 0.1);
  animation: correctPop 0.5s ease;
}

.option-btn.correct .option-letter {
  background: var(--accent-green);
  color: white;
}

.option-btn.wrong {
  border-color: var(--accent-red);
  background: rgba(231, 76, 60, 0.1);
  animation: shake 0.5s ease;
}

.option-btn.wrong .option-letter {
  background: var(--accent-red);
  color: white;
}

.option-btn:disabled {
  cursor: default;
  transform: none;
  opacity: 0.7;
}

@keyframes correctPop {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.03);
  }

  100% {
    transform: scale(1);
  }
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
  }

  20% {
    transform: translateX(-8px);
  }

  40% {
    transform: translateX(8px);
  }

  60% {
    transform: translateX(-4px);
  }

  80% {
    transform: translateX(4px);
  }
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 28px;
  border-radius: var(--radius-full);
  font-size: var(--text-base);
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: var(--transition-smooth);
  border: none;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  box-shadow: 0 4px 16px var(--primary-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px var(--primary-glow);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-active);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  transform: translateY(-2px);
}

.btn-success {
  background: linear-gradient(135deg, var(--accent-green), #00A080);
  color: white;
  box-shadow: 0 4px 16px var(--accent-green-glow);
}

.btn-success:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px var(--accent-green-glow);
}

.btn-lg {
  padding: 16px 36px;
  font-size: var(--text-lg);
}

.btn-group {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 24px;
}

/* ---- Feedback Area ---- */
.feedback {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
  border-left: 4px solid var(--primary);
  animation: feedbackSlide 0.4s ease;
}

.feedback.correct {
  border-left-color: var(--accent-green);
  background: rgba(0, 210, 160, 0.08);
}

.feedback.wrong {
  border-left-color: var(--accent-red);
  background: rgba(231, 76, 60, 0.08);
}

.feedback-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: var(--text-xl);
  font-weight: 700;
  margin-bottom: 8px;
}

.feedback.correct .feedback-title {
  color: var(--accent-green);
}

.feedback.wrong .feedback-title {
  color: var(--accent-red);
}

.feedback-text {
  font-size: var(--text-base);
  color: var(--text-secondary);
  line-height: 1.7;
}

.feedback-text .correct-answer {
  color: var(--accent-green);
  font-weight: 600;
}

.feedback-xp {
  margin-top: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-elevated);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--accent-orange);
}

@keyframes feedbackSlide {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ---- Dialogue Mode ---- */
.dialogue-container {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 28px;
  margin-bottom: 24px;
}

.dialogue-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: var(--text-xl);
  font-weight: 700;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.dialogue-lines {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.dialogue-line {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  opacity: 0;
  animation: dialogueFade 0.5s ease forwards;
}

.dialogue-line:nth-child(1) {
  animation-delay: 0.1s;
}

.dialogue-line:nth-child(2) {
  animation-delay: 0.3s;
}

.dialogue-line:nth-child(3) {
  animation-delay: 0.5s;
}

.dialogue-line:nth-child(4) {
  animation-delay: 0.7s;
}

.dialogue-line:nth-child(5) {
  animation-delay: 0.9s;
}

.dialogue-line:nth-child(6) {
  animation-delay: 1.1s;
}

.dialogue-line:nth-child(7) {
  animation-delay: 1.3s;
}

@keyframes dialogueFade {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.speaker-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
  color: white;
}

.speaker-avatar.a {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
}

.speaker-avatar.b {
  background: linear-gradient(135deg, var(--accent-green), #00A080);
}

.dialogue-bubble {
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  max-width: 80%;
}

.speaker-name {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--primary-light);
  margin-bottom: 4px;
}

.dialogue-text {
  font-size: var(--text-base);
  line-height: 1.5;
}

.question-area {
  border-top: 1px solid var(--border-subtle);
  padding-top: 20px;
}

.question-text {
  font-size: var(--text-lg);
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-primary);
}

.question-counter {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-bottom: 8px;
}

/* ---- Speed Listen Mode ---- */
.passage-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: var(--text-xl);
  font-weight: 700;
  margin-bottom: 8px;
  text-align: center;
}

.passage-category {
  text-align: center;
  margin-bottom: 20px;
}

.category-tag {
  display: inline-block;
  background: var(--bg-elevated);
  padding: 4px 14px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  color: var(--primary-light);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ---- Results Screen ---- */
.results-container {
  text-align: center;
  padding: 40px 0;
}

.results-score-circle {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  margin: 0 auto 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

.results-score-circle::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  padding: 4px;
  background: conic-gradient(var(--accent-green) var(--score-percent, 0%), var(--bg-base) 0%);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  transition: all 1s ease;
}

.results-score-circle .score-number {
  font-family: 'Space Grotesk', sans-serif;
  font-size: var(--text-5xl);
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent-green), var(--accent-blue));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.results-score-circle .score-label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.results-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: var(--text-3xl);
  font-weight: 800;
  margin-bottom: 8px;
}

.results-subtitle {
  color: var(--text-secondary);
  font-size: var(--text-lg);
  margin-bottom: 32px;
}

.results-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  max-width: 500px;
  margin: 0 auto 32px;
}

.result-stat {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 20px;
}

.result-stat .label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.result-stat .value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--primary-light);
}

.new-achievements {
  margin-bottom: 32px;
}

.new-achievements h3 {
  font-size: var(--text-lg);
  margin-bottom: 12px;
  color: var(--accent-orange);
}

.new-achievement-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--accent-orange);
  border-radius: var(--radius-full);
  padding: 10px 20px;
  margin: 4px;
  font-size: var(--text-sm);
  font-weight: 600;
  animation: achievementPop 0.6s ease;
}

@keyframes achievementPop {
  0% {
    transform: scale(0);
    opacity: 0;
  }

  50% {
    transform: scale(1.2);
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ---- Fill-in-Blank Specific ---- */
.fill-sentence {
  font-size: var(--text-xl);
  line-height: 1.8;
  text-align: center;
  padding: 20px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
  border: 1px solid var(--border-subtle);
}

.blank-word {
  display: inline-block;
  min-width: 100px;
  border-bottom: 3px solid var(--primary);
  color: var(--primary-light);
  font-weight: 700;
  padding: 2px 8px;
  margin: 0 4px;
  transition: var(--transition-fast);
}

.blank-word.revealed {
  color: var(--accent-green);
  border-bottom-color: var(--accent-green);
}

/* ---- Comparison View (Dictation) ---- */
.comparison {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.comparison-box {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  border: 1px solid var(--border-subtle);
}

.comparison-box .label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.comparison-box .text {
  font-size: var(--text-base);
  line-height: 1.6;
}

.word-correct {
  color: var(--accent-green);
}

.word-wrong {
  color: var(--accent-red);
  text-decoration: line-through;
}

.word-missing {
  color: var(--accent-orange);
  font-style: italic;
}

/* ---- Floating Particles Effect ---- */
.particle {
  position: fixed;
  pointer-events: none;
  z-index: 100;
  font-size: 24px;
  animation: floatUp 1.5s ease-out forwards;
}

@keyframes floatUp {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }

  100% {
    opacity: 0;
    transform: translateY(-100px) scale(0.5);
  }
}

/* ---- XP Popup ---- */
.xp-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-card);
  border: 2px solid var(--accent-orange);
  border-radius: var(--radius-xl);
  padding: 32px 48px;
  text-align: center;
  z-index: 200;
  animation: popupBounce 0.6s ease;
  box-shadow: 0 0 40px var(--accent-orange-glow);
}

.xp-popup .emoji {
  font-size: 48px;
  margin-bottom: 12px;
}

.xp-popup .title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--accent-orange);
  margin-bottom: 8px;
}

.xp-popup .desc {
  color: var(--text-secondary);
}

@keyframes popupBounce {
  0% {
    transform: translate(-50%, -50%) scale(0);
    opacity: 0;
  }

  60% {
    transform: translate(-50%, -50%) scale(1.1);
  }

  100% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
}

/* ---- Toast Notification ---- */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-active);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  min-width: 280px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastSlide 0.4s ease;
  box-shadow: var(--shadow-lg);
}

.toast.achievement {
  border-color: var(--accent-orange);
}

.toast-icon {
  font-size: 24px;
}

.toast-content {
  flex: 1;
}

.toast-title {
  font-weight: 600;
  font-size: var(--text-sm);
}

.toast-desc {
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

@keyframes toastSlide {
  from {
    opacity: 0;
    transform: translateX(100px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ---- Settings Panel ---- */
.settings-toggle {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}

.settings-toggle:hover {
  color: var(--text-primary);
  border-color: var(--border-active);
}

.settings-panel {
  display: none;
  position: fixed;
  top: 0;
  right: 0;
  width: 360px;
  height: 100%;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-subtle);
  padding: 24px;
  z-index: 250;
  overflow-y: auto;
  animation: slideInRight 0.3s ease;
}

.settings-panel.open {
  display: block;
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
  }

  to {
    transform: translateX(0);
  }
}

.settings-panel h3 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: var(--text-xl);
  font-weight: 700;
  margin-bottom: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.settings-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
}

.settings-group {
  margin-bottom: 24px;
}

.settings-group label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.settings-group select,
.settings-group input[type="range"] {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px;
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: var(--text-sm);
}

.settings-group select {
  cursor: pointer;
}

.settings-group select option {
  background: var(--bg-card);
}

.reset-btn {
  width: 100%;
  background: var(--accent-red);
  color: white;
  border: none;
  padding: 12px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
  font-size: var(--text-sm);
  transition: var(--transition-fast);
  margin-top: 20px;
}

.reset-btn:hover {
  opacity: 0.9;
}

/* ---- Overlay ---- */
.overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-overlay);
  z-index: 240;
  animation: fadeIn 0.3s ease;
}

.overlay.open {
  display: block;
}

/* ---- Confetti container ---- */
.confetti-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 150;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  top: -20px;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  animation: confettiFall 3s ease-out forwards;
}

@keyframes confettiFall {
  0% {
    opacity: 1;
    transform: translateY(0) rotate(0deg);
  }

  100% {
    opacity: 0;
    transform: translateY(100vh) rotate(720deg);
  }
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .app-header {
    flex-direction: column;
    gap: 12px;
    text-align: center;
  }

  .header-stats {
    flex-wrap: wrap;
    justify-content: center;
  }

  .welcome-title {
    font-size: var(--text-3xl);
  }

  .progress-card {
    grid-template-columns: repeat(2, 1fr);
  }

  .mode-grid {
    grid-template-columns: 1fr;
  }

  .options-grid {
    grid-template-columns: 1fr;
  }

  .comparison {
    grid-template-columns: 1fr;
  }

  .results-stats {
    grid-template-columns: 1fr;
  }

  .game-header {
    flex-direction: column;
    gap: 12px;
  }

  .game-progress-bar {
    width: 150px;
  }

  .settings-panel {
    width: 100%;
  }
}

@media (max-width: 480px) {
  #app {
    padding: 0 12px;
  }

  .welcome-title {
    font-size: var(--text-2xl);
  }

  .audio-player {
    padding: 20px;
  }

  .btn-audio {
    width: 48px;
    height: 48px;
  }

  .dictation-input {
    font-size: var(--text-base);
    padding: 14px 16px;
  }

  .achievements-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ---- Utility classes ---- */
.hidden {
  display: none !important;
}

.text-center {
  text-align: center;
}

.mt-sm {
  margin-top: 8px;
}

.mt-md {
  margin-top: 16px;
}

.mt-lg {
  margin-top: 24px;
}

.mb-sm {
  margin-bottom: 8px;
}

.mb-md {
  margin-bottom: 16px;
}

.mb-lg {
  margin-bottom: 24px;
}

/* ---- CEFR Level Tabs ---- */
.cefr-section {
  margin-bottom: 40px;
}

.cefr-section h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: var(--text-2xl);
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text-primary);
}

.cefr-level-tabs {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
}

.cefr-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 16px 8px;
  background: var(--bg-card);
  border: 2px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: var(--transition-smooth);
  position: relative;
  overflow: hidden;
  font-family: inherit;
  color: var(--text-primary);
}

.cefr-tab::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--level-color);
  opacity: 0.4;
  transition: var(--transition-smooth);
}

.cefr-tab:hover:not(.locked) {
  transform: translateY(-3px);
  border-color: var(--level-color);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.cefr-tab:hover:not(.locked)::before {
  opacity: 1;
}

.cefr-tab.active {
  border-color: var(--level-color);
  background: var(--bg-card-hover);
  box-shadow: 0 0 20px color-mix(in srgb, var(--level-color) 30%, transparent);
}

.cefr-tab.active::before {
  opacity: 1;
  height: 4px;
}

.cefr-tab.locked {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(0.5);
}

.cefr-tab.current .cefr-tab-label {
  color: var(--level-color);
}

.cefr-tab-label {
  font-family: 'Space Grotesk', sans-serif;
  font-size: var(--text-xl);
  font-weight: 800;
  letter-spacing: 0.5px;
}

.cefr-tab-name {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  font-weight: 500;
}

.cefr-tab-lock {
  font-size: 14px;
  margin-top: 2px;
}

.cefr-tab-current {
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 10px;
  color: var(--level-color);
  animation: starPulse 2s ease-in-out infinite;
}

@keyframes starPulse {

  0%,
  100% {
    opacity: 0.7;
    transform: scale(1);
  }

  50% {
    opacity: 1;
    transform: scale(1.2);
  }
}

/* ---- CEFR Level Up Popup ---- */
.xp-popup.cefr-popup {
  background: linear-gradient(135deg, var(--bg-card), var(--bg-elevated));
  border-width: 2px;
}

.xp-popup.cefr-popup .cefr-desc {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-top: 8px;
  font-style: italic;
}

/* ---- CEFR Responsive ---- */
@media (max-width: 768px) {
  .cefr-level-tabs {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 480px) {
  .cefr-level-tabs {
    grid-template-columns: repeat(2, 1fr);
  }

  .cefr-tab {
    padding: 12px 6px;
  }

  .cefr-tab-label {
    font-size: var(--text-lg);
  }
}

/* ---- Challenge Tab ---- */
.cefr-tab.challenge-ready {
  border-color: var(--accent-orange);
  background: linear-gradient(135deg, rgba(243, 156, 18, 0.15), var(--bg-card));
  animation: challengePulse 2s ease-in-out infinite;
  cursor: pointer;
  opacity: 1;
}

.cefr-tab.challenge-ready:hover {
  transform: translateY(-4px);
  box-shadow: 0 4px 24px rgba(243, 156, 18, 0.4);
}

.cefr-tab-challenge {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--accent-orange);
  margin-top: 4px;
  letter-spacing: 0.5px;
  animation: challengeGlow 2s ease-in-out infinite;
}

@keyframes challengePulse {

  0%,
  100% {
    border-color: var(--accent-orange);
    box-shadow: 0 0 12px rgba(243, 156, 18, 0.2);
  }

  50% {
    border-color: #E67E22;
    box-shadow: 0 0 24px rgba(243, 156, 18, 0.4);
  }
}

@keyframes challengeGlow {

  0%,
  100% {
    opacity: 0.8;
  }

  50% {
    opacity: 1;
  }
}

/* ---- Challenge Results ---- */
.challenge-result-badge {
  text-align: center;
  margin-bottom: 20px;
}

.challenge-result-icon {
  font-size: 48px;
  margin-bottom: 8px;
}

.challenge-result-badge.pass .challenge-result-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: var(--text-2xl);
  font-weight: 800;
}

.challenge-result-badge.fail .challenge-result-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: var(--text-2xl);
  font-weight: 800;
  color: var(--text-secondary);
}

.challenge-encouragement {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin: 16px 0;
  text-align: center;
}

.challenge-encouragement p {
  color: var(--text-secondary);
  font-size: var(--text-sm);
  margin: 4px 0;
}

.challenge-encouragement p:first-child {
  font-size: var(--text-base);
  color: var(--text-primary);
}