/* style.css — VERA Vorbereitung */
/* Palette: warm sky-blue + sunny yellow, friendly & playful for Grundschüler */

:root, [data-theme="light"] {
  /* Type Scale */
  --text-xs:   clamp(0.75rem,  0.7rem  + 0.25vw, 0.875rem);
  --text-sm:   clamp(0.875rem, 0.8rem  + 0.35vw, 1rem);
  --text-base: clamp(1rem,     0.95rem + 0.25vw, 1.125rem);
  --text-lg:   clamp(1.125rem, 1rem    + 0.75vw, 1.5rem);
  --text-xl:   clamp(1.5rem,   1.2rem  + 1.25vw, 2.25rem);
  --text-2xl:  clamp(2rem,     1.2rem  + 2.5vw,  3.5rem);
  --text-3xl:  clamp(2.5rem,   1rem    + 4vw,    5rem);

  /* Spacing */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;

  /* Radius */
  --radius-sm: 0.5rem;
  --radius-md: 0.75rem;
  --radius-lg: 1.25rem;
  --radius-xl: 2rem;
  --radius-full: 9999px;

  /* Transitions */
  --transition-interactive: 180ms cubic-bezier(0.16, 1, 0.3, 1);

  /* Fonts */
  --font-display: 'Plus Jakarta Sans', 'Nunito', system-ui, sans-serif;
  --font-body:    'Nunito', 'Plus Jakarta Sans', system-ui, sans-serif;

  /* Content widths */
  --content-narrow: 640px;
  --content-default: 960px;
  --content-wide: 1200px;

  /* === LIGHT MODE PALETTE === */
  /* Sky blue base — evokes school, learning, friendliness */
  --color-bg:              #f0f7ff;
  --color-surface:         #f8fbff;
  --color-surface-2:       #ffffff;
  --color-surface-offset:  #e3eef9;
  --color-surface-dynamic: #d3e5f5;
  --color-divider:         #c8dded;
  --color-border:          #b8cedf;

  --color-text:            #1a2a3a;
  --color-text-muted:      #5a7a8a;
  --color-text-faint:      #9ab0bf;
  --color-text-inverse:    #f8fbff;

  /* Primary: Sky Blue */
  --color-primary:         #1a7bc8;
  --color-primary-hover:   #1263a8;
  --color-primary-active:  #0b4c82;
  --color-primary-highlight: #cce3f7;

  /* Accent: Sunny Yellow */
  --color-accent:          #f5a623;
  --color-accent-hover:    #e09010;
  --color-accent-active:   #c07808;
  --color-accent-highlight: #fdeec9;

  /* Subject colors */
  --color-deutsch:         #e84c7d;   /* pink-red for Deutsch */
  --color-deutsch-light:   #fce8f0;
  --color-mathe:           #2db87a;   /* green for Mathe */
  --color-mathe-light:     #e3f7ee;

  --color-success:         #2db87a;
  --color-success-light:   #e3f7ee;
  --color-error:           #e84c4c;
  --color-error-light:     #fce8e8;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(26, 42, 58, 0.08);
  --shadow-md: 0 4px 16px rgba(26, 42, 58, 0.1);
  --shadow-lg: 0 12px 40px rgba(26, 42, 58, 0.12);
  --shadow-card: 0 2px 8px rgba(26, 42, 58, 0.08), 0 0 0 1px rgba(26, 42, 58, 0.04);
}

