/**
 * Multiplayer UI Styles
 *
 * Modern, beautiful UI for FFA multiplayer
 */

/* ========================================
   COMMON STYLES
   ======================================== */

.hidden {
  display: none !important;
}

/* ========================================
   LOBBY STYLES
   ======================================== */

/* Left: Room list */

.room-name {
  font-size: 16px;
  font-weight: 600;
  color: white;
  margin-bottom: 4px;
}

/* Right: Room details or create room */

/* Selected room detail view */

.player-name {
  flex: 1;
  font-size: 14px;
  color: white;
  font-weight: 600;
}

/* ========================================
   CREATE ROOM MODAL
   ======================================== */

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: #cbd5e0;
  margin-bottom: 8px;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 10px 12px;
  background: rgba(30, 35, 50, 0.8);
  border: 1px solid rgba(102, 126, 234, 0.4);
  border-radius: 8px;
  color: white;
  font-size: 14px;
  transition: all 0.2s ease;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: rgba(102, 126, 234, 0.8);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

/* ========================================
   MULTIPLAYER GAME VIEW
   ======================================== */

/* Top header with timer and back button */

/* Main game area with player boards */

/* Game over modal */
.game-over-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(18, 23, 31, 0.98);
  border: 2px solid rgba(102, 126, 234, 0.5);
  border-radius: 16px;
  padding: 40px;
  min-width: 400px;
  text-align: center;
  z-index: 3000;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
}

.game-over-title {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 16px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid rgba(102, 126, 234, 0.2);
}

.stat-row:last-child {
  border-bottom: none;
}

.stat-label {
  color: #a0aec0;
  font-size: 14px;
}

.stat-value {
  color: white;
  font-weight: 600;
  font-size: 14px;
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

/* ========================================
   UTILITY CLASSES
   ======================================== */

.fade-in {
  animation: fadeIn 0.3s ease-in;
}

/* Shared keyframe names. lobby-styles.css and match-config-styles.css (retired by
 * keystone-multiplayer.css) loaded after main.css and so defined the effective
 * fadeIn / modalSlideIn / titleGlow that `.modal.visible`, `.game-container`,
 * `.modal-content` and `.modal h1` still name. Their definitions live here now so
 * those surfaces animate exactly as before. */
@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(-20px);
  }

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

@keyframes titleGlow {
  0%,
  100% {
    text-shadow: 0 0 20px rgba(139, 92, 246, 0.5);
  }

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

@keyframes slideIn {
  from {
    transform: translateX(-20px);
    opacity: 0;
  }

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

/* Leaderboard widget */
.leaderboard {
  position: fixed;
  top: 20px;
  right: 20px;
  background: rgba(18, 23, 31, 0.95);
  border: 1px solid rgba(102, 126, 234, 0.4);
  border-radius: 12px;
  padding: 16px;
  min-width: 200px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 100;
}

/* Match Timer */

/* Attack indicators */

/* Frag counter */

/* Death overlay */
.death-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  z-index: 1000;
  pointer-events: none;
}

.death-text {
  font-size: 32px;
  font-weight: 700;
  color: #fc8181;
  text-shadow: 0 0 20px rgba(252, 129, 129, 0.5);
  animation: deathPulse 1s ease-in-out infinite;
}

@keyframes deathPulse {

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

  50% {
    opacity: 1;
    transform: scale(1.1);
  }
}

/* Victory overlay */

/* Responsive tweaks */
@media (max-width: 1400px) {
  .leaderboard {
    min-width: 180px;
    padding: 12px;
  }
}

@media (max-width: 768px) {
  .leaderboard {
    top: 10px;
    right: 10px;
  }
}

/* Main Player Card Styles - Overrides for new layout */
.player-card {
  position: relative;
  /* Ensure existing styles are compatible */
  display: flex;
  flex-direction: column;
  /* Remove padding that was for the old header */
  padding-top: 24px;
  border: 1px solid rgba(102, 126, 234, 0.3);
  border-radius: 12px;
  background: rgba(18, 23, 31, 0.85);
  backdrop-filter: blur(4px);
  /* Ensure card content doesn't overlap the avatar */
  margin-top: 15px;
}

.player-card.hot-potato-holder {
  border-color: rgba(249, 115, 22, 0.9);
  box-shadow:
    0 0 0 1px rgba(249, 115, 22, 0.35),
    0 0 24px rgba(249, 115, 22, 0.24);
}

.player-card.hot-potato-holder::after {
  content: "Hot Potato " attr(data-potato-progress);
  position: absolute;
  top: 8px;
  right: 10px;
  z-index: 7;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(24, 16, 10, 0.9);
  border: 1px solid rgba(249, 115, 22, 0.7);
  color: #fed7aa;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  pointer-events: none;
}

/* New Avatar Header Layout */
.player-header {
  display: flex !important;
  /* Force display back on */
  position: absolute;
  top: -18px;
  /* Center circle on the border (36px height / 2) */
  left: 50%;
  transform: translateX(-50%);
  width: auto;
  background: transparent;
  padding: 0;
  margin: 0;
  z-index: 5;
  border: none;
  /* Remove old header borders/bgs */
}

/* Avatar Circle Styles */
.player-avatar {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #0c0a1a;
  /* Match page background to mask the card border */
  border: 2px solid rgba(102, 126, 234, 0.5);
  /* Re-add border around circle */
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
  /* Shadow to lift it */
}

.avatar-text {
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  z-index: 2;
}

/* Optional glow effect inside avatar */
.avatar-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  height: 100%;
  border-radius: 50%;
  box-shadow: 0 0 15px rgba(102, 126, 234, 0.4);
  pointer-events: none;
}

/* Hide the old text label if we missed removing it anywhere */

/* ========================================
   INFINITY LMS LAYOUT
   ======================================== */

