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

:root {
  --bg: #0f1923;
  --bg-darker: #0a1118;
  --bg-card: #1a2c38;
  --bg-input: #0f1923;
  --bg-sidebar: #0a1118;
  --border: #243442;
  --border-light: #2a3f4f;
  --text: #e0e8ed;
  --text-muted: #7a8e9e;
  --text-dim: #506778;
  --primary: #00e701;
  --primary-hover: #00ff01;
  --primary-dim: rgba(0,231,1,0.15);
  --danger: #ed4245;
  --danger-hover: #ff5e4f;
  --success: #00e701;
  --success-hover: #00ff01;
  --cyan: #00d4ff;
  --purple: #a855f7;
  --gold: #fbbf24;
  --silver: #94a3b8;
  --bronze: #cd7f32;
  --diamond: #22d3ee;
  --radius: 8px;
  --radius-lg: 12px;
  --sidebar-width: 220px;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  font-size: 14px;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); text-decoration: underline; }

/* ---- SIDEBAR LAYOUT ---- */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 20px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-brand h1 {
  font-size: 1rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.02em;
}
.sidebar-brand .brand-sub {
  font-size: 0.65rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 2px;
}

.sidebar-nav {
  padding: 12px 8px;
  flex: 1;
}
.sidebar-nav .nav-label {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 12px 12px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  text-decoration: none;
}
.nav-item:hover {
  background: rgba(255,255,255,0.05);
  color: var(--text);
  text-decoration: none;
}
.nav-item.active {
  background: var(--primary-dim);
  color: var(--primary);
}
.nav-item .nav-icon {
  font-size: 1.1rem;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-user {
  padding: 12px 12px;
  border-top: 1px solid var(--border);
}
.sidebar-user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius);
  margin-bottom: 8px;
}
.sidebar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.85rem;
  color: var(--primary);
  flex-shrink: 0;
}
.sidebar-user-details {
  min-width: 0;
}
.sidebar-user-name {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text);
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-user-rank {
  font-size: 0.7rem;
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
}

