/* ===================================
   ChessDare - Design System & Styles
   =================================== */

/* --- CSS Custom Properties --- */
:root {
  /* Colors - Dark Theme */
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-tertiary: #1a1a2e;
  --bg-card: rgba(26, 26, 46, 0.6);
  --bg-card-hover: rgba(26, 26, 46, 0.85);
  --bg-input: rgba(26, 26, 46, 0.8);
  --bg-navbar: rgba(10, 10, 15, 0.85);

  --text-primary: #f0f0f5;
  --text-secondary: #a0a0b8;
  --text-muted: #6b6b80;
  --text-link: #a78bfa;

  /* Accent Gradient */
  --accent-start: #7c3aed;
  --accent-mid: #a855f7;
  --accent-end: #06b6d4;
  --gradient-accent: linear-gradient(135deg, var(--accent-start), var(--accent-end));
  --gradient-accent-h: linear-gradient(90deg, var(--accent-start), var(--accent-end));

  /* Status Colors */
  --color-success: #22c55e;
  --color-error: #ef4444;
  --color-warning: #f59e0b;
  --color-draw: #a0a0b8;

  /* Borders */
  --border-color: rgba(160, 160, 184, 0.12);
  --border-color-hover: rgba(160, 160, 184, 0.25);
  --border-accent: rgba(124, 58, 237, 0.4);

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;

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

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 30px rgba(124, 58, 237, 0.15);

  /* Typography */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;
  --font-size-3xl: 2rem;
  --font-size-4xl: 2.5rem;
  --font-size-5xl: 3.5rem;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 400ms ease;

  /* Z-index */
  --z-dropdown: 100;
  --z-navbar: 200;
  --z-modal: 300;
  --z-tooltip: 400;
}

/* --- Custom Tooltips --- */
[data-tooltip] {
  position: relative;
}

[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 12px;
  font-family: var(--font-family);
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-accent);
  box-shadow: var(--shadow-lg);
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
  pointer-events: none;
  z-index: var(--z-tooltip);
}

[data-tooltip]:hover::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  border: 6px solid transparent;
  border-top-color: var(--border-accent);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
  pointer-events: none;
  z-index: var(--z-tooltip);
}

[data-tooltip]:hover::before,
[data-tooltip]:hover::after {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

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

/* Global background pattern */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(124, 58, 237, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(6, 182, 212, 0.04) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, rgba(168, 85, 247, 0.03) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

a {
  color: var(--text-link);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--accent-end);
}

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

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

.main-content {
  flex: 1;
  position: relative;
  z-index: 1;
}

/* --- Navbar --- */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: var(--z-navbar);
  background: var(--bg-navbar);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-color);
  transition: background var(--transition-base);
}

.navbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  gap: var(--space-md);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.navbar-search {
  position: relative;
  flex: 1 1 auto;
  max-width: 180px;
  min-width: 100px;
}

.navbar-search--guest {
  max-width: 176px;
}

.navbar-search-input {
  width: 100%;
  box-sizing: border-box;
  height: 36px;
  padding: 0 12px;
  font-size: var(--font-size-sm);
  font-family: var(--font-family);
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.navbar-search-input::placeholder {
  color: var(--text-muted);
}

.navbar-search-input:focus {
  border-color: rgba(124, 58, 237, 0.45);
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.15);
}

/* Dropdown search (hidden on desktop, shown on mobile) */
.dropdown-search {
  display: none;
  padding: var(--space-sm) var(--space-md);
}

.dropdown-search + .dropdown-divider {
  display: none;
}

.dropdown-search-input {
  width: 100%;
  box-sizing: border-box;
  height: 36px;
  padding: 0 12px;
  font-size: var(--font-size-sm);
  font-family: var(--font-family);
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.dropdown-search-input::placeholder {
  color: var(--text-muted);
}

.dropdown-search-input:focus {
  border-color: rgba(124, 58, 237, 0.45);
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.15);
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--text-primary);
  font-weight: 700;
  font-size: var(--font-size-xl);
  text-decoration: none;
  flex-shrink: 0;
}

.navbar-brand:hover {
  color: var(--text-primary);
}

.navbar-brand-logo {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: block;
  object-fit: contain;
}

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