/* Infinity LMS Layout - Vertical boards in horizontal arrangement */
.multiplayer-game-area.infinity-lms {
  /* Boards are tall (20 visible rows) but narrow (10 cols) */
  --infinity-visible-rows: 20;
  --infinity-board-aspect: 0.5;
  /* 10 cols / 20 rows */
}

/* 2 players - wider boards */
.multiplayer-game-area.infinity-lms.players-2 {
  display: grid;
  grid-template-columns: repeat(2, max-content);
  gap: 40px;
  justify-content: center;
  align-items: center;
}

.multiplayer-game-area.infinity-lms.players-2 .player-card {
  max-height: 85vh;
}

/* 3 players - medium width */
.multiplayer-game-area.infinity-lms.players-3 {
  display: grid;
  grid-template-columns: repeat(3, max-content);
  gap: 30px;
  justify-content: center;
  align-items: center;
}

.multiplayer-game-area.infinity-lms.players-3 .player-card {
  max-height: 82vh;
}

/* Player Stats Table */
.stats-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 4px;
  /* Add gap between rows */
  font-size: 13px;
}

.stats-table th {
  text-align: left;
  color: #7a8aa8;
  font-size: 11px;
  text-transform: uppercase;
  padding: 8px 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.stats-table td {
  padding: 10px 12px;
  color: #e2e8f0;
  background: rgba(30, 41, 59, 0.4);
}

.stats-table tr td:first-child {
  border-top-left-radius: 6px;
  border-bottom-left-radius: 6px;
}

.stats-table tr td:last-child {
  border-top-right-radius: 6px;
  border-bottom-right-radius: 6px;
}

.stats-table .col-rank {
  width: 40px;
  text-align: center;
  font-weight: 700;
  color: #fff;
}

.stats-table .col-player {
  /* Allow wrapper to handle layout */
}

.stats-table .player-stats-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Ensure the player color dot is visible and aligned */
.stats-table .player-color-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  box-shadow: 0 0 5px rgba(255, 255, 255, 0.3);
  margin-right: 4px;
  flex-shrink: 0;
  background-color: #cbd5e0;
  /* Fallback color if variable missing */
}

/* 4 players - narrow boards */
.multiplayer-game-area.infinity-lms.players-4 {
  display: grid;
  grid-template-columns: repeat(4, max-content);
  gap: 12px;
  justify-content: center;
  align-items: center;
}

.multiplayer-game-area.infinity-lms.players-4 .player-card {
  max-height: 80vh;
}

/* Minimap positioning in player card - OPTIMIZED for space efficiency */
.player-card.infinity-lms {
  --infinity-minimap-column: 65px;
  --infinity-minimap-gap: 8px;
  --infinity-card-padding-x: 14px;
  --infinity-card-padding-y: 12px;
  display: grid;
  grid-template-areas:
    "header header"
    "next next"
    "board minimap"
    "stats .";
  grid-template-columns: auto var(--infinity-minimap-column);
  /* Slimmer: 65px vs 90px */
  column-gap: var(--infinity-minimap-gap);
  row-gap: 6px;
  padding: var(--infinity-card-padding-y) var(--infinity-card-padding-x);
  width: max-content;
  box-sizing: border-box;
  align-items: start;
  justify-items: center;
  margin-top: 0;
}

.player-card.infinity-lms .infinity-minimap {
  grid-area: minimap;
  width: 55px !important;
  /* Slimmer: 55px vs 80px (saves 100px for 4 players) */
  height: calc(var(--board-height) + 2px) !important;
  margin: 0 !important;
  padding: 6px 3px 8px !important;
  text-align: center;
  display: grid;
  grid-template-rows: auto 1fr auto;
  align-items: center;
  justify-items: center;
  justify-self: start;
  align-self: start;
  opacity: 0.8;
  /* Read-only in local versus: a look around would pause this board alone. */
  pointer-events: none;
}

.player-card.infinity-lms .infinity-minimap canvas {
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  min-height: 0;
}

.player-card.infinity-lms .infinity-minimap .minimap-title {
  width: 100%;
  font-size: 6px !important;
  letter-spacing: 0 !important;
  line-height: 1.2;
  margin: 2px 0 6px !important;
  white-space: nowrap;
}

.player-card.infinity-lms .infinity-minimap .minimap-instruction {
  width: 100%;
  font-size: 5px !important;
  letter-spacing: 0 !important;
  line-height: 1.2;
  margin: 6px 0 0 !important;
  word-break: break-word;
}

/* Board takes main area */
.player-card.infinity-lms .player-board-wrapper {
  grid-area: board;
  justify-self: center;
}

/* Next section wrapper */
.player-card.infinity-lms .player-next-section {
  grid-area: next;
  justify-self: center;
}

/* Next piece area */
.player-card.infinity-lms .player-next-pieces {
  grid-area: next;
}

/* Stats align with board column */
.player-card.infinity-lms .player-stats-bar {
  grid-area: stats;
  justify-self: center;
}

/* Header */
.player-card.infinity-lms .player-header {
  grid-area: header;
  top: calc(-1 * var(--infinity-card-padding-y) - 1px);
  left: 50%;
  transform: translate(-50%, -50%);
}

/* ========================================
   ONLINE MULTIPLAYER (3-COLUMN LAYOUT)
   Opponents | Main Board | Info
   ======================================== */

.online-game-area {
  /* Narrower sides so the center HERO board gets the majority of the width (the
   * focused board is the star). If you change these, mirror them in clampPx() in
   * OnlineMultiplayerMode.js (hero board sizing fallback). */
  --online-opponents-width: clamp(300px, 24vw, 460px);
  --online-info-width: clamp(300px, 20vw, 440px);
  --online-opponent-board-min-width: 140px;
  --online-opponent-board-min-height: 220px;
  --round-start-accent: #4fd1c5;
  --round-start-accent-rgb: 79, 209, 197;
  display: grid;
  /* Ensure the center gets at least minmax(400px) and sides flex appropriately */
  grid-template-columns: var(--online-opponents-width) minmax(360px, 1fr) var(--online-info-width);
  grid-template-rows: 1fr;
  gap: 10px;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  padding: 16px;
  box-sizing: border-box;
  background: transparent;
  z-index: 200;
  align-items: stretch;
  /* Was center, changed to stretch so side panels can fill vertical space */
}