/* ---- TOP BAR ---- */
.topbar {
  height: 56px;
  background: var(--bg-darker);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-content {
  padding: 24px;
  max-width: 1200px;
}

/* ---- BUTTONS ---- */
.btn {
  padding: 10px 18px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #0f1923; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); box-shadow: 0 0 20px rgba(0,231,1,0.2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--danger-hover); }
.btn-success { background: var(--success); color: #0f1923; }
.btn-success:hover:not(:disabled) { background: var(--success-hover); }
.btn-warning { background: var(--gold); color: #0f1923; }
.btn-warning:hover:not(:disabled) { background: #f59e0b; }
.btn-icon {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.btn-icon:hover { background: var(--primary-dim); color: var(--primary); border-color: var(--primary); }
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.btn-outline:hover:not(:disabled) { background: rgba(255,255,255,0.05); color: var(--text); }
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  padding: 8px 12px;
}
.btn-ghost:hover:not(:disabled) { color: var(--text); background: rgba(255,255,255,0.05); }
.btn-sm { padding: 6px 12px; font-size: 0.7rem; }
.btn-block { width: 100%; justify-content: center; }

/* ---- CARD ---- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-title .icon {
  font-size: 1rem;
}

/* ---- FORMS ---- */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  color: var(--text);
  font-size: 0.875rem;
  transition: border-color 0.15s;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
}
.form-control::placeholder {
  color: var(--text-dim);
}
select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%237a8e9e' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

/* ---- TABS (Admin) ---- */
.tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 20px;
  background: var(--bg-darker);
  border-radius: var(--radius);
  padding: 3px;
}
.tab-btn {
  padding: 8px 16px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.15s;
}
.tab-btn.active {
  background: var(--bg-card);
  color: var(--text);
}
.tab-btn:hover:not(.active) { color: var(--text); }

/* ---- TABLE ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
}
th {
  color: var(--text-dim);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.65rem;
  letter-spacing: 0.08em;
}
tr:hover td { background: rgba(255,255,255,0.02); }

/* ---- LOGIN ---- */
.login-page {
  min-height: 100vh;
  display: flex;
  background: var(--bg-darker);
}
.login-left {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}
.login-card {
  width: 100%;
  max-width: 380px;
}
.login-card h1 {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 4px;
}
.login-card .subtitle {
  color: var(--text-dim);
  margin-bottom: 28px;
  font-size: 0.85rem;
}
.login-tabs {
  display: flex;
  margin-bottom: 20px;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 3px;
  border: 1px solid var(--border);
}
.login-tab {
  flex: 1;
  padding: 9px;
  text-align: center;
  border: none;
  background: none;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.15s;
}
.login-tab.active {
  background: var(--primary);
  color: #0f1923;
}
.auth-toggle {
  text-align: center;
  margin-top: 20px;
  font-size: 0.8rem;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0;
  transition: color 0.15s;
}
.btn-link:hover { color: var(--primary-hover); text-decoration: underline; }
.login-right {
  flex: 1;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 40px;
  border-left: 1px solid var(--border);
}
.login-right h2 {
  font-size: 1.75rem;
  font-weight: 800;
  margin-bottom: 12px;
  color: var(--text);
}
.login-right p {
  color: var(--text-muted);
  font-size: 0.9rem;
  max-width: 320px;
  text-align: center;
  line-height: 1.6;
}
.login-features {
  margin-top: 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.login-feature {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.login-feature .feat-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--primary-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
@media (max-width: 768px) {
  .login-right { display: none; }
}

/* ---- ARENA LAYOUT ---- */
.arena-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
}
@media (max-width: 900px) {
  .arena-grid { grid-template-columns: 1fr; }
}

/* ---- QUESTION CARD ---- */
.question-card {
  text-align: center;
  padding: 32px 24px;
}
.question-text {
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.3;
  margin-bottom: 28px;
}
.round-type-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 16px;
}
.round-type-normal { background: rgba(0,231,1,0.1); color: var(--primary); }
.round-type-double { background: rgba(251,191,36,0.15); color: var(--gold); }
.round-type-streak_booster { background: rgba(0,212,255,0.15); color: var(--cyan); }
.round-type-speed { background: rgba(237,66,69,0.15); color: var(--danger); }

/* ---- TIMER ---- */
.timer-bar {
  height: 4px;
  background: var(--bg-input);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 6px;
}
.timer-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  transition: width 0.3s linear, background 0.3s;
}
.timer-bar-fill.urgent { background: var(--danger); }
.timer-text {
  font-size: 1.75rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  margin-bottom: 20px;
  color: var(--primary);
}
.timer-text.urgent { color: var(--danger); animation: timerPulse 0.5s ease-in-out infinite; }
@keyframes timerPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.option-btn {
  padding: 20px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-input);
  color: var(--text);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}
.option-btn:hover:not(:disabled) { border-color: var(--primary); background: rgba(0,231,1,0.05); }
.option-btn.option-a:hover:not(:disabled) { border-color: var(--cyan); background: rgba(0,212,255,0.08); }
.option-btn.option-b:hover:not(:disabled) { border-color: var(--purple); background: rgba(168,85,247,0.08); }
.option-btn.selected-a { border-color: var(--cyan); background: var(--cyan); color: #0f1923; }
.option-btn.selected-b { border-color: var(--purple); background: var(--purple); color: #fff; }
.option-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.option-label {
  display: block;
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  opacity: 0.6;
  margin-bottom: 4px;
  font-weight: 800;
}

/* ---- WAITING STATE ---- */
.waiting-state {
  text-align: center;
  padding: 48px 20px;
}
.waiting-state .pulse-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--primary-dim);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  animation: pulse 2s ease-in-out infinite;
  font-size: 1.75rem;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.08); opacity: 0.7; }
}
.waiting-state h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 6px;
}
.waiting-state p { color: var(--text-muted); font-size: 0.85rem; }

/* ---- RESULT ANIMATIONS ---- */
.result-badge {
  display: inline-block;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.result-correct { background: rgba(0,231,1,0.12); color: var(--success); }
.result-incorrect { background: rgba(237,66,69,0.12); color: var(--danger); }

@keyframes flashGreen {
  0% { box-shadow: 0 0 0 0 rgba(0,231,1,0.5); }
  50% { box-shadow: 0 0 30px 8px rgba(0,231,1,0.2); }
  100% { box-shadow: 0 0 0 0 rgba(0,231,1,0); }
}
@keyframes flashRed {
  0% { box-shadow: 0 0 0 0 rgba(237,66,69,0.5); }
  50% { box-shadow: 0 0 30px 8px rgba(237,66,69,0.2); }
  100% { box-shadow: 0 0 0 0 rgba(237,66,69,0); }
}
.flash-correct { animation: flashGreen 0.8s ease-out; }
.flash-incorrect { animation: flashRed 0.8s ease-out; }

/* ---- STREAK DISPLAY ---- */
.streak-display {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--gold);
}
.streak-fire { font-size: 0.85rem; }