.brand-beta {
  font-size: 0.55rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--gradient-accent-h);
  color: #fff;
  padding: 0.5em 0.8em;
  border-radius: 4px;
  line-height: 1;
  align-self: flex-start;
  margin-top: 0.15em;
}

.navbar-links {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.nav-link {
  color: var(--text-secondary);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  font-weight: 500;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
}

.nav-link:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.nav-link.active {
  color: var(--text-primary);
  background: rgba(124, 58, 237, 0.15);
}

.nav-link-mobile-auth {
  display: none;
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

/* Guest language menu (navbar, logged out) */
.guest-lang-menu {
  position: relative;
  flex-shrink: 0;
}

.guest-lang-menu-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 10px 0 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  cursor: pointer;
  color: var(--text-primary);
  transition: all var(--transition-fast);
  font-family: var(--font-family);
}

.guest-lang-menu-trigger:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--border-color-hover);
}

.guest-lang-icon {
  flex-shrink: 0;
  color: var(--text-muted);
}

.guest-lang-code {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--accent-mid);
  min-width: 1.5em;
  text-align: center;
}

.guest-lang-chevron {
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform var(--transition-fast);
}

.guest-lang-menu.open .guest-lang-chevron {
  transform: rotate(180deg);
}

.dropdown-item.guest-lang-item.is-active {
  color: var(--accent-mid);
  font-weight: 600;
  background: rgba(124, 58, 237, 0.08);
}

/* User Menu */
.user-menu {
  position: relative;
}

.user-menu-trigger {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  padding: 4px 12px 4px 4px;
  cursor: pointer;
  color: var(--text-primary);
  transition: all var(--transition-fast);
  font-family: var(--font-family);
}

.user-menu-trigger:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--border-color-hover);
}

.user-avatar-small {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--gradient-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.user-avatar-small img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-letter {
  color: white;
  font-weight: 700;
  font-size: var(--font-size-sm);
}

.user-menu-name {
  font-size: var(--font-size-sm);
  font-weight: 500;
}

.user-menu-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-size: 11px;
  font-weight: 700;
  background: var(--gradient-accent);
  color: white;
  border-radius: var(--radius-full);
  box-shadow: 0 0 8px rgba(124, 58, 237, 0.4);
}

.user-menu-badge[hidden] {
  display: none;
}

.chevron-icon {
  transition: transform var(--transition-fast);
}

.user-menu.open .chevron-icon {
  transform: rotate(180deg);
}

.user-dropdown,
.guest-lang-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 200px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all var(--transition-fast);
  z-index: var(--z-dropdown);
  overflow: hidden;
}

.guest-lang-dropdown {
  min-width: 160px;
}

.user-menu.open .user-dropdown,
.guest-lang-menu.open .guest-lang-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  transition: all var(--transition-fast);
  text-decoration: none;
  border: none;
  background: none;
  width: 100%;
  cursor: pointer;
  font-family: var(--font-family);
}

.dropdown-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.dropdown-danger:hover {
  background: rgba(239, 68, 68, 0.1);
  color: var(--color-error);
}

.nav-link-donate {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #f472b6;
  background: rgba(236, 72, 153, 0.08);
  border: 1px solid rgba(236, 72, 153, 0.2);
}

.nav-link-donate:hover {
  color: #f9a8d4;
  background: rgba(236, 72, 153, 0.15);
  border-color: rgba(236, 72, 153, 0.35);
}

.nav-link-donate.active {
  color: #f9a8d4;
  background: rgba(236, 72, 153, 0.18);
  border-color: rgba(236, 72, 153, 0.4);
}

.nav-link-donate svg {
  flex-shrink: 0;
}

.dropdown-divider {
  height: 1px;
  background: var(--border-color);
  margin: var(--space-xs) 0;
}

.dropdown-item-challenges {
  position: relative;
}

.challenge-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-size: 11px;
  font-weight: 700;
  background: var(--gradient-accent);
  color: white;
  border-radius: var(--radius-full);
  margin-left: auto;
}

.challenge-badge[hidden] {
  display: none;
}

.dropdown-item-lab {
  flex-wrap: wrap;
}

.dropdown-item-beta {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  background: rgba(124, 58, 237, 0.18);
  border: 1px solid rgba(124, 58, 237, 0.35);
  color: #c4b5fd;
  line-height: 1;
  flex-shrink: 0;
  margin-left: 2px;
}

