/* ═══════════════════════════════════════
   IQ Bunny — Prep for Kids, Made for Hazel
   Premium Kid-Friendly IQ Test Prep
   ═══════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
  /* IQ Bunny warm palette — inspired by the logo */
  --bunny-blue: #4a8fd4;
  --bunny-gold: #f5a623;
  --bunny-orange: #e87c3e;
  --bunny-peach: #fde8d0;
  --bunny-cream: #fef9f2;
  --bunny-green: #7bc67e;
  --bunny-red: #e05555;
  
  --bg-primary: #1a1d2e;
  --bg-card: #232740;
  --bg-card-hover: #2a2f4a;
  --text-primary: #f0f0f5;
  --text-secondary: #a0a4c0;
  --text-muted: #6b70a0;
  
  --correct: #4ade80;
  --wrong: #f87171;
  --border-radius: 16px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Outfit', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* Background pattern */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 20% 20%, rgba(74, 143, 212, 0.08) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(245, 166, 35, 0.06) 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, rgba(123, 198, 126, 0.04) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* ═══ LAYOUT ═══ */
.app {
  position: relative;
  z-index: 1;
  max-width: 700px;
  margin: 0 auto;
  padding: 16px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ═══ HEADER ═══ */
.header {
  text-align: center;
  padding: 24px 0 16px;
}
.header .logo {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--bunny-gold);
  box-shadow: 0 4px 20px rgba(245, 166, 35, 0.3);
  margin-bottom: 12px;
  animation: float 3s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
.header h1 {
  font-size: 2rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--bunny-blue), var(--bunny-gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
}
.header .subtitle {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ═══ CARDS ═══ */
.card {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  border: 1px solid rgba(255,255,255,0.06);
  padding: 24px;
  margin-bottom: 16px;
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 24px rgba(0,0,0,0.2);
  transition: var(--transition);
}
.card:hover {
  border-color: rgba(255,255,255,0.1);
}

/* ═══ WELCOME SCREEN ═══ */
#welcome { flex: 1; }
.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 16px 0;
}
.mode-btn {
  background: linear-gradient(135deg, var(--bg-card), var(--bg-card-hover));
  border: 2px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 20px 16px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-primary);
}
.mode-btn:hover, .mode-btn:active {
  border-color: var(--bunny-blue);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(74, 143, 212, 0.2);
}
.mode-btn .icon {
  font-size: 2rem;
  display: block;
  margin-bottom: 8px;
}
.mode-btn .label {
  font-weight: 600;
  font-size: 1rem;
}
.mode-btn .desc {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Category chips */
.cat-section { margin: 16px 0; }
.cat-section h3 {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
}
.cat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.cat-chip {
  padding: 8px 16px;
  border-radius: 100px;
  border: 2px solid rgba(255,255,255,0.1);
  background: transparent;
  color: var(--text-primary);
  font-family: 'Outfit', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
}
.cat-chip:hover { border-color: var(--bunny-blue); }
.cat-chip.active {
  background: var(--bunny-blue);
  border-color: var(--bunny-blue);
  color: #fff;
  box-shadow: 0 2px 12px rgba(74, 143, 212, 0.3);
}
.cat-chip.active.verbal { background: #6366f1; border-color: #6366f1; }
.cat-chip.active.numerical { background: var(--bunny-green); border-color: var(--bunny-green); color: #1a1d2e; }
.cat-chip.active.spatial { background: var(--bunny-orange); border-color: var(--bunny-orange); }
.cat-chip.active.logical { background: #a855f7; border-color: #a855f7; }
.cat-chip.active.analogies { background: var(--bunny-gold); border-color: var(--bunny-gold); color: #1a1d2e; }

/* Difficulty selector */
.diff-section { margin: 16px 0; }
.diff-btns {
  display: flex;
  gap: 8px;
}
.diff-btn {
  flex: 1;
  padding: 10px;
  border-radius: 10px;
  border: 2px solid rgba(255,255,255,0.1);
  background: transparent;
  color: var(--text-primary);
  font-family: 'Outfit', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}
.diff-btn:hover { border-color: var(--bunny-gold); }
.diff-btn.active {
  background: var(--bunny-gold);
  border-color: var(--bunny-gold);
  color: #1a1d2e;
}

/* Start button */
.start-btn {
  display: block;
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--bunny-blue), #3a6fb8);
  color: #fff;
  font-family: 'Outfit', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  margin-top: 20px;
  letter-spacing: 0.5px;
}
.start-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(74, 143, 212, 0.4);
}
.start-btn:active { transform: translateY(0); }

/* Question count display */
.q-count-display {
  text-align: center;
  margin-top: 12px;
  color: var(--text-secondary);
  font-size: 0.85rem;
}
.q-count-display span { color: var(--bunny-gold); font-weight: 700; }

/* ═══ QUIZ SCREEN ═══ */
#quiz { display: none; flex: 1; flex-direction: column; }

/* Progress bar */
.progress-wrap {
  width: 100%;
  height: 8px;
  background: rgba(255,255,255,0.06);
  border-radius: 100px;
  overflow: hidden;
  margin-bottom: 8px;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--bunny-blue), var(--bunny-gold));
  border-radius: 100px;
  transition: width 0.5s ease;
  width: 0%;
}

/* Stats row */
.stats-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.stats-row .timer {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: var(--bunny-gold);
}
.stats-row .score {
  font-weight: 600;
}
.stats-row .score .correct-count { color: var(--correct); }
.stats-row .score .wrong-count { color: var(--wrong); }

/* Category tag */
.cat-tag {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 100px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
}
.cat-tag.verbal { background: rgba(99,102,241,0.2); color: #818cf8; }
.cat-tag.numerical { background: rgba(123,198,126,0.2); color: var(--bunny-green); }
.cat-tag.spatial { background: rgba(232,124,62,0.2); color: var(--bunny-orange); }
.cat-tag.logical { background: rgba(168,85,247,0.2); color: #c084fc; }
.cat-tag.analogies { background: rgba(245,166,35,0.2); color: var(--bunny-gold); }

/* Question text */
.question-text {
  font-size: 1.1rem;
  font-weight: 500;
  line-height: 1.6;
  margin-bottom: 20px;
  white-space: pre-line;
}

/* Choices */
.choices {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}
.choice-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  border: 2px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  background: rgba(255,255,255,0.03);
  color: var(--text-primary);
  font-family: 'Outfit', sans-serif;
  font-size: 0.95rem;
  font-weight: 400;
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
  line-height: 1.4;
  -webkit-user-select: none;
  user-select: none;
}
.choice-btn:hover {
  border-color: var(--bunny-blue);
  background: rgba(74, 143, 212, 0.08);
}
.choice-btn .choice-letter {
  min-width: 30px;
  height: 30px;
  border-radius: 8px;
  background: rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.choice-btn.selected {
  border-color: var(--bunny-blue);
  background: rgba(74, 143, 212, 0.12);
}
.choice-btn.selected .choice-letter {
  background: var(--bunny-blue);
  color: #fff;
}
/* Correct/wrong states */
.choice-btn.correct {
  border-color: var(--correct) !important;
  background: rgba(74, 222, 128, 0.12) !important;
}
.choice-btn.correct .choice-letter {
  background: var(--correct) !important;
  color: #1a1d2e !important;
}
.choice-btn.wrong {
  border-color: var(--wrong) !important;
  background: rgba(248, 113, 113, 0.12) !important;
}
.choice-btn.wrong .choice-letter {
  background: var(--wrong) !important;
  color: #fff !important;
}
.choice-btn.disabled {
  pointer-events: none;
  opacity: 0.6;
}
.choice-btn.correct.disabled, .choice-btn.wrong.disabled {
  opacity: 1;
}

/* Explanation box */
.explanation {
  display: none;
  padding: 14px 16px;
  border-radius: 12px;
  background: rgba(245, 166, 35, 0.08);
  border: 1px solid rgba(245, 166, 35, 0.2);
  margin: 12px 0;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--bunny-peach);
}
.explanation.show { display: block; animation: slideIn 0.3s ease; }
.explanation .label {
  font-weight: 700;
  color: var(--bunny-gold);
  margin-bottom: 4px;
}

/* Next button */
.next-btn {
  display: none;
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--bunny-gold), var(--bunny-orange));
  color: #1a1d2e;
  font-family: 'Outfit', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  margin-top: 8px;
}
.next-btn.show { display: block; animation: slideIn 0.3s ease; }
.next-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(245, 166, 35, 0.3);
}

