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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: #0f0f1a;
  color: #e0e0e0;
  min-height: 100vh;
  overflow-x: hidden;
}

.app-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px;
  min-height: 100vh;
}

.screen {
  display: none;
  animation: fadeIn 0.4s ease;
}

.screen.active {
  display: block;
}

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

.welcome-content {
  text-align: center;
  padding: 30px 0;
}

.welcome-content h1 {
  font-size: 2.5rem;
  margin-bottom: 8px;
  background: linear-gradient(135deg, #4A90D9, #E91E63, #F5A623);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  font-size: 1.1rem;
  color: #888;
  margin-bottom: 10px;
}

.description {
  color: #aaa;
  margin-bottom: 30px;
  line-height: 1.6;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

/* Name Field */
.name-field {
  max-width: 420px;
  margin: 0 auto 28px;
  text-align: left;
}

.name-field label {
  display: block;
  font-size: 0.9rem;
  color: #aaa;
  margin-bottom: 8px;
  font-weight: 600;
}

.name-field input {
  width: 100%;
  background: #12122a;
  border: 2px solid #2a2a4a;
  border-radius: 10px;
  padding: 12px 16px;
  color: #fff;
  font-size: 1rem;
  outline: none;
  transition: all 0.2s;
}

.name-field input:focus {
  border-color: #4A90D9;
}

.name-field input.input-error {
  border-color: #E74C3C;
}

.name-hint {
  display: none;
  color: #E74C3C;
  font-size: 0.8rem;
  margin-top: 8px;
}

.name-hint.show {
  display: block;
}

.result-student {
  font-size: 1.6rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
}

/* Chapter Grid */
.chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.chapter-card {
  background: #1a1a2e;
  border: 2px solid #2a2a4a;
  border-radius: 16px;
  padding: 24px 16px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
}

.chapter-card:hover {
  transform: translateY(-4px);
  border-color: var(--card-color);
  background: #1f1f35;
  box-shadow: 0 8px 30px rgba(0,0,0,0.3);
}

.chapter-card .icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  display: block;
}

.chapter-card .chapter-number {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: #666;
  margin-bottom: 6px;
}

.chapter-card .chapter-name {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: #fff;
}

.chapter-card .question-count {
  font-size: 0.8rem;
  color: #777;
}

.chapter-card.locked {
  opacity: 0.75;
}

.chapter-card.locked .icon {
  filter: grayscale(0.4);
}

.chapter-card.locked .question-count {
  color: #F5A623;
}

/* Lock Modal */
.lock-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 20, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.lock-modal {
  background: #1a1a2e;
  border: 1px solid #2a2a4a;
  border-radius: 16px;
  padding: 30px;
  max-width: 360px;
  width: 100%;
  text-align: center;
  animation: fadeIn 0.25s ease;
}

.lock-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 10px;
}

.lock-text {
  color: #aaa;
  font-size: 0.9rem;
  margin-bottom: 18px;
}

.lock-modal input {
  width: 100%;
  background: #12122a;
  border: 2px solid #2a2a4a;
  border-radius: 10px;
  padding: 12px 16px;
  color: #fff;
  font-size: 1rem;
  outline: none;
  margin-bottom: 12px;
  text-align: center;
  transition: all 0.2s;
}

.lock-modal input:focus {
  border-color: #4A90D9;
}

.lock-error {
  color: #E74C3C;
  font-size: 0.85rem;
  margin-bottom: 12px;
}

.lock-buttons {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 6px;
}

/* Instructions */
.instructions-chapter {
  color: #4A90D9;
  font-weight: 600;
  margin-bottom: 8px;
}

.instructions-text {
  text-align: left;
  color: #ccc;
  font-size: 0.9rem;
  margin-bottom: 10px;
}

.instructions-text p {
  margin-bottom: 10px;
}

.instructions-text ul {
  margin: 0;
  padding-left: 20px;
  line-height: 1.9;
}