/* Mobile Nav */
.mobile-menu-btn {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--space-sm);
}

.mobile-menu-btn span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: transform 0.3s ease, opacity 0.3s ease;
  transform-origin: center;
}

.mobile-menu-btn.active span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.mobile-menu-btn.active span:nth-child(2) {
  opacity: 0;
}

.mobile-menu-btn.active span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 10px 20px;
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-base);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
}

.btn-primary {
  background: var(--gradient-accent);
  color: white;
  border: none;
  box-shadow: 0 2px 12px rgba(124, 58, 237, 0.3);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(124, 58, 237, 0.45);
  color: white;
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: 0 1px 6px rgba(124, 58, 237, 0.12);
  filter: grayscale(0.25);
}

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

.btn-ghost:hover {
  color: var(--text-primary);
  border-color: var(--border-color-hover);
  background: rgba(255, 255, 255, 0.05);
}

.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid rgba(124, 58, 237, 0.5);
}

.btn-outline:hover {
  background: rgba(124, 58, 237, 0.1);
  border-color: var(--accent-start);
  color: white;
}

.btn-lg {
  padding: 14px 28px;
  font-size: var(--font-size-base);
  border-radius: var(--radius-md);
}

.btn-block {
  width: 100%;
}

/* --- Hero Section --- */
.hero {
  padding: calc(64px + var(--space-3xl)) 0 var(--space-3xl);
  overflow: hidden;
}

.hero-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3xl);
  align-items: center;
}

.hero-title {
  font-size: var(--font-size-5xl);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-lg);
}

.hero-gradient {
  display: block;
  background: var(--gradient-accent-h);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-subtitle {
  font-size: var(--font-size-lg);
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: var(--space-xl);
  max-width: 500px;
}

.hero-actions {
  display: flex;
  gap: var(--space-md);
  margin-bottom: var(--space-2xl);
}

.hero-stats {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-value {
  font-size: var(--font-size-xl);
  font-weight: 700;
}

.stat-label {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-divider {
  width: 1px;
  height: 32px;
  background: var(--border-color);
}

/* Hero Chessboard */
.hero-visual {
  display: flex;
  justify-content: center;
  align-items: center;
}

.chess-board-hero {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  width: 380px;
  height: 380px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  border: 1px solid var(--border-color);
  transform: perspective(800px) rotateX(5deg) rotateY(-5deg);
  animation: boardFloat 6s ease-in-out infinite;
}

.board-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  user-select: none;
  transition: background var(--transition-fast);
}

.cell-light {
  background: rgba(168, 85, 247, 0.15);
}

.cell-dark {
  background: rgba(124, 58, 237, 0.3);
}

.board-cell:hover {
  background: rgba(6, 182, 212, 0.25);
}

/* --- Features Section --- */
.features {
  padding: var(--space-3xl) 0;
}

.section-title {
  text-align: center;
  font-size: var(--font-size-3xl);
  font-weight: 700;
  margin-bottom: var(--space-2xl);
  letter-spacing: -0.01em;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-lg);
}

.feature-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  transition: all var(--transition-base);
}

.feature-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-accent);
  transform: translateY(-4px);
  box-shadow: var(--shadow-glow);
}

.feature-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  background: rgba(124, 58, 237, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-md);
  color: var(--accent-mid);
}

.feature-card h3 {
  font-size: var(--font-size-xl);
  font-weight: 600;
  margin-bottom: var(--space-sm);
}

.feature-card p {
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  line-height: 1.7;
}

/* --- Auth Section --- */
.auth-section {
  padding: calc(64px + var(--space-3xl)) 0 var(--space-3xl);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: var(--space-2xl);
  box-shadow: var(--shadow-lg);
  animation: fadeInUp 0.5s ease;
}

.auth-header {
  text-align: center;
  margin-bottom: var(--space-xl);
}

.auth-header h1 {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  margin-bottom: var(--space-xs);
}

.auth-header p {
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
}

/* --- Forms --- */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.form-label {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--text-secondary);
}

.input-wrapper {
  position: relative;
}

.input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  transition: color var(--transition-fast);
}

.form-input {
  width: 100%;
  padding: 12px 14px 12px 44px;
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  outline: none;
  transition: all var(--transition-fast);
}

