/* ── CSS Variables ────────────────────────────────────────────────────────── */
:root {
  --purple: #C0603A;        /* Fuchsrot */
  --purple-light: #D4784F;  /* Fuchsrot-hell */
  --purple-dark: #6B4C35;   /* Holzbraun */
  --green: #1D9E75;
  --green-light: #2EC28F;
  --orange: #EF9F27;
  --red: #E05C5C;
  --bg: #FAF7F0;            /* Birkenweiss */
  --card-bg: #FFFFFF;
  --text: #2C1810;          /* warm dark brown */
  --text-muted: #8B6A58;    /* warm muted brown */
  --border: #E0D5C8;        /* warm beige */
  --radius: 18px;
  --radius-sm: 10px;
  --shadow: 0 3px 14px rgba(192, 96, 58, 0.12);
  --shadow-lg: 0 8px 28px rgba(192, 96, 58, 0.22);
  --font-body: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'Courier New', 'Consolas', monospace;
}

/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

button, .module-card, .nav-btn, .diff-btn, .row-btn {
  touch-action: manipulation;
}

body {
  font-family: var(--font-body);
  background: #0a0818;
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
}

/* ── Sternenhimmel ─────────────────────────────────────────────────────────── */

#star-sky {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 0;
  pointer-events: none;
}

#login-screen,
#app-shell {
  position: relative;
  z-index: 1;
}

@keyframes twinkle {
  0%, 100% { opacity: 0.9; }
  50%       { opacity: 0.2; }
}

@keyframes twinkleBright {
  0%, 100% { opacity: 0.95; }
  40%       { opacity: 0.45; }
  70%       { opacity: 0.8; }
}

.star-toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: rgba(26, 16, 53, 0.92);
  color: #e8d8ff;
  border: 1px solid #c8b8f0;
  border-radius: 20px;
  padding: 10px 20px;
  font-size: 0.95rem;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.4s ease, transform 0.4s ease;
  z-index: 200;
  pointer-events: none;
}

.star-toast--visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.hidden { display: none !important; }

/* ── Header ───────────────────────────────────────────────────────────────── */
header {
  background: linear-gradient(135deg, var(--purple) 0%, var(--purple-light) 100%);
  color: white;
  padding: 12px 20px;
  box-shadow: 0 3px 12px rgba(192, 96, 58, 0.35);
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.app-title {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.3px;
}

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

.header-stat {
  background: rgba(255,255,255,0.18);
  padding: 9px 12px;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 600;
}

.level-badge { background: rgba(255,255,255,0.28); }
.profile-chip {
  background: rgba(255,255,255,0.22);
  border: 1.5px solid rgba(255,255,255,0.4);
  font-weight: 700;
}

.header-settings-btn {
  background: rgba(255,255,255,0.18);
  border: 1.5px solid rgba(255,255,255,0.3);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.18s, transform 0.18s;
  flex-shrink: 0;
}
.header-settings-btn:hover { background: rgba(255,255,255,0.32); transform: rotate(30deg); }
.header-settings-btn.active { background: rgba(255,255,255,0.38); transform: rotate(60deg); }

.file-storage-btns {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.file-storage-advanced {
  margin-top: 8px;
}
.file-storage-advanced summary {
  cursor: pointer;
  font-size: 0.88rem;
  color: var(--text-muted);
  user-select: none;
}

/* ── Navigation ───────────────────────────────────────────────────────────── */
#main-nav {
  background: transparent;
  display: flex;
  gap: 12px;
  padding: 14px 16px 0;
  max-width: 900px;
  margin: 0 auto;
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 16px 10px;
  border: 2.5px solid var(--border);
  border-bottom: none;
  background: white;
  border-radius: 18px 18px 0 0;
  font-family: var(--font-body);
  cursor: pointer;
  transition: transform 0.18s cubic-bezier(.34,1.56,.64,1), box-shadow 0.18s, background 0.18s;
  box-shadow: 0 -2px 8px rgba(192, 96, 58, 0.06);
  white-space: nowrap;
  position: relative;
  top: 2px;
}

.nav-label { font-size: 1rem; font-weight: 700; color: var(--text-muted); }

.nav-btn:hover { transform: translateY(-3px); box-shadow: 0 -4px 14px rgba(192, 96, 58, 0.14); }
.nav-btn:hover .nav-label { color: var(--purple); }

.nav-btn.active {
  background: white;
  border-color: var(--purple-light);
  box-shadow: 0 -4px 16px rgba(192, 96, 58, 0.18);
  transform: translateY(-4px);
  z-index: 1;
}
.nav-btn.active .nav-label {
  color: var(--purple);
}

/* ── Main layout ──────────────────────────────────────────────────────────── */
main {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 16px 48px;
  background: white;
  border-top: 2.5px solid var(--purple-light);
}

.tab-content { padding-top: 24px; }

.section-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--purple-dark);
  margin-bottom: 20px;
  text-wrap: balance;
}

/* ── Module cards ─────────────────────────────────────────────────────────── */
.module-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}

.module-card {
  background: white;
  border: 2.5px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 16px;
  cursor: pointer;
  text-align: center;
  transition: transform 0.18s cubic-bezier(.34,1.56,.64,1), box-shadow 0.18s, border-color 0.18s;
  box-shadow: var(--shadow);
}

.module-card:hover {
  transform: translateY(-5px) scale(1.03);
  box-shadow: var(--shadow-lg);
  border-color: var(--purple-light);
}

.module-card:active {
  transform: scale(0.97);
}

.module-icon { font-size: 2.4rem; margin-bottom: 10px; }
.module-name { font-size: 1.05rem; font-weight: 700; color: var(--purple-dark); }
.module-desc { font-size: 1rem; color: var(--text-muted); margin-top: 4px; }

/* ── Config screens ───────────────────────────────────────────────────────── */
.module-config {
  background: white;
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
  max-width: 600px;
}

.config-section { margin-bottom: 20px; }
.config-label { font-weight: 600; margin-bottom: 10px; color: var(--text-muted); font-size: 0.9rem; }

.config-option { margin-bottom: 16px; }

.btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-group.vertical { flex-direction: column; }

