/* ==========================================================================
   DeutschLernen - Modern Vocabulary Trainer & Quiz Arena Styles
   Design: Premium Glassmorphism, Dual Theme (Dark/Light), WCAG AA Accessible
   ========================================================================== */

:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-card: #1a2235;
  --bg-card-hover: #222d46;
  --bg-card-glass: rgba(26, 34, 53, 0.75);
  --border: #2a3550;
  --border-light: #3b486b;
  --text-primary: #f0f4fc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent-gold: #f59e0b;
  --accent-gold-glow: rgba(245, 158, 11, 0.25);
  --accent-red: #ef4444;
  --accent-green: #10b981;
  --accent-green-glow: rgba(16, 185, 129, 0.25);
  --accent-blue: #3b82f6;
  --accent-purple: #8b5cf6;

  --streak-fire: #ff5722;
  --font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 20px var(--accent-gold-glow);
}

body.light-mode, [data-theme="light"], html.light-mode {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-card-glass: rgba(255, 255, 255, 0.85);
  --border: #e2e8f0;
  --border-light: #cbd5e1;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
}

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

html {
  overflow-anchor: none;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  overflow-anchor: none;
  transition: background-color var(--transition), color var(--transition);
}

/* WCAG AA Focus Styles */
:focus-visible {
  outline: 2px solid var(--accent-gold);
  outline-offset: 3px;
}

/* Universal Visibility Utility */
.hidden {
  display: none !important;
}

/* Completion & Empty State Celebration Cards */
.completion-card, .empty-state-card {
  grid-column: 1 / -1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 24px;
  text-align: center;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  animation: fadeInScale 0.35s ease-out;
}

.completion-emoji, .empty-state-emoji {
  font-size: 48px;
  line-height: 1;
}

.completion-card h2 {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-primary);
}

.accuracy-score {
  font-size: 16px;
  color: var(--text-secondary);
}

.accuracy-score strong {
  color: var(--accent-green);
  font-size: 18px;
}

.completion-btn {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #000;
  font-weight: 800;
  font-size: 15px;
  padding: 12px 28px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 4px 16px rgba(245, 158, 11, 0.3);
}

.completion-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 22px rgba(245, 158, 11, 0.45);
}

@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* App Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-card-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
}

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

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid transparent;
  transition: var(--transition);
}

.back-link:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border);
  transform: none;
}

body.light-mode .back-link:hover,
[data-theme="light"] .back-link:hover,
html.light-mode .back-link:hover {
  background: rgba(15, 23, 42, 0.04);
}

.brand-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.stat-pill.streak {
  border-color: rgba(255, 87, 34, 0.4);
  color: var(--streak-fire);
}

.stat-pill.review-queue {
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.stat-pill.review-queue:hover {
  transform: translateY(-1px);
  border-color: var(--accent-red);
}

.stat-pill.review-queue:focus-visible,
.stat-pill.sync-status:focus-visible {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
}

.stat-pill.review-queue.has-mistakes {
  border-color: rgba(239, 68, 68, 0.5);
  background: rgba(239, 68, 68, 0.12);
  color: var(--accent-red);
  animation: pulse-glow 2s infinite ease-in-out;
}

.stat-pill.sync-status {
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.stat-pill.sync-status:hover {
  transform: translateY(-1px);
  border-color: var(--accent-blue);
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 0 rgba(239, 68, 68, 0); }
  50% { box-shadow: 0 0 12px rgba(239, 68, 68, 0.35); }
}

.stat-pill.timer-pill {
  border-color: rgba(245, 158, 11, 0.4);
  background: rgba(245, 158, 11, 0.1);
  color: var(--accent-gold);
}

.stat-pill.timer-pill.urgent {
  border-color: rgba(239, 68, 68, 0.7);
  background: rgba(239, 68, 68, 0.2);
  color: var(--accent-red);
  animation: pulse-glow 1s infinite ease-in-out;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-icon {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border);
  color: var(--text-primary);
}

body.light-mode .btn-icon:hover,
[data-theme="light"] .btn-icon:hover,
html.light-mode .btn-icon:hover {
  background: rgba(15, 23, 42, 0.04);
}

/* Main Container */
.main-wrapper {
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding: 12px 20px 32px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-anchor: none;
}

/* Dashboard Controls Bar */
.controls-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow-card);
}