/* Dark Mode */
[data-theme="dark"] {
  --color-bg:              #0f1a26;
  --color-surface:         #152030;
  --color-surface-2:       #1c2b3d;
  --color-surface-offset:  #1a2a3c;
  --color-surface-dynamic: #243548;
  --color-divider:         #2a3d52;
  --color-border:          #344d65;

  --color-text:            #d0e4f0;
  --color-text-muted:      #6a90aa;
  --color-text-faint:      #3a5a70;
  --color-text-inverse:    #0f1a26;

  --color-primary:         #5ab0f0;
  --color-primary-hover:   #3a98e0;
  --color-primary-active:  #2080c8;
  --color-primary-highlight: #1e3a58;

  --color-accent:          #f5c050;
  --color-accent-hover:    #e0a830;
  --color-accent-active:   #c09020;
  --color-accent-highlight: #3d3010;

  --color-deutsch:         #f07098;
  --color-deutsch-light:   #3a1828;
  --color-mathe:           #50d090;
  --color-mathe-light:     #0d3020;

  --color-success:         #50d090;
  --color-success-light:   #0d3020;
  --color-error:           #f07070;
  --color-error-light:     #3a1010;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.5);
  --shadow-card: 0 2px 8px rgba(0,0,0,0.3), 0 0 0 1px rgba(255,255,255,0.04);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --color-bg:              #0f1a26;
    --color-surface:         #152030;
    --color-surface-2:       #1c2b3d;
    --color-surface-offset:  #1a2a3c;
    --color-surface-dynamic: #243548;
    --color-divider:         #2a3d52;
    --color-border:          #344d65;
    --color-text:            #d0e4f0;
    --color-text-muted:      #6a90aa;
    --color-text-faint:      #3a5a70;
    --color-text-inverse:    #0f1a26;
    --color-primary:         #5ab0f0;
    --color-primary-hover:   #3a98e0;
    --color-primary-active:  #2080c8;
    --color-primary-highlight: #1e3a58;
    --color-accent:          #f5c050;
    --color-accent-hover:    #e0a830;
    --color-accent-active:   #c09020;
    --color-accent-highlight: #3d3010;
    --color-deutsch:         #f07098;
    --color-deutsch-light:   #3a1828;
    --color-mathe:           #50d090;
    --color-mathe-light:     #0d3020;
    --color-success:         #50d090;
    --color-success-light:   #0d3020;
    --color-error:           #f07070;
    --color-error-light:     #3a1010;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.5);
    --shadow-card: 0 2px 8px rgba(0,0,0,0.3), 0 0 0 1px rgba(255,255,255,0.04);
  }
}

/* ===== LAYOUT ===== */
.container {
  width: 100%;
  max-width: var(--content-default);
  margin-inline: auto;
  padding-inline: clamp(var(--space-4), 5vw, var(--space-12));
}

/* ===== HEADER ===== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-divider);
  box-shadow: var(--shadow-sm);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding-block: var(--space-3);
}

.logo-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
  color: var(--color-text);
}

.logo-text {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 800;
  color: var(--color-primary);
  line-height: 1.1;
}

.logo-sub {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-weight: 500;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.theme-toggle {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  color: var(--color-text-muted);
  background: var(--color-surface-offset);
}

.theme-toggle:hover {
  color: var(--color-primary);
  background: var(--color-primary-highlight);
}

/* ===== HERO ===== */
.hero {
  padding-block: clamp(var(--space-10), 8vw, var(--space-20));
  text-align: center;
  background: linear-gradient(160deg, var(--color-bg) 0%, var(--color-surface-offset) 100%);
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 50%, var(--color-primary-highlight) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, var(--color-accent-highlight) 0%, transparent 45%);
  pointer-events: none;
}

.hero-content {
  position: relative;
  z-index: 1;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--color-primary-highlight);
  color: var(--color-primary);
  font-size: var(--text-sm);
  font-weight: 700;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  margin-bottom: var(--space-6);
  font-family: var(--font-display);
}

.hero h1 {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: 800;
  color: var(--color-text);
  margin-bottom: var(--space-4);
}

.hero h1 span {
  color: var(--color-primary);
}

.hero-desc {
  font-size: var(--text-lg);
  color: var(--color-text-muted);
  max-width: 52ch;
  margin-inline: auto;
  margin-bottom: var(--space-10);
}

/* ===== SUBJECT CARDS ===== */
.subject-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-6);
  padding-block: clamp(var(--space-10), 6vw, var(--space-16));
}

@media (max-width: 480px) {
  .subject-grid {
    grid-template-columns: 1fr;
  }
}

