* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --purple: #7c3aed;
  --purple-light: #a78bfa;
  --purple-dark: #5b21b6;
  --purple-bg: #f5f3ff;
  --green: #22c55e;
  --green-bg: #dcfce7;
  --red: #ef4444;
  --red-bg: #fee2e2;
  --orange: #f59e0b;
  --orange-bg: #fef3c7;
  --gray: #6b7280;
  --gray-light: #f3f4f6;
  --gray-border: #e5e7eb;
  --text: #1f2937;
  --text-light: #6b7280;
  --radius: 12px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
}
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--purple-bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}
.screen { display: none; padding: 16px; max-width: 600px; margin: 0 auto; padding-bottom: 40px; }
.screen.active { display: block; }

/* Header */
.header { text-align: center; padding: 24px 0 8px; }
.header h1 { font-size: 1.6rem; color: var(--purple-dark); }
.subtitle { color: var(--text-light); font-size: 0.9rem; margin-top: 4px; }
.greeting { text-align: center; font-size: 1.1rem; color: var(--purple); font-weight: 600; margin: 12px 0 20px; }

/* Home cards */
.home-cards { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; margin-bottom: 24px; }
.home-card {
  background: #fff;
  border: 2px solid var(--gray-border);
  border-radius: var(--radius);
  padding: 16px 8px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-family: inherit;
}
.home-card:active { transform: scale(0.96); }
.card-quiz { border-color: var(--purple-light); }
.card-quiz:hover { background: var(--purple-bg); }
.card-progress { border-color: var(--green); }
.card-progress:hover { background: var(--green-bg); }
.card-flash { border-color: var(--orange); }
.card-flash:hover { background: var(--orange-bg); }
.card-vocab { border-color: var(--purple-light); }
.card-vocab:hover { background: var(--purple-bg); }
.card-icon { font-size: 2rem; }
.card-title { font-weight: 700; font-size: 0.95rem; }
.card-desc { font-size: 0.75rem; color: var(--text-light); }

/* Badge shelf */
.badge-shelf { margin-bottom: 20px; }
.badge-shelf h3 { font-size: 0.95rem; color: var(--text-light); margin-bottom: 8px; }
.badge-list { display: flex; flex-wrap: wrap; gap: 8px; }
.badge-item {
  display: flex; align-items: center; gap: 4px;
  background: #fff; border: 1px solid var(--gray-border);
  border-radius: 20px; padding: 4px 10px;
  font-size: 0.8rem;
}
.badge-item.earned { border-color: var(--orange); background: var(--orange-bg); }
.badge-item.locked { opacity: 0.4; filter: grayscale(1); }
.badge-emoji { font-size: 1.1rem; }
.badge-name { font-weight: 600; }

/* Overall stats */
.overall-stats { text-align: center; color: var(--text-light); font-size: 0.85rem; }

/* Version label */
.version-label { text-align: center; color: var(--text-light); font-size: 0.7rem; margin-top: 16px; opacity: 0.5; }

/* Top bar */
.screen-top-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.btn-back {
  background: none; border: none; font-size: 1rem; color: var(--purple);
  cursor: pointer; font-weight: 600; padding: 4px 0; font-family: inherit;
}
h2 { font-size: 1.3rem; color: var(--purple-dark); margin-bottom: 16px; }

