/* ── Variables ─────────────────────────────────────────────── */
:root {
  --bg:        #080b10;
  --bg2:       #0d1117;
  --bg3:       #111820;
  --surface:   #141c26;
  --surface2:  #1a2434;
  --border:    rgba(180, 140, 60, 0.2);
  --border2:   rgba(180, 140, 60, 0.08);
  --gold:      #c9a84c;
  --gold2:     #e8c96a;
  --gold-dim:  rgba(201, 168, 76, 0.15);
  --red:       #c0392b;
  --green:     #27ae60;
  --text:      #d4c9b0;
  --text-dim:  rgba(212, 201, 176, 0.5);
  --text-mute: rgba(212, 201, 176, 0.3);
  --font-head: 'Cinzel', serif;
  --font-body: 'Rajdhani', sans-serif;
  --nav-h:     58px;
  --radius:    6px;
  --glow:      0 0 20px rgba(201, 168, 76, 0.15);
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Background texture ────────────────────────────────────── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(201,168,76,0.02) 0%, transparent 60%),
    url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23c9a84c' fill-opacity='0.02'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

#app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Nav ───────────────────────────────────────────────────── */
/* Mirror the main site's .header-inner pattern: full-bleed bar with the
   contents constrained to a 1320px-wide container. Brand sits at the
   container's left edge, nav-links at the right edge. */
#nav {
  height: var(--nav-h);
  background: rgba(8, 11, 16, 0.95);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(24px, calc((100% - 1320px) / 2));
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  box-shadow: 0 1px 0 var(--border2), 0 4px 24px rgba(0,0,0,0.4);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon { font-size: 20px; }

.brand-logo {
  height: 48px;
  width: auto;
  display: block;
}

.brand-name {
  font-family: var(--font-head);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--gold);
  text-shadow: 0 0 20px rgba(201,168,76,0.4);
}

.nav-links {
  display: flex;
  gap: 4px;
}

.nav-link {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  text-decoration: none;
  padding: 6px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  transition: all 0.2s;
  position: relative;
}

.nav-link:hover {
  color: var(--gold);
  background: var(--gold-dim);
  border-color: var(--border);
}

.nav-link.active {
  color: var(--gold2);
  background: var(--gold-dim);
  border-color: var(--border);
  text-shadow: 0 0 12px rgba(201,168,76,0.4);
}

/* ── Footer (mirrors main site footer.php styles, using Tower tokens) ───── */
.site-footer {
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 56px 0 0;
  position: relative;
  z-index: 2;
}

.footer-inner {
  padding: 0 max(24px, calc((100% - 1320px) / 2));
}

.footer-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr 1fr;
  gap: 40px;
  padding-bottom: 40px;
}

.footer-brand-name {
  font-family: var(--font-head);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text);
  margin: 0 0 8px;
  text-transform: uppercase;
}
.footer-brand-name span { color: var(--gold); }

.footer-tagline {
  font-size: 0.85rem;
  font-style: italic;
  color: var(--text-dim);
  margin: 0;
}

.footer-col h4 {
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-dim);
  margin: 0 0 14px;
}
.footer-col ul { list-style: none; padding: 0; margin: 0; }
.footer-col li { margin-bottom: 6px; }
.footer-col a {
  color: var(--text);
  font-size: 0.875rem;
  text-decoration: none;
  transition: color 0.15s ease;
}
.footer-col a:hover { color: var(--gold); }

.footer-bottom {
  border-top: 1px solid var(--border);
  padding: 16px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.footer-bottom p {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin: 0;
}
.footer-bottom a {
  color: var(--gold);
  text-decoration: none;
}
.footer-bottom a:hover { color: var(--gold2); }

@media (max-width: 768px) {
  .footer-grid { grid-template-columns: 1fr 1fr; gap: 24px; }
  .footer-bottom { flex-direction: column; gap: 8px; text-align: center; }
}

/* ── Pages ─────────────────────────────────────────────────── */
#main { flex: 1; }

.page { display: none; }
.page.active { display: block; animation: fadeIn 0.25s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Shared page layout ────────────────────────────────────── */
.page-wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px;
}

.page-header {
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border2);
}