.subject-card {
  background: var(--color-surface-2);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  cursor: pointer;
  border: 2px solid transparent;
  text-align: left;
  transition: transform var(--transition-interactive), box-shadow var(--transition-interactive), border-color var(--transition-interactive);
}

.subject-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.subject-card.deutsch { border-color: var(--color-deutsch); }
.subject-card.mathe   { border-color: var(--color-mathe); }

.subject-card:hover.deutsch { box-shadow: 0 12px 40px rgba(232, 76, 125, 0.2); }
.subject-card:hover.mathe   { box-shadow: 0 12px 40px rgba(45, 184, 122, 0.2); }

.subject-icon {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}

.subject-icon.deutsch { background: var(--color-deutsch-light); }
.subject-icon.mathe   { background: var(--color-mathe-light); }

.subject-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 800;
}

.subject-card.deutsch .subject-title { color: var(--color-deutsch); }
.subject-card.mathe   .subject-title { color: var(--color-mathe); }

.subject-desc {
  color: var(--color-text-muted);
  font-size: var(--text-base);
  line-height: 1.5;
}

.subject-topics {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.topic-tag {
  font-size: var(--text-xs);
  font-weight: 600;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-family: var(--font-display);
}

.deutsch .topic-tag { background: var(--color-deutsch-light); color: var(--color-deutsch); }
.mathe   .topic-tag { background: var(--color-mathe-light);   color: var(--color-mathe); }

.subject-btn {
  margin-top: var(--space-2);
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: var(--text-sm);
  font-family: var(--font-display);
  color: white;
  width: fit-content;
}

.subject-btn.deutsch { background: var(--color-deutsch); }
.subject-btn.deutsch:hover { background: #d03a6a; }
.subject-btn.mathe   { background: var(--color-mathe); }
.subject-btn.mathe:hover   { background: #22a068; }

/* ===== SECTIONS ===== */
.section {
  padding-block: clamp(var(--space-10), 6vw, var(--space-20));
}

.section-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 800;
  color: var(--color-text);
  margin-bottom: var(--space-2);
  text-align: center;
}

.section-subtitle {
  text-align: center;
  color: var(--color-text-muted);
  margin-bottom: var(--space-10);
  font-size: var(--text-base);
}

/* ===== HOW IT WORKS ===== */
.steps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-6);
}

.step-card {
  text-align: center;
  padding: var(--space-6);
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.step-number {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background: var(--color-primary-highlight);
  color: var(--color-primary);
  font-size: var(--text-lg);
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-4);
  font-family: var(--font-display);
}

.step-card h3 {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 700;
  margin-bottom: var(--space-2);
}

.step-card p { font-size: var(--text-sm); color: var(--color-text-muted); }

/* ===== QUIZ VIEWS ===== */
#quiz-view, #result-view {
  display: none;
}

#quiz-view.active, #result-view.active {
  display: block;
}

#home-view.hidden, #quiz-view.hidden, #result-view.hidden {
  display: none;
}

.quiz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding-block: var(--space-6);
  flex-wrap: wrap;
}

.quiz-subject-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 700;
  font-size: var(--text-sm);
  font-family: var(--font-display);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
}

.quiz-subject-badge.deutsch {
  background: var(--color-deutsch-light);
  color: var(--color-deutsch);
}

.quiz-subject-badge.mathe {
  background: var(--color-mathe-light);
  color: var(--color-mathe);
}

.quiz-meta {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  font-family: var(--font-display);
  font-weight: 600;
}

/* Progress Bar */
.progress-container {
  margin-bottom: var(--space-8);
}

.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
  font-weight: 600;
  font-family: var(--font-display);
}

.progress-bar {
  height: 10px;
  background: var(--color-surface-offset);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--color-primary), var(--color-accent));
  transition: width 400ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* Question Card */
.question-card {
  background: var(--color-surface-2);
  border-radius: var(--radius-xl);
  padding: clamp(var(--space-6), 4vw, var(--space-10));
  box-shadow: var(--shadow-md);
  margin-bottom: var(--space-6);
}

.question-category {
  font-size: var(--text-xs);
  font-weight: 700;
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-faint);
  margin-bottom: var(--space-4);
}