/* ---- RANK BADGE ---- */
.rank-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.rank-bronze { background: rgba(205,127,50,0.15); color: var(--bronze); }
.rank-silver { background: rgba(148,163,184,0.15); color: var(--silver); }
.rank-gold { background: rgba(251,191,36,0.15); color: var(--gold); }
.rank-diamond { background: rgba(34,211,238,0.15); color: var(--diamond); }

/* ---- SIDEBAR LEADERBOARD & STATS ---- */
.score-display {
  text-align: center;
  padding: 16px;
  background: var(--bg-input);
  border-radius: var(--radius);
  margin-bottom: 12px;
}
.score-display .label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  margin-bottom: 4px;
  font-weight: 700;
}
.score-display .value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}
.mini-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}
.mini-stat {
  text-align: center;
  padding: 10px 8px;
  background: var(--bg-input);
  border-radius: var(--radius);
}
.mini-stat .label {
  font-size: 0.55rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin-bottom: 2px;
  font-weight: 700;
}
.mini-stat .value {
  font-size: 1rem;
  font-weight: 800;
}

.lb-list { list-style: none; }
.lb-item {
  display: flex;
  align-items: center;
  padding: 8px 10px;
  border-radius: 6px;
  margin-bottom: 2px;
  transition: background 0.1s;
  gap: 8px;
}
.lb-item:hover { background: rgba(255,255,255,0.03); }
.lb-item.lb-leader {
  background: linear-gradient(135deg, rgba(251,191,36,0.08), rgba(251,191,36,0.02));
  border: 1px solid rgba(251,191,36,0.12);
}
.lb-rank {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 800;
  background: var(--bg-input);
  flex-shrink: 0;
}
.lb-item:nth-child(1) .lb-rank { background: var(--gold); color: #0f1923; }
.lb-item:nth-child(2) .lb-rank { background: var(--silver); color: #0f1923; }
.lb-item:nth-child(3) .lb-rank { background: var(--bronze); color: #0f1923; }
.lb-info { flex: 1; min-width: 0; }
.lb-name { font-weight: 700; font-size: 0.8rem; display: block; }
.lb-meta { font-size: 0.6rem; color: var(--text-dim); display: flex; gap: 6px; align-items: center; }
.lb-score {
  font-weight: 800;
  font-size: 0.8rem;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.lb-you { color: var(--cyan); }

/* ---- NEW LEADER NOTIFICATION ---- */
.new-leader-notif {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, rgba(251,191,36,0.2), rgba(251,191,36,0.05));
  border: 1px solid rgba(251,191,36,0.25);
  padding: 10px 24px;
  border-radius: var(--radius);
  font-weight: 800;
  font-size: 0.85rem;
  color: var(--gold);
  z-index: 200;
  animation: slideDown 0.4s ease, fadeOut 0.5s 3s ease forwards;
}
@keyframes slideDown {
  from { transform: translateX(-50%) translateY(-20px); opacity: 0; }
  to { transform: translateX(-50%) translateY(0); opacity: 1; }
}
@keyframes fadeOut {
  to { opacity: 0; transform: translateX(-50%) translateY(-10px); }
}

/* ---- ADMIN ---- */
.admin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}
@media (max-width: 800px) {
  .admin-grid { grid-template-columns: 1fr; }
}
.section-title {
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.6rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge-admin { background: rgba(237,66,69,0.15); color: var(--danger); }
.badge-user { background: rgba(0,231,1,0.1); color: var(--primary); }
.badge-active { background: rgba(0,231,1,0.12); color: var(--success); }
.badge-ended { background: rgba(122,142,158,0.15); color: var(--text-muted); }

.submission-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: 6px;
  background: var(--bg-input);
  margin-bottom: 4px;
  font-size: 0.8rem;
}
.submission-answer {
  font-weight: 800;
  padding: 2px 10px;
  border-radius: 4px;
  font-size: 0.7rem;
}
.submission-answer.a { background: rgba(0,212,255,0.15); color: var(--cyan); }
.submission-answer.b { background: rgba(168,85,247,0.15); color: var(--purple); }

/* ---- PROFILE ---- */
.profile-header {
  text-align: center;
  margin-bottom: 24px;
}
.profile-header h1 {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 6px;
}
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
@media (max-width: 700px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  text-align: center;
}
.stat-card .stat-label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin-bottom: 4px;
  font-weight: 700;
}
.stat-card .stat-value {
  font-size: 1.5rem;
  font-weight: 800;
}
.stat-card .stat-value.primary { color: var(--primary); }
.stat-card .stat-value.gold { color: var(--gold); }
.stat-card .stat-value.cyan { color: var(--cyan); }
.stat-card .stat-value.success { color: var(--success); }

/* ---- HALL OF FAME ---- */
.hof-week { margin-bottom: 16px; }
.hof-week h4 {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-bottom: 6px;
  font-weight: 700;
}
.hof-entry {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg-input);
  border-radius: 6px;
  margin-bottom: 4px;
  font-size: 0.8rem;
}
.hof-position { font-size: 1.1rem; }

