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

:root {
  --primary: #1a3a5c;
  --primary-light: #2c5f8a;
  --accent: #c0392b;
  --bg: #f5f6fa;
  --card-bg: #ffffff;
  --text: #2c3e50;
  --text-light: #7f8c8d;
  --border: #dce1e8;
  --success: #27ae60;
  --error: #e74c3c;
  --highlight: #f39c12;
}

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

header {
  background: var(--primary);
  color: white;
  padding: 1.5rem 2rem;
  text-align: center;
}

header h1 {
  font-size: 1.8rem;
  font-weight: 600;
  letter-spacing: -0.5px;
}

.subtitle {
  font-size: 0.95rem;
  opacity: 0.85;
  margin-top: 0.25rem;
}

nav {
  background: var(--primary-light);
  display: flex;
  justify-content: center;
  gap: 0;
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  padding: 0.9rem 2rem;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  border-bottom: 3px solid transparent;
}

.nav-btn:hover {
  color: white;
  background: rgba(255,255,255,0.1);
}

.nav-btn.active {
  color: white;
  border-bottom-color: var(--highlight);
}

.game {
  display: none;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
}

.game.active {
  display: block;
}

.game-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.game-header h2 {
  font-size: 1.5rem;
  color: var(--primary);
  margin-bottom: 0.3rem;
}

.game-header p {
  color: var(--text-light);
  font-size: 0.9rem;
}

.toggle-group {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1rem;
}

.toggle-btn {
  padding: 0.5rem 1.5rem;
  border: 2px solid var(--border);
  background: var(--card-bg);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  transition: all 0.2s;
}

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

.toggle-btn:hover:not(.active) {
  border-color: var(--primary-light);
}

.score-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-top: 0.75rem;
  font-weight: 600;
  color: var(--primary);
}

.reset-btn {
  padding: 0.4rem 1rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
}

.reset-btn:hover {
  opacity: 0.9;
}

/* Explorer */
.explorer-container {
  display: grid;
  grid-template-columns: 1fr 350px;
  gap: 1.5rem;
  align-items: start;
}

.cell-diagram {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.5rem;
  min-height: 450px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cell-diagram svg {
  width: 100%;
  max-width: 550px;
  height: auto;
}

.info-panel {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.5rem;
  position: sticky;
  top: 70px;
}

.info-panel h3 {
  color: var(--primary);
  font-size: 1.15rem;
  margin-bottom: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border);
}

.info-panel p {
  font-size: 0.9rem;
  color: var(--text-light);
  margin-bottom: 0.75rem;
}

#info-details {
  font-size: 0.9rem;
  line-height: 1.7;
}

#info-details .detail-label {
  font-weight: 600;
  color: var(--primary);
  display: block;
  margin-top: 0.5rem;
}

#info-details .comparison {
  background: var(--bg);
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
  margin-top: 0.5rem;
  font-size: 0.85rem;
  border-left: 3px solid var(--primary-light);
}

.sub-parts-nav {
  margin-top: 0.75rem;
}

.sub-parts-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.4rem;
}

.sub-part-btn {
  padding: 0.35rem 0.7rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 500;
  transition: background 0.2s;
}

.sub-part-btn:hover {
  background: var(--primary-light);
}

.back-btn {
  margin-top: 0.75rem;
  background: var(--text-light);
}

.back-btn:hover {
  background: var(--text);
}

/* SVG interactive */
.organelle {
  cursor: pointer;
  transition: opacity 0.2s, filter 0.2s;
}

.organelle:hover {
  opacity: 0.8;
  filter: brightness(1.1);
}

.organelle.highlighted {
  filter: drop-shadow(0 0 6px var(--highlight));
}

/* Labeling */
.labeling-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.labeling-diagram {
  position: relative;
  width: 100%;
  max-width: 700px;
}

.label-slot {
  position: absolute;
  background: var(--card-bg);
  border: 2px dashed var(--primary-light);
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--primary);
  text-align: center;
  min-width: 100px;
  transition: all 0.2s;
}

