* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Dark Midnight Theme */
  --bg-primary: #0f1419;
  --bg-secondary: #1a1f26;
  --bg-card: #252d38;
  --text-primary: #f0f4f8;
  --text-secondary: #cbd5e1;
  --accent-primary: #6366f1;
  --accent-secondary: #818cf8;
  --gradient-primary: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  --card-bg: rgba(37, 45, 56, 0.7);
  --success-color: #10b981;
  --error-color: #ef4444;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

body.light-theme {
  /* Light Frost Theme */
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-card: #f1f5f9;
  --text-primary: #1e293b;
  --text-secondary: #475569;
  --accent-primary: #6366f1;
  --accent-secondary: #818cf8;
  --gradient-primary: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  --card-bg: rgba(241, 245, 249, 0.95);
  --success-color: #059669;
  --error-color: #dc2626;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  color: var(--text-primary);
  transition: background 0.3s ease, color 0.3s ease;
}

.container {
  max-width: 900px;
  width: 100%;
}

/* Screen Management */
.screen {
  display: none;
  animation: fadeIn 0.3s ease-in;
}

.screen.active {
  display: block;
}

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

/* Settings Button and Modal */
.settings-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 100;
}

.btn-settings {
  width: 50px;
  height: 50px;
  padding: 0;
  border-radius: 50%;
  background: var(--gradient-primary);
  color: white;
  font-size: 1.3em;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.btn-settings:hover {
  transform: scale(1.1) rotate(90deg);
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.5);
}

.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 30px;
  max-width: 400px;
  width: 90%;
  box-shadow: var(--shadow);
  border: 1px solid rgba(99, 102, 241, 0.1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 25px;
  padding-bottom: 15px;
  border-bottom: 1px solid rgba(99, 102, 241, 0.1);
}

.modal-header h2 {
  color: var(--text-primary);
  margin: 0;
  font-size: 1.5em;
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.8em;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.3s;
}

.close-btn:hover {
  color: var(--text-primary);
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.setting-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.setting-label {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-primary);
  cursor: pointer;
  flex: 1;
}

.setting-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--accent-primary);
}

.theme-select {
  padding: 8px 12px;
  border: 2px solid rgba(99, 102, 241, 0.3);
  border-radius: 8px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 0.95em;
  transition: all 0.3s ease;
}

.theme-select:hover,
.theme-select:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.2);
  outline: none;
}

/* Quiz Selection Screen */
.selection-content {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 40px 30px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(99, 102, 241, 0.1);
}

.selection-content h1 {
  text-align: center;
  color: var(--text-primary);
  font-size: 2.5em;
  margin-bottom: 10px;
}

.subtitle {
  text-align: center;
  color: var(--text-secondary);
  font-size: 1.1em;
  margin-bottom: 40px;
}

/* Streak Display */
.streak-display {
  display: flex;
  justify-content: center;
  gap: 40px;
  margin: 30px 0 50px 0;
  padding: 20px;
  background: rgba(99, 102, 241, 0.08);
  border-radius: 12px;
  border: 1px solid rgba(99, 102, 241, 0.1);
}

.streak-item {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.streak-label {
  color: var(--text-secondary);
  font-size: 0.9em;
  font-weight: 500;
}

.streak-value {
  color: var(--accent-primary);
  font-size: 2em;
  font-weight: 700;
}

/* Breadcrumb Navigation */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  font-size: 0.95em;
  color: var(--text-secondary);
}

.breadcrumb-link {
  background: none;
  border: none;
  color: var(--accent-primary);
  cursor: pointer;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.3s ease;
  padding: 4px 8px;
  border-radius: 6px;
}

.breadcrumb-link:hover {
  color: white;
  background: var(--accent-primary);
}

.breadcrumb-sep {
  color: var(--text-secondary);
}

/* Chapter Cards */
.chapter-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 30px;
  margin-top: 30px;
}

.chapter-card {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 30px;
  text-align: center;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  cursor: pointer;
  border: 1px solid rgba(99, 102, 241, 0.15);
  position: relative;
}

.chapter-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 20px 40px rgba(99, 102, 241, 0.15);
}

.chapter-icon {
  font-size: 3em;
  margin-bottom: 15px;
}

.chapter-card h2 {
  color: var(--text-primary);
  margin-bottom: 10px;
  font-size: 1.3em;
}

