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

:root {
  --bg:            #0a1628;
  --surface:       #0f2040;
  --card:          #132847;
  --border:        #1e3a5f;
  --border-hover:  #2a5080;
  --accent:        #1a6b4a;
  --accent-bright: #22c55e;
  --text:          #e8f4f0;
  --text-muted:    #8fb3a0;
  --rarity-common:    #9ca3af;
  --rarity-uncommon:  #4ade80;
  --rarity-rare:      #60a5fa;
  --rarity-legendary: #c084fc;
  --rarity-mythical:  #fbbf24;
  --rarity-junk:      #6b7280;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  background-image: radial-gradient(ellipse at 50% 0%, #0f3060 0%, transparent 60%);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
}

/* ── Navigation ── */
.nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-brand { font-size: 1.1rem; font-weight: 700; color: var(--text); text-decoration: none; flex-shrink: 0; }
.nav-brand:hover { color: var(--accent-bright); }
.nav-links { display: flex; gap: 1.5rem; }
.nav-links a { color: var(--text-muted); text-decoration: none; font-size: 0.9rem; transition: color 0.15s; }
.nav-links a:hover, .nav-links a.active { color: var(--accent-bright); }
.nav-search { margin-left: auto; }
.nav-search form { display: flex; }
.nav-search input {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-family: inherit;
  width: 190px;
  outline: none;
  transition: border-color 0.15s, width 0.2s;
}
.nav-search input:focus { border-color: var(--accent-bright); width: 220px; }
.nav-search input::placeholder { color: var(--text-muted); }

/* ── Layout ── */
.container { max-width: 1100px; margin: 0 auto; padding: 2rem 1.5rem; flex: 1; }

/* ── Page header ── */
.page-header { margin-bottom: 2rem; }
.page-header h1 { font-size: 1.9rem; font-weight: 700; margin-bottom: 0.35rem; }
.page-header p { color: var(--text-muted); font-size: 0.95rem; }

/* ── Hero ── */
.hero { text-align: center; padding: 4rem 0 3rem; }
.hero h1 { font-size: 2.6rem; font-weight: 700; margin-bottom: 0.75rem; letter-spacing: -0.02em; }
.hero p { color: var(--text-muted); font-size: 1.05rem; max-width: 520px; margin: 0 auto 2rem; line-height: 1.6; }
.hero-links { display: flex; gap: 0.75rem; justify-content: center; flex-wrap: wrap; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.3rem;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  transition: opacity 0.15s, border-color 0.15s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { opacity: 0.88; }
.btn-outline { border: 1px solid var(--border); color: var(--text-muted); }
.btn-outline:hover { border-color: var(--accent-bright); color: var(--text); }

/* ── Cards ── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  transition: border-color 0.15s;
}
.card:hover { border-color: var(--border-hover); }
.card h2, .card h3 { margin-bottom: 1rem; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.card-grid .card { margin-bottom: 0; }

/* ── Guide anchor nav ── */
.guide-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 2rem;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.guide-nav a {
  font-size: 0.83rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: 3px 10px;
  border-radius: 99px;
  border: 1px solid transparent;
  transition: all 0.15s;
}
.guide-nav a:hover { color: var(--accent-bright); border-color: var(--border); background: var(--card); }

/* ── Section titles ── */
.section-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 2.5rem 0 1rem;
  color: var(--accent-bright);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.section-title:first-of-type { margin-top: 0; }

/* ── Item rows (guide lists) ── */
.item-row {
  display: flex;
  align-items: center;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
  gap: 0.75rem;
  flex-wrap: wrap;
}
.item-row:last-child { border-bottom: none; }
.item-name { font-weight: 500; flex: 1; min-width: 120px; }
.item-cost { color: var(--rarity-mythical); font-size: 0.85rem; white-space: nowrap; }
.item-bonus { color: var(--accent-bright); font-size: 0.85rem; white-space: nowrap; }
.item-desc { color: var(--text-muted); font-size: 0.85rem; flex: 2; min-width: 160px; }
.badge-locked { font-size: 0.75rem; color: var(--text-muted); background: var(--surface); padding: 2px 8px; border-radius: 99px; white-space: nowrap; border: 1px solid var(--border); }
.hint-text { color: var(--text-muted); font-size: 0.85rem; margin-top: 1rem; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.75rem 1rem;
  text-align: left;
  white-space: nowrap;
}
thead th a { color: var(--text-muted); text-decoration: none; transition: color 0.15s; }
thead th a:hover { color: var(--text); }
thead th.sort-active a { color: var(--accent-bright); }
tbody td { padding: 0.7rem 1rem; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(255,255,255,0.025); }
.rank-cell { color: var(--text-muted); width: 44px; font-size: 0.85rem; }
.rank-1 { color: var(--rarity-mythical); font-weight: 700; }
.rank-2 { color: var(--rarity-legendary); font-weight: 600; }
.rank-3 { color: var(--rarity-uncommon); font-weight: 600; }
.username-link { color: var(--text); text-decoration: none; font-weight: 500; transition: color 0.15s; }
.username-link:hover { color: var(--accent-bright); }

/* ── Rarity colours ── */
.rarity-common    { color: var(--rarity-common); }
.rarity-uncommon  { color: var(--rarity-uncommon); }
.rarity-rare      { color: var(--rarity-rare); }
.rarity-legendary { color: var(--rarity-legendary); }
.rarity-mythical  { color: var(--rarity-mythical); }
.rarity-junk      { color: var(--rarity-junk); }

/* ── Profile ── */
.profile-header { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.profile-name { font-size: 2rem; font-weight: 700; letter-spacing: -0.02em; }
.prestige-badge {
  font-size: 0.8rem;
  color: var(--rarity-mythical);
  background: rgba(251,191,36,0.1);
  border: 1px solid rgba(251,191,36,0.3);
  padding: 4px 12px;
  border-radius: 99px;
  white-space: nowrap;
}
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  margin-bottom: 1.25rem;
  transition: color 0.15s;
}
.back-link:hover { color: var(--accent-bright); }
.profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1.5rem; }
.profile-grid .card { margin-bottom: 0; }
.card-section-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 600;
  margin-bottom: 0.75rem;
}
.stat-row { display: flex; justify-content: space-between; align-items: center; padding: 0.4rem 0; border-bottom: 1px solid var(--border); font-size: 0.875rem; }
.stat-row:last-child { border-bottom: none; }
.stat-row-label { color: var(--text-muted); }
.stat-row-val { font-weight: 500; }

