/* Modern RPG Gamified English Learning CSS */
:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #121826;
  --bg-card: rgba(26, 34, 52, 0.75);
  --border-color: rgba(255, 255, 255, 0.1);
  --border-glow: rgba(99, 102, 241, 0.3);
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --accent-cyan: #06b6d4;
  --accent-indigo: #6366f1;
  --accent-purple: #8b5cf6;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --fever-glow: #ff007f;
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Pretendard", sans-serif;
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.15) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(6, 182, 212, 0.12) 0px, transparent 50%),
    radial-gradient(at 50% 50%, rgba(139, 92, 246, 0.08) 0px, transparent 70%);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Glassmorphic Container */
.glass {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

/* Header & Status Bar */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 14, 23, 0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  padding: 12px 24px;
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.logo-icon {
  font-size: 28px;
  filter: drop-shadow(0 0 10px var(--accent-indigo));
  animation: float 3s ease-in-out infinite;
}

.logo-text h1 {
  font-size: 20px;
  font-weight: 800;
  background: linear-gradient(135deg, #a5b4fc, #38bdf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
}

.logo-text p {
  font-size: 11px;
  color: var(--text-muted);
}

/* Player Status Bar */
.player-status {
  display: flex;
  align-items: center;
  gap: 16px;
  background: rgba(18, 24, 38, 0.8);
  padding: 6px 16px;
  border-radius: 9999px;
  border: 1px solid var(--border-color);
}

.stat-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
}

.level-badge {
  background: linear-gradient(135deg, var(--accent-indigo), var(--accent-purple));
  color: white;
  padding: 3px 10px;
  border-radius: 9999px;
  font-size: 12px;
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.5);
}

.xp-container {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 90px;
}

.xp-bar-bg {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
}

.xp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #06b6d4, #3b82f6);
  border-radius: 3px;
  width: 40%;
  transition: width 0.4s ease;
}

.gold-badge {
  color: #fbbf24;
}

.streak-badge {
  color: #f97316;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-icon {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: var(--accent-cyan);
}

/* Category Filter Bar */
.category-nav {
  max-width: 1200px;
  margin: 16px auto 0;
  padding: 0 16px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.category-nav::-webkit-scrollbar {
  display: none;
}

.cat-btn {
  background: rgba(18, 24, 38, 0.6);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 8px 16px;
  border-radius: 9999px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.cat-btn.active, .cat-btn:hover {
  background: rgba(99, 102, 241, 0.2);
  border-color: var(--accent-indigo);
  color: #ffffff;
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.3);
}

/* Main Content Wrapper */
main {
  max-width: 1200px;
  margin: 20px auto 40px;
  padding: 0 16px;
  flex: 1;
  width: 100%;
}

/* Mode Tabs */
.mode-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.mode-tab-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 12px;
  color: var(--text-main);
  text-align: center;
  cursor: pointer;
  transition: all 0.25s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.mode-tab-btn .tab-icon {
  font-size: 24px;
}

.mode-tab-btn .tab-title {
  font-size: 14px;
  font-weight: 700;
}

.mode-tab-btn .tab-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.mode-tab-btn:hover {
  transform: translateY(-2px);
  border-color: var(--accent-cyan);
}

.mode-tab-btn.active {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.25), rgba(6, 182, 212, 0.2));
  border-color: var(--accent-cyan);
  box-shadow: 0 0 20px rgba(6, 182, 212, 0.3);
}

/* Game Card Area */
.game-viewport {
  position: relative;
  min-height: 480px;
  padding: 24px;
  display: flex;
  flex-direction: column;
}

/* Fever Bar & Combo Display */
.combat-hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.combo-badge {
  font-size: 18px;
  font-weight: 800;
  color: #38bdf8;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(6, 182, 212, 0.15);
  padding: 6px 14px;
  border-radius: 9999px;
  border: 1px solid rgba(6, 182, 212, 0.4);
  transition: transform 0.2s ease;
}

.combo-badge.pulse {
  animation: pulseScale 0.3s ease;
}

.fever-meter-wrap {
  flex: 1;
  max-width: 280px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.fever-bar-bg {
  flex: 1;
  height: 10px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 5px;
  overflow: hidden;
}

.fever-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ec4899, #f43f5e, #fbbf24);
  border-radius: 5px;
  transition: width 0.3s ease;
}

