/* ============================================================
   Drag-n-Drop Arena — Main Stylesheet
   Professional dark gaming + e-learning aesthetic
   ============================================================ */

/* ── CSS Custom Properties ───────────────────────────────── */
:root {
  /* Backgrounds — deep navy-black palette */
  --clr-bg:        #05080f;
  --clr-surface:   #0a1020;
  --clr-surface-2: #0f1929;
  --clr-surface-3: #162035;
  --clr-border:    #1c2d46;
  --clr-border-subtle: #162035;

  /* Primary — vivid violet */
  --clr-primary:        #7c3aed;
  --clr-primary-light:  #8b5cf6;
  --clr-primary-dark:   #5b21b6;
  --clr-primary-glow:   rgba(124, 58, 237, 0.22);

  /* Accent palette */
  --clr-secondary:    #22d3ee;
  --clr-gold:         #fbbf24;
  --clr-green:        #34d399;
  --clr-red:          #f87171;
  --clr-orange:       #fb923c;
  --clr-blue:         #3b82f6;

  /* Text */
  --clr-text:       #e8eef8;
  --clr-text-muted: #6b7f9a;
  --clr-text-dim:   #334159;

  /* Gradients */
  --gradient-primary: linear-gradient(135deg, #7c3aed 0%, #2563eb 100%);
  --gradient-gold:    linear-gradient(135deg, #fbbf24 0%, #f97316 100%);
  --gradient-battle:  linear-gradient(135deg, #7c3aed 0%, #db2777 100%);
  --gradient-cyan:    linear-gradient(135deg, #22d3ee 0%, #2563eb 100%);
  --gradient-surface: linear-gradient(180deg, #0f1929 0%, #0a1020 100%);

  /* Typography */
  --font-body:    'Inter', system-ui, sans-serif;
  --font-heading: 'Syne', 'Inter', system-ui, sans-serif;
  --font-code:    'JetBrains Mono', 'Fira Code', 'Courier New', monospace;

  /* Spacing */
  --space-xs:  4px;
  --space-sm:  8px;
  --space-md:  16px;
  --space-lg:  24px;
  --space-xl:  40px;
  --space-2xl: 64px;

  /* Radius */
  --radius-sm:   6px;
  --radius-md:   10px;
  --radius-lg:   16px;
  --radius-xl:   24px;
  --radius-full: 9999px;

  /* Shadows — deeper and more layered */
  --shadow-sm:   0 1px 4px rgba(0,0,0,0.5), 0 0 1px rgba(0,0,0,0.3);
  --shadow-md:   0 4px 16px rgba(0,0,0,0.55), 0 1px 4px rgba(0,0,0,0.4);
  --shadow-lg:   0 8px 40px rgba(0,0,0,0.65), 0 2px 8px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 32px var(--clr-primary-glow), 0 0 8px rgba(124,58,237,0.1);
  --shadow-card: 0 2px 0 var(--clr-border), var(--shadow-md);

  /* Transitions */
  --transition: 0.18s ease;
  --transition-slow: 0.35s ease;
}

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

html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--font-body);
  background: var(--clr-bg);
  color: var(--clr-text);
  line-height: 1.65;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(124,58,237,0.06) 0%, transparent 70%);
}

a { color: var(--clr-secondary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--clr-text); }

img { max-width: 100%; display: block; }

svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ── Typography ───────────────────────────────────────────── */
h1, h2, h3, h4 {
  font-family: var(--font-heading);
  line-height: 1.2;
  color: var(--clr-text);
  letter-spacing: -0.01em;
}
h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); }
h2 { font-size: clamp(1.25rem, 2.5vw, 1.75rem); }
h3 { font-size: 1.125rem; }

p { color: var(--clr-text-muted); }

.gradient-text {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.text-success { color: var(--clr-green) !important; }
.text-danger  { color: var(--clr-red) !important; }
.text-muted   { color: var(--clr-text-muted) !important; }

/* ── Layout ───────────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

.main-content {
  flex: 1;
  padding-top: 72px; /* height of topbar */
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 10px 22px;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(255,255,255,0.06), transparent);
  pointer-events: none;
}

.btn--primary {
  background: var(--gradient-primary);
  color: #fff;
  box-shadow: 0 4px 16px rgba(124,58,237,0.35), 0 1px 2px rgba(0,0,0,0.3);
}
.btn--primary:hover {
  box-shadow: 0 6px 24px rgba(124,58,237,0.5), 0 1px 4px rgba(0,0,0,0.4);
  transform: translateY(-1px);
  color: #fff;
}
.btn--primary:active { transform: translateY(0); }

.btn--ranked {
  background: var(--gradient-gold);
  color: #fff;
  box-shadow: 0 4px 16px rgba(251,191,36,0.3), 0 1px 2px rgba(0,0,0,0.3);
}
.btn--ranked:hover { box-shadow: 0 6px 24px rgba(251,191,36,0.45); transform: translateY(-1px); color: #fff; }

.btn--ghost {
  background: rgba(255,255,255,0.03);
  color: var(--clr-text);
  border: 1px solid var(--clr-border);
  box-shadow: none;
}
.btn--ghost::after { display: none; }
.btn--ghost:hover {
  background: var(--clr-surface-2);
  border-color: rgba(124,58,237,0.5);
  color: var(--clr-text);
  box-shadow: 0 0 0 1px rgba(124,58,237,0.2);
}

.btn--danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
  box-shadow: 0 4px 12px rgba(239,68,68,0.3);
}
.btn--danger:hover { box-shadow: 0 6px 20px rgba(239,68,68,0.45); transform: translateY(-1px); color: #fff; }

.btn--sm  { padding: 6px 14px; font-size: 0.8rem; }
.btn--lg  { padding: 13px 30px; font-size: 0.95rem; }
.btn--xl  { padding: 15px 38px; font-size: 1rem; }
.btn--xs  { padding: 3px 8px; font-size: 0.75rem; border-radius: var(--radius-sm); }
.btn--full { width: 100%; justify-content: center; }

/* ── Top Navigation Bar ───────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 64px;
  background: rgba(5, 8, 15, 0.92);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border-bottom: 1px solid rgba(28, 45, 70, 0.8);
  z-index: 1000;
  box-shadow: 0 1px 0 rgba(124,58,237,0.08);
}

.topbar__inner {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  height: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 var(--space-xl);
}

/* Logo */
.topbar__logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
}
.logo-mark {
  width: 30px; height: 30px;
  flex-shrink: 0;
  filter: drop-shadow(0 0 6px rgba(124,58,237,0.4));
}
.logo-text   { font-family: var(--font-heading); font-size: 1.05rem; color: var(--clr-text); font-weight: 800; letter-spacing: -0.02em; }
.logo-accent { color: var(--clr-primary-light); }

