/* ============================
   AMŐBA ONLINE - Design System
   Dark Theme + Glassmorphism + Neon
   ============================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700;800&display=swap');

/* ── CSS Variables ── */
:root {
  /* Colors */
  --bg-primary: #0a0a1a;
  --bg-secondary: #12122a;
  --bg-card: rgba(20, 20, 50, 0.6);
  --bg-glass: rgba(255, 255, 255, 0.05);
  --border-glass: rgba(255, 255, 255, 0.1);

  --neon-blue: #00d4ff;
  --neon-blue-glow: rgba(0, 212, 255, 0.3);
  --neon-orange: #ff6b35;
  --neon-orange-glow: rgba(255, 107, 53, 0.3);
  --neon-green: #00ff88;
  --neon-red: #ff3366;
  --neon-purple: #a855f7;

  --text-primary: #e8e8f0;
  --text-secondary: #8888aa;
  --text-muted: #555577;

  /* Typography */
  --font-body: 'Inter', sans-serif;
  --font-heading: 'Outfit', sans-serif;

  /* Spacing */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* Shadows */
  --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-glow-blue: 0 0 20px var(--neon-blue-glow);
  --shadow-glow-orange: 0 0 20px var(--neon-orange-glow);
}

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

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

body {
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

/* Animated background */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(0, 212, 255, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(255, 107, 53, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, rgba(168, 85, 247, 0.05) 0%, transparent 50%);
  z-index: -1;
  animation: bgPulse 8s ease-in-out infinite alternate;
}

@keyframes bgPulse {
  0% {
    opacity: 0.8;
  }

  100% {
    opacity: 1;
  }
}

/* ── Typography ── */
h1,
h2,
h3,
h4 {
  font-family: var(--font-heading);
  font-weight: 700;
  letter-spacing: -0.02em;
}

h1 {
  font-size: 2.5rem;
}

h2 {
  font-size: 1.75rem;
}

h3 {
  font-size: 1.25rem;
}

a {
  color: var(--neon-blue);
  text-decoration: none;
  transition: all 0.2s;
}

a:hover {
  text-shadow: 0 0 10px var(--neon-blue-glow);
}

/* ── Glass Card ── */
.glass-card {
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 2rem;
  transition: all 0.3s ease;
}

.glass-card:hover {
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: var(--shadow-card), 0 0 30px rgba(0, 212, 255, 0.05);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.1rem;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
  transition: left 0.5s;
}

.btn:hover::before {
  left: 100%;
}

.btn-primary {
  background: linear-gradient(135deg, var(--neon-blue), #0099cc);
  color: white;
  box-shadow: 0 4px 15px var(--neon-blue-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px var(--neon-blue-glow);
}

.btn-secondary {
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--neon-blue);
}

.btn-google {
  background: white;
  color: #333;
  font-weight: 500;
  gap: 0.75rem;
}

.btn-google:hover {
  background: #f0f0f0;
  transform: translateY(-2px);
}

.btn-google svg {
  width: 20px;
  height: 20px;
}

.btn-danger {
  background: linear-gradient(135deg, var(--neon-red), #cc0033);
  color: white;
}

.btn-danger:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(255, 51, 102, 0.3);
}

.btn-orange {
  background: linear-gradient(135deg, var(--neon-orange), #cc5500);
  color: white;
  box-shadow: 0 4px 15px var(--neon-orange-glow);
}

.btn-orange:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px var(--neon-orange-glow);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
}

.btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 0.95rem;
}

.btn-block {
  width: 100%;
}

/* ── Form Elements ── */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.form-input {
  width: 100%;
  padding: 0.6rem 0.85rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.875rem;
  transition: all 0.3s ease;
}

.form-input:focus {
  outline: none;
  border-color: var(--neon-blue);
  box-shadow: 0 0 0 3px var(--neon-blue-glow);
  background: rgba(255, 255, 255, 0.08);
}

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

/* Dark dropdowns */
select.form-input {
  appearance: auto;
}

select.form-input option {
  background: #1a1f2e;
  color: var(--text-primary);
  padding: 0.5rem;
}

/* Presence dot */
.presence-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
  flex-shrink: 0;
}

.presence-dot.online {
  background: #22c55e;
  box-shadow: 0 0 6px #22c55e88;
}

.presence-dot.recent {
  background: #eab308;
  box-shadow: 0 0 6px #eab30888;
}

.presence-dot.offline {
  background: #6b7280;
}

/* ── Auth Page Layout ── */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
}

.auth-container {
  width: 100%;
  max-width: 420px;
}

.auth-logo {
  text-align: center;
  margin-bottom: 2rem;
}

.auth-logo h1 {
  font-size: 2.5rem;
  background: linear-gradient(135deg, var(--neon-blue), var(--neon-orange));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.25rem;
}

.auth-logo p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.auth-error {
  color: var(--neon-red);
  font-size: 0.9rem;
  min-height: 1.25rem;
  margin-bottom: 0.5rem;
  text-align: center;
}

.auth-success {
  color: var(--neon-green);
  font-size: 0.9rem;
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
  text-align: center;
  background: rgba(0, 255, 136, 0.1);
  border: 1px solid rgba(0, 255, 136, 0.3);
  border-radius: var(--radius-sm);
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1.5rem 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-glass);
}

.auth-toggle {
  text-align: center;
  margin-top: 1.5rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* ── Navigation Bar ── */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-glass);
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-brand {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--neon-blue), var(--neon-orange));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.navbar-links {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  list-style: none;
}