.online-game-area::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background:
    radial-gradient(circle at 50% 52%, rgba(var(--round-start-accent-rgb), 0.26), transparent 58%),
    radial-gradient(circle at 50% 52%, rgba(var(--round-start-accent-rgb), 0.18), transparent 72%);
  z-index: 8;
}

/* LEFT COLUMN: Opponents Panel */
.opponents-panel {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow: visible;
  height: 100%;
  min-height: 0;
  align-self: stretch;
}

.watch-controls {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  background: rgba(15, 20, 30, 0.8);
  /* Less transparent */
  border: 1px solid rgba(102, 126, 234, 0.3);
  border-radius: 10px;
  z-index: 5;
  overflow: visible;
}

.watch-controls-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.watch-controls-left,
.watch-controls-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.watch-btn {
  padding: 8px 14px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: 1px solid rgba(102, 126, 234, 0.4);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.watch-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(102, 126, 234, 0.4);
}

.watch-btn.watch-toggle.is-active {
  background: linear-gradient(135deg, #4ade80 0%, #22c55e 100%);
  border-color: rgba(74, 222, 128, 0.7);
  box-shadow: 0 3px 12px rgba(74, 222, 128, 0.35);
}

.watch-btn.watch-select-btn {
  background: rgba(30, 36, 52, 0.9);
  color: #e2e8f0;
  border-color: rgba(102, 126, 234, 0.35);
}

.watch-btn.watch-select-btn:hover {
  background: rgba(62, 70, 98, 0.85);
  border-color: rgba(102, 126, 234, 0.6);
  box-shadow: 0 3px 10px rgba(102, 126, 234, 0.35);
}

.watch-btn.watch-select-btn.is-active {
  border-color: rgba(129, 140, 248, 0.9);
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}

.watch-mode-indicator {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 2px 6px;
  border-radius: 999px;
  color: #86efac;
  border: 1px solid rgba(74, 222, 128, 0.6);
  background: rgba(34, 197, 94, 0.15);
}

.watch-mode-indicator.is-manual {
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.7);
  background: rgba(251, 191, 36, 0.12);
}

.watching-status {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.watching-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #7a8aa8;
}

.watching-count {
  font-size: 14px;
  color: #a0aec0;
  font-weight: 600;
  min-width: 32px;
  text-align: right;
}

.watch-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 4px;
  flex: 1;
  min-height: 0;
  max-height: 100%;
  align-content: stretch;
  align-items: stretch;
  justify-items: stretch;
  position: relative;
  z-index: 1;
}

/* Full-roster watch (spectator / eliminated player): show up to 8 boards instead of the
 * default 2x2. Without this the 5th–8th mini-boards overflow the fixed 2x2 grid and render
 * clipped off-screen. 2 columns x 4 rows fits the tall left watch panel. */
.watch-grid.full-roster {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(4, minmax(0, 1fr));
}

.opponent-mini-board {
  /* Dark card matching main board's aesthetic */
  background: rgba(10, 15, 25, 0.85);
  border: none;
  border-radius: 12px;
  padding: 4px 4px 2px 4px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* Center content vertically so board sits in the middle of the cell */
  justify-content: center;
  gap: 0;

  /* Fill the grid cell completely */
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;

  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow:
    inset 0 0 18px rgba(102, 126, 234, 0.08),
    0 0 20px rgba(0, 0, 0, 0.4);
  position: relative;
  overflow: hidden;
}

.opponent-grid-frame {
  display: flex;
  align-items: stretch;
  gap: 3px;
  width: auto;
  flex: 0 1 auto;
  /* Don't force-grow, let the canvas JS vars dictate natural height */
  min-width: 0;
  min-height: 0;
  position: relative;
  overflow: hidden;
  border: none;
  border-radius: 0;
  padding: 0;
  background: rgba(10, 8, 24, 0.8);
}

.opponent-garbage-meter {
  position: relative;
  flex: 0 0 10px;
  height: 100%;
  width: 100%;
  border-radius: 6px;
  background: rgba(5, 8, 14, 0.95);
  border: 1px solid rgba(102, 126, 234, 0.2);
  overflow: hidden;
  box-shadow:
    inset 0 0 10px rgba(0, 0, 0, 0.9),
    inset 0 0 3px rgba(0, 0, 0, 0.8);
  pointer-events: none;
}

.opponent-garbage-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 0;
  background: linear-gradient(to top,
      rgba(239, 68, 68, 0.8) 0%,
      rgba(249, 115, 22, 0.9) 60%,
      rgba(251, 191, 36, 1) 100%);
  box-shadow:
    inset 0 0 6px rgba(255, 255, 255, 0.4),
    0 0 12px rgba(251, 191, 36, 0.5);
  border-top: 1px solid rgba(255, 255, 255, 0.9);
  transition: height 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.opponent-garbage-segments {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 100%;
  display: flex;
  flex-direction: column-reverse;
  gap: 1px;
  padding: 2px 0;
  box-sizing: border-box;
  pointer-events: none;
}

.opponent-garbage-segment {
  width: 100%;
  border-radius: 2px;
  opacity: 0.85;
  box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.35);
}

.opponent-garbage-glow {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 100%;
  background: linear-gradient(to top, rgba(239, 68, 68, 0.3) 0%, transparent 55%);
  pointer-events: none;
}

.opponent-garbage-meter.pending {
  box-shadow: 0 0 10px rgba(251, 191, 36, 0.35);
}

.opponent-garbage-meter.warning {
  box-shadow: 0 0 14px rgba(239, 68, 68, 0.5);
}

