/* ============================================================
   Drag-n-Drop Arena — Shared Base Stylesheet
   Includes: variables, reset, typography, layout, buttons,
   topbar, flash messages, cards, badges, forms, XP bars,
   code blocks, spinner, footer, and global utilities.
   ============================================================ */

/* ── CSS Custom Properties ───────────────────────────────── */
:root {
  /* Backgrounds — deep navy CyberQuest palette */
  --clr-bg: #101722;
  --clr-surface: #141e2d;
  --clr-surface-2: #182030;
  --clr-surface-3: #1e2940;
  --clr-border: rgba(37, 123, 244, 0.18);
  --clr-border-subtle: rgba(37, 123, 244, 0.08);

  /* Primary — electric blue */
  --clr-primary: #257bf4;
  --clr-primary-light: #4f93f6;
  --clr-primary-dark: #1a5fc4;
  --clr-primary-glow: rgba(37, 123, 244, 0.22);

  /* Accent palette */
  --clr-secondary: #257bf4;
  --clr-gold: #fbbf24;
  --clr-green: #34d399;
  --clr-red: #f87171;
  --clr-orange: #fb923c;
  --clr-blue: #257bf4;

  /* Text */
  --clr-text: #e2e8f4;
  --clr-text-muted: #94a3b8;
  --clr-text-dim: #2a3a50;

  /* Gradients */
  --gradient-primary: linear-gradient(135deg, #257bf4 0%, #257bf4 100%);
  --gradient-gold: linear-gradient(135deg, #fbbf24 0%, #f97316 100%);
  --gradient-battle: linear-gradient(135deg, #257bf4 0%, #db2777 100%);
  --gradient-cyan: linear-gradient(135deg, #257bf4 0%, #257bf4 100%);
  --gradient-surface: linear-gradient(180deg, #182030 0%, #141e2d 100%);

  /* Typography — Barlow: geometric, tactical, techy */
  --font-body: 'Barlow', system-ui, sans-serif;
  --font-heading: 'Barlow Semi Condensed', 'Barlow', 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 — sharper, more angular */
  --radius-sm: 3px;
  --radius-md: 6px;
  --radius-lg: 10px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.6), 0 0 1px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.6), 0 1px 4px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.7), 0 2px 8px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 32px var(--clr-primary-glow), 0 0 8px rgba(37, 123, 244, 0.15);
  --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:
    linear-gradient(to right, rgba(37, 123, 244, 0.04) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(37, 123, 244, 0.04) 1px, transparent 1px);
  background-size: 40px 40px;
}

/* ── Disable JetBrains Mono / Fira Code ligatures globally ── */
/* Ligatures convert !=, ==, >=, <=, ->, ||, && into single glyphs */
code, pre, kbd, samp, tt,
[class*="tok-"],
[class*="ttml"],
[class*="code-"],
[class*="parsons"],
[class*="preview-"],
.section-eyebrow,
.cta-panel__prompt,
.cta-particle,
.hero__badge,
.lang-chip {
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "calt" 0;
}

/* ── CyberQuest Utility Classes ───────────────────────────── */
.cyber-grid {
  background-image:
    linear-gradient(to right, rgba(37, 123, 244, 0.05) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(37, 123, 244, 0.05) 1px, transparent 1px);
  background-size: 40px 40px;
}

.glass-panel {
  background: rgba(16, 23, 34, 0.65);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(37, 123, 244, 0.2);
}

.neon-glow {
  transition: border-color var(--transition);
}

.neon-glow:hover {
  border-color: rgba(37, 123, 244, 0.55) !important;
}

.glitch-text {
  letter-spacing: 0.05em;
}

.ms-icon {
  font-family: 'Material Symbols Outlined';
  font-size: inherit;
  font-style: normal;
  line-height: 1;
  vertical-align: middle;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

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.15;
  color: var(--clr-text);
  letter-spacing: 0.02em;
  font-weight: 700;
}

h1 {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
}

h2 {
  font-size: clamp(1.2rem, 2.5vw, 1.6rem);
  letter-spacing: 0.03em;
}

h3 {
  font-size: 1.05rem;
  letter-spacing: 0.04em;
}

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-primary {
  color: var(--clr-primary) !important;
}

.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(--clr-primary);
  color: #fff;
  font-family: var(--font-heading);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.82rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  border-radius: var(--radius-sm);
}

.btn--primary:hover {
  background: var(--clr-primary-light);
  transform: translateY(-1px);
  color: #fff;
}

.btn--primary:active {
  transform: translateY(0);
}

.btn--ranked {
  background: var(--gradient-gold);
  color: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.btn--ranked:hover {
  transform: translateY(-1px);
  color: #fff;
}

.btn--ghost {
  background: transparent;
  color: var(--clr-text-muted);
  border: 1px solid rgba(37, 123, 244, 0.25);
  box-shadow: none;
  font-family: var(--font-heading);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
}

.btn--ghost::after {
  display: none;
}

.btn--ghost:hover {
  background: rgba(37, 123, 244, 0.08);
  border-color: rgba(37, 123, 244, 0.5);
  color: var(--clr-text);
}

.btn--danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
}

.btn--danger:hover {
  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(16, 23, 34, 0.85);
  backdrop-filter: blur(16px) saturate(1.5);
  -webkit-backdrop-filter: blur(16px) saturate(1.5);
  border-bottom: 1px solid rgba(37, 123, 244, 0.2);
  z-index: 1000;
  box-shadow: 0 1px 0 rgba(37, 123, 244, 0.06);
}

.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: 3px;
  text-decoration: none;
  flex-shrink: 0;
}

