/* Colors come from theme.js (CSS variables on :root). These are the defaults
   (Antique Gold on Midnight) in case the script hasn't run. */
:root {
  --bg:          #0c0f1c;
  --surface:     #141829;
  --surface-2:   #1b2036;
  --text:        #e9ebf5;
  --muted:       #9fa5c0;
  --line:        #262c45;
  --accent:      #d4b25a;
  --accent-2:    #e8cf8a;
  --accent-text: #d4b25a;
  --accent-soft: color-mix(in srgb, #d4b25a 18%, #141829);
  --on-accent:   #0b0b0b;
  --focus:       #d4b25a;
  --radius:      8px;
  --shadow:      0 1px 2px rgb(0 0 0 / 0.3), 0 12px 32px -16px rgb(0 0 0 / 0.6);
  color-scheme: dark;
}

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

html { font-size: 16px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Accessibility helpers ──────────────────────────────────────────────── */

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -3rem;
  z-index: 100;
  background: var(--accent);
  color: var(--on-accent);
  border-radius: var(--radius);
  font-weight: 600;
  padding: 0.5rem 1rem;
  text-decoration: none;
}
.skip-link:focus { top: 1rem; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}

/* ── Header ─────────────────────────────────────────────────────────────── */

header {
  background: linear-gradient(180deg, var(--accent-soft) 0%, var(--surface) 100%);
  border-bottom: 1px solid var(--line);
  padding: 1rem 1.5rem 1.75rem;
  position: relative;
  text-align: center;
}

.header-inner { max-width: 960px; margin: 0 auto; padding-top: 1.25rem; }

h1 {
  font-size: 2.1rem;
  font-weight: 700;
  color: var(--accent-text);
  letter-spacing: 0.03em;
  line-height: 1.2;
}

.subtitle {
  color: var(--muted);
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  margin-top: 0.35rem;
  text-transform: uppercase;
}

.stats {
  color: var(--text);
  font-size: 0.95rem;
  margin-top: 0.8rem;
}

/* ── Theme pickers ──────────────────────────────────────────────────────── */

.theme-pickers {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  max-width: 1100px;
  margin: 0 auto;
}

.color-chooser { position: relative; }

.color-chooser > button {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  cursor: pointer;
  display: flex;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  gap: 0.5rem;
  min-height: 2.25rem;
  padding: 0.3rem 0.8rem 0.3rem 0.4rem;
}
.color-chooser > button:hover { border-color: var(--accent); }

.swatch {
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--line);
  flex: none;
  height: 20px;
  width: 20px;
}

.color-menu {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 4px;
  grid-template-columns: repeat(4, 1fr);
  padding: 10px;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  width: min(340px, calc(100vw - 32px));
  z-index: 30;
}
.color-menu[hidden] { display: none; }

.color-menu button {
  background: transparent;
  border: 2px solid transparent;
  border-radius: 12px;
  color: var(--muted);
  cursor: pointer;
  display: grid;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  gap: 4px;
  justify-items: center;
  line-height: 1.25;
  padding: 8px 4px;
  text-align: center;
}
.color-menu button:hover { background: var(--surface-2); color: var(--text); }
.color-menu button[aria-checked="true"] { border-color: var(--accent); color: var(--text); }
.color-menu .swatch { height: 28px; width: 28px; }
.color-menu small { color: var(--muted); font-size: 0.7rem; font-weight: 500; }

/* ── Main ───────────────────────────────────────────────────────────────── */

main {
  flex: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
  width: 100%;
}

/* ── Search bar ─────────────────────────────────────────────────────────── */

.search-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.9rem;
}

input, select, button { font: inherit; }

.search-bar input {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  flex: 1;
  font-size: 1rem;
  min-height: 2.75rem;
  min-width: 200px;
  padding: 0.5rem 0.85rem;
}
.search-bar input::placeholder { color: var(--muted); opacity: 1; }
.search-bar input:focus { border-color: var(--accent); }