.opponent-next-queue {
  display: flex;
  justify-content: center;
  align-items: center;
  align-self: center;
  margin-bottom: 0;
  /* Match outer width of grid-frame exactly: 
     10px (garbage) + 3px (gap) + var (canvas) + 4px (canvas borders) = var + 17px */
  width: calc(var(--mini-canvas-width-px, 80px) + 17px);
  box-sizing: border-box;
  height: auto;
  min-height: 22px;
  flex: 0 0 auto;
  /* Dark bg removed based on user request */
  background: transparent;
  border: none;
  border-radius: 8px 8px 0 0;
  padding: 4px;
}

.opponent-next-pieces {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 100%;
}

.opponent-next-piece {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  background: rgba(12, 12, 22, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.4);
  transition: transform 0.2s ease;
  flex: 0 0 auto;
}

.opponent-next-piece canvas {
  display: block;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
  width: 100% !important;
  height: 100% !important;
  object-fit: contain;
}

/* Primary/highlighted piece (first in queue) - leftmost */
.opponent-next-piece.highlight {
  width: 36px;
  height: 36px;
  opacity: 1;
  border: 1px solid rgba(139, 92, 246, 0.6);
  box-shadow:
    0 0 8px rgba(139, 92, 246, 0.35),
    inset 0 0 5px rgba(255, 255, 255, 0.05);
}

/* Secondary pieces - progressively smaller and fainter */
.opponent-next-piece:nth-child(2) {
  width: 28px;
  height: 28px;
  opacity: 0.75;
}

.opponent-next-piece:nth-child(3) {
  width: 22px;
  height: 22px;
  opacity: 0.55;
}

.opponent-mini-board:hover {
  box-shadow:
    inset 0 0 18px rgba(102, 126, 234, 0.15),
    0 0 24px rgba(102, 126, 234, 0.2);
  transform: scale(1.02);
}

.opponent-mini-board.dead {
  opacity: 0.5;
  filter: grayscale(80%);
}

/* Late joiner waiting to spawn next round — NOT eliminated. Gently dimmed with a teal cast
   (distinct from the grayscale .dead), paired with the "Next round" card. */
.opponent-mini-board.waiting {
  opacity: 0.78;
  filter: saturate(0.7) brightness(0.92);
}

.opponent-grid-frame.death-shake {
  animation: deathShake 0.45s ease-in-out;
}

.opponent-mini-board canvas {
  width: 100%;
  height: auto;
  image-rendering: pixelated;
  border-radius: 4px;
}

.opponent-mini-board canvas.opponent-grid {
  display: block;
  /* JS _handleResize() computes the max 1:2 size that fits the cell and sets these vars */
  width: var(--mini-canvas-width-px, 80px);
  height: var(--mini-canvas-height-px, 160px);
  max-width: none;
  max-height: none;
  flex: 0 0 auto;

  /* Match main board: open-ceiling, left/right/bottom borders, rounded bottom */
  border-top: none;
  border-right: 2px solid rgba(102, 126, 234, 0.45);
  border-bottom: 2px solid rgba(102, 126, 234, 0.45);
  border-left: 2px solid rgba(102, 126, 234, 0.45);
  border-radius: 0 0 8px 8px;
  box-shadow:
    inset 0 0 12px rgba(102, 126, 234, 0.1),
    0 0 10px rgba(0, 0, 0, 0.3);
}

.opponent-name {
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  color: #e2e8f0;
  margin-top: 1px;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  letter-spacing: 0.5px;
}

.opponent-frags {
  font-family: 'Space Mono', monospace;
  font-size: 9px;
  color: rgba(255, 255, 255, 0.6);
  text-align: center;
  width: 100%;
  display: block;
  margin-top: 0px;
  letter-spacing: 0.5px;
}

/* Mini avatar for opponent boards */

.opponent-frags {
  font-size: 10px;
  color: #48bb78;
  margin-top: 2px;
  text-align: center;
  padding-bottom: 12px;
  /* Pad the bottom since container no longer has padding */
}

/* CENTER COLUMN: Main Board Panel.
 * FILLS its grid track (was width:max-content, which shrank to the board and left the wide
 * center column empty) so the hero board can scale to the column and JS can measure it. The
 * board itself is sized to var(--board-width/height) and stays centered inside this panel. */
.main-board-panel {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  margin: 0;
  min-width: 0;
  position: relative;
}

/* Online multiplayer uses the same .player-card as local multiplayer.
   CSS variables (--board-width, --board-height, --player-primary, etc.)
   and inline styles are injected by OnlineMultiplayerMode.js */
.main-board-panel>.player-card {
  display: flex;
  margin-top: 0;
  /* No avatar badge in online mode */
  padding-top: 12px;
  /* Normal padding instead of avatar offset */
  max-height: calc(100vh - 20px);
  /* Prevent overflow */
}

.main-board-panel>.player-card .player-header {
  display: none !important;
  /* No avatar in online mode */
}

.main-board-panel .garbage-indicator {
  width: 20px;
  height: var(--board-height);
  background: rgba(5, 8, 14, 0.95);
  /* Deep dark background */
  border: 1px solid rgba(102, 126, 234, 0.2);
  border-radius: 6px;
  /* Slightly rounder */
  position: relative;
  overflow: hidden;
  box-shadow:
    inset 0 0 15px rgba(0, 0, 0, 0.9),
    /* Deep inner shadow */
    inset 0 0 5px rgba(0, 0, 0, 0.8);
  /* Sharp inner lip */
}

.main-board-panel .garbage-indicator .garbage-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  /* Plasma liquid look: bright core, colored edges */
  background: linear-gradient(to top,
      rgba(239, 68, 68, 0.8) 0%,
      rgba(249, 115, 22, 0.9) 60%,
      rgba(251, 191, 36, 1) 100%);
  /* Inner bright reflection and outer glow */
  box-shadow:
    inset 0 0 10px rgba(255, 255, 255, 0.4),
    0 0 20px rgba(251, 191, 36, 0.6);
  /* White-hot leading edge */
  border-top: 2px solid rgba(255, 255, 255, 0.9);
  transition: height 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  /* Bouncy liquid transition */
  height: 0;
  z-index: 1;
}