/* ═══ RESULTS SCREEN ═══ */
#results { display: none; flex: 1; }

.results-header {
  text-align: center;
  padding: 24px 0;
}
.results-header .bunny { font-size: 3rem; margin-bottom: 8px; }
.results-header h2 {
  font-size: 1.6rem;
  font-weight: 700;
}
.results-header .score-big {
  font-size: 3rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--bunny-gold), var(--bunny-orange));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 8px 0;
}
.results-header .message {
  color: var(--text-secondary);
  font-size: 1rem;
}

/* Category breakdown */
.breakdown { margin: 16px 0; }
.breakdown h3 {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
}
.cat-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.cat-result:last-child { border: none; }
.cat-result .cat-name {
  font-weight: 500;
  font-size: 0.9rem;
  text-transform: capitalize;
}
.cat-result .cat-score {
  font-weight: 700;
  font-size: 0.9rem;
}
.cat-bar-wrap {
  flex: 1;
  height: 6px;
  background: rgba(255,255,255,0.06);
  border-radius: 100px;
  margin: 0 16px;
  overflow: hidden;
}
.cat-bar {
  height: 100%;
  border-radius: 100px;
  transition: width 1s ease;
}
.cat-bar.verbal { background: #6366f1; }
.cat-bar.numerical { background: var(--bunny-green); }
.cat-bar.spatial { background: var(--bunny-orange); }
.cat-bar.logical { background: #a855f7; }
.cat-bar.analogies { background: var(--bunny-gold); }

/* Review accordion */
.review-section { margin: 16px 0; }
.review-section h3 {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
}
.review-item {
  padding: 12px;
  border-radius: 10px;
  margin-bottom: 8px;
  border: 1px solid rgba(255,255,255,0.06);
  font-size: 0.85rem;
  line-height: 1.5;
  cursor: pointer;
  transition: var(--transition);
}
.review-item:hover { background: rgba(255,255,255,0.03); }
.review-item.review-correct {
  border-left: 3px solid var(--correct);
}
.review-item.review-wrong {
  border-left: 3px solid var(--wrong);
}
.review-item .rq { font-weight: 600; margin-bottom: 4px; white-space: pre-line; }
.review-item .ra { color: var(--text-secondary); }
.review-item .ra .right { color: var(--correct); font-weight: 600; }
.review-item .ra .user-wrong { color: var(--wrong); text-decoration: line-through; margin-right: 8px; }
.review-item .rexp {
  display: none;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.06);
  color: var(--bunny-peach);
  font-size: 0.82rem;
}
.review-item.open .rexp { display: block; }

/* Restart buttons */
.restart-btns {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}
.restart-btn {
  flex: 1;
  padding: 14px;
  border: 2px solid var(--bunny-blue);
  border-radius: 12px;
  background: transparent;
  color: var(--bunny-blue);
  font-family: 'Outfit', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}
.restart-btn:hover {
  background: var(--bunny-blue);
  color: #fff;
}
.restart-btn.primary {
  background: linear-gradient(135deg, var(--bunny-blue), #3a6fb8);
  border-color: transparent;
  color: #fff;
}

/* ═══ STREAK ANIMATIONS ═══ */
.streak-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  font-size: 2.5rem;
  font-weight: 800;
  pointer-events: none;
  z-index: 100;
  opacity: 0;
  text-align: center;
}
.streak-popup.show {
  animation: streakPop 1.2s ease forwards;
}
@keyframes streakPop {
  0% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
  20% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
  50% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -60%) scale(0.8); opacity: 0; }
}