.navbar-links a {
  color: var(--text-secondary);
  font-weight: 500;
  padding: 0.5rem;
  transition: all 0.2s;
}

.navbar-links a:hover,
.navbar-links a.active {
  color: var(--neon-blue);
}

.navbar-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.navbar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--neon-blue), var(--neon-purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
}

.lang-switcher {
  display: flex;
  gap: 0.25rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.lang-switcher button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  transition: all 0.2s;
}

.lang-switcher button.active {
  background: var(--neon-blue);
  color: white;
}

/* ── Main Content ── */
.main-content {
  max-width: 1600px;
  margin: 0 auto;
  padding: 1.5rem;
  min-height: calc(100vh - 70px);
  display: flex;
  flex-direction: column;
}

/* ── Lobby Page ── */
.lobby-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-top: 1.5rem;
  flex: 1;
}



.lobby-section h3 {
  margin-bottom: 1rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  font-size: 1.1rem;
  letter-spacing: 0.02em;
}

.room-actions {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.room-code-input {
  display: flex;
  gap: 0.5rem;
}

.room-code-input .form-input {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-weight: 700;
  text-align: center;
}

.ai-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.5rem;
}

/* Room Settings Chips */
.room-settings {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.setting-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.setting-group label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.chip-row {
  display: flex;
  gap: 0.25rem;
}

.chip {
  padding: 0.25rem 0.55rem;
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.chip:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.chip.active {
  background: rgba(255, 215, 0, 0.15);
  border-color: rgba(255, 215, 0, 0.5);
  color: #ffd700;
  box-shadow: 0 0 8px rgba(255, 215, 0, 0.15);
}

.toggle-chip.on {
  background: rgba(76, 175, 80, 0.15);
  border-color: rgba(76, 175, 80, 0.5);
  color: #4caf50;
}

.room-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 400px;
  overflow-y: auto;
}

.room-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  transition: all 0.2s;
}

.room-item:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--neon-blue);
}

.room-item.room-playing {
  border-color: var(--neon-green);
  background: rgba(0, 255, 136, 0.05);
}

.room-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.room-badges {
  font-size: 0.65rem;
  color: var(--text-secondary);
  opacity: 0.7;
  letter-spacing: 0.03em;
}

/* Game Timer */
.player-timer {
  font-family: 'Outfit', monospace;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 0.5rem;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
  min-width: 3.5rem;
  text-align: center;
}

.player-timer.active {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.12);
}

.player-timer.urgent {
  color: #ff4444;
  animation: timerUrgent 1s ease-in-out infinite;
}

@keyframes timerUrgent {

  0%,
  100% {
    background: rgba(255, 68, 68, 0.08);
  }

  50% {
    background: rgba(255, 68, 68, 0.2);
  }
}

.room-code-display {
  font-family: 'Outfit', monospace;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--neon-blue);
}