/* Nav links */
.topbar__nav {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: var(--space-md);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: var(--radius-md);
  color: var(--clr-text-muted);
  font-size: 0.825rem;
  font-weight: 500;
  transition: all var(--transition);
  text-decoration: none;
  letter-spacing: 0.01em;
}
.nav-link svg { width: 15px; height: 15px; opacity: 0.8; }
.nav-link:hover { background: rgba(255,255,255,0.05); color: var(--clr-text); }
.nav-link.active {
  background: rgba(124,58,237,0.12);
  color: var(--clr-primary-light);
  box-shadow: inset 0 0 0 1px rgba(124,58,237,0.2);
}
.nav-link.active svg { opacity: 1; }
.nav-link--battle {
  color: var(--clr-primary-light);
  background: rgba(124,58,237,0.08);
  border: 1px solid rgba(124,58,237,0.2);
}
.nav-link--battle:hover { background: rgba(124,58,237,0.18); color: var(--clr-primary-light); border-color: rgba(124,58,237,0.4); }
.nav-link--admin { color: var(--clr-gold); }

/* Meta / user area */
.topbar__meta {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

/* XP mini bar */
.topbar__xp {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
}
.level-badge {
  background: var(--clr-primary);
  color: #fff;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: 0.72rem;
}
.xp-bar-mini {
  width: 60px;
  height: 5px;
  background: var(--clr-surface-3);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.xp-bar-mini__fill {
  height: 100%;
  background: var(--gradient-primary);
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}
.xp-text { color: var(--clr-text-muted); }

/* Notification bell */
.icon-btn {
  position: relative;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--clr-text-muted);
  padding: 6px;
  border-radius: var(--radius-md);
  transition: all var(--transition);
}
.icon-btn svg { width: 20px; height: 20px; display: block; }
.icon-btn:hover { background: var(--clr-surface-2); color: var(--clr-text); }
.notif-dot {
  position: absolute;
  top: 2px; right: 2px;
  background: var(--clr-red);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}

/* Avatar dropdown */
.avatar-menu { position: relative; }
.avatar-btn {
  background: none;
  border: 2px solid var(--clr-border);
  border-radius: var(--radius-full);
  cursor: pointer;
  padding: 0;
  width: 36px; height: 36px;
  overflow: hidden;
  transition: border-color var(--transition);
}
.avatar-btn:hover { border-color: var(--clr-primary); }
.avatar-img { width: 100%; height: 100%; object-fit: cover; }
.avatar-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%; height: 100%;
  background: var(--clr-surface-3);
  color: var(--clr-text);
  font-weight: 700;
  font-size: 0.8rem;
}

.avatar-dropdown {
  display: none;
  position: absolute;
  right: 0; top: calc(100% + 8px);
  width: 200px;
  background: var(--clr-surface-2);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  overflow: hidden;
}
.avatar-dropdown.open { display: block; }
.dropdown-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--clr-border);
}
.dropdown-header strong { display: block; font-size: 0.9rem; }
.dropdown-header span { font-size: 0.75rem; color: var(--clr-text-muted); }
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: var(--clr-text-muted);
  font-size: 0.875rem;
  transition: background var(--transition);
  cursor: pointer;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  text-decoration: none;
}
.dropdown-item svg { width: 16px; height: 16px; }
.dropdown-item:hover { background: var(--clr-surface-3); color: var(--clr-text); }
.dropdown-item--danger { color: var(--clr-red); }
.dropdown-item--danger:hover { background: rgba(239,68,68,0.1); }
.dropdown-divider { border-top: 1px solid var(--clr-border); margin: 4px 0; }

/* Hamburger (mobile) */
.hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  margin-left: var(--space-md);
  flex-direction: column;
  gap: 5px;
}
.hamburger span {
  display: block;
  width: 22px; height: 2px;
  background: var(--clr-text);
  border-radius: 2px;
  transition: all var(--transition);
}

/* ── Flash Messages ───────────────────────────────────────── */
.flash-container {
  position: fixed;
  top: 72px; right: var(--space-lg);
  z-index: 900;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
}

.flash {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 1px solid;
  background: var(--clr-surface-2);
  box-shadow: var(--shadow-md);
  animation: slideIn 0.25s ease;
}
@keyframes slideIn { from { opacity:0; transform: translateX(20px); } to { opacity:1; transform: translateX(0); } }

.flash--success { border-color: var(--clr-green); }
.flash--error   { border-color: var(--clr-red); }
.flash--warning { border-color: var(--clr-gold); }
.flash--info    { border-color: var(--clr-secondary); }

.flash__icon { font-size: 1rem; }
.flash--success .flash__icon { color: var(--clr-green); }
.flash--error   .flash__icon { color: var(--clr-red); }
.flash--warning .flash__icon { color: var(--clr-gold); }
.flash__message { flex: 1; font-size: 0.875rem; color: var(--clr-text); }
.flash__close {
  background: none; border: none; cursor: pointer;
  color: var(--clr-text-muted); font-size: 1.1rem; padding: 0 4px;
}
.flash__close:hover { color: var(--clr-text); }

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--clr-surface-2);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}
.card:hover {
  border-color: rgba(124,58,237,0.4);
  box-shadow: var(--shadow-md), 0 0 0 1px rgba(124,58,237,0.1);
  transform: translateY(-1px);
}

