/* ==========================================================================
   AETHER CHESS - CUSTOM DESIGN SYSTEM & DESIGN STYLE
   ========================================================================== */

:root {
  /* Colors */
  --bg-primary: #0a0c10;
  --bg-secondary: #121620;
  --glass-bg: rgba(18, 22, 32, 0.65);
  --glass-bg-subtle: rgba(18, 22, 32, 0.4);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-border-glow: rgba(147, 51, 234, 0.3);
  
  --text-primary: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dark: #1f2937;
  
  --primary: #8b5cf6; /* Electric Purple */
  --primary-glow: rgba(139, 92, 246, 0.4);
  --secondary: #06b6d4; /* Electric Cyan */
  --secondary-glow: rgba(6, 182, 212, 0.4);
  --accent: #f59e0b; /* Bright Amber Gold */
  
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  
  /* Layout Dimensions */
  --board-size: min(80vw, 80vh, 560px);
  --square-size: calc(var(--board-size) / 8);
  --sidebar-width: 360px;
  
  /* Fonts */
  --font-display: 'Space Grotesk', sans-serif;
  --font-sans: 'Outfit', sans-serif;
  
  /* Animations */
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   RESET & SYSTEM BASICS
   ========================================================================== */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  overflow-x: hidden;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

/* ==========================================================================
   MESH BACKGROUND DYNAMICS
   ========================================================================== */

.mesh-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: -1;
  overflow: hidden;
  background: radial-gradient(circle at 50% 50%, #111424, #080911);
}

.mesh-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(140px);
  opacity: 0.25;
  mix-blend-mode: screen;
}

.orb-1 {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, var(--primary), transparent 70%);
  top: -200px;
  left: -100px;
  animation: drift-orb 25s infinite alternate ease-in-out;
}

.orb-2 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, var(--secondary), transparent 70%);
  bottom: -150px;
  right: -50px;
  animation: drift-orb 20s infinite alternate-reverse ease-in-out;
}

.orb-3 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, #ec4899, transparent 70%); /* hot pink */
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation: drift-orb 30s infinite alternate ease-in-out;
}

@keyframes drift-orb {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(60px, -40px) scale(1.1); }
  100% { transform: translate(-40px, 80px) scale(0.9); }
}

/* ==========================================================================
   GLASSMORPHISM & PREMIUM UTILITIES
   ========================================================================== */

.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.4);
  transition: var(--transition-smooth);
}

.glass-card:hover {
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 16px 48px 0 rgba(0, 0, 0, 0.5), 0 0 20px 0 var(--glass-border-glow);
}

.glass-card-subtle {
  background: var(--glass-bg-subtle);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 12px 24px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  transition: var(--transition-fast);
  color: #fff;
  user-select: none;
  text-decoration: none;
}

.btn-sm {
  padding: 8px 16px;
  font-size: 0.85rem;
  border-radius: 8px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.5);
  filter: brightness(1.1);
}

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

.btn-glow {
  position: relative;
  overflow: hidden;
}

.btn-glow::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(45deg, transparent, rgba(255,255,255,0.1), transparent);
  transform: rotate(45deg);
  transition: 0.5s;
  pointer-events: none;
}

.btn-glow:hover::after {
  left: 120%;
  transition: 0.5s;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--glass-border);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
}

.btn-secondary-outline {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.btn-secondary-outline:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.3);
}

.btn-danger-outline {
  background: transparent;
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: var(--danger);
}

.btn-danger-outline:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--danger);
  transform: translateY(-1px);
}

.btn-success {
  background: var(--success);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}
.btn-success:hover {
  background: #059669;
  transform: translateY(-1px);
}

.btn-danger {
  background: var(--danger);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}
.btn-danger:hover {
  background: #dc2626;
  transform: translateY(-1px);
}

.btn-icon {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  width: 40px;
  height: 40px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--secondary);
}

.btn-icon-only {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 !important;
}

