/* ============================================================
   Survivors.gg Leaderboards — Dark/Blue Theme
   ============================================================ */

:root {
  --bg: #0b0a08;
  --panel: #12100c;
  --panel-2: #191611;
  --border: #2e2818;
  --border-soft: rgba(255, 255, 255, 0.05);
  --text: #f3efe6;
  --muted: #a2988a;
  --accent: #e7c14b;
  --accent-dim: #b8922e;
  --accent-grad: linear-gradient(90deg, rgba(160, 122, 24, 0.8), rgba(74, 56, 10, 0.35) 55%, rgba(74, 56, 10, 0) 100%);
  --gold: #e7c14b;
  --silver: #cdd5dc;
  --bronze: #c07a3d;
}

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

html { color-scheme: dark; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Montserrat", "Segoe UI", system-ui, sans-serif;
  font-size: 14.5px;
  line-height: 1.45;
  min-height: 100vh;
}

/* Dezente Berg-Silhouette im Hintergrund */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(160, 120, 30, 0.14), transparent 60%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1600 500' preserveAspectRatio='xMidYMax slice'%3E%3Cpath fill='%23131008' d='M0 500V320l140-90 120 70 150-120 170 110 140-70 180 130 150-90 170 60 130-100 150 120 100-60v320z'/%3E%3Cpath fill='%230e0c07' d='M0 500V400l180-80 160 60 190-110 200 100 170-60 210 90 180-70 160 50 150-80v200z'/%3E%3C/svg%3E") bottom center / cover no-repeat,
    var(--bg);
}

.page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 18px 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 100vh;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
}

/* ---------- Topbar ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 18px;
}

.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand-logo { width: 46px; height: 46px; border-radius: 50%; display: block; }
.brand-text {
  font-family: "Orbitron", sans-serif;
  font-weight: 900;
  font-size: 17px;
  letter-spacing: 1px;
  color: var(--gold);
  white-space: nowrap;
}
.brand-text em { font-style: normal; color: var(--gold); }

.server-title { flex: 1; text-align: center; min-width: 0; }
.server-title h1 {
  font-family: "Orbitron", sans-serif;
  font-weight: 900;
  font-style: italic;
  font-size: clamp(17px, 2.6vw, 26px);
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent);
  text-shadow: 0 0 22px rgba(231, 193, 75,0.35);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.server-sub {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-top: 2px;
}

/* Buttons */
.btn {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  padding: 10px 16px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.btn:hover { border-color: var(--accent-dim); box-shadow: 0 0 12px rgba(231, 193, 75,0.18); }
.btn .caret { color: var(--accent); margin-left: 4px; }

.server-select { position: relative; }
.server-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 250px;
  max-height: 60vh;
  overflow-y: auto;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  z-index: 50;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.6);
  padding: 6px;
}
.server-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 7px;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  padding: 9px 12px;
  cursor: pointer;
}
.server-menu button:hover { background: rgba(231, 193, 75,0.12); }
.server-menu button.active { background: var(--accent-grad); border: 1px solid rgba(231, 193, 75,0.35); }

/* ---------- Layout ---------- */

.layout {
  display: grid;
  grid-template-columns: 250px 1fr;
  gap: 16px;
  align-items: start;
  flex: 1;
}

/* ---------- Sidebar ---------- */

.sidebar { padding: 14px; display: flex; flex-direction: column; gap: 10px; }

.search-box { position: relative; }
#searchInput {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  font: inherit;
  padding: 10px 12px;
}
#searchInput::placeholder { color: var(--muted); }
#searchInput:focus { outline: none; border-color: var(--accent-dim); }

.suggest {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  overflow: hidden;
  z-index: 40;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
}
.suggest button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  color: var(--text);
  font: inherit;
  padding: 9px 12px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.suggest button:hover { background: rgba(231, 193, 75,0.12); }
.suggest .none { padding: 9px 12px; color: var(--muted); }

.side-btn {
  width: 100%;
  text-align: left;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  padding: 11px 14px;
  cursor: pointer;
  transition: border-color 0.15s;
  position: relative;
}
.side-btn:hover { border-color: var(--accent-dim); }
.side-btn.active {
  background: var(--accent-grad);
  border-color: rgba(231, 193, 75,0.55);
}

.side-divider { height: 1px; background: var(--border); margin: 6px 2px; }

/* ---------- Board / Tabelle ---------- */

.board { display: flex; flex-direction: column; gap: 10px; min-width: 0; }

.notice {
  background: var(--accent-grad);
  border: 1px solid rgba(231, 193, 75,0.5);
  border-radius: 10px;
  font-weight: 700;
  text-align: center;
  padding: 11px 14px;
  cursor: pointer;
}

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 7px;
  min-width: 640px;
}

