:root {
  --bg-color: #0f172a;
  --card-bg: rgba(30, 41, 59, 0.7);
  --accent: #38bdf8;
  --text-main: #f1f5f9;
  --text-dim: #94a3b8;
  --online: #22c55e;
  --afk: #f59e0b;
  --offline: #ef4444;
}

body {
  background: radial-gradient(circle at top right, #1e293b, #0f172a);
  color: var(--text-main);
  font-family: 'Inter', -apple-system, sans-serif;
  margin: 0;
  min-height: 100vh;
}

.dashboard-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}

/* Header & Status */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 1rem;
  margin-bottom: 2rem;
}

.header-content {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

h1 {
  margin: 0;
  font-size: 1.5rem;
}

.server-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-dim);
  background: rgba(0, 0, 0, 0.2);
  padding: 5px 12px;
  border-radius: 20px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--offline);
  box-shadow: 0 0 5px var(--offline);
  transition: all 0.3s;
}

.status-dot.live {
  background: var(--online);
  box-shadow: 0 0 8px var(--online);
}

.status-dot.loading {
  background: var(--afk);
  box-shadow: 0 0 8px var(--afk);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% {
    opacity: 0.5;
  }

  50% {
    opacity: 1;
  }

  100% {
    opacity: 0.5;
  }
}

/* Controls */
.control-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
}

.control-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* --- TABLE STYLING --- */
#table-container {
  overflow-x: auto;
  /* Allows scrolling sideways for many columns */
  border-radius: 12px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

table {
  width: 100%;
  border-collapse: separate;
  /* Required for sticky to work with spacing */
  border-spacing: 0 4px;
  /* Space between rows */
  min-width: 800px;
  /* Ensure table doesn't crush on small screens */
}

/* --- HEADERS --- */
th {
  text-align: left;
  padding: 15px 12px;
  color: var(--accent);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  cursor: pointer;
  user-select: none;
  background: #0f172a;
  /* Match background so stats disappear behind it */
  position: sticky;
  top: 0;
  z-index: 20;
  /* Highest priority */
}

/* The 'Player' header spans 2 columns (Head + Name). Lock it to the left. */
th[data-objective="Player"] {
  left: 0;
  z-index: 30;
  /* Higher than normal headers */
  min-width: 200px;
  /* Ensure wide enough for long names */
}

/* --- ROWS & CELLS --- */
tr {
  background: var(--card-bg);
  transition: background 0.2s;
}

tr:hover {
  background: rgba(51, 65, 85, 0.9);
}

td {
  padding: 12px;
  border: none;
  color: var(--text-dim);
  white-space: nowrap;
  /* Prevent stats from wrapping */
}

/* --- LOCKED COLUMNS (Head & Name) --- */

/* 1. The Head Column (Skin) */
td.skin {
  width: 48px;
  min-width: 48px;
  max-width: 48px;
  padding: 0;
  box-sizing: border-box;
  /* Ensures padding doesn't increase width */

  position: sticky;
  left: 0;
  background: inherit;
  z-index: 10;
}

/* 2. The Name Column */
td[data-objective="Player"] {
  color: var(--text-main);
  font-weight: 600;
  white-space: nowrap;
  /* Forces text to stay on one line */

  /* Layout Fix: Align Status and Name side-by-side */
  display: flex;
  align-items: center;
  height: 100%;
  /* Fill the cell height */
  box-sizing: border-box;

  position: sticky;
  left: 48px;
  /* Stick exactly next to the skin column */
  background: inherit;
  z-index: 10;

  border-right: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 4px 0 8px -4px rgba(0, 0, 0, 0.5);
}

/* --- BEDROCK IDENTIFICATION (Updated) --- */
td[data-objective="Player"][data-value^="."] .status {
  display: flex;
  align-items: center;
  width: auto;
  margin-right: 8px;
  background: none;
  box-shadow: none;
}

/* Re-create the status dot */
td[data-objective="Player"][data-value^="."] .status::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}

td[data-objective="Player"][data-value^="."] .status.online::before {
  background: var(--online);
  box-shadow: 0 0 6px var(--online);
}

td[data-objective="Player"][data-value^="."] .status.offline::before {
  background: var(--offline);
  opacity: 0.5;
}