.page-title {
  font-family: var(--font-head);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--gold);
  margin-bottom: 4px;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-mute);
  letter-spacing: 0.05em;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.page-header-left { flex: 1; }
.page-header-center { flex: 1; text-align: center; }
.page-header-right { flex: 1; display: flex; justify-content: flex-end; align-items: center; }
.page-bar-logo {
  font-family: var(--font-head);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--gold);
  text-transform: uppercase;
}

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 16px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.card:hover {
  border-color: var(--border);
  box-shadow: var(--glow);
}

.card-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-mute);
  margin-bottom: 6px;
}

.card-value {
  font-family: var(--font-head);
  font-size: 26px;
  font-weight: 700;
  color: var(--gold2);
}

.card-name {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: capitalize;
  color: var(--text);
  margin-bottom: 10px;
}

/* ── Grid layouts ──────────────────────────────────────────── */
.grid-auto {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.grid-auto-lg {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 12px;
}

/* ── Stats row inside card ─────────────────────────────────── */
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  border-bottom: 1px solid var(--border2);
  font-size: 13px;
}
.stat-row:last-child { border-bottom: none; }
.stat-key { color: var(--text-dim); }
.stat-val { font-weight: 600; color: var(--text); font-family: monospace; font-size: 13px; }
.stat-val.green { color: var(--green); }
.stat-val.gold  { color: var(--gold); }

