:root {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: #1e293b;
  --bg-card-hover: #334155;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent-gold: #f59e0b;
  --accent-red: #ef4444;
  --accent-blue: #3b82f6;
  --accent-green: #10b981;
  --accent-purple: #8b5cf6;
  --der-color: #38bdf8;
  --die-color: #f43f5e;
  --das-color: #34d399;
  --border-color: #334155;
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
  --font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-family);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header & Stat Bar */
header {
  background-color: var(--bg-secondary);
  border-bottom: 2px solid var(--border-color);
  padding: 12px 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  font-size: 28px;
}

.brand-name {
  font-size: 22px;
  font-weight: 800;
  background: linear-gradient(135deg, #f59e0b 0%, #ef4444 50%, #3b82f6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
}

.stats-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  padding: 6px 14px;
  border-radius: 9999px;
  font-size: 14px;
  font-weight: 700;
}

.stat-pill.hearts {
  color: #f87171;
  cursor: pointer;
  transition: transform 0.15s, background-color 0.15s;
}
.stat-pill.hearts:hover {
  background-color: rgba(239, 68, 68, 0.2);
  transform: scale(1.05);
}

.stat-pill.coins {
  color: #fbbf24;
}

.stat-pill.streak {
  color: #fb923c;
}

.stat-pill.level {
  color: #a78bfa;
}

.xp-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 140px;
}

.xp-text {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
}

.xp-bar-outer {
  width: 100%;
  height: 8px;
  background-color: #334155;
  border-radius: 999px;
  overflow: hidden;
}