.controls-row-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.selectors-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.select-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}

.styled-select {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  transition: var(--transition);
}

.styled-select:hover,
.styled-select:focus {
  border-color: var(--accent-gold);
}

/* Mode Switcher Chips */
.modes-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}

.mode-chip {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 7px 13px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.mode-chip:hover {
  color: var(--text-primary);
  border-color: var(--border-light);
  background: var(--bg-card-hover);
}

.mode-chip.active,
.mode-chip.mistakes-mode.active,
.mode-chip.sprint-mode.active,
.mode-chip.artikel-mode.active {
  background: var(--text-primary);
  border-color: var(--text-primary);
  color: var(--bg-primary);
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

@media (max-width: 1200px) {
  .header-controls .header-secondary-link {
    display: none !important;
  }
}

.sprint-metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 20px 0;
}

.metric-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.metric-val {
  font-size: 24px;
  font-weight: 800;
  color: var(--accent-gold);
}

.metric-lbl {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Quiz Arena */
.quiz-arena {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Progress Section */
.arena-progress-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--text-secondary);
}

.progress-track {
  width: 100%;
  height: 8px;
  background: var(--bg-secondary);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #f59e0b, #10b981);
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

/* Flash Word Card */
.prompt-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  text-align: center;
  position: relative;
  box-shadow: var(--shadow-card);
  transition: transform var(--transition), border-color var(--transition);
}

.prompt-card:hover {
  border-color: var(--border-light);
}

.prompt-meta {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.badge-level {
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-gold);
  border: 1px solid rgba(245, 158, 11, 0.3);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
}

.badge-level.badge-a1,
.badge-a1 {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border-color: rgba(16, 185, 129, 0.3);
}

.badge-level.badge-a2,
.badge-a2 {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
  border-color: rgba(59, 130, 246, 0.3);
}

.badge-level.badge-b1,
.badge-b1 {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border-color: rgba(245, 158, 11, 0.3);
}

.badge-level.badge-b2,
.badge-b2 {
  background: rgba(139, 92, 246, 0.15);
  color: #8b5cf6;
  border-color: rgba(139, 92, 246, 0.3);
}

.badge-level.badge-c1,
.badge-c1 {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.3);
}

.badge-level.badge-c2,
.badge-c2 {
  background: rgba(236, 72, 153, 0.15);
  color: #ec4899;
  border-color: rgba(236, 72, 153, 0.3);
}

.shortcut-hints {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  cursor: help;
  user-select: none;
  transition: var(--transition);
}

.shortcut-hints:hover {
  color: var(--text-primary);
  border-color: var(--accent-gold);
}

.badge-pos {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  font-size: 11px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
}

/* German Noun Gender Color Indicators (Standard Pedagogy: der=Blue, die=Pink/Red, das=Green) */
.badge-gender {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.badge-gender.der, .gender-der {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8 !important;
  border: 1px solid rgba(56, 189, 248, 0.4);
}
.badge-gender.die, .gender-die {
  background: rgba(244, 114, 182, 0.15);
  color: #f472b6 !important;
  border: 1px solid rgba(244, 114, 182, 0.4);
}
.badge-gender.das, .gender-das {
  background: rgba(74, 222, 128, 0.15);
  color: #4ade80 !important;
  border: 1px solid rgba(74, 222, 128, 0.4);
}

.prompt-word-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 4px 0;
}