/* Input Fields */
.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.input-wrapper i {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
  width: 18px;
  height: 18px;
  pointer-events: none;
}

.input-wrapper input {
  width: 100%;
  padding: 12px 14px 12px 42px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  color: #fff;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  transition: var(--transition-fast);
}

.input-wrapper input:focus {
  outline: none;
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--primary);
  box-shadow: 0 0 12px rgba(139, 92, 246, 0.2);
}

/* ==========================================================================
   LOBBY SCREEN LAYOUT
   ========================================================================== */

#app-container {
  width: 100%;
  max-width: 1280px;
  padding: 20px;
  min-height: 90vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.view-screen {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.hidden {
  display: none !important;
}

.lobby-card {
  width: 100%;
  max-width: 460px;
  padding: 40px;
  text-align: center;
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 16px;
}

.brand h1, .brand h2 {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: #fff;
}

.brand h1 span, .brand h2 span {
  background: linear-gradient(135deg, var(--secondary), var(--primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-icon {
  width: 52px;
  height: 52px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.8rem;
  margin-bottom: 12px;
  box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4);
}

.tagline {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.5;
  margin-bottom: 28px;
}

.name-input-group {
  text-align: left;
  margin-bottom: 24px;
}

.name-input-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.lobby-actions {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#btn-create-game {
  width: 100%;
  font-size: 1.05rem;
  padding: 14px 28px;
}

.separator {
  display: flex;
  align-items: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  margin: 8px 0;
}

.separator::before, .separator::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
}

.separator span {
  padding: 0 12px;
}

.join-panel {
  display: flex;
  gap: 10px;
}

.join-panel .input-wrapper {
  flex: 1;
}

.join-panel input {
  padding-left: 36px;
  font-family: monospace;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.join-panel .input-wrapper i {
  left: 12px;
}

.lobby-footer {
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.8rem;
  color: var(--text-muted);
}
.lobby-footer p {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.lobby-footer i {
  color: var(--accent);
  width: 14px;
  height: 14px;
}

/* ==========================================================================
   GAME SCREEN LAYOUT
   ========================================================================== */

#game-screen {
  align-items: flex-start;
}

.game-layout {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Header */
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
}

.mini-brand {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  margin-bottom: 0;
}
.mini-brand .logo-icon {
  width: 32px;
  height: 32px;
  font-size: 1.1rem;
  border-radius: 8px;
  margin-bottom: 0;
  box-shadow: none;
}
.mini-brand h2 {
  font-size: 1.25rem;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Main Two-Column Layout */
.game-main-content {
  display: grid;
  grid-template-columns: 1fr var(--sidebar-width);
  gap: 24px;
  align-items: start;
}

/* ==========================================================================
   CHESSBOARD ZONE
   ========================================================================== */

.chessboard-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

/* Player Badges */
.player-badge {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: var(--board-size);
  padding: 10px 16px;
  border-radius: 12px;
  transition: var(--transition-smooth);
}

.player-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--text-muted);
}
.status-dot.active {
  background-color: var(--success);
  box-shadow: 0 0 8px var(--success);
}
.status-dot.disconnected {
  background-color: var(--danger);
  box-shadow: 0 0 8px var(--danger);
  animation: pulse-red 1.5s infinite;
}

@keyframes pulse-red {
  0% { opacity: 0.4; }
  50% { opacity: 1; }
  100% { opacity: 0.4; }
}

.player-avatar {
  width: 28px;
  height: 28px;
  background: rgba(255,255,255,0.06);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}
.player-avatar i {
  width: 14px;
  height: 14px;
}

.player-meta {
  display: flex;
  flex-direction: column;
}

.player-name {
  font-size: 0.9rem;
  font-weight: 600;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-role-tag {
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.player-timer {
  font-family: 'Space Grotesk', monospace;
  font-weight: 700;
  font-size: 1.25rem;
  padding: 4px 10px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  color: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.active-turn {
  border-color: rgba(139, 92, 246, 0.4);
  background: rgba(139, 92, 246, 0.04);
}
.active-turn .player-timer {
  color: var(--primary);
  border-color: rgba(139, 92, 246, 0.2);
  box-shadow: 0 0 10px rgba(139, 92, 246, 0.1);
  animation: pulse-border 2s infinite alternate;
}

@keyframes pulse-border {
  0% { box-shadow: 0 0 5px rgba(139, 92, 246, 0.1); }
  100% { box-shadow: 0 0 15px rgba(139, 92, 246, 0.3); }
}

/* Board Outer Framing & Coordinates */
.board-outer-container {
  display: flex;
  position: relative;
}

.board-middle-row {
  display: flex;
  flex-direction: column;
}

/* Chessboard Frame */
.chessboard-frame {
  padding: 6px;
  background: linear-gradient(135deg, rgba(255,255,255,0.06), rgba(255,255,255,0.01));
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.chessboard {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: var(--board-size);
  height: var(--board-size);
  border-radius: 8px;
  overflow: hidden;
  user-select: none;
  touch-action: none;
}

/* Coordinates along board edges */
.coordinates {
  display: flex;
  color: var(--text-muted);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.65rem;
  pointer-events: none;
  opacity: 0.6;
}

.coordinates-x {
  height: 20px;
  width: var(--board-size);
  margin-left: 6px; /* align with frame */
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  align-items: center;
  text-align: center;
}

.coordinates-y {
  width: 20px;
  height: var(--board-size);
  margin-top: 6px; /* align with frame */
  display: grid;
  grid-template-rows: repeat(8, 1fr);
  align-items: center;
  text-align: center;
}

.horizontal-bottom { order: 3; }
.horizontal-top { order: 1; visibility: hidden; } /* hide top coordinates for cleaner view */
.vertical-left { order: 1; }
.vertical-right { order: 3; visibility: hidden; }

/* ==========================================================================
   CHESSBOARD SQUARES & PIECES
   ========================================================================== */

.square {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease;
}

/* Emerald Theme Styles */
.emerald-theme .square.light {
  background-color: #e2e8f0; /* frosted sand slate */
}
.emerald-theme .square.dark {
  background-color: #2b543d; /* deep matte emerald forest */
}

/* Space Theme Styles */
.space-theme .square.light {
  background-color: #3b4252; /* iced carbon slate */
}
.space-theme .square.dark {
  background-color: #1a1e2a; /* deep space abyss */
}

/* Highlights */
.square.selected {
  background-color: rgba(139, 92, 246, 0.45) !important;
  box-shadow: inset 0 0 0 3px var(--primary);
}

.square.last-move {
  background-color: rgba(6, 182, 212, 0.25) !important;
}

.square.in-check {
  background-color: rgba(239, 68, 68, 0.4) !important;
  box-shadow: inset 0 0 15px rgba(239, 68, 68, 0.7);
  animation: pulse-red-glow 1s infinite alternate;
}

@keyframes pulse-red-glow {
  0% { box-shadow: inset 0 0 10px rgba(239, 68, 68, 0.5); }
  100% { box-shadow: inset 0 0 20px rgba(239, 68, 68, 0.9); }
}

/* Drag & Move Overlays */
.move-indicator {
  width: 28%;
  height: 28%;
  background-color: rgba(16, 185, 129, 0.45);
  border-radius: 50%;
  pointer-events: none;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.4);
}

.capture-indicator {
  position: absolute;
  width: 80%;
  height: 80%;
  border: 3px solid rgba(239, 68, 68, 0.5);
  border-radius: 50%;
  pointer-events: none;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.2);
}

.square.drag-over {
  background-color: rgba(6, 182, 212, 0.2) !important;
}

/* Chess Pieces */
.piece {
  width: 82%;
  height: 82%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  z-index: 10;
  transition: transform 0.1s ease;
  user-select: none;
}

.piece:active {
  cursor: grabbing;
}

.piece.dragging {
  opacity: 0.4;
  transform: scale(1.1);
}

/* SVGs styling for professional contrast */
.piece svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.25));
  transition: transform 0.2s ease;
}

.piece:hover svg {
  transform: translateY(-2px);
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.35));
}