.topbar__logo-img {
  width: 44px;
  height: 44px;
  object-fit: contain;
}

.logo-mark {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
}

.logo-text {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  color: var(--clr-text);
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.logo-accent {
  color: var(--clr-primary);
}

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

.nav-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  height: 64px;
  border-radius: 0;
  color: var(--clr-text-muted);
  font-family: var(--font-heading);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: all var(--transition);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  position: relative;
}

.nav-link svg {
  width: 15px;
  height: 15px;
  opacity: 0.7;
  flex-shrink: 0;
}

.nav-link:hover {
  color: var(--clr-text);
  background: rgba(37, 123, 244, 0.05);
}

.nav-link.active {
  color: var(--clr-primary);
  border-bottom-color: var(--clr-primary);
  background: transparent;
}

.nav-link.active svg {
  opacity: 1;
}

.nav-link--admin {
  letter-spacing: 0.05em;
}

/* ── Disabled nav link with tooltip ─────────────────────── */
.nav-link--disabled,
.nav-dropdown__item--disabled {
  opacity: 0.38;
  cursor: not-allowed;
  pointer-events: none;
  position: relative;
}

/* Restore pointer-events on the wrapper so the tooltip fires */
.nav-link--disabled {
  pointer-events: auto;
}
.nav-dropdown__item--disabled {
  pointer-events: auto;
}

.nav-link--disabled:hover,
.nav-dropdown__item--disabled:hover {
  color: var(--clr-text-muted);
  background: transparent;
  border-bottom-color: transparent;
  border-left-color: transparent;
}

.nav-link--disabled::after,
.nav-dropdown__item--disabled::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--clr-surface-2, #1a1f2e);
  color: var(--clr-text);
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  text-transform: none;
  white-space: nowrap;
  text-align: center;
  padding: 6px 12px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 1100;
}

.nav-link--disabled:hover::after,
.nav-dropdown__item--disabled:hover::after {
  opacity: 1;
}

/* ── Arena nav dropdown (admin-only bundle) ──────────────── */
.nav-dropdown {
  position: relative;
  height: 64px;
  display: flex;
  align-items: center;
}

.nav-dropdown__trigger {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  height: 64px;
  gap: 5px;
}