.prompt-word {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.audio-btn-play {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
}

.audio-btn-play:hover {
  background: var(--accent-gold);
  color: #000;
  transform: scale(1.08);
  border-color: var(--accent-gold);
}

.prompt-subhint {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* Choice Buttons Grid */
.options-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.options-grid.artikel-grid {
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

@media (max-width: 640px) {
  .options-grid,
  .options-grid.artikel-grid {
    grid-template-columns: 1fr;
  }
}

.quiz-option-btn {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  text-align: left;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.quiz-option-btn:hover:not(.disabled) {
  background: var(--bg-card-hover);
  border-color: var(--accent-gold);
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

.quiz-option-btn.btn-gender-der .opt-key {
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.4);
}
.quiz-option-btn.btn-gender-der:hover:not(.disabled) {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.08);
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.25);
}

.quiz-option-btn.btn-gender-die .opt-key {
  color: #f472b6;
  border-color: rgba(244, 114, 182, 0.4);
}
.quiz-option-btn.btn-gender-die:hover:not(.disabled) {
  border-color: #f472b6;
  background: rgba(244, 114, 182, 0.08);
  box-shadow: 0 0 14px rgba(244, 114, 182, 0.25);
}

.quiz-option-btn.btn-gender-das .opt-key {
  color: #4ade80;
  border-color: rgba(74, 222, 128, 0.4);
}
.quiz-option-btn.btn-gender-das:hover:not(.disabled) {
  border-color: #4ade80;
  background: rgba(74, 222, 128, 0.08);
  box-shadow: 0 0 14px rgba(74, 222, 128, 0.25);
}

.opt-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.opt-text {
  flex: 1;
  line-height: 1.4;
}

/* Answer State Styles */
.quiz-option-btn.correct {
  background: rgba(16, 185, 129, 0.15) !important;
  border-color: var(--accent-green) !important;
  color: #10b981 !important;
  box-shadow: 0 0 16px var(--accent-green-glow);
}

.quiz-option-btn.correct .opt-key {
  background: var(--accent-green);
  color: #ffffff;
  border-color: var(--accent-green);
}

.quiz-option-btn.wrong {
  background: rgba(239, 68, 68, 0.15) !important;
  border-color: var(--accent-red) !important;
  color: #ef4444 !important;
  animation: shake 0.35s ease-in-out;
}

.quiz-option-btn.wrong .opt-key {
  background: var(--accent-red);
  color: #ffffff;
  border-color: var(--accent-red);
}

.quiz-option-btn.disabled {
  cursor: default;
  opacity: 0.7;
}

/* Don't Know / Skip Action Button */
.dontknow-container {
  display: flex;
  justify-content: center;
  margin-top: 4px;
}

.dontknow-container.hidden {
  display: none !important;
}

.btn-dont-know {
  background: rgba(255, 255, 255, 0.03);
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  padding: 10px 20px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition);
  width: 100%;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

.btn-dont-know:hover:not(:disabled) {
  border-color: var(--accent-gold);
  color: var(--accent-gold);
  background: rgba(245, 158, 11, 0.08);
}

.btn-dont-know.active-revealed {
  border-color: var(--accent-gold);
  color: var(--accent-gold);
  background: rgba(245, 158, 11, 0.12);
}

.btn-dont-know:disabled {
  cursor: default;
  opacity: 0.6;
}

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

/* Explanation Card */
.explanation-card {
  background: var(--bg-card);
  border-left: 4px solid var(--accent-gold);
  border-top: 1px solid var(--border);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: fadeIn 0.3s ease-in-out;
}

.explanation-card.hidden {
  display: none;
}

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

.explain-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent-gold);
  display: flex;
  align-items: center;
  gap: 6px;
}