.spinner-sm {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--neon-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

.room-status {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.room-status.waiting {
  color: var(--neon-green);
}

.room-code-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: rgba(0, 212, 255, 0.1);
  border: 1px solid var(--neon-blue);
  border-radius: var(--radius-sm);
  font-family: 'Outfit', monospace;
  font-weight: 700;
  font-size: 1.3rem;
  letter-spacing: 0.15em;
  color: var(--neon-blue);
  cursor: pointer;
  transition: all 0.2s;
}

.room-code-badge:hover {
  background: rgba(0, 212, 255, 0.2);
}

.empty-state {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
}

/* ── Game Board ── */
.game-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 1.5rem;
  margin: 0 auto;
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.player-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.player-stone {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.player-stone.blue {
  background: radial-gradient(circle at 35% 35%, #66e0ff, var(--neon-blue), #005577);
  box-shadow: 0 0 12px var(--neon-blue-glow);
}

.player-stone.orange {
  background: radial-gradient(circle at 35% 35%, #ffaa77, var(--neon-orange), #993300);
  box-shadow: 0 0 12px var(--neon-orange-glow);
}

.turn-indicator {
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.95rem;
  text-align: center;
  animation: turnPulse 2s ease-in-out infinite;
}

.turn-indicator.your-turn {
  background: rgba(0, 212, 255, 0.15);
  color: var(--neon-blue);
  border: 1px solid var(--neon-blue);
}

.turn-indicator.opponent-turn {
  background: rgba(255, 107, 53, 0.15);
  color: var(--neon-orange);
  border: 1px solid var(--neon-orange);
  animation: none;
}

@keyframes turnPulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.7;
  }
}

.board-container {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  min-height: min(70vh, 700px);
  margin: 0 auto;
}

.board {
  display: grid;
  grid-template-columns: repeat(var(--board-size, 15), 1fr);
  grid-template-rows: repeat(var(--board-size, 15), 1fr);
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #1a1a3a, #0f0f2a);
  border: 2px solid var(--border-glass);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-card), inset 0 0 60px rgba(0, 0, 0, 0.3);
}

.cell {
  border: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}

.cell:hover {
  background: rgba(255, 255, 255, 0.08);
}

.cell.disabled {
  cursor: not-allowed;
}

.cell.last-move {
  box-shadow: inset 0 0 14px rgba(255, 215, 0, 0.45), 0 0 6px rgba(255, 215, 0, 0.2);
  animation: lastMovePulse 2s ease-in-out infinite;
}

@keyframes lastMovePulse {

  0%,
  100% {
    box-shadow: inset 0 0 14px rgba(255, 215, 0, 0.45), 0 0 6px rgba(255, 215, 0, 0.2);
  }

  50% {
    box-shadow: inset 0 0 22px rgba(255, 215, 0, 0.7), 0 0 12px rgba(255, 215, 0, 0.35);
  }
}

.cell .stone {
  width: 80%;
  height: 80%;
  border-radius: 50%;
  animation: stoneDrop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.cell .stone.blue {
  background: radial-gradient(circle at 35% 35%, #66e0ff, var(--neon-blue), #005577);
  box-shadow: 0 0 10px var(--neon-blue-glow), inset 0 -2px 4px rgba(0, 0, 0, 0.3);
}

/* Player 2 = X shape */
.cell .stone.orange {
  background: none !important;
  box-shadow: none !important;
  border-radius: 0;
  position: relative;
}

.cell .stone.orange::before,
.cell .stone.orange::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 90%;
  height: 18%;
  background: linear-gradient(90deg, #ff9955, var(--neon-orange), #ff6622);
  box-shadow: 0 0 8px var(--neon-orange-glow);
  border-radius: 3px;
  transform-origin: center;
}

.cell .stone.orange::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.cell .stone.orange::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.cell .stone.winning {
  animation: winGlow 0.8s ease-in-out infinite alternate;
}

@keyframes stoneDrop {
  0% {
    transform: scale(0);
    opacity: 0;
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes winGlow {
  0% {
    box-shadow: 0 0 10px var(--neon-blue-glow);
    transform: scale(1);
  }

  100% {
    box-shadow: 0 0 25px var(--neon-blue-glow), 0 0 50px var(--neon-blue-glow);
    transform: scale(1.1);
  }
}

/* ── Game End Overlay ── */
.game-end-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  border-radius: var(--radius-md);
  animation: fadeIn 0.3s ease;
}

.game-end-card {
  text-align: center;
  padding: 3rem;
  max-width: 400px;
}

.game-end-card h2 {
  font-size: 2rem;
  margin-bottom: 1rem;
}

.game-end-card .elo-change {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 1rem 0;
}

.elo-change.positive {
  color: var(--neon-green);
}

.elo-change.negative {
  color: var(--neon-red);
}

.game-end-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 1.5rem;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

/* ── Session Stats Panel ── */
.session-stats-panel {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.65rem 0.85rem;
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  text-align: left;
  margin-top: 0.5rem;
}

.session-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
}

.session-row .stat-win {
  color: #4ade80;
}

.session-row .stat-loss {
  color: #f87171;
}

.session-row .stat-draw {
  color: #facc15;
}

.session-trend {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.trend-dot {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 3px;
  transition: transform 0.15s;
}

.trend-dot:hover {
  transform: scale(1.3);
}

.trend-dot.trend-win {
  background: #4ade80;
}

.trend-dot.trend-loss {
  background: #f87171;
}

.trend-dot.trend-draw {
  background: #facc15;
}

.session-streak {
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.25rem 0.5rem;
  background: rgba(255, 180, 0, 0.12);
  border-radius: var(--radius-sm);
  text-align: center;
  animation: streakPulse 1.5s ease-in-out infinite;
}

@keyframes streakPulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.7;
  }
}

/* ── Chat Panel ── */
.chat-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 400px;
  max-height: calc(100vh - 120px);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 0;
}

.chat-message {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 0.4rem;
  margin-bottom: 0.25rem;
}

.chat-message-content {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  max-width: 85%;
}

.chat-message .chat-user {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--neon-blue);
  margin-left: 0.25rem;
}

.chat-message .chat-text {
  font-size: 0.85rem;
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.08);
  padding: 0.45rem 0.65rem;
  border-radius: 1rem 1rem 1rem 0;
  animation: msgSlide 0.2s ease;
  word-break: break-word;
}

.chat-message .msg-avatar,
.chat-message .msg-avatar-placeholder {
  width: 24px;
  height: 24px;
  min-width: 24px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.chat-message .msg-avatar-placeholder {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
}

.chat-message.own {
  flex-direction: row-reverse;
}

.chat-message.own .chat-user {
  color: var(--neon-orange);
  text-align: right;
  margin-right: 0.25rem;
  margin-left: 0;
}

.chat-message.own .chat-message-content {
  align-items: flex-end;
}

.chat-message.own .chat-text {
  background: rgba(255, 107, 53, 0.15);
  border-radius: 1rem 1rem 0 1rem;
}

@keyframes msgSlide {
  from {
    opacity: 0;
    transform: translateY(5px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chat-input-area {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.5rem 0.75rem 0.75rem;
  border-top: 1px solid var(--border-glass);
  margin-top: auto;
}

.chat-input-area .form-input {
  flex: 1;
  padding: 0.5rem 0.65rem;
  font-size: 0.85rem;
  resize: none;
  min-height: 52px;
  max-height: 80px;
  line-height: 1.35;
}

.chat-input-area .chat-send-row {
  display: flex;
  justify-content: flex-end;
}

.chat-input-area .btn {
  padding: 0.3rem 0.75rem;
  font-size: 0.78rem;
}

/* ── Leaderboard ── */
.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}

.leaderboard-table th {
  padding: 0.5rem 0.5rem;
  text-align: left;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-glass);
  white-space: nowrap;
}

.leaderboard-table td {
  padding: 0.5rem 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  transition: background 0.2s;
  font-size: 0.85rem;
  white-space: nowrap;
}

.leaderboard-table tr:hover td {
  background: rgba(255, 255, 255, 0.03);
}

.leaderboard-table tr.self td {
  background: rgba(0, 212, 255, 0.08);
  border-color: rgba(0, 212, 255, 0.1);
}

.rank-medal {
  font-size: 1.2rem;
}

.elo-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.6rem;
  background: rgba(0, 212, 255, 0.1);
  border: 1px solid rgba(0, 212, 255, 0.2);
  border-radius: var(--radius-sm);
  font-weight: 700;
  color: var(--neon-blue);
  font-size: 0.9rem;
}

/* ── Personal Stats Card ── */
.your-rank-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--neon-blue), var(--neon-purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  color: #fff;
  overflow: hidden;
  flex-shrink: 0;
}

