:root {
  --panel-bg: rgba(30, 41, 59, 0.7);
  --panel-border: rgba(255, 255, 255, 0.1);
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-dim: rgba(59, 130, 246, 0.15);
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --review: #8b5cf6;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
}

body.dark-theme {
  color: var(--text-main);
  font-family: 'Inter', sans-serif;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.glass-panel {
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
}

.quiz-navbar {
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  flex-wrap: nowrap !important;
  padding: 0.5rem 1.25rem !important;
  min-height: 52px !important;
  height: 52px !important;
  background: rgba(10, 16, 30, 0.98) !important;
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  position: sticky !important;
  top: 0 !important;
  z-index: 1000 !important;
}

.quiz-navbar .navbar-brand {
  font-size: 1.1rem !important;
  font-weight: 800 !important;
  white-space: nowrap !important;
  display: flex !important;
  align-items: center !important;
  gap: 0.4rem !important;
  color: #fff !important;
}

.quiz-navbar .quiz-header-actions {
  display: flex !important;
  align-items: center !important;
  gap: 0.5rem !important;
  flex-wrap: nowrap !important;
  margin: 0 !important;
}

.quiz-navbar .btn {
  padding: 0.35rem 0.75rem !important;
  font-size: 0.8rem !important;
  height: 32px !important;
  border-radius: 6px !important;
  white-space: nowrap !important;
  margin: 0 !important;
}

.screen {
  display: none;
  flex: 1;
  padding: 1.25rem;
}

.screen.active {
  display: flex;
  flex-direction: column;
}

#loading-screen {
  align-items: center;
  justify-content: center;
}

.loader {
  border: 4px solid var(--panel-border);
  border-top: 4px solid var(--primary);
  border-radius: 50%;
  width: 50px;
  height: 50px;
  animation: spin 1s linear infinite;
  margin-bottom: 1rem;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.exam-container {
  display: flex;
  gap: 1.5rem;
  max-width: 100%;
  margin: 0 auto;
  width: 100%;
}

.ad-container {
  margin-bottom: 1rem;
  min-height: 90px;
  width: 100%;
  display: flex;
  justify-content: center;
}

.question-panel {
  flex: 3;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 1.5rem;
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

.status-panel {
  flex: 1;
  min-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.5rem;
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

.section-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 0.5rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.section-tabs::-webkit-scrollbar {
  display: none;
}

.section-tab {
  padding: 0.5rem 1rem;
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--text-main);
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.section-tab.active {
  background: var(--primary-dim);
  color: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.2);
}

.section-tab:hover:not(.active) {
  background: rgba(255, 255, 255, 0.05);
}

.question-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 1.2rem;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  font-weight: 600;
}

.q-number {
  color: var(--text-main);
  font-weight: 700;
}

.q-marks {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.question-content {
  font-size: 1.15rem;
  line-height: 1.6;
  padding: 1.25rem;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  color: #f1f5f9;
}

.options-container {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.option-label {
  display: flex;
  align-items: center;
  padding: 1rem 1.2rem;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.2s ease;
}

.option-label:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--primary);
}

.option-label input[type="radio"] {
  margin-right: 0.85rem;
  transform: scale(1.2);
  accent-color: var(--primary);
  flex-shrink: 0;
}

.option-label.selected {
  background: rgba(59, 130, 246, 0.12);
  border-color: var(--primary);
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.2);
}

.action-buttons {
  display: flex;
  justify-content: space-between;
  margin-top: auto;
  gap: 1rem;
}