/* Star explosion on correct */
.star-burst {
  position: fixed;
  pointer-events: none;
  z-index: 99;
  font-size: 1.5rem;
  animation: starFly 0.8s ease forwards;
}
@keyframes starFly {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(0); opacity: 0; }
}

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

/* Screen transitions */
.screen { animation: fadeIn 0.4s ease; }
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ═══ STATS DASHBOARD (bottom of welcome) ═══ */
.past-stats { margin: 16px 0; }
.past-stats h3 {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
}
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}
.stat-item {
  background: rgba(255,255,255,0.03);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
}
.stat-item .stat-val {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--bunny-gold);
}
.stat-item .stat-label {
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ═══ HIDDEN UTILITY ═══ */
.hidden { display: none !important; }

/* ═══ MOBILE RESPONSIVENESS ═══ */
@media (max-width: 480px) {
  .app { padding: 12px; }
  .header .logo { width: 90px; height: 90px; }
  .header h1 { font-size: 1.6rem; }
  .mode-grid { grid-template-columns: 1fr; }
  .mode-btn { padding: 16px; }
  .question-text { font-size: 1rem; }
  .choice-btn { padding: 12px 14px; font-size: 0.9rem; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .results-header .score-big { font-size: 2.5rem; }
}

@media (min-width: 768px) {
  .app { padding: 24px; }
  .header .logo { width: 140px; height: 140px; }
  .header h1 { font-size: 2.4rem; }
  .question-text { font-size: 1.2rem; }
}

/* ═══ SCROLLBAR ═══ */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 100px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }
