:root {
  --bg: #0d0b08;
  --bg-soft: #151208;
  --panel: #171309;
  --panel-edge: rgba(180, 140, 65, 0.38);
  --text: #eadfc7;
  --muted: #bfae8a;
  --gold: #c8a05d;
  --gold-bright: #e2be79;
  --accent: #8e5f2d;
  --shadow: rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html {
  overflow-y: scroll;
}

html, body {
  margin: 0;
  min-height: 100%;
  background: #0d0b08;
  color: var(--text);
  font-family: "Libre Baskerville", serif;
}

a { color: inherit; text-decoration: none; }

.site-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 20px 0 60px;
}

/* ── topbar ── */
.hero, .subhero { padding-bottom: 24px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding: 14px 20px;
  border: 1px solid var(--panel-edge);
  background: var(--panel);
  box-shadow: none;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: "Cinzel", serif;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--gold-bright);
  flex-shrink: 0;
}

.brand-mark { display: none; }

.nav-links {
  display: flex;
  align-items: center;
  gap: 20px;
  color: var(--muted);
  font-size: 0.95rem;
}

.nav-links a[aria-current="page"] { color: var(--gold-bright); }

/* ── buttons ── */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 20px;
  border-radius: 3px;
  border: 1px solid var(--panel-edge);
  font-weight: 700;
  font-family: inherit;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.button:hover {
  transform: translateY(-1px);
  border-color: rgba(226, 190, 121, 0.8);
}

.button.primary {
  background: linear-gradient(180deg, #d4ad6c 0%, #9f7336 100%);
  color: #1e1208;
  border-color: transparent;
}

.button.secondary {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.nav-btn {
  min-height: 36px;
  padding: 0 14px;
  font-size: 0.88rem;
}

/* ── hero / subhero cards ── */
.hero-card, .subhero-card, .panel {
  border: 1px solid var(--panel-edge);
  background: var(--panel);
  box-shadow: 0 24px 48px var(--shadow);
}

.hero-card {
  padding: 44px 40px;
  min-height: 400px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: var(--panel);
}

.subhero-card {
  padding: 32px 36px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--gold-bright);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
}

h1, h2 {
  margin: 0 0 14px;
  font-family: "Cinzel", serif;
  font-weight: 700;
}

h1 { font-size: clamp(2.2rem, 5vw, 3.8rem); line-height: 1.05; }
h2 { font-size: 1.35rem; }

.lead { color: var(--muted); line-height: 1.75; margin: 0 0 4px; }

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 26px;
}

/* ── status grid ── */
.status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 30px;
}

.status-grid article {
  padding: 16px;
  border: 1px solid rgba(200, 160, 93, 0.18);
  background: rgba(255, 255, 255, 0.02);
}

.label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* ── main content ── */
.content { display: grid; gap: 18px; }

.panel { padding: 28px; }

.intro {
  display: grid;
  gap: 24px;
  grid-template-columns: 1.4fr 1fr;
}

.intro p { color: var(--muted); line-height: 1.75; margin: 0 0 14px; }
.intro p:last-child { margin: 0; }

.feature-list {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 2;
}

/* ── hiscores controls ── */
.hiscores-controls {
  padding: 0;
  overflow: hidden;
}

.search-wrap {
  display: grid;
  gap: 8px;
  padding: 18px 20px;
  color: var(--muted);
  border-bottom: 1px solid rgba(200, 160, 93, 0.12);
}

.search-wrap input {
  width: 100%;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--panel-edge);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
}

.search-wrap input:focus { outline: 1px solid var(--gold); }

/* ── hiscores two-column layout ── */
.hiscores-layout {
  display: grid;
  grid-template-columns: 178px 1fr;
  gap: 18px;
  align-items: start;
}

.skill-sidebar {
  border: 1px solid var(--panel-edge);
  background: var(--panel);
  box-shadow: 0 24px 48px var(--shadow);
  position: sticky;
  top: 20px;
  overflow: hidden;
}