/* ── Status / badge ────────────────────────────────────────── */
.badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 3px;
}
.badge-green { background: rgba(39,174,96,0.15); color: #2ecc71; border: 1px solid rgba(39,174,96,0.3); }
.badge-red   { background: rgba(192,57,43,0.15);  color: #e74c3c; border: 1px solid rgba(192,57,43,0.3); }
.badge-gold  { background: var(--gold-dim);        color: var(--gold); border: 1px solid var(--border); }

/* ── Updated label ─────────────────────────────────────────── */
.updated-label {
  font-size: 11px;
  color: var(--text-mute);
  letter-spacing: 0.05em;
}

/* ── Loading / error states ────────────────────────────────── */
.state-loading, .state-error {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-dim);
  font-size: 14px;
  letter-spacing: 0.05em;
}

.state-error { color: #e74c3c; }

.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-right: 10px;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Section divider ───────────────────────────────────────── */
.section-rule {
  border: none;
  border-top: 1px solid var(--border2);
  margin: 24px 0;
}

/* ── Mono ──────────────────────────────────────────────────── */
.mono {
  font-family: 'Courier New', Courier, monospace;
  font-size: 12px;
  word-break: break-all;
  color: var(--text-dim);
}

/* ── Collapsible wallet expand ─────────────────────────────── */
.wallet-toggle {
  width: 100%;
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  text-align: left;
  padding: 0;
  font-family: inherit;
}

.wallet-detail { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border2); }

.wallet-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.expand-hint { font-size: 11px; color: var(--text-mute); margin-top: 6px; }

/* ── Almanac ───────────────────────────────────────────────── */
.almanac-toolbar {
  display: flex; align-items: flex-start; gap: 12px; margin-bottom: 16px; flex-wrap: wrap;
}
.almanac-cats { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; }
.cat-btn {
  background: var(--surface); border: 1px solid var(--border2); border-radius: var(--radius);
  color: var(--text-dim); font-family: var(--font-body); font-size: 12px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase; padding: 5px 12px; cursor: pointer; transition: all 0.15s;
}
.cat-btn:hover { border-color: var(--border); color: var(--text); background: var(--surface2); }
.cat-btn.active { background: var(--gold-dim); border-color: var(--border); color: var(--gold); }
.cat-count { font-size: 10px; color: var(--text-mute); margin-left: 4px; }
.cat-btn.active .cat-count { color: var(--gold); opacity: 0.7; }
.almanac-search {
  background: var(--surface); border: 1px solid var(--border2); border-radius: var(--radius);
  color: var(--text); font-family: var(--font-body); font-size: 13px; padding: 6px 14px; width: 220px; transition: border-color 0.18s;
}
.almanac-search:focus { outline: none; border-color: var(--border); }
.almanac-search::placeholder { color: var(--text-mute); }
.almanac-count { font-size: 11px; color: var(--text-mute); letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 12px; }
.almanac-item-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; align-items: start;
}
.alm-card {
  background: var(--surface); border: 1px solid var(--border2); border-radius: var(--radius);
  padding: 12px 14px; transition: border-color 0.15s, box-shadow 0.15s; display: flex; flex-direction: column; gap: 4px;
}
.alm-card:hover { border-color: var(--border); box-shadow: var(--glow); }
.alm-card-header { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 2px; }
.alm-cat-tag { font-size: 10px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-mute); }
.alm-rarity { font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; padding: 1px 6px; border-radius: 3px; }
.rarity-common    { color: var(--text-dim); background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.08); }
.rarity-uncommon  { color: #2ecc71; background: rgba(39,174,96,0.1); border: 1px solid rgba(39,174,96,0.25); }
.rarity-rare      { color: #4fa8ff; background: rgba(30,144,255,0.1); border: 1px solid rgba(30,144,255,0.25); }
.rarity-epic      { color: #a855f7; background: rgba(168,85,247,0.1); border: 1px solid rgba(168,85,247,0.25); }
.rarity-legendary { color: var(--gold); background: var(--gold-dim); border: 1px solid var(--border); }
.alm-name { font-family: var(--font-head); font-size: 13px; font-weight: 600; color: var(--text); letter-spacing: 0.04em; line-height: 1.3; }
.alm-brand { font-size: 11px; color: var(--text-mute); letter-spacing: 0.05em; }
.alm-fields { margin-top: 6px; display: flex; flex-direction: column; gap: 2px; }
.alm-field { display: flex; justify-content: space-between; align-items: center; padding: 3px 0; border-bottom: 1px solid var(--border2); font-size: 12px; }
.alm-field:last-child { border-bottom: none; }
.alm-field-key { color: var(--text-dim); font-size: 11px; letter-spacing: 0.03em; }
.alm-field-val { font-weight: 600; color: var(--text); font-family: monospace; font-size: 12px; }
.empty-state { padding: 48px; text-align: center; color: var(--text-mute); font-size: 13px; letter-spacing: 0.05em; }
/* Almanac hub */
.alm-hub {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-bottom: 8px;
}
.alm-hub-tile {
  background: var(--surface); border: 1px solid var(--border2); border-radius: var(--radius);
  padding: 20px 12px 16px; display: flex; flex-direction: column; align-items: center; gap: 6px;
  cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s, background 0.15s; text-align: center;
}
.alm-hub-tile:hover { border-color: var(--border); box-shadow: var(--glow); background: var(--surface2); }
.alm-hub-tile-icon { font-size: 28px; line-height: 1; }
.alm-hub-tile-label {
  font-family: var(--font-head); font-size: 12px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text);
}
.alm-hub-tile-count { font-size: 11px; color: var(--text-mute); letter-spacing: 0.04em; }
/* Almanac breadcrumb */
.alm-breadcrumb {
  display: flex; align-items: center; gap: 8px; margin-bottom: 16px; font-size: 13px; color: var(--text-dim);
}
.alm-back-btn {
  background: none; border: none; color: var(--text-mute); font-family: var(--font-body); font-size: 12px;
  font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; cursor: pointer; padding: 0;
  transition: color 0.15s;
}
.alm-back-btn:hover { color: var(--gold); }
.alm-breadcrumb-sep { color: var(--border); }
.alm-breadcrumb-label { font-weight: 600; color: var(--text); letter-spacing: 0.04em; }
/* Almanac category + rarity filter chips */
.alm-cat-filters,
.alm-rarity-filters { display: flex; flex-wrap: wrap; gap: 6px; row-gap: 6px; align-items: center; }
.alm-rarity-chip {
  background: var(--surface); border: 1px solid var(--border2); border-radius: var(--radius);
  font-family: var(--font-body); font-size: 11px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: capitalize; padding: 4px 10px; cursor: pointer; transition: all 0.15s; color: var(--text-dim);
}
.alm-rarity-chip:hover { border-color: var(--border); color: var(--text); }
.alm-rarity-chip.active { background: var(--gold-dim); border-color: var(--border); color: var(--gold); }
.alm-rarity-chip.rarity-uncommon.active { background: rgba(39,174,96,0.15); border-color: rgba(39,174,96,0.5); color: #2ecc71; }
.alm-rarity-chip.rarity-rare.active    { background: rgba(30,144,255,0.15); border-color: rgba(30,144,255,0.5); color: #4fa8ff; }
.alm-rarity-chip.rarity-epic.active    { background: rgba(168,85,247,0.15); border-color: rgba(168,85,247,0.5); color: #a855f7; }
.alm-rarity-chip.rarity-legendary.active { background: var(--gold-dim); border-color: var(--border); color: var(--gold); }
/* Almanac card image */
.alm-img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  border-radius: 4px;
  background: var(--bg3);
  margin-bottom: 6px;
}
/* Almanac pagination */
.alm-hub-tile-img {
  width: 80px; height: 80px; object-fit: contain; border-radius: 6px; margin-bottom: 4px;
}
.rarity-mythic { color: #ff9944; background: rgba(255,153,68,0.1); border: 1px solid rgba(255,153,68,0.25); }
.alm-rarity-chip.rarity-mythic.active { background: rgba(255,153,68,0.15); border-color: rgba(255,153,68,0.5); color: #ff9944; }
.alm-desc { font-size: 11px; color: var(--text-mute); margin-top: 6px; line-height: 1.4; }
.alm-pagination {
  display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 20px; padding-top: 16px;
  border-top: 1px solid var(--border2);
}
.alm-page-btn {
  background: var(--surface); border: 1px solid var(--border2); border-radius: var(--radius);
  color: var(--text-dim); font-family: var(--font-body); font-size: 12px; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase; padding: 6px 16px; cursor: pointer; transition: all 0.15s;
}
.alm-page-btn:hover:not(:disabled) { border-color: var(--border); color: var(--text); background: var(--surface2); }
.alm-page-btn:disabled { opacity: 0.3; cursor: default; }
.alm-page-info { font-size: 12px; color: var(--text-mute); letter-spacing: 0.05em; }
/* ── Leaderboard ───────────────────────────────────────────── */

.lb-pill-wrap {
  display: flex;
  gap: 0;
  border-radius: var(--radius);
  border: 1px solid var(--border2);
  overflow: hidden;
}

.lb-pill {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 7px 18px;
  border: none;
  background: var(--surface);
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.2s;
}

.lb-pill.active {
  background: var(--gold-dim);
  color: var(--gold);
}

.lb-pill:hover:not(.active) {
  color: var(--text);
  background: var(--surface2);
}

.lb-pagination {
  margin-top: 20px;
  display: flex;
  justify-content: center;
}

.lb-pages {
  display: flex;
  gap: 4px;
  align-items: center;
}

.lb-page-btn {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border2);
  background: var(--surface);
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.2s;
}

.lb-page-btn:hover:not(.disabled):not(.active) {
  color: var(--text);
  border-color: var(--border);
}

.lb-page-btn.active {
  background: var(--gold-dim);
  color: var(--gold);
  border-color: var(--border);
}

.lb-page-btn.disabled {
  opacity: 0.3;
  cursor: default;
}

.lb-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.lb-tab {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 7px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border2);
  background: var(--surface);
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.2s;
}

.lb-tab:hover { color: var(--text); border-color: var(--border); }
.lb-tab.active { color: var(--gold); border-color: var(--border); background: var(--gold-dim); }

.lb-filters {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.lb-filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.lb-filter-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-mute);
}

.lb-filter-select {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13px;
  padding: 6px 10px;
  cursor: pointer;
  transition: border-color 0.2s;
}

.lb-filter-select:hover, .lb-filter-select:focus {
  border-color: var(--border);
  outline: none;
}

.lb-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border2);
}

.lb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.lb-table thead th {
  padding: 10px 16px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-mute);
  background: var(--surface);
  border-bottom: 1px solid var(--border2);
}