.instructions-text strong {
  color: #fff;
}

/* Exam History */
.exam-history {
  max-width: 640px;
  margin: 34px auto 0;
  text-align: left;
}

.history-title {
  color: #ddd;
  font-size: 1.1rem;
  margin-bottom: 10px;
  text-align: center;
}

.history-empty {
  color: #777;
  text-align: center;
  font-size: 0.9rem;
  background: #14142b;
  border: 1px solid #2a2a4a;
  border-radius: 12px;
  padding: 16px;
}

.history-count {
  color: #888;
  font-size: 0.85rem;
  text-align: center;
  margin-bottom: 10px;
}

.history-list {
  background: #14142b;
  border: 1px solid #2a2a4a;
  border-radius: 12px;
  overflow: hidden;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid #22223c;
  font-size: 0.85rem;
  flex-wrap: wrap;
}

.history-item:last-child {
  border-bottom: none;
}

.history-name {
  flex: 1 1 160px;
  font-weight: 600;
  color: #fff;
}

.history-chapter {
  color: #aaa;
  background: #22223c;
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 0.75rem;
}

.history-score {
  font-weight: 600;
  color: #50B86C;
}

.history-date {
  color: #777;
  font-size: 0.8rem;
  margin-left: auto;
}

/* Chapter Screen */
.chapter-content {
  padding: 20px 0;
}

.back-btn {
  background: none;
  border: 1px solid #333;
  color: #aaa;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
  margin-bottom: 20px;
}

.back-btn:hover {
  background: #1a1a2e;
  color: #fff;
  border-color: #555;
}

.chapter-header {
  text-align: center;
  margin-bottom: 30px;
}

.chapter-header h2 {
  font-size: 1.8rem;
  color: #fff;
  margin-bottom: 6px;
}

.chapter-header p {
  color: #888;
  font-size: 0.95rem;
}

/* Question Counter */
.question-counter {
  text-align: center;
  margin-bottom: 24px;
}

.progress-bar-container {
  width: 100%;
  height: 6px;
  background: #1a1a2e;
  border-radius: 3px;
  overflow: hidden;
  margin-top: 10px;
}

.progress-bar {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease, background 0.3s;
}

.progress-text {
  font-size: 0.85rem;
  color: #777;
}

.timer-display {
  font-size: 1.1rem;
  font-weight: 600;
  color: #4fd1c5;
  margin-top: 8px;
}

.timer-display.timer-low {
  color: #E74C3C;
}

/* Question Card */
.question-card {
  background: #1a1a2e;
  border-radius: 16px;
  padding: 30px;
  margin-bottom: 20px;
  border: 1px solid #2a2a4a;
}

.question-card h3 {
  font-size: 1.15rem;
  color: #fff;
  margin-bottom: 20px;
  line-height: 1.5;
}

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

.option-btn {
  background: #12122a;
  border: 2px solid #2a2a4a;
  border-radius: 12px;
  padding: 14px 18px;
  color: #ccc;
  cursor: pointer;
  text-align: left;
  font-size: 0.95rem;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 12px;
}

.option-btn:hover:not(.disabled) {
  border-color: #555;
  background: #1a1a35;
  color: #fff;
}

.option-letter {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #2a2a4a;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.85rem;
  flex-shrink: 0;
  transition: all 0.2s;
}

.option-btn:hover:not(.disabled) .option-letter {
  background: #4A90D9;
  color: #fff;
}

.option-btn.selected {
  border-color: #4A90D9;
  background: rgba(74, 144, 217, 0.15);
  color: #fff;
}

.option-btn.selected .option-letter {
  background: #4A90D9;
  color: #fff;
}

.option-btn.correct {
  border-color: #50B86C;
  background: rgba(80, 184, 108, 0.1);
}

.option-btn.correct .option-letter {
  background: #50B86C;
  color: #fff;
}

.option-btn.incorrect {
  border-color: #E74C3C;
  background: rgba(231, 76, 60, 0.1);
}