/* Config */
.config-section { margin-bottom: 20px; }
.config-label { display: block; font-weight: 600; margin-bottom: 8px; font-size: 0.95rem; }
.hint { font-weight: 400; color: var(--text-light); font-size: 0.8rem; }
.btn-group { display: flex; gap: 8px; }
.btn-option {
  flex: 1; padding: 10px; border: 2px solid var(--gray-border);
  border-radius: var(--radius); background: #fff; font-size: 1.1rem;
  font-weight: 700; cursor: pointer; transition: all 0.2s; font-family: inherit;
}
.btn-option.selected { border-color: var(--purple); background: var(--purple); color: #fff; }
.leerdoel-checkboxes { display: flex; flex-direction: column; gap: 6px; }
.leerdoel-cb {
  display: flex; align-items: center; gap: 8px;
  background: #fff; border: 1px solid var(--gray-border);
  border-radius: 8px; padding: 8px 12px; cursor: pointer;
  font-size: 0.9rem; transition: all 0.15s;
}
.leerdoel-cb.checked { border-color: var(--purple); background: #ede9fe; }
.leerdoel-cb input { display: none; }
.leerdoel-cb-check {
  width: 20px; height: 20px; border: 2px solid var(--gray-border);
  border-radius: 4px; display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; color: #fff; flex-shrink: 0;
}
.leerdoel-cb.checked .leerdoel-cb-check { background: var(--purple); border-color: var(--purple); }
.leerdoel-cb-text { flex: 1; }
.leerdoel-cb-par { color: var(--text-light); font-size: 0.75rem; }

/* Buttons */
.btn-primary {
  display: block; width: 100%; padding: 14px;
  background: var(--purple); color: #fff; border: none;
  border-radius: var(--radius); font-size: 1.05rem;
  font-weight: 700; cursor: pointer; transition: all 0.2s; font-family: inherit;
}
.btn-primary:active { background: var(--purple-dark); transform: scale(0.98); }
.btn-secondary {
  padding: 10px 20px; background: #fff; color: var(--purple);
  border: 2px solid var(--purple); border-radius: var(--radius);
  font-size: 0.95rem; font-weight: 600; cursor: pointer; font-family: inherit;
}
.btn-danger {
  display: block; width: 100%; padding: 12px;
  background: #fff; color: var(--red); border: 2px solid var(--red);
  border-radius: var(--radius); font-size: 0.95rem;
  font-weight: 600; cursor: pointer; font-family: inherit;
}
.btn-danger:active { background: var(--red-bg); }
.btn-start { margin-top: 24px; }

/* Quiz screen */
.quiz-top-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.quiz-progress-text { font-weight: 700; font-size: 0.9rem; color: var(--purple); white-space: nowrap; }
.quiz-progress-bar { flex: 1; height: 6px; background: var(--gray-border); border-radius: 3px; min-width: 60px; }
.quiz-progress-fill { height: 100%; background: var(--purple); border-radius: 3px; transition: width 0.3s; }
.btn-exit {
  background: none; border: 1px solid var(--gray-border); border-radius: 8px;
  padding: 4px 12px; font-size: 0.8rem; color: var(--text-light);
  cursor: pointer; white-space: nowrap; font-family: inherit;
}
.quiz-leerdoel-badge {
  display: inline-block; background: #ede9fe; color: var(--purple-dark);
  font-size: 0.75rem; font-weight: 600; padding: 2px 10px;
  border-radius: 12px; margin-bottom: 10px;
}
.question-card {
  background: #fff; border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow); margin-bottom: 12px;
}
.question-text { font-size: 1.05rem; font-weight: 600; line-height: 1.5; margin-bottom: 16px; }
.question-type-badge {
  display: inline-block; font-size: 0.7rem; background: var(--gray-light);
  color: var(--text-light); padding: 2px 8px; border-radius: 8px; margin-bottom: 12px;
}

/* Question image */
.question-image { width: 100%; max-height: 300px; object-fit: contain; border-radius: 8px; margin-bottom: 12px; }

/* Multiple choice options */
.option-btn {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 12px; margin-bottom: 8px;
  background: #fff; border: 2px solid var(--gray-border);
  border-radius: var(--radius); cursor: pointer;
  font-size: 0.95rem; text-align: left; transition: all 0.15s;
  font-family: inherit; line-height: 1.4;
}
.option-btn:active { transform: scale(0.98); }
.option-letter {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--gray-light); display: flex; align-items: center;
  justify-content: center; font-weight: 700; font-size: 0.85rem;
  flex-shrink: 0; color: var(--text);
}
.option-btn.selected { border-color: var(--purple); background: #ede9fe; }
.option-btn.selected .option-letter { background: var(--purple); color: #fff; }
.option-btn.correct { border-color: var(--green); background: var(--green-bg); }
.option-btn.correct .option-letter { background: var(--green); color: #fff; }
.option-btn.wrong { border-color: var(--red); background: var(--red-bg); }
.option-btn.wrong .option-letter { background: var(--red); color: #fff; }
.option-btn.disabled { pointer-events: none; opacity: 0.7; }
.option-btn.dimmed { opacity: 0.5; }

/* Choose all that apply */
.option-btn .check-box {
  width: 20px; height: 20px; border: 2px solid var(--gray-border);
  border-radius: 4px; display: flex; align-items: center;
  justify-content: center; flex-shrink: 0; font-size: 0.75rem; color: transparent;
}
.option-btn.selected .check-box { background: var(--purple); border-color: var(--purple); color: #fff; }
.option-btn.correct .check-box { background: var(--green); border-color: var(--green); color: #fff; }
.option-btn.wrong .check-box { background: var(--red); border-color: var(--red); color: #fff; }
.btn-submit-multi {
  display: block; width: 100%; padding: 12px; margin-top: 4px;
  background: var(--purple); color: #fff; border: none;
  border-radius: var(--radius); font-size: 1rem; font-weight: 700;
  cursor: pointer; font-family: inherit; opacity: 0.4; pointer-events: none;
}
.btn-submit-multi.active { opacity: 1; pointer-events: auto; }
.cata-hint { font-size: 0.8rem; color: var(--text-light); margin-bottom: 8px; }

/* Invullen */
.invul-container { display: flex; gap: 8px; }
.invul-input {
  flex: 1; padding: 12px; border: 2px solid var(--gray-border);
  border-radius: var(--radius); font-size: 1rem; font-family: inherit;
  outline: none;
}
.invul-input:focus { border-color: var(--purple); }
.invul-input.correct { border-color: var(--green); background: var(--green-bg); }
.invul-input.wrong { border-color: var(--red); background: var(--red-bg); }
.invul-submit {
  padding: 12px 20px; background: var(--purple); color: #fff; border: none;
  border-radius: var(--radius); font-size: 1rem; font-weight: 700;
  cursor: pointer; font-family: inherit;
}
.invul-correct-answer { margin-top: 8px; font-size: 0.9rem; color: var(--green); font-weight: 600; }

/* Volgorde */
.volgorde-list { list-style: none; }
.volgorde-item {
  display: flex; align-items: center; gap: 8px;
  background: #fff; border: 2px solid var(--gray-border);
  border-radius: var(--radius); padding: 10px 12px; margin-bottom: 6px;
  font-size: 0.9rem; transition: all 0.15s; line-height: 1.4;
}
.volgorde-item.correct-pos { border-color: var(--green); background: var(--green-bg); }
.volgorde-item.wrong-pos { border-color: var(--red); background: var(--red-bg); }
.volgorde-num {
  width: 24px; height: 24px; border-radius: 50%; background: var(--gray-light);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.8rem; flex-shrink: 0;
}
.volgorde-text { flex: 1; }
.volgorde-arrows { display: flex; flex-direction: column; gap: 2px; flex-shrink: 0; }
.volgorde-arrows button {
  width: 28px; height: 22px; border: 1px solid var(--gray-border);
  background: #fff; border-radius: 4px; cursor: pointer;
  font-size: 0.7rem; display: flex; align-items: center; justify-content: center;
}
.volgorde-arrows button:active { background: var(--purple-bg); }
.btn-submit-volgorde {
  display: block; width: 100%; padding: 12px; margin-top: 8px;
  background: var(--purple); color: #fff; border: none;
  border-radius: var(--radius); font-size: 1rem; font-weight: 700;
  cursor: pointer; font-family: inherit;
}

/* Feedback */
.feedback-panel {
  background: #fff; border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow); animation: slideUp 0.3s ease;
}
@keyframes slideUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
.feedback-result { font-size: 1.1rem; font-weight: 700; margin-bottom: 4px; }
.feedback-result.correct { color: var(--green); }
.feedback-result.wrong { color: var(--red); }
.feedback-encouragement { font-size: 0.95rem; margin-bottom: 8px; font-style: italic; color: var(--text-light); }
.feedback-explanation {
  font-size: 0.9rem; line-height: 1.5; color: var(--text);
  background: var(--gray-light); padding: 12px; border-radius: 8px;
  margin-bottom: 12px;
}
.btn-next { margin-top: 4px; }

/* Results */
.results-header { text-align: center; margin-bottom: 16px; }
.score-circle { position: relative; width: 130px; height: 130px; margin: 0 auto 12px; }
.score-circle svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.score-bg { fill: none; stroke: var(--gray-border); stroke-width: 8; }
.score-fg { fill: none; stroke: var(--purple); stroke-width: 8; stroke-linecap: round; stroke-dasharray: 339.29; stroke-dashoffset: 339.29; transition: stroke-dashoffset 1s ease; }
.score-text {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  font-size: 2rem; font-weight: 800; color: var(--purple-dark);
}
.results-summary { font-size: 0.95rem; color: var(--text-light); }
.results-encouragement {
  text-align: center; font-size: 1.05rem; font-weight: 600;
  color: var(--purple); margin-bottom: 20px; padding: 0 8px;
}
.results-breakdown { margin-bottom: 20px; }
.results-breakdown h3, .results-missed h3 { font-size: 0.95rem; color: var(--text-light); margin-bottom: 8px; }
.breakdown-row {
  display: flex; align-items: center; gap: 8px; margin-bottom: 6px;
  font-size: 0.85rem;
}
.breakdown-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.breakdown-bar { width: 80px; height: 8px; background: var(--gray-border); border-radius: 4px; flex-shrink: 0; }
.breakdown-bar-fill { height: 100%; border-radius: 4px; transition: width 0.5s; }
.breakdown-pct { width: 36px; text-align: right; font-weight: 600; flex-shrink: 0; }
.missed-item {
  background: #fff; border-radius: 8px; padding: 12px;
  margin-bottom: 8px; border-left: 3px solid var(--red);
}
.missed-q { font-weight: 600; font-size: 0.9rem; margin-bottom: 4px; }
.missed-a { font-size: 0.85rem; color: var(--green); }
.results-actions { display: flex; gap: 12px; margin-top: 20px; }
.results-actions .btn-primary, .results-actions .btn-secondary { flex: 1; }

/* Badge celebration */
.badge-celebration { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-bottom: 16px; }
.new-badge-item { text-align: center; animation: badgePop 0.5s ease; }
@keyframes badgePop { 0% { transform: scale(0); } 50% { transform: scale(1.3); } 100% { transform: scale(1); } }
.new-badge-emoji { font-size: 2.5rem; }
.new-badge-name { font-size: 0.8rem; font-weight: 700; color: var(--purple-dark); }

/* Badge overlay */
.badge-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center; z-index: 100;
  animation: fadeIn 0.3s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.badge-popup {
  background: #fff; border-radius: 20px; padding: 32px; text-align: center;
  max-width: 300px; width: 90%; animation: badgePop 0.5s ease;
}
.badge-popup-icon { font-size: 4rem; margin-bottom: 8px; }
.badge-popup h2 { color: var(--purple-dark); margin-bottom: 4px; }
.badge-popup p { color: var(--text-light); font-size: 0.9rem; }

/* Progress screen */
.overall-progress {
  background: #fff; border-radius: var(--radius); padding: 16px;
  margin-bottom: 16px; text-align: center; box-shadow: var(--shadow);
}
.overall-pct { font-size: 2rem; font-weight: 800; color: var(--purple-dark); }
.overall-detail { font-size: 0.85rem; color: var(--text-light); margin-top: 4px; }
.progress-card {
  background: #fff; border-radius: var(--radius); padding: 14px;
  margin-bottom: 10px; box-shadow: var(--shadow);
}
.progress-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.progress-card-title { font-weight: 700; font-size: 0.9rem; flex: 1; }
.progress-card-badge { font-size: 1.2rem; }
.progress-bar { height: 10px; background: var(--gray-border); border-radius: 5px; overflow: hidden; }
.progress-bar-fill { height: 100%; border-radius: 5px; transition: width 0.5s; }
.progress-card-detail { font-size: 0.8rem; color: var(--text-light); margin-top: 6px; display: flex; justify-content: space-between; }
.reset-section { margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--gray-border); }

/* Flashcards */
.flash-counter { font-size: 0.85rem; color: var(--text-light); font-weight: 600; }
.flash-hint { text-align: center; color: var(--text-light); font-size: 0.85rem; margin-bottom: 12px; }
.flashcard-container { perspective: 1000px; margin-bottom: 16px; }
.flashcard {
  position: relative; width: 100%; min-height: 200px;
  cursor: pointer; transition: transform 0.5s;
  transform-style: preserve-3d;
}
.flashcard.flipped { transform: rotateY(180deg); }
.flashcard-front, .flashcard-back {
  position: absolute; width: 100%; min-height: 200px;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  border-radius: var(--radius); padding: 24px;
  display: flex; align-items: center; justify-content: center;
  text-align: center; line-height: 1.6; font-size: 0.95rem;
  box-shadow: var(--shadow);
}
.flashcard-front { background: #fff; font-weight: 700; font-size: 1.05rem; color: var(--purple-dark); }
.flashcard-back { background: var(--purple); color: #fff; transform: rotateY(180deg); }
.flashcard-back.flashcard-formatted { text-align: left; font-size: 0.85rem; }
.flash-nav { display: flex; gap: 12px; justify-content: center; }
.flash-nav button { flex: 1; max-width: 160px; }
.flash-empty { text-align: center; padding: 40px 20px; }
.flash-empty p { margin-bottom: 16px; color: var(--text-light); }

/* Confetti */
.confetti { position: fixed; top: -10px; width: 10px; height: 10px; border-radius: 2px; z-index: 200; animation: confettiFall linear forwards; pointer-events: none; }
@keyframes confettiFall { to { top: 110vh; transform: rotate(720deg); } }