.lb-table tbody tr {
  border-bottom: 1px solid var(--border2);
  transition: background 0.15s;
}

.lb-table tbody tr:last-child { border-bottom: none; }
.lb-table tbody tr:hover { background: var(--surface2); }

.lb-table tbody td {
  padding: 10px 16px;
  color: var(--text);
}

.lb-table tbody td:first-child {
  color: var(--text-mute);
  font-family: monospace;
  font-size: 12px;
  width: 50px;
}

.lb-knight td { color: var(--gold) !important; }
.lb-knight td:first-child { color: var(--gold2) !important; }

/* Wallet Nav */
/* Wallet-nav dropdown ─────────────────────────────────────── */
#wallet-nav { position: relative; }

#wallet-address-display {
  cursor: pointer;
  user-select: none;
  align-items: center;
  gap: 8px;
}
.wm-chev {
  font-size: 11px;
  color: var(--text-dim);
  transition: transform 0.15s ease;
  margin-left: 2px;
}
#wallet-nav.open .wm-chev { transform: rotate(180deg); }

#wallet-nav .wm-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 240px;
  background: rgba(12, 16, 22, 0.98);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 0 1px rgba(0,0,0,0.4);
  backdrop-filter: blur(12px);
  padding: 12px;
  display: none;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
}
#wallet-nav.open .wm-panel { display: flex; }