.your-rank-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.your-stats-row {
  display: flex;
  justify-content: space-around;
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  gap: 0.5rem;
  flex-wrap: wrap;
}

.your-stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}

.your-stat-value {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
}

.your-stat-label {
  font-size: 0.72rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* ── Mini Donut Chart ── */
.your-stat-chart-wrap {
  align-items: center;
}

.mini-donut {
  width: 48px;
  height: 48px;
}

.donut-segment {
  animation: donutAppear 0.8s ease-out forwards;
}

@keyframes donutAppear {
  from {
    stroke-dasharray: 0 200;
  }
}

/* ── Avatar Dropzone ── */
.avatar-dropzone {
  border: 2px dashed rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  position: relative;
  text-align: center;
}

.avatar-dropzone:hover,
.avatar-dropzone.dragover {
  border-color: var(--neon-blue);
  background: rgba(0, 212, 255, 0.05);
}

.avatar-dropzone-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  pointer-events: none;
}

.avatar-preview {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  margin: 0 auto 0.75rem;
  overflow: hidden;
  display: none;
}

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

/* ── Room Live Badge ── */
.room-live-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.2);
  border-radius: var(--radius-sm);
  animation: livePulse 2s ease-in-out infinite;
}

@keyframes livePulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.6;
  }
}

/* ── Game Overlay Modals ── */
.game-overlay-modal {
  position: fixed;
  inset: 0;
  z-index: 250;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  animation: modalFadeIn 0.25s ease;
}

.game-overlay-modal.hidden {
  display: none;
}

.game-overlay-content {
  max-width: 400px;
  width: 90%;
  padding: 2rem;
  text-align: center;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ── Toast Notifications ── */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  padding: 0.75rem 1.25rem;
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.9rem;
  animation: toastIn 0.3s ease;
  box-shadow: var(--shadow-card);
}

.toast.success {
  border-color: var(--neon-green);
}

.toast.error {
  border-color: var(--neon-red);
}

.toast.info {
  border-color: var(--neon-blue);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(50px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ── Spinner ── */
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-glass);
  border-top-color: var(--neon-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 2rem auto;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ── Utilities ── */
.text-center {
  text-align: center;
}

.text-muted {
  color: var(--text-secondary);
}

.mt-1 {
  margin-top: 0.5rem;
}

.mt-2 {
  margin-top: 1rem;
}

.mt-3 {
  margin-top: 1.5rem;
}

.mb-1 {
  margin-bottom: 0.5rem;
}

.mb-2 {
  margin-bottom: 1rem;
}

.gap-1 {
  gap: 0.5rem;
}

.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.hidden {
  display: none !important;
}

/* ── Responsive ── */
/* Old responsive rules consolidated into new @media block below */

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

  .board-container {
    max-width: 100%;
  }

  .game-end-card {
    padding: 2rem;
  }
}

/* ── Hamburger Menu ── */
.hamburger-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem;
  z-index: 101;
}