.form-input::placeholder {
  color: var(--text-muted);
}

.form-input:focus {
  border-color: var(--accent-start);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}

.form-input:focus + .input-icon,
.form-input:focus ~ .input-icon {
  color: var(--accent-mid);
}

/* Fix: icon is before input in DOM, so use parent focus-within */
.input-wrapper:focus-within .input-icon {
  color: var(--accent-mid);
}

.form-hint {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

/* Alert */
.alert {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  margin-bottom: var(--space-md);
}

.alert-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--color-error);
}

.auth-footer {
  text-align: center;
  margin-top: var(--space-lg);
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

.auth-footer a {
  font-weight: 600;
}



/* --- Footer --- */
.footer {
  border-top: 1px solid var(--border-color);
  padding: var(--space-xl) 0;
  position: relative;
  z-index: 1;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-weight: 700;
  font-size: var(--font-size-lg);
}

.footer-text {
  color: var(--text-muted);
  font-size: var(--font-size-sm);
  margin: 0;
  text-align: center;
}

.footer-brand {
  flex: 1;
}

.footer-links {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--font-size-sm);
}

.footer-links-divider {
  color: var(--text-muted);
  opacity: 0.4;
  user-select: none;
}

.footer-link {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s ease;
}

.footer-link:hover {
  color: var(--text-primary);
}

/* --- Animations --- */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes boardFloat {
  0%, 100% {
    transform: perspective(800px) rotateX(5deg) rotateY(-5deg);
  }
  50% {
    transform: perspective(800px) rotateX(3deg) rotateY(-3deg) translateY(-8px);
  }
}

/* --- Responsive --- */
@media (max-width: 1024px) {
  .hero-content {
    grid-template-columns: 1fr;
    gap: var(--space-2xl);
    text-align: center;
  }

  .hero-subtitle {
    max-width: 100%;
  }

  .hero-actions {
    justify-content: center;
  }

  .hero-stats {
    justify-content: center;
  }

  .hero-visual {
    order: -1;
  }

  .chess-board-hero {
    width: 320px;
    height: 320px;
  }

  .features-grid {
    grid-template-columns: 1fr;
    max-width: 500px;
    margin: 0 auto;
  }

  .profile-stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 768px) {
  :root {
    --font-size-5xl: 2.5rem;
    --font-size-4xl: 2rem;
    --font-size-3xl: 1.75rem;
  }

  .navbar-links {
    display: flex;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: rgb(10, 10, 15);
    border-bottom: 1px solid var(--border-color);
    flex-direction: column;
    padding: var(--space-md);
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  }

  .navbar-links.open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
  }

  .nav-link-mobile-auth {
    display: inline-flex;
    width: 100%;
    justify-content: center;
    margin-top: 4px;
  }

  .nav-link-mobile-auth-primary {
    background: rgba(124, 58, 237, 0.18);
    border: 1px solid rgba(124, 58, 237, 0.35);
    color: var(--text-primary);
  }

  .navbar-actions > .btn {
    display: none;
  }

  .navbar-search {
    display: none;
  }

  .dropdown-search {
    display: block;
  }

  .dropdown-search + .dropdown-divider {
    display: block;
  }

  .mobile-menu-btn {
    display: flex;
  }

  .user-menu-name {
    display: none;
  }

  .chess-board-hero {
    width: 260px;
    height: 260px;
    font-size: 1.4rem;
  }

  .board-cell {
    font-size: 1.4rem;
  }

  .profile-header {
    flex-direction: column;
    text-align: center;
  }

  .profile-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .profile-joined {
    justify-content: center;
  }

  .footer-inner {
    flex-direction: column;
    gap: var(--space-sm);
    text-align: center;
  }

  .footer-brand {
    flex: unset;
    justify-content: center;
  }

  .footer-text {
    flex: unset;
    text-align: center;
    font-size: var(--font-size-xs);
    word-break: break-word;
  }

  .footer-links {
    flex-wrap: wrap;
    justify-content: center;
    font-size: var(--font-size-xs);
  }

  .hero-actions {
    flex-direction: column;
    align-items: center;
  }
}

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

  .hero-stats {
    flex-direction: column;
    gap: var(--space-md);
  }

  .stat-divider {
    width: 32px;
    height: 1px;
  }

  .auth-card {
    padding: var(--space-xl);
  }
}