.main-board-panel .garbage-indicator .garbage-segments {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 100%;
  display: flex;
  flex-direction: column-reverse;
  gap: 1px;
  padding: 2px 0;
  box-sizing: border-box;
  z-index: 2;
  pointer-events: none;
}

.main-board-panel .garbage-indicator .garbage-segment {
  width: 100%;
  border-radius: 2px;
  opacity: 0.85;
  box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.35);
}

.main-board-panel .garbage-indicator .garbage-glow {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 100%;
  background: linear-gradient(to top, rgba(239, 68, 68, 0.3) 0%, transparent 50%);
  pointer-events: none;
  z-index: 3;
}

.main-board-panel .garbage-indicator.pending {
  box-shadow: 0 0 10px rgba(251, 191, 36, 0.35);
  animation: garbagePulse 1.2s ease-in-out infinite;
}

.main-board-panel .garbage-indicator.warning {
  box-shadow: 0 0 16px rgba(239, 68, 68, 0.5);
  animation: garbageWarning 0.8s ease-in-out infinite;
}

.main-board-panel .garbage-indicator.flash {
  animation: garbageFlash 0.5s ease-out;
}

.main-board-panel .garbage-indicator.countered {
  animation: garbageCountered 0.6s ease-out;
}

.main-board-panel .garbage-indicator.outgoing {
  animation: garbageOutgoing 0.4s ease-out;
}

@keyframes garbagePulse {

  0%,
  100% {
    border-color: rgba(102, 126, 234, 0.3);
  }

  50% {
    border-color: rgba(251, 191, 36, 0.7);
  }
}

@keyframes garbageWarning {

  0%,
  100% {
    border-color: rgba(239, 68, 68, 0.4);
  }

  50% {
    border-color: rgba(239, 68, 68, 0.9);
  }
}

@keyframes garbageFlash {
  0% {
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.9);
  }

  100% {
    box-shadow: 0 0 0 rgba(239, 68, 68, 0);
  }
}

@keyframes garbageCountered {
  0% {
    box-shadow: 0 0 18px rgba(72, 187, 120, 0.8);
  }

  100% {
    box-shadow: 0 0 0 rgba(72, 187, 120, 0);
  }
}

@keyframes garbageOutgoing {
  0% {
    box-shadow: 0 0 14px rgba(96, 165, 250, 0.8);
  }

  100% {
    box-shadow: 0 0 0 rgba(96, 165, 250, 0);
  }
}

.online-main-board {
  /* Exact single-player dimensions */
  height: var(--board-height);
  width: var(--board-width);
  background: rgba(10, 15, 25, 0.85);
  border: 2px solid rgba(102, 126, 234, 0.45);
  border-top: none;
  border-radius: 0 0 12px 12px;
  box-shadow:
    inset 0 0 18px rgba(102, 126, 234, 0.15),
    0 0 30px rgba(102, 126, 234, 0.25);
  overflow: hidden;
  position: relative;
  box-sizing: content-box;
}

/* Spectator spotlight: a watcher has no board of their own, so the main board becomes a
 * large view of ONE selected player (click a mini-board on the left to choose). */
.spectator-spotlight {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  height: 100%;
  padding: 8px 6px;
  box-sizing: border-box;
  gap: 6px;
}
.spectator-spotlight-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  flex: 0 0 auto;
  font-weight: 800;
  letter-spacing: 1px;
}
.spectator-spotlight-eye { color: #5eead4; font-size: 18px; line-height: 1; }
.spectator-spotlight-name {
  font-size: 16px;
  color: #5eead4;
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.spectator-spotlight-frags { font-size: 13px; color: #cbd5e0; opacity: 0.85; }
.spectator-spotlight-stage {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
/* Spectator spotlight = board + pending-garbage bar, laid out like the main board's
 * .player-board-wrapper (bar to the left of the board). The bar's height is set inline
 * (= the board height) by OpponentWatchManager._resizeSpotlight; it inherits the main
 * board's vertical-meter look via the shared .main-board-panel .garbage-indicator rules. */
.spectator-spotlight-board-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  max-width: 100%;
  max-height: 100%;
}
.spectator-spotlight-garbage {
  flex: 0 0 20px;
  align-self: center;
}
.spectator-spotlight-garbage .opponent-garbage-segment {
  width: 100%;
  border-radius: 2px;
  opacity: 0.85;
  box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.35);
}
/* The canvas size is set EXPLICITLY (inline px) by OpponentWatchManager._resizeSpotlight()
 * — the largest 1:2 board that fits the stage. We deliberately do NOT use aspect-ratio +
 * height:100% here: in a wide column the flex cross-axis stretch + _renderMiniBoard's
 * getBoundingClientRect feedback drove a runaway height (canvas sized by width → 2× tall →
 * overflow). Explicit px (like the mini-boards) breaks that loop. */
.spectator-spotlight-canvas {
  max-height: 100%;
  max-width: 100%;
  border-radius: 8px;
  /* OPAQUE backing: _renderMiniBoard fills the canvas at 0.6 alpha, so a translucent CSS
     background let the theme (e.g. the red planet) bleed through the big center board — the
     "blurred background" the spectator view had. An opaque backing makes it read like the
     host/peer board (which draws an opaque playfield). */
  background: #0a0f19;
  /* 2px so the selected-player colour (set inline by the spotlight onChange) reads clearly. */
  border: 2px solid rgba(102, 126, 234, 0.35);
  image-rendering: pixelated;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.spectator-spotlight-hint {
  flex: 0 0 auto;
  font-size: 11px;
  color: #cbd5e0;
  opacity: 0.6;
  text-align: center;
}
/* Highlight the mini-board currently shown in the spotlight — in the SELECTED player's colour
 * (--spotlight-color is set inline by OpponentWatchManager; falls back to teal). */
.opponent-mini-board.spotlighted {
  outline: 2px solid var(--spotlight-color, #5eead4);
  outline-offset: 1px;
  box-shadow: 0 0 16px var(--spotlight-color, #5eead4) !important;
}

/* SPECTATOR layout: a watcher has no board of their own, so the spotlight must be the STAR
 * (the focused board is largest). The board lives inside the player-card structure,
 * which is sized for a player — so under .spectating we (a) hide the local-only chrome (own
 * stats bar, NEXT queue, garbage indicator — all empty for a spectator) and (b) make the
 * board chain FILL the center column so the spotlight canvas scales up to fill it. */
#online-multiplayer-container.spectating .player-stats-bar,
#online-multiplayer-container.spectating .player-next-section,
#online-multiplayer-container.spectating #online-garbage-bar {
  display: none;
}
#online-multiplayer-container.spectating #online-player-card {
  width: 100%;
  height: 100%;
  max-height: 100%;
  padding: 0;
}
#online-multiplayer-container.spectating .player-board-wrapper,
#online-multiplayer-container.spectating .player-board-section {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  /* Clip so a transient oversize canvas can't inflate the flex chain past the column. */
  overflow: hidden;
}
#online-multiplayer-container.spectating .player-board-section {
  display: flex;
}
#online-multiplayer-container.spectating #online-main-board {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
}
/* Host/peer recolor #online-board-border to the local player; a spectator has no local player,
   so it stays the default purple (#8b5cf6) — a stray frame around the whole column. Hide it so
   the spotlight canvas's player-coloured border (set inline by the onChange) is the single clean
   frame around the board, matching the host/peer look. */