.btn {
  padding: 0.75rem 1.4rem;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

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

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

.btn-secondary {
  background: var(--review);
  color: white;
}

.btn-secondary:hover {
  background: #7c3aed;
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--text-muted);
  color: var(--text-main);
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Timer Card */
.timer-card {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.85rem 1.2rem;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: 12px;
  width: 100%;
  box-sizing: border-box;
}

.timer-card .timer-icon {
  font-size: 1.3rem;
  line-height: 1;
}

.timer-card .timer-label {
  font-size: 0.95rem;
  color: var(--text-muted);
  font-weight: 600;
}

.timer-card #timer-display,
.timer-card .timer-value {
  font-family: 'Outfit', monospace, sans-serif !important;
  font-size: 1.45rem !important;
  font-weight: 900 !important;
  color: #f87171 !important;
  letter-spacing: 1px !important;
  background: none !important;
  padding: 0 !important;
  margin: 0 !important;
  border: none !important;
  box-shadow: none !important;
}

.palette-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  padding: 0.85rem;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  font-size: 0.85rem;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.badge {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.badge.answered { background: var(--success); }
.badge.not-answered { background: var(--danger); }
.badge.review { background: var(--review); }
.badge.not-visited {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.palette-container {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 0.5rem 0;
  overflow-y: visible;
}

.palette-section-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 0.4rem;
  margin-bottom: -0.4rem;
  font-family: 'Outfit', sans-serif;
  letter-spacing: 0.5px;
}

.palette-section-title.active {
  color: var(--primary);
  border-color: var(--primary);
}

.palette-grid-inner {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
  gap: 0.45rem;
  width: 100%;
}

.pal-btn {
  width: 100%;
  aspect-ratio: 1;
  height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pal-btn:hover {
  transform: scale(1.08);
}

.pal-btn.answered {
  background: var(--success);
  color: white;
  border-color: transparent;
}

.pal-btn.not-answered {
  background: var(--danger);
  color: white;
  border-color: transparent;
}

.pal-btn.review {
  background: var(--review);
  color: white;
  border-color: transparent;
}

/* Responsive Mobile Layout (<= 768px) */
@media (max-width: 768px) {
  html, body.dark-theme {
    height: auto !important;
    min-height: 100vh !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
  }
  
  .screen, .screen.active, #exam-screen {
    height: auto !important;
    overflow: visible !important;
    padding: 0.5rem 0.6rem 3rem !important;
  }
  
  .exam-container {
    flex-direction: column;
    gap: 1.25rem;
    height: auto !important;
    overflow: visible !important;
  }
  
  .question-panel {
    padding: 1rem 0.85rem !important;
    border-radius: 14px;
    gap: 0.9rem;
    overflow: visible !important;
    height: auto !important;
  }
  
  .section-tabs {
    margin-bottom: 0.4rem;
    padding-bottom: 0.4rem;
    gap: 0.4rem;
  }
  
  .section-tab {
    padding: 0.4rem 0.75rem;
    font-size: 0.82rem;
    border-radius: 6px;
  }
  
  .question-header {
    padding: 0.65rem 0.85rem;
    font-size: 0.88rem;
  }
  
  .question-content {
    padding: 1rem 0.9rem;
    font-size: 1.05rem;
    line-height: 1.55;
    border-radius: 10px;
  }
  
  .options-container {
    gap: 0.6rem;
  }
  
  .option-label {
    padding: 0.85rem 0.9rem;
    font-size: 0.95rem;
    border-radius: 10px;
    line-height: 1.45;
  }
  
  .action-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
    margin-top: 0.75rem;
  }
  
  #btn-save-next {
    grid-column: 1 / -1;
    order: -1;
    padding: 0.85rem 1rem;
    font-size: 1rem;
    font-weight: 700;
    border-radius: 10px;
  }
  
  #btn-mark-review, #btn-clear {
    padding: 0.7rem 0.5rem;
    font-size: 0.8rem;
    text-align: center;
    border-radius: 8px;
    line-height: 1.3;
  }
  
  .status-panel {
    padding: 1rem 0.85rem !important;
    border-radius: 14px;
    min-width: 100%;
    overflow: visible !important;
    height: auto !important;
    max-height: none !important;
  }
  
  .palette-stats {
    padding: 0.75rem 0.6rem;
    font-size: 0.8rem;
    gap: 0.4rem;
  }
  
  .palette-container {
    max-height: none !important;
    overflow: visible !important;
    padding: 0.5rem 0;
  }
  
  .palette-grid-inner {
    grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
    gap: 0.4rem;
  }
  
  .pal-btn {
    height: 36px;
    font-size: 0.82rem;
  }
}