.nav-dropdown__chevron {
  opacity: 0.5;
  transition: transform var(--transition), opacity var(--transition);
  flex-shrink: 0;
}

.nav-dropdown--open .nav-dropdown__chevron {
  transform: rotate(180deg);
  opacity: 1;
}

.nav-dropdown__panel {
  display: none;
  position: absolute;
  top: calc(100% - 1px);
  left: 50%;
  transform: translateX(-50%);
  min-width: 180px;
  background: rgba(16, 23, 34, 0.97);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(37, 123, 244, 0.2);
  border-top: 2px solid var(--clr-primary);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  padding: var(--space-xs) 0;
  z-index: 1000;
  box-shadow: var(--shadow-lg);
}

.nav-dropdown--open .nav-dropdown__panel {
  display: block;
  animation: dropdown-in 0.15s ease;
}

@keyframes dropdown-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-6px);
  }

  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.nav-dropdown__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  font-family: var(--font-heading);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--clr-text-muted);
  text-decoration: none;
  transition: all var(--transition);
  border-left: 2px solid transparent;
}

.nav-dropdown__item svg {
  width: 15px;
  height: 15px;
  opacity: 0.6;
  flex-shrink: 0;
}

.nav-dropdown__item:hover {
  color: var(--clr-text);
  background: rgba(37, 123, 244, 0.06);
  border-left-color: rgba(37, 123, 244, 0.3);
}

.nav-dropdown__item:hover svg {
  opacity: 1;
}

.nav-dropdown__item.active {
  color: var(--clr-primary);
  border-left-color: var(--clr-primary);
  background: rgba(37, 123, 244, 0.06);
}

.nav-dropdown__item.active svg {
  opacity: 1;
}

/* 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;
}

/* ── Notification panel ──────────────────────────────────── */
.notif-menu {
  position: relative;
}

.notif-panel {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 340px;
  background: rgba(16, 23, 34, 0.97);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(37, 123, 244, 0.25);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  overflow: hidden;
}

.notif-panel.open {
  display: flex;
  flex-direction: column;
}

.notif-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--clr-border);
  flex-shrink: 0;
}

.notif-panel__title {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--clr-text);
}

.notif-panel__mark-read {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.75rem;
  color: var(--clr-primary);
  padding: 0;
  transition: color var(--transition);
}

.notif-panel__mark-read:hover {
  color: var(--clr-primary-light);
}

.notif-panel__body {
  overflow-y: auto;
  max-height: 400px;
  overscroll-behavior: contain;
}

.notif-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--clr-text-muted);
  font-size: 0.875rem;
  margin: 0;
}

.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--clr-border-subtle);
  text-decoration: none;
  color: var(--clr-text-muted);
  font-size: 0.875rem;
  transition: background var(--transition);
  position: relative;
}

.notif-item:last-child {
  border-bottom: none;
}

.notif-item:hover {
  background: var(--clr-surface-2);
  color: var(--clr-text);
}

.notif-item--unread {
  background: var(--clr-surface);
  color: var(--clr-text);
  border-left: 2px solid var(--clr-primary);
  padding-left: 14px;
}

.notif-item--unread:hover {
  background: var(--clr-surface-2);
}

.notif-item__icon {
  font-size: 1rem;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.notif-icon--duel {
  background: rgba(37, 123, 244, 0.15);
}

.notif-icon--achievement {
  background: rgba(251, 191, 36, 0.15);
}

.notif-icon--reward {
  background: rgba(52, 211, 153, 0.15);
}

.notif-icon--friend {
  background: rgba(34, 211, 238, 0.15);
}

.notif-icon--default {
  background: var(--clr-surface-3);
}

.notif-item__content {
  flex: 1;
  min-width: 0;
}

.notif-item__msg {
  margin: 0 0 3px;
  line-height: 1.4;
  word-break: break-word;
}

.notif-item__time {
  font-size: 0.72rem;
  color: var(--clr-text-muted);
}

.notif-item__dot {
  width: 7px;
  height: 7px;
  border-radius: var(--radius-full);
  background: var(--clr-primary);
  flex-shrink: 0;
  margin-top: 6px;
}

/* ── Notification backdrop (mobile) ─────────────────────── */
.notif-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 199;
}