.question-text {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-8);
  line-height: 1.3;
}

.question-hint {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-6);
  font-style: italic;
}

/* Answer Options */
.answers-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
}

@media (max-width: 500px) {
  .answers-grid {
    grid-template-columns: 1fr;
  }
}

.answer-btn {
  padding: var(--space-4) var(--space-6);
  background: var(--color-surface-offset);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  font-size: var(--text-base);
  font-weight: 600;
  font-family: var(--font-body);
  color: var(--color-text);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-interactive);
  min-height: 70px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1.3;
}

.answer-btn:hover:not(:disabled) {
  background: var(--color-primary-highlight);
  border-color: var(--color-primary);
  color: var(--color-primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.answer-btn.selected {
  background: var(--color-primary-highlight);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.answer-btn.correct {
  background: var(--color-success-light);
  border-color: var(--color-success);
  color: var(--color-success);
}

.answer-btn.wrong {
  background: var(--color-error-light);
  border-color: var(--color-error);
  color: var(--color-error);
}

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

/* Feedback */
.feedback-box {
  padding: var(--space-4) var(--space-6);
  border-radius: var(--radius-lg);
  margin-top: var(--space-4);
  font-weight: 600;
  font-size: var(--text-base);
  display: none;
  align-items: center;
  gap: var(--space-3);
}

.feedback-box.show { display: flex; }

.feedback-box.correct-fb {
  background: var(--color-success-light);
  color: var(--color-success);
}

.feedback-box.wrong-fb {
  background: var(--color-error-light);
  color: var(--color-error);
}

/* Next Button */
.quiz-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: var(--space-6);
}

.btn-primary {
  padding: var(--space-4) var(--space-8);
  background: var(--color-primary);
  color: white;
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: var(--text-base);
  font-family: var(--font-display);
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background: var(--color-primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  padding: var(--space-3) var(--space-6);
  background: var(--color-surface-offset);
  color: var(--color-text-muted);
  border-radius: var(--radius-full);
  font-weight: 600;
  font-size: var(--text-sm);
  font-family: var(--font-display);
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.btn-secondary:hover {
  background: var(--color-border);
  color: var(--color-text);
}

/* ===== RESULT VIEW ===== */
.result-card {
  max-width: 640px;
  margin-inline: auto;
  background: var(--color-surface-2);
  border-radius: var(--radius-xl);
  padding: clamp(var(--space-8), 6vw, var(--space-12));
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.result-emoji {
  font-size: 5rem;
  margin-bottom: var(--space-4);
  display: block;
  animation: bounceIn 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes bounceIn {
  0% { transform: scale(0.5); opacity: 0; }
  70% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

.result-score-circle {
  width: 220px;
  height: 220px;
  border-radius: var(--radius-full);
  border: 8px solid var(--color-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: var(--space-6) auto;
}

.result-score-num {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 5vw, 3rem);
  font-weight: 800;
  color: var(--color-primary);
  line-height: 1;
}

.result-score-label {
  font-size: var(--text-base);
  color: var(--color-text-muted);
  font-weight: 600;
  margin-top: 4px;
}

.result-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 800;
  color: var(--color-text);
  margin-bottom: var(--space-3);
}

.result-message {
  color: var(--color-text-muted);
  margin-bottom: var(--space-8);
}

.result-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}

.result-stat {
  background: var(--color-surface-offset);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
}

.result-stat-num {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 800;
  color: var(--color-text);
}

.result-stat-num.correct { color: var(--color-success); }
.result-stat-num.wrong   { color: var(--color-error); }

.result-stat-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-weight: 600;
  font-family: var(--font-display);
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  align-items: center;
}

/* ===== INFO SECTION ===== */
.info-section {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  box-shadow: var(--shadow-sm);
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-6);
  margin-top: var(--space-6);
}

.info-card {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
}

.info-icon {
  font-size: 1.75rem;
  flex-shrink: 0;
}

.info-card h3 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-base);
  margin-bottom: var(--space-1);
}

.info-card p {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  max-width: none;
}

/* ===== FOOTER ===== */
.site-footer {
  background: var(--color-surface-offset);
  border-top: 1px solid var(--color-divider);
  padding-block: var(--space-8);
  text-align: center;
}

/* Footer nur auf Home-View zeigen */
body.view-quiz .site-footer,
body.view-level .site-footer,
body.view-result .site-footer {
  display: none;
}

.footer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
}