#wallet-nav .wm-id {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
#wallet-nav .wm-id #ps-icon { color: var(--gold); font-size: 14px; }
#wallet-nav .wm-id #ps-name {
  font-family: var(--font-head);
  color: var(--gold2);
  font-size: 14px;
  letter-spacing: 0.06em;
}

#wallet-nav .wm-playerid {
  font-size: 11px;
  color: var(--text-mute);
  letter-spacing: 0.04em;
}
#wallet-nav .wm-playerid:empty { display: none; }

#wallet-nav .wm-rule {
  border: 0;
  border-top: 1px solid var(--border2);
  margin: 4px 0;
}

#wallet-nav .wm-action {
  background: transparent;
  border: 1px solid var(--border2);
  color: var(--text);
  padding: 8px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  font-family: var(--font-body);
  text-align: left;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
#wallet-nav .wm-action:hover {
  background: var(--gold-dim);
  border-color: var(--border);
  color: var(--gold);
}
#wallet-nav .wm-action-danger:hover {
  background: rgba(192, 57, 43, 0.15);
  border-color: rgba(192, 57, 43, 0.5);
  color: var(--red);
}

/* Override legacy #ps-edit-btn rule (from when it lived in the strip)
   so it matches the other dropdown actions: full-width, sentence case,
   normal letter-spacing, same padding/font as .wm-action. */
#wallet-nav #ps-edit-btn {
  margin-left: 0;
  text-transform: none;
  letter-spacing: normal;
  font-size: 13px;
  padding: 8px 12px;
  text-align: left;
  width: 100%;
}

#wallet-connect-btn {
  background: var(--gold-dim);
  color: var(--gold);
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-family: var(--font-body);
  transition: all 0.18s;
}

#wallet-connect-btn:hover {
  background: rgba(201,168,76,0.25);
  border-color: var(--gold);
  color: var(--gold2);
}

#wallet-address-display {
  display: none;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-family: monospace;
  background: var(--surface);
  color: var(--text);
  padding: 8px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border2);
  cursor: pointer;
  transition: all 0.18s;
}

#wallet-address-display:hover {
  border-color: var(--border);
  color: var(--gold);
}

/* Modal — Tower theme (deep navy + gold) */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(3, 6, 11, 0.78);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.modal-box {
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg2) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  min-width: 320px;
  max-width: 420px;
  width: 100%;
  color: var(--text);
  box-shadow: 0 20px 60px rgba(0,0,0,0.55), 0 0 0 1px rgba(0,0,0,0.4), var(--glow);
}
.modal-box h3 {
  margin: 0 0 16px;
  font-family: var(--font-head);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--gold);
}
.modal-box ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.wallet-option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
}
.wallet-option:hover {
  background: var(--gold-dim);
  border-color: var(--border);
  color: var(--gold);
}
.wallet-option:active { transform: translateY(1px); }
.wallet-option img { border-radius: 4px; flex-shrink: 0; }
.not-installed {
  color: var(--text-mute);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-left: auto;
}
.modal-box > button {
  margin-top: 14px;
  width: 100%;
  padding: 10px 14px;
  background: transparent;
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-family: var(--font-body);
  font-size: 13px;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.modal-box > button:hover {
  background: var(--surface2);
  border-color: var(--border);
  color: var(--text);
}
#wallet-modal-feedback {
  margin: 10px 0 0 !important;
  padding: 8px 10px;
  border-radius: var(--radius);
  background: rgba(192, 57, 43, 0.12);
  border: 1px solid rgba(192, 57, 43, 0.4);
  color: var(--red) !important;
  font-size: 12px !important;
}