/* ── Badges & Tags ────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--clr-surface-3);
  color: var(--clr-text-muted);
}
.badge--success { background: rgba(16,185,129,0.15); color: var(--clr-green); }
.badge--danger  { background: rgba(239,68,68,0.15);  color: var(--clr-red); }
.badge--gold    { background: rgba(245,158,11,0.15); color: var(--clr-gold); }

.rank-badge {
  font-weight: 700;
  font-size: 0.85rem;
  font-family: var(--font-heading);
  letter-spacing: 0.5px;
}

.level-chip {
  background: var(--clr-surface-3);
  color: var(--clr-secondary);
  border-radius: var(--radius-full);
  padding: 2px 10px;
  font-size: 0.78rem;
  font-weight: 600;
}

.difficulty-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
}
.difficulty-badge--beginner     { background: rgba(16,185,129,0.15); color: var(--clr-green); }
.difficulty-badge--intermediate { background: rgba(14,165,233,0.15); color: var(--clr-secondary); }
.difficulty-badge--advanced     { background: rgba(245,158,11,0.15); color: var(--clr-gold); }
.difficulty-badge--expert       { background: rgba(239,68,68,0.15);  color: var(--clr-red); }

/* ── Forms ────────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: var(--space-md);
}
.form-group label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--clr-text);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.form-label-link { font-size: 0.8rem; color: var(--clr-secondary); font-weight: 400; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-md); }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 11px 14px;
  background: var(--clr-surface-3);
  border: 1px solid rgba(28,45,70,0.9);
  border-radius: var(--radius-md);
  color: var(--clr-text);
  font-family: var(--font-body);
  font-size: 0.875rem;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.3);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: rgba(124,58,237,0.6);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.12), inset 0 1px 2px rgba(0,0,0,0.2);
  background: rgba(22,32,53,0.9);
}
input:hover:not(:focus), select:hover:not(:focus) {
  border-color: rgba(28,45,70,1.2);
}
input::placeholder { color: var(--clr-text-dim); }
select { cursor: pointer; }
textarea { resize: vertical; min-height: 100px; }

.form-group--error input,
.form-group--error select {
  border-color: var(--clr-red);
}
.form-error {
  font-size: 0.78rem;
  color: var(--clr-red);
}

/* Input + toggle password button */
.input-with-toggle { position: relative; }
.input-with-toggle input { padding-right: 42px; }
.toggle-password {
  position: absolute;
  right: 10px; top: 50%;
  transform: translateY(-50%);
  background: none; border: none; cursor: pointer;
  color: var(--clr-text-muted);
  padding: 4px;
}
.toggle-password:hover { color: var(--clr-text); }
.eye-icon { width: 18px; height: 18px; }

/* Password strength */
.password-strength { margin-bottom: var(--space-md); }
.password-strength__bar {
  height: 4px;
  background: var(--clr-surface-3);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: 4px;
}
.password-strength__fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.3s ease, background 0.3s ease;
}
.password-strength__label { font-size: 0.75rem; color: var(--clr-text-muted); }

/* ── XP Bars ──────────────────────────────────────────────── */
.xp-bar-full { }
.xp-bar-full__labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--clr-text-muted);
  margin-bottom: 6px;
}
.xp-bar-full__track {
  height: 8px;
  background: var(--clr-surface-3);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.xp-bar-full__fill {
  height: 100%;
  background: var(--gradient-primary);
  border-radius: var(--radius-full);
  transition: width 0.6s ease;
}

/* ── Auth Pages ───────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--clr-bg);
}

.auth-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100vh;
}

.auth-split__left {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: var(--space-2xl) var(--space-xl);
  background: linear-gradient(160deg, #0c1525 0%, #08101e 100%);
  border-right: 1px solid var(--clr-border);
  position: relative;
  overflow: hidden;
}

/* Dot-grid background */
.auth-split__left::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(124,58,237,0.12) 1px, transparent 1px);
  background-size: 28px 28px;
  pointer-events: none;
}

/* Glowing orb */
.auth-split__left::after {
  content: '';
  position: absolute;
  top: -20%; left: -10%;
  width: 60%; height: 60%;
  background: radial-gradient(circle, rgba(124,58,237,0.12) 0%, transparent 70%);
  pointer-events: none;
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  margin-bottom: var(--space-2xl);
  position: relative;
  z-index: 1;
}
.auth-logo .logo-text { font-size: 1.2rem; }

.auth-tagline {
  position: relative;
  z-index: 1;
}
.auth-tagline h2 { font-size: 1.9rem; margin-bottom: 14px; letter-spacing: -0.02em; }
.auth-tagline p  { color: var(--clr-text-muted); line-height: 1.75; font-size: 0.95rem; }

.auth-perks {
  list-style: none;
  margin-top: var(--space-xl);
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  z-index: 1;
}
.auth-perks li {
  color: var(--clr-text-muted);
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 10px;
}
.auth-perks li::before { content: none; }

.auth-rank-preview {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-xl);
  position: relative;
  z-index: 1;
}
.rank-badge-lg {
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-family: var(--font-heading);
  font-size: 0.82rem;
  font-weight: 700;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--clr-border);
  backdrop-filter: blur(4px);
}
.rank-badge-lg--gold    { color: var(--clr-gold);   border-color: rgba(251,191,36,0.25); }
.rank-badge-lg--platinum{ color: #22d3ee;            border-color: rgba(34,211,238,0.25); }
.rank-badge-lg--legend  { color: #f43f5e;            border-color: rgba(244,63,94,0.25); }

/* Auth card */
.auth-split__right {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
  background: var(--clr-bg);
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--clr-surface-2);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  box-shadow: var(--shadow-lg);
  position: relative;
}
.auth-card::before {
  content: '';
  position: absolute;
  top: 0; left: 10%; right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(124,58,237,0.5), transparent);
}

.auth-card__header {
  text-align: center;
  margin-bottom: var(--space-xl);
}
.auth-card__header h1 { font-size: 1.6rem; margin-bottom: 8px; letter-spacing: -0.02em; }
.auth-card__header p  { color: var(--clr-text-muted); font-size: 0.9rem; }

.auth-form { display: flex; flex-direction: column; }

.auth-card__footer {
  text-align: center;
  margin-top: var(--space-lg);
  font-size: 0.85rem;
  color: var(--clr-text-muted);
}
.auth-card__footer a { color: var(--clr-secondary); }

/* ── HOME PAGE ────────────────────────────────────────────── */
.home-page { background: var(--clr-bg); }

.home-nav {
  position: fixed; top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-xl);
  height: 64px;
  background: rgba(5,8,15,0.88);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border-bottom: 1px solid rgba(28,45,70,0.7);
  z-index: 100;
  box-shadow: 0 1px 0 rgba(124,58,237,0.06);
}
.home-nav__actions { display: flex; gap: var(--space-sm); }

/* Hero */
.hero {
  min-height: 100vh;
  padding-top: 64px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2xl);
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
  padding: 100px var(--space-xl) var(--space-2xl);
}

.hero__bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(109,40,217,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(109,40,217,0.04) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
  z-index: 0;
}

