/* ══════════════════════════════════════════════════════════════════
   URQUIZ LIVE F1 EDITION - STYLESHEET (css/quiz.css)
   - Sticky F1 Championship Standings Bar
   - Admin Host Control Center & Question Loader
   - Normal User Waiting Room / Lobby
   - Mode 1: Question-by-Question Arena (Visual Countdown, Reveal)
   - Mode 2: All-at-Once Race (Masked Cards, Individual Timers)
   - Question Map Drawer with Status Dots & Fastest Lap Purple Rings
   - Grand Prix Podium with Pedestals & Confetti
   ══════════════════════════════════════════════════════════════════ */

/* Quiz Workspace Container */
#quiz-workspace {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  background: transparent;
}

/* ═══════════════════════════════════════════════════
   STICKY F1 CHAMPIONSHIP STANDINGS BAR
   ═══════════════════════════════════════════════════ */
#f1-leaderboard-bar {
  flex-shrink: 0;
  background: var(--surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--glass-border);
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  z-index: 30;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.f1-brand-ticker {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.f1-racing-badge {
  background: linear-gradient(135deg, #4b5563, #1f2937);
  color: #ffffff;
  font-size: 0.64rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 6px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.1);
}
.f1-round-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}

/* Top 3 Podiums in Header Bar */
.f1-top3-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  flex: 1;
  min-width: 0;
  justify-content: center;
}

.f1-driver-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--surface-alt);
  border: 1px solid var(--glass-border);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  transition: transform 0.2s, border-color 0.2s;
}
.f1-driver-pill.p1 {
  border-color: rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.15);
}
.f1-driver-pill.p1 .f1-pos-badge {
  background: #ffffff;
  color: #000;
}
.f1-driver-pill.p2 {
  border-color: rgba(200, 200, 200, 0.4);
}
.f1-driver-pill.p2 .f1-pos-badge {
  background: #d1d5db;
  color: #000;
}
.f1-driver-pill.p3 {
  border-color: rgba(150, 150, 150, 0.4);
}
.f1-driver-pill.p3 .f1-pos-badge {
  background: #9ca3af;
  color: #000;
}

.f1-pos-badge {
  font-size: 0.6rem;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 8px;
  background: var(--surface-hover);
  color: var(--text-primary);
}
.f1-driver-name {
  color: var(--text-primary);
}
.f1-driver-pts {
  color: var(--accent-glow);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
}
.f1-fastest-lap-icon {
  color: var(--purple-fast);
  font-size: 0.7rem;
}

.f1-standings-toggle-btn {
  padding: 6px 12px;
  border-radius: 8px;
  background: var(--surface-alt);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s;
}
.f1-standings-toggle-btn:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

/* Standings Modal / Slide-down Dropdown */
#standings-dropdown {
  display: none;
  position: absolute;
  top: 50px;
  right: 16px;
  width: 360px;
  max-width: 90vw;
  max-height: 400px;
  overflow-y: auto;
  z-index: 100;
  border-radius: 14px;
  padding: 16px;
  background: var(--surface);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--glass-border);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.4);
  animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
#standings-dropdown.open {
  display: block;
}

.standings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.standings-table th {
  text-align: left;
  padding: 6px 8px;
  font-size: 0.65rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--glass-border);
}
.standings-table td {
  padding: 8px;
  border-bottom: 1px solid var(--glass-border);
  color: var(--text-primary);
}
.standings-table tr:last-child td {
  border-bottom: none;
}
.standings-rank {
  font-weight: 800;
  color: var(--text-secondary);
  width: 30px;
}
.standings-table tr:nth-child(1) .standings-rank { color: #ffffff; }
.standings-table tr:nth-child(2) .standings-rank { color: #d1d5db; }
.standings-table tr:nth-child(3) .standings-rank { color: #9ca3af; }
.standings-pts {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  color: var(--accent-glow);
  text-align: right;
}

/* ═══════════════════════════════════════════════════
   SCROLLABLE QUIZ MAIN AREA
   ═══════════════════════════════════════════════════ */
.quiz-scroll-container {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 16px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* VIEW 1: NORMAL USER LOBBY / WAITING ROOM */
#quiz-lobby-view {
  display: none;
  flex-direction: column;
  width: 100%;
  max-width: 650px;
  margin: auto 0;
  animation: fadeIn 0.3s ease;
}

.lobby-card {
  padding: 36px 28px;
  border-radius: 20px;
  text-align: center;
}

.f1-lights-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 24px;
}
.f1-light {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.15);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
  transition: all 0.3s;
}
.f1-light.active-red {
  background: #ef4444;
  border-color: #f87171;
  box-shadow: 0 0 14px #ef4444;
}
.f1-light.active-green {
  background: #22c55e;
  border-color: #4ade80;
  box-shadow: 0 0 16px #22c55e;
}

.lobby-title {
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin-bottom: 6px;
  color: var(--text-primary);
}
.lobby-subtitle {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-bottom: 24px;
  line-height: 1.5;
}

.lobby-classmates-section {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--glass-border);
  text-align: left;
}
.lobby-classmates-header {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.connected-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.connected-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  background: var(--surface-alt);
  border: 1px solid var(--glass-border);
  font-size: 0.8rem;
  color: var(--text-primary);
}
.connected-chip .chip-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green-1);
}