/* ── Profile Strip ─────────────────────────────────────────────── */
#profile-strip {
  background: rgba(10, 14, 20, 0.97);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  position: sticky;
  top: var(--nav-h);
  z-index: 90;
}

#profile-strip-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 40px;
  display: flex;
  align-items: center;
  gap: 12px;
}

#ps-icon {
  color: var(--gold);
  font-size: 14px;
}

#ps-name {
  font-family: var(--font-head);
  font-size: 13px;
  color: var(--gold2);
  letter-spacing: 0.06em;
}

#ps-playerid {
  font-size: 11px;
  color: var(--text-mute);
}

#ps-edit-btn {
  margin-left: auto;
  background: none;
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 5px 14px;
  cursor: pointer;
  transition: all 0.18s;
}

#ps-edit-btn:hover {
  color: var(--gold);
  border-color: var(--border);
  background: var(--gold-dim);
}

/* ── Profile Panel ─────────────────────────────────────────────── */
#profile-panel {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
}

#profile-panel-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 24px;
}

.pp-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pp-label {
  font-family: var(--font-head);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
}

.pp-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.pp-input {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13px;
  padding: 8px 12px;
  width: 260px;
  transition: border-color 0.18s;
}

.pp-input:focus {
  outline: none;
  border-color: var(--border);
}

.pp-input::placeholder {
  color: var(--text-mute);
}

.pp-btn {
  background: var(--gold-dim);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--gold);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 8px 16px;
  cursor: pointer;
  transition: all 0.18s;
}

.pp-btn:hover {
  background: rgba(201,168,76,0.25);
  border-color: var(--gold);
  color: var(--gold2);
}

#pp-feedback {
  font-size: 12px;
  min-height: 16px;
}

#tower-foundation {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

#foundation-inner {
  max-width: 380px;
  width: 100%;
  padding: 48px 32px;
  text-align: center;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,215,0,0.15);
  border-radius: 12px;
}

.foundation-logo {
  font-size: 40px;
  margin-bottom: 12px;
}

.foundation-title {
  font-family: 'Cinzel', serif;
  font-size: 26px;
  color: var(--gold);
  margin: 0 0 4px;
  letter-spacing: 0.15em;
}

.foundation-subtitle {
  font-size: 12px;
  color: var(--text-dim);
  margin: 0 0 32px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.foundation-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.foundation-row input {
  flex: 1;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 4px;
  padding: 10px 14px;
  color: var(--text);
  font-size: 14px;
  outline: none;
}

.foundation-row input:focus {
  border-color: rgba(255,215,0,0.4);
}

#citizen-feedback {
  font-size: 13px;
  margin-top: 8px;
  min-height: 18px;
  color: var(--text-dim);
}

.badge-blue {
  background: rgba(30, 144, 255, 0.15);
  color: #4fa8ff;
  border: 1px solid rgba(30, 144, 255, 0.3);
}

.badge-grey {
  background: rgba(255,255,255,0.05);
  color: var(--text-dim);
  border: 1px solid rgba(255,255,255,0.1);
}