/* ==========================================================================
   SIDEBAR LAYOUT & WIDGETS
   ========================================================================== */

.sidebar-column {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Invite/Share Card */
.share-card {
  padding: 20px;
}
.share-card h3 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.share-card h3 i {
  color: var(--secondary);
  width: 18px;
  height: 18px;
}
.share-card p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.share-link-wrapper {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.share-link-wrapper input {
  flex: 1;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--text-muted);
  font-size: 0.8rem;
  outline: none;
}
.share-link-wrapper input:focus {
  border-color: var(--secondary);
}

.game-code-badge {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.02);
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px dashed rgba(255, 255, 255, 0.08);
}
.game-code-badge strong {
  font-family: monospace;
  color: var(--accent);
  letter-spacing: 0.5px;
}

/* Tab Container (Moves & Chat) */
.logs-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 380px;
  overflow: hidden;
  border-radius: 20px;
}

.tabs-header {
  display: flex;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(0,0,0,0.1);
}

.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  padding: 12px;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: var(--transition-fast);
}
.tab-btn:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,0.02);
}
.tab-btn.active {
  color: var(--primary);
  background: transparent;
  box-shadow: inset 0 -2px 0 var(--primary);
}

.tab-btn i {
  width: 16px;
  height: 16px;
}

.chat-badge {
  background-color: var(--danger);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 8px;
}

