html {
  max-width: 100%;
  overflow-x: auto;
}

body {
  background: #050814;
  color: #f5f5f5;
  font-family: Arial, sans-serif;
  margin: 0;
  padding: 20px;
  overflow-x: auto;
}

/* Top back link */
.back-top {
  display: block;
  text-align: left;
  margin-bottom: 8px;
  color: #888;
  text-decoration: none;
  font-size: 0.9rem;
}
.back-top:hover {
  color: #ccc;
}

h1 {
  text-align: center;
  margin-bottom: 6px;
}
.subtitle {
  text-align: center;
  color: #b0b0b0;
  margin-bottom: 8px;
  font-size: 0.95rem;
}
.updated {
  text-align: center;
  color: #777;
  font-size: 0.8rem;
  margin-bottom: 6px;
}

/* Discord + Donate buttons */
.top-buttons {
  text-align: center;
  margin-bottom: 10px;
}
.top-buttons a {
  display: inline-block;
  padding: 8px 16px;
  margin: 4px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: bold;
  text-decoration: none;
  border: 1px solid #3b4f7d;
  background: #1a2744;
  color: #f5f5f5;
  cursor: pointer;
}
.top-buttons a:hover {
  background: #243660;
}
.top-buttons .btn-discord {
  border-color: #5865f2;
}
.top-buttons .btn-donate {
  border-color: #f59e0b;
}

.controls {
  text-align: center;
  margin-bottom: 8px;
}
.controls input,
.controls select,
.controls label {
  font-size: 0.9rem;
}
.controls input,
.controls select {
  padding: 6px 8px;
  margin: 4px;
  background: #111626;
  border: 1px solid #3b4f7d;
  color: #f5f5f5;
  border-radius: 4px;
}
.controls .checkbox-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
  color: #b0b0b0;
}
.controls button {
  padding: 6px 12px;
  margin: 4px;
  background: #1a2744;
  border: 1px solid #3b4f7d;
  color: #f5f5f5;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
}
.controls button:hover {
  background: #243660;
}

.planet-buttons,
.prof-buttons {
  text-align: center;
  margin-bottom: 8px;
}
.planet-buttons button,
.prof-buttons button {
  padding: 4px 10px;
  margin: 2px;
  font-size: 0.8rem;
  background: #111626;
  border: 1px solid #3b4f7d;
  color: #f5f5f5;
  border-radius: 4px;
  cursor: pointer;
}
.planet-buttons button:hover,
.prof-buttons button:hover {
  background: #243660;
}
.planet-buttons button.active,
.prof-buttons button.active {
  background: #3b4f7d;
  font-weight: bold;
}

.mobile-tip {
  text-align: center;
  font-size: 0.8rem;
  color: #888;
  margin-bottom: 8px;
}