.hero__content { position: relative; z-index: 1; }
.hero__badge {
  display: inline-block;
  padding: 6px 14px;
  background: rgba(109,40,217,0.15);
  border: 1px solid rgba(109,40,217,0.3);
  border-radius: var(--radius-full);
  color: var(--clr-primary-light);
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: var(--space-lg);
}
.hero__title {
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1.15;
  margin-bottom: var(--space-lg);
}
.hero__subtitle {
  font-size: 1.1rem;
  color: var(--clr-text-muted);
  max-width: 480px;
  margin-bottom: var(--space-xl);
  line-height: 1.7;
}
.hero__cta { display: flex; gap: var(--space-md); flex-wrap: wrap; margin-bottom: var(--space-xl); }
.hero__stats { display: flex; align-items: center; gap: var(--space-lg); }
.hero__stat-num { display: block; font-size: 1.5rem; font-weight: 800; font-family: var(--font-heading); }
.hero__stat-label { font-size: 0.8rem; color: var(--clr-text-muted); }
.hero__stat-divider { width: 1px; height: 36px; background: var(--clr-border); }

/* Hero preview card */
.hero__preview { position: relative; z-index: 1; }
.preview-card {
  background: var(--clr-surface-2);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-glow), var(--shadow-lg);
}
.preview-card__header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 16px;
  background: var(--clr-surface-3);
  border-bottom: 1px solid var(--clr-border);
}
.preview-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
}
.preview-dot--red    { background: #ef4444; }
.preview-dot--yellow { background: #f59e0b; }
.preview-dot--green  { background: #10b981; }
.preview-card__title {
  font-family: var(--font-code);
  font-size: 0.78rem;
  color: var(--clr-text-muted);
  margin-left: 8px;
}
.preview-card__body { padding: var(--space-lg); }

.parsons-preview { display: flex; flex-direction: column; gap: 6px; }
.parsons-line {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--clr-surface-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--clr-border);
  cursor: grab;
}
.parsons-line--dragging {
  border-color: var(--clr-primary);
  background: var(--clr-primary-glow);
}
.parsons-line--highlight {
  border-color: var(--clr-green);
  background: rgba(16,185,129,0.1);
}
.drag-handle { color: var(--clr-text-dim); user-select: none; }
.parsons-line code {
  font-family: var(--font-code);
  font-size: 0.85rem;
  color: var(--clr-text);
}
.kw { color: #c792ea; }
.fn { color: #82aaff; }
.num{ color: #f78c6c; }

.preview-badge {
  display: inline-block;
  margin-top: var(--space-md);
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
}
.preview-badge--correct { background: rgba(16,185,129,0.15); color: var(--clr-green); }

/* Features section */
.features, .modes { padding: var(--space-2xl) 0; }
.section-header { text-align: center; margin-bottom: var(--space-xl); }
.section-header h2 { margin-bottom: 12px; }
.section-header p  { color: var(--clr-text-muted); }

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-lg);
}
.feature-card {
  background: var(--clr-surface-2);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  position: relative;
  transition: all var(--transition);
}
.feature-card:hover { border-color: var(--clr-primary); transform: translateY(-2px); }
.feature-card--featured {
  border-color: var(--clr-primary);
  background: linear-gradient(135deg, var(--clr-surface-2), rgba(109,40,217,0.1));
}
.feature-card__icon { font-size: 1.75rem; margin-bottom: var(--space-md); }
.feature-card h3    { margin-bottom: 8px; }
.feature-card p     { font-size: 0.875rem; }
.feature-card__badge {
  position: absolute;
  top: 12px; right: 12px;
  background: var(--clr-primary);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

/* Modes */
.modes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-lg);
}
.mode-card {
  background: var(--clr-surface-2);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  transition: all var(--transition);
}
.mode-card:hover { border-color: var(--clr-secondary); transform: translateY(-2px); }
.mode-card--ranked {
  border-color: rgba(245,158,11,0.4);
  background: linear-gradient(135deg, var(--clr-surface-2), rgba(245,158,11,0.05));
}
.mode-card__icon { font-size: 2rem; margin-bottom: var(--space-md); display: block; }
.mode-card h3    { margin-bottom: 8px; }
.mode-card p     { font-size: 0.875rem; margin-bottom: var(--space-md); }
.mode-tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--clr-surface-3);
  color: var(--clr-text-muted);
}
.mode-tag--ranked { background: rgba(245,158,11,0.15); color: var(--clr-gold); }

/* CTA section */
.cta-section {
  padding: var(--space-2xl) 0;
  text-align: center;
  background: linear-gradient(135deg, rgba(109,40,217,0.1), rgba(14,165,233,0.05));
  border-top: 1px solid var(--clr-border);
}
.cta-section h2 { margin-bottom: 12px; }
.cta-section p  { margin-bottom: var(--space-xl); }

/* ── Footer ───────────────────────────────────────────────── */
.site-footer {
  background: var(--clr-surface);
  border-top: 1px solid var(--clr-border);
  padding: var(--space-xl) 0;
  position: relative;
}
.site-footer::before {
  content: '';
  position: absolute;
  top: 0; left: 20%; right: 20%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(124,58,237,0.3), transparent);
}
.site-footer__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-xl);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-md);
}
.footer-logo { display: flex; align-items: center; gap: 10px; font-family: var(--font-heading); font-weight: 800; }
.footer-copy { color: var(--clr-text-dim); font-size: 0.78rem; }
.footer-nav { display: flex; gap: var(--space-lg); }
.footer-nav a { color: var(--clr-text-muted); font-size: 0.82rem; transition: color var(--transition); }
.footer-nav a:hover { color: var(--clr-text); }

/* ── Dashboard Page ───────────────────────────────────────── */
.page-dashboard { max-width: 1200px; margin: 0 auto; padding: var(--space-xl); }

.dash-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-xl);
  background: var(--clr-surface-2);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  margin-bottom: var(--space-lg);
}
.dash-hero__left { display: flex; align-items: flex-start; gap: var(--space-lg); flex: 1; }

.dash-hero__avatar {
  position: relative;
  width: 80px; height: 80px;
  flex-shrink: 0;
}
.dash-hero__avatar img,
.dash-hero__avatar span {
  width: 80px; height: 80px;
  border-radius: var(--radius-full);
  border: 3px solid var(--clr-primary);
  object-fit: cover;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--clr-surface-3);
  font-size: 1.5rem;
  font-weight: 800;
  font-family: var(--font-heading);
}
.avatar-level {
  position: absolute;
  bottom: -4px; right: -4px;
  background: var(--clr-primary);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-full);
}