.option-btn.incorrect .option-letter {
  background: #E74C3C;
  color: #fff;
}

.option-btn.disabled {
  cursor: default;
  opacity: 0.7;
  pointer-events: none;
}

.option-btn.disabled.correct {
  opacity: 1;
}

/* Feedback */
.feedback {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 0.9rem;
  display: none;
}

.feedback.show {
  display: block;
}

.feedback.correct {
  background: rgba(80, 184, 108, 0.15);
  color: #50B86C;
  border: 1px solid rgba(80, 184, 108, 0.3);
}

.feedback.incorrect {
  background: rgba(231, 76, 60, 0.15);
  color: #E74C3C;
  border: 1px solid rgba(231, 76, 60, 0.3);
}

/* Quiz Controls */
.quiz-controls {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 20px;
}

.btn {
  padding: 12px 28px;
  border-radius: 10px;
  border: none;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: linear-gradient(135deg, #4A90D9, #357ABD);
  color: #fff;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #5AA0E9, #4A90D9);
  transform: translateY(-1px);
}

.btn-secondary {
  background: #2a2a4a;
  color: #ccc;
}

.btn-secondary:hover {
  background: #3a3a5a;
}

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

/* Results */
.hidden {
  display: none !important;
}

.results-area {
  background: #1a1a2e;
  border-radius: 16px;
  padding: 30px;
  text-align: center;
  border: 1px solid #2a2a4a;
  animation: fadeIn 0.5s ease;
}

.results-area h3 {
  font-size: 1.5rem;
  color: #fff;
  margin-bottom: 10px;
}

.score-display {
  font-size: 3rem;
  font-weight: 700;
  margin: 20px 0;
}

.score-display .score-num {
  background: linear-gradient(135deg, #50B86C, #3CA85C);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.score-display .score-total {
  color: #666;
}

.score-message {
  color: #aaa;
  margin-bottom: 24px;
  font-size: 1rem;
}

.review-list {
  margin-top: 24px;
  text-align: left;
}

.review-item {
  background: #12122a;
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 10px;
  border-left: 3px solid #555;
}

.review-item.correct {
  border-left-color: #50B86C;
}

.review-item.incorrect {
  border-left-color: #E74C3C;
}

.review-item .review-question {
  font-weight: 600;
  color: #ddd;
  margin-bottom: 6px;
  font-size: 0.9rem;
}

.review-item .review-answer {
  font-size: 0.85rem;
  color: #888;
}

.review-item .review-answer span {
  font-weight: 600;
}

.review-item .review-answer .correct-ans {
  color: #50B86C;
}

.review-item .review-answer .incorrect-ans {
  color: #E74C3C;
}

/* Final Results Screen */
.results-content {
  text-align: center;
  padding: 40px 0;
}

.results-content .overall-score {
  font-size: 4rem;
  font-weight: 700;
  background: linear-gradient(135deg, #50B86C, #3CA85C);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 20px 0;
}

.chapter-results {
  margin: 30px 0;
}

.chapter-result-item {
  background: #1a1a2e;
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid #2a2a4a;
}

.chapter-result-item .cr-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chapter-result-item .cr-icon {
  font-size: 1.5rem;
}

.chapter-result-item .cr-name {
  font-weight: 600;
  color: #ddd;
}

.chapter-result-item .cr-score {
  font-weight: 600;
  font-size: 1.1rem;
}

.cr-score.great {
  color: #50B86C;
}

.cr-score.ok {
  color: #F5A623;
}

.cr-score.poor {
  color: #E74C3C;
}

/* Responsive */
@media (max-width: 600px) {
  .welcome-content h1 {
    font-size: 1.8rem;
  }

  .chapter-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
  }

  .chapter-card {
    padding: 16px 10px;
  }

  .chapter-card .icon {
    font-size: 2rem;
  }

  .question-card {
    padding: 20px;
  }

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