.footer-logo {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--text-base);
  color: var(--color-primary);
}

.footer-note {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  max-width: 50ch;
  margin-inline: auto;
}

.footer-credit {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
}

.footer-credit a {
  color: var(--color-text-muted);
  text-decoration: none;
}

.footer-credit a:hover { color: var(--color-primary); }

/* ===== BACK BUTTON ===== */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  font-weight: 600;
  font-family: var(--font-display);
  text-decoration: none;
  cursor: pointer;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
}

.back-btn:hover {
  color: var(--color-primary);
  background: var(--color-primary-highlight);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
  .result-details {
    grid-template-columns: 1fr;
  }

  .quiz-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .hero h1 {
    font-size: clamp(2rem, 8vw, 3rem);
  }
}

/* ===== ANIMATIONS ===== */
.fade-in {
  animation: fadeIn 0.4s ease-out both;
}

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

.slide-up {
  animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

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

/* ===== LEVEL SELECTION ===== */
.level-select-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
}

@media (max-width: 500px) {
  .level-select-grid {
    grid-template-columns: 1fr;
  }
}

.level-card {
  background: var(--color-surface-2);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  box-shadow: var(--shadow-card);
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform var(--transition-interactive), box-shadow var(--transition-interactive), border-color var(--transition-interactive);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.level-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.l1-card { border-color: var(--color-primary); }
.l2-card { border-color: var(--color-accent); }
.l3-card { border-color: var(--color-deutsch); }

.l1-card:hover { box-shadow: 0 12px 40px rgba(26, 123, 200, 0.2); }
.l2-card:hover { box-shadow: 0 12px 40px rgba(245, 166, 35, 0.2); }
.l3-card:hover { box-shadow: 0 12px 40px rgba(232, 76, 125, 0.2); }

.level-card-header {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.level-big-num {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 800;
  color: white;
  flex-shrink: 0;
}

.l1-card .level-big-num { background: var(--color-primary); }
.l2-card .level-big-num { background: var(--color-accent); }
.l3-card .level-big-num { background: var(--color-deutsch); }

.level-card-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 800;
}

.l1-card .level-card-title { color: var(--color-primary); }
.l2-card .level-card-title { color: var(--color-accent); }
.l3-card .level-card-title { color: var(--color-deutsch); }

.level-card-subtitle {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-weight: 600;
  font-family: var(--font-display);
  white-space: nowrap;
}

.level-card-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.level-q-count {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  background: var(--color-surface-offset);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.level-star-row {
  font-size: var(--text-base);
  letter-spacing: 2px;
}

.level-card-desc {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  max-width: none;
  line-height: 1.5;
}

.level-start-btn {
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: var(--text-sm);
  font-family: var(--font-display);
  color: white;
  width: fit-content;
  margin-top: var(--space-2);
}

.l1-btn { background: var(--color-primary); }
.l1-btn:hover { background: var(--color-primary-hover); }
.l2-btn { background: var(--color-accent); }
.l2-btn:hover { background: var(--color-accent-hover); }
.l3-btn { background: var(--color-deutsch); }
.l3-btn:hover { background: #d03a6a; }

/* Level badges on subject card */
.subject-levels {
  display: flex;
  flex-direction: row;
  gap: var(--space-2);
  margin-top: var(--space-3);
  align-items: center;
}

.level-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 800;
  font-family: var(--font-display);
  flex-shrink: 0;
}

.l1-badge { background: var(--color-primary-highlight); color: var(--color-primary); }
.l2-badge { background: var(--color-accent-highlight);  color: var(--color-accent); }
.l3-badge { background: var(--color-deutsch-light);     color: var(--color-deutsch); }

.subject-levels-label {
  font-size: var(--text-xs);
  font-weight: 700;
  font-family: var(--font-display);
  color: var(--color-text-muted);
  margin-right: 2px;
}

/* Quiz level badge */
.quiz-level-badge {
  display: inline-flex;
  align-items: center;
  background: var(--color-surface-offset);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  font-weight: 700;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-family: var(--font-display);
}

/* Result level info */
.result-level-info {
  font-size: var(--text-sm);
  font-weight: 700;
  font-family: var(--font-display);
  color: var(--color-text-muted);
  background: var(--color-surface-offset);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  display: inline-block;
  margin-bottom: var(--space-4);
}

/* Hero greeting */
.hero-greeting {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: var(--space-4);
}

/* Level step numbers */
.level-num { font-family: var(--font-display); font-weight: 800; }
.l1-num { background: var(--color-primary-highlight); color: var(--color-primary); }
.l2-num { background: var(--color-accent-highlight);  color: var(--color-accent); }
.l3-num { background: var(--color-deutsch-light);     color: var(--color-deutsch); }

@media (max-width: 600px) {
  .level-select-grid { grid-template-columns: 1fr; }
  .subject-levels { flex-direction: row; flex-wrap: wrap; }
}

/* ===== LESE-VIEW: Text padding (from index.html inline moved here) ===== */
.lese-text-box {
  padding: 28px clamp(20px, 4vw, 36px) !important;
  margin-bottom: 24px !important;
}

/* ===== GAMIFICATION ===== */

/* Streak widget in header */
.streak-widget {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: linear-gradient(135deg, #fff4e0, #ffecc5);
  border: 1.5px solid #f5a623;
  border-radius: 99px;
  padding: 5px 12px;
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 800;
  color: #c07808;
  cursor: default;
  user-select: none;
  flex-shrink: 0;
}
[data-theme="dark"] .streak-widget {
  background: linear-gradient(135deg, #3d2800, #4a3200);
  border-color: #f5c050;
  color: #f5c050;
}
.streak-flame { font-size: 1rem; }
.streak-zero { opacity: 0.6; }

/* Progress section on home */
.progress-section {
  background: var(--color-surface);
  padding-block: clamp(var(--space-8), 5vw, var(--space-12));
  border-top: 1px solid var(--color-divider);
}
.progress-subject-block {
  background: var(--color-surface-2);
  border-radius: var(--radius-xl);
  padding: var(--space-6) var(--space-8);
  margin-bottom: var(--space-4);
  box-shadow: var(--shadow-sm);
}
.progress-subject-title {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 800;
  margin-bottom: var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.progress-levels-row {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
}
.progress-level-item {
  flex: 1;
  min-width: 100px;
  background: var(--color-surface-offset);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  align-items: center;
  text-align: center;
}
.progress-level-label {
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--color-text-muted);
}
.progress-mini-bar-bg {
  width: 100%;
  height: 8px;
  background: var(--color-divider);
  border-radius: 99px;
  overflow: hidden;
}
.progress-mini-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.6s cubic-bezier(0.16,1,0.3,1);
}
.l1-fill { background: var(--color-primary); }
.l2-fill { background: var(--color-accent); }
.l3-fill { background: var(--color-deutsch); }
.progress-level-frac {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  color: var(--color-text-faint);
}
.progress-mastered-tag {
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-display);
  color: var(--color-success);
  background: var(--color-success-light);
  border-radius: 99px;
  padding: 2px 8px;
}
.progress-empty-hint {
  font-size: var(--text-sm);
  color: var(--color-text-faint);
  text-align: center;
  padding: var(--space-4) 0;
}

/* Highscore row on result screen */
.result-highscore-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}
.result-hs-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 700;
  padding: var(--space-2) var(--space-4);
  border-radius: 99px;
}
.result-hs-badge.new-record {
  background: linear-gradient(135deg, #fff4c2, #ffe080);
  color: #8b6000;
  border: 1.5px solid #f5c050;
  animation: popIn 0.4s cubic-bezier(0.16,1,0.3,1) both;
}
[data-theme="dark"] .result-hs-badge.new-record {
  background: linear-gradient(135deg, #3a2e00, #4d3c00);
  color: #f5c050;
  border-color: #f5c050;
}
.result-hs-badge.prev-record {
  background: var(--color-surface-offset);
  color: var(--color-text-muted);
}
@keyframes popIn {
  0% { transform: scale(0.7); opacity: 0; }
  70% { transform: scale(1.08); }
  100% { transform: scale(1); opacity: 1; }
}

/* Badge unlock popup */
.badge-popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease both;
}
.badge-popup {
  background: var(--color-surface-2);
  border-radius: var(--radius-xl);
  padding: var(--space-8) var(--space-10);
  text-align: center;
  max-width: 380px;
  width: 90%;
  box-shadow: var(--shadow-lg);
  animation: popIn 0.35s cubic-bezier(0.16,1,0.3,1) both;
}
.badge-popup-icon { font-size: 3.5rem; display: block; margin-bottom: var(--space-3); }
.badge-popup-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 800;
  color: var(--color-accent);
  margin-bottom: var(--space-2);
}
.badge-popup-name {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 800;
  color: var(--color-text);
  margin-bottom: var(--space-2);
}
.badge-popup-desc {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-6);
  line-height: 1.6;
}
.badge-popup-close {
  background: var(--color-primary);
  color: white;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-base);
  padding: var(--space-3) var(--space-8);
  border-radius: 99px;
  cursor: pointer;
  width: 100%;
}
.badge-popup-close:hover { background: var(--color-primary-hover); }