.notif-backdrop.visible {
  display: block;
}

@media (max-width: 640px) {
  .notif-panel {
    position: fixed;
    top: 64px;
    left: 0;
    right: 0;
    width: 100%;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    border-left: none;
    border-right: none;
    border-top: none;
    z-index: 200;
  }

  .notif-panel__body {
    max-height: 60vh;
  }
}

/* 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: 210px;
  background: rgba(16, 23, 34, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(37, 123, 244, 0.25);
  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--reward {
  border-color: #f59e0b;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.12) 0%, rgba(251, 191, 36, 0.06) 100%);
  box-shadow: var(--shadow-md);
  padding: 14px 18px;
}

.flash__icon {
  font-size: 1rem;
}

.flash--reward .flash__icon {
  font-size: 1.4rem;
  line-height: 1;
}

.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--reward .flash__message {
  font-weight: 600;
  font-size: 0.925rem;
  color: var(--clr-gold);
}

@keyframes flash-fadeout {
  0% {
    opacity: 1;
    transform: translateX(0);
  }

  100% {
    opacity: 0;
    transform: translateX(20px);
  }
}

.flash--hiding {
  animation: flash-fadeout 0.35s ease forwards;
}

.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: rgba(16, 23, 34, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(37, 123, 244, 0.15);
  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(37, 123, 244, 0.4);
  box-shadow: var(--shadow-md);
  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);
}

.badge--warn {
  background: rgba(245, 158, 11, 0.15);
  color: var(--clr-gold);
}

.badge--info {
  background: rgba(34, 211, 238, 0.12);
  color: var(--clr-secondary);
}

.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);
}

/* ── Language logo ───────────────────────────────────────── */
.lang-logo {
  display: inline-block;
  width: 1.5em;
  height: 1.5em;
  vertical-align: middle;
  object-fit: contain;
}

.lang-logo--label {
  width: 1.1em;
  height: 1.1em;
  vertical-align: -0.15em;
  margin-right: 4px;
}

/* ── 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: #257bf4;
  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(37, 123, 244, 0.6);
  box-shadow: 0 0 0 3px rgba(37, 123, 244, 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: 64px;
}

.toggle-password {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--clr-text-muted);
  padding: 4px;
  display: flex;
  align-items: center;
  transition: color 0.15s;
}

.toggle-password:hover {
  color: var(--clr-text);
}

/* Lit/active state — password is currently visible */
.toggle-password[aria-pressed="true"] {
  color: var(--clr-primary-light);
}

.eye-icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: block;
}

/* Both icons + labels hidden by default;
   explicitly reveal the correct one per aria-pressed state */
.eye-icon--open,
.eye-icon--off,
.toggle-password__label--see,
.toggle-password__label--unsee {
  display: none;
}

/* aria-pressed="false" → password is hidden → show slash-eye + "See" */
.toggle-password[aria-pressed="false"] .eye-icon--off,
.toggle-password[aria-pressed="false"] .toggle-password__label--see {
  display: block;
}

/* aria-pressed="true" → password is visible → show open-eye + "Unsee" */
.toggle-password[aria-pressed="true"] .eye-icon--open,
.toggle-password[aria-pressed="true"] .toggle-password__label--unsee {
  display: block;
}

/* See / Unsee label typography */
.toggle-password__label--see,
.toggle-password__label--unsee {
  font-family: var(--font-code);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  line-height: 1;
}

/* 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);
}

/* Utility input class */
.form-input {
  width: 100%;
  padding: 10px 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);
  outline: none;
}

.form-input:focus {
  border-color: rgba(37, 123, 244, 0.6);
  box-shadow: 0 0 0 3px rgba(37, 123, 244, 0.12);
}