.skill-sidebar-hdr {
  padding: 10px 14px;
  background: rgba(200, 160, 93, 0.1);
  border-bottom: 1px solid var(--panel-edge);
  color: var(--gold-bright);
  font-family: "Cinzel", serif;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  text-align: center;
}

#skill-list { display: flex; flex-direction: column; }

.skill-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 13px;
  border: none;
  border-bottom: 1px solid rgba(200, 160, 93, 0.07);
  border-left: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.86rem;
  cursor: pointer;
  text-align: left;
  transition: background 80ms, color 80ms;
}

.skill-btn:hover {
  background: rgba(255, 255, 255, 0.035);
  color: var(--text);
}

.skill-btn.active {
  background: rgba(200, 160, 93, 0.1);
  color: var(--gold-bright);
  border-left-color: var(--gold);
}

.skill-btn-icon {
  width: 20px;
  height: 20px;
  image-rendering: pixelated;
  flex-shrink: 0;
  object-fit: contain;
}

.hiscores-right { display: grid; gap: 18px; }

/* ── search (standalone, no tabs) ── */
.hiscores-search {
  padding: 0;
}

.hiscores-search .search-wrap {
  padding: 14px 18px;
  border-bottom: none;
}

/* ── hiscores heading ── */
.hiscores-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 18px;
  border-bottom: 1px solid rgba(200, 160, 93, 0.15);
  background: rgba(200, 160, 93, 0.06);
  color: var(--gold-bright);
  font-family: "Cinzel", serif;
  font-size: 0.92rem;
  letter-spacing: 0.06em;
}

.hiscores-heading img {
  width: 20px;
  height: 20px;
  image-rendering: pixelated;
  object-fit: contain;
}

/* ── hiscores table ── */
.hiscores-panel {
  padding: 0;
  overflow: hidden;
}

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

.hiscores-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.hiscores-table th:nth-child(1) { width: 60px; }   /* Rank */
.hiscores-table th:nth-child(2) { width: 175px; }  /* Player — capped, ~16 char max */
.hiscores-table th:nth-child(3) { width: 200px; }  /* Total Level */
.hiscores-table th:nth-child(4) { width: 240px; }  /* Total XP */

.hiscores-table th { white-space: nowrap; }

.hiscores-table th,
.hiscores-table td {
  padding: 13px 18px;
  border-bottom: 1px solid rgba(200, 160, 93, 0.1);
  text-align: left;
}

.hiscores-table th {
  color: var(--gold-bright);
  font-family: "Cinzel", serif;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.03);
}

.player-row {
  cursor: pointer;
  transition: background 80ms;
}

.player-row:hover td { background: rgba(255, 255, 255, 0.025); }

.player-row.expanded td {
  background: rgba(200, 160, 93, 0.06);
  border-bottom: none;
}

.player-name {
  color: var(--gold-bright);
  font-weight: 700;
}

/* ── player detail (expanded) ── */
.player-detail td {
  padding: 0;
  background: rgba(200, 160, 93, 0.03);
  border-bottom: 1px solid rgba(200, 160, 93, 0.12);
}

.detail-inner {
  padding: 14px 18px 18px;
}

.detail-totals {
  display: flex;
  gap: 24px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.88rem;
}

.detail-totals strong { color: var(--gold-bright); }

.skill-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 5px;
}

.skill-cell {
  display: grid;
  grid-template-columns: 20px 1fr auto auto;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border: 1px solid rgba(200, 160, 93, 0.1);
  background: rgba(255, 255, 255, 0.02);
  font-size: 0.82rem;
}

.skill-icon {
  width: 18px;
  height: 18px;
  image-rendering: pixelated;
  object-fit: contain;
}

.skill-name { color: var(--muted); }

.skill-level {
  color: var(--gold-bright);
  font-weight: 700;
  min-width: 22px;
  text-align: right;
}

