:root {
  --bg-dark: #09090b;
  --bg-panel: #111114;
  --bg-hover: #1c1c21;
  --primary: #c39c5b;
  --accent: #769656;
  --text-main: #e4e4e7;
  --text-dim: #71717a;
  --border-glass: #27272a;
  --board-white: #ebecd0;
  --board-black: #779556;
  --font-family: 'Outfit', 'Inter', sans-serif;
  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-family);
  min-height: 100vh;
  display: flex;
  /* Allow vertical scroll on body if needed, but usually main-wrapper handles it */
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-glass); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* Sidebar */
.sidebar {
  width: 240px;
  background: #000;
  border-right: 1px solid var(--border-glass);
  display: flex;
  flex-direction: column;
  z-index: 100;
}

.logo-container {
  padding: 2rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.logo-icon { font-size: 1.8rem; color: var(--primary); }
.logo-text { font-size: 1.25rem; font-weight: 800; color: #fff; letter-spacing: -0.5px; }

.nav-menu { flex: 1; padding: 0 0.75rem; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  color: var(--text-dim);
  text-decoration: none;
  border-radius: 8px;
  margin-bottom: 4px;
  font-weight: 500;
  transition: all 0.2s;
}

.nav-link:hover { color: #fff; background: var(--bg-hover); }
.nav-link.active { color: #fff; background: var(--bg-hover); box-shadow: inset 3px 0 0 var(--primary); }

/* Main Content */
.main-wrapper { 
  flex: 1; 
  display: flex; 
  flex-direction: column; 
  overflow-y: overlay; /* Use overlay for cleaner scrollbars */
  height: 100vh;
  -webkit-overflow-scrolling: touch;
}

header {
  height: 64px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 2rem;
  border-bottom: 1px solid var(--border-glass);
  background: #000;
}

.page-title { font-size: 0.8rem; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; }

.user-profile { display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 5px 12px; border-radius: 20px; transition: background 0.2s; }
.user-profile:hover { background: var(--bg-hover); }
.avatar { 
  width: 28px; 
  height: 28px; 
  background: var(--primary); 
  border-radius: 50%; 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  color: #000; 
  font-weight: 800; 
  font-size: 0.75rem; 
  background-size: cover;
  background-position: center;
}

/* Dashboard */
.dashboard-container {
  padding: 2rem;
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 2rem;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

.glass-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-glass);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transition: var(--transition-fast);
}

.stat-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border-glass);
  padding: 1.5rem;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.stat-label { font-size: 0.75rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; font-weight: 600; }
.stat-value { font-size: 2rem; font-weight: 800; color: var(--text-main); font-family: 'JetBrains Mono', monospace; }

.mobile-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 70px;
  background: rgba(9, 9, 11, 0.95);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border-glass);
  display: none;
  justify-content: space-around;
  align-items: center;
  z-index: 1000;
  padding: 0 1rem;
}

.mobile-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.7rem;
  font-weight: 600;
  transition: var(--transition-fast);
  padding: 8px 12px;
  border-radius: 12px;
}

.mobile-link i { font-size: 1.4rem; font-style: normal; }
.mobile-link.active { color: var(--primary); background: rgba(195, 156, 91, 0.1); }

.pairing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 1rem;
  padding: 2rem;
}