/* ── Pills / tags ── */
.pill { font-size: 0.82rem; background: var(--surface); padding: 3px 10px; border-radius: 99px; border: 1px solid var(--border); display: inline-block; }
.pill-effect { color: var(--accent-bright); background: rgba(34,197,94,0.08); border-color: rgba(34,197,94,0.25); }
.pill-enchant { color: var(--rarity-rare); }
.pill-achievement { color: var(--rarity-mythical); }
.pill-item { color: var(--text); }

/* ── Code ── */
code {
  font-family: 'Courier New', monospace;
  font-size: 0.875em;
  background: var(--surface);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
  color: var(--rarity-rare);
}

/* ── Commands ── */
.cmd-group { margin-bottom: 2rem; }
.cmd-group h3 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent-bright);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}
.cmd-row { display: flex; align-items: baseline; gap: 1rem; padding: 0.45rem 0; border-bottom: 1px solid var(--border); }
.cmd-row:last-child { border-bottom: none; }
.cmd-name { font-family: 'Courier New', monospace; color: var(--rarity-rare); font-size: 0.875rem; white-space: nowrap; min-width: 210px; flex-shrink: 0; }
.cmd-desc { color: var(--text-muted); font-size: 0.875rem; }

/* ── Footer ── */
.footer { padding: 1.5rem 2rem; text-align: center; color: var(--text-muted); font-size: 0.8rem; border-top: 1px solid var(--border); }

/* ── HTMX ── */
.htmx-indicator { opacity: 0; transition: opacity 0.2s; }
.htmx-request .htmx-indicator { opacity: 1; }

/* ── Card description (home page) ── */
.card-desc { color: var(--text-muted); font-size: 0.9rem; line-height: 1.6; }

/* ── Responsive ── */
@media (max-width: 700px) {
  .nav { padding: 0 1rem; gap: 1rem; }
  .nav-search { display: none; }
  .container { padding: 1.5rem 1rem; }
  .profile-grid { grid-template-columns: 1fr; }
  .cmd-name { min-width: 0; }
  .cmd-row { flex-wrap: wrap; gap: 0.25rem; }
  .hero h1 { font-size: 2rem; }
  .hero p { font-size: 0.95rem; }
  .item-row { flex-wrap: wrap; }
  .item-desc { flex: unset; width: 100%; text-align: left; }
  .section-title { font-size: 1.15rem; }
  .profile-name { font-size: 1.6rem; }
}