.dash-hero__info { flex: 1; }
.dash-hero__info h1 { font-size: 1.4rem; margin-bottom: 6px; }
.rank-display { display: flex; align-items: center; gap: var(--space-md); margin-bottom: var(--space-md); }
.rank-points { font-size: 0.8rem; color: var(--clr-text-muted); }

.daily-reward {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--clr-surface-3);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-md);
}
.daily-reward--claimed { border-color: rgba(16,185,129,0.3); }
.daily-reward__icon { font-size: 1.5rem; }
.daily-reward__info { flex: 1; }
.daily-reward__info strong { display: block; font-size: 0.85rem; }
.daily-reward__info span { font-size: 0.78rem; }

/* Stats row */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}
.stat-card {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  background: var(--clr-surface-2);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
}
.stat-card__icon { font-size: 1.75rem; }
.stat-card__num  { display: block; font-size: 1.5rem; font-weight: 800; font-family: var(--font-heading); color: var(--clr-text); }
.stat-card__label{ display: block; font-size: 0.75rem; color: var(--clr-text-muted); }
.stat-card__icon--win    { color: var(--clr-gold); }
.stat-card__icon--streak { color: var(--clr-orange); }

/* Dashboard grid */
.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-lg);
}
.dash-section {
  background: var(--clr-surface-2);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
}
.dash-section--battle { grid-column: 1 / -1; }

.dash-section__title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1rem;
  margin-bottom: var(--space-md);
  color: var(--clr-text);
}
.section-link { margin-left: auto; font-size: 0.8rem; color: var(--clr-secondary); }

/* Battle mode buttons */
.battle-modes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
}
.battle-mode-form { display: contents; }
.battle-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: var(--space-lg) var(--space-md);
  border-radius: var(--radius-lg);
  border: 2px solid var(--clr-border);
  background: var(--clr-surface-3);
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font-body);
  text-decoration: none;
  text-align: center;
}
.battle-btn:hover { transform: translateY(-2px); }
.battle-btn__icon  { font-size: 2rem; }
.battle-btn__title { font-weight: 700; font-size: 0.95rem; color: var(--clr-text); }
.battle-btn__sub   { font-size: 0.75rem; color: var(--clr-text-muted); }

.battle-btn--quick:hover  { border-color: var(--clr-secondary); background: rgba(14,165,233,0.08); }
.battle-btn--ranked       { border-color: rgba(245,158,11,0.3); }
.battle-btn--ranked:hover { border-color: var(--clr-gold); background: rgba(245,158,11,0.08); }
.battle-btn--practice:hover { border-color: var(--clr-green); background: rgba(16,185,129,0.08); }

/* Match list */
.match-list { display: flex; flex-direction: column; gap: 8px; }
.match-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: 10px 12px;
  background: var(--clr-surface-3);
  border-radius: var(--radius-md);
  border-left: 3px solid var(--clr-border);
}
.match-item--win  { border-left-color: var(--clr-green); }
.match-item--loss { border-left-color: var(--clr-red); }
.match-result {
  font-weight: 800;
  font-size: 0.85rem;
  min-width: 18px;
  text-align: center;
}
.match-item--win  .match-result { color: var(--clr-green); }
.match-item--loss .match-result { color: var(--clr-red); }
.match-info  { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.match-opponent { font-size: 0.85rem; font-weight: 500; }
.match-mode     { font-size: 0.72rem; color: var(--clr-text-muted); }
.match-time     { font-size: 0.72rem; color: var(--clr-text-muted); }
.match-link { font-size: 0.75rem; color: var(--clr-secondary); }

/* Lesson chips */
.lesson-quick-links { display: flex; flex-wrap: wrap; gap: 8px; }
.lesson-chip {
  padding: 6px 14px;
  background: var(--clr-surface-3);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  color: var(--clr-text-muted);
  transition: all var(--transition);
  text-decoration: none;
}
.lesson-chip:hover { border-color: var(--clr-primary); color: var(--clr-text); background: var(--clr-primary-glow); }
.lesson-chip--all { color: var(--clr-secondary); }

/* Achievements */
.achievement-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.achievement-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 8px;
  background: var(--clr-surface-3);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-md);
  text-align: center;
  cursor: default;
  transition: all var(--transition);
}
.achievement-badge:hover { border-color: var(--clr-gold); }
.achievement-badge__icon { font-size: 1.4rem; }
.achievement-badge__name { font-size: 0.65rem; color: var(--clr-text-muted); line-height: 1.2; }
.achievement-badge__date { font-size: 0.6rem; color: var(--clr-text-dim); }

/* Empty states */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-xl);
  text-align: center;
}
.empty-state__icon { font-size: 2rem; }
.empty-state p { color: var(--clr-text-muted); font-size: 0.875rem; }

/* ── Battle Page ──────────────────────────────────────────── */
.page-battle { max-width: 100%; padding: var(--space-md); }

.battle-hud {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: var(--space-md);
  align-items: center;
  padding: var(--space-md) var(--space-xl);
  background: var(--clr-surface-2);
  border-bottom: 1px solid var(--clr-border);
  position: sticky; top: 64px;
  z-index: 10;
}

.hud-player {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}
.hud-player--2 { flex-direction: row-reverse; }
.hud-player--me .hud-player__name::after {
  content: '';
}

.hud-player__avatar {
  position: relative;
  width: 48px; height: 48px;
  border-radius: var(--radius-full);
  border: 2px solid var(--clr-border);
  overflow: hidden;
}
.hud-player--me .hud-player__avatar { border-color: var(--clr-primary); }
.hud-player__avatar img, .hud-player__avatar span {
  width: 100%; height: 100%;
  object-fit: cover;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--clr-surface-3);
  font-weight: 800;
}
.you-tag {
  position: absolute;
  bottom: -4px; left: 50%;
  transform: translateX(-50%);
  background: var(--clr-primary);
  color: #fff;
  font-size: 0.55rem;
  font-weight: 700;
  padding: 0 4px;
  border-radius: 3px;
  white-space: nowrap;
}

.hud-player__name { font-weight: 700; font-size: 0.9rem; }
.hud-player__level { font-size: 0.72rem; color: var(--clr-text-muted); }
.hud-player__info--right { text-align: right; }

.hud-score {
  font-family: var(--font-heading);
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--clr-text);
  min-width: 36px;
  text-align: center;
}

