/* ============================================================
   QUIZ PLAYER
   ============================================================ */
.quiz-player {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 20px;
}

@media (max-width: 900px) {
  .quiz-player { grid-template-columns: 1fr; }
  .quiz-sidebar { order: -1; }
  .quiz-sidebar-toggle { display: flex !important; width: 100%; justify-content: center; }
}

@media (min-width: 901px) {
  .quiz-sidebar-toggle { display: none; }
  .quiz-sidebar-content { display: block !important; }
}

.quiz-header {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.quiz-title-block h2 { font-size: 1.2rem; margin-bottom: 2px; }
.quiz-title-block p { font-size: 0.85rem; color: var(--text-muted); }

.timer-display {
  font-family: ui-monospace, "SF Mono", Monaco, monospace;
  font-size: 1.4rem;
  font-weight: 700;
  padding: 8px 16px;
  background: var(--bg-soft);
  border-radius: 10px;
  border: 2px solid var(--border);
  min-width: 110px;
  text-align: center;
}

.timer-display.warn-25 { border-color: var(--warning); color: var(--warning); }
.timer-display.warn-10 { border-color: var(--danger); color: var(--danger); animation: pulse 1.4s infinite; }

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

/* Question card */
.question-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow-sm);
}

.question-num { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 8px; }
.question-text { font-size: 1.15rem; margin-bottom: 20px; line-height: 1.6; }
.question-image { max-width: 100%; max-height: 350px; border-radius: var(--radius); border: 1px solid var(--border); margin-bottom: 16px; display: block; }
.question-meta { font-size: 0.8rem; color: var(--text-muted); margin-top: 6px; display: flex; gap: 12px; flex-wrap: wrap; }

/* Options */
.option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  cursor: pointer;
  transition: all var(--transition);
  min-height: 48px;
}

.option:hover { border-color: var(--primary); background: var(--primary-soft); }
.option input { margin-top: 3px; flex-shrink: 0; }

.option-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: var(--bg-soft);
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.option.selected { border-color: var(--primary); background: var(--primary-soft); }
.option.selected .option-key { background: var(--primary); color: white; }
.option.correct { border-color: var(--success); background: var(--success-soft); }
.option.incorrect { border-color: var(--danger); background: var(--danger-soft); }

/* Navigation */
.quiz-nav {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 20px;
  flex-wrap: wrap;
}

/* Sidebar question map */
.quiz-sidebar {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}

.qmap-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  gap: 6px;
  margin-top: 12px;
}

.qmap-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-soft);
  border: 2px solid transparent;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  position: relative;
  transition: all var(--transition);
}

.qmap-cell:hover { transform: scale(1.08); }
.qmap-cell.answered { background: var(--success); color: white; }
.qmap-cell.flagged::after {
  content: "\01F6A9";
  position: absolute;
  top: -6px;
  right: -4px;
  font-size: 0.7rem;
}
.qmap-cell.current { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }

.legend { font-size: 0.75rem; color: var(--text-muted); margin-top: 12px; display: grid; gap: 4px; }
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-swatch { width: 14px; height: 14px; border-radius: 4px; }

/* ============================================================
   RESULTS
   ============================================================ */
.result-hero {
  background: var(--grad);
  color: white;
  padding: 36px;
  border-radius: var(--radius-lg);
  text-align: center;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}

.result-hero.fail { background: var(--grad-warm); }
.result-score { font-size: 4.5rem; font-weight: 900; line-height: 1; margin: 12px 0; }
.result-percent { font-size: 1.4rem; opacity: 0.92; }
.result-status {
  display: inline-block;
  padding: 6px 18px;
  background: rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  margin-top: 10px;
  font-weight: 700;
}

/* Review items */
.review-item {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-left: 5px solid var(--success);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.review-item.incorrect { border-left-color: var(--danger); }
.review-item.partial { border-left-color: var(--warning); }
.review-q { font-weight: 600; margin-bottom: 8px; }
.review-line { font-size: 0.9rem; margin: 4px 0; }
.review-explanation {
  background: var(--primary-soft);
  border-radius: 8px;
  padding: 10px 14px;
  margin-top: 10px;
  font-size: 0.9rem;
}

/* ============================================================
   CONFETTI
   ============================================================ */
.confetti-piece {
  position: fixed;
  width: 10px;
  height: 14px;
  top: -20px;
  pointer-events: none;
  animation: confetti-fall 3s linear forwards;
  z-index: 9999;
}

@keyframes confetti-fall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}

/* ============================================================
   QUIZ CARD GRID (Home)
   ============================================================ */
.quiz-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.quiz-tile {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 28px;
  display: flex;
  flex-direction: column;
  transition: all var(--transition);
  cursor: pointer;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.quiz-tile::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 5px;
  background: var(--grad);
  transition: height var(--transition);
}

.quiz-tile:hover {
  transform: translateY(-6px) scale(1.01);
  box-shadow: var(--shadow-xl);
  border-color: var(--primary);
}

.quiz-tile:hover::before {
  height: 8px;
}

.quiz-tile-cat {
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--secondary);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 10px;
  background: var(--secondary-soft);
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  align-self: flex-start;
}

.quiz-tile h3 { font-size: 1.15rem; margin-bottom: 8px; font-weight: 800; letter-spacing: -0.02em; color: var(--text); }
.quiz-tile-desc { color: var(--text-muted); font-size: 0.85rem; flex-grow: 1; margin-bottom: 14px; line-height: 1.6; }
.quiz-tile-meta { display: flex; gap: 6px; flex-wrap: wrap; font-size: 0.72rem; }

/* ============================================================
   LEADERBOARD
   ============================================================ */
.leader-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
}

.leader-rank {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--bg-soft);
  font-weight: 800;
}

.leader-rank.gold { background: linear-gradient(135deg, #fde68a, #f59e0b); color: #5a3a00; }
.leader-rank.silver { background: linear-gradient(135deg, #e5e7eb, #9ca3af); color: #2d2d2d; }
.leader-rank.bronze { background: linear-gradient(135deg, #fcd9b4, #d97706); color: #5c2900; }
.leader-meta { flex: 1; }
.leader-name { font-weight: 700; }
.leader-sub { font-size: 0.85rem; color: var(--text-muted); }
.leader-score { font-weight: 800; color: var(--primary); }

/* ============================================================
   BADGES & XP
   ============================================================ */
.badge-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
  position: relative;
}

.badge-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 8px;
  background: var(--grad);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  box-shadow: var(--shadow);
}

.badge-card.locked .badge-icon { background: var(--bg-soft); filter: grayscale(1); opacity: 0.45; }
.badge-name { font-weight: 700; font-size: 0.9rem; }
.badge-desc { font-size: 0.75rem; color: var(--text-muted); }

.xp-bar {
  height: 14px;
  background: var(--bg-soft);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 8px;
}

.xp-fill {
  height: 100%;
  background: var(--grad);
  transition: width 600ms ease;
}