.chapter-card p {
  color: var(--text-secondary);
  margin-bottom: 20px;
  font-size: 0.95em;
}

.chapter-completion {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  margin-bottom: 20px;
  padding: 12px;
  background: rgba(99, 102, 241, 0.08);
  border-radius: 8px;
}

.completion-badge {
  font-size: 1.2em;
}

.completion-text {
  color: var(--text-secondary);
  font-size: 0.9em;
}

.completion-percentage {
  font-weight: 600;
  color: var(--accent-primary);
}

/* Chapter Header */
.chapter-header {
  margin-bottom: 40px;
}

.chapter-header h1 {
  color: var(--text-primary);
  margin-bottom: 10px;
}

.chapter-header .subtitle {
  color: var(--text-secondary);
}

.chapter-progress {
  display: flex;
  justify-content: center;
  margin-top: 30px;
}

.progress-ring-container {
  position: relative;
  width: 150px;
  height: 150px;
}

.progress-ring-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.progress-ring-bg {
  fill: none;
  stroke: rgba(99, 102, 241, 0.1);
  stroke-width: 8;
}

.progress-ring-fill {
  fill: none;
  stroke: var(--accent-primary);
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.5s ease;
  stroke-dasharray: 282.7;
  stroke-dashoffset: 282.7;
}

.progress-text-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.progress-percentage {
  font-size: 1.5em;
  font-weight: 700;
  color: var(--accent-primary);
}

.progress-label {
  font-size: 0.85em;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Quiz Cards */
.quiz-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

.quiz-card {
  position: relative;
}

.quiz-card-status {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--success-color);
  color: white;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.8em;
  font-weight: 600;
}

.quiz-card-score {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(99, 102, 241, 0.9);
  color: white;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.85em;
  font-weight: 600;
}

.quiz-card {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 30px;
  text-align: center;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  cursor: pointer;
  border: 1px solid rgba(99, 102, 241, 0.15);
}

.quiz-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 20px 40px rgba(99, 102, 241, 0.15);
}

.quiz-icon {
  font-size: 3em;
  margin-bottom: 15px;
}

.quiz-card h2 {
  color: var(--text-primary);
  margin-bottom: 10px;
}

.quiz-card p {
  color: var(--text-secondary);
  margin-bottom: 20px;
  font-size: 0.95em;
}

/* Mode Selection Screen */
.mode-content {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 40px 30px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(99, 102, 241, 0.1);
}

.mode-content h1 {
  text-align: center;
  color: var(--text-primary);
  font-size: 2.5em;
  margin-bottom: 10px;
}

.mode-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin: 40px 0;
}

.mode-card {
  background: var(--gradient-primary);
  border-radius: 12px;
  padding: 30px;
  text-align: center;
  color: white;
  transition: transform 0.3s, box-shadow 0.3s;
}

.mode-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 15px 30px rgba(0, 188, 212, 0.3);
}

.mode-icon {
  font-size: 3em;
  margin-bottom: 15px;
}

.mode-card h2 {
  margin-bottom: 10px;
  font-size: 1.5em;
}

.mode-card p {
  margin-bottom: 20px;
  opacity: 0.9;
}

.mode-content .btn-secondary {
  margin-top: 30px;
}

/* Quiz Taking Screen */
.quiz-content {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 40px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(99, 102, 241, 0.1);
}

.quiz-header h1 {
  color: var(--text-primary);
  margin-bottom: 20px;
}

.progress-bar {
  height: 8px;
  background: rgba(99, 102, 241, 0.1);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 10px;
}

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

.progress-text {
  color: var(--text-secondary);
  font-size: 0.9em;
  margin-bottom: 30px;
}

.question-container {
  margin: 30px 0;
  animation: slideIn 0.3s ease;
}

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

#question-text {
  color: var(--text-primary);
  font-size: 1.3em;
  margin-bottom: 25px;
  line-height: 1.6;
}

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

.option {
  padding: 15px 18px;
  border: 2px solid var(--text-secondary);
  border-radius: 10px;
  cursor: pointer;
  background: var(--bg-card);
  color: var(--text-primary);
  transition: all 0.3s ease;
  font-size: 1em;
}

