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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.6;
  color: #1a1a1a;
  background: #f5f5f5;
  min-height: 100vh;
}

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

.hidden {
  display: none !important;
}

/* Topic Selection */
#topic-view {
  text-align: center;
  padding-top: 2rem;
}

#topic-view h1 {
  font-size: 2rem;
  margin-bottom: 0.25rem;
}

.subtitle {
  color: #666;
  margin-bottom: 2rem;
  font-size: 1.1rem;
}

#topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}

.topic-card {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 1.25rem;
  cursor: pointer;
  text-align: left;
  transition: box-shadow 0.15s, border-color 0.15s;
}

.topic-card:hover {
  border-color: #4a90d9;
  box-shadow: 0 2px 8px rgba(74, 144, 217, 0.15);
}

.topic-card .topic-id {
  font-size: 0.85rem;
  color: #888;
  font-weight: 600;
}

.topic-card .topic-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0.25rem 0;
}

.topic-card .topic-count {
  font-size: 0.85rem;
  color: #666;
}

/* Quiz View */
.quiz-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid #ddd;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

#progress {
  font-size: 0.9rem;
  color: #666;
}

#score {
  font-size: 0.9rem;
  font-weight: 600;
  color: #2a7e2a;
}

.btn-link {
  background: none;
  border: none;
  color: #4a90d9;
  cursor: pointer;
  font-size: 0.95rem;
  padding: 0.25rem 0;
}

.btn-link:hover {
  text-decoration: underline;
}

#question-container {
  background: #fff;
  border-radius: 8px;
  padding: 1.5rem;
  border: 1px solid #ddd;
}

#question-text {
  font-size: 1.1rem;
  margin-bottom: 1.25rem;
  white-space: pre-line;
}

/* Options */
#options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.option-btn {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border: 2px solid #ddd;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  text-align: left;
  font-size: 1rem;
  transition: border-color 0.15s, background 0.15s;
  line-height: 1.5;
}

.option-btn:hover:not(.disabled) {
  border-color: #4a90d9;
  background: #f0f6ff;
}

.option-btn.selected {
  border-color: #4a90d9;
  background: #e8f0fe;
}

.option-btn.correct {
  border-color: #2a7e2a;
  background: #e8f5e9;
}

.option-btn.wrong {
  border-color: #c62828;
  background: #ffebee;
}

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

.option-letter {
  font-weight: 700;
  color: #555;
  min-width: 1.5rem;
  flex-shrink: 0;
}

.option-text {
  flex: 1;
}

/* Buttons */
.btn-primary, .btn-secondary {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.15s;
}

.btn-primary {
  background: #4a90d9;
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: #3a7bc8;
}

.btn-primary:disabled {
  background: #b0c4de;
  cursor: not-allowed;
}

.btn-secondary {
  background: #e0e0e0;
  color: #333;
}

.btn-secondary:hover {
  background: #d0d0d0;
}

/* Feedback */
#feedback {
  margin: 1rem 0;
  padding: 1rem;
  border-radius: 8px;
  background: #f8f9fa;
  border: 1px solid #ddd;
}

#explanation {
  font-size: 0.95rem;
  color: #333;
}

/* Appendix */
#appendix-container {
  margin-bottom: 1.25rem;
  text-align: center;
}

#appendix-container h3 {
  font-size: 0.9rem;
  color: #666;
  margin-bottom: 0.5rem;
}

#appendix-img {
  max-width: 100%;
  border: 1px solid #ddd;
  border-radius: 4px;
  cursor: zoom-in;
}

/* Lightbox */
#lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  cursor: zoom-out;
  padding: 1rem;
}

#lightbox-img {
  max-width: 95vw;
  max-height: 95vh;
  object-fit: contain;
}

/* Results */
#results-view {
  text-align: center;
  padding-top: 3rem;
}

#results-view h2 {
  font-size: 1.75rem;
  margin-bottom: 1rem;
}

#results-score {
  font-size: 1.25rem;
  margin-bottom: 2rem;
}

#results-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

/* Responsive */
@media (max-width: 480px) {
  #app {
    padding: 0.5rem;
  }

  #topic-view h1 {
    font-size: 1.5rem;
  }

  #question-container {
    padding: 1rem;
  }

  .option-btn {
    padding: 0.75rem;
  }
}
