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

:root {
  --bg-dark: #0f0f0f;
  --bg-card: #1a1a1a;
  --primary: #3b82f6;
  --success: #10b981;
  --error: #ef4444;
  --text: #ffffff;
  --text-muted: #9ca3af;
  --border: #333333;
  --transition: 0.3s ease;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-dark);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* -----------------------------------
   Layout & Header
----------------------------------- */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px;
}

header {
  text-align: center;
  margin-bottom: 40px;
  padding: 20px 0;
}

h1 {
  font-size: 2.5rem;
  background: linear-gradient(135deg, #3b82f6, #10b981);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 10px;
}

.subtitle {
  color: var(--text-muted);
  font-size: 1.1rem;
}

/* -----------------------------------
   User Section
----------------------------------- */
.user-section {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  padding: 15px 20px;
  background: var(--bg-card);
  border-radius: 10px;
  border: 1px solid var(--border);
}

.user-name {
  font-size: 1.2rem;
  font-weight: 600;
}

/* -----------------------------------
   Buttons
----------------------------------- */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  transition: all var(--transition);
  display: inline-block;
}

.btn:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

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

.btn-primary:hover {
  background-color: #2563eb;
  transform: translateY(-2px);
}

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

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

/* -----------------------------------
   Inputs
----------------------------------- */
.input-field {
  width: 100%;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-dark);
  color: var(--text);
  font-size: 1rem;
  margin-bottom: 20px;
}

/* -----------------------------------
   Subject Selection
----------------------------------- */
.subjects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
}

.subject-card {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 30px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 15px;
}

.subject-card:hover {
  border-color: var(--primary);
  transform: translateY(-5px);
}

.subject-icon {
  font-size: 3rem;
}

.subject-name {
  font-size: 1.5rem;
  font-weight: 700;
}

/* -----------------------------------
   Quiz Section
----------------------------------- */
.quiz-container {
  display: none;
}

#backToSubjectsBtn {
  display: none;
}

.quiz-container.active {
  display: block;
}

.quiz-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 2px solid var(--border);
}

.quiz-info {
  color: var(--text-muted);
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--bg-card);
  border-radius: 10px;
  margin-bottom: 30px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #10b981);
  transition: width 0.4s ease;
}

/* -----------------------------------
   Question Card
----------------------------------- */
.question-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 30px;
  margin-bottom: 30px;
  animation: fadeIn 0.4s ease;
}

.question-text {
  font-size: 1.4rem;
  font-weight: 600;
  margin-bottom: 25px;
  line-height: 1.6;
}

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

.option {
  background: var(--bg-dark);
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 15px 20px;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 12px;
}

.option:hover {
  border-color: var(--primary);
  background: #1a1a2e;
}

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

/* Visual feedback for answers */
.option.correct {
  border-color: var(--success);
  background: rgba(16, 185, 129, 0.1);
}

.option.incorrect {
  border-color: var(--error);
  background: rgba(239, 68, 68, 0.1);
}

/* -----------------------------------
   Buttons Group
----------------------------------- */
.button-group {
  display: flex;
  gap: 12px;
  margin-top: 30px;
}

.button-group .btn {
  flex: 1;
}

/* -----------------------------------
   Answer Modal
----------------------------------- */
.answer-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  transition: opacity var(--transition);
}

.answer-modal.active {
  display: flex;
  animation: fadeIn 0.4s ease;
}

.answer-modal-content {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 24px;
  max-width: 380px;
  width: 90%;
  border: 1px solid var(--border);
  text-align: center;
  animation: scaleUp 0.3s ease;
}

.answer-result {
  width: 70px;
  height: 70px;
  margin: 0 auto 16px;
  border: 3px solid var(--success);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  background: transparent;
}

.answer-result.incorrect {
  border-color: var(--error);
}

.answer-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--success);
}

.answer-title.incorrect {
  color: var(--error);
}

.correct-answer {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  margin: 12px 0;
  font-weight: 500;
  color: var(--text);
  font-size: 0.9rem;
}

.explanation-text {
  background: transparent;
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.5;
  margin: 12px 0;
}

.continue-btn {
  margin-top: 16px;
  width: 100%;
  padding: 10px 15px;
  font-size: 0.9rem;
}
/* -----------------------------------
   User Info (Top-right small corner)
----------------------------------- */
.user-info {
  position: absolute;
  top: 20px;
  right: 25px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 30px;
  padding: 6px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.user-info span {
  color: var(--primary);
  font-weight: 600;
}

.user-info button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  transition: transform 0.2s ease;
}

.user-info button:hover {
  transform: rotate(20deg);
  color: var(--primary);
}


/* -----------------------------------
   Completion Modal
----------------------------------- */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

.modal.active {
  display: flex;
  animation: fadeIn 0.4s ease;
}

.modal-content {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 40px;
  max-width: 500px;
  text-align: center;
  border: 1px solid var(--border);
  animation: scaleUp 0.3s ease;
}

.modal-title {
  font-size: 2rem;
  margin-bottom: 20px;
  color: var(--success);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 15px;
  margin-bottom: 30px;
}

.stat {
  background: var(--bg-dark);
  padding: 15px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

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

.stat-label {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 5px;
}
/* -----------------------------------
   Difficulty Section
----------------------------------- */
.difficulty-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 25px;
}

.difficulty-card {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 30px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
}

.difficulty-card:hover {
  transform: translateY(-5px);
  border-color: var(--primary);
}

.difficulty-card.easy {
  border-color: var(--success);
}
.difficulty-card.easy:hover {
  background: rgba(16, 185, 129, 0.1);
}

.difficulty-card.medium {
  border-color: #facc15;
}
.difficulty-card.medium:hover {
  background: rgba(250, 204, 21, 0.1);
}

.difficulty-card.hard {
  border-color: var(--error);
}
.difficulty-card.hard:hover {
  background: rgba(239, 68, 68, 0.1);
}

.difficulty-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 10px;
}
/* -----------------------------------
   Scoreboard (Quiz Header)
----------------------------------- */
.scoreboard {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-card);
  padding: 10px 15px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 0.95rem;
  color: var(--text);
  min-width: 260px;
  box-shadow: 0 0 10px rgba(0,0,0,0.3);
}

.scoreboard > div {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 70px;
  gap: 4px;
}

.scoreboard strong {
  color: var(--primary);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.scoreboard div > div {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
}

/* Pulse animation when score increases */
@keyframes scorePulse {
  0% { transform: scale(1); color: var(--text); }
  50% { transform: scale(1.3); color: var(--success); }
  100% { transform: scale(1); color: var(--text); }
}

.score-updated {
  animation: scorePulse 0.5s ease;
}

/* Responsive design */
@media (max-width: 640px) {
  .scoreboard {
    flex-wrap: wrap;
    gap: 10px;
    padding: 8px;
    min-width: 0;
  }

  .scoreboard > div {
    flex: 1 1 30%;
    min-width: 0;
  }

  .scoreboard strong {
    font-size: 0.8rem;
  }

  .scoreboard div > div {
    font-size: 0.9rem;
  }
}
.total-score-display {
  position: absolute;
  top: 20px;
  left: 25px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 16px;
  font-size: 1rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.total-score-display span:first-child {
  font-size: 1.2rem;
}

.total-score-display strong {
  color: var(--primary);
}


/* -----------------------------------
   Animations
----------------------------------- */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleUp {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* -----------------------------------
   Responsive
----------------------------------- */
@media (max-width: 640px) {
  h1 { font-size: 1.8rem; }
  .subjects-grid { grid-template-columns: 1fr; }
  .question-text { font-size: 1.1rem; }
}