.option:hover {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: white;
  transform: translateX(4px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

.option.selected {
  background: var(--accent-primary);
  color: white;
  border-color: var(--accent-primary);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

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

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

.quiz-controls {
  display: flex;
  gap: 15px;
  margin-top: 40px;
  justify-content: space-between;
}

/* Results Screen */
.results-content {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 40px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(99, 102, 241, 0.1);
}

.results-content h1 {
  text-align: center;
  color: var(--text-primary);
  margin-bottom: 30px;
  font-size: 2em;
}

.score-display {
  text-align: center;
  margin: 40px 0;
}

.score-circle {
  width: 150px;
  height: 150px;
  margin: 0 auto;
  background: var(--gradient-primary);
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: white;
}

#final-score {
  font-size: 3em;
  font-weight: bold;
  margin: 0;
}

.score-circle p:last-child {
  font-size: 0.9em;
  opacity: 0.9;
}

.results-feedback {
  text-align: center;
  margin: 20px 0;
  font-size: 1.1em;
  color: var(--text-secondary);
}

.results-breakdown {
  background: var(--bg-secondary);
  border-radius: 8px;
  padding: 20px;
  margin: 30px 0;
  border: 1px solid rgba(99, 102, 241, 0.1);
}

.results-breakdown h3 {
  color: var(--text-primary);
  margin-bottom: 15px;
}

#results-summary {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.result-item {
  background: var(--bg-card);
  padding: 15px;
  border-radius: 8px;
  border-left: 4px solid var(--accent-primary);
}

.result-item.correct {
  border-left-color: #4caf50;
}

.result-item.incorrect {
  border-left-color: #f44336;
}

.result-item-question {
  font-weight: bold;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.result-item-answer {
  color: var(--text-secondary);
  font-size: 0.95em;
}

.results-controls {
  display: flex;
  gap: 15px;
  justify-content: center;
  margin-top: 30px;
  flex-wrap: wrap;
}

/* Learn Mode Screen */
.learn-content {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 40px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(99, 102, 241, 0.1);
}

.learn-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  flex-wrap: wrap;
  gap: 20px;
}

.learn-header h1 {
  color: var(--text-primary);
  margin: 0;
}

#learn-questions-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.learn-card {
  background: var(--bg-secondary);
  border-radius: 10px;
  padding: 20px;
  border-left: 4px solid var(--accent-primary);
  border: 1px solid rgba(99, 102, 241, 0.1);
  border-left: 4px solid var(--accent-primary);
}

.learn-card-number {
  color: var(--accent-primary);
  font-weight: bold;
  margin-bottom: 8px;
  font-size: 0.9em;
}

.learn-card-question {
  color: var(--text-primary);
  font-weight: bold;
  margin-bottom: 15px;
  font-size: 1.1em;
}

.learn-card-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.learn-option {
  padding: 10px 15px;
  background: var(--bg-card);
  border-radius: 8px;
  border: 1px solid rgba(99, 102, 241, 0.1);
  color: var(--text-secondary);
  font-size: 0.95em;
}

.learn-option.correct {
  background: rgba(16, 185, 129, 0.1);
  border-color: var(--success-color);
  color: var(--success-color);
  font-weight: 500;
}

/* Buttons */
.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 10px;
  font-size: 1em;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.btn-primary {
  background: var(--gradient-primary);
  color: white;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.4);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--accent-primary);
  border: 2px solid var(--accent-primary);
}

.btn-secondary:hover {
  background: var(--accent-primary);
  color: white;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

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

/* Responsive Design */
@media (max-width: 768px) {
  .selection-content,
  .mode-content,
  .quiz-content,
  .results-content,
  .learn-content {
    padding: 20px;
  }

  .selection-content h1,
  .mode-content h1,
  .results-content h1 {
    font-size: 1.8em;
  }

  .quiz-cards,
  .mode-cards {
    grid-template-columns: 1fr;
  }

  .quiz-controls {
    flex-direction: column;
  }

  .btn {
    padding: 10px 20px;
    font-size: 0.95em;
  }

  .score-circle {
    width: 120px;
    height: 120px;
  }

  #final-score {
    font-size: 2.2em;
  }

  .learn-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 480px) {
  .selection-content,
  .mode-content,
  .quiz-content,
  .results-content,
  .learn-content {
    padding: 15px;
  }

  .quiz-icon,
  .mode-icon {
    font-size: 2em;
  }

  .option,
  .learn-option {
    padding: 12px;
    font-size: 0.9em;
  }

  #question-text {
    font-size: 1.1em;
  }

  .results-controls {
    flex-direction: column;
  }

  .results-controls .btn {
    width: 100%;
  }
}