.explain-sentence-de {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.explain-sentence-trans {
  font-size: 13px;
  color: var(--text-secondary);
  font-style: italic;
}

.explain-syn-ant {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
}

.explain-syn-ant span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.explain-syn-ant strong {
  color: var(--text-secondary);
}

/* Next / Continue Action Bar */
.action-bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

.btn-primary-action {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #000000;
  border: none;
  border-radius: var(--radius-md);
  padding: 14px 28px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
  transition: var(--transition);
}

.btn-primary-action:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.4);
}

.btn-primary-action:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

/* Aktif hale gelince pulse ile dikkat çek (focus() olmadan) */
.btn-primary-action:not(:disabled) {
  animation: btn-pulse-ready 1.8s ease-in-out 0.2s 2;
}

@keyframes btn-pulse-ready {
  0%, 100% { box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3); }
  50%       { box-shadow: 0 4px 28px rgba(245, 158, 11, 0.75); transform: scale(1.02); }
}

/* Dictionary Search Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease-out;
}

.modal-backdrop.hidden {
  display: none;
}

.modal-dialog {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  max-width: 720px;
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

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

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
}

.modal-close-btn:hover {
  color: var(--text-primary);
}

.modal-search-bar {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}

.search-input-field {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
}

.search-input-field:focus {
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 3px var(--accent-gold-glow);
}

.modal-scroll-area {
  padding: 16px 24px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.search-result-row {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: var(--transition);
}

.search-result-row:hover {
  border-color: var(--border-light);
  background: var(--bg-card-hover);
}

.row-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.row-header strong {
  font-size: 16px;
  color: var(--text-primary);
}

.mini-audio-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 14px;
  margin-left: auto;
  padding: 2px 6px;
  border-radius: 4px;
}

.mini-audio-btn:hover {
  background: var(--bg-card);
}

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

.row-example {
  font-size: 12px;
  color: var(--text-muted);
}

/* Commercial & Legal Footer */
.app-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-card);
  padding: 40px 20px 30px;
  margin-top: auto;
  color: var(--text-secondary);
  font-size: 13px;
}

.footer-content {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  text-align: center;
}

.footer-links {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.footer-links a,
.footer-links button {
  color: var(--text-secondary);
  text-decoration: none;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  transition: var(--transition);
}

.footer-links a:hover,
.footer-links button:hover {
  color: var(--accent-gold);
  text-decoration: underline;
}

.footer-disclaimer-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-muted);
}

.footer-disclaimer-box p + p {
  margin-top: 8px;
}

.footer-copy {
  font-size: 12px;
  color: var(--text-muted);
}

/* ==========================================================================
   User Account, Cloud Sync & Community Feedback Modals
   ========================================================================== */

/* Sync Status Badge in Header */
.stat-pill.sync-status {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  transition: var(--transition);
}

.stat-pill.sync-status:hover {
  border-color: var(--accent-gold);
}

.btn-auth-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-auth-trigger:hover {
  border-color: var(--accent-gold);
  color: var(--accent-gold);
}

/* Auth Tabs & Form */
.auth-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.auth-tab-btn {
  flex: 1;
  padding: 12px 16px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition);
}

.auth-tab-btn.active {
  color: var(--accent-gold);
  border-bottom-color: var(--accent-gold);
}

.auth-form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
  text-align: left;
}

.auth-form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.auth-input-field,
.feedback-select-field,
.feedback-textarea {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
}

.auth-input-field:focus,
.feedback-select-field:focus,
.feedback-textarea:focus {
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 3px var(--accent-gold-glow);
}

.auth-notice-msg {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  margin-bottom: 16px;
  display: none;
}

.auth-notice-msg.error {
  display: block;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid var(--accent-red);
  color: var(--accent-red);
}

.auth-notice-msg.success {
  display: block;
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid var(--accent-green);
  color: var(--accent-green);
}