@media (max-width: 768px) {
  .hamburger-btn {
    display: block;
  }

  .lobby-grid {
    grid-template-columns: 1fr;
  }

  /* Room list first on mobile */
  .lobby-grid>.lobby-section:last-child {
    order: -1;
  }

  .navbar {
    padding: 0.75rem 1rem;
    height: 65px;
    z-index: 1002;
  }

  .navbar-brand {
    font-size: 1.25rem;
  }

  .navbar-links {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 65px;
    left: 0;
    width: 100%;
    height: calc(100vh - 65px);
    background: rgba(10, 10, 26, 0.95);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    align-items: center;
    justify-content: flex-start;
    padding-top: 2.5rem;
    gap: 1.5rem;
    z-index: 1001;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    transform: translateY(-150%);
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.25, 1, 0.5, 1);
    margin: 0;
    overflow-y: auto;
    padding-bottom: 2rem;
  }

  .navbar-links.open {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
  }

  .navbar-links li {
    width: 100%;
    text-align: center;
    transform: translateY(-10px);
    opacity: 0;
    transition: transform 0.4s ease, opacity 0.4s ease;
  }

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

  .navbar-links.open li:nth-child(1) {
    transition-delay: 0.1s;
  }

  .navbar-links.open li:nth-child(2) {
    transition-delay: 0.15s;
  }

  .navbar-links.open li:nth-child(3) {
    transition-delay: 0.2s;
  }

  .navbar-links.open li:nth-child(4) {
    transition-delay: 0.25s;
  }

  .navbar-links.open li:nth-child(5) {
    transition-delay: 0.3s;
  }

  .navbar-links a {
    display: inline-block;
    padding: 0.5rem 1.5rem;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--text-primary);
    background: none;
    -webkit-text-fill-color: initial;
    transition: all 0.2s;
  }

  .navbar-links a:active {
    transform: scale(0.95);
  }

  .navbar-links a.active {
    color: var(--neon-blue);
    text-shadow: 0 0 15px var(--neon-blue-glow);
  }

  .navbar-user {
    width: 90%;
    max-width: 300px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1rem;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0 auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  }

  /* Reorder menu items: Lang & Profile top, links below */
  .navbar-links li:nth-child(3) {
    order: 1;
  }

  /* Lang switcher */
  .navbar-links li:nth-child(4) {
    order: 2;
    margin-bottom: 1.5rem;
  }

  /* Profile */
  .navbar-links li:nth-child(1) {
    order: 3;
  }

  /* Lobby */
  .navbar-links li:nth-child(2) {
    order: 4;
  }

  /* Leaderboard */
  .navbar-links li:nth-child(5) {
    order: 5;
    margin-top: auto;
  }

  /* Changelog */
  .navbar-links li:nth-child(6) {
    order: 6;
    margin-bottom: 2rem;
  }

  /* Logout */

  /* Game layout: stack vertically */
  .game-layout {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  /* Game header: compact */
  .game-header {
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.5rem;
  }

  .player-info {
    gap: 0.35rem;
    font-size: 0.8rem;
  }

  .player-info span:not(.elo-badge) {
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .elo-badge {
    font-size: 0.75rem;
    padding: 0.15rem 0.4rem;
  }

  .turn-indicator {
    font-size: 0.8rem;
    padding: 0.35rem 0.65rem;
    order: -1;
    width: 100%;
    text-align: center;
  }

  .room-setting i {
    color: var(--neon-blue);
    width: 20px;
    text-align: center;
  }

  /* Give the Spectator row a bit more visual separation */
  .room-setting:last-child {
    margin-top: 5px;
  }

  .player-stone {
    width: 18px;
    height: 18px;
  }

  /* Chat panel mobile */
  .chat-panel {
    min-height: 200px;
    max-height: 250px;
  }

  .chat-panel h3 {
    font-size: 0.95rem;
    padding: 0.5rem 0.75rem;
  }

  /* Buttons row */
  .flex.justify-between.mt-2 {
    gap: 0.5rem;
  }

  .flex.justify-between.mt-2 .btn {
    font-size: 0.75rem;
    padding: 0.3rem 0.6rem;
  }

  h1 {
    font-size: 1.75rem;
  }

  h2 {
    font-size: 1.35rem;
  }

  .glass-card {
    padding: 1rem;
  }

  .auth-logo h1 {
    font-size: 2rem;
  }

  /* ── Leaderboard Mobile Redesign ── */

  /* Hide less important columns on mobile */
  .mobile-hide {
    display: none !important;
  }

  .leaderboard-table {
    table-layout: fixed;
    width: 100%;
  }

  .leaderboard-table th,
  .leaderboard-table td {
    padding: 0.4rem 0.25rem;
    font-size: 0.75rem;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Column widths for mobile: #, Player, 🌍, Score, Games, Wins */
  .leaderboard-table th:nth-child(1),
  .leaderboard-table td:nth-child(1) {
    width: 28px;
    text-align: center;
  }

  .leaderboard-table th:nth-child(3),
  .leaderboard-table td:nth-child(3) {
    width: 28px;
    text-align: center;
  }

  .leaderboard-table .elo-badge {
    font-size: 0.7rem;
    padding: 0.1rem 0.35rem;
  }

  .rank-medal {
    font-size: 0.95rem;
  }

  /* Personal stats card: 3x2 grid */
  .your-stats-row {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.65rem 0.35rem;
    justify-items: center;
  }

  .your-stat-value {
    font-size: 1rem;
  }

  .your-stat-label {
    font-size: 0.65rem;
  }

  .mini-donut {
    width: 40px;
    height: 40px;
  }

  /* Prevent your-rank-card from overflowing */
  #your-rank-card .flex {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  #your-rank-card .elo-badge {
    font-size: 0.8rem;
  }

  #your-rank-number {
    font-size: 1.3rem !important;
  }

  /* Glass card overflow protection */
  .glass-card {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Country filter compact */
  #country-filter {
    min-width: 120px !important;
    font-size: 0.85rem;
  }

  .main-content {
    padding: 1rem 0.75rem;
  }

  /* Modals */
  .game-overlay-content {
    width: 95vw !important;
    max-width: 95vw !important;
    max-height: 85vh !important;
  }

  .modal-card {
    min-width: 280px;
    width: 95%;
    padding: 1.25rem;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── SVG Win-line animation ── */
@keyframes drawLine {
  to {
    stroke-dashoffset: 0;
  }
}

/* ── Game End Overlay slide-in ── */
.game-end-animate .game-end-card {
  animation: slideUp 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes slideUp {
  from {
    transform: translateY(40px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ── Game End Title variants ── */
.game-end-title.win {
  color: var(--neon-green);
  text-shadow: 0 0 20px rgba(0, 255, 136, 0.6);
}

.game-end-title.lose {
  color: var(--neon-red);
  text-shadow: 0 0 20px rgba(255, 60, 60, 0.6);
}

.game-end-title.draw {
  color: var(--neon-blue);
  text-shadow: 0 0 20px var(--neon-blue-glow);
}

/* ── Create Room Options (two buttons) ── */
.create-room-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* ── Settings / Generic Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-overlay.hidden {
  display: none;
}

.modal-card {
  padding: 2rem;
  min-width: 320px;
  max-width: 420px;
  width: 90%;
  text-align: center;
  animation: slideUp 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-card h3 {
  font-size: 1.3rem;
  margin-bottom: 1rem;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin-top: 1.25rem;
}

/* ── Modal Avatar ── */
.modal-avatar-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 0.75rem;
}

.modal-avatar-circle {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--neon-blue), var(--neon-purple));
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 3px solid rgba(255, 255, 255, 0.15);
}

/* ── Avatar Dropzone ── */
.avatar-dropzone {
  border: 2px dashed rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-md);
  padding: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.avatar-dropzone:hover,
.avatar-dropzone.dragover {
  border-color: var(--neon-blue);
  background: rgba(0, 208, 255, 0.06);
}

.avatar-dropzone-label {
  font-size: 0.82rem;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.4;
}

.avatar-preview {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  overflow: hidden;
  display: none;
  margin: 0 auto;
}

/* ── Player X header icon (game header) ── */
.player-stone-x {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--neon-orange);
  text-shadow: 0 0 10px var(--neon-orange-glow);
  flex-shrink: 0;
}

/* ── Player Link (leaderboard clickable name) ── */
.player-link {
  color: var(--text-primary);
  text-decoration: none;
  cursor: pointer;
  transition: color 0.2s, text-shadow 0.2s;
}

.player-link:hover {
  color: var(--neon-blue);
  text-shadow: 0 0 8px var(--neon-blue-glow);
  text-decoration: underline;
}

/* Level System */
.level-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.1rem 0.5rem 0.1rem 0.25rem;
  border-radius: 1rem;
  background: linear-gradient(135deg, rgba(147, 51, 234, 0.2), rgba(79, 70, 229, 0.2));
  border: 1px solid rgba(147, 51, 234, 0.3);
  font-size: 0.7rem;
  line-height: 1;
  white-space: nowrap;
}

.level-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.2rem;
  height: 1.2rem;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffd700, #f59e0b);
  color: #1a1a2e;
  font-weight: 800;
  font-size: 0.6rem;
}

.level-name {
  color: #c4b5fd;
  font-weight: 600;
}

.level-progress {
  position: relative;
  height: 0.4rem;
  border-radius: 0.2rem;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
  margin-top: 0.25rem;
}

.level-progress-fill {
  height: 100%;
  border-radius: 0.2rem;
  background: linear-gradient(90deg, #9333ea, #6366f1, #818cf8);
  transition: width 0.5s ease;
}

.level-progress-text {
  position: absolute;
  top: -1rem;
  right: 0;
  font-size: 0.55rem;
  color: var(--text-secondary);
}

/* Spectator banner */
.spectator-banner {
  text-align: center;
  padding: 0.5rem 1rem;
  background: linear-gradient(135deg, rgba(147, 51, 234, 0.2), rgba(79, 70, 229, 0.2));
  border: 1px solid rgba(147, 51, 234, 0.4);
  border-radius: 0.5rem;
  color: #c4b5fd;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  animation: pulse-soft 2s ease-in-out infinite;
}

@keyframes pulse-soft {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.7;
  }
}

/* Move reminder pulse */
.move-reminder {
  animation: move-pulse 1s ease-in-out infinite;
  box-shadow: 0 0 20px rgba(255, 200, 0, 0.4);
}

@keyframes move-pulse {

  0%,
  100% {
    box-shadow: 0 0 10px rgba(255, 200, 0, 0.2);
  }

  50% {
    box-shadow: 0 0 30px rgba(255, 200, 0, 0.6);
  }
}

/* Online count badge */
.online-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  border-radius: 1rem;
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: #22c55e;
  font-size: 0.8rem;
  font-weight: 600;
}

