:root {
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --bg: #0f172a;
  --card-bg: #1e293b;
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --success: #22c55e;
  --danger: #ef4444;
  --glass: rgba(30, 41, 59, 0.7);
  --border: rgba(255, 255, 255, 0.1);
}

[data-theme="light"] {
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --text: #0f172a;
  --text-muted: #64748b;
  --glass: rgba(255, 255, 255, 0.8);
  --border: #e2e8f0;
}

@media (max-width: 768px) {
  body {
    align-items: flex-start;
    padding-top: 1rem;
    height: auto;
  }
  .container {
    padding: 1rem;
    width: 95%;
    margin: 0 auto 2rem auto;
    border-radius: 16px;
  }
  h1 {
    font-size: 1.5rem;
    text-align: center;
  }
  .btn {
    padding: 0.8rem;
    font-size: 0.9rem;
    width: 100%; /* Stack buttons */
    margin-bottom: 0.5rem;
  }

  /* Header adjustments */
  .header-flex {
    flex-direction: column;
    gap: 1rem;
    align-items: center !important;
  }
  
  /* Header buttons container */
  .header-flex > div {
    display: flex;
    justify-content: center;
    flex-wrap: wrap; 
    gap: 0.5rem !important;
    width: 100%;
  }

  /* Admin Nav Overflow Fix */
  .admin-nav {
      display: flex;
      overflow-x: auto;
      white-space: nowrap;
      padding-bottom: 0.5rem;
      width: 100%;
      -webkit-overflow-scrolling: touch;
      margin-bottom: 1.5rem;
      gap: 0.5rem;
      border-bottom: 1px solid var(--border);
  }

  .nav-link {
      flex: 0 0 auto;
      padding: 0.6rem 1rem;
      background: rgba(255, 255, 255, 0.05);
      border-radius: 8px;
  }

  .score-table th,
  .score-table td {
    padding: 0.5rem;
    font-size: 0.8rem;
  }
  .stat-card {
    padding: 1rem;
  }
}

@media (max-width: 480px) {
  h1 {
    font-size: 1.5rem;
  }
  .container {
    padding: 1rem;
  }
  .category-grid {
    grid-template-columns: 1fr;
  } /* 1 column for very small screens */
  .option-btn {
    font-size: 0.9rem;
    padding: 0.8rem;
  }
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family:
    "Inter",
    -apple-system,
    sans-serif;
}

body {
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
  padding: 20px 0;
}

.container {
  max-width: 800px;
  width: 90%;
  padding: 2.5rem;
  background: var(--glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  animation: fadeIn 0.6s ease-out;
}

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

h1 {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, #818cf8 0%, #c084fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-align: center;
}

.subtitle {
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 2rem;
}

/* Category Grid */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.category-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  padding: 1.5rem;
  border-radius: 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
  color: var(--text);
}

.category-card:hover {
  transform: translateY(-5px);
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.1);
  box-shadow: 0 10px 20px -10px rgba(99, 102, 241, 0.3);
}

.category-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  display: block;
}

.category-name {
  font-weight: 600;
}

/* Buttons */
.btn {
  display: inline-block;
  width: 100%;
  padding: 1rem 2rem;
  background: var(--primary);
  color: white;
  text-decoration: none;
  border-radius: 12px;
  font-weight: 600;
  text-align: center;
  transition: all 0.3s ease;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

.btn:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(99, 102, 241, 0.4);
}

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

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

/* Quiz UI */
.timer {
  text-align: right;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 0.5rem;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--card-bg);
  border-radius: 4px;
  margin-bottom: 2rem;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  width: 0%;
  transition: width 0.3s ease;
}

.question-text {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  display: block;
}

.options-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-bottom: 2rem;
}

@media (min-width: 600px) {
  .options-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* Admin Grid Layout */
.admin-grid {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 900px) {
  .admin-grid {
    grid-template-columns: 1fr;
  }
}

/* Utility for Flex Headers */
.header-flex {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.option-btn {
  background: var(--card-bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 1rem 1.5rem;
  border-radius: 12px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 1rem;
  position: relative;
  overflow: hidden;
}

.option-btn:hover {
  border-color: var(--primary);
}

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

.option-btn.correct {
  background-color: var(--success) !important;
  color: white !important;
  border-color: var(--success) !important;
}

.option-btn.wrong {
  background-color: var(--danger) !important;
  color: white !important;
  border-color: var(--danger) !important;
}

/* Result & Score Card */
.score-circle {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  border: 8px solid var(--primary);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  margin: 2rem auto;
}

.score-num {
  font-size: 3rem;
  font-weight: 800;
}

.score-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}

.score-table th,
.score-table td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.score-table th {
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
}

.badge {
  padding: 0.25rem 0.75rem;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-python {
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
}
.badge-gk {
  background: rgba(168, 85, 247, 0.2);
  color: #c084fc;
}
.badge-science {
  background: rgba(34, 197, 94, 0.2);
  color: #4ade80;
}
.badge-history {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
}
.badge-math {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
}