.form-input--sm {
  padding: 6px 10px;
  font-size: 0.82rem;
}

/* ── 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;
}

/* ── Loading Spinner ──────────────────────────────────────── */
@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;
}

/* ── 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;
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "calt" 0;
}

/* ── Footer ───────────────────────────────────────────────── */
.site-footer {
  background: rgba(16, 23, 34, 0.9);
  border-top: 1px solid rgba(37, 123, 244, 0.2);
  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(37, 123, 244, 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;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.footer-copy {
  color: var(--clr-text-dim);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.footer-nav {
  display: flex;
  gap: var(--space-lg);
}

.footer-nav a {
  color: var(--clr-text-muted);
  font-size: 0.75rem;
  font-family: var(--font-heading);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  transition: color var(--transition);
}

.footer-nav a:hover {
  color: var(--clr-primary);
}

/* ── Shared Utilities ─────────────────────────────────────── */

/* "YOU" tag — used across leaderboard, duel show, duel play */
.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;
}

/* 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;
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-svg {
  width: 2rem;
  height: 2rem;
  color: var(--clr-primary);
  opacity: 0.7;
}

.empty-state p {
  color: var(--clr-text-muted);
  font-size: 0.875rem;
}

/* Page header utility */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
  flex-wrap: wrap;
}

.page-header h1 {
  margin-bottom: 4px;
}

.page-header p {
  font-size: 0.9rem;
}

/* Back link */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--clr-text-muted);
  text-decoration: none;
  font-family: var(--font-heading);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: color var(--transition);
}

.back-link:hover {
  color: var(--clr-primary);
}

/* ── Responsive — Global ──────────────────────────────────── */
@media (max-width: 768px) {
  .topbar__inner {
    padding: 0 var(--space-md);
  }

  .topbar__nav {
    display: none;
    position: fixed;
    top: 64px;
    left: 0;
    right: 0;
    background: rgba(16, 23, 34, 0.97);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(37, 123, 244, 0.2);
    flex-direction: column;
    padding: var(--space-md) 0;
    gap: 0;
    height: auto;
    z-index: 999;
  }

  .topbar__nav.open {
    display: flex;
  }

  .topbar__nav .nav-link {
    height: auto;
    padding: 12px 24px;
    border-bottom: none;
    border-left: 2px solid transparent;
    width: 100%;
  }

  .topbar__nav .nav-link.active {
    border-left-color: var(--clr-primary);
    background: rgba(37, 123, 244, 0.08);
  }

  .hamburger {
    display: flex;
  }

  .topbar__xp {
    display: none;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  /* Arena dropdown — accordion on mobile */
  .nav-dropdown {
    height: auto;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .nav-dropdown__trigger {
    height: auto;
    padding: 12px 24px;
    border-bottom: none;
    border-left: 2px solid transparent;
    border-top: none;
    border-right: none;
    width: 100%;
    justify-content: flex-start;
  }

  .nav-dropdown__trigger.active {
    border-left-color: var(--clr-primary);
    background: rgba(37, 123, 244, 0.08);
  }

  .nav-dropdown__panel {
    position: static;
    transform: none;
    min-width: unset;
    width: 100%;
    border: none;
    border-top: 1px solid rgba(37, 123, 244, 0.12);
    border-radius: 0;
    box-shadow: none;
    padding: 0;
    background: rgba(37, 123, 244, 0.03);
  }

  .nav-dropdown--open .nav-dropdown__panel {
    animation: none;
  }

  .nav-dropdown__item {
    padding: 10px 24px 10px 40px;
  }

  .nav-dropdown__item.active {
    border-left-color: var(--clr-primary);
    background: rgba(37, 123, 244, 0.08);
  }

  /* Disabled nav link in mobile nav — full width, no tooltip */
  .topbar__nav .nav-link--disabled {
    width: 100%;
    height: auto;
    padding: 12px 24px;
    border-bottom: none;
    border-left: 2px solid transparent;
  }

  .nav-link--disabled::after,
  .nav-dropdown__item--disabled::after {
    display: none;
  }
}

/* ── Shared page hero header ─────────────────────────────── */
.page-hdr {
  margin-bottom: var(--space-2xl);
}

.page-hdr__eyebrow {
  margin-bottom: var(--space-sm);
}

.page-hdr__tag {
  font-family: var(--font-code);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  color: #257bf4;
  background: rgba(37, 123, 244, 0.08);
  border: 1px solid rgba(37, 123, 244, 0.25);
  border-radius: var(--radius-sm);
  padding: 3px 10px;
  display: inline-block;
}

.page-hdr__title {
  font-family: var(--font-heading);
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: -0.03em;
  color: #e2e8f4;
  margin-bottom: var(--space-sm);
}

.page-hdr__title em {
  font-style: normal;
  color: #257bf4;
  -webkit-text-fill-color: #257bf4;
  background: none;
}

.page-hdr__sub {
  font-size: 0.95rem;
  color: var(--clr-text-muted);
  max-width: 520px;
  line-height: 1.7;
}

.page-hdr__row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-md);
}