.online-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
  animation: blink 2s infinite;
}

@keyframes blink {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.3;
  }
}

/* Lobby chat */
.lobby-chat {
  margin-top: 1rem;
  border-radius: 0.75rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.lobby-chat-header {
  padding: 0.5rem 1rem;
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.lobby-chat-messages {
  padding: 0.5rem 1rem;
  max-height: 200px;
  overflow-y: auto;
  font-size: 0.85rem;
}

.lobby-chat-messages .msg {
  margin-bottom: 0.4rem;
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
}

.lobby-chat-messages .msg-avatar {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.lobby-chat-messages .msg-avatar-placeholder {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--neon-blue), var(--neon-purple));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.lobby-chat-messages .msg-time {
  color: var(--text-muted);
  font-size: 0.7rem;
  opacity: 0.6;
}

.lobby-chat-messages .msg-user {
  color: var(--neon-purple);
  font-weight: 600;
}

.lobby-chat-input {
  display: flex;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.lobby-chat-input input {
  flex: 1;
  background: transparent;
  border: none;
  padding: 0.5rem 1rem;
  color: var(--text-primary);
  font-size: 0.85rem;
  outline: none;
}

.lobby-chat-input button {
  padding: 0.5rem 1rem;
  background: rgba(147, 51, 234, 0.15);
  border: none;
  color: #a78bfa;
  cursor: pointer;
  font-weight: 600;
}

/* Changelog modal */
.changelog-item {
  margin-bottom: 0.75rem;
}

.changelog-tag {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  border-radius: 0.25rem;
  font-size: 0.7rem;
  font-weight: 700;
  margin-right: 0.3rem;
  text-transform: uppercase;
}

.changelog-tag.new {
  background: rgba(34, 197, 94, 0.2);
  color: #22c55e;
}

.changelog-tag.fix {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

.changelog-tag.mod {
  background: rgba(59, 130, 246, 0.2);
  color: #3b82f6;
}

/* Tournament tabs */
.tournament-tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1rem;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 0.5rem;
  padding: 0.25rem;
}

.tournament-tab {
  flex: 1;
  text-align: center;
  padding: 0.5rem;
  border-radius: 0.35rem;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: all 0.2s;
  border: none;
  background: transparent;
}

.tournament-tab:hover {
  color: var(--text-primary);
}

.tournament-tab.active {
  background: linear-gradient(135deg, rgba(147, 51, 234, 0.3), rgba(79, 70, 229, 0.3));
  color: #c4b5fd;
}

/* ── 3-Column Lobby Layout ── */
.lobby-grid-3col {
  display: grid;
  grid-template-columns: 470px 1fr 230px;
  gap: 0.85rem;
  align-items: start;
}

@media (max-width: 1050px) {
  .lobby-grid-3col {
    grid-template-columns: 1fr 1fr;
  }

  .member-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 720px) {
  .lobby-grid-3col {
    grid-template-columns: 1fr;
  }
}

/* ── AI Mode Picker ── */
.ai-main-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.2), rgba(147, 51, 234, 0.15));
  border: 1px solid rgba(147, 51, 234, 0.35);
  color: #c4b5fd;
  font-weight: 700;
  font-size: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
}