/* Battle center: VS + timer */
.battle-center { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.vs-divider { font-family: var(--font-heading); font-size: 1.1rem; color: var(--clr-text-muted); }

.battle-timer { }
.timer-svg { width: 56px; height: 56px; }
.timer-count {
  position: absolute;
  /* centered via SVG viewBox offset — JS will handle this */
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 800;
}
/* Wrap timer in relative div */
.battle-timer__ring { position: relative; width: 56px; height: 56px; display: flex; align-items: center; justify-content: center; }
.battle-timer__ring svg { position: absolute; inset: 0; }
.timer-count { position: relative; z-index: 1; }
.round-info { font-size: 0.72rem; color: var(--clr-text-muted); }

/* Arena */
.battle-arena {
  max-width: 800px;
  margin: var(--space-xl) auto;
  padding: 0 var(--space-lg);
}
.challenge-loading { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: var(--space-2xl); }

.challenge-display {
  background: var(--clr-surface-2);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
}
.challenge-question {
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--clr-text);
  margin-bottom: var(--space-lg);
  line-height: 1.6;
}
.challenge-code { margin-bottom: var(--space-lg); }
.challenge-actions {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-top: var(--space-xl);
}
.answer-status { font-size: 0.85rem; }

/* Round result overlay */
.round-result {
  text-align: center;
  padding: var(--space-xl);
}
.round-result__icon { font-size: 3rem; margin-bottom: var(--space-md); }
.round-result__explanation { color: var(--clr-text-muted); margin: var(--space-md) 0; font-style: italic; }
.round-scores { display: flex; justify-content: center; gap: var(--space-xl); font-weight: 700; }

/* Waiting overlay */
.waiting-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8,12,20,0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-lg);
  z-index: 50;
  backdrop-filter: blur(4px);
}
.waiting-spinner {
  width: 48px; height: 48px;
  border: 3px solid var(--clr-border);
  border-top-color: var(--clr-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-spinner {
  width: 32px; height: 32px;
  border: 2px solid var(--clr-border);
  border-top-color: var(--clr-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ── Challenge Input Types ────────────────────────────────── */
/* Multiple Choice */
.mc-choices { display: flex; flex-direction: column; gap: 10px; }
.mc-choice {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--clr-surface-3);
  border: 2px solid var(--clr-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition);
  font-size: 0.9rem;
}
.mc-choice:hover { border-color: var(--clr-primary); background: var(--clr-primary-glow); }
.mc-choice.selected { border-color: var(--clr-primary); background: var(--clr-primary-glow); }
.mc-choice.correct  { border-color: var(--clr-green); background: rgba(16,185,129,0.15); }
.mc-choice.wrong    { border-color: var(--clr-red); background: rgba(239,68,68,0.15); }
.mc-choice-letter {
  width: 28px; height: 28px;
  border-radius: var(--radius-full);
  background: var(--clr-surface-2);
  border: 1px solid var(--clr-border);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.78rem; font-weight: 700;
  flex-shrink: 0;
}

/* Code blocks */
.code-block-wrap {
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.code-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  background: var(--clr-surface-3);
  border-bottom: 1px solid var(--clr-border);
  font-size: 0.78rem;
  color: var(--clr-text-muted);
}
.copy-btn {
  background: none; border: none; cursor: pointer;
  color: var(--clr-secondary); font-size: 0.75rem;
}
.copy-btn:hover { color: var(--clr-text); }
.code-block {
  background: #0d1117;
  padding: var(--space-md);
  overflow-x: auto;
  font-family: var(--font-code);
  font-size: 0.875rem;
  line-height: 1.6;
  color: #c9d1d9;
  margin: 0;
}

/* Parsons puzzle (battle) */
.parsons-container { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-lg); }
.parsons-zone-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--clr-text-muted);
  margin-bottom: 8px;
}
.parsons-zone {
  min-height: 120px;
  border: 2px dashed var(--clr-border);
  border-radius: var(--radius-md);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color var(--transition);
}
.parsons-zone.drag-over { border-color: var(--clr-primary); background: var(--clr-primary-glow); }
.parsons-block {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: var(--clr-surface-3);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-sm);
  cursor: grab;
  user-select: none;
  transition: all var(--transition);
  font-family: var(--font-code);
  font-size: 0.82rem;
}
.parsons-block:hover  { border-color: var(--clr-primary); }
.parsons-block.dragging { opacity: 0.5; border-color: var(--clr-primary); }

/* Fill-in-blank */
.fill-blank-code {
  font-family: var(--font-code);
  font-size: 0.875rem;
  line-height: 2;
  background: #0d1117;
  padding: var(--space-md);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-lg);
  overflow-x: auto;
}
.blank-slot {
  display: inline-block;
  min-width: 80px;
  height: 26px;
  border: 2px dashed var(--clr-primary);
  border-radius: var(--radius-sm);
  padding: 0 8px;
  vertical-align: middle;
  background: var(--clr-primary-glow);
  text-align: center;
  line-height: 24px;
  cursor: pointer;
  transition: all var(--transition);
}
.blank-slot.filled   { border-style: solid; border-color: var(--clr-green); background: rgba(16,185,129,0.1); }
.blank-slot.drag-over{ border-color: var(--clr-gold); background: rgba(245,158,11,0.1); }
.blank-slot.correct  { border-color: var(--clr-green); }
.blank-slot.wrong    { border-color: var(--clr-red); }

.token-bank {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: var(--space-md);
  background: var(--clr-surface-3);
  border-radius: var(--radius-md);
  border: 1px dashed var(--clr-border);
}
.token {
  padding: 4px 14px;
  background: var(--clr-surface-2);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-full);
  font-family: var(--font-code);
  font-size: 0.82rem;
  cursor: grab;
  user-select: none;
  transition: all var(--transition);
}
.token:hover  { border-color: var(--clr-primary); color: var(--clr-text); }
.token.used   { opacity: 0.35; cursor: default; }
.token.dragging { opacity: 0.5; }

/* Output prediction */
.output-input {
  font-family: var(--font-code);
  background: #0d1117;
  border: 1px solid var(--clr-border);
  color: var(--clr-green);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  width: 100%;
  resize: none;
  min-height: 80px;
}

/* ── Leaderboard Page ─────────────────────────────────────── */
.page-leaderboard { max-width: 1200px; margin: 0 auto; padding: var(--space-xl); }
.page-hero { margin-bottom: var(--space-xl); }
.page-hero h1 { margin-bottom: 8px; }

