:root {
  --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #311042 100%);
  --card-bg: rgba(30, 41, 59, 0.7);
  --card-border: rgba(255, 255, 255, 0.12);
  --card-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.5), 0 0 30px rgba(99, 102, 241, 0.15);

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-light: rgba(99, 102, 241, 0.15);

  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.18);
  --success-border: rgba(16, 185, 129, 0.4);

  --error: #f43f5e;
  --error-bg: rgba(244, 63, 94, 0.18);
  --error-border: rgba(244, 63, 94, 0.4);

  --badge-bg: rgba(255, 255, 255, 0.08);
  --btn-bg: rgba(255, 255, 255, 0.06);
  --btn-border: rgba(255, 255, 255, 0.14);
  --btn-hover: rgba(255, 255, 255, 0.12);

  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 7px;
}

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

body {
  font-family: 'Outfit', sans-serif;
  background: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 10px 10px 16px;
}

.app-container {
  width: 100%;
  max-width: 800px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Header */
.app-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

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

.logo-icon {
  font-size: 1.4rem;
  filter: drop-shadow(0 4px 12px rgba(99, 102, 241, 0.4));
}

.app-header h1 {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(90deg, #ffffff, #c7d2fe);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Stats bar */
.stats-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.stat-pill {
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(12px);
  border: 1px solid var(--btn-border);
  padding: 4px 9px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.76rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s ease;
}

.stat-pill:hover {
  transform: translateY(-1px);
}

.stat-pill .stat-icon {
  font-size: 0.85rem;
}

.correct-stat .stat-icon {
  color: var(--success);
}
.correct-stat strong {
  color: #34d399;
}

.incorrect-stat .stat-icon {
  color: var(--error);
}
.incorrect-stat strong {
  color: #fb7185;
}

.total-stat strong {
  color: #818cf8;
}

.streak-stat strong {
  color: #fbbf24;
}

/* Filter bar */
.filter-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px 10px;
  background: rgba(30, 41, 59, 0.4);
  backdrop-filter: blur(8px);
  padding: 6px 10px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 5px;
}

.filter-group label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

select {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--btn-border);
  color: var(--text-main);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.76rem;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s;
}

select:focus {
  border-color: var(--primary);
}

#speech-rate {
  width: 80px;
  accent-color: var(--primary);
  cursor: pointer;
}

#speech-rate-value {
  font-size: 0.76rem;
  color: var(--text-muted);
  font-weight: 500;
  min-width: 3.2em;
}

.filter-actions {
  display: flex;
  gap: 5px;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.btn-icon {
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  color: var(--text-main);
  padding: 4px 9px;
  font-size: 0.75rem;
  font-weight: 500;
}
.btn-icon:hover {
  background: var(--btn-hover);
}

.btn-secondary {
  background: transparent;
  border: 1px dashed rgba(255, 255, 255, 0.2);
  color: var(--text-muted);
  padding: 4px 9px;
  font-size: 0.75rem;
}
.btn-secondary:hover {
  background: rgba(244, 63, 94, 0.1);
  color: #fda4af;
  border-color: rgba(244, 63, 94, 0.3);
}

/* Card Main Area */
.game-main {
  width: 100%;
}

.flashcard {
  background: var(--card-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.3s;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--badge-bg);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.word-type-badge {
  background: rgba(99, 102, 241, 0.2);
  color: #a5b4fc;
  border-color: rgba(99, 102, 241, 0.4);
}

.word-gender-badge {
  background: rgba(236, 72, 153, 0.15);
  color: #f472b6;
  border-color: rgba(236, 72, 153, 0.3);
}

.card-progress {
  margin-left: auto;
  font-size: 0.78rem;
  color: var(--text-dim);
  font-weight: 500;
}

/* Question word & Symbol */
.card-question {
  text-align: center;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.word-symbol {
  font-size: 2.1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.3));
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  user-select: none;
}

.word-symbol:hover {
  transform: scale(1.15) rotate(4deg);
}

.spanish-word {
  font-family: 'Playfair Display', serif;
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #ffffff 30%, #e0e7ff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.2;
}

.word-hint {
  color: var(--text-muted);
  font-size: 0.78rem;
}

/* Options Grid (5 buttons) */
.options-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

@media (min-width: 600px) {
  .options-grid {
    grid-template-columns: 1fr 1fr;
  }
  .options-grid .option-btn:last-child:nth-child(odd) {
    grid-column: span 2;
  }
}

.option-btn {
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  color: var(--text-main);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 500;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 9px;
  position: relative;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.option-btn:hover:not(:disabled) {
  background: var(--btn-hover);
  border-color: rgba(99, 102, 241, 0.6);
  transform: translateY(-2px);
  box-shadow: 0 8px 16px -4px rgba(99, 102, 241, 0.2);
}

.option-btn:active:not(:disabled) {
  transform: translateY(0);
}

.option-btn:disabled {
  cursor: default;
}

.option-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  font-size: 0.74rem;
  font-weight: 600;
  flex-shrink: 0;
}

.option-text {
  flex-grow: 1;
  word-break: break-word;
}

/* States when answered */
.option-btn.correct {
  background: var(--success-bg) !important;
  border-color: var(--success) !important;
  color: #34d399 !important;
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.25) !important;
}