#online-multiplayer-container.spectating #online-board-border {
  display: none;
}

/* The width is now correctly set on .online-next-queue-wrapper at line ~2845 */

.online-main-board::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 10px;
  background:
    linear-gradient(110deg,
      transparent 12%,
      rgba(var(--round-start-accent-rgb), 0.94) 40%,
      transparent 70%);
  mix-blend-mode: screen;
  opacity: 0;
  transform: translateX(-130%);
  pointer-events: none;
  z-index: 3;
}

/* Force canvas to fill container exactly - matches single player approach */
.online-main-board canvas {
  display: block !important;
  width: var(--board-width) !important;
  height: var(--board-height) !important;
  margin: 0 !important;
  padding: 0 !important;
  image-rendering: crisp-edges;
  image-rendering: -moz-crisp-edges;
  image-rendering: pixelated;
  position: relative;
  z-index: 1;
}

/* Main board eliminated/death state */
.online-main-board.eliminated {
  opacity: 0.6;
  filter: grayscale(60%);
  transition: opacity 0.5s ease, filter 0.5s ease;
}

.online-main-board.eliminated canvas {
  filter: grayscale(60%);
}

.online-main-board.death-shake {
  animation: deathShake 0.45s ease-in-out;
}

@keyframes deathShake {

  0%,
  100% {
    transform: translateX(0);
  }

  20% {
    transform: translateX(-6px);
  }

  40% {
    transform: translateX(6px);
  }

  60% {
    transform: translateX(-4px);
  }

  80% {
    transform: translateX(4px);
  }
}

/* Online Multiplayer Next Queue - Mirrors single-player .player-next-pieces styling */

/* Individual next piece containers */

/* Primary/highlighted piece (first in queue) - leftmost */

/* Secondary pieces - progressively smaller and fainter */

/* Empty piece slot */

/* RIGHT COLUMN: Info Panel */
.right-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
  align-self: stretch;
  /* Stretch full height even when grid centers other items */
}

.online-scoreboard {
  background: rgba(15, 20, 30, 0.8);
  border: 1px solid rgba(102, 126, 234, 0.3);
  border-radius: 8px;
  padding: 16px;
  flex: 0 0 auto;
}

.scoreboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(102, 126, 234, 0.2);
}

.scoreboard-title {
  font-size: 14px;
  font-weight: 700;
  color: white;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.scoreboard-goal {
  font-size: 12px;
  color: #a0aec0;
}

.scoreboard-columns-header {
  display: grid;
  grid-template-columns: 24px 1fr 50px 50px 50px;
  align-items: center;
  gap: 8px;
  padding: 0 10px 6px 10px;
  margin-bottom: 6px;
  border-bottom: 1px solid rgba(102, 126, 234, 0.2);
  font-size: 11px;
  font-weight: 700;
  color: #a0aec0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.scoreboard-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.scoreboard-row {
  display: grid;
  grid-template-columns: 24px 1fr 50px 50px 50px;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: rgba(40, 45, 60, 0.4);
  border-radius: 4px;
  /* Slightly squarer for tech look */
  border-left: 3px solid var(--player-row-color, rgba(102, 126, 234, 0.4));
  /* Default fallback */
  transition: all 0.2s ease;
  font-size: 12px;
  position: relative;
  overflow: hidden;
}

/* Subtle gradient background based on player color */
.scoreboard-row::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 100%;
  background: linear-gradient(90deg, var(--player-row-color), transparent);
  opacity: 0.1;
  pointer-events: none;
  z-index: 0;
}

/* Local player highlight - emphasize more */
.scoreboard-row.local-player {
  background: rgba(102, 126, 234, 0.1);
  /* fallback */
  border-left-width: 4px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
}

.scoreboard-row.local-player::before {
  opacity: 0.15;
}

.scoreboard-row.dead {
  opacity: 0.5;
  filter: grayscale(0.8);
  border-left-color: #718096;
  /* Grey out the color strip */
}

/* Ensure content sits above the background gradient */
.scoreboard-row>* {
  position: relative;
  z-index: 1;
}

.scoreboard-row .col-rank {
  text-align: center;
  font-weight: 600;
  margin-right: -4px;
  color: #ffffff;
}