.leaderboard-table-wrap { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--clr-border); }
.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
}
.leaderboard-table thead tr {
  background: var(--clr-surface-3);
  border-bottom: 1px solid var(--clr-border);
}
.leaderboard-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--clr-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.leaderboard-table td {
  padding: 12px 16px;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--clr-border);
  vertical-align: middle;
}
.leaderboard-table tr:last-child td { border-bottom: none; }
.leaderboard-table tr:hover td { background: var(--clr-surface-2); }
.lb-row--me td   { background: rgba(109,40,217,0.08) !important; }
.lb-row--top:nth-child(1) td { background: rgba(245,158,11,0.06); }

.rank-col { width: 48px; text-align: center; }
.rank-num { font-size: 0.85rem; color: var(--clr-text-muted); }
.medal { font-size: 1.1rem; }

.lb-player { display: flex; align-items: center; gap: 10px; }
.lb-avatar {
  width: 32px; height: 32px;
  border-radius: var(--radius-full);
  background: var(--clr-surface-3);
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 700;
  flex-shrink: 0;
}
.lb-avatar img { width: 100%; height: 100%; object-fit: cover; }
.lb-player__name { font-weight: 600; color: var(--clr-text); }
.lb-player__name .you-tag { position: static; transform: none; margin-left: 6px; }
.rp-col { color: var(--clr-gold); }

/* ── Profile Page ─────────────────────────────────────────── */
.page-profile { max-width: 1200px; margin: 0 auto; padding: var(--space-xl); }

.profile-header {
  display: flex;
  align-items: flex-start;
  gap: var(--space-xl);
  background: var(--clr-surface-2);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
}
.profile-avatar {
  position: relative;
  width: 100px; height: 100px;
  flex-shrink: 0;
}
.profile-avatar img, .profile-avatar span {
  width: 100px; height: 100px;
  border-radius: var(--radius-full);
  border: 3px solid var(--clr-primary);
  object-fit: cover;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--clr-surface-3);
  font-size: 1.75rem;
  font-weight: 800;
}
.profile-avatar__level {
  position: absolute;
  bottom: 0; right: 0;
  background: var(--clr-primary);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-full);
}
.profile-header__info { flex: 1; }
.profile-header__info h1 { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.edit-profile-btn { font-size: 1rem; }
.profile-rank { margin-bottom: 6px; font-family: var(--font-heading); font-weight: 700; }
.profile-meta { display: flex; gap: var(--space-lg); font-size: 0.8rem; color: var(--clr-text-muted); margin-bottom: var(--space-md); }

.profile-stats {
  display: flex;
  gap: var(--space-xl);
  background: var(--clr-surface-3);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
}
.profile-stat { display: flex; flex-direction: column; align-items: center; text-align: center; }
.profile-stat__num   { font-family: var(--font-heading); font-size: 1.5rem; font-weight: 800; }
.profile-stat__label { font-size: 0.72rem; color: var(--clr-text-muted); }

.profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-lg); }
.profile-section {
  background: var(--clr-surface-2);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
}
.profile-section h2 { font-size: 1rem; margin-bottom: var(--space-md); }

/* ── Lessons Pages ────────────────────────────────────────── */
.page-lessons { max-width: 1200px; margin: 0 auto; padding: var(--space-xl); }
.page-hero--lessons { margin-bottom: var(--space-xl); }

.curriculum-section { margin-bottom: var(--space-2xl); }
.curriculum-section__header {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}
.curriculum-icon { font-size: 1.4rem; }
.lesson-count { font-size: 0.8rem; color: var(--clr-text-muted); background: var(--clr-surface-3); padding: 2px 10px; border-radius: var(--radius-full); }

.lesson-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-md);
}
.lesson-card {
  background: var(--clr-surface-2);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  text-decoration: none;
  display: block;
  transition: all var(--transition);
}
.lesson-card:hover { border-color: var(--clr-primary); transform: translateY(-2px); box-shadow: var(--shadow-glow); }
.lesson-card__header { margin-bottom: 8px; }
.lesson-card__title  { font-size: 0.95rem; font-weight: 700; color: var(--clr-text); margin-bottom: 6px; }
.lesson-card__desc   { font-size: 0.8rem; color: var(--clr-text-muted); margin-bottom: var(--space-md); }
.lesson-card__footer { display: flex; justify-content: space-between; align-items: center; font-size: 0.75rem; color: var(--clr-text-muted); }
.lesson-card__arrow  { color: var(--clr-primary); }
.lesson-card--empty  { border-style: dashed; cursor: default; }
.lesson-card--empty:hover { transform: none; }

/* Lesson show */
.page-lesson-show { padding: var(--space-xl) 0; }
.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; color: var(--clr-text-muted); margin-bottom: var(--space-lg); }
.breadcrumb a { color: var(--clr-secondary); }

.lesson-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: var(--space-xl);
  align-items: start;
}
.lesson-content { }
.lesson-content__header { margin-bottom: var(--space-xl); }
.lesson-content__header h1 { margin: 10px 0; }
.lesson-description { color: var(--clr-text-muted); }
.lesson-content__body { line-height: 1.8; }
.lesson-content__body code {
  font-family: var(--font-code);
  background: var(--clr-surface-3);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85em;
}
.lesson-examples { margin-top: var(--space-xl); }
.lesson-examples h2 { margin-bottom: var(--space-md); }

.lesson-sidebar { display: flex; flex-direction: column; gap: var(--space-md); position: sticky; top: 84px; }
.sidebar-card {
  background: var(--clr-surface-2);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
}
.sidebar-card h3 { margin-bottom: var(--space-md); }
.sidebar-card--battle { border-color: rgba(109,40,217,0.3); background: rgba(109,40,217,0.05); }
.sidebar-card--battle p { font-size: 0.85rem; margin-bottom: var(--space-md); }