.option-btn.correct .option-index {
  background: var(--success);
  color: #ffffff;
}

.option-btn.incorrect {
  background: var(--error-bg) !important;
  border-color: var(--error) !important;
  color: #fb7185 !important;
  box-shadow: 0 0 20px rgba(244, 63, 94, 0.25) !important;
}

.option-btn.incorrect .option-index {
  background: var(--error);
  color: #ffffff;
}

.option-btn.dimmed {
  opacity: 0.45;
}

/* Feedback Box */
.feedback-area {
  display: flex;
  flex-direction: column;
  gap: 7px;
  animation: fadeIn 0.3s ease;
}

.feedback-area.hidden {
  display: none;
}

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

.feedback-banner {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.9rem;
}

.feedback-banner.correct {
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  color: #6ee7b7;
}

.feedback-banner.incorrect {
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  color: #fca5a5;
}

.feedback-icon {
  font-size: 1.15rem;
}

.sentence-box {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  padding: 8px 10px;
}

.sentence-item {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sentence-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.btn-play {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1;
  padding: 2px 4px;
  border-radius: var(--radius-sm);
}

.btn-play:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.08);
}

.sentence-text {
  font-size: 0.86rem;
  color: var(--text-main);
  line-height: 1.35;
}

.sentence-text u {
  text-decoration-color: var(--primary);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  color: #c7d2fe;
  font-weight: 600;
}

.word-details-box {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 6px 10px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  padding: 8px 10px;
}

.detail-item {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.detail-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-dim);
  font-weight: 600;
}

.detail-value {
  font-size: 0.84rem;
  color: var(--text-main);
  font-weight: 500;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  padding: 9px 16px;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
}

.key-hint {
  font-size: 0.72rem;
  opacity: 0.8;
  font-weight: normal;
}

/* History Review Section */
.history-section {
  background: rgba(30, 41, 59, 0.4);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  padding: 10px 12px;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.history-header h3 {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-muted);
}

.history-count {
  font-size: 0.72rem;
  color: var(--text-dim);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 170px;
  overflow-y: auto;
  padding-right: 4px;
}

.history-list::-webkit-scrollbar {
  width: 6px;
}

.history-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 999px;
}

.empty-history-text {
  font-size: 0.82rem;
  color: var(--text-dim);
  text-align: center;
  padding: 10px 0;
}

.history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 9px;
  background: rgba(15, 23, 42, 0.4);
  border-radius: var(--radius-sm);
  border-left: 3px solid transparent;
  font-size: 0.78rem;
}

.history-row.was-correct {
  border-left-color: var(--success);
}

.history-row.was-incorrect {
  border-left-color: var(--error);
}

.history-words {
  display: flex;
  align-items: center;
  gap: 6px;
}

.hw-symbol {
  font-size: 1.05rem;
}

.hw-spanish {
  font-weight: 600;
  color: #ffffff;
}

.hw-arrow {
  color: var(--text-dim);
  font-size: 0.75rem;
}

.hw-german {
  color: var(--text-muted);
}

.hw-type {
  font-size: 0.7rem;
  padding: 2px 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  color: var(--text-dim);
}

.history-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
}

.history-badge.badge-success {
  background: var(--success-bg);
  color: #34d399;
}

.history-badge.badge-error {
  background: var(--error-bg);
  color: #fb7185;
}
