:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #111118;
  --bg-card: #16161f;
  --bg-elevated: #1e1e2a;
  --accent-primary: #7c3aed;
  --accent-secondary: #06b6d4;
  --accent-warning: #f59e0b;
  --accent-success: #10b981;
  --accent-danger: #ef4444;
  --text-primary: #f1f0f7;
  --text-secondary: #9d9ab5;
  --text-muted: #5c5975;
  --border-color: rgba(255,255,255,0.06);
  --border-accent: rgba(124,58,237,0.3);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.4);
  --shadow-md: 0 8px 32px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 40px rgba(124,58,237,0.2);
  --font-display: 'Syne', sans-serif;
  --font-body: 'DM Sans', sans-serif;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --transition-fast: 0.15s ease;
  --transition-base: 0.25s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(124,58,237,0.12) 0%, transparent 60%),
    radial-gradient(ellipse 40% 40% at 90% 80%, rgba(6,182,212,0.06) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* ── Navbar ── */
.navbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 2rem; height: 68px;
  background: rgba(10,10,15,0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-color);
}

.logo {
  font-family: var(--font-display); font-weight: 800; font-size: 1.4rem;
  color: var(--text-primary); text-decoration: none;
  display: flex; align-items: center; gap: 0.4rem;
}
.logo-accent { color: var(--accent-primary); }

.navbar-menu { display: flex; align-items: center; gap: 0.5rem; }