/* The Bedrock Block Icon */
td[data-objective="Player"][data-value^="."] .status::after {
  content: '';
  display: inline-block;
  width: 16px;
  height: 16px;
  image-rendering: pixelated;
  background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAABa0lEQVR4nE2SLbLsIBCFT1KjotGt0Wg0Ono0i4gelUWwiNZoNLp1axZxxalHPSTQ5+eDQ0RqrQDMDICqhhBqrb13d885q+rzPPi3ju/3O8ZYa933DcDd3X2txUtmpqo84ukhIpQJIay1AKSUSimtNTrTioqqetZaY4zUSynd9y0irbWcc2sNQCmFhu4O4GNm7j7nTCm5u4jEGMcYO7SZpZR67yJSSjlVVURCCHNOurXWOLbWYoc5J3n03o+ccykFQGttrcUmBPW/SYyx915KOUXEzMws5xxCYJNNeYNicgAngBjjFqMhI7XWeu8bKKWP67oAhBBEZM7JSCklYtiTOWdKH9d1Pc+zA6jqxsUMAHYfMzt+vx/r8l1CCDnnGCMlxhgiwttkcwLg1hiDdd39fV93V9VdiTPv+34IawuQIMcI7X1f2hLgp5TSe59zbh8AbF9rNbP9Cyn9IQF3p/AYI8Z43zfhMAmb8Ef+AR7RHDvxAF+PAAAAAElFTkSuQmCC');
  background-size: contain;
  background-repeat: no-repeat;
  opacity: 0.9;
  border: 1px solid rgba(0, 0, 0, 0.5);
  border-radius: 2px;
}

/* Images & Standard Status */
.skin img {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  vertical-align: middle;
}

.status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
  margin-right: 10px;
}

.status.online {
  background: var(--online);
  box-shadow: 0 0 6px var(--online);
}

.status.afk {
  background: var(--afk);
}

.status.offline {
  background: var(--offline);
  opacity: 0.5;
}

/* Modal & Pagination (Keep as is) */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: #1e293b;
  padding: 2rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  min-width: 300px;
  max-width: 500px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.column-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  max-height: 400px;
  overflow-y: auto;
}

.col-option {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 5px;
  border-radius: 4px;
}

.col-option:hover {
  background: rgba(255, 255, 255, 0.05);
}

.webstats-pagination {
  margin-top: 20px;
  text-align: center;
}

button.webstats-pagination {
  background: var(--accent);
  border: none;
  color: #0f172a;
  font-weight: bold;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  margin: 0 5px;
}

button.webstats-pagination:disabled {
  background: var(--text-dim);
  opacity: 0.5;
  cursor: not-allowed;
}

/* --- BEDROCK PLAYER IDENTIFICATION --- */

/* 1. Target the status container for Bedrock players (names starting with .) */
td[data-objective="Player"][data-value^="."] .status {
  display: flex;
  /* Allow side-by-side layout */
  align-items: center;
  /* Center vertically */
  width: auto;
  /* Allow expansion beyond just the dot */
  margin-right: 8px;
  /* Spacing between icon and name */
  background: none;
  /* Remove default dot background (we rebuild it below) */
  box-shadow: none;
  /* Remove default glow */
}

/* 2. Re-create the status dot (Green/Red circle) */
td[data-objective="Player"][data-value^="."] .status::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  /* Space between Dot and Bedrock Block */
}

/* Color logic for the dot */
td[data-objective="Player"][data-value^="."] .status.online::before {
  background: var(--online);
  box-shadow: 0 0 6px var(--online);
}

td[data-objective="Player"][data-value^="."] .status.offline::before {
  background: var(--offline);
  opacity: 0.5;
}

/* 3. The Bedrock Block Icon */
td[data-objective="Player"][data-value^="."] .status {
  display: inline-flex;
  align-items: center;
  width: auto;
  margin-right: 8px;
  background: none;
  box-shadow: none;
}

/* Images & Status */
.skin img {
  width: 28px;
  height: 28px;
  border-radius: 4px;
}

.status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status.online {
  background: var(--online);
  box-shadow: 0 0 6px var(--online);
}

.status.afk {
  background: var(--afk);
}

.status.offline {
  background: var(--offline);
  opacity: 0.5;
}

/* Modal Styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: #1e293b;
  padding: 2rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  min-width: 300px;
  max-width: 500px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.column-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  max-height: 400px;
  overflow-y: auto;
}

.col-option {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 5px;
  border-radius: 4px;
}

.col-option:hover {
  background: rgba(255, 255, 255, 0.05);
}

/* Pagination */
.webstats-pagination {
  margin-top: 20px;
  text-align: center;
}

button.webstats-pagination {
  background: var(--accent);
  border: none;
  color: #0f172a;
  font-weight: bold;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  margin: 0 5px;
}

button.webstats-pagination:disabled {
  background: var(--text-dim);
  opacity: 0.5;
  cursor: not-allowed;
}