.scoreboard-row .col-name {
  font-weight: 600;
  color: #cbd5e0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 11px;
}

.scoreboard-row .col-primary {
  font-weight: 700;
  color: white;
  text-align: right;
}

.scoreboard-row .col-secondary {
  color: #a0aec0;
  text-align: right;
  font-family: monospace;
}

.scoreboard-row .col-status {
  text-align: right;
  font-size: 10px;
  text-transform: uppercase;
  color: #718096;
}

.scoreboard-row.dead .col-status {
  color: #fc8181;
}

.scoreboard-row:not(.dead) .col-status {
  color: #48bb78;
}

/* Late joiner waiting to spawn next round — teal "Waiting", NOT the red of eliminated. */
.scoreboard-row.waiting {
  opacity: 0.82;
  border-left-color: #5eead4;
}

.scoreboard-row.waiting .col-status {
  color: #5eead4;
}

.online-kill-feed {
  background: rgba(15, 20, 30, 0.8);
  border: 1px solid rgba(102, 126, 234, 0.3);
  border-radius: 8px;
  padding: 16px;
  flex: 1 1 0;
  min-height: 80px;
  overflow-y: auto;
  /* Firefox: thin accent scrollbar matching the Serenity Hub / Settings design language. */
  scrollbar-width: thin;
  scrollbar-color: rgba(102, 126, 234, 0.62) rgba(0, 0, 0, 0.12);
}

/* Battle Log scrollbar — Serenity design language (accent → lavender gradient thumb on a
 * subtle dark track), matching the Serenity Hub and Settings modal instead of the grey default. */
.online-kill-feed::-webkit-scrollbar {
  width: 7px;
}
.online-kill-feed::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.12);
  border-radius: 7px;
}
.online-kill-feed::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(102, 126, 234, 0.80), rgba(142, 162, 255, 0.55));
  border: 1px solid rgba(8, 10, 23, 0.55);
  border-radius: 7px;
}
.online-kill-feed::-webkit-scrollbar-thumb:hover {
  background: rgba(102, 126, 234, 0.95);
}

.kill-feed-header {
  font-size: 12px;
  font-weight: 700;
  color: #a0aec0;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
}

.kill-feed-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kill-feed-item {
  font-size: 12px;
  color: #cbd5e0;
  padding: 6px 8px;
  background: rgba(40, 45, 60, 0.3);
  border-radius: 4px;
  animation: slideInKill 0.3s ease-out;
}

.kill-feed-item.expiring {
  animation: slideInKill 0.3s ease-out, killFadeOut 1s ease-out forwards;
}

@keyframes slideInKill {
  from {
    transform: translateX(-20px);
    opacity: 0;
  }

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

@keyframes killFadeOut {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
    transform: translateX(-8px);
  }
}

.kill-feed-item .killer {
  color: #48bb78;
  font-weight: 600;
}

.kill-feed-item .victim {
  color: #fc8181;
  font-weight: 600;
}

/* Round divider in the transactional (cross-round) Battle Log. */
.kill-feed-item.round-divider {
  background: transparent;
  text-align: center;
  color: #94a3b8;
  font-weight: 700;
  letter-spacing: 1px;
  opacity: 0.8;
  padding: 8px 4px 2px;
  animation: none;
}

/* Scoreboard overlay (TAB) */
.scoreboard-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 15, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  opacity: 1;
  transition: opacity 0.2s ease;
}

.scoreboard-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.scoreboard-overlay-panel {
  width: min(640px, 90vw);
  background: rgba(12, 18, 32, 0.92);
  border: 1px solid rgba(102, 126, 234, 0.4);
  border-radius: 12px;
  padding: 18px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.scoreboard-overlay-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 10px;
  margin-bottom: 12px;
  border-bottom: 1px solid rgba(102, 126, 234, 0.2);
}