.auth-notice-msg.info {
  display: block;
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid var(--accent-blue, #3b82f6);
  color: #60a5fa;
}

.btn-auth-submit,
.btn-feedback-submit {
  width: 100%;
  padding: 12px;
  border-radius: var(--radius-md);
  background: var(--accent-gold);
  color: #000000;
  font-weight: 700;
  font-size: 14px;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  margin-top: 8px;
}

.btn-auth-submit:hover,
.btn-feedback-submit:hover {
  background: var(--de-gold);
  transform: translateY(-1px);
}

.auth-divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 18px 0;
  color: var(--text-muted);
  font-size: 12px;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--border);
}

.auth-divider span {
  padding: 0 10px;
}

.btn-google-auth {
  width: 100%;
  padding: 10px;
  border-radius: var(--radius-md);
  background: #ffffff;
  color: #1f2937;
  font-weight: 600;
  font-size: 14px;
  border: 1px solid #d1d5db;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: var(--transition);
}

.btn-google-auth:hover {
  background: #f9fafb;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Star Rating in Feedback */
.star-rating-wrap {
  display: flex;
  gap: 10px;
  font-size: 28px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  align-items: center;
  padding: 4px 0;
}

.star-rating-wrap span {
  color: var(--border);
  transition: transform 0.15s ease, color 0.15s ease;
  display: inline-block;
  outline: none;
}

.star-rating-wrap span:hover,
.star-rating-wrap span:focus-visible {
  transform: scale(1.25);
}

.star-rating-wrap span.selected,
.star-rating-wrap span.hover {
  color: var(--accent-gold);
  text-shadow: 0 0 10px rgba(245, 158, 11, 0.4);
}

/* Floating Feedback Button */
.btn-floating-feedback {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 90;
  background: linear-gradient(135deg, var(--accent-gold), #d97706);
  color: #000000;
  font-weight: 700;
  font-size: 13px;
  padding: 10px 18px;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.35);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
}

.btn-floating-feedback:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(245, 158, 11, 0.5);
}

/* RTL Support */
[dir="rtl"] {
  direction: rtl;
  text-align: right;
}
.quiz-option-btn[dir="rtl"] {
  direction: rtl;
  text-align: right;
}
.quiz-option-btn[dir="rtl"] .opt-key {
  margin-left: 8px;
  margin-right: 0;
}
.arena-prompt[dir="rtl"],
.arena-word[dir="rtl"] {
  direction: rtl;
  text-align: center;
}
.explain-trans[dir="rtl"] {
  direction: rtl;
  text-align: right;
}

/* Responsive Mobile Layout Enhancements */
@media (max-width: 768px) {
  .header-container {
    flex-wrap: wrap;
    gap: 12px;
    padding: 10px 14px;
  }
  .header-left {
    flex: 1;
    min-width: 200px;
  }
  .header-stats {
    order: 2;
    gap: 8px;
  }
  .header-controls {
    order: 3;
    width: 100%;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 6px;
  }
  .selectors-group {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .select-wrapper {
    justify-content: space-between;
  }
  .select-wrapper .styled-select {
    flex: 1;
    max-width: 220px;
  }
}

/* ==========================================================================
   Linguistic Metadata & Grammatical Gender Color Coding
   der = #2563eb (Blue) | die = #dc2626 (Red) | das = #16a34a (Green)
   ========================================================================== */
.gender-der, .gender-art.der {
  color: #2563eb !important;
  font-weight: 800;
}
.gender-die, .gender-art.die {
  color: #dc2626 !important;
  font-weight: 800;
}
.gender-das, .gender-art.das {
  color: #16a34a !important;
  font-weight: 800;
}

.badge-gender {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge-gender.der {
  background: rgba(37, 99, 235, 0.14);
  color: #2563eb;
  border: 1px solid rgba(37, 99, 235, 0.35);
}
.badge-gender.die {
  background: rgba(220, 38, 38, 0.14);
  color: #dc2626;
  border: 1px solid rgba(220, 38, 38, 0.35);
}
.badge-gender.das {
  background: rgba(22, 163, 74, 0.14);
  color: #16a34a;
  border: 1px solid rgba(22, 163, 74, 0.35);
}

.word-plural-tag {
  display: inline-block;
  color: var(--accent-gold);
  font-size: 0.75em;
  font-weight: 700;
  margin-left: 6px;
  background: rgba(245, 158, 11, 0.12);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid rgba(245, 158, 11, 0.25);
  vertical-align: middle;
}

.verb-forms-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.25);
  color: var(--text-primary);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
}