/* ── Nav toggle button ─────────────────────────────────────── */
#wallet-nav-mobile { display: none; }

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--gold);
  font-size: 18px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.page-bar-logo-img {
  height: 122px;
  mix-blend-mode: screen;
  object-fit: contain;
  border-radius: 0;
  mask-image: radial-gradient(ellipse 70% 70% at 50% 50%, black 40%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 70% 70% at 50% 50%, black 40%, transparent 100%);
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
  .almanac-item-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .almanac-search { width: 100%; }
  .almanac-toolbar { flex-direction: column; }
  .brand-name { font-size: 14px; }
  .brand-logo { height: 52px; }
  .page-wrap { padding: 20px 16px; }

  /* Mobile nav toggle visible (wallet-nav stays — it now lives inside
     the hamburger). The legacy #wallet-nav-mobile hardcoded button was
     replaced by relocating #wallet-nav itself into #nav-links. */
  .nav-toggle { display: flex; }

  /* Nav links become a dropdown panel */
  .nav-links {
    display: none;
    flex-direction: column;
    position: absolute;
    top: var(--nav-h);
    left: 0;
    right: 0;
    background: rgba(8, 11, 16, 0.98);
    border-bottom: 1px solid var(--border);
    padding: 8px 16px 16px;
    gap: 4px;
    z-index: 99;
    backdrop-filter: blur(12px);
  }
  .nav-links.open { display: flex; }

  .nav-link {
    padding: 12px 16px;
    font-size: 14px;
    border-radius: var(--radius);
    border: 1px solid transparent;
  }
  .nav-link:hover, .nav-link.active {
    border-color: var(--border);
  }

  /* Truncate wallet address on mobile */
  #wallet-address-text {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
  }

  /* Empty profile-strip stub stays hidden on mobile (and everywhere
     really — wallet.js sets display:block on it but we override). */
  #profile-strip { display: none !important; }

  /* On mobile the wallet-nav is relocated into #nav-links by JS so it
     becomes a section of the hamburger menu. Style it like one:
     full-width, no chevron, the dropdown panel is shown inline (not
     absolute) so Connect / address / Edit / Sign Out / Disconnect
     are all part of the open hamburger. */
  #nav-links #wallet-nav {
    display: block;
    width: 100%;
    margin-top: 8px;
    padding-top: 12px;
    border-top: 1px solid rgba(180,140,60,0.08);
  }
  #nav-links #wallet-connect-btn {
    width: 100%;
    background: var(--gold-dim);
    color: var(--gold);
    border: 1px solid var(--border);
    padding: 12px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-family: var(--font-body);
  }
  #nav-links #wallet-address-display {
    width: 100%;
    justify-content: center;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--gold-dim);
    color: var(--gold);
    font-family: var(--font-body);
    font-size: 13px;
    cursor: default;
  }
  #nav-links #wallet-address-display .wm-chev { display: none; }
  #nav-links .wm-panel {
    position: static !important;
    display: flex !important;
    box-shadow: none;
    background: transparent;
    backdrop-filter: none;
    border: none;
    padding: 8px 0 0;
    min-width: 0;
    width: 100%;
  }
  /* Only render the dropdown contents when there's an actual logged-in
     state. wallet.js's setNavConnected() reveals #wallet-address-display
     and that's our signal — without it, we hide the menu items so the
     hamburger only shows the Connect Wallet button. */
  #nav-links #wallet-address-display[style*="display: none"] ~ .wm-panel,
  #nav-links #wallet-address-display:not([style*="inline-flex"]) ~ .wm-panel {
    display: none !important;
  }

  /* Stop horizontal page scroll on mobile — any wide descendant
     was dragging the whole document sideways. */
  html, body { overflow-x: hidden; max-width: 100%; }
  #app       { overflow-x: hidden; max-width: 100vw; }

  /* Unified mobile per-page header across the Tower:
       title (left-aligned)  →  actions (full-width, left-aligned)
     The WATCHTOWER center label is redundant on mobile — the parent
     Tower nav already brands the page, and showing it makes the
     header feel disjointed in three vertical sections. */
  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
  }
  .page-header-center { display: none; }
  .page-header-left,
  .page-header-right {
    flex: 0 0 auto;
    width: 100%;
    min-width: 0;
    text-align: left;
  }
  .page-header-right {
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 8px;
  }
  .page-header-right > * { flex: 0 1 auto; }
  .page-title    { font-size: 18px; }

  /* ── Lands: full-bleed map, prevent top overflow ────────── */
  #lands-wrap {
    width: 100%;
    position: relative;
    overflow: hidden;
    margin: 0;
  }
  #lands-iframe {
    width: 100%;
    display: block;
    /* JS sets height precisely; this is a safe fallback that uses
       small-viewport units so mobile address bar bounce doesn't
       blow out the page. */
    min-height: calc(100svh - var(--nav-h));
    min-height: calc(100dvh - var(--nav-h));
  }

  /* ── Recipes iframe: tighter mobile fit ─────────────────── */
  #page-recipes .page-wrap { padding: 12px 12px; }
  #page-recipes .page-wrap > div {
    height: calc(100svh - var(--nav-h) - 24px) !important;
    height: calc(100dvh - var(--nav-h) - 24px) !important;
    min-height: 0 !important;
  }
  #page-recipes iframe { border-radius: 4px !important; }

  /* ── Leaderboard mobile ──────────────────────────────────── */
  /* Wrap tabs onto multiple rows so Calido Raceway isn't truncated. */
  .lb-tabs {
    flex-wrap: wrap;
    gap: 6px;
    padding-bottom: 4px;
  }
  .lb-tab {
    flex: 1 1 auto;
    white-space: nowrap;
    text-align: center;
    min-width: 0;
    font-size: 12px;
    padding: 8px 10px;
  }

  /* .lb-filters is flex on desktop, so use flex-direction here, not
     grid-template-columns (which had no effect on a flex parent). */
  .lb-filters {
    flex-direction: column;
    gap: 10px;
  }
  .lb-filter-group { width: 100%; }
  .lb-filter-select { width: 100%; }

  .lb-pill-wrap {
    width: 100%;
    display: flex;
    gap: 6px;
  }
  .lb-pill { flex: 1 1 50%; text-align: center; }

  /* Table fills the wrap width; wrap scrolls horizontally only if the
     table's min-width exceeds the viewport. Override the generic
     table { display: block } safety net so the table layout survives. */
  .lb-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-left: -12px;
    margin-right: -12px;
    padding: 0 12px;
  }
  .lb-table {
    display: table !important;
    width: 100%;
    overflow: visible !important;
    font-size: 12px;
    table-layout: auto;
  }
  .lb-table thead { display: table-header-group; }
  .lb-table tbody { display: table-row-group; }
  .lb-table tr    { display: table-row; }
  .lb-table th, .lb-table td { display: table-cell; padding: 8px 6px; }
  /* Rank (1st), Collected (3rd), Time (last) all shrink-to-content via
     the width:1% trick. Player (2nd) flexes naturally to fill the rest. */
  .lb-table th:first-child,
  .lb-table td:first-child {
    width: 1%; padding-left: 10px; padding-right: 6px;
    white-space: nowrap;
  }
  .lb-table th:nth-child(n+3),
  .lb-table td:nth-child(n+3) { white-space: nowrap; }
  /* Last column shrinks to its content (it's always a small integer
     like "100" on holocache, since Time was moved to column 3). */
  .lb-table th:last-child,
  .lb-table td:last-child { width: 1%; padding-right: 10px; }
  /* Final guard: never let the wrap or table push horizontal scroll. */
  .lb-table-wrap { overflow-x: hidden; }

  .lb-pagination { justify-content: center; flex-wrap: wrap; }

  /* ── Treasury / Armory: tighter card grids ──────────────── */
  .grid-2, .grid-3,
  [class*="armory-grid"],
  [class*="treasury-grid"] {
    grid-template-columns: 1fr !important;
    gap: 12px;
  }
  .stat-row { font-size: 13px; }

  /* ── Almanac: smaller tiles + full-width search ────────── */
  .almanac-item-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
  }
  .almanac-cats { gap: 4px; }

  /* Easier-to-tap category + rarity chips on touch */
  .alm-cat-filters,
  .alm-rarity-filters {
    gap: 10px;
    row-gap: 10px;
  }
  .alm-rarity-chip {
    padding: 9px 14px;
    font-size: 12.5px;
    letter-spacing: 0.06em;
    line-height: 1;
  }

  /* ── Generic tables: never let them push the layout wide ── */
  table { display: block; max-width: 100%; overflow-x: auto; }
}












































