* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  background: linear-gradient(180deg, #eef2ff 0%, #f8fafc 100%);
  color: #1e293b;
  min-height: 100vh;
}
#app {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

.hero { text-align: center; margin-bottom: 20px; }
.hero h1 { font-size: 2.2rem; margin: 10px 0 4px; }
.hero .sub { color: #475569; margin: 0 0 14px; }
.starbar { font-size: 1.2rem; margin-bottom: 8px; }

.progress-outer, .cat-progress-outer {
  background: #e2e8f0;
  border-radius: 999px;
  height: 14px;
  overflow: hidden;
  max-width: 400px;
  margin: 0 auto;
}
.progress-inner {
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
  height: 100%;
  transition: width 0.4s;
}
.cat-progress-outer { max-width: none; height: 10px; margin: 8px 0 4px; }
.cat-progress-inner { background: var(--accent, #6366f1); height: 100%; transition: width 0.4s; }

.mode-row { display: flex; justify-content: center; margin: 18px 0; }
.mode-btn {
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  color: white;
  border: none;
  border-radius: 16px;
  padding: 18px 28px;
  font-size: 1.2rem;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 6px 0 #3730a3;
  transition: transform 0.1s;
}
.mode-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #3730a3; }
.mode-btn span { display: block; font-size: 0.85rem; font-weight: normal; opacity: 0.9; margin-top: 4px; }

.section-title { text-align: center; color: #334155; margin: 20px 0 12px; }

.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}
.cat-card {
  background: white;
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
  border-top: 6px solid var(--accent, #6366f1);
  text-align: center;
}
.cat-icon { font-size: 2.2rem; }
.cat-name { font-weight: bold; font-size: 1.05rem; margin: 6px 0; min-height: 46px; display:flex; align-items:center; justify-content:center; }
.cat-count { font-size: 0.85rem; color: #64748b; margin-bottom: 10px; }
.cat-btns { display: flex; gap: 8px; justify-content: center; }
.cat-btns button {
  border: none;
  border-radius: 10px;
  padding: 10px 12px;
  background: #f1f5f9;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  color: #334155;
  transition: background 0.15s;
}
.cat-btns button:hover { background: var(--accent, #6366f1); color: white; }

.back-btn {
  border: none;
  background: #e2e8f0;
  padding: 8px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  margin-bottom: 14px;
}
.back-btn:hover { background: #cbd5e1; }

.card-counter, .score-row { text-align: center; color: #64748b; margin-bottom: 10px; font-weight: 600; }

/* Flashcard */
.flashcard {
  perspective: 1200px;
  max-width: 460px;
  height: 380px;
  margin: 0 auto;
  cursor: pointer;
  position: relative;
}
.flash-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 20px;
  background: white;
  box-shadow: 0 8px 24px rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  transition: transform 0.5s;
  transform: rotateY(0deg);
}
.flash-back { transform: rotateY(180deg); }
.flashcard.flipped .flash-front { transform: rotateY(-180deg); }
.flashcard.flipped .flash-back { transform: rotateY(0deg); }

.flash-svg { width: 100%; max-width: 280px; margin: 0 auto; display: block; }
.term-svg { width: 100%; height: auto; }
.lbl { font-size: 11px; fill: #475569; font-family: inherit; }

.flash-term { font-size: 1.7rem; font-weight: bold; color: #4f46e5; margin-top: 10px; }
.flash-term.small { font-size: 1.3rem; margin-bottom: 14px; }
.flash-hint { color: #94a3b8; font-size: 0.85rem; margin-top: 6px; }
.flash-def { text-align: center; font-size: 1.1rem; line-height: 1.5; color: #334155; }

.nav-row { display: flex; justify-content: center; gap: 14px; margin-top: 20px; }
.nav-row button, .next-question-btn {
  border: none;
  background: #4f46e5;
  color: white;
  padding: 12px 20px;
  border-radius: 12px;
  font-weight: bold;
  font-size: 1rem;
  cursor: pointer;
}
.nav-row button:disabled { background: #cbd5e1; cursor: not-allowed; }
.nav-row button:hover:not(:disabled), .next-question-btn:hover { background: #4338ca; }

/* Quiz / Practice cards */
.quiz-card {
  background: white;
  border-radius: 20px;
  padding: 24px;
  max-width: 560px;
  margin: 0 auto;
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
  text-align: center;
}
.quiz-question { font-size: 1.2rem; font-weight: bold; margin: 10px 0 6px; color: #1e293b; }
.quiz-def { color: #475569; font-size: 1.05rem; margin-bottom: 16px; }
.options-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.option-btn {
  border: 2px solid #e2e8f0;
  background: #f8fafc;
  border-radius: 12px;
  padding: 14px 10px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.15s;
}
.option-btn:hover:not(:disabled) { border-color: #6366f1; background: #eef2ff; }
.option-btn.correct { background: #dcfce7; border-color: #22c55e; }
.option-btn.wrong { background: #fee2e2; border-color: #ef4444; }
.option-btn:disabled { cursor: default; }

.feedback { margin-top: 16px; font-size: 1.1rem; font-weight: bold; min-height: 26px; }
.next-question-btn { margin-top: 14px; }

.result-card {
  background: white;
  border-radius: 20px;
  padding: 40px 24px;
  max-width: 480px;
  margin: 20px auto;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
}
.result-badge { font-size: 1.6rem; margin-bottom: 14px; }
.result-score { font-size: 1.3rem; color: #334155; margin-bottom: 20px; }

@media (max-width: 480px) {
  .options-grid { grid-template-columns: 1fr; }
  .flashcard { height: 420px; }
  .hero h1 { font-size: 1.7rem; }
}