.diff-btn, .type-btn {
  padding: 10px 18px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: white;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
  transition: border-color 0.15s, background-color 0.15s, color 0.15s;
}

.diff-btn.active, .type-btn.active {
  background: var(--purple);
  color: white;
  border-color: var(--purple);
}

.diff-btn:hover:not(.active), .type-btn:hover:not(.active) {
  border-color: var(--purple-light);
  color: var(--purple);
}

.config-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  flex-wrap: wrap;
}

/* Row selector (Einmaleins) */
.row-selector { margin-bottom: 20px; }

.row-selector-hint {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.row-btn-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.row-btn {
  min-width: 64px;
  padding: 12px 14px;
  border: 2.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: white;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  position: relative;
  transition: border-color 0.15s, background-color 0.15s, color 0.15s, box-shadow 0.15s;
  color: var(--text-muted);
}

.row-btn:hover:not(.selected) {
  border-color: var(--purple-light);
  color: var(--purple);
}

.row-btn.selected {
  background: var(--purple);
  color: white;
  border-color: var(--purple);
  box-shadow: 0 3px 8px rgba(192, 96, 58, 0.3);
}

.row-selector-actions {
  display: flex;
  gap: 8px;
}

.row-action-btn {
  padding: 6px 16px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  background: white;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.row-action-btn:hover { border-color: var(--purple); color: var(--purple); }

.row-checkmark {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--green);
  color: white;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.module-check-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.check-option {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
}

.check-option input[type=checkbox] {
  width: 22px;
  height: 22px;
  cursor: pointer;
  accent-color: var(--purple);
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn-primary {
  background: linear-gradient(135deg, var(--purple) 0%, var(--purple-light) 100%);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px 28px;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 48px;
  transition: transform 0.18s cubic-bezier(.34,1.56,.64,1), box-shadow 0.15s;
  box-shadow: 0 4px 12px rgba(192, 96, 58, 0.30);
}

.btn-primary:hover { transform: translateY(-2px) scale(1.03); box-shadow: 0 6px 18px rgba(192, 96, 58, 0.35); }
.btn-primary:active { transform: scale(0.97); }

.btn-secondary {
  background: white;
  color: var(--purple);
  border: 2px solid var(--purple);
  border-radius: var(--radius-sm);
  padding: 12px 24px;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 48px;
  transition: background-color 0.15s;
}

.btn-secondary:hover { background: var(--bg); }

.btn-danger {
  background: white;
  color: var(--red);
  border: 2px solid var(--red);
  border-radius: var(--radius-sm);
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 48px;
  transition: background-color 0.15s;
}

.btn-danger:hover { background: #fff0f0; }

.btn-next {
  background: var(--green);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px 32px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 52px;
  margin-top: 16px;
  transition: background 0.15s, transform 0.1s;
  box-shadow: 0 2px 8px rgba(29,158,117,0.3);
}

.btn-next:hover { background: #178a64; transform: translateY(-1px); }

/* ── Exercise area ────────────────────────────────────────────────────────── */
.progress-container {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.exercise-topbar {
  margin-bottom: 12px;
}

.exit-btn {
  background: white;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background-color 0.15s;
}

.exit-btn:hover { border-color: var(--purple); color: var(--purple); background: var(--bg); }

.progress-track {
  flex: 1;
  height: 12px;
  background: var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--purple), #E8904A, var(--orange));
  border-radius: 6px;
  transition: width 0.5s cubic-bezier(.34,1.2,.64,1);
}

.progress-text {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-muted);
  min-width: 50px;
  text-align: right;
}

/* Question display */
.question-display {
  text-align: center;
  margin-bottom: 28px;
}

.question-text {
  font-size: 3rem;
  font-weight: 800;
  color: var(--purple-dark);
  line-height: 1.2;
  text-shadow: 0 2px 8px rgba(192, 96, 58, 0.10);
  transition: transform 0.3s;
}

.schriftlich-hint {
  font-size: 1rem;
  color: var(--text-muted);
  margin-top: 12px;
  font-style: italic;
}

/* ── Question feed ────────────────────────────────────────────────────────── */
.question-feed {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 62vh;
  overflow-y: auto;
  padding: 4px 2px 0;
  scroll-behavior: smooth;
}

/* Browsers ignore padding-bottom on flex scroll containers — use ::after instead */
.question-feed::after {
  content: '';
  display: block;
  min-height: 64px;
  flex-shrink: 0;
}

/* Subtle scrollbar */
.question-feed::-webkit-scrollbar { width: 5px; }
.question-feed::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.feed-card {
  background: white;
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow);
  border-left: 4px solid transparent;
  transition: opacity 0.35s ease, transform 0.35s ease, border-color 0.2s;
  animation: feed-slide-in 0.3s cubic-bezier(.34,1.15,.64,1);
}

@keyframes feed-slide-in {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

.feed-card--past {
  opacity: 0.45;
  transform: scale(0.985);
  box-shadow: none;
}

.feed-card--past .question-text { font-size: 1.5rem; color: var(--text-muted); }
.feed-card--past .schriftlich-hint { display: none; }
.feed-card--past .fc-input { display: none; }
.feed-card--past .submit-answer-btn { display: none; }
.feed-card--past .answer-input-field { width: 72px; font-size: 1.3rem; padding: 6px 8px; }

.feed-card--correct { border-left-color: var(--green); }
.feed-card--wrong   { border-left-color: var(--red); }

/* Question section inside card */
.fc-question { margin-bottom: 16px; }

/* Inline row: question = [input] OK */
.fc-question-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.fc-question-row .question-text { margin: 0; }

/* Input section (MC) */
.fc-input {
  display: flex;
  justify-content: flex-start;
  margin-bottom: 4px;
}

/* Feedback section */
.fc-feedback {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  animation: fadeIn 0.2s ease;
}

.fc-fb--correct .fc-fb-row { color: var(--green); }
.fc-fb--wrong   .fc-fb-row { color: var(--red); }

.fc-fb-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.1rem;
  font-weight: 700;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.fc-fb-icon { font-size: 1.4rem; }
.fc-fb-msg  { flex: 1; }
.fc-fb-pts  { font-size: 0.95rem; font-weight: 800; color: var(--orange); white-space: nowrap; }
.fc-streak  { font-size: 0.9rem; color: #e74c3c; font-weight: 700; }

.fc-fb-correct {
  font-size: 1rem;
  color: var(--text-muted);
  margin-bottom: 14px;
}
.fc-fb-correct strong { color: var(--text); font-size: 1.15rem; }

/* Solution section */
.fc-solution {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  animation: fadeIn 0.25s ease;
}

/* Free input */
.free-input-area {
  display: flex;
  gap: 12px;
  align-items: center;
}

.answer-input-field {
  width: 130px;
  padding: 12px 14px;
  font-size: 1.8rem;
  font-weight: 700;
  text-align: center;
  border: 3px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: border-color 0.2s;
}

.answer-input-field:focus { border-color: var(--purple); }
.answer-input-field:focus-visible { outline: 2px solid var(--purple); outline-offset: 2px; }
.answer-input-field:disabled { background: var(--bg); color: var(--text-muted); }

/* Remove number input spinners */
.answer-input-field::-webkit-inner-spin-button,
.answer-input-field::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.answer-input-field { -moz-appearance: textfield; }

/* Multiple choice */
.mc-options {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
}

.mc-btn {
  min-width: 100px;
  padding: 20px 24px;
  font-size: 1.8rem;
  font-weight: 800;
  border: 3px solid var(--border);
  border-radius: var(--radius);
  background: white;
  cursor: pointer;
  transition: transform 0.18s cubic-bezier(.34,1.56,.64,1), box-shadow 0.15s, border-color 0.15s, background 0.15s;
  box-shadow: var(--shadow);
}

.mc-btn:hover:not(:disabled) {
  border-color: var(--purple);
  background: #fdf0ea;
  transform: translateY(-4px) scale(1.06);
  box-shadow: var(--shadow-lg);
}

.mc-btn:active:not(:disabled) { transform: scale(0.95); }

.mc-btn:disabled { cursor: default; }
.mc-btn.mc-correct { background: #e0f8ee; border-color: var(--green); color: var(--green); }
.mc-btn.mc-wrong { background: #fde8e8; border-color: var(--red); color: var(--red); }

/* Feedback */
.feedback-area {
  border-radius: var(--radius);
  padding: 20px 24px;
  text-align: center;
  margin-top: 16px;
  animation: fadeIn 0.25s ease;
}

.feedback-correct {
  background: #e8f8f2;
  border: 2px solid var(--green);
}

.feedback-wrong {
  background: #fdeaea;
  border: 2px solid var(--red);
}

.feedback-icon { font-size: 2.8rem; margin-bottom: 6px; animation: pop 0.35s cubic-bezier(.34,1.56,.64,1); }

.feedback-text {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.feedback-correct .feedback-text { color: var(--green); }
.feedback-wrong .feedback-text { color: var(--red); }

.feedback-points {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--orange);
  animation: pop 0.4s cubic-bezier(.34,1.56,.64,1) 0.1s both;
}

.feedback-streak {
  font-size: 1rem;
  font-weight: 700;
  color: #e74c3c;
  margin-top: 4px;
}

.feedback-answer {
  font-size: 1.1rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.feedback-answer strong { color: var(--text); font-size: 1.3rem; }

@keyframes pop {
  0%   { transform: scale(0.6); opacity: 0; }
  100% { transform: scale(1);   opacity: 1; }
}

/* Bounce question on correct answer */
.correct-bounce {
  animation: correct-bounce 0.5s cubic-bezier(.34,1.56,.64,1);
}

@keyframes correct-bounce {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.12); }
  100% { transform: scale(1); }
}

/* Schriftlich solution */
.solution-area {
  background: #faf5f0;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-top: 16px;
  animation: fadeIn 0.3s ease;
}

.solution-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--purple-dark);
  margin-bottom: 16px;
}

.calc-display {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  display: inline-block;
  min-width: 200px;
  max-width: 100%;
  overflow-x: auto;
  margin-bottom: 16px;
}

.calc-line-row {
  white-space: pre;
  line-height: 1.7;
}

.calc-header { color: var(--purple-dark); font-weight: 800; }
.calc-number { color: var(--text); font-weight: 700; }
.calc-multiplier { color: var(--purple); }
.calc-line { color: var(--text-muted); }
.calc-partial { color: var(--text); }
.calc-carry { color: var(--orange); font-size: 0.8em; line-height: 1; }
.calc-result { color: var(--green); font-weight: 800; }

.solution-steps { margin-top: 12px; }
.steps-title { font-weight: 700; margin-bottom: 8px; color: var(--text-muted); }
.solution-steps ol { padding-left: 20px; }
.solution-steps li { margin-bottom: 6px; font-size: 0.95rem; line-height: 1.5; }

/* Streak indicator */
.streak-indicator {
  text-align: center;
  font-size: 1.3rem;
  font-weight: 700;
  min-height: 40px;
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: color 0.3s, background-color 0.3s;
}

.streak-fire { color: #e74c3c; background: #fff0ee; animation: pulse 0.6s ease; }
.streak-star { color: var(--orange); background: #fff8ed; animation: pulse 0.6s ease; }
.streak-ok { color: var(--purple); background: #fdf0ea; animation: pulse 0.6s ease; }

/* ── Round complete ───────────────────────────────────────────────────────── */
.round-complete-card {
  background: white;
  border-radius: var(--radius);
  padding: 36px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  max-width: 480px;
  margin: 0 auto;
  border-top: 5px solid var(--purple);
  animation: fadeIn 0.4s cubic-bezier(.34,1.2,.64,1);
}

.round-complete-card h2 {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--purple-dark);
  margin-bottom: 20px;
}

.round-complete-emoji { font-size: 4rem; margin-bottom: 8px; }
.round-complete-pct { font-size: 2.5rem; font-weight: 800; color: var(--purple); margin-bottom: 16px; }

.round-summary {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.rs-correct { color: var(--green); font-weight: 700; }
.rs-wrong { color: var(--red); font-weight: 700; }
.rs-hints { color: var(--orange); font-weight: 700; }

.round-streak { color: var(--text-muted); font-size: 0.95rem; margin-bottom: 6px; }
.round-level { color: var(--purple); font-weight: 700; margin-bottom: 24px; }

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

/* ── Dashboard ────────────────────────────────────────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}

.dash-card {
  background: white;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.dash-card h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--purple-dark);
  margin-bottom: 16px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 10px;
}

.dash-overview { grid-column: 1 / -1; }
.dash-badges { grid-column: 1 / -1; }

/* Level display */
.level-display { margin-bottom: 16px; }
.level-name { font-size: 1.3rem; font-weight: 800; color: var(--purple); margin-bottom: 8px; }
.level-bar-wrap {
  height: 14px;
  background: var(--border);
  border-radius: 7px;
  overflow: hidden;
  margin-bottom: 4px;
}
.level-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--purple), var(--purple-light));
  border-radius: 7px;
  transition: width 0.6s ease;
}
.level-pts { font-size: 0.85rem; color: var(--text-muted); }

.stat-row { display: flex; gap: 20px; flex-wrap: wrap; }
.stat-item { text-align: center; }
.stat-value { font-size: 1.8rem; font-weight: 800; color: var(--purple); }
.stat-label { font-size: 0.85rem; color: var(--text-muted); }

/* Heatmap */
.heatmap {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.heatmap-cell {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: default;
  transition: transform 0.1s;
}

.heatmap-cell:hover { transform: scale(1.05); }
.heatmap-row-num { font-size: 1.1rem; font-weight: 800; color: white; text-shadow: 0 1px 3px rgba(0,0,0,0.3); }
.heatmap-status { font-size: 0.75rem; color: rgba(255,255,255,0.85); }

.heatmap-legend, .chart-legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.legend-item { display: flex; align-items: center; gap: 5px; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0; }

/* Bar chart */
.bar-chart { display: block; width: 100%; max-width: 320px; }

/* Weakest tasks */
.weak-tasks-list { display: flex; flex-direction: column; gap: 10px; }
.weak-task { display: flex; align-items: center; gap: 8px; }
.weak-task-label { min-width: 80px; font-family: var(--font-mono); font-size: 0.95rem; font-weight: 700; }
.weak-bar-wrap { flex: 1; height: 10px; background: var(--border); border-radius: 5px; overflow: hidden; }
.weak-bar { height: 100%; border-radius: 5px; transition: width 0.5s ease; }
.weak-pct { min-width: 60px; font-size: 0.82rem; color: var(--text-muted); text-align: right; }

/* Badges (dashboard) */
.badges-grid { display: flex; flex-wrap: wrap; gap: 16px; }
.badge-item {
  text-align: center;
  width: 110px;
  padding: 16px 10px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
}
.badge-earned { background: #faf5f0; border-color: var(--purple-light); box-shadow: 0 2px 8px rgba(192, 96, 58, 0.12); }
.badge-locked { opacity: 0.35; }
.badge-icon { font-size: 2.6rem; margin-bottom: 6px; }
.badge-name { font-size: 0.85rem; font-weight: 600; color: var(--text); line-height: 1.3; }

.empty-state { color: var(--text-muted); font-style: italic; font-size: 0.9rem; }

/* ── Settings ─────────────────────────────────────────────────────────────── */
.settings-form { max-width: 560px; }
.settings-section {
  background: white;
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.settings-section h3 { font-size: 1rem; font-weight: 700; color: var(--purple-dark); margin-bottom: 16px; }

.form-group { margin-bottom: 16px; }
.form-group label:first-child {
  display: block;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.form-group input[type=text],
.form-group select {
  width: 100%;
  padding: 12px 14px;
  font-size: 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.2s;
}

.form-group input[type=text]:focus,
.form-group select:focus { border-color: var(--purple); }
.form-group input[type=text]:focus-visible,
.form-group select:focus-visible { outline: 2px solid var(--purple); outline-offset: 2px; }

/* Toggle switch */
.toggle-label {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}

.toggle-label input[type=checkbox] { display: none; }

.toggle-switch {
  width: 46px;
  height: 26px;
  background: var(--border);
  border-radius: 13px;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  top: 3px;
  left: 3px;
  transition: left 0.2s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.toggle-label input:checked + .toggle-switch { background: var(--purple); }
.toggle-label input:checked + .toggle-switch::after { left: 23px; }

.toggle-text { font-size: 1rem; font-weight: 600; }

.module-toggles { display: flex; flex-direction: column; gap: 14px; }

.row-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.row-check-label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 2px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  transition: border-color 0.15s;
}

.row-check-label:hover { border-color: var(--purple); }
.row-check-label input[type=checkbox] { accent-color: var(--purple); }

.settings-actions { margin: 20px 0; }

.file-storage-desc { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 10px; }
.file-storage-status { font-size: 0.95rem; }
.file-ok { color: var(--green); }
.file-none { color: var(--text-muted); }

.danger-zone { border-color: #ffd0d0; background: #fffafa; }
.danger-zone h3 { color: var(--red); }
.danger-zone p { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 14px; }

/* ── Dialog ───────────────────────────────────────────────────────────────── */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 20px;
}

.dialog-box {
  background: white;
  border-radius: var(--radius);
  padding: 28px;
  max-width: 400px;
  width: 100%;
  box-shadow: var(--shadow-lg);
}

.dialog-box h3 { font-size: 1.2rem; margin-bottom: 12px; color: var(--red); }
.dialog-box p { color: var(--text-muted); margin-bottom: 20px; }

.dialog-actions { display: flex; gap: 12px; }

/* ── Animation overlay ────────────────────────────────────────────────────── */
#animation-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  overflow: hidden;
}

/* Confetti */
.confetti-piece {
  position: fixed;
  top: -20px;
  border-radius: 2px;
  animation: confetti-fall linear forwards;
}

@keyframes confetti-fall {
  0%   { transform: translateY(0) rotate(0deg); opacity: 1; }
  80%  { opacity: 1; }
  100% { transform: translateY(105vh) rotate(720deg); opacity: 0; }
}

/* Level-up banner */
.levelup-banner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: white;
  border-radius: var(--radius);
  padding: 28px 40px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: levelup-pop 0.4s ease, levelup-fade 0.4s ease 2.6s forwards;
  border: 3px solid var(--purple);
}

.levelup-icon { font-size: 3.5rem; margin-bottom: 8px; }
.levelup-title { font-size: 1rem; font-weight: 700; color: var(--text-muted); }
.levelup-name { font-size: 1.8rem; font-weight: 800; color: var(--purple); }

@keyframes levelup-pop {
  0%   { transform: translate(-50%,-50%) scale(0.5); opacity: 0; }
  100% { transform: translate(-50%,-50%) scale(1); opacity: 1; }
}

@keyframes levelup-fade {
  100% { opacity: 0; transform: translate(-50%,-50%) scale(0.9); }
}

/* Badge toast */
.badge-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: white;
  border-radius: var(--radius);
  padding: 14px 18px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 14px;
  border-left: 4px solid var(--purple);
  z-index: 1000;
  transform: translateX(120%);
  transition: transform 0.35s ease;
  max-width: 300px;
}

.badge-toast.visible { transform: translateX(0); }

.badge-toast-icon { font-size: 2rem; flex-shrink: 0; }
.badge-toast-title { font-size: 0.8rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; }
.badge-toast-name { font-size: 0.95rem; font-weight: 700; color: var(--text); }

/* Simple toast */
.simple-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: white;
  padding: 12px 24px;
  border-radius: 24px;
  font-size: 0.95rem;
  font-weight: 600;
  z-index: 1001;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.simple-toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Countdown bar ────────────────────────────────────────────────────────── */
.countdown-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 320px;
}

.countdown-bar {
  width: 100%;
  height: 7px;
  background: var(--orange);
  border-radius: 4px;
  transform-origin: left;
  animation: countdown-drain linear forwards;
}

.countdown-bar--blue {
  background: var(--purple-light);
}

@keyframes countdown-drain {
  from { transform: scaleX(1); }
  to   { transform: scaleX(0); }
}

.countdown-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  letter-spacing: 0.2px;
}

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

@keyframes pulse {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* ── Misc ─────────────────────────────────────────────────────────────────── */
.loading-msg {
  text-align: center;
  color: var(--text-muted);
  padding: 40px;
  font-size: 1.1rem;
}

/* ── Uhrzeit level cards ──────────────────────────────────────────────────── */
.uhrzeit-level-cards {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.uhrzeit-level-card {
  flex: 1;
  min-width: 120px;
  padding: 16px 12px;
  border: 2.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: white;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, background-color 0.15s, color 0.15s;
  color: var(--text-muted);
}

.uhrzeit-level-card:hover:not(.active) {
  border-color: var(--purple-light);
  color: var(--purple);
}

.uhrzeit-level-card.active {
  background: var(--purple);
  color: white;
  border-color: var(--purple);
  box-shadow: 0 3px 8px rgba(192, 96, 58, 0.3);
}

.ulc-num {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.ulc-desc {
  font-size: 0.8rem;
  opacity: 0.85;
}

/* ── Clock card ───────────────────────────────────────────────────────────── */
.clock-wrap {
  display: flex;
  justify-content: center;
  margin: 8px 0;
}

.clock-wrap svg {
  width: min(260px, 85vw);
  height: min(260px, 85vw);
}

.clock-prompt {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  text-align: center;
}

.clock-tod-hint {
  font-weight: 400;
  color: #888;
  font-size: 0.95rem;
}

.clock-mc-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 10px;
}

.clock-opt-btn {
  padding: 12px 20px;
  border: 2.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: white;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  color: var(--purple-dark);
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
  min-width: 80px;
}

.clock-opt-btn:hover:not(:disabled) {
  background: var(--purple);
  color: white;
  border-color: var(--purple);
}

.clock-opt-btn:disabled { opacity: 0.7; cursor: default; }

.clock-opt-btn.mc-correct { background: var(--green); color: white; border-color: var(--green); }
.clock-opt-btn.mc-wrong   { background: var(--red);   color: white; border-color: var(--red);   }

.clock-input-row {
  margin-top: 8px;
}

.clock-text-input {
  padding: 10px 14px;
  border: 2.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1.1rem;
  font-weight: 600;
  width: 200px;
  font-family: var(--font-body);
  color: var(--text);
  transition: border-color 0.15s;
}

.clock-text-input:focus { border-color: var(--purple); }
.clock-text-input:focus-visible { outline: 2px solid var(--purple); outline-offset: 2px; }

.clock-hint-btn {
  display: block;
  margin: 6px auto 0;
  padding: 5px 14px;
  font-size: 0.82rem;
  color: #888;
  background: #f5f5f5;
  border: 1.5px solid #ddd;
  border-radius: 20px;
  cursor: default;
  font-family: var(--font-body);
  user-select: none;
}

.clock-hint-btn:hover {
  background: #efefef;
  color: #555;
}

.diff-clock-toggle {
  cursor: pointer;
  margin: 8px auto;
}

.clock-set-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 4px;
}

/* Diff question */
.diff-prompt {
  font-size: 1.15rem;
  line-height: 1.7;
}

.diff-clock-wrap {
  margin: 10px 0 4px;
  text-align: center;
}

.diff-clock-time {
  font-size: 1rem;
  font-weight: 700;
  color: var(--purple-dark);
  margin-top: 4px;
  min-height: 1.4em;
}

.diff-question-text {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--purple-dark);
  margin-top: 8px;
  text-align: center;
}

.diff-unit {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
  align-self: center;
}

.clock-diff-input {
  width: 90px;
}

/* Diff solution steps */
.correct-clock-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
}

.correct-clock-label {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--green);
}

.diff-steps {
  padding-left: 20px;
  margin: 8px 0;
  font-size: 1rem;
  line-height: 1.8;
  font-weight: 600;
  color: var(--text);
}

/* ── Masse module ─────────────────────────────────────────────────────────── */

/* Config: bereich cards */
.masse-bereich-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 8px;
}
.masse-bereich-card {
  display: flex; flex-direction: column; align-items: center;
  padding: 12px 8px; border-radius: var(--radius-sm);
  border: 2px solid var(--border); background: var(--card-bg);
  cursor: pointer; transition: border-color 0.15s, background-color 0.15s;
  font-family: var(--font-body);
}
.masse-bereich-card:hover { border-color: var(--purple); }
.masse-bereich-card.active { border-color: var(--purple); background: #fdf0ea; }
.mbc-icon { font-size: 1.5rem; margin-bottom: 4px; }
.mbc-name { font-size: 0.85rem; font-weight: 700; color: var(--text); }
.mbc-units { font-size: 0.7rem; color: var(--text-muted); margin-top: 2px; }

/* Bereich color badges */
.masse-badge {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  font-size: 0.8rem; font-weight: 700; margin-bottom: 10px;
}
.masse-ber-laenge   { background: #dbeafe; color: #1e40af; }
.masse-ber-gewicht  { background: #fef3c7; color: #92400e; }
.masse-ber-flaeche  { background: #d1fae5; color: #065f46; }
.masse-ber-hohlmass { background: #ede9fe; color: #5b21b6; }

/* Convert question display */
.masse-convert-q { text-align: center; }
.masse-convert-display {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; flex-wrap: wrap; margin: 8px 0;
}
.masse-from {
  font-size: 2rem; font-weight: 800; color: var(--text);
}
.masse-eq { font-size: 1.8rem; color: var(--text-muted); }
.masse-blank {
  font-size: 2rem; font-weight: 700; color: var(--purple);
  text-decoration: underline dotted;
}
.masse-unit-label {
  font-size: 1.1rem; font-weight: 700; color: var(--text-muted);
  padding: 0 4px;
}

/* Compare question display */
.masse-compare-display {
  display: flex; align-items: center; justify-content: center;
  gap: 16px; margin: 10px 0;
}
.masse-cmp-val { font-size: 1.8rem; font-weight: 800; color: var(--text); }
.masse-cmp-circle { font-size: 2rem; color: var(--purple); }

/* Option buttons row */
.masse-opt-row {
  display: flex; flex-wrap: wrap; gap: 10px;
  justify-content: center; margin: 12px 0;
}
.masse-opt-btn {
  padding: 12px 22px; border-radius: var(--radius-sm);
  border: 2px solid var(--border); background: var(--card-bg);
  font-size: 1rem; font-weight: 700; cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s, color 0.15s; font-family: var(--font-body);
  color: var(--text);
}
.masse-opt-btn:hover:not(:disabled) { border-color: var(--purple); background: #fdf0ea; }
.masse-opt-btn.mc-correct { background: #d1fae5; border-color: var(--green); color: #065f46; }
.masse-opt-btn.mc-wrong   { background: #fee2e2; border-color: var(--red);   color: #991b1b; }
.masse-unit-btn { min-width: 70px; text-align: center; font-size: 1.1rem; }
.masse-cat-btn  { min-width: 110px; font-size: 0.95rem; }

/* Text question */
.masse-text-q {
  font-size: 1.15rem; line-height: 1.6; color: var(--text);
  margin: 8px 0; text-align: center;
}

/* Categorize question */
.masse-cat-q {
  font-size: 1.2rem; text-align: center; margin: 10px 0; color: var(--text);
  line-height: 1.6;
}
.masse-unit-highlight {
  font-size: 1.8rem; font-weight: 900; color: var(--purple);
  display: inline-block; margin: 0 6px;
}

/* Solution steps */
.masse-solution-steps {
  list-style: none; padding: 0;
}
.masse-solution-steps li {
  font-size: 1.05rem; font-weight: 600; color: var(--text);
  padding: 6px 0; border-bottom: 1px solid var(--border);
}
.masse-solution-steps li:last-child { border-bottom: none; }

/* Responsive */
@media (max-width: 480px) {
  .masse-bereich-cards { grid-template-columns: repeat(2, 1fr); }
  .masse-from, .masse-cmp-val { font-size: 1.5rem; }
}

/* ── Level path (Dashboard) ───────────────────────────────────────────────── */
.lvlpath {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: 18px;
}
.lvlpath-arrow {
  text-align: center;
  font-size: 0.9rem;
  color: var(--border);
  line-height: 1.2;
}
.lvlpath-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
}
.lvlpath-past {
  background: rgba(29,158,117,0.08);
  border-color: rgba(29,158,117,0.25);
  opacity: 0.75;
}
.lvlpath-current {
  background: rgba(192, 96, 58, 0.1);
  border-color: var(--purple-light);
  box-shadow: 0 2px 10px rgba(192, 96, 58, 0.15);
}
.lvlpath-future {
  background: rgba(0,0,0,0.03);
  border-color: var(--border);
  opacity: 0.45;
}
.lvlpath-icon { font-size: 1.6rem; flex-shrink: 0; }
.lvlpath-info { flex: 1; min-width: 0; }
.lvlpath-name { font-weight: 700; font-size: 0.95rem; }
.lvlpath-current .lvlpath-name { color: var(--purple-dark); }
.lvlpath-past .lvlpath-name { color: var(--green); }
.lvlpath-future .lvlpath-name { color: var(--text-muted); }
.lvlpath-pts { font-size: 0.78rem; color: var(--text-muted); margin-top: 1px; }
.lvlpath-bar-wrap {
  height: 5px;
  background: var(--border);
  border-radius: 3px;
  margin-top: 5px;
  overflow: hidden;
}
.lvlpath-bar {
  height: 100%;
  border-radius: 3px;
  background: var(--purple);
  transition: width 0.4s ease;
}
.lvlpath-past .lvlpath-bar { background: var(--green); }

/* ── Disabled start button ────────────────────────────────────────────────── */
#start-einmaleins:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Written arithmetic column display ───────────────────────────────────── */

.arith-display {
  display: flex;
  justify-content: center;
  margin: 8px 0;
}

.arith-column {
  display: inline-flex;
  flex-direction: column;
  font-family: var(--font-mono);
  font-size: 2.4rem;
  font-weight: 700;
  line-height: 1.4;
  gap: 0;
}

.arith-row {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
}

.arith-cell {
  width: 1.1em;
  text-align: center;
  display: inline-block;
}

.arith-op-cell {
  width: 1em;
  text-align: right;
  display: inline-block;
}

.arith-sep {
  border-top: 3px solid var(--text);
  margin: 4px 0 2px;
  width: 100%;
}

.arith-carry-row .arith-cell,
.arith-borrow-row .arith-cell {
  font-size: 0.55em;
  color: var(--orange);
  font-weight: 700;
  vertical-align: bottom;
  line-height: 1;
}

.arith-carry-row .arith-op-cell,
.arith-borrow-row .arith-op-cell {
  font-size: 0.55em;
}

.arith-borrow-row .arith-cell sup {
  font-size: 0.7em;
  vertical-align: super;
}

.arith-result-row .arith-cell {
  color: var(--purple-dark);
}

/* Level cards for Addition/Subtraction (same style as division-level-card) */
.arith-level-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.arith-level-card {
  padding: 14px 18px;
  border: 2.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: white;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
  font-family: var(--font-body);
}

.arith-level-card:hover { border-color: var(--purple-light); background: #faf5f0; }
.arith-level-card.active { border-color: var(--purple); background: #fdf0ea; }

.alc-num {
  font-weight: 700;
  font-size: 1rem;
  color: var(--purple-dark);
  margin-bottom: 2px;
}

.alc-desc {
  font-size: 0.88rem;
  color: var(--text-muted);
}

/* ── Responsive ───────────────────────────────────────────────────────────── */

/* Tablet & large phones */
@media (max-width: 600px) {
  .question-text { font-size: 2.2rem; }
  .mc-btn { font-size: 1.5rem; min-width: 80px; padding: 16px 18px; }
  .answer-input-field { width: 120px; font-size: 1.5rem; }
  .module-cards { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .heatmap { grid-template-columns: repeat(5, 1fr); }
  .calc-display { font-size: 1.2rem; }

  main { padding: 0 12px 40px; }
  .module-config { padding: 20px 14px; max-width: 100%; }

  /* Header: stack title + stats, both centered */
  header { padding: 10px 16px; }
  .header-inner { flex-direction: column; align-items: center; gap: 8px; }
  .header-stats { justify-content: center; flex-wrap: nowrap; gap: 6px; }
  .header-stat { padding: 4px 10px; font-size: 0.85rem; }
  .level-badge { display: none; }

  .clock-opt-btn { padding: 10px 14px; font-size: 1rem; min-width: 70px; min-height: 48px; }
  .clock-mc-options { gap: 10px; }

  .nav-btn { gap: 6px; padding: 8px 10px; }
  .nav-label { font-size: 0.88rem; }
  .nav-icon { width: 26px; height: 26px; }

  .section-title { font-size: 1.2rem; }
  .diff-btn, .type-btn { padding: 10px 14px; font-size: 0.88rem; min-height: 44px; }
  .row-btn { min-width: 52px; min-height: 48px; }
}

/* Small phones */
@media (max-width: 480px) {
  .masse-bereich-cards { grid-template-columns: repeat(2, 1fr); }
  .masse-from, .masse-cmp-val { font-size: 1.5rem; }

  /* Header: hide title, stats only */
  header { padding: 8px 12px; }
  .app-title { display: none; }
  .header-inner { gap: 4px; }
  .header-stats { gap: 5px; }
  .header-stat { padding: 4px 9px; font-size: 0.8rem; }

  #main-nav { gap: 6px; padding: 10px 10px 0; }
  .nav-label { font-size: 0.8rem; }

  .question-text { font-size: 1.9rem; }
  .mc-btn { font-size: 1.3rem; padding: 14px 16px; }

  .feed-card { padding: 18px 14px; }

  .module-card { padding: 20px 12px; }
  .module-icon { font-size: 2rem; }
  .module-name { font-size: 0.95rem; }
}

/* ── Division module ──────────────────────────────────────────────────────── */
.div-inverse-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.div-remainder-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.div-rest-label {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-muted);
}

.div-remainder-input { width: 90px !important; }

/* Division config level cards (same style as uhrzeit) */
.division-level-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 4px;
}

.division-level-card {
  background: white;
  border: 2.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.18s, background 0.18s;
  font-family: var(--font-body);
}

.division-level-card:hover { border-color: var(--purple-light); }
.division-level-card.active {
  border-color: var(--purple);
  background: #f5f3ff;
}

.dlc-num { font-weight: 700; color: var(--purple-dark); font-size: 0.95rem; }
.dlc-desc { font-size: 0.85rem; color: var(--text-muted); margin-top: 2px; }

/* Medium solution steps */
.div-medium-steps {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  line-height: 2;
  background: #faf5f0;
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin: 10px 0;
  color: var(--purple-dark);
}

.div-medium-step { display: block; }

/* Hard solution steps */
.div-hard-steps {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0;
}

.div-hard-step {
  display: flex;
  gap: 10px;
  align-items: baseline;
  background: #faf5f0;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.div-step-hidden { opacity: 0; transform: translateY(6px); }
.div-step-visible { opacity: 1; transform: translateY(0); }

.div-step-num {
  font-weight: 700;
  color: var(--purple);
  font-size: 0.9rem;
  flex-shrink: 0;
  min-width: 22px;
}

.div-step-text {
  font-size: 0.92rem;
  color: var(--text);
  line-height: 1.5;
  font-family: var(--font-mono);
}

.div-result-line {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--green);
  padding: 10px 14px;
  background: rgba(29,158,117,0.08);
  border-radius: var(--radius-sm);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

/* ── Login Screen ─────────────────────────────────────────────────────────── */

.login-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
}

.login-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 40px 32px;
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.login-logo-img {
  width: 120px;
  height: 120px;
  object-fit: contain;
  border-radius: 24px;
  margin-bottom: 8px;
}

.login-title {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--purple);
  margin-bottom: 28px;
}

.login-form .form-group {
  text-align: left;
  margin-bottom: 16px;
}

.login-form label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.login-form input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: var(--font-body);
  color: var(--text);
  background: white;
  transition: border-color 0.2s;
}

.login-form input:focus {
  border-color: var(--purple);
}
.login-form input:focus-visible { outline: 2px solid var(--purple); outline-offset: 2px; }

.login-error {
  background: rgba(224, 92, 92, 0.12);
  color: var(--red);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 14px;
  text-align: left;
}

.login-btn {
  width: 100%;
  padding: 14px;
  font-size: 1.05rem;
  margin-top: 4px;
}

.login-help {
  margin-top: 24px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.login-help a {
  color: var(--purple);
  text-decoration: none;
}

.logout-btn {
  width: 100%;
  opacity: 0.7;
  font-size: 0.9rem;
}

/* ── Asset images ─────────────────────────────────────────────────────────── */

/* Logo in header — cropped to head only */
.app-logo {
  width: 38px;
  height: 38px;
  object-fit: cover;
  object-position: center 12%;
  border-radius: 10px;
  vertical-align: middle;
  margin-right: 6px;
}

/* Nav icons */
.nav-btn .nav-icon {
  width: 64px;
  height: 64px;
  object-fit: contain;
  display: block;
  flex-shrink: 0;
}

/* Module card images */
.module-card .module-icon {
  width: 110px;
  height: 110px;
  object-fit: contain;
  display: block;
  margin: 0 auto 8px;
  border-radius: 0;
  background: none;
}

/* Badge grid images — override font-size rule for img tags */
img.badge-icon {
  width: 88px;
  height: 88px;
  object-fit: contain;
  display: block;
  margin: 0 auto 6px;
  font-size: 0; /* suppress alt text layout */
}

/* Lock placeholder for unearned badges */
.badge-lock-icon {
  font-size: 2.8rem;
  line-height: 1;
  display: block;
  text-align: center;
  margin: 0 auto 6px;
  width: 88px;
  height: 88px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.badge-name-locked {
  color: var(--text-muted);
  font-style: italic;
}

/* Badge strip images */
img.bs-badge-icon {
  width: 80px;
  height: 80px;
  object-fit: contain;
  display: block;
  margin: 0 auto 4px;
}

/* Level path rank images */
img.lvlpath-icon-img {
  width: 72px;
  height: 72px;
  object-fit: contain;
  border-radius: 12px;
  flex-shrink: 0;
}

/* Badge toast image */
img.badge-toast-icon {
  width: 48px;
  height: 48px;
  object-fit: contain;
  flex-shrink: 0;
}

/* Level-up banner image */
img.levelup-icon {
  width: 80px;
  height: 80px;
  object-fit: contain;
}

/* ── Geld Module ──────────────────────────────────────────────────────────── */
.geld-receipt {
  background: #fafafa;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 12px 16px;
  font-family: var(--font-mono);
  max-width: 320px;
  margin: 0 auto;
}

.geld-receipt-title {
  font-weight: bold;
  font-size: 1em;
  margin-bottom: 8px;
  font-family: var(--font-body);
  text-align: center;
  color: #444;
}

.geld-receipt-row {
  display: flex;
  justify-content: space-between;
  padding: 2px 0;
  font-size: 0.95em;
  color: #333;
  gap: 12px;
}
.geld-receipt-row span:first-child {
  font-family: var(--font-body);
}
.geld-receipt-row span:last-child,
.geld-receipt-total span:last-child {
  font-family: var(--font-mono);
  white-space: nowrap;
  text-align: right;
}

.geld-receipt-sep {
  border-top: 1px dashed #ccc;
  margin: 6px 0;
}

.geld-receipt-total {
  display: flex;
  justify-content: space-between;
  font-weight: bold;
  font-size: 1em;
  color: #222;
}

.geld-chf-prefix {
  font-weight: bold;
  color: #444;
  font-size: 1em;
  line-height: 1;
  align-self: center;
  margin-right: 4px;
}

.geld-coins-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  padding: 12px 0;
}

.geld-coin-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.geld-coin-img {
  display: block;
  object-fit: contain;
  user-select: none;
}

.geld-question-text {
  font-size: 1em;
  color: #444;
  margin-bottom: 4px;
  line-height: 1.5;
  text-align: center;
}

.geld-amount-highlight {
  font-weight: bold;
  color: #2d7a2d;
}

.geld-mc-btn {
  background: var(--card-bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 28px;
  font-size: 1.1em;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  color: var(--text);
}

.geld-mc-btn:hover:not(:disabled) {
  background: var(--purple);
  color: white;
  border-color: var(--purple);
  transform: translateY(-1px);
}

.geld-mc-btn:disabled {
  cursor: default;
  opacity: 0.7;
}

.geld-mc-btn.mc-correct {
  background: var(--green) !important;
  border-color: var(--green) !important;
  color: white !important;
}

.geld-mc-btn.mc-wrong {
  background: var(--red) !important;
  border-color: var(--red) !important;
  color: white !important;
}

.geld-solution {
  background: #f0f7f0;
  border: 1px solid #c8e6c8;
  border-radius: 8px;
  padding: 12px 16px;
  margin: 8px auto 0;
  max-width: 320px;
  font-size: 0.92em;
  font-family: var(--font-mono);
}

.geld-solution-step {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 0;
  color: #333;
}
.geld-solution-step .geld-sol-label {
  font-family: var(--font-body);
  color: #555;
  white-space: nowrap;
}
.geld-solution-step .geld-sol-amt {
  font-family: var(--font-mono);
  text-align: right;
  white-space: nowrap;
}
.geld-solution-step.geld-sol-sep {
  border-top: 1px dashed #aaa;
  margin-top: 4px;
  padding-top: 6px;
}
.geld-solution-step strong {
  color: #1a5c1a;
}

.geld-written-block {
  max-width: 280px;
  margin: 8px auto 0;
  font-family: var(--font-mono);
  font-size: 1.05em;
}

.geld-written-row {
  display: flex;
  gap: 8px;
  padding: 2px 0;
}

.geld-written-op {
  width: 16px;
  text-align: right;
  color: #888;
}

.geld-written-val {
  color: #222;
}

.geld-written-sep {
  border-top: 1px solid #bbb;
  margin: 6px 0;
}

.geld-input {
  width: 100px;
  text-align: right;
  font-size: 1em;
  padding: 8px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
}

/* ── Hint block ───────────────────────────────────────────────────────────── */

.fc-fb--hint .fc-fb-row { color: var(--orange); }

.hint-steps {
  margin: 0 0 14px 0;
  padding-left: 1.4em;
  line-height: 2.1;
  font-size: 1rem;
  color: var(--text);
}

.hint-memory {
  font-size: 0.875rem;
  color: var(--text-muted);
  border-top: 1px dashed var(--border);
  padding-top: 10px;
  margin-bottom: 14px;
}

.hint-close-btn {
  width: 100%;
}

/* ── Reduced Motion ───────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  #star-sky { display: none; }
}