thead th {
  font-family: "Montserrat", sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  text-align: right;
  padding: 4px 14px 6px;
  white-space: nowrap;
  user-select: none;
}
thead th.sortable { cursor: pointer; }
thead th.sortable:hover { color: var(--text); }
thead th.active { color: var(--accent); }
thead th .arrow { font-size: 11px; margin-left: 3px; }
thead th.rank-h, thead th.name-h { text-align: left; }

tbody tr {
  background: var(--panel);
  cursor: pointer;
}
tbody tr:hover { background: var(--panel-2); }

tbody td {
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 11px 14px;
  text-align: right;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
tbody td:first-child {
  border-left: 1px solid var(--border);
  border-radius: 9px 0 0 9px;
  text-align: left;
  font-family: "Orbitron", sans-serif;
  font-weight: 700;
  font-size: 13px;
  width: 64px;
}
tbody td:last-child {
  border-right: 1px solid var(--border);
  border-radius: 0 9px 9px 0;
}
tbody td.name-cell {
  text-align: left;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 700;
}

/* Top 3 */
tr.r1 td { border-color: rgba(231, 193, 75, 0.75); }
tr.r1 td:first-child { color: var(--gold); background: linear-gradient(90deg, rgba(231, 193, 75, 0.22), transparent); }
tr.r2 td { border-color: rgba(205, 213, 220, 0.55); }
tr.r2 td:first-child { color: var(--silver); background: linear-gradient(90deg, rgba(205, 213, 220, 0.16), transparent); }
tr.r3 td { border-color: rgba(192, 122, 61, 0.65); }
tr.r3 td:first-child { color: var(--bronze); background: linear-gradient(90deg, rgba(192, 122, 61, 0.2), transparent); }

.empty-state, .loading, .error-state {
  text-align: center;
  color: var(--muted);
  padding: 46px 0;
}
.error-state { color: #ff6b6b; }

/* ---------- Tabellen-Fuß / Pagination ---------- */

.table-foot {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 2px 4px 4px;
}

#perPage {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  padding: 7px 10px;
  cursor: pointer;
}
#perPage:focus { outline: none; border-color: var(--accent-dim); }

.showing { color: var(--muted); font-weight: 600; }

.pager { margin-left: auto; display: flex; gap: 6px; }
.pager button {
  min-width: 36px;
  height: 36px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.pager button:hover:not(:disabled) { border-color: var(--accent-dim); }
.pager button.active { background: var(--accent-dim); border-color: var(--accent-dim); color: #fff; }
.pager button:disabled { opacity: 0.35; cursor: default; }
.pager .arrow-btn { color: var(--accent); }

/* ---------- Footer ---------- */

.site-footer {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 16px 20px;
  flex-wrap: wrap;
}
.foot-brand { display: flex; align-items: center; gap: 14px; }
.foot-logo { width: 56px; height: 56px; border-radius: 50%; }
.foot-copy { font-weight: 700; }
.foot-note { color: var(--muted); font-size: 12.5px; }

.foot-links { margin-left: auto; display: flex; gap: 22px; flex-wrap: wrap; }
.foot-links a { color: var(--text); text-decoration: none; font-weight: 600; }
.foot-links a:hover { color: var(--accent); }

/* ---------- Player-Modal ---------- */

.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal.hidden, .hidden { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.75); }

.modal-panel {
  position: relative;
  background: var(--panel);
  border: 1px solid rgba(231, 193, 75,0.4);
  border-radius: 14px;
  padding: 20px;
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.7);
}

.player-head { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.player-name {
  font-family: "Orbitron", sans-serif;
  font-size: 19px;
  font-weight: 900;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.close-btn {
  margin-left: auto;
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
}
.close-btn:hover { color: var(--text); }

.player-sub { color: var(--muted); font-size: 12.5px; margin-bottom: 14px; }
.player-kd { color: var(--accent); font-weight: 700; }

.pstat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 10px;
}
.pstat {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 12px;
}
.pstat .l { color: var(--muted); font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.pstat .v { font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; margin-top: 2px; }
.pstat .r { color: var(--gold); font-size: 12px; font-weight: 700; }
.pstat .r.none { color: var(--muted); font-weight: 400; }

/* ---------- Mobile ---------- */

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; flex-wrap: wrap; }
  .search-box { flex: 1 1 100%; }
  .side-btn { flex: 1 1 auto; width: auto; text-align: center; }
  .side-divider { display: none; }

  .topbar { flex-wrap: wrap; justify-content: space-between; }
  .server-title { order: 3; flex: 1 1 100%; }

  .table-foot { flex-wrap: wrap; }
  .pager { margin-left: 0; }
  tbody td.name-cell { max-width: 150px; }
}