.label-slot.filled {
  border-style: solid;
  background: #e8f4f8;
}

.label-slot.correct {
  border-color: var(--success);
  background: #d5f5e3;
  color: var(--success);
}

.label-slot.incorrect {
  border-color: var(--error);
  background: #fadbd8;
  color: var(--error);
  animation: shake 0.4s;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.word-bank {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  padding: 1rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  min-height: 60px;
  width: 100%;
  max-width: 700px;
}

.drag-label {
  padding: 0.45rem 1rem;
  background: var(--primary);
  color: white;
  border-radius: 4px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: grab;
  user-select: none;
  transition: transform 0.15s, box-shadow 0.15s;
}

.drag-label:active {
  cursor: grabbing;
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.drag-label.placed {
  opacity: 0.4;
  pointer-events: none;
}

.feedback {
  text-align: center;
  padding: 0.75rem;
  border-radius: 6px;
  margin-top: 1rem;
  font-weight: 600;
  display: none;
}

.feedback.show {
  display: block;
}

.feedback.success {
  background: #d5f5e3;
  color: #1e8449;
}

.feedback.error {
  background: #fadbd8;
  color: #c0392b;
}

.feedback.info {
  background: #d6eaf8;
  color: #2471a3;
}

/* Quiz */
.quiz-container {
  max-width: 700px;
  margin: 0 auto;
}

.quiz-question {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.5rem;
  margin-bottom: 1rem;
  font-size: 1.05rem;
  line-height: 1.6;
}

.quiz-question .q-number {
  color: var(--primary);
  font-weight: 700;
}

.quiz-question .q-type {
  font-size: 0.78rem;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 1px;
  display: block;
  margin-bottom: 0.5rem;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.quiz-option {
  padding: 0.9rem 1.2rem;
  background: var(--card-bg);
  border: 2px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  text-align: left;
  transition: all 0.2s;
}

.quiz-option:hover:not(.disabled) {
  border-color: var(--primary-light);
  background: #eef3f8;
}

.quiz-option.selected {
  border-color: var(--primary);
  background: #d6eaf8;
}

.quiz-option.correct {
  border-color: var(--success);
  background: #d5f5e3;
}

.quiz-option.incorrect {
  border-color: var(--error);
  background: #fadbd8;
}

.quiz-option.disabled {
  cursor: default;
  opacity: 0.7;
}

.next-btn {
  display: block;
  margin: 1rem auto 0;
  padding: 0.7rem 2rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
}

.next-btn:hover {
  background: var(--primary-light);
}

.quiz-results {
  text-align: center;
  max-width: 700px;
  margin: 0 auto;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2rem;
}

.quiz-results h3 {
  font-size: 1.4rem;
  color: var(--primary);
  margin-bottom: 0.5rem;
}

#final-score {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
}

#quiz-review {
  text-align: left;
  margin-bottom: 1.5rem;
}

.review-item {
  padding: 0.75rem;
  border-radius: 6px;
  margin-bottom: 0.5rem;
  font-size: 0.88rem;
  border-left: 4px solid;
}

.review-item.wrong {
  background: #fef5e7;
  border-color: var(--highlight);
}

.review-item.correct {
  background: #eafaf1;
  border-color: var(--success);
}

footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-light);
  font-size: 0.82rem;
  margin-top: 2rem;
  border-top: 1px solid var(--border);
}

/* Responsive */
@media (max-width: 900px) {
  .explorer-container {
    grid-template-columns: 1fr;
  }
  .info-panel {
    position: static;
  }
}

@media (max-width: 600px) {
  header h1 {
    font-size: 1.3rem;
  }
  .nav-btn {
    padding: 0.7rem 1rem;
    font-size: 0.85rem;
  }
  .game {
    padding: 1rem;
  }
  .cell-diagram {
    min-height: 300px;
    padding: 1rem;
  }
}