/* DESKTOP TABLE SCROLL AREA – both bars visible */
.table-wrapper {
  position: relative;
  overflow: auto; /* X & Y */
  padding-bottom: 10px;
  width: 100%;
  max-width: 100%;
  max-height: calc(100vh - 260px); /* keeps horizontal bar in view */
  box-sizing: border-box;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  min-width: 900px;
}
th,
td {
  border: 1px solid #333;
  padding: 4px 6px;
  text-align: center;
  white-space: nowrap;
  background: #050814;
}
th {
  background: linear-gradient(to bottom, #1a2744, #111626);
  position: sticky;
  top: 0;
  z-index: 3;
  cursor: pointer;
}
th.sortable::after {
  content: " ⇅";
  font-size: 0.7rem;
  color: #999;
}
th.sorted-asc::after {
  content: " ↑";
  color: #fff;
}
th.sorted-desc::after {
  content: " ↓";
  color: #fff;
}
tr:nth-child(even) td {
  background: #111626;
}

.sticky-col {
  position: sticky;
  left: 0;
  z-index: 2;
}
.sticky-col.col-2 {
  left: 140px;
}
.sticky-col.col-3 {
  left: 280px;
}
.sticky-col.col-4 {
  left: 420px;
}
th.sticky-col {
  z-index: 4;
}

.stat-high {
  color: #7cfc7c;
  font-weight: bold;
}
.stat-mid {
  color: #ffd966;
}
.stat-low {
  color: #ff7f7f;
}

.prof-focus {
  background: #262654 !important;
  border: 1px solid #00e5ff !important;
  box-shadow: 0 0 8px rgba(0, 229, 255, 0.9) inset;
}

.back {
  display: block;
  margin-top: 14px;
  text-align: center;
  color: #888;
  text-decoration: none;
  font-size: 0.9rem;
}
.back:hover {
  color: #ccc;
}

.empty {
  text-align: center;
  margin-top: 20px;
  color: #888;
  font-size: 0.9rem;
}

/* DETAIL PANEL (Galaxy Harvester style) */
.detail-panel {
  margin-top: 12px;
  background: #090f1e;
  border: 1px solid #3b4f7d;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.8rem;
}
.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.detail-title-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.detail-name {
  font-weight: bold;
  font-size: 0.95rem;
  color: #e5e5e5;
}
.detail-class {
  font-size: 0.8rem;
  color: #9ca3af;
}
.detail-close {
  border: 1px solid #3b4f7d;
  background: #111626;
  color: #f5f5f5;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.75rem;
  cursor: pointer;
}
.detail-close:hover {
  background: #243660;
}
.detail-planets {
  font-size: 0.78rem;
  color: #d1d5db;
  margin-bottom: 6px;
}
.detail-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 6px;
}
.detail-badge {
  padding: 2px 6px;
  border-radius: 999px;
  background: #111626;
  border: 1px solid #3b4f7d;
  font-size: 0.7rem;
  color: #d1d5db;
}
.detail-badge-key {
  border-color: #00e5ff;
  color: #e0f2fe;
}
.detail-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 4px;
}
.detail-stat {
  font-size: 0.75rem;
  color: #cbd5f5;
}
.detail-stat span.label {
  color: #9ca3af;
}
.detail-meta {
  font-size: 0.72rem;
  color: #9ca3af;
  margin-top: 2px;
}

/* MOBILE CARD LAYOUT */
.cards-container {
  display: none;
  margin-top: 8px;
}
.resource-card {
  background: #090f1e;
  border: 1px solid #3b4f7d;
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 8px;
  font-size: 0.8rem;
}
.card-header-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.card-name {
  font-weight: bold;
  font-size: 0.9rem;
  color: #e5e5e5;
}
.card-class {
  font-size: 0.78rem;
  color: #b0b0b0;
}
.card-planets {
  font-size: 0.75rem;
  color: #9ca3af;
  margin-bottom: 4px;
}
.card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 6px;
}
.card-badge {
  padding: 2px 6px;
  border-radius: 999px;
  background: #111626;
  border: 1px solid #3b4f7d;
  font-size: 0.7rem;
  color: #d1d5db;
}
.card-badge-key {
  border-color: #00e5ff;
  color: #e0f2fe;
}
.card-stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}
.card-stat {
  font-size: 0.75rem;
  color: #cbd5f5;
}
.card-stat span.label {
  color: #9ca3af;
}
.card-time {
  margin-top: 4px;
  font-size: 0.72rem;
  color: #9ca3af;
}

/* Mobile tweaks */
@media (max-width: 768px) {
  body {
    padding: 10px;
  }
  .subtitle,
  .updated {
    padding: 0 8px;
  }
  .table-wrapper {
    margin-top: 8px;
    -webkit-overflow-scrolling: touch;
    max-height: none; /* let it grow; cards are primary UX here */
  }
  .detail-panel {
    margin-top: 10px;
  }
}

@media (max-width: 600px) {
  .top-buttons a {
    display: block;
    width: 100%;
    max-width: 260px;
    margin: 4px auto;
  }

  .controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
  }
  .controls input,
  .controls select,
  .controls button {
    width: 48%;
    box-sizing: border-box;
    margin: 2px 1%;
  }
  .controls .checkbox-wrap {
    width: 100%;
    justify-content: center;
    margin-left: 0;
    margin-top: 4px;
  }

  .planet-buttons button,
  .prof-buttons button {
    padding: 6px 10px;
    font-size: 0.78rem;
  }

  table {
    font-size: 0.75rem;
  }
  th,
  td {
    padding: 3px 4px;
  }
}