.xp-bar-inner {
  height: 100%;
  background: linear-gradient(90deg, #8b5cf6, #ec4899);
  width: 0%;
  transition: width 0.4s ease-out;
}

.sound-toggle-btn {
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: 9999px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.sound-toggle-btn:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

/* Nav Tabs */
nav.game-nav {
  background-color: #162032;
  border-bottom: 1px solid var(--border-color);
  padding: 8px 16px;
}

.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav-container::-webkit-scrollbar {
  display: none;
}

.nav-tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
  white-space: nowrap;
}

.nav-tab-btn:hover {
  color: var(--text-main);
  background-color: rgba(255, 255, 255, 0.05);
}

.nav-tab-btn.active {
  color: #fff;
  background-color: #2563eb;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

/* Main Content */
main {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 16px;
  flex: 1;
}

.tab-panel {
  display: none;
}
.tab-panel.active {
  display: block;
  animation: fadeIn 0.25s ease-out;
}

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

/* Hero & Section Headers */
.section-header {
  margin-bottom: 24px;
}

.section-title {
  font-size: 24px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-desc {
  color: var(--text-muted);
  margin-top: 6px;
  font-size: 15px;
}

/* Quests Grid */
.quests-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.quest-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.quest-card:hover {
  transform: translateY(-4px);
  border-color: #3b82f6;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.quest-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
}

.quest-icon {
  font-size: 36px;
  background-color: rgba(255, 255, 255, 0.05);
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
}

.cefr-tag {
  background-color: #2563eb;
  color: white;
  font-size: 12px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
}

.quest-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 4px;
}

.quest-title-en {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.quest-summary {
  font-size: 14px;
  color: #cbd5e1;
  line-height: 1.5;
  margin-bottom: 16px;
}

.quest-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border-color);
  padding-top: 14px;
}

.quest-rewards {
  display: flex;
  gap: 12px;
  font-size: 13px;
  font-weight: 700;
}

.start-quest-btn {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-weight: 700;
  cursor: pointer;
  transition: filter 0.15s;
}
.start-quest-btn:hover {
  filter: brightness(1.15);
}

/* Quest Active Play Screen */
.quest-player-overlay {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 30px;
  max-width: 800px;
  margin: 0 auto;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}

.quest-step-progress {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  color: var(--text-muted);
  font-size: 14px;
}

.speaker-bubble {
  background-color: #0f172a;
  border: 1px solid #334155;
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
  position: relative;
}

.speaker-name {
  font-size: 14px;
  font-weight: 800;
  color: var(--accent-gold);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.german-dialogue-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.german-dialogue-text {
  font-size: 20px;
  font-weight: 600;
  color: #fff;
  line-height: 1.4;
}

.tts-speaker-btn {
  background-color: #334155;
  border: none;
  color: #fff;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  transition: background-color 0.15s, transform 0.15s;
}
.tts-speaker-btn:hover {
  background-color: #2563eb;
  transform: scale(1.1);
}

.translation-text {
  color: var(--text-muted);
  font-size: 15px;
  font-style: italic;
  margin-top: 8px;
}

.grammar-tip-box {
  margin-top: 14px;
  background-color: rgba(59, 130, 246, 0.1);
  border-left: 4px solid var(--accent-blue);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: #93c5fd;
}

.options-title {
  font-size: 14px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 12px;
}

.quest-options-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.quest-option-card {
  background-color: #1e293b;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
}
.quest-option-card:hover {
  border-color: #60a5fa;
  background-color: #334155;
}
.quest-option-card.correct {
  border-color: var(--accent-green) !important;
  background-color: rgba(16, 185, 129, 0.15) !important;
}
.quest-option-card.wrong {
  border-color: var(--accent-red) !important;
  background-color: rgba(239, 68, 68, 0.15) !important;
}

.option-de {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
}
.option-en {
  font-size: 13px;
  color: var(--text-muted);
}

.feedback-banner {
  margin-top: 20px;
  padding: 16px;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  display: none;
}
.feedback-banner.success {
  display: block;
  background-color: rgba(16, 185, 129, 0.2);
  border: 1px solid var(--accent-green);
  color: #6ee7b7;
}
.feedback-banner.error {
  display: block;
  background-color: rgba(239, 68, 68, 0.2);
  border: 1px solid var(--accent-red);
  color: #fca5a5;
}

/* Speed Arena (Der / Die / Das Blitz) */
.arena-container {
  max-width: 650px;
  margin: 0 auto;
  text-align: center;
}

.arena-card {
  background-color: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 40px 24px;
  margin-bottom: 24px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  position: relative;
}

.arena-target-word {
  font-size: 44px;
  font-weight: 900;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
}

.arena-meaning {
  font-size: 18px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.article-buttons-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.article-btn {
  padding: 18px 12px;
  font-size: 22px;
  font-weight: 900;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  color: white;
  transition: transform 0.1s, filter 0.15s;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.article-btn:hover {
  filter: brightness(1.15);
  transform: translateY(-2px);
}
.article-btn:active {
  transform: translateY(1px);
}

.article-btn .shortcut-hint {
  font-size: 11px;
  opacity: 0.8;
  font-weight: 600;
}

.article-btn.der {
  background-color: #0284c7;
}
.article-btn.die {
  background-color: #e11d48;
}
.article-btn.das {
  background-color: #059669;
}

.arena-stats-row {
  display: flex;
  justify-content: space-around;
  background-color: rgba(0, 0, 0, 0.3);
  padding: 12px;
  border-radius: var(--radius-md);
  margin-top: 16px;
}

.arena-rule-box {
  background-color: rgba(59, 130, 246, 0.15);
  border: 1px solid var(--accent-blue);
  border-radius: var(--radius-md);
  padding: 14px;
  font-size: 14px;
  color: #bfdbfe;
  margin-top: 16px;
  display: none;
}

/* Satzbau (Sentence Builder) */
.satzbau-container {
  max-width: 750px;
  margin: 0 auto;
}

.satzbau-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 24px;
}

.sentence-target-area {
  min-height: 80px;
  background-color: #0f172a;
  border: 2px dashed #475569;
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 20px;
}

.tile-pool-area {
  min-height: 80px;
  padding: 12px;
  background-color: rgba(255, 255, 255, 0.02);
  border-radius: var(--radius-md);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 20px;
}

.word-tile {
  background: #334155;
  color: white;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}
.word-tile:hover {
  background: #475569;
  transform: translateY(-2px);
}

.word-tile.in-target {
  background: #2563eb;
}

/* Case Crusher */
.case-crusher-card {
  max-width: 750px;
  margin: 0 auto;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 30px;
}

.case-rule-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  margin-bottom: 12px;
}
.case-rule-badge.dativ {
  background-color: #7c3aed;
  color: #ede9fe;
}
.case-rule-badge.akkusativ {
  background-color: #db2777;
  color: #fdf2f8;
}

.case-sentence-display {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 12px;
}

.case-sentence-display span.blank {
  color: var(--accent-gold);
  border-bottom: 3px solid var(--accent-gold);
  padding: 0 8px;
}

.case-options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin: 20px 0;
}

.case-btn {
  background-color: #0f172a;
  border: 2px solid #334155;
  color: white;
  padding: 16px;
  border-radius: var(--radius-md);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}
.case-btn:hover {
  border-color: #3b82f6;
  background-color: #1e293b;
}

/* SRS Flashcards */
.srs-container {
  max-width: 650px;
  margin: 0 auto;
}

.srs-flip-card {
  background-color: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  min-height: 280px;
  padding: 36px 24px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  cursor: pointer;
  margin-bottom: 24px;
  position: relative;
  transition: border-color 0.2s, transform 0.2s;
}
.srs-flip-card:hover {
  border-color: #3b82f6;
}

.srs-front-text {
  font-size: 34px;
  font-weight: 800;
  margin-bottom: 12px;
}

.srs-back-text {
  font-size: 22px;
  color: var(--accent-gold);
  margin-top: 16px;
  border-top: 1px solid var(--border-color);
  padding-top: 16px;
  width: 100%;
}

.srs-example-de {
  font-size: 15px;
  color: #cbd5e1;
  margin-top: 8px;
}

.srs-example-en {
  font-size: 13px;
  color: var(--text-muted);
}

.srs-rating-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.srs-rate-btn {
  padding: 12px;
  border: none;
  border-radius: var(--radius-md);
  color: white;
  font-weight: 800;
  cursor: pointer;
  font-size: 14px;
  transition: filter 0.15s;
}
.srs-rate-btn:hover {
  filter: brightness(1.2);
}
.srs-rate-btn.again { background-color: #ef4444; }
.srs-rate-btn.hard { background-color: #f97316; }
.srs-rate-btn.good { background-color: #3b82f6; }
.srs-rate-btn.easy { background-color: #10b981; }

/* Stats & Dashboard */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.stat-box {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-align: center;
}

.stat-box-val {
  font-size: 36px;
  font-weight: 900;
  color: var(--accent-gold);
  margin-bottom: 6px;
}

.stat-box-label {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 600;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(0, 0, 0, 0.75);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
}
.modal-backdrop.active {
  display: flex;
}

.modal-window {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 450px;
  width: 100%;
  padding: 28px;
  text-align: center;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
}

.modal-title {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 12px;
}

.modal-desc {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.btn-primary {
  background-color: #2563eb;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-weight: 700;
  cursor: pointer;
}

.btn-secondary {
  background-color: #334155;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-weight: 700;
  cursor: pointer;
}

/* Responsive tweaks */
@media (max-width: 640px) {
  header { padding: 10px 16px; }
  .brand-name { font-size: 18px; }
  .arena-target-word { font-size: 32px; }
  .article-btn { padding: 14px 8px; font-size: 18px; }
  .srs-rating-buttons { grid-template-columns: repeat(2, 1fr); }
}