/* VIEW 2: ADMIN HOST CONTROL CENTER */
#admin-host-view {
  display: none;
  flex-direction: column;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  animation: fadeIn 0.3s ease;
}

.host-card {
  padding: 28px 24px;
  border-radius: 20px;
}
.host-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--glass-border);
}
.host-title-wrap {
  display: flex;
  flex-direction: column;
}
.host-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-primary);
}
.host-subtitle {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.loader-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.btn-loader-action {
  padding: 7px 12px;
  border-radius: 8px;
  background: var(--surface-alt);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}
.btn-loader-action:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
  border-color: var(--glass-border-hover);
}

#raw-quiz-input {
  width: 100%;
  height: 160px;
  padding: 12px;
  border-radius: 12px;
  background: var(--input-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  resize: vertical;
  outline: none;
  margin-bottom: 12px;
}
#raw-quiz-input:focus {
  border-color: var(--accent);
}

.parser-status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-bottom: 22px;
  padding: 6px 12px;
  border-radius: 8px;
  background: var(--surface-alt);
}
.parser-status-bar.valid {
  color: var(--green-1);
}

/* Mode Selection Cards */
.mode-selector-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}
@media (max-width: 600px) {
  .mode-selector-grid { grid-template-columns: 1fr; }
}

.mode-card {
  padding: 16px;
  border-radius: 14px;
  background: var(--surface-alt);
  border: 1px solid var(--glass-border);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
}
.mode-card:hover {
  border-color: var(--glass-border-hover);
  background: var(--surface-hover);
}
.mode-card.selected {
  background: var(--accent-subtle);
  border-color: var(--accent);
  box-shadow: 0 0 16px rgba(94, 106, 210, 0.25);
}
.mode-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.mode-card-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-primary);
}
.mode-card-desc {
  font-size: 0.76rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* Match Settings Row */
.host-settings-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}
@media (max-width: 640px) {
  .host-settings-row { grid-template-columns: 1fr; }
}

.btn-start-quiz {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  background: linear-gradient(135deg, #d1d5db, #9ca3af);
  border: none;
  color: #000000;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 6px 24px rgba(255, 255, 255, 0.15);
  transition: transform 0.15s, opacity 0.2s;
}
.btn-start-quiz:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(239, 68, 68, 0.5);
}
.btn-start-quiz:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* ═══════════════════════════════════════════════════
   VIEW 3: ACTIVE QUIZ ARENA (Mode 1 & Mode 2)
   ═══════════════════════════════════════════════════ */
#quiz-arena-view {
  display: none;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  animation: fadeIn 0.3s ease;
}

/* Question Card */
.quiz-card {
  width: 100%;
  padding: 24px;
  border-radius: 20px;
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
  transition: all 0.25s ease;
}

/* Question Header */
.card-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.q-progress-pill {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent-glow);
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--accent-subtle);
  border: 1px solid rgba(94, 106, 210, 0.25);
}
.q-timer-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
  background: var(--surface-alt);
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--glass-border);
}
.q-timer-badge.warning {
  color: var(--red);
  border-color: rgba(231, 76, 60, 0.4);
  animation: pulseTimer 0.8s ease-in-out infinite;
}
@keyframes pulseTimer {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.96); }
}