.nav-link {
  color: var(--text-secondary); text-decoration: none; font-weight: 500;
  padding: 0.5rem 0.9rem; border-radius: var(--radius-sm);
  transition: color var(--transition-fast), background var(--transition-fast);
}
.nav-link:hover { color: var(--text-primary); background: var(--bg-elevated); }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.65rem 1.4rem; border-radius: var(--radius-sm);
  font-family: var(--font-body); font-weight: 500; font-size: 0.95rem;
  cursor: pointer; border: none; text-decoration: none;
  transition: all var(--transition-fast);
}
.btn-primary { background: var(--accent-primary); color: white; box-shadow: 0 0 20px rgba(124,58,237,0.3); }
.btn-primary:hover { background: #6d28d9; box-shadow: 0 0 30px rgba(124,58,237,0.5); transform: translateY(-1px); }
.btn-secondary { background: var(--bg-elevated); color: var(--text-primary); border: 1px solid var(--border-color); }
.btn-secondary:hover { border-color: var(--border-accent); }
.btn-outline { background: transparent; color: var(--accent-primary); border: 1px solid var(--border-accent); }
.btn-outline:hover { background: rgba(124,58,237,0.1); }
.btn-danger { background: var(--accent-danger); color: white; }
.btn-success { background: var(--accent-success); color: white; }
.btn-lg { padding: 0.85rem 2rem; font-size: 1.05rem; }
.btn-sm { padding: 0.4rem 0.9rem; font-size: 0.85rem; }
.btn-full { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* ── Cards ── */
.card {
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: var(--radius-lg); padding: 1.5rem;
  position: relative; overflow: hidden;
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
}
.card:hover { border-color: var(--border-accent); box-shadow: var(--shadow-glow); }
.card-elevated { background: var(--bg-elevated); box-shadow: var(--shadow-md); }

/* ── Forms ── */
.form-group { margin-bottom: 1.25rem; }
.form-label {
  display: block; font-size: 0.875rem; font-weight: 500;
  color: var(--text-secondary); margin-bottom: 0.5rem;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.form-control {
  width: 100%; padding: 0.75rem 1rem;
  background: var(--bg-primary); border: 1px solid var(--border-color);
  border-radius: var(--radius-sm); color: var(--text-primary);
  font-family: var(--font-body); font-size: 1rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
}
.form-control:focus { border-color: var(--accent-primary); box-shadow: 0 0 0 3px rgba(124,58,237,0.15); }
.form-control::placeholder { color: var(--text-muted); }
.form-error { font-size: 0.8rem; color: var(--accent-danger); margin-top: 0.35rem; }

/* ── Badge ── */
.badge {
  display: inline-flex; align-items: center;
  padding: 0.25rem 0.7rem; border-radius: 100px;
  font-size: 0.75rem; font-weight: 600; letter-spacing: 0.03em;
}
.badge-primary { background: rgba(124,58,237,0.2); color: #a78bfa; }
.badge-success { background: rgba(16,185,129,0.2); color: #34d399; }
.badge-warning { background: rgba(245,158,11,0.2); color: #fcd34d; }
.badge-danger  { background: rgba(239,68,68,0.2);  color: #f87171; }
.badge-info    { background: rgba(6,182,212,0.2);  color: #67e8f9; }

/* ── Layout ── */
.container { max-width: 1200px; margin: 0 auto; padding: 0 1.5rem; position: relative; z-index: 1; }
.grid-2 { display: grid; grid-template-columns: repeat(2,1fr); gap: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 1.5rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 1.25rem; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-1 { gap: 0.5rem; } .gap-2 { gap: 1rem; } .gap-3 { gap: 1.5rem; }
.mt-1 { margin-top: 0.5rem; } .mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; } .mt-4 { margin-top: 2rem; }
.mb-2 { margin-bottom: 1rem; } .mb-3 { margin-bottom: 1.5rem; } .mb-4 { margin-bottom: 2rem; }
.py-section { padding: 4rem 0; }

/* ── Typography ── */
h1,h2,h3,h4 { font-family: var(--font-display); font-weight: 700; line-height: 1.2; }
h1 { font-size: clamp(2rem,5vw,3.5rem); }
h2 { font-size: clamp(1.5rem,3vw,2.2rem); }
h3 { font-size: 1.3rem; }
.text-gradient {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.text-muted { color: var(--text-secondary); }
.text-center { text-align: center; }

/* ── Toast ── */
#toast-container {
  position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 9999;
  display: flex; flex-direction: column; gap: 0.75rem;
}
.toast {
  min-width: 280px; padding: 0.9rem 1.2rem; border-radius: var(--radius-md);
  background: var(--bg-elevated); border: 1px solid var(--border-color);
  color: var(--text-primary); font-size: 0.9rem; box-shadow: var(--shadow-md);
  animation: slideInRight 0.3s ease, fadeOut 0.3s ease 3.7s forwards;
  display: flex; align-items: center; gap: 0.75rem;
}
.toast-success { border-color: rgba(16,185,129,0.4); }
.toast-error   { border-color: rgba(239,68,68,0.4); }
.toast-info    { border-color: rgba(6,182,212,0.4); }

/* ── Timer Bar ── */
.timer-bar-container { width: 100%; height: 6px; background: var(--bg-elevated); border-radius: 100px; overflow: hidden; }
.timer-bar { height: 100%; background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary)); transition: width 1s linear; border-radius: 100px; }
.timer-bar.urgent { background: linear-gradient(90deg, var(--accent-warning), var(--accent-danger)); }

/* ── Scoreboard ── */
.scoreboard-item {
  display: flex; align-items: center; gap: 1rem; padding: 0.85rem 1rem;
  border-radius: var(--radius-md); background: var(--bg-secondary);
  border: 1px solid var(--border-color); transition: all var(--transition-base);
}
.scoreboard-item.current-player { border-color: var(--border-accent); background: rgba(124,58,237,0.1); }
.scoreboard-item .rank { font-family: var(--font-display); font-weight: 800; font-size: 1.1rem; min-width: 2rem; color: var(--text-muted); }
.scoreboard-item.rank-1 .rank { color: #fbbf24; }
.scoreboard-item.rank-2 .rank { color: #9ca3af; }
.scoreboard-item.rank-3 .rank { color: #cd7c2f; }

/* ── Answer Options ── */
.answer-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 1rem; }
.answer-option {
  padding: 1.2rem 1.5rem; border-radius: var(--radius-md);
  border: 2px solid var(--border-color); background: var(--bg-card);
  color: var(--text-primary); font-size: 1rem; font-weight: 500;
  cursor: pointer; text-align: left; transition: all var(--transition-fast);
  display: flex; align-items: center; gap: 0.75rem; font-family: var(--font-body);
}
.answer-option:hover:not(:disabled) { border-color: var(--accent-primary); background: rgba(124,58,237,0.08); transform: translateY(-2px); }
.answer-option.selected { border-color: var(--accent-primary); background: rgba(124,58,237,0.15); }
.answer-option.correct { border-color: var(--accent-success); background: rgba(16,185,129,0.12); }
.answer-option.incorrect { border-color: var(--accent-danger); background: rgba(239,68,68,0.12); opacity: 0.7; }
.answer-option:disabled { cursor: not-allowed; }
.option-letter {
  display: flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem; border-radius: 50%;
  background: var(--bg-elevated); font-weight: 700;
  font-family: var(--font-display); flex-shrink: 0; font-size: 0.85rem;
}

/* ── Room Code ── */
.room-code { display: inline-flex; gap: 0.4rem; font-family: var(--font-display); font-size: 2.5rem; font-weight: 800; letter-spacing: 0.2em; }
.room-code-char { background: var(--bg-elevated); border: 1px solid var(--border-accent); border-radius: var(--radius-sm); padding: 0.3rem 0.6rem; color: var(--accent-primary); }

/* ── Player Pill ── */
.player-pill {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.4rem 0.8rem; background: var(--bg-elevated);
  border: 1px solid var(--border-color); border-radius: 100px;
  font-size: 0.875rem; animation: popIn 0.3s ease;
}

/* ── Admin Table ── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { text-align: left; padding: 0.75rem 1rem; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-muted); border-bottom: 1px solid var(--border-color); font-family: var(--font-display); }
.data-table td { padding: 0.9rem 1rem; border-bottom: 1px solid rgba(255,255,255,0.03); font-size: 0.9rem; }
.data-table tr:hover td { background: rgba(255,255,255,0.02); }

/* ── Main & Footer ── */
.main-content { flex: 1; position: relative; z-index: 1; }
.footer { border-top: 1px solid var(--border-color); padding: 1.5rem; position: relative; z-index: 1; }
.footer-inner { max-width: 1200px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; color: var(--text-muted); font-size: 0.875rem; }

/* ── Nav User Menu ── */
.nav-user-menu { position: relative; }
.nav-user-btn { padding: 0.5rem 0.9rem; border-radius: var(--radius-sm); background: var(--bg-elevated); cursor: pointer; font-size: 0.875rem; color: var(--text-primary); display: inline-flex; align-items: center; gap: 0.3rem; }
.nav-dropdown { position: absolute; top: calc(100% + 0.5rem); right: 0; background: var(--bg-elevated); border: 1px solid var(--border-color); border-radius: var(--radius-md); min-width: 160px; box-shadow: var(--shadow-md); display: none; z-index: 200; overflow: hidden; }
.nav-dropdown.open { display: block; }
.dropdown-item { display: block; padding: 0.65rem 1rem; color: var(--text-secondary); text-decoration: none; font-size: 0.875rem; cursor: pointer; background: none; border: none; width: 100%; text-align: left; transition: background var(--transition-fast), color var(--transition-fast); }
.dropdown-item:hover { background: rgba(255,255,255,0.05); color: var(--text-primary); }
.dropdown-item-danger { color: var(--accent-danger) !important; }
.dropdown-divider { height: 1px; background: var(--border-color); margin: 0.25rem 0; }

/* ── Animations ── */
@keyframes fadeIn { from { opacity:0; transform:translateY(16px); } to { opacity:1; transform:translateY(0); } }
@keyframes slideInRight { from { opacity:0; transform:translateX(20px); } to { opacity:1; transform:translateX(0); } }
@keyframes fadeOut { to { opacity:0; transform:translateX(20px); } }
@keyframes popIn { 0% { transform:scale(0.8); opacity:0; } 60% { transform:scale(1.05); } 100% { transform:scale(1); opacity:1; } }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:0.5; } }
@keyframes timerPulse { 0% { box-shadow:0 0 0 0 rgba(239,68,68,0.4); } 70% { box-shadow:0 0 0 10px rgba(239,68,68,0); } 100% { box-shadow:0 0 0 0 rgba(239,68,68,0); } }
@keyframes shimmer { 0% { background-position:200% 0; } 100% { background-position:-200% 0; } }

.animate-fade-in { animation: fadeIn 0.5s ease both; }
.animate-fade-in-delay { animation: fadeIn 0.5s ease 0.15s both; }

/* ── Hamburger ── */
.hamburger { display: none; flex-direction: column; gap: 5px; background: none; border: none; cursor: pointer; padding: 4px; }
.hamburger span { display: block; width: 22px; height: 2px; background: var(--text-secondary); border-radius: 2px; transition: all 0.2s; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .hamburger { display: flex; }
  .navbar-menu { display: none; position: absolute; top: 68px; left: 0; right: 0; background: var(--bg-secondary); flex-direction: column; padding: 1rem; border-bottom: 1px solid var(--border-color); }
  .navbar-menu.open { display: flex; }
  .grid-2,.grid-3,.grid-4 { grid-template-columns: 1fr; }
  .answer-grid { grid-template-columns: 1fr; }
  .room-code { font-size: 1.8rem; }
}