.ai-main-btn:hover {
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.35), rgba(147, 51, 234, 0.25));
  border-color: rgba(147, 51, 234, 0.6);
  transform: translateY(-1px);
}

.ai-picker {
  margin-top: 0.5rem;
  animation: slideDown 0.2s ease;
  overflow: hidden;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ai-picker-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.ai-btn {
  border-radius: 0.75rem !important;
  padding: 0.75rem 0.5rem !important;
  text-align: center;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1.6;
  transition: all 0.2s;
}

.ai-easy {
  background: rgba(34, 197, 94, 0.12) !important;
  border: 1px solid rgba(34, 197, 94, 0.3) !important;
  color: #4ade80 !important;
}

.ai-easy:hover {
  background: rgba(34, 197, 94, 0.22) !important;
  transform: translateY(-2px);
}

.ai-medium {
  background: rgba(234, 179, 8, 0.12) !important;
  border: 1px solid rgba(234, 179, 8, 0.3) !important;
  color: #fbbf24 !important;
}

.ai-medium:hover {
  background: rgba(234, 179, 8, 0.22) !important;
  transform: translateY(-2px);
}

.ai-hard {
  background: rgba(239, 68, 68, 0.12) !important;
  border: 1px solid rgba(239, 68, 68, 0.3) !important;
  color: #f87171 !important;
}

.ai-hard:hover {
  background: rgba(239, 68, 68, 0.22) !important;
  transform: translateY(-2px);
}

/* ── Discord-style Member Panel ── */
.member-panel {
  padding: 0.75rem;
  border-radius: 1rem;
  min-height: 300px;
}

.member-panel-header {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.member-section-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
  opacity: 0.6;
}

.member-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.4rem;
  border-radius: 0.5rem;
  margin-bottom: 0.2rem;
  cursor: default;
  transition: background 0.15s;
}

.member-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.member-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  position: relative;
}

.member-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.member-status-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 2px solid var(--bg-primary, #0f0e1a);
}

.member-status-dot.online {
  background: #22c55e;
}

.member-status-dot.idle {
  background: #f59e0b;
}

.member-status-dot.offline {
  background: #6b7280;
}

.member-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.member-item.is-offline .member-name {
  color: var(--text-secondary);
  opacity: 0.65;
}

.member-last-seen {
  font-size: 0.68rem;
  color: var(--text-secondary);
  opacity: 0.5;
  margin-left: auto;
  white-space: nowrap;
}

/* Clickable member names */
.member-item.clickable {
  cursor: pointer;
}

.member-item.clickable:hover {
  background: rgba(0, 212, 255, 0.08);
}

.member-item.clickable:hover .member-name {
  color: var(--neon-blue);
}

/* ── Profile Modal ── */
.profile-modal-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  position: relative;
}

.profile-modal-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--neon-blue), var(--neon-purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
}

.profile-modal-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.profile-modal-info {
  flex: 1;
}

.profile-modal-close {
  position: absolute;
  top: -0.5rem;
  right: -0.5rem;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.profile-modal-close:hover {
  background: rgba(255, 60, 60, 0.2);
  color: #ff6b6b;
}

.profile-modal-elo {
  display: flex;
  align-items: center;
  margin-bottom: 1rem;
}

.profile-modal-live {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  background: rgba(255, 100, 100, 0.1);
  border: 1px solid rgba(255, 100, 100, 0.25);
  border-radius: 0.5rem;
  margin-bottom: 1rem;
  font-size: 0.85rem;
}

.profile-modal-live .live-indicator {
  font-weight: 600;
  color: #ff6b6b;
  animation: livePulse 2s ease-in-out infinite;
}

.profile-modal-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 0.5rem;
}

.profile-stat {
  text-align: center;
}

.profile-stat-value {
  display: block;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
}