.verb-aux-highlight {
  color: var(--accent-gold);
  font-weight: 700;
}

/* Flashcard Arena Mode & SM-2 Rating Controls */
.flashcard-arena-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.flashcard-flip-card {
  perspective: 1000px;
  cursor: pointer;
  min-height: 200px;
}

.flashcard-inner {
  position: relative;
  width: 100%;
  display: grid;
  grid-template-columns: 1fr;
  transition: transform 0.45s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
}

.flashcard-flip-card.flipped .flashcard-inner {
  transform: rotateY(180deg);
}

.flashcard-front, .flashcard-back {
  grid-area: 1 / 1;
  width: 100%;
  min-height: 220px;
  box-sizing: border-box;
  border-radius: var(--radius-lg);
  padding: 24px;
  text-align: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.flashcard-front {
  transform: rotateY(0deg);
  z-index: 2;
}

.flashcard-back {
  transform: rotateY(180deg);
  border-color: rgba(245, 158, 11, 0.45);
}

.flashcard-flip-card.flipped .flashcard-front {
  pointer-events: none;
  visibility: hidden;
  transition: visibility 0s 0.22s;
}

.flashcard-flip-card:not(.flipped) .flashcard-back {
  pointer-events: none;
  visibility: hidden;
  transition: visibility 0s 0.22s;
}

.sm2-ratings-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.btn-sm2 {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 12px 6px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-card);
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
  transition: var(--transition);
}

.btn-sm2:hover {
  transform: translateY(-2px);
}

.btn-sm2-key {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  color: var(--text-muted);
}

.btn-sm2.rating-again {
  border-color: rgba(239, 68, 68, 0.4);
  color: #ef4444;
}
.btn-sm2.rating-again:hover {
  background: rgba(239, 68, 68, 0.15);
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.3);
}

.btn-sm2.rating-hard {
  border-color: rgba(245, 158, 11, 0.4);
  color: #f59e0b;
}
.btn-sm2.rating-hard:hover {
  background: rgba(245, 158, 11, 0.15);
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.3);
}

.btn-sm2.rating-good {
  border-color: rgba(59, 130, 246, 0.4);
  color: #3b82f6;
}
.btn-sm2.rating-good:hover {
  background: rgba(59, 130, 246, 0.15);
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.3);
}

.btn-sm2.rating-easy {
  border-color: rgba(16, 185, 129, 0.4);
  color: #10b981;
}
.btn-sm2.rating-easy:hover {
  background: rgba(16, 185, 129, 0.15);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.3);
}

/* Type-In Mode & On-Screen Umlaut Bar */
.typein-box {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.umlaut-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
}

.umlaut-key-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.umlaut-key-btn:hover {
  border-color: var(--accent-gold);
  background: var(--bg-card-hover);
  color: var(--accent-gold);
}

.typein-input-row {
  display: flex;
  gap: 10px;
}

.typein-input-field {
  flex: 1;
  background: var(--bg-secondary);
  border: 2px solid var(--border);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 18px;
  font-weight: 600;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  outline: none;
  transition: var(--transition);
}

.typein-input-field:focus {
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 3px var(--accent-gold-glow);
}

.typein-input-field.correct-input {
  border-color: var(--accent-green);
  background: rgba(16, 185, 129, 0.08);
}

.typein-input-field.wrong-input {
  border-color: var(--accent-red);
  background: rgba(239, 68, 68, 0.08);
}

