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

:root {
  --bg-primary: #0D1B2A;
  --bg-secondary: #1B2838;
  --bg-card: #243447;
  --accent: #4FC3F7;
  --accent-secondary: #26C6DA;
  --text-primary: #F0F4F8;
  --text-secondary: #A0AEC0;
  --correct: #4CAF50;
  --incorrect: #EF5350;
  --border: #2D3E50;
  --warning: #FFA726;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
}

#app {
  max-width: 800px;
  margin: 0 auto;
  padding: 16px;
}

.screen { display: none; }
.screen.active { display: block; }
.hidden { display: none !important; }

/* Header */
.app-header {
  text-align: center;
  padding: 32px 0 24px;
}
.app-header h1 {
  font-size: 28px;
  color: var(--accent);
  margin-bottom: 4px;
}
.subtitle {
  color: var(--text-secondary);
  font-size: 14px;
}

/* Mode Cards */
.mode-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}
@media (max-width: 600px) {
  .mode-cards { grid-template-columns: 1fr; }
}

.mode-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}
.mode-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(79, 195, 247, 0.15);
}
.mode-card .mode-icon {
  font-size: 36px;
  margin-bottom: 12px;
}
.mode-card h2 {
  font-size: 20px;
  margin-bottom: 4px;
}
.mode-card p {
  color: var(--text-secondary);
  font-size: 14px;
}
.mode-desc {
  margin-top: 8px;
  font-size: 13px !important;
}

/* Stats Summary */
.stats-summary {
  background: var(--bg-secondary);
  border-radius: 8px;
  padding: 16px;
  font-size: 14px;
  color: var(--text-secondary);
}
.stats-summary .stat-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
}
.stats-summary .stat-value {
  color: var(--text-primary);
  font-weight: 600;
}

/* Screen Header */
.screen-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  padding: 8px 0;
}
.screen-header h2 {
  font-size: 20px;
}

.back-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: border-color 0.2s;
}
.back-btn:hover { border-color: var(--accent); }

/* Config Section */
.config-section {
  margin-bottom: 24px;
}
.config-section h3 {
  font-size: 16px;
  margin-bottom: 12px;
  color: var(--accent);
}

.domain-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.domain-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-card);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}
.domain-option input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.count-selector {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.count-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}
.count-btn.active {
  border-color: var(--accent);
  background: rgba(79, 195, 247, 0.1);
  color: var(--accent);
}
.count-btn:hover { border-color: var(--accent); }

.start-btn {
  display: block;
  width: 100%;
  padding: 16px;
  background: var(--accent);
  color: var(--bg-primary);
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 24px;
  transition: opacity 0.2s;
}
.start-btn:hover { opacity: 0.9; }

/* Quiz Screen */
.quiz-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0 12px;
}
.quiz-progress {
  display: flex;
  gap: 16px;
  align-items: center;
}
#quiz-counter {
  font-size: 14px;
  color: var(--text-secondary);
}
.timer {
  background: var(--bg-card);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 14px;
  font-family: monospace;
  color: var(--accent);
}
.timer.warning { color: var(--warning); }
.timer.danger { color: var(--incorrect); }

.progress-bar {
  height: 4px;
  background: var(--bg-secondary);
  border-radius: 2px;
  margin-bottom: 24px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.3s;
  border-radius: 2px;
}

.question-area {
  margin-bottom: 20px;
}
.question-meta {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.domain-badge, .difficulty-badge {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 4px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
}
.difficulty-badge.high { color: var(--incorrect); border: 1px solid var(--incorrect); }
.difficulty-badge.medium { color: var(--warning); border: 1px solid var(--warning); }

.question-text {
  font-size: 15px;
  line-height: 1.8;
  white-space: pre-wrap;
}

/* Choices */
.choices-area {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.choice-btn {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
  transition: all 0.2s;
  width: 100%;
}
.choice-btn:hover:not(.disabled) {
  border-color: var(--accent);
  background: rgba(79, 195, 247, 0.05);
}
.choice-btn .choice-label {
  font-weight: 700;
  color: var(--accent);
  min-width: 20px;
  flex-shrink: 0;
}
.choice-btn.selected {
  border-color: var(--accent);
  background: rgba(79, 195, 247, 0.1);
}
.choice-btn.correct {
  border-color: var(--correct);
  background: rgba(76, 175, 80, 0.1);
}
.choice-btn.correct .choice-label { color: var(--correct); }
.choice-btn.incorrect {
  border-color: var(--incorrect);
  background: rgba(239, 83, 80, 0.1);
}
.choice-btn.incorrect .choice-label { color: var(--incorrect); }
.choice-btn.disabled { cursor: default; opacity: 0.8; }

/* Explanation Area (Review mode) */
.explanation-area {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.result-badge {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 12px;
  padding: 8px 16px;
  border-radius: 8px;
  text-align: center;
}
.result-badge.correct {
  background: rgba(76, 175, 80, 0.1);
  color: var(--correct);
}
.result-badge.incorrect {
  background: rgba(239, 83, 80, 0.1);
  color: var(--incorrect);
}

.explanation-box {
  background: var(--bg-secondary);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}
.explanation-box h4 {
  color: var(--accent);
  margin-bottom: 8px;
  font-size: 14px;
}
.explanation-box p {
  font-size: 14px;
  line-height: 1.8;
  white-space: pre-wrap;
  color: var(--text-secondary);
}

.next-btn {
  display: block;
  width: 100%;
  padding: 14px;
  background: var(--accent);
  color: var(--bg-primary);
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}
.next-btn:hover { opacity: 0.9; }

/* Result Screen */
.result-summary {
  text-align: center;
  padding: 32px 0;
}
.score-circle {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  border: 4px solid var(--accent);
  margin-bottom: 12px;
}
.score-number {
  font-size: 40px;
  font-weight: 700;
  color: var(--accent);
}
.score-label {
  font-size: 16px;
  color: var(--text-secondary);
}
.score-percent {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 8px;
}
.pass-status {
  font-size: 18px;
  font-weight: 700;
}
.pass-status.pass { color: var(--correct); }
.pass-status.fail { color: var(--incorrect); }

.domain-breakdown {
  margin: 24px 0;
}
.domain-breakdown .breakdown-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: var(--bg-card);
  border-radius: 6px;
  margin-bottom: 8px;
  font-size: 13px;
}
.breakdown-item .breakdown-bar {
  width: 100px;
  height: 6px;
  background: var(--bg-secondary);
  border-radius: 3px;
  overflow: hidden;
}
.breakdown-item .breakdown-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s;
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
}
.action-btn {
  padding: 14px;
  background: var(--accent);
  color: var(--bg-primary);
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.action-btn.secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-primary);
}
.action-btn:hover { opacity: 0.9; }

/* Wrong Answers Detail */
#wrong-answers-detail {
  margin-top: 16px;
}
.wrong-item {
  background: var(--bg-card);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
  border-left: 3px solid var(--incorrect);
}
.wrong-item .wrong-q {
  font-size: 14px;
  margin-bottom: 8px;
  line-height: 1.6;
}
.wrong-item .wrong-answer {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.wrong-item .wrong-correct {
  font-size: 13px;
  color: var(--correct);
  margin-bottom: 8px;
}
.wrong-item .wrong-explanation {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  white-space: pre-wrap;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Mobile optimizations */
@media (max-width: 480px) {
  #app { padding: 12px; }
  .app-header { padding: 20px 0 16px; }
  .app-header h1 { font-size: 24px; }
  .question-text { font-size: 14px; }
  .choice-btn { padding: 12px 14px; font-size: 13px; }
}