.profile-stat-label {
  font-size: 0.7rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.profile-modal-activity {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* Profile Modal Mobile */
@media (max-width: 768px) {
  #profile-modal .modal-card {
    width: 95%;
    max-width: 340px;
    padding: 1.25rem;
  }

  .profile-modal-avatar {
    width: 50px;
    height: 50px;
    font-size: 1.2rem;
  }

  .profile-modal-header h3 {
    font-size: 1rem;
  }

  .profile-modal-stats {
    padding: 0.5rem;
    gap: 0.25rem;
  }

  .profile-stat-value {
    font-size: 1rem;
  }

  .profile-stat-label {
    font-size: 0.65rem;
  }

  .profile-modal-live {
    flex-wrap: wrap;
    font-size: 0.8rem;
    padding: 0.5rem;
  }

  .profile-modal-live .btn {
    width: 100%;
    margin-top: 0.5rem;
    margin-left: 0;
  }
}

/* ── Admin Chat Moderation ── */
.msg {
  position: relative;
}

.msg-delete-btn {
  position: absolute;
  right: 0.25rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  font-size: 0.7rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
  padding: 0.15rem 0.3rem;
  border-radius: var(--radius-sm);
}

.msg:hover .msg-delete-btn {
  opacity: 0.6;
}

.msg-delete-btn:hover {
  opacity: 1 !important;
  background: rgba(239, 68, 68, 0.15);
}

.admin-badge {
  font-size: 0.65rem;
  margin-left: 0.15rem;
  vertical-align: middle;
}

/* ═══════════════════════════════════════
   MOBILE RESPONSIVE — Global
   ═══════════════════════════════════════ */

/* Hamburger button — always hidden on desktop */
.hamburger-btn {
  display: none;
  background: none;
  border: 1px solid var(--border-glass);
  color: var(--text-primary);
  font-size: 1.4rem;
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}

.hamburger-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--neon-blue);
}

@media (max-width: 768px) {

  /* ── Hamburger visible ── */
  .hamburger-btn {
    display: block;
  }

  /* ── Navbar collapse ── */
  .navbar {
    flex-wrap: wrap;
    padding: 0.75rem 1rem;
  }

  .navbar-links {
    display: none;
    flex-direction: column;
    width: 100%;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-glass);
    padding-bottom: 2rem;
  }

  .navbar-links.open {
    display: flex;
  }

  .navbar-links li {
    width: 100%;
  }

  .navbar-links a {
    display: block;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-sm);
  }

  .navbar-links a:hover,
  .navbar-links a.active {
    background: rgba(0, 212, 255, 0.08);
  }

  .navbar-user {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
  }

  .lang-switcher {
    justify-content: center;
    width: 100%;
  }

  /* ── Main content ── */
  .main-content {
    padding: 0.75rem;
  }

  .main-content h2 {
    font-size: 1.3rem;
    text-align: center;
  }

  /* ── Glass cards ── */
  .glass-card {
    padding: 1rem;
  }

  /* ── Game Layout — single column ── */
  .game-layout {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  /* Game header — wrap on mobile */
  .game-header {
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
  }

  .player-info {
    gap: 0.35rem;
    font-size: 0.8rem;
  }

  .player-info span {
    font-size: 0.75rem;
  }

  .turn-indicator {
    width: 100%;
    order: -1;
    font-size: 0.85rem;
    padding: 0.4rem 0.75rem;
  }

  .elo-badge {
    font-size: 0.65rem !important;
    padding: 0.15rem 0.35rem;
  }

  .player-timer {
    font-size: 0.75rem;
    padding: 0.15rem 0.35rem;
    min-width: 2.8rem;
  }

  /* Board — touch friendly */
  .board-container {
    width: 100%;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Chat panel — compact */
  .chat-panel {
    padding: 0.75rem;
  }

  .chat-panel h3 {
    font-size: 1rem;
  }

  .chat-messages {
    max-height: 150px;
  }

  /* Game end overlay — mobile friendly */
  .game-end-card {
    padding: 1rem !important;
    max-width: 95vw;
  }

  .game-end-title {
    font-size: 1.3rem !important;
  }

  .game-end-actions {
    flex-direction: column;
    gap: 0.5rem;
  }

  .game-end-actions .btn {
    width: 100%;
  }

  /* ── Lobby ── */
  .room-settings {
    flex-direction: column;
    gap: 0.5rem;
  }

  .setting-group {
    width: 100%;
    justify-content: space-between;
  }

  .room-list {
    max-height: 250px;
  }

  .room-item {
    padding: 0.75rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .room-actions h3 {
    font-size: 0.95rem;
  }

  /* Lobby chat — compact */
  .lobby-chat-messages {
    max-height: 120px;
  }

  /* ── Leaderboard table — horizontal scroll ── */
  .leaderboard-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .leaderboard-table {
    font-size: 0.75rem;
    min-width: 500px;
  }

  .leaderboard-table th,
  .leaderboard-table td {
    padding: 0.4rem 0.5rem;
  }

  /* Leaderboard search / filters */
  .leaderboard-header {
    flex-direction: column;
    gap: 0.5rem;
    align-items: stretch;
  }

  .tournament-tabs {
    flex-wrap: wrap;
    justify-content: center;
  }

  .tournament-tab {
    font-size: 0.7rem;
    padding: 0.3rem 0.5rem;
  }

  /* Your Rank section */
  .your-rank-card {
    padding: 0.75rem;
  }

  /* ── Modal cards ── */
  .modal-content,
  .modal-card {
    width: 95% !important;
    max-width: 95vw !important;
    padding: 1rem !important;
  }

  /* ── Member panel on mobile ── */
  .member-panel {
    min-height: unset;
    max-height: 250px;
    overflow-y: auto;
  }
}