.tab-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.tab-content {
  display: none;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}
.tab-content.active {
  display: flex;
}

/* Moves Log List */
.move-log-container {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  font-family: var(--font-sans);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.no-moves-msg {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
  margin-top: 40px;
  font-style: italic;
}

.move-row {
  display: grid;
  grid-template-columns: 35px 1fr 1fr;
  font-size: 0.85rem;
  padding: 6px 12px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.01);
}
.move-row:nth-child(even) {
  background: rgba(255, 255, 255, 0.03);
}

.move-num {
  color: var(--text-muted);
  font-weight: 600;
}

.move-algebraic {
  cursor: pointer;
  font-weight: 500;
  transition: var(--transition-fast);
}
.move-algebraic:hover {
  color: var(--secondary);
}

/* Chat Messages Area */
.chat-messages-container {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-msg {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 0.85rem;
  line-height: 1.4;
  animation: message-pop 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes message-pop {
  0% { transform: translateY(5px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

.chat-msg .sender {
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.3px;
  margin-bottom: 2px;
  text-transform: uppercase;
}

.chat-msg.self {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(139, 92, 246, 0.15));
  border: 1px solid rgba(139, 92, 246, 0.15);
  border-bottom-right-radius: 2px;
}
.chat-msg.self .sender {
  color: var(--primary);
}

.chat-msg.opponent {
  align-self: flex-start;
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.15), rgba(6, 182, 212, 0.1));
  border: 1px solid rgba(6, 182, 212, 0.15);
  border-bottom-left-radius: 2px;
}
.chat-msg.opponent .sender {
  color: var(--secondary);
}

.chat-msg.spectator {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  font-style: italic;
}
.chat-msg.spectator .sender {
  color: var(--text-muted);
}

.system-message {
  align-self: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 8px;
  padding: 6px 12px;
  width: 95%;
  border: 1px solid rgba(255, 255, 255, 0.03);
  margin: 4px 0;
}

.chat-input-wrapper {
  display: flex;
  padding: 10px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(0,0,0,0.1);
  gap: 8px;
}

.chat-input-wrapper input {
  flex: 1;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  padding: 8px 12px;
  color: #fff;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  outline: none;
}
.chat-input-wrapper input:focus {
  border-color: var(--primary);
  background: rgba(255, 255, 255, 0.06);
}

/* Sidebar Bottom Action Controls */
.game-controls {
  padding: 12px 16px;
  display: flex;
  gap: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(0,0,0,0.15);
}
.game-controls button {
  flex: 1;
}

/* ==========================================================================
   OVERLAYS AND MODAL STYLES
   ========================================================================== */

/* Spectator live banner */
.spectator-banner {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(6, 182, 212, 0.15);
  border: 1px solid rgba(6, 182, 212, 0.4);
  backdrop-filter: blur(10px);
  color: var(--secondary);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 20px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  z-index: 999;
}
.spectator-banner i {
  width: 16px;
  height: 16px;
  animation: eye-glow 2s infinite alternate;
}

@keyframes eye-glow {
  0% { transform: scale(0.9); opacity: 0.7; }
  100% { transform: scale(1.1); opacity: 1; }
}

/* Modal Overlay */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(5, 6, 10, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fade-in 0.25s ease-out;
}

.modal-card {
  width: 90%;
  max-width: 400px;
  padding: 36px 28px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  border-color: rgba(255, 255, 255, 0.1);
}

.modal-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(139, 92, 246, 0.15);
  border: 1px solid rgba(139, 92, 246, 0.3);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}
.modal-icon i {
  width: 32px;
  height: 32px;
}

.modal-icon.warning-icon {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.3);
  color: var(--warning);
}