.btn-typein-submit {
  background: var(--accent-gold);
  color: #000;
  border: none;
  font-weight: 700;
  font-size: 15px;
  padding: 0 24px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
}

.btn-typein-submit:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.btn-typein-submit.btn-typein-next {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
}

.btn-typein-submit.btn-typein-next:hover {
  background: linear-gradient(135deg, #059669, #047857);
}

.btn-typein-dontknow {
  background: var(--bg-card);
  border: 1.5px dashed var(--border);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 14px;
  padding: 0 16px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
}

.btn-typein-dontknow:hover:not(:disabled) {
  border-color: var(--accent-gold);
  color: var(--accent-gold);
  background: rgba(245, 158, 11, 0.08);
}

.btn-typein-dontknow:disabled {
  cursor: default;
  opacity: 0.6;
}

.smart-umlaut-toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

/* ==========================================================================
   Mobile Responsive Optimizations (Screens <= 768px)
   Eliminates huge sticky header overlap, compacts controls,
   and ensures the prompt card and answers fit comfortably on screen.
   ========================================================================== */
@media (max-width: 768px) {
  .app-header {
    position: relative !important;
    top: auto;
    padding: 8px 12px;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .header-container {
    gap: 8px;
  }

  .header-left {
    gap: 8px;
    width: 100%;
    justify-content: space-between;
  }

  .header-left .back-link {
    font-size: 12px;
    padding: 4px 8px;
  }

  .brand-title {
    font-size: 15px;
  }

  .header-stats {
    gap: 6px;
    flex-wrap: wrap;
  }

  .stat-pill {
    padding: 4px 8px;
    font-size: 11px;
  }

  .header-controls {
    gap: 6px;
    flex-wrap: wrap;
  }

  .header-controls .header-secondary-link {
    display: none !important;
  }

  .btn-icon {
    padding: 5px 8px;
    font-size: 12px;
  }

  .main-wrapper {
    padding: 6px 10px 24px;
    gap: 8px;
  }

  .controls-panel {
    padding: 8px 10px;
    gap: 6px;
  }

  .selectors-group {
    gap: 6px;
  }

  .select-wrapper {
    font-size: 12px;
  }

  .styled-select {
    padding: 6px 8px;
    font-size: 12px;
  }

  .modes-strip {
    gap: 6px;
    padding-bottom: 4px;
  }

  .mode-chip {
    padding: 5px 10px;
    font-size: 12px;
  }

  .arena-progress-card {
    padding: 6px 12px;
    gap: 4px;
  }

  .progress-header {
    font-size: 12px;
  }

  .prompt-card {
    padding: 10px 14px;
    border-radius: var(--radius-md);
  }

  .prompt-meta {
    gap: 6px;
    margin-bottom: 4px;
  }

  .prompt-word {
    font-size: 23px;
  }

  .prompt-subhint {
    font-size: 12px;
    margin-top: 2px;
  }

  .audio-btn-play {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }

  .options-grid {
    gap: 6px;
  }

  .quiz-option-btn {
    padding: 9px 12px;
    min-height: 42px;
    font-size: 13.5px;
    gap: 10px;
  }

  .opt-key {
    width: 24px;
    height: 24px;
    font-size: 11px;
  }

  .btn-dont-know {
    padding: 8px 14px;
    font-size: 12.5px;
  }

  .sm2-ratings-grid {
    gap: 6px;
  }

  .btn-sm2 {
    padding: 8px 4px;
    font-size: 12px;
  }

  .typein-box {
    padding: 12px 14px;
    gap: 8px;
  }

  .typein-input-field {
    padding: 8px 12px;
    font-size: 15px;
  }

  .btn-typein-submit,
  .btn-typein-dontknow {
    padding: 0 14px;
    font-size: 13px;
  }
}

@media (max-width: 768px), (pointer: coarse) {
  .back-link,
  .btn-icon,
  .mode-chip {
    min-height: 44px;
    min-width: 44px;
  }
}