/* Countdown Progress Bar */
.countdown-bar-wrap {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 20px;
}
.countdown-bar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-glow));
  border-radius: 4px;
  transition: width 0.1s linear, background 0.3s;
}
.countdown-bar-fill.warning {
  background: linear-gradient(90deg, #f59e0b, #ef4444);
}

.question-text {
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.55;
  color: var(--text-primary);
  margin-bottom: 22px;
}

/* Option Buttons Grid */
.options-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.option-btn {
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--surface-alt);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}
.option-btn:hover:not(.locked) {
  background: var(--surface-hover);
  border-color: var(--glass-border-hover);
  transform: translateY(-1px);
}
.option-letter {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--accent-glow);
  flex-shrink: 0;
}
.option-label {
  flex: 1;
  line-height: 1.4;
}

/* Option Selected & Lock States */
.option-btn.selected {
  background: var(--accent-subtle);
  border-color: var(--accent);
  color: #fff;
}
.option-btn.locked {
  cursor: not-allowed;
  opacity: 0.85;
}
.option-btn.correct {
  background: rgba(34, 197, 94, 0.18) !important;
  border-color: #22c55e !important;
  color: #ffffff !important;
  box-shadow: 0 0 16px rgba(34, 197, 94, 0.3);
}
.option-btn.correct .option-letter {
  background: #22c55e;
  color: #000;
}
.option-btn.wrong {
  background: rgba(239, 68, 68, 0.18) !important;
  border-color: #ef4444 !important;
  color: #ffffff !important;
}
.option-btn.wrong .option-letter {
  background: #ef4444;
  color: #fff;
}

/* Card Feedback Banner */
.card-feedback {
  display: none;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.84rem;
  font-weight: 600;
  margin-top: 12px;
  align-items: center;
  justify-content: space-between;
}
.card-feedback.visible {
  display: flex;
}
.card-feedback.success {
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.35);
  color: var(--green-1);
}
.card-feedback.failure {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: var(--red);
}
.card-feedback.waiting {
  background: var(--surface-alt);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
}


/* Admin Arena Action Bar (Bottom Floating or Sticky) */
.admin-arena-bar {
  display: none;
  width: 100%;
  padding: 14px 20px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow);
  margin-top: 12px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.admin-arena-bar.visible {
  display: flex;
}

.arena-btn {
  padding: 9px 16px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid var(--glass-border);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}
.arena-btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}
.arena-btn.primary:hover {
  background: var(--accent-hover);
}
.arena-btn.danger {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.3);
  color: #ff6b6b;
}
.arena-btn.danger:hover {
  background: rgba(239, 68, 68, 0.25);
}

/* Round F1 Breakdown Table in Q-by-Q Mode */
.round-breakdown-card {
  width: 100%;
  padding: 20px;
  border-radius: 16px;
  margin-top: 16px;
  animation: slideUp 0.3s ease;
}
.round-breakdown-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ═══════════════════════════════════════════════════
   VIEW 4: GRAND PRIX PODIUM & RESULTS
   ═══════════════════════════════════════════════════ */
#quiz-podium-view {
  display: none;
  flex-direction: column;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  text-align: center;
  animation: fadeIn 0.4s ease;
}

.podium-showcase {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 16px;
  margin: 40px 0 32px;
}

.podium-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 130px;
}

.podium-driver-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  margin-bottom: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.podium-driver-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
  margin-bottom: 4px;
}
.podium-driver-pts {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent-glow);
  margin-bottom: 10px;
}

.podium-pedestal {
  width: 100%;
  border-radius: 16px 16px 0 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.9);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}
.podium-pedestal.first {
  height: 160px;
  background: linear-gradient(180deg, #d1d5db, #6b7280);
  border: 1px solid rgba(255, 255, 255, 0.5);
}
.podium-pedestal.second {
  height: 120px;
  background: linear-gradient(180deg, #9ca3af, #4b5563);
  border: 1px solid rgba(200, 200, 200, 0.5);
}
.podium-pedestal.third {
  height: 90px;
  background: linear-gradient(180deg, #6b7280, #374151);
  border: 1px solid rgba(150, 150, 150, 0.5);
}

/* AI Prompt Helper Modal */
#ai-helper-modal .modal-card {
  width: 500px;
  text-align: left;
}
.ai-sample-prompt-box {
  background: rgba(0, 0, 0, 0.4);
  padding: 12px;
  border-radius: 10px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  color: #e2e8f0;
  line-height: 1.45;
  white-space: pre-wrap;
  margin-bottom: 14px;
  border: 1px solid var(--glass-border);
}