.search-bar button {
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: var(--on-accent);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
  min-height: 2.75rem;
  padding: 0.5rem 1.5rem;
  white-space: nowrap;
}
.search-bar button:hover { background: var(--accent-2); }

/* ── Filter row ─────────────────────────────────────────────────────────── */

.filter-row {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  margin-bottom: 0.9rem;
}

.filter { display: grid; gap: 0.25rem; }
.filter > span { color: var(--muted); font-size: 0.85rem; font-weight: 600; }

.filter select {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  font-size: 0.95rem;
  min-height: 2.5rem;
  padding: 0.4rem 0.6rem;
  width: 100%;
}
.filter select:focus { border-color: var(--accent); }

/* ── Search hint ────────────────────────────────────────────────────────── */

.search-hint {
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.9;
  margin-bottom: 0.9rem;
}

.search-hint code {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--text);
  font-family: ui-monospace, monospace;
  font-size: 0.85rem;
  padding: 1px 5px;
  white-space: nowrap;
}

/* ── Results info ───────────────────────────────────────────────────────── */

.results-info {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 0.6rem;
  min-height: 1.5em;
}

/* ── Table ──────────────────────────────────────────────────────────────── */

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow-x: auto;
}
.table-wrap:focus { outline: none; }

table {
  border-collapse: collapse;
  font-size: 0.9375rem;
  width: 100%;
}

thead th {
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  color: var(--accent-text);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 0.7rem 0.75rem;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

tbody tr { border-bottom: 1px solid var(--line); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover      { background: var(--surface-2); }

tbody td {
  padding: 0.6rem 0.75rem;
  vertical-align: top;
}

.col-char     { white-space: nowrap; }
.player-name  { color: var(--accent-text); display: block; font-weight: 600; }

.discord-copy {
  align-items: center;
  background: none;
  border: none;
  border-radius: 4px;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  font-size: 0.875rem;
  gap: 0.4rem;
  padding: 0.1rem 0;
  text-align: left;
}
.discord-copy:hover { color: var(--text); }

.copy-tag {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0 0.5rem;
}
.discord-copy:hover .copy-tag { border-color: var(--accent); }
.discord-copied .copy-tag     { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

.col-noun    { color: var(--muted); white-space: nowrap; }
.col-name    { color: var(--text); min-width: 16rem; }
.col-loc     { color: var(--muted); white-space: nowrap; }
.col-price   { white-space: nowrap; }
.col-notes   { color: var(--text); font-style: italic; max-width: 220px; }
.col-updated { color: var(--muted); white-space: nowrap; }

.price-free  {
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: 4px;
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 1px 6px;
  text-transform: uppercase;
}

.empty-state {
  color: var(--muted);
  font-style: italic;
  padding: 2.5rem !important;
  text-align: center;
}

/* ── Pagination ─────────────────────────────────────────────────────────── */

.pagination {
  align-items: center;
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin-top: 1.1rem;
}

.pagination button {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  font-size: 0.95rem;
  min-height: 2.5rem;
  padding: 0.4rem 1.1rem;
}
.pagination button:hover:not(:disabled) { background: var(--surface-2); border-color: var(--accent); }
.pagination button:disabled { cursor: default; opacity: 0.45; }
.pagination .page-info      { color: var(--muted); font-size: 0.9rem; }

/* ── Footer ─────────────────────────────────────────────────────────────── */

footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
  padding: 1.1rem 1.5rem;
  text-align: center;
}
footer strong        { color: var(--text); }
footer a             { color: var(--accent-text); }
footer a:hover       { color: var(--text); }

/* ── Small screens ──────────────────────────────────────────────────────── */

@media (max-width: 600px) {
  header      { padding: 0.75rem 1rem 1.4rem; }
  .theme-pickers { justify-content: center; }
  h1          { font-size: 1.65rem; }
  main        { padding: 1rem; }
  .filter-row { grid-template-columns: 1fr 1fr; }
}
