/* CSS Variables */
:root {
  --primary: #3498db;
  --primary-dark: #2980b9;
  --success: #27ae60;
  --success-light: #d4edda;
  --error: #e74c3c;
  --error-light: #f8d7da;
  --text: #2c3e50;
  --text-light: #7f8c8d;
  --bg: #f5f6fa;
  --card-bg: #ffffff;
  --border: #dcdde1;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  --radius: 12px;
}

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

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

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
}

/* Screens */
.screen {
  display: none;
}

.screen.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

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

/* Home Screen */
h1 {
  font-size: 2.5rem;
  text-align: center;
  margin-bottom: 0.5rem;
  color: var(--primary);
}

.subtitle {
  text-align: center;
  color: var(--text-light);
  margin-bottom: 2rem;
  font-size: 1rem;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
}

select, input[type="number"] {
  width: 100%;
  padding: 12px 16px;
  font-size: 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  transition: border-color 0.2s;
}

select:focus, input:focus {
  outline: none;
  border-color: var(--primary);
}

.mode-buttons {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.mode-btn {
  flex: 1;
  padding: 16px;
  font-size: 1rem;
  font-weight: 600;
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  background: var(--card-bg);
  color: var(--primary);
  cursor: pointer;
  transition: all 0.2s;
}

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

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

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

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

.hidden {
  display: none !important;
}

/* Quiz Screen */
.quiz-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.mode-indicator {
  background: var(--primary);
  color: white;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.875rem;
  font-weight: 500;
}

#progress-text {
  font-weight: 500;
  color: var(--text-light);
}

.progress-bar-container {
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.question-card {
  background: var(--card-bg);
  padding: 24px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}

.question-text {
  font-size: 1.2rem;
  font-weight: 500;
  line-height: 1.5;
}

.options-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 1.5rem;
}

.option-btn {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  background: var(--card-bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  font-size: 1rem;
}

.option-btn:hover:not(:disabled) {
  border-color: var(--primary);
  transform: translateX(4px);
}

.option-btn.selected {
  border-color: var(--primary);
  background: rgba(52, 152, 219, 0.1);
}

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

.option-btn.incorrect {
  border-color: var(--error);
  background: var(--error-light);
}

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

.option-letter {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--bg);
  border-radius: 50%;
  font-weight: 600;
  flex-shrink: 0;
}

.option-text {
  flex: 1;
  padding-top: 4px;
}

.feedback {
  padding: 16px;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-weight: 500;
  text-align: center;
}

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

.feedback.incorrect {
  background: var(--error-light);
  color: var(--error);
}

.action-buttons {
  display: flex;
  gap: 1rem;
}

.action-btn {
  flex: 1;
  padding: 14px 24px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
}

.action-btn.primary {
  background: var(--primary);
  color: white;
}

.action-btn.primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

.action-btn.primary:disabled {
  background: var(--border);
  cursor: not-allowed;
}

.action-btn.secondary {
  background: var(--card-bg);
  color: var(--text);
  border: 2px solid var(--border);
}

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

/* Results Screen */
h2 {
  text-align: center;
  margin-bottom: 1.5rem;
  font-size: 2rem;
}

.score-card {
  background: var(--card-bg);
  padding: 32px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: center;
  margin-bottom: 2rem;
}

.score-value {
  font-size: 3rem;
  font-weight: 700;
  color: var(--primary);
}

.score-percentage {
  font-size: 1.5rem;
  color: var(--text-light);
  margin-top: 0.5rem;
}

.corrections-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 2rem;
}

.correction-card {
  background: var(--card-bg);
  padding: 20px;
  border-radius: var(--radius);
  border-left: 4px solid var(--border);
}

.correction-card.correct {
  border-left-color: var(--success);
}

.correction-card.incorrect {
  border-left-color: var(--error);
}

.correction-question {
  font-weight: 500;
  margin-bottom: 12px;
}

.correction-answer {
  padding: 8px 12px;
  border-radius: 6px;
  margin-top: 8px;
}

.correction-answer.user-answer.correct {
  background: var(--success-light);
  color: var(--success);
}

.correction-answer.user-answer.incorrect {
  background: var(--error-light);
  color: var(--error);
}

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

/* Responsive */
@media (max-width: 600px) {
  .container {
    padding: 12px;
  }

  h1 {
    font-size: 1.75rem;
  }

  .subtitle {
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
  }

  .mode-buttons {
    flex-direction: column;
  }

  .mode-btn {
    padding: 14px;
  }

  .form-group label {
    font-size: 0.95rem;
  }

  select, input[type="number"] {
    padding: 10px 14px;
    font-size: 16px; /* Prevents iOS zoom on focus */
  }

  .question-card {
    padding: 16px;
  }

  .question-text {
    font-size: 1.05rem;
  }

  .option-btn {
    padding: 12px;
    gap: 10px;
    font-size: 0.95rem;
  }

  .option-letter {
    width: 28px;
    height: 28px;
    font-size: 0.9rem;
  }

  .option-text {
    padding-top: 2px;
  }

  .feedback {
    padding: 12px;
    font-size: 0.95rem;
  }

  .action-buttons {
    flex-direction: column;
  }

  .action-btn {
    padding: 14px 20px;
  }

  .score-card {
    padding: 24px;
  }

  .score-value {
    font-size: 2.5rem;
  }

  .score-percentage {
    font-size: 1.25rem;
  }

  .correction-card {
    padding: 14px;
  }

  .correction-question {
    font-size: 0.95rem;
  }

  .correction-answer {
    font-size: 0.9rem;
    padding: 6px 10px;
  }
}