.skill-xp {
  color: var(--muted);
  font-size: 0.75rem;
  min-width: 68px;
  text-align: right;
}

/* ── responsive ── */
@media (max-width: 820px) {
  .site-shell {
    width: min(100% - 20px, 1120px);
    padding-top: 10px;
  }

  .topbar, .hero-card, .subhero-card, .panel {
    padding-left: 16px;
    padding-right: 16px;
  }

  .status-grid, .intro { grid-template-columns: 1fr; }

  .hero-card { padding-top: 32px; padding-bottom: 32px; }

  .skill-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }

  /* hiscores: stack sidebar above table on mobile */
  .hiscores-layout {
    grid-template-columns: 1fr;
  }

  .skill-sidebar {
    position: static;
  }

  #skill-list {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0;
  }

  .skill-btn {
    border-left: none;
    border-bottom: 2px solid transparent;
    padding: 7px 10px;
    font-size: 0.8rem;
    gap: 5px;
  }

  .skill-btn.active {
    border-bottom-color: var(--gold);
    border-left-color: transparent;
  }
}

/* ── player lookup form (flex — used on both hiscores + player pages) ── */
.player-lookup-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
}

.lookup-label {
  color: var(--muted);
  font-size: 0.88rem;
  flex-shrink: 0;
}

.lookup-row {
  display: flex;
  flex: 1;
  gap: 8px;
  min-width: 200px;
}

.lookup-row input {
  flex: 1;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--panel-edge);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
}

.lookup-row input:focus { outline: 1px solid var(--gold); }

.lookup-row .button { min-height: 40px; padding: 0 16px; }

/* ── player layout: stats table left, search card right ── */
.player-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 18px;
  align-items: start;
}

/* ── player search card (right column, stacked block) ── */
.player-search-card {
  display: grid;
  gap: 10px;
  padding: 18px;
  align-content: start;
}

.player-search-card .lookup-label {
  color: var(--muted);
  font-size: 0.85rem;
}

.player-search-card input {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--panel-edge);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
}

.player-search-card input:focus { outline: 1px solid var(--gold); }

.player-search-card .button { width: 100%; justify-content: center; }

/* ── player stats table ── */
.stats-table th:nth-child(1) { width: 35%; }    /* Skill */
.stats-table th:nth-child(2) { width: 20%; }    /* Rank */
.stats-table th:nth-child(3) { width: 15%; }    /* Level */
.stats-table th:nth-child(4) { width: 30%; }    /* XP */

.stat-skill-col {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stat-skill-col .skill-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* ── row flash highlight (player page) ── */
@keyframes row-flash {
  0%   { background: rgba(200, 160, 93, 0.22); }
  100% { background: transparent; }
}

.row-flash td { animation: row-flash 1.2s ease forwards; }

/* ── back link in eyebrow ── */
.back-link { color: var(--muted); }
.back-link:hover { color: var(--gold-bright); }

/* ── hiscores player row ── */
.player-row { cursor: pointer; }
.player-row:hover td { background: rgba(255, 255, 255, 0.025); }
.player-name a { color: var(--gold-bright); font-weight: 700; text-decoration: none; }
.player-name a:hover { text-decoration: underline; }

/* ── homepage screenshot ── */
.screenshot-panel {
  border: 1px solid var(--panel-edge);
  overflow: hidden;
  line-height: 0;
}

.screenshot-panel img {
  width: 100%;
  display: block;
  object-fit: cover;
}

/* ── homepage discord section (kept for reference) ── */
.discord-section {
  display: flex;
  align-items: center;
  gap: 32px;
  padding: 28px;
}

.discord-text h2 { margin: 0 0 10px; }
.discord-text p { color: var(--muted); margin: 0 0 18px; line-height: 1.65; }

.discord-image {
  flex: 1;
  min-height: 180px;
  border: 1px solid rgba(200, 160, 93, 0.1);
  background: rgba(255,255,255,0.015);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.82rem;
}

.discord-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