@media (max-width: 600px) {
  .page-hdr__row {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-sm);
  }

  .page-hdr__row > a.btn {
    display: flex;
    width: 100%;
    box-sizing: border-box;
    justify-content: center;
    white-space: normal;
    word-break: break-word;
    overflow: visible;
    height: auto;
  }
}

/* ── Logout confirmation modal ───────────────────────────── */
.logout-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logout-modal[hidden] { display: none; }

.logout-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 14, 22, 0.72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.logout-modal__box {
  position: relative;
  background: var(--clr-surface-2);
  border: 1px solid var(--clr-border);
  border-radius: 16px;
  padding: 2rem 2.25rem 1.75rem;
  width: min(360px, calc(100vw - 2rem));
  text-align: center;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5);
  animation: logout-modal-in 0.18s ease;
}

@keyframes logout-modal-in {
  from { opacity: 0; transform: scale(0.93) translateY(8px); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}

.logout-modal__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(248, 113, 113, 0.12);
  color: var(--clr-red);
  margin-bottom: 1rem;
}

.logout-modal__title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--clr-text);
  margin: 0 0 0.4rem;
}

.logout-modal__body {
  font-size: 0.9rem;
  color: var(--clr-text-muted);
  margin: 0 0 1.5rem;
  line-height: 1.6;
}

.logout-modal__actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}

/* ── Section count badge (used in dash & profile titles) ─── */
.profile-section__count {
  font-family: var(--font-code);
  font-size: 0.65rem;
  color: var(--clr-text-muted);
  margin-left: 2px;
}

/* ── Shared Achievement Grid & Badges ────────────────────── */
.achievement-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px;
}

.achievement-badge {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 8px 10px;
  background: var(--clr-surface-3);
  border: 1px solid var(--ach-color, var(--clr-border));
  border-radius: var(--radius-md);
  text-align: center;
  cursor: default;
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
}

/* Subtle color wash at the top of each card */
.achievement-badge::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 80% 60% at 50% -10%, var(--ach-color, transparent), transparent);
  opacity: 0.1;
  pointer-events: none;
}

.achievement-badge:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4),
              0 0 0 1px var(--ach-color, var(--clr-border));
}

.achievement-badge__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ach-color, var(--clr-text-muted));
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.5));
  position: relative;
}

.achievement-badge__icon svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.achievement-badge__name {
  font-family: var(--font-code);
  font-size: 0.63rem;
  font-weight: 700;
  color: var(--ach-color, var(--clr-text));
  line-height: 1.25;
  letter-spacing: 0.02em;
  position: relative;
}

.achievement-badge__desc {
  font-size: 0.58rem;
  color: var(--clr-text-muted);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  position: relative;
}

.achievement-badge__date {
  font-family: var(--font-code);
  font-size: 0.54rem;
  color: var(--clr-text-dim);
  margin-top: 2px;
  position: relative;
}