/* ---- MODAL ---- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.75);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.15s ease;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  max-width: 520px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  animation: modalSlide 0.2s ease;
}
@keyframes modalSlide {
  from { transform: translateY(16px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 {
  font-size: 1rem;
  font-weight: 800;
}
.modal-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.1s;
}
.modal-close:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.modal-body { padding: 20px; }
.rule-section { margin-bottom: 16px; }
.rule-section:last-child { margin-bottom: 0; }
.rule-section h3 {
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--primary);
}
.rule-section p {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 4px;
}
.rule-section ul { list-style: none; padding: 0; }
.rule-section li {
  font-size: 0.8rem;
  padding: 4px 0;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---- SETTINGS ---- */
.settings-section {
  margin-top: 24px;
  border-top: 1px solid var(--border);
  padding-top: 24px;
}
.settings-title {
  font-size: 1rem;
  font-weight: 800;
  margin-bottom: 16px;
}
.settings-msg {
  margin-top: 10px;
  font-size: 0.8rem;
  font-weight: 700;
  min-height: 18px;
}
.settings-msg.success { color: var(--success); }
.settings-msg.error { color: var(--danger); }

/* ---- TOAST ---- */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.toast {
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 0.8rem;
  font-weight: 700;
  animation: toastIn 0.2s ease;
  max-width: 320px;
}
.toast-success { background: var(--success); color: #0f1923; }
.toast-error { background: var(--danger); color: #fff; }
@keyframes toastIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ---- LIVE USERS LIST ---- */
.live-users-header {
  display: grid;
  grid-template-columns: 1fr 80px 80px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
}
.lu-col-name {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}
.lu-col-opt {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.live-users-header .lu-opt-a { color: var(--primary); }
.live-users-header .lu-opt-b { color: var(--cyan); }
.live-users-list {
  max-height: 400px;
  overflow-y: auto;
}
.lu-empty {
  padding: 24px 16px;
  text-align: center;
  font-size: 0.8rem;
}
.lu-row {
  display: grid;
  grid-template-columns: 1fr 80px 80px;
  padding: 8px 16px;
  align-items: center;
  border-bottom: 1px solid rgba(36,52,66,0.4);
  transition: background 0.15s;
}
.lu-row:last-child { border-bottom: none; }
.lu-row:hover { background: rgba(255,255,255,0.02); }
.lu-user {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.lu-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  flex-shrink: 0;
  box-shadow: 0 0 6px rgba(0,231,1,0.4);
}
.lu-dot.lu-dot-away {
  background: var(--text-dim);
  box-shadow: none;
}
.lu-name {
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lu-opt {
  text-align: center;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-dim);
  background: rgba(255,255,255,0.03);
  border: 1px solid transparent;
  transition: all 0.3s ease;
}
.lu-opt.lu-picked {
  animation: lu-flash 0.5s ease;
}
.lu-opt.lu-opt-a.lu-picked {
  background: rgba(0,231,1,0.15);
  color: var(--primary);
  border-color: rgba(0,231,1,0.35);
  box-shadow: 0 0 12px rgba(0,231,1,0.2);
}
.lu-opt.lu-opt-b.lu-picked {
  background: rgba(0,212,255,0.15);
  color: var(--cyan);
  border-color: rgba(0,212,255,0.35);
  box-shadow: 0 0 12px rgba(0,212,255,0.2);
}
.lu-opt.lu-correct {
  background: rgba(0,231,1,0.2) !important;
  color: var(--primary) !important;
  border-color: rgba(0,231,1,0.5) !important;
  box-shadow: 0 0 16px rgba(0,231,1,0.3) !important;
}
.lu-opt.lu-incorrect {
  background: rgba(237,66,69,0.15) !important;
  color: var(--danger) !important;
  border-color: rgba(237,66,69,0.35) !important;
  box-shadow: 0 0 12px rgba(237,66,69,0.2) !important;
}
@keyframes lu-flash {
  0% { transform: scale(1); }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

/* ---- MISC ---- */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; }
.gap-2 { gap: 8px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* ---- MOBILE SIDEBAR ---- */
.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px;
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.2s ease; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .sidebar-toggle { display: block; }
  .sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 99;
    display: none;
  }
  .sidebar-overlay.show { display: block; }
}
