:root {
  --bg: #0f1117;
  --card-bg: #1a1d29;
  --border: #2a2e3f;
  --text: #e6e8f0;
  --text-muted: #9aa0b4;
  --primary: #5b6cff;
  --primary-hover: #4756d6;
  --correct: #2ecc71;
  --wrong: #ff5f5f;
  --skipped: #f5a623;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px 60px;
}

.app-header {
  text-align: center;
  margin-bottom: 24px;
}

.app-header h1 {
  margin: 0 0 4px;
  font-size: 28px;
}

.subtitle {
  color: var(--text-muted);
  margin: 0;
  font-size: 14px;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.card h2 {
  margin-top: 0;
}

.field {
  margin-bottom: 20px;
}

.field label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  color: var(--text-muted);
}

select#topic-select {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
}

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

.count-btn {
  flex: 1;
  min-width: 60px;
  padding: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
  transition: all 0.15s;
}

.count-btn:hover {
  border-color: var(--primary);
}

.count-btn.selected {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.btn-primary {
  width: 100%;
  padding: 14px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

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

.btn-primary.hidden {
  display: none;
}

.secondary-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.btn-secondary {
  flex: 1;
  min-width: 140px;
  padding: 11px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--primary);
}

.btn-secondary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.mastery-block {
  margin-top: 28px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
  display: none;
}

.mastery-block h3 {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0 0 12px;
}

.mastery-row {
  margin-bottom: 10px;
}

.mastery-row-top {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 4px;
}

.mastery-topic-name {
  color: var(--text);
}

.mastery-topic-pct {
  color: var(--text-muted);
}

.mastery-bar-bg {
  height: 6px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.mastery-bar-fill {
  height: 100%;
  background: var(--correct);
  transition: width 0.3s;
}

.history {
  margin-top: 28px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.history h3 {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0 0 10px;
}

#history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 14px;
}

#history-list li {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
}

#history-list li:last-child {
  border-bottom: none;
}

/* Quiz screen */
.quiz-progress {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 14px;
  color: var(--text-muted);
}

.badge {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 13px;
}

.progress-bar {
  height: 6px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 20px;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  width: 0%;
  transition: width 0.3s;
}

#question-text {
  font-size: 19px;
  margin-bottom: 20px;
}

.options-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.option {
  padding: 14px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 15px;
  transition: all 0.15s;
}

.option:hover:not(.disabled) {
  border-color: var(--primary);
}

.option.disabled {
  cursor: default;
}

.option.correct {
  background: rgba(46, 204, 113, 0.15);
  border-color: var(--correct);
}

.option.wrong {
  background: rgba(255, 95, 95, 0.15);
  border-color: var(--wrong);
}

.btn-skip {
  width: 100%;
  margin-top: 12px;
  padding: 11px;
  background: transparent;
  color: var(--text-muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-skip:hover {
  border-color: var(--skipped);
  color: var(--skipped);
}

.btn-skip.hidden {
  display: none;
}

.explanation-box {
  margin-top: 18px;
  padding: 14px 16px;
  background: var(--bg);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text-muted);
}

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

#btn-next {
  margin-top: 20px;
}

/* Result screen */
.result-score {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

#result-score-value {
  font-size: 32px;
  font-weight: 700;
}

.result-breakdown {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
  font-size: 14px;
}

.breakdown-item b {
  font-weight: 700;
}

.breakdown-correct {
  color: var(--correct);
}

.breakdown-wrong {
  color: var(--wrong);
}

.breakdown-skipped {
  color: var(--skipped);
}

.retry-info {
  font-size: 13px;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin: 0 0 20px;
}

.retry-info.hidden {
  display: none;
}

.topic-stats {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
}

.topic-stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
}

.topic-stat-name {
  color: var(--text);
}

.topic-stat-value {
  color: var(--text-muted);
}

/* Flashcards */
.flashcard {
  min-height: 160px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
  margin-bottom: 20px;
}

.flashcard-question {
  font-size: 20px;
  text-align: center;
  padding: 20px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.flashcard-answer {
  padding: 16px 18px;
  background: rgba(46, 204, 113, 0.08);
  border: 1px solid var(--correct);
  border-radius: var(--radius);
}

.flashcard-answer.hidden {
  display: none;
}

.flashcard-answer-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 6px;
}

.flashcard-answer-text {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 10px;
}

.flashcard-explanation {
  font-size: 14px;
  color: var(--text-muted);
}

.flash-assess {
  display: flex;
  gap: 8px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.flash-assess.hidden {
  display: none;
}

.btn-assess {
  flex: 1;
  min-width: 90px;
  padding: 12px 8px;
  border-radius: var(--radius);
  border: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn-assess:hover {
  opacity: 0.85;
}

.btn-assess-forgot {
  background: rgba(255, 95, 95, 0.15);
  border: 1px solid var(--wrong);
  color: var(--wrong);
}

.btn-assess-hard {
  background: rgba(245, 166, 35, 0.15);
  border: 1px solid var(--skipped);
  color: var(--skipped);
}

.btn-assess-good {
  background: rgba(46, 204, 113, 0.15);
  border: 1px solid var(--correct);
  color: var(--correct);
}

.btn-assess-easy {
  background: rgba(91, 108, 255, 0.15);
  border: 1px solid var(--primary);
  color: var(--primary);
}

.flash-recall-box {
  padding: 16px 18px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.flash-recall-label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.flash-recall-input {
  width: 100%;
  padding: 10px 12px;
  background: var(--card-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
}

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

.flash-done {
  text-align: center;
  padding: 20px 0;
}

.flash-done.hidden {
  display: none;
}

.flash-done p {
  color: var(--text-muted);
  margin-bottom: 16px;
}