.modal-icon.info-icon {
  background: rgba(6, 182, 212, 0.15);
  border-color: rgba(6, 182, 212, 0.3);
  color: var(--secondary);
}

.modal-card h2 {
  font-family: var(--font-display);
  font-size: 1.8rem;
  margin-bottom: 8px;
  font-weight: 700;
}
.modal-card p {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 28px;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}
.modal-actions button {
  width: 100%;
}

/* ==========================================================================
   TOAST NOTIFICATION INJECTOR
   ========================================================================== */

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 1010;
}

.toast {
  background: rgba(18, 22, 32, 0.85);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  color: #fff;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  transform: translateX(120%);
  animation: slide-in-toast 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.toast i {
  width: 18px;
  height: 18px;
}
.toast.info i { color: var(--secondary); }
.toast.success i { color: var(--success); }
.toast.warning i { color: var(--warning); }
.toast.danger i { color: var(--danger); }

@keyframes slide-in-toast {
  to { transform: translateX(0); }
}

/* ==========================================================================
   ANIMATIONS UTILS
   ========================================================================== */

.animate-fade-in {
  animation: fade-in 0.4s ease-out;
}
.animate-scale-in {
  animation: scale-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.animate-slide-down {
  animation: slide-down 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scale-in {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes slide-down {
  from { transform: translate(-50%, -30px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

/* ==========================================================================
   RESPONSIVE MEDIA QUERIES (MOBILE SUPPORT)
   ========================================================================== */

@media (max-width: 992px) {
  :root {
    --board-size: min(90vw, 75vh, 480px);
  }
  
  #app-container {
    padding: 10px;
  }
  
  .game-main-content {
    grid-template-columns: 1fr;
    justify-items: center;
  }
  
  .sidebar-column {
    width: var(--board-size);
  }
  
  .logs-card {
    height: 320px;
  }
}

@media (max-width: 576px) {
  :root {
    --board-size: min(92vw, 92vh, 360px);
  }
  
  .lobby-card {
    padding: 24px 16px;
  }
  
  .join-panel {
    flex-direction: column;
  }
  
  .game-header {
    padding: 10px 14px;
  }
  
  .player-badge {
    padding: 8px 12px;
  }
  
  .player-timer {
    font-size: 1.1rem;
    padding: 2px 6px;
  }
  
  .coordinates-y {
    display: none; /* hide coords on very small screens to fit board */
  }
  .coordinates-x {
    margin-left: 0;
  }
  
  .sidebar-column {
    width: 100%;
  }
}