/* Language links (user dropdown compact switcher) */
.lang-link {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-decoration: none;
  transition: all var(--transition-fast);
  padding: 2px 4px;
}

.lang-link:hover {
  color: var(--text-primary);
}

.lang-link.active {
  color: var(--accent-mid);
}

.lang-divider {
  font-size: 10px;
  color: var(--border-color);
  user-select: none;
}

/* User Dropdown Language */
.dropdown-lang-container {
  cursor: default !important;
}

.dropdown-lang-container:hover {
  background: transparent !important;
}

.dropdown-lang-switcher {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  background: rgba(255, 255, 255, 0.03);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  margin-left: var(--space-xs);
}

.dropdown-lang-switcher .lang-link {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  padding: 2px 4px;
}

.dropdown-lang-switcher .lang-link:hover {
  color: var(--text-primary);
}

.dropdown-lang-switcher .lang-link.active {
  color: var(--accent-mid);
}

/* User Dropdown Style Section */
.dropdown-style-section {
  padding: 0;
}

.dropdown-style-label {
  cursor: default !important;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: var(--font-size-sm);
  padding-bottom: 2px;
}

.dropdown-style-label:hover {
  background: transparent !important;
  color: var(--text-secondary) !important;
}

.dropdown-style-row {
  cursor: default !important;
  padding: 4px var(--space-md);
  gap: var(--space-sm);
}

.dropdown-style-row:hover {
  background: transparent !important;
}

.dropdown-style-row-label {
  font-size: 11px;
  color: var(--text-muted);
  min-width: 50px;
}

.style-board-options,
.style-piece-options {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

.style-board-btn,
.style-piece-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 0;
  background: none;
  transition: border-color var(--transition-fast), transform var(--transition-fast);
}

.style-board-btn:hover,
.style-piece-btn:hover {
  transform: scale(1.1);
}

.style-board-btn.active,
.style-piece-btn.active {
  border-color: var(--accent-mid);
}

.style-board-btn {
  width: 28px;
  height: 28px;
  overflow: hidden;
  border-radius: 4px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}

.style-board-btn > span {
  display: block;
  width: 100%;
  height: 100%;
}

.style-piece-btn {
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
}

.style-piece-btn img {
  pointer-events: none;
}

/* ── Partner Badge (global) ── */
.partner-emoji {
  font-style: normal;
  margin-left: 1px;
}

/* ── Active Game Banner (home / lobby) ── */
.active-game-banner {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  padding: var(--space-md) var(--space-lg);
  margin: var(--space-lg) 0;
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.22), rgba(6, 182, 212, 0.18));
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 18px rgba(124, 58, 237, 0.18);
  flex-wrap: wrap;
  width: 100%;
  box-sizing: border-box;
  text-align: left;
}

.active-game-banner-icon {
  font-size: 1.75rem;
  line-height: 1;
  animation: active-game-pulse 1.8s ease-in-out infinite;
}

.active-game-banner-text {
  flex: 1;
  min-width: 220px;
}

.active-game-banner-title {
  font-size: var(--font-size-base);
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 2px 0;
}

.active-game-banner-desc {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin: 0;
}

.active-game-banner .btn {
  flex-shrink: 0;
}

@keyframes active-game-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.12); opacity: 0.85; }
}

/* ── Active Game Card (profile) ── */
.profile-active-game {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  padding: var(--space-md) var(--space-lg);
  margin: var(--space-lg) 0;
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.18), rgba(6, 182, 212, 0.14));
  border: 1px solid rgba(34, 197, 94, 0.4);
  border-radius: var(--radius-md);
  flex-wrap: wrap;
}

.profile-active-game-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--color-success);
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6);
  animation: active-game-dot-pulse 1.6s ease-in-out infinite;
  flex-shrink: 0;
}

.profile-active-game-text {
  flex: 1;
  min-width: 220px;
}

.profile-active-game-title {
  font-size: var(--font-size-base);
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 2px 0;
}

.profile-active-game-desc {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin: 0;
}

.profile-active-game .btn {
  flex-shrink: 0;
}

@keyframes active-game-dot-pulse {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6); }
  70% { box-shadow: 0 0 0 10px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}