.card-btn {
  aspect-ratio: 1;
  background: #18181b;
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.card-btn:hover { border-color: var(--primary); background: #27272a; transform: translateY(-2px); }
.card-btn .time { font-size: 1.5rem; font-weight: 800; color: var(--text-main); }
.card-btn .mode { font-size: 0.7rem; color: var(--text-dim); text-transform: uppercase; font-weight: 600; }

/* Game View */
.game-container {
  display: none;
  padding: 1.5vh 2rem;
  gap: 2rem;
  justify-content: center;
  align-items: center;
  height: 100vh;
  max-height: 100vh;
  box-sizing: border-box;
  overflow: hidden;
}
.board-container { width: min(75vh, 650px); aspect-ratio: 1; border: 4px solid #27272a; border-radius: 4px; overflow: hidden; }
.chess-board { display: grid; grid-template-columns: repeat(8, 1fr); width: 100%; height: 100%; }
.square { display: flex; align-items: center; justify-content: center; position: relative; }
.square.light { background: var(--board-white); }
.square.dark { background: var(--board-black); }
.square.last-move { background: rgba(252, 211, 77, 0.4) !important; }
.square.selected { background: rgba(34, 197, 94, 0.4) !important; }
.square.can-move::after, .square.can-premove::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 15;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.square.can-move::after { background: rgba(0, 0, 0, 0.15); }
.square.can-premove::after { background: rgba(244, 67, 54, 0.4); }

.square.can-capture, .square.can-premove-capture { 
  box-shadow: inset 0 0 0 4px rgba(0,0,0,0.15); 
}
.square.can-premove-capture {
  box-shadow: inset 0 0 0 4px rgba(244, 67, 54, 0.4);
}
.square.premove { background: rgba(255, 0, 0, 0.4) !important; box-shadow: inset 0 0 0 3px #ff0000; }
.piece-img { 
  width: 95%; 
  height: 95%; 
  background-size: contain; 
  background-repeat: no-repeat; 
  background-position: center; 
  z-index: 10; 
  cursor: grab;
  will-change: transform, opacity;
}
.piece-img:active { cursor: grabbing; }

.coord-rank, .coord-file {
  position: absolute;
  font-size: 0.65rem;
  font-weight: 700;
  pointer-events: none;
  user-select: none;
  opacity: 0.5;
}

.coord-rank { top: 2px; left: 2px; }
.coord-file { bottom: 2px; right: 2px; }

.light .coord-rank, .light .coord-file { color: var(--board-black); }
.dark .coord-rank, .dark .coord-file { color: var(--board-white); }

.clock-display {
  background: #18181b;
  color: #fff;
  padding: 0.6rem 1rem;
  border-radius: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.8rem;
  font-weight: 700;
  min-width: 130px;
  text-align: center;
  border: 1px solid var(--border-glass);
}

.clock-display.active { background: #fff; color: #000; }

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  overflow-y: auto;
  padding: 2rem 1rem;
}
.modal-backdrop.active { display: flex; }
@media (max-height: 850px) {
  .modal-backdrop {
    align-items: flex-start;
  }
}
.modal-content { background: #18181b; padding: 2rem; border-radius: 12px; width: 400px; border: 1px solid var(--border-glass); }

.game-sidebar {
  width: 380px;
  height: min(80vh, 790px);
  max-height: 100%;
}

.btn-premium { background: var(--primary); color: #000; border: none; padding: 10px 16px; border-radius: 6px; font-weight: 700; cursor: pointer; width: 100%; }
.btn-secondary { background: transparent; color: #fff; border: 1px solid var(--border-glass); padding: 10px 16px; border-radius: 6px; cursor: pointer; transition: all 0.2s; }
.btn-secondary:focus { border-color: var(--primary); outline: none; background: rgba(255,255,255,0.08); }

/* Theme Buttons */
.theme-btn {
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--border-glass);
  background: rgba(255,255,255,0.05);
  color: #fff;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
}
.theme-btn:hover { background: rgba(255,255,255,0.1); border-color: var(--primary); }

.theme-btn.classic { border-left: 10px solid #779556; }
.theme-btn.blue { border-left: 10px solid #8ca2ad; }
.theme-btn.wood { border-left: 10px solid #8b5a2b; }
.theme-btn.purple { border-left: 10px solid #884d88; }
.theme-btn.grey { border-left: 10px solid #808080; }
.theme-btn.ocean { border-left: 10px solid #2e5a88; }

/* Switch Toggle */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; inset: 0; background-color: #333; transition: .4s; border-radius: 24px; }
.slider:before { position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider { background-color: var(--primary); }
input:checked + .slider:before { transform: translateX(20px); }

/* Theme Previews */
.theme-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
}
.theme-preview:hover {
  background: rgba(255,255,255,0.08);
  border-color: var(--primary);
  transform: translateY(-2px);
}
.theme-preview span { font-size: 0.8rem; font-weight: 600; color: var(--text-dim); }
.theme-preview:hover span { color: #fff; }

.card-btn {
  background: var(--bg-panel);
  border: 1px solid var(--border-glass);
  padding: 1.5rem;
  border-radius: 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  justify-content: center;
}
.card-btn:hover { border-color: var(--primary); transform: translateY(-3px); background: rgba(195,156,91,0.05); }

.board-mini {
  width: 60px;
  height: 60px;
  border-radius: 4px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  overflow: hidden;
  border: 2px solid var(--primary);
}
.board-mini::before, .board-mini::after { content: ''; }
.board-mini.classic { background: linear-gradient(45deg, #779556 50%, #ebecd0 50%); }
.board-mini.blue { background: linear-gradient(45deg, #8ca2ad 50%, #dee3e6 50%); }
.board-mini.wood { background: linear-gradient(45deg, #8b5a2b 50%, #e9c08a 50%); }
.board-mini.purple { background: linear-gradient(45deg, #884d88 50%, #efefef 50%); }
.board-mini.grey { background: linear-gradient(45deg, #808080 50%, #e2e2e2 50%); }
.board-mini.ocean { background: linear-gradient(45deg, #2e5a88 50%, #d1e1f1 50%); }

/* Replay Controls */
.replay-controls {
  display: flex;
  justify-content: center;
  align-items: stretch;
  gap: 8px;
  margin-top: 1.5rem;
  background: rgba(0,0,0,0.3);
  padding: 8px;
  border-radius: 12px;
  border: 1px solid var(--border-glass);
}

.ctrl-btn {
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 1.2rem;
  padding: 10px 15px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 50px;
}

.ctrl-btn:hover {
  background: rgba(255,255,255,0.1);
  color: var(--primary);
}

.ctrl-btn:active {
  transform: scale(0.95);
}

.ctrl-btn.btn-play {
  color: var(--accent);
  background: rgba(var(--accent-rgb), 0.1);
}

.ctrl-btn.btn-play:hover {
  background: rgba(var(--accent-rgb), 0.2);
}

.replay-move-item {
  padding: 8px 12px;
  cursor: pointer;
  border-radius: 4px;
  font-weight: 500;
  color: #ccc;
  transition: all 0.15s;
}

.replay-move-item:hover {
  background: rgba(255,255,255,0.05);
  color: #fff;
}

.replay-move-item.active {
  background: var(--primary);
  color: #000;
  font-weight: 800;
}

/* Toggles */
.toggle-container {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  padding: 8px 0;
}

.toggle-container input {
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: var(--primary);
}

.toggle-label {
  color: var(--text-main);
  font-size: 0.9rem;
}

/* Setup View Styles */
.setup-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.setup-group label {
  font-size: 0.85rem;
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.setup-input {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass);
  border-radius: 8px;
  padding: 12px 16px;
  color: var(--text-main);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

.setup-input:focus {
  border-color: var(--primary);
}

select.setup-input option {
  background: #18181b;
  color: #fff;
}

@keyframes pulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(195, 156, 91, 0.4); }
  70% { transform: scale(1.05); box-shadow: 0 0 0 10px rgba(195, 156, 91, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(195, 156, 91, 0); }
}

.pulse-animation {
  animation: pulse 2s infinite;
  background: var(--primary) !important;
  color: #000 !important;
}

@media (max-width: 1000px) {
  .sidebar { display: none; }
  .mobile-nav { display: flex; }
  
  /* Profile Page Mobile Optimizations */
  #profile-view .glass-panel > div:first-child {
    flex-direction: column !important;
    align-items: center !important;
    text-align: center !important;
    gap: 1.5rem !important;
  }
  
  #profile-view .glass-panel > div:first-child > div:last-of-type {
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  
  #profile-view .btn-secondary[onclick^="openProfileEditModal"] {
    position: static !important;
    margin: 1rem auto 0 auto !important;
    width: 100% !important;
    display: block;
    text-align: center;
  }

  .main-wrapper { 
    padding-bottom: 80px; 
    height: auto;
    overflow-y: auto;
  }
  body { overflow-y: auto; }
  header { padding: 0 1rem; height: 56px; }
  .page-title { font-size: 0.7rem; }
  
  .dashboard-container { 
    grid-template-columns: 1fr; 
    padding: 1rem; 
    gap: 1.5rem;
  }
  
  .tournament-detail-container {
    grid-template-columns: 1fr !important;
  }

  .game-container { 
    flex-direction: column; 
    padding: 1rem 0 3rem 0 !important; 
    align-items: center; 
    gap: 1rem;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    justify-content: flex-start !important;
  }
  
  #game-view > div:first-child,
  #puzzle-solve-view > div:first-child,
  #replay-view > div:first-child {
    width: 100% !important;
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  
  .game-sidebar { 
    width: 100% !important; 
    height: auto !important;
    min-height: 300px;
    padding: 0 16px !important;
    box-sizing: border-box;
  }
  
  .board-container { 
    width: 100% !important; 
    max-width: 100vw !important;
    aspect-ratio: 1 !important;
    border-left: none !important;
    border-right: none !important;
    border-radius: 0 !important;
    border-width: 2px 0 !important;
  }

  #game-view > div:first-child > div:first-child,
  #game-view > div:first-child > div:nth-child(3) {
    padding: 0 16px !important;
    width: 100% !important;
    box-sizing: border-box;
  }

  /* Tournament Detail Mobile Optimizations */
  #tournament-detail-view .glass-panel h1 {
    font-size: 1.5rem !important;
  }
  
  #t-detail-meta {
    flex-wrap: wrap;
    font-size: 0.8rem !important;
  }

  .leaderboard-row td {
    padding: 10px 8px !important;
    font-size: 0.9rem;
  }

  #t-leaderboard-rows b {
    font-size: 0.9rem !important;
  }

  .mobile-action-bar {
    display: flex !important;
  }

  .tournament-detail-container aside {
    /* Keep aside below the main leaderboard panel on mobile */
    display: flex;
    flex-direction: column;
    gap: 1rem;
    order: 2;
  }

  .tournament-detail-container .glass-panel {
    margin-bottom: 0;
  }

  /* Compact buttons for mobile */
  #t-action-btns {
    flex-direction: row !important;
    flex-wrap: wrap;
    gap: 8px !important;
  }
  
  #t-action-btns button, #t-action-btns + button {
    flex: 1;
    min-width: 140px;
    padding: 8px 12px !important;
    font-size: 0.8rem !important;
  }

  .stat-card {
    padding: 1rem;
  }
  .stat-value {
    font-size: 1.5rem;
  }

  .t-chat-panel {
    height: 400px !important;
    min-height: 400px !important;
    max-height: 400px !important;
    flex: none !important;
  }
}

.t-chat-panel {
  min-height: 400px;
}

@media (max-width: 600px) {
  .pairing-grid { 
    grid-template-columns: repeat(2, 1fr); 
    padding: 0.75rem; 
    gap: 0.75rem;
  }
  .card-btn { padding: 1rem; }
  .card-btn .time { font-size: 1.2rem; }
  
  .clock-display { 
    font-size: 1.2rem; 
    min-width: 90px; 
    padding: 0.3rem 0.6rem; 
  }
  
  header { padding: 0 0.75rem; }
  
  .modal-content {
    width: 95%;
    padding: 1.5rem;
  }
  
  #t-detail-meta span {
    font-size: 0.7rem;
  }
}

/* Avatar Frames & Leaderboard Styles */
.leaderboard-avatar-wrapper {
  position: relative;
  width: 32px;
  height: 32px;
}

.leaderboard-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  border: 1px solid var(--border-glass);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #000;
  font-size: 0.8rem;
}

.top-rank-frame {
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1rem;
  z-index: 2;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

.rank-gold { border: 2px solid #ffd700; box-shadow: 0 0 10px rgba(255, 215, 0, 0.4); }
.rank-silver { border: 2px solid #c0c0c0; box-shadow: 0 0 10px rgba(192, 192, 192, 0.4); }
.rank-bronze { border: 2px solid #cd7f32; box-shadow: 0 0 10px rgba(205, 127, 50, 0.4); }

.leaderboard-row {
  transition: background 0.2s;
}
.leaderboard-row:hover {
  background: rgba(255,255,255,0.03);
}
.player-rank-icon {
  display: inline-block;
  width: 24px;
  text-align: center;
}

.filter-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass);
  color: var(--text-dim);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.filter-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.filter-btn.active {
  background: var(--btn-color, var(--primary));
  border-color: transparent;
  color: #000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.timer-glow {
  animation: timerPulse 2s infinite ease-in-out;
  text-shadow: 0 0 10px rgba(195, 156, 91, 0.4);
}

@keyframes timerPulse {
  0% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.8; transform: scale(1.02); text-shadow: 0 0 20px rgba(195, 156, 91, 0.6); }
  100% { opacity: 1; transform: scale(1); }
}

.t-card-entry {
  animation: slideInUp 0.4s ease-out both;
}

@keyframes slideInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.t-detail-entry {
  animation: fadeIn 0.6s ease-out both;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.live-timer-badge {
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  transition: all 0.3s;
}

.confetti {
  position: fixed;
  width: 10px;
  height: 10px;
  background: var(--primary);
  top: -20px;
  z-index: 4000;
  pointer-events: none;
  animation: confettiFall 3s linear forwards;
}

@keyframes confettiFall {
  0% { transform: translateY(0) rotate(0); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

.win-sticker {
  position: fixed;
  font-size: 3rem;
  z-index: 4001;
  pointer-events: none;
  animation: stickerBurst 1s ease-out forwards;
}

@keyframes stickerBurst {
  0% { transform: scale(0) rotate(0); opacity: 0; }
  50% { transform: scale(1.5) rotate(20deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 0; transform: translateY(-100px); }
}

.game-over-win { color: var(--accent) !important; text-shadow: 0 0 20px rgba(118, 150, 86, 0.5); }
.game-over-loss { color: #f44336 !important; text-shadow: 0 0 20px rgba(244, 67, 54, 0.5); }

.timer-flip {
  display: inline-flex;
  gap: 4px;
}

.flip-card {
  position: relative;
  width: 30px;
  height: 45px;
  background: #111114;
  border-radius: 6px;
  border: 2px solid var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--primary);
  overflow: hidden;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.flip-card::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: rgba(0,0,0,0.5);
  z-index: 2;
}

.animate-pop {
  animation: popScale 0.3s ease-out;
}

@keyframes numScroll {
  0% { transform: translateY(100%); filter: blur(3px); opacity: 0; }
  100% { transform: translateY(0); filter: blur(0); opacity: 1; }
}
.animate-pop {
  animation: numScroll 0.3s cubic-bezier(0.17, 0.67, 0.83, 0.67);
}

.lobby-timer-active {
  color: var(--primary);
  font-weight: 800;
  animation: tickPulse 1s infinite;
}

@keyframes tickPulse {
  0% { opacity: 1; }
  50% { opacity: 0.7; }
  100% { opacity: 1; }
}

.lobby-animate {
  animation: lobbyTick 0.5s ease-out;
}
@keyframes lobbyTick {
  0% { transform: scale(1.2); color: var(--primary); }
  100% { transform: scale(1); }
}

/* Lichess Puzzle Feedback pulse/shake animation */
#puzzle-feedback-ui.pulse-animation {
  animation: shakeAndPulse 0.4s ease-in-out both;
}

@keyframes shakeAndPulse {
  0% { transform: scale(0.8); opacity: 0; }
  20% { transform: scale(1.1) translateX(-8px); }
  40% { transform: scale(1.1) translateX(8px); }
  60% { transform: scale(1.05) translateX(-4px); }
  80% { transform: scale(1.05) translateX(4px); }
  100% { transform: scale(1) translateX(0); opacity: 1; }
}

#puzzle-success-ui {
  animation: successPop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

@keyframes successPop {
  0% { transform: scale(0.7); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* Lichess Right-Click Drawing Overlay Styles */
.drawing-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 100;
}

/* Board Styles */
.board-container {
  width: min(68vh, 700px);
  max-width: 100%;
  aspect-ratio: 1;
}

.chess-board {
  position: relative; /* Ensure relative layout for absolute SVG overlay */
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: 100%;
  height: 100%;
  border: 4px solid #3d2b1f; /* dark wood border */
  border-radius: 4px;
  box-shadow: var(--shadow-lg);
}

.square {
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  cursor: pointer;
}

.square.light {
  background-color: #eeddcc; /* wooden light */
}

.square.dark {
  background-color: #8b5a2b; /* wooden dark */
}

.square.selected {
  background-color: rgba(255, 255, 0, 0.4) !important;
}

.move-hint {
  width: 25%;
  height: 25%;
  background-color: rgba(0, 0, 0, 0.2);
  border-radius: 50%;
}

.capture-hint {
  width: 90%;
  height: 90%;
  border: 5px solid rgba(0, 0, 0, 0.2);
  border-radius: 50%;
  position: absolute;
}

.piece {
  font-size: 3.5rem;
  user-select: none;
  z-index: 10;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.4);
}
.piece.white { color: #fff; }
.piece.black { color: #000; }

/* Modern Inputs and Buttons */
.glass-input {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass);
  border-radius: 8px;
  padding: 12px 16px;
  color: var(--text-main);
  font-size: 1rem;
  outline: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
  font-family: inherit;
}

.glass-input:focus {
  border-color: var(--primary);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 3px rgba(195, 156, 91, 0.15), inset 0 2px 4px rgba(0,0,0,0.1);
}

.glass-input::placeholder {
  color: var(--text-dim);
}

.glass-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: #000;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 12px rgba(195, 156, 91, 0.25);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(195, 156, 91, 0.4);
  background: #d4ae6d;
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(195, 156, 91, 0.3);
}

.btn-primary:disabled {
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.4);
  cursor: not-allowed;
  box-shadow: none;
}

/* Active Page Display Fix */
.dashboard-container.active-page {
  display: grid !important;
}
.game-container.active-page {
  display: flex !important;
}

/* Board Square Themes */
.chess-board.theme-classic .square.light { background-color: #ebecd0; }
.chess-board.theme-classic .square.dark { background-color: #779556; }

.chess-board.theme-blue .square.light { background-color: #dee3e6; }
.chess-board.theme-blue .square.dark { background-color: #8ca2ad; }

.chess-board.theme-wood .square.light { background-color: #e9c08a; }
.chess-board.theme-wood .square.dark { background-color: #8b5a2b; }

.chess-board.theme-purple .square.light { background-color: #efefef; }
.chess-board.theme-purple .square.dark { background-color: #884d88; }

.chess-board.theme-grey .square.light { background-color: #e2e2e2; }
.chess-board.theme-grey .square.dark { background-color: #808080; }

.chess-board.theme-ocean .square.light { background-color: #d1e1f1; }
.chess-board.theme-ocean .square.dark { background-color: #2e5a88; }

/* Background Theme variables redefinition */
body.bg-dark {
  --bg-dark: #09090b;
  --bg-panel: #111114;
  --bg-hover: #1c1c21;
  --text-main: #e4e4e7;
  --text-dim: #71717a;
  --border-glass: #27272a;
}
body.bg-amoled {
  --bg-dark: #000000;
  --bg-panel: #0a0a0a;
  --bg-hover: #141414;
  --text-main: #eeeeee;
  --text-dim: #666666;
  --border-glass: #222222;
}
body.bg-light {
  --bg-dark: #e8ebef;     /* Soothing silver-grey page background */
  --bg-panel: #ffffff;    /* Clean white cards */
  --bg-hover: #dce1e7;    /* Softer grey for hover states */
  --text-main: #1e293b;   /* Soft slate-800 instead of harsh black */
  --text-dim: #475569;    /* slate-600 for legible subtexts */
  --border-glass: #cbd5e1;/* slate-300 for soft, modern borders */
}

/* Premium adjustments for light/amoled sidebars and headers */
body.bg-light .sidebar {
  background: #ffffff !important;
  border-right: 1px solid #cbd5e1 !important;
}
body.bg-light header {
  background: #ffffff !important;
  border-bottom: 1px solid #cbd5e1 !important;
}

body.bg-light .logo-text,
body.bg-light .page-title,
body.bg-light h1,
body.bg-light h2,
body.bg-light h3,
body.bg-light h4,
body.bg-light h5,
body.bg-light h6,
body.bg-light label,
body.bg-light .coord {
  color: #1e293b !important;
}

/* Sidebar nav links and controls */
body.bg-light .nav-link {
  color: #475569 !important;
}
body.bg-light .nav-link:hover,
body.bg-light .mobile-link:hover {
  background: #f1f5f9 !important;
  color: #1e293b !important;
}
body.bg-light .nav-link.active,
body.bg-light .mobile-link.active {
  background: #e2e8f0 !important;
  color: #1e293b !important;
  border-left: 4px solid var(--primary) !important;
}

/* Form controls & search inputs */
body.bg-light .glass-input,
body.bg-light .setup-input {
  background: #f1f5f9 !important;
  border: 1px solid #cbd5e1 !important;
  color: #1e293b !important;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.04) !important;
}
body.bg-light .glass-input:focus,
body.bg-light .setup-input:focus {
  border-color: var(--primary) !important;
  background: #ffffff !important;
  box-shadow: 0 0 0 3px rgba(195, 156, 91, 0.2), inset 0 1px 3px rgba(0,0,0,0.04) !important;
}
body.bg-light .glass-input::placeholder,
body.bg-light .setup-input::placeholder {
  color: #64748b !important;
}
body.bg-light select.glass-input,
body.bg-light select.setup-input {
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 16px center !important;
  background-size: 16px !important;
  padding-right: 40px !important;
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  appearance: none !important;
}
body.bg-light select.glass-input option,
body.bg-light select.setup-input option {
  background-color: #ffffff !important;
  color: #1e293b !important;
}

/* Cards & translucent elements overrides for light mode */
body.bg-light .stat-card,
body.bg-light .theme-preview,
body.bg-light .theme-btn,
body.bg-light .filter-btn {
  background: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  color: #1e293b !important;
}
body.bg-light .stat-card span,
body.bg-light .theme-preview span,
body.bg-light .theme-btn span,
body.bg-light .filter-btn span {
  color: #475569 !important;
}
body.bg-light .theme-preview:hover,
body.bg-light .theme-btn:hover,
body.bg-light .filter-btn:hover {
  background: #f8fafc !important;
  border-color: var(--primary) !important;
}
body.bg-light .theme-preview:hover span,
body.bg-light .theme-btn:hover span,
body.bg-light .filter-btn:hover span {
  color: #1e293b !important;
}
body.bg-light .filter-btn.active {
  background: var(--primary) !important;
  color: #000000 !important;
  border-color: var(--primary) !important;
}

/* Buttons and secondary controls */
body.bg-light .btn-secondary {
  background: #ffffff !important;
  color: #1e293b !important;
  border: 1px solid #cbd5e1 !important;
}
body.bg-light .btn-secondary:hover {
  background: #f1f5f9 !important;
  border-color: var(--primary) !important;
}

/* Leaderboard hover effects */
body.bg-light .leaderboard-row:hover {
  background: #f1f5f9 !important;
}

/* Modals */
body.bg-light .modal-content {
  background: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  color: #1e293b !important;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 10px 10px -5px rgba(0, 0, 0, 0.02) !important;
}
body.bg-light .modal-content h1,
body.bg-light .modal-content h2,
body.bg-light .modal-content h3 {
  color: #1e293b !important;
}

/* Chat background overlay issues */
body.bg-light #chat-messages {
  background: #f1f5f9 !important;
}
body.bg-light #t-chat-messages {
  background: #f1f5f9 !important;
}
body.bg-light #admin-u-chat-messages {
  background: #f1f5f9 !important;
  border: 1px solid #cbd5e1 !important;
}

/* Scrollbars for light mode */
body.bg-light ::-webkit-scrollbar-thumb {
  background: #cbd5e1 !important;
}
body.bg-light ::-webkit-scrollbar-thumb:hover {
  background: #94a3b8 !important;
}

/* Premium Chat Partner Items */
.chat-partner-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.03);
  border-left: 3px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 6px;
  transition: all 0.2s ease;
  border: 1px solid var(--border-glass);
}
.chat-partner-item:hover {
  background: var(--bg-hover);
  transform: translateX(2px);
}
.chat-partner-item.active {
  background: rgba(195, 156, 91, 0.12) !important;
  border-left: 3px solid var(--primary) !important;
  border-color: rgba(195, 156, 91, 0.3) !important;
}
body.bg-light .chat-partner-item.active {
  background: rgba(195, 156, 91, 0.15) !important;
}
.chat-partner-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.chat-partner-name {
  font-weight: 600;
  color: var(--text-main);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 5px;
}
.chat-partner-name.system {
  color: var(--accent) !important;
}
.chat-partner-time {
  font-size: 0.75rem;
  color: var(--text-dim);
}
.chat-partner-last-msg {
  font-size: 0.8rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Premium Chat Bubbles */
.chat-bubble {
  padding: 8px 14px;
  border-radius: 12px;
  max-width: 80%;
  word-break: break-word;
  font-size: 0.95rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  line-height: 1.4;
  margin-bottom: 2px;
}
.chat-bubble.me {
  align-self: flex-end;
  background: var(--primary);
  color: #000000;
  border-bottom-right-radius: 4px;
  font-weight: 500;
}
.chat-bubble.them {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--border-glass);
}
body.bg-light .chat-bubble.them {
  background: #ffffff !important;
  color: #09090b !important;
  border: 1px solid #d4d4d8 !important;
}
.chat-bubble-sender {
  font-size: 0.75rem;
  color: var(--accent);
  display: block;
  font-weight: bold;
  margin-bottom: 3px;
}
.chat-bubble-text {
  white-space: pre-wrap;
}

/* Premium User Search Results */
.search-result-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-glass);
  padding: 10px;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 5px;
  transition: all 0.2s ease;
}
.search-result-item:hover {
  background: var(--bg-hover);
  border-color: var(--primary);
  transform: translateX(2px);
}
.search-result-avatar {
  width: 30px;
  height: 30px;
  background: var(--primary);
  color: #000;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 0.8rem;
  overflow: hidden;
}
.search-result-name {
  color: var(--text-main);
  font-weight: 600;
  font-size: 0.9rem;
}
.search-result-rating {
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 700;
}
body.bg-amoled .sidebar,
body.bg-amoled header {
  background: #000000 !important;
  border-color: #222222 !important;
}

/* Premium Chess Coordinates */
.coord {
  position: absolute;
  font-size: 0.65rem;
  font-weight: 700;
  pointer-events: none;
  user-select: none;
  opacity: 0.75;
  z-index: 20;
}
.coord.rank {
  top: 4px;
  left: 4px;
}
.coord.file {
  bottom: 4px;
  right: 4px;
}

.chess-board.theme-classic .square.light .coord { color: #779556; }
.chess-board.theme-classic .square.dark .coord { color: #ebecd0; }
.chess-board.theme-blue .square.light .coord { color: #8ca2ad; }
.chess-board.theme-blue .square.dark .coord { color: #dee3e6; }
.chess-board.theme-wood .square.light .coord { color: #8b5a2b; }
.chess-board.theme-wood .square.dark .coord { color: #e9c08a; }
.chess-board.theme-purple .square.light .coord { color: #884d88; }
.chess-board.theme-purple .square.dark .coord { color: #efefef; }
.chess-board.theme-grey .square.light .coord { color: #808080; }
.chess-board.theme-grey .square.dark .coord { color: #e2e2e2; }
.chess-board.theme-ocean .square.light .coord { color: #2e5a88; }
.chess-board.theme-ocean .square.dark .coord { color: #d1e1f1; }

/* Premium Toast Animations */
@keyframes toastSlideIn {
  from { opacity: 0; transform: translateY(20px) scale(0.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastSlideOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(20px) scale(0.9); }
}

/* Premium Draw Offer Card styling */
.draw-offer-card {
  position: fixed;
  top: 100px;
  right: 24px;
  width: 320px;
  background: var(--bg-panel);
  border: 2px solid var(--primary);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 15px 40px rgba(0,0,0,0.6);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: slideInRight 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  font-family: var(--font-family);
  border-left: 6px solid var(--primary);
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(50px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes slideOutRight {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(50px); }
}

.draw-offer-card .title {
  color: var(--text-main);
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
}

.draw-offer-card .actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.draw-offer-card .btn-draw-choice {
  flex: 1;
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  transition: transform 0.1s, background 0.2s;
}

.draw-offer-card .btn-draw-choice:active {
  transform: scale(0.95);
}

.draw-offer-card .btn-accept {
  background: var(--accent);
  color: #000;
}

.draw-offer-card .btn-accept:hover {
  background: #648149;
  color: #fff;
}

.draw-offer-card .btn-decline {
  background: #f44336;
  color: #fff;
}

.draw-offer-card .btn-decline:hover {
  background: #d32f2f;
}

/* Premium Particle Emoji Burst */
.emoji-particle {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 10002;
  will-change: transform, opacity;
  animation: emojiBurst 1.3s cubic-bezier(0.1, 0.8, 0.3, 1) forwards;
}

@keyframes emojiBurst {
  0% {
    transform: translate(-50%, -50%) scale(0) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translate(var(--tx), var(--ty)) scale(1.6) rotate(var(--rot));
    opacity: 0;
  }
}

/* Premium Lichess-Style Quick matchmaking search styles */
.pairing-grid.searching-active .card-btn:not(.searching) {
  opacity: 0.4;
  pointer-events: none;
  filter: grayscale(0.5) blur(0.5px);
  transform: scale(0.95);
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.card-btn.searching {
  transform: translateY(-8px) scale(1.05) !important;
  border-color: var(--primary) !important;
  background: rgba(195, 156, 91, 0.08) !important;
  box-shadow: 0 15px 35px rgba(195, 156, 91, 0.25), 0 0 0 1px var(--primary) !important;
  pointer-events: auto !important;
  opacity: 1 !important;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* Spinner styled circular animation */
.card-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(255, 255, 255, 0.05);
  border-top: 3px solid var(--primary);
  border-radius: 50%;
  animation: cardSpin 1s cubic-bezier(0.4, 0, 0.2, 1) infinite;
  margin-top: 10px;
  box-shadow: 0 0 10px rgba(195, 156, 91, 0.2);
}

@keyframes cardSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.card-btn.searching .mode {
  color: var(--primary) !important;
  animation: textPulse 1.5s ease-in-out infinite;
  font-weight: 700;
  letter-spacing: 0.5px;
}

@keyframes textPulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* Premium Visual Pawn Promotion Styles */
.square.promotion-option {
  background-color: rgba(9, 9, 11, 0.95) !important;
  border-radius: 50% !important;
  transform: scale(0.9) !important;
  box-shadow: 0 0 15px rgba(195, 156, 91, 0.3), inset 0 0 10px rgba(255, 255, 255, 0.05);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
  z-index: 1000 !important;
  cursor: pointer !important;
  border: 2px solid var(--primary) !important;
}

.square.promotion-option:hover {
  background-color: var(--primary) !important;
  transform: scale(1.02) !important;
  box-shadow: 0 0 25px var(--primary) !important;
}

.square.promotion-option:hover .promotion-piece-img {
  filter: brightness(0.1);
}

.promotion-piece-img {
  width: 85% !important;
  height: 85% !important;
  transition: all 0.2s ease;
}

/* Red Lichess-Style Premove Selection Hints */
.premove-move-hint {
  width: 24%;
  height: 24%;
  background-color: rgba(239, 68, 68, 0.7) !important; /* Premium semi-transparent red dot */
  border-radius: 50%;
  position: absolute;
  z-index: 15;
  pointer-events: none;
}

.premove-capture-hint {
  width: 88%;
  height: 88%;
  border: 5px solid rgba(239, 68, 68, 0.6) !important; /* Premium semi-transparent red ring */
  border-radius: 50%;
  position: absolute;
  z-index: 15;
  pointer-events: none;
}

/* Premium Login/Registration Modal Styles */
#login-modal {
  background: radial-gradient(circle at center, rgba(15, 15, 20, 0.85) 0%, rgba(5, 5, 8, 0.98) 100%);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

#login-modal .modal-content {
  background: rgba(22, 22, 29, 0.75);
  border: 1px solid rgba(195, 156, 91, 0.2); /* Gold tinted border */
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6), 
              0 0 50px rgba(195, 156, 91, 0.08); /* Subtle golden glow */
  border-radius: 20px;
  padding: 2.5rem;
  width: 440px;
  max-width: 90%;
  animation: modalZoomIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  position: relative;
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.3s ease;
}

/* Float Animation for the Chess Icon */
#login-modal .modal-content > span {
  display: inline-block;
  font-size: 3.5rem;
  margin-bottom: 0.5rem;
  color: var(--primary);
  filter: drop-shadow(0 0 8px rgba(195, 156, 91, 0.4));
  animation: floatChessPiece 3s ease-in-out infinite;
}

/* Smooth Transitions for toggling modes */
#login-modal .modal-content * {
  transition: all 0.3s ease;
}

/* Shake Error keyframes */
@keyframes shakeError {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-8px); }
  20%, 40%, 60%, 80% { transform: translateX(8px); }
}

.shake-error {
  animation: shakeError 0.5s cubic-bezier(.36,.07,.19,.97) both;
}

/* Glow red border for validation errors */
.input-error {
  border-color: #ef4444 !important;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.35) !important;
  background: rgba(239, 68, 68, 0.08) !important;
}

/* Modal entrance animation */
@keyframes modalZoomIn {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Chess piece floating */
@keyframes floatChessPiece {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-8px) rotate(3deg);
  }
}

/* Style overrides for light mode for the login modal */
body.bg-light #login-modal {
  background: radial-gradient(circle at center, rgba(232, 235, 239, 0.85) 0%, rgba(190, 195, 202, 0.98) 100%);
}
body.bg-light #login-modal .modal-content {
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(195, 156, 91, 0.35);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15), 
              0 0 50px rgba(195, 156, 91, 0.15);
}
body.bg-light #login-modal h2 {
  color: #1e293b !important;
}