.scoreboard-overlay-title {
  font-size: 14px;
  font-weight: 700;
  color: white;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.scoreboard-overlay-goal {
  font-size: 12px;
  color: #a0aec0;
}

.scoreboard-overlay-table {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.scoreboard-overlay-row {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 80px 90px 90px;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: rgba(40, 45, 60, 0.4);
  border-radius: 6px;
  font-size: 13px;
  color: #cbd5e0;
}

.scoreboard-overlay-row.header {
  background: rgba(30, 35, 50, 0.7);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.6px;
  color: #a0aec0;
}

.scoreboard-overlay-row.local-player {
  border: 1px solid rgba(102, 126, 234, 0.5);
  background: rgba(102, 126, 234, 0.2);
}

.scoreboard-overlay-row.dead {
  opacity: 0.5;
}

/* Late joiner waiting to spawn — teal, distinct from eliminated. */
.scoreboard-overlay-row.waiting {
  opacity: 0.82;
}

.scoreboard-overlay-row.waiting .col-status {
  color: #5eead4;
}

.scoreboard-overlay-row .col-primary,
.scoreboard-overlay-row .col-secondary,
.scoreboard-overlay-row .col-status,
.scoreboard-overlay-row .col-rank {
  text-align: right;
}

.scoreboard-overlay-row .col-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.online-chat {
  background: rgba(15, 20, 30, 0.8);
  border: 1px solid rgba(102, 126, 234, 0.3);
  border-radius: 8px;
  padding: 12px;
  flex: 1;
  min-height: 200px;
  display: flex;
  flex-direction: column;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  margin-bottom: 8px;
  font-size: 12px;
  color: #cbd5e0;
  padding: 8px;
}

/* Nice chat message styling - matches lobby */
.chat-message {
  padding: 8px 10px;
  margin-bottom: 6px;
  background: rgba(0, 255, 255, 0.05);
  border-radius: 6px;
  color: #e0e7ff;
  font-size: 13px;
  line-height: 1.4;
  animation: chatMessageSlideIn 0.3s ease;
  word-break: break-word;
}

.chat-message .color-indicator {
  display: inline-block;
  width: 4px;
  height: 14px;
  border-radius: 2px;
  margin-right: 8px;
  vertical-align: middle;
  box-shadow: 0 0 6px currentColor;
  flex-shrink: 0;
}

.chat-message .author {
  font-weight: 600;
  color: #a78bfa;
  margin-right: 6px;
}

.chat-message .text {
  color: #e0e7ff;
}

.chat-message.system-message {
  padding: 10px;
  margin-bottom: 8px;
  background: rgba(139, 92, 246, 0.1);
  border-left: 3px solid rgba(139, 92, 246, 0.5);
  border-radius: 6px;
  color: #c4b5fd;
  font-size: 12px;
  font-style: italic;
}

@keyframes chatMessageSlideIn {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }

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

/* Lobby/Results compatible message styles */
.system-message {
  padding: 10px;
  margin-bottom: 8px;
  background: rgba(139, 92, 246, 0.1);
  border-left: 3px solid rgba(139, 92, 246, 0.5);
  border-radius: 6px;
  color: #c4b5fd;
  font-size: 12px;
  animation: chatMessageSlideIn 0.3s ease;
}

.player-message {
  padding: 8px 10px;
  margin-bottom: 6px;
  background: rgba(0, 255, 255, 0.05);
  border-radius: 6px;
  color: #e0e7ff;
  font-size: 13px;
  line-height: 1.4;
  animation: chatMessageSlideIn 0.3s ease;
  word-break: break-word;
}

.player-message .color-indicator {
  display: inline-block;
  width: 4px;
  height: 14px;
  border-radius: 2px;
  margin-right: 8px;
  vertical-align: middle;
  box-shadow: 0 0 6px currentColor;
  flex-shrink: 0;
}

.player-message .author {
  font-weight: 600;
  margin-right: 6px;
}

.player-message .text {
  color: #e0e7ff;
}

.chat-input-area {
  display: flex;
  gap: 8px;
  padding-right: 75px;
  /* Clear space for bottom-right toolbar (settings, serenity hub) */
}

.chat-input-area input {
  flex: 1;
  background: rgba(40, 45, 60, 0.8);
  border: 1px solid rgba(102, 126, 234, 0.3);
  border-radius: 6px;
  padding: 8px 10px;
  color: white;
  font-size: 12px;
}

.chat-input-area input:focus {
  outline: none;
  border-color: rgba(102, 126, 234, 0.6);
}

.chat-send-btn {
  padding: 8px 12px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.chat-send-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

/* Responsive adjustments for online multiplayer */
@media (max-width: 1200px) {
  .online-game-area {
    --online-opponents-width: 220px;
    --online-info-width: 260px;
    --online-opponent-board-min-width: 160px;
    --online-opponent-board-min-height: 210px;
    gap: 12px;
    padding: 12px;
  }

  .online-main-board {
    width: 280px;
    height: 560px;
  }

  .main-board-panel .garbage-indicator {
    height: 560px;
  }
}

@media (max-width: 900px) {
  .online-game-area {
    --online-opponent-board-min-width: 110px;
    --online-opponent-board-min-height: 100px;
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
    gap: 10px;
    padding: 10px;
  }

  .opponents-panel {
    flex-direction: row;
    max-height: 120px;
  }

  .watch-controls-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .watch-controls-right {
    width: 100%;
    justify-content: space-between;
  }

  .watch-grid {
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: minmax(0, 1fr);
  }

  .watch-grid.full-roster {
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(2, minmax(0, 1fr));
  }

  .right-panel {
    flex-direction: row;
    max-height: 150px;
  }

  .online-scoreboard,
  .online-kill-feed,
  .online-chat {
    flex: 1;
  }
}

/* Opponent Selection Popup */

.opponent-selection-popup {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  width: auto;
  max-height: min(70vh, 560px);
  background: rgba(15, 20, 30, 0.95);
  border: 1px solid rgba(102, 126, 234, 0.4);
  border-radius: 10px;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.5);
  z-index: 120;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  pointer-events: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.opponent-selection-popup.hidden {
  display: none;
}

.opponent-selection-popup .selection-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.opponent-selection-popup .selection-title {
  font-size: 12px;
  font-weight: 700;
  color: #e2e8f0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.opponent-selection-popup .selection-hint {
  font-size: 11px;
  color: #94a3b8;
}

.opponent-selection-popup .selection-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 2px;
}

.opponent-selection-popup .selection-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.opponent-selection-popup .selection-group-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #a0aec0;
  text-transform: uppercase;
}

.opponent-selection-popup .opponent-selection-item {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: rgba(28, 34, 48, 0.8);
  border: 1px solid rgba(102, 126, 234, 0.15);
  border-radius: 8px;
  color: #e2e8f0;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

.opponent-selection-popup .opponent-selection-item:hover {
  border-color: rgba(102, 126, 234, 0.5);
  background: rgba(42, 52, 74, 0.85);
}

.opponent-selection-popup .opponent-selection-item.watched {
  border-color: rgba(74, 222, 128, 0.6);
  background: rgba(22, 101, 52, 0.25);
}

.opponent-selection-popup .opponent-selection-item.dead {
  opacity: 0.6;
  text-decoration: line-through;
}

.opponent-selection-popup .selection-toggle {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1px solid rgba(148, 163, 184, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #e2e8f0;
  background: rgba(15, 20, 30, 0.6);
}

.opponent-selection-popup .opponent-selection-item.watched .selection-toggle {
  border-color: rgba(74, 222, 128, 0.7);
  color: #86efac;
}

.opponent-selection-popup .selection-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.opponent-selection-popup .selection-frags {
  color: #cbd5e0;
  font-size: 11px;
}

.opponent-selection-popup .selection-empty {
  font-size: 12px;
  color: #94a3b8;
  padding: 6px 2px;
}

.opponent-selection-popup .selection-footer {
  font-size: 11px;
  color: #94a3b8;
}