/* Badges display on result */
.result-badges-section {
  margin-bottom: var(--space-6);
}
.result-badges-title {
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-faint);
  margin-bottom: var(--space-3);
}
.badges-grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  justify-content: center;
}
.badge-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--color-surface-offset);
  border: 1.5px solid var(--color-border);
  border-radius: 99px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font-display);
  color: var(--color-text-muted);
}
.badge-chip.unlocked {
  background: var(--color-accent-highlight);
  border-color: var(--color-accent);
  color: #8b6000;
}
[data-theme="dark"] .badge-chip.unlocked {
  background: #3a2e00;
  border-color: var(--color-accent);
  color: var(--color-accent);
}

/* Quiz count badge */
.quiz-count-chip {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  color: var(--color-text-faint);
  background: var(--color-surface-offset);
  padding: 3px 10px;
  border-radius: 99px;
  display: inline-block;
  margin-bottom: var(--space-4);
}

/* ===== LAUTLESE TOOLBAR ===== */
.lautlese-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
  background: color-mix(in oklch, var(--color-primary) 8%, var(--color-card, var(--color-surface-2)));
  border: 1.5px solid color-mix(in oklch, var(--color-primary) 25%, var(--color-border));
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
}

.lautlese-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--color-primary);
  color: white;
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 700;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background 0.15s, transform 0.12s;
  min-height: 40px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.lautlese-btn:hover { background: var(--color-primary-hover); transform: translateY(-1px); }
.lautlese-btn:active { transform: translateY(0); }
.lautlese-btn.paused { background: var(--color-accent); color: #5a3000; }
.lautlese-btn.paused:hover { background: var(--color-accent-hover); }

.lautlese-stop-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--color-surface-offset);
  color: var(--color-text-muted);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 700;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background 0.15s;
  min-height: 40px;
  touch-action: manipulation;
}
.lautlese-stop-btn:hover { background: var(--color-error-light); color: var(--color-error); }

.lautlese-voice-info {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-family: var(--font-display);
  font-weight: 600;
  flex: 1;
  text-align: right;
}

/* Sentence highlight while reading */
.lese-sentence {
  border-radius: 4px;
  transition: background 0.25s ease;
}
.lese-sentence.reading-active {
  background: color-mix(in oklch, var(--color-accent) 28%, transparent);
  outline: 1.5px solid color-mix(in oklch, var(--color-accent) 50%, transparent);
}