.fever-active {
  animation: feverGlow 1.2s infinite alternate;
}

/* Mode 1: Word Speed Quiz */
.quiz-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 30px 16px;
  margin: auto 0;
}

.word-display {
  margin-bottom: 12px;
  position: relative;
}

.word-target {
  font-size: 42px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: #ffffff;
  text-shadow: 0 0 20px rgba(99, 102, 241, 0.4);
}

.word-speaker-btn {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  margin-left: 10px;
  vertical-align: middle;
  transition: transform 0.15s ease;
}

.word-speaker-btn:hover {
  transform: scale(1.2);
}

.word-hint {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.quiz-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  width: 100%;
  max-width: 600px;
}

.option-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 16px 20px;
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 12px;
}

.option-btn .num-tag {
  background: rgba(255, 255, 255, 0.1);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

.option-btn:hover {
  background: rgba(99, 102, 241, 0.2);
  border-color: var(--accent-indigo);
  transform: translateY(-2px);
}

.option-btn.correct {
  background: rgba(16, 185, 129, 0.3) !important;
  border-color: var(--accent-emerald) !important;
  color: #a7f3d0 !important;
}

.option-btn.wrong {
  background: rgba(239, 68, 68, 0.3) !important;
  border-color: var(--accent-rose) !important;
  color: #fca5a5 !important;
  animation: shake 0.4s ease;
}

/* Mode 2: Dungeon RPG Battle */
.dungeon-arena {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.battle-stage {
  display: flex;
  justify-content: space-around;
  align-items: center;
  background: rgba(0, 0, 0, 0.3);
  border-radius: var(--radius-md);
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.combatant {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
}

.combatant-avatar {
  font-size: 64px;
  filter: drop-shadow(0 0 15px rgba(255, 255, 255, 0.2));
  transition: transform 0.2s ease;
}

.combatant-avatar.attack {
  animation: attackAnim 0.35s ease;
}

.combatant-avatar.hit {
  animation: hitAnim 0.35s ease;
}

.combatant-name {
  font-size: 15px;
  font-weight: 700;
}

.hp-bar-wrap {
  width: 130px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hp-bar-bg {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
}

.hp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #ef4444, #10b981);
  transition: width 0.3s ease;
}

.hp-text {
  font-size: 11px;
  color: var(--text-muted);
}

/* Sentence Builder Construction Area */
.sentence-builder-zone {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
}

.target-kr-text {
  font-size: 19px;
  font-weight: 700;
  color: #e2e8f0;
  text-align: center;
}

.sentence-hint-box {
  font-size: 13px;
  color: #38bdf8;
  background: rgba(6, 182, 212, 0.1);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(6, 182, 212, 0.3);
}

.drop-zone {
  min-height: 60px;
  width: 100%;
  max-width: 750px;
  background: rgba(15, 23, 42, 0.7);
  border: 2px dashed rgba(99, 102, 241, 0.4);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-start;
}

.word-bank {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  max-width: 750px;
}

.token-chip {
  background: rgba(99, 102, 241, 0.25);
  border: 1px solid var(--accent-indigo);
  color: #ffffff;
  padding: 8px 16px;
  border-radius: 9999px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.token-chip:hover {
  background: rgba(99, 102, 241, 0.45);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.token-chip.placed {
  background: rgba(16, 185, 129, 0.25);
  border-color: var(--accent-emerald);
}

.token-chip.placed:hover {
  background: rgba(239, 68, 68, 0.3);
  border-color: var(--accent-rose);
}

.battle-action-bar {
  display: flex;
  gap: 12px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-indigo), var(--accent-cyan));
  color: #ffffff;
  border: none;
  padding: 12px 28px;
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(6, 182, 212, 0.5);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* Mode 3: Listening Hunter */
.listening-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 30px 10px;
}

.listen-play-btn {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: linear-gradient(135deg, #06b6d4, #3b82f6);
  border: none;
  font-size: 42px;
  color: white;
  cursor: pointer;
  box-shadow: 0 0 30px rgba(6, 182, 212, 0.4);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.listen-play-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 0 40px rgba(6, 182, 212, 0.6);
}

.speed-control-group {
  display: flex;
  gap: 8px;
}

.speed-chip {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 4px 12px;
  border-radius: 9999px;
  font-size: 12px;
  cursor: pointer;
}

.speed-chip.active {
  background: rgba(6, 182, 212, 0.3);
  border-color: var(--accent-cyan);
  color: #ffffff;
}

/* Mode 4: Speaking Master */
.speaking-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  padding: 30px 16px;
  text-align: center;
}

.target-speak-box {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 24px 30px;
  max-width: 680px;
  width: 100%;
}

.target-speak-en {
  font-size: 24px;
  font-weight: 800;
  color: #ffffff;
  margin-bottom: 8px;
}

.target-speak-kr {
  font-size: 15px;
  color: var(--text-muted);
}

.mic-button {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-rose), #fb7185);
  border: none;
  font-size: 38px;
  color: white;
  cursor: pointer;
  box-shadow: 0 0 25px rgba(244, 63, 94, 0.4);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mic-button:hover {
  transform: scale(1.06);
  box-shadow: 0 0 35px rgba(244, 63, 94, 0.6);
}

.mic-button.recording {
  background: #ef4444;
  animation: pulseScale 1s infinite alternate;
  box-shadow: 0 0 45px rgba(239, 68, 68, 0.8);
}

.accuracy-meter {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.accuracy-score {
  font-size: 36px;
  font-weight: 800;
  color: var(--accent-emerald);
}

/* Mode 5: Card Flip Match */
.card-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  max-width: 700px;
  margin: 0 auto;
  perspective: 1000px;
}

.flip-card {
  height: 100px;
  border-radius: var(--radius-md);
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  font-size: 15px;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.flip-card:hover {
  border-color: var(--accent-cyan);
  transform: translateY(-2px);
}

.flip-card.selected {
  background: rgba(99, 102, 241, 0.35);
  border-color: var(--accent-indigo);
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.5);
}

.flip-card.matched {
  background: rgba(16, 185, 129, 0.2);
  border-color: var(--accent-emerald);
  color: #a7f3d0;
  pointer-events: none;
  opacity: 0.5;
}

/* Shop & Review Notebook View */
.list-view-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.shop-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  transition: all 0.2s ease;
}

.shop-card:hover {
  border-color: var(--accent-amber);
  transform: translateY(-2px);
}

.shop-card-top {
  display: flex;
  gap: 12px;
  align-items: center;
}

.shop-item-icon {
  font-size: 32px;
  background: rgba(255, 255, 255, 0.06);
  padding: 10px;
  border-radius: var(--radius-md);
}

.shop-item-info h4 {
  font-size: 16px;
  font-weight: 700;
}

.shop-item-info p {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.shop-item-buy {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.item-price {
  font-weight: 700;
  color: #fbbf24;
}

/* Floating Feedback & Animations */
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@keyframes pulseScale {
  0% { transform: scale(1); }
  50% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

@keyframes attackAnim {
  0% { transform: translateX(0); }
  50% { transform: translateX(40px) scale(1.15); }
  100% { transform: translateX(0); }
}

@keyframes hitAnim {
  0% { transform: translateX(0) scale(1); filter: brightness(1); }
  25% { transform: translateX(-15px) scale(0.95); filter: brightness(2) drop-shadow(0 0 10px red); }
  50% { transform: translateX(10px); }
  100% { transform: translateX(0); filter: brightness(1); }
}

@keyframes feverGlow {
  0% { box-shadow: 0 0 15px rgba(255, 0, 127, 0.4); }
  100% { box-shadow: 0 0 30px rgba(255, 0, 127, 0.8), 0 0 50px rgba(251, 191, 36, 0.5); }
}

/* Responsive Styles */
@media (max-width: 768px) {
  header {
    padding: 10px 14px;
  }
  .header-container {
    justify-content: center;
  }
  .player-status {
    width: 100%;
    justify-content: space-around;
  }
  .quiz-options {
    grid-template-columns: 1fr;
  }
  .card-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .mode-tabs {
    grid-template-columns: repeat(3, 1fr);
  }
  .word-target {
    font-size: 32px;
  }
}