.challenge-list { display: flex; flex-direction: column; gap: 8px; }
.challenge-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--clr-surface-3);
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: all var(--transition);
  border: 1px solid var(--clr-border);
}
.challenge-item:hover { border-color: var(--clr-primary); }
.challenge-type-icon { font-size: 1.1rem; }
.challenge-item__info { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.challenge-item__type { font-size: 0.78rem; font-weight: 500; color: var(--clr-text); }
.challenge-item__arrow { color: var(--clr-primary); }

/* ── Lobby Page ───────────────────────────────────────────── */
.page-lobby { max-width: 1200px; margin: 0 auto; padding: var(--space-xl); }
.lobby-header { text-align: center; margin-bottom: var(--space-xl); }
.lobby-modes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}
.lobby-card {
  background: var(--clr-surface-2);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  position: relative;
}
.lobby-card--ranked { border-color: rgba(245,158,11,0.3); }
.lobby-card__badge {
  display: inline-block;
  padding: 3px 10px;
  background: var(--clr-surface-3);
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--clr-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  width: fit-content;
}
.lobby-card__badge--ranked { background: rgba(245,158,11,0.15); color: var(--clr-gold); }
.lobby-card__icon { font-size: 2.5rem; }
.lobby-card h2 { font-size: 1.25rem; }
.lobby-card p { font-size: 0.875rem; }
.lobby-card__details { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.lobby-card__details li { font-size: 0.8rem; color: var(--clr-text-muted); }
.lobby-card__details li::before { content: '• '; color: var(--clr-primary); }

/* ── Result Page ──────────────────────────────────────────── */
.page-result { max-width: 900px; margin: 0 auto; padding: var(--space-xl); }
.result-banner {
  text-align: center;
  padding: var(--space-2xl);
  border-radius: var(--radius-xl);
  border: 1px solid;
  margin-bottom: var(--space-xl);
}
.result-banner--win  { border-color: rgba(245,158,11,0.4); background: rgba(245,158,11,0.08); }
.result-banner--loss { border-color: rgba(239,68,68,0.4); background: rgba(239,68,68,0.06); }
.result-banner--draw { border-color: var(--clr-border); }
.result-banner__icon { font-size: 3rem; margin-bottom: var(--space-md); }
.result-banner h1 { font-size: 2.5rem; margin-bottom: 8px; }
.result-banner p  { color: var(--clr-text-muted); }

.result-rounds { margin-bottom: var(--space-xl); }
.result-rounds h2 { margin-bottom: var(--space-lg); }
.rounds-table-wrap { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--clr-border); }
.rounds-table { width: 100%; border-collapse: collapse; }
.rounds-table th { background: var(--clr-surface-3); padding: 10px 14px; text-align: left; font-size: 0.78rem; color: var(--clr-text-muted); }
.rounds-table td { padding: 10px 14px; border-bottom: 1px solid var(--clr-border); font-size: 0.85rem; }

.result-actions { display: flex; gap: var(--space-md); justify-content: center; }

/* ── Admin Pages ──────────────────────────────────────────── */
.page-admin { max-width: 1200px; margin: 0 auto; padding: var(--space-xl); }
.admin-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-xl); flex-wrap: wrap; gap: var(--space-md); }
.admin-search { display: flex; gap: 8px; }
.admin-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}
.admin-stat-card {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  background: var(--clr-surface-2);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
}
.admin-stat-card--live { border-color: rgba(239,68,68,0.3); }
.admin-stat-card__icon { font-size: 1.5rem; }
.admin-stat-card__num  { display: block; font-size: 1.5rem; font-weight: 800; font-family: var(--font-heading); }
.admin-stat-card__label{ display: block; font-size: 0.75rem; color: var(--clr-text-muted); }

.admin-quick-nav {
  display: flex;
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}
.admin-nav-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: var(--space-md) var(--space-lg);
  background: var(--clr-surface-2);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-lg);
  color: var(--clr-text-muted);
  transition: all var(--transition);
  text-decoration: none;
}
.admin-nav-card:hover { border-color: var(--clr-primary); color: var(--clr-text); }

.admin-section { background: var(--clr-surface-2); border: 1px solid var(--clr-border); border-radius: var(--radius-lg); padding: var(--space-lg); margin-bottom: var(--space-lg); }
.admin-section h2 { margin-bottom: var(--space-md); font-size: 1rem; }

.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th {
  background: var(--clr-surface-3);
  padding: 10px 14px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--clr-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.admin-table td {
  padding: 10px 14px;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--clr-border);
  vertical-align: middle;
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: var(--clr-surface-3); }
.admin-actions { display: flex; gap: 6px; }

.role-badge { display: inline-block; padding: 2px 8px; border-radius: var(--radius-full); font-size: 0.72rem; font-weight: 600; }
.role-badge--admin  { background: rgba(109,40,217,0.2); color: var(--clr-primary-light); }
.role-badge--player { background: rgba(14,165,233,0.15); color: var(--clr-secondary); }
.role-badge--banned { background: rgba(239,68,68,0.15); color: var(--clr-red); }

.type-chip {
  display: inline-block;
  padding: 2px 8px;
  background: var(--clr-surface-3);
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  color: var(--clr-text-muted);
}

/* ── Error Pages ──────────────────────────────────────────── */
.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 64px);
  text-align: center;
  padding: var(--space-xl);
  gap: var(--space-lg);
}
.error-page__code {
  font-family: var(--font-heading);
  font-size: clamp(4rem, 15vw, 8rem);
  font-weight: 800;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.error-page__title   { font-size: 1.5rem; }
.error-page__message { color: var(--clr-text-muted); }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 1024px) {
  .dash-grid       { grid-template-columns: 1fr; }
  .dash-section--battle { grid-column: 1; }
  .profile-grid    { grid-template-columns: 1fr; }
  .lesson-layout   { grid-template-columns: 1fr; }
  .lobby-modes     { grid-template-columns: 1fr; }
  .auth-split      { grid-template-columns: 1fr; }
  .auth-split__left{ display: none; }
}

@media (max-width: 768px) {
  .topbar__nav  { display: none; }
  .hamburger    { display: flex; }
  .topbar__xp   { display: none; }
  .hero         { grid-template-columns: 1fr; }
  .hero__preview{ display: none; }
  .stats-row    { grid-template-columns: repeat(2, 1fr); }
  .battle-modes { grid-template-columns: 1fr 1fr; }
  .form-row     { grid-template-columns: 1fr; }
  .admin-stats  { grid-template-columns: repeat(2, 1fr); }
  .profile-stats{ flex-wrap: wrap; gap: var(--space-lg); }
  .battle-hud   { grid-template-columns: 1fr auto; }
  .hud-player--2{ display: none; }
  .leaderboard-table th:nth-child(n+5),
  .leaderboard-table td:nth-child(n+5) { display: none; }
}

@media (max-width: 480px) {
  .stats-row    { grid-template-columns: 1fr 1fr; }
  .battle-modes { grid-template-columns: 1fr; }
  .admin-stats  { grid-template-columns: 1fr 1fr; }
}
