:root {
  --bg: #14120f;
  --bg-alt: #1c1913;
  --bg-card: #221e17;
  --iron: #4a4740;
  --patina: #7c8f6a;
  --rust: #a8503a;
  --rust-bright: #c96a4f;
  --bone: #e8e2d4;
  --bone-dim: #a39c8c;
  --gold: #c9a227;
  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --slot: 64px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  min-height: 100vh;
  background:
    radial-gradient(900px 480px at 20% 0%, #2a241c 0%, transparent 55%),
    radial-gradient(800px 500px at 90% 10%, #1a2220 0%, transparent 50%),
    var(--bg);
  color: var(--bone);
  font-family: var(--font-body);
  line-height: 1.5;
}

a { color: var(--patina); text-decoration: none; }
a:hover { color: var(--bone); }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid rgba(232, 226, 212, 0.08);
}
.topbar img { height: 36px; width: auto; }
.topbar nav { display: flex; gap: 0.85rem; align-items: center; flex-wrap: wrap; }

.wrap {
  width: min(1100px, calc(100% - 2rem));
  margin: 2rem auto 4rem;
}

h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  margin-bottom: 0.25rem;
}
.sub { color: var(--bone-dim); margin-bottom: 1.5rem; }

.char-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.char-card {
  background: var(--bg-card);
  border: 1px solid rgba(232, 226, 212, 0.12);
  border-radius: 4px;
  padding: 1.15rem 1.2rem;
  transition: border-color 0.15s, transform 0.15s;
  cursor: pointer;
  color: inherit;
  display: block;
}
.char-card:hover {
  border-color: var(--patina);
  transform: translateY(-2px);
}
.char-card h2 {
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 600;
  margin-bottom: 0.2rem;
}
.char-card .meta { color: var(--bone-dim); font-size: 0.9rem; }
.char-card .bp {
  margin-top: 0.85rem;
  font-size: 1.1rem;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}
.char-card .guild {
  margin-top: 0.35rem;
  font-size: 0.85rem;
  color: var(--patina);
}

.empty {
  padding: 2rem;
  text-align: center;
  color: var(--bone-dim);
  border: 1px dashed var(--iron);
  border-radius: 4px;
}

/* Detail layout */
.armory-hero {
  display: grid;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}
@media (min-width: 800px) {
  .armory-hero {
    grid-template-columns: 1fr 1.2fr;
    align-items: start;
  }
}

.panel {
  background: var(--bg-card);
  border: 1px solid rgba(232, 226, 212, 0.1);
  border-radius: 4px;
  padding: 1.25rem;
}
.panel h3 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  margin-bottom: 0.85rem;
  letter-spacing: 0.02em;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}
.stat {
  background: var(--bg);
  border: 1px solid rgba(232, 226, 212, 0.06);
  border-radius: 3px;
  padding: 0.65rem 0.75rem;
}
.stat .lbl {
  display: block;
  font-size: 0.7rem;
  letter-spacing: 0.02em;
  color: var(--bone-dim);
}
.stat .val {
  font-size: 1.15rem;
  font-variant-numeric: tabular-nums;
  color: var(--bone);
}
.stat .val.gold { color: var(--gold); }

/* Paperdoll */
.doll {
  display: grid;
  grid-template-columns: var(--slot) 1fr var(--slot);
  gap: 0.5rem;
  justify-items: center;
  max-width: 320px;
  margin: 0 auto;
}
.doll-col {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.doll-center {
  min-height: calc(var(--slot) * 4);
  width: 100%;
  border: 1px dashed rgba(232, 226, 212, 0.12);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--bone-dim);
  font-family: var(--font-display);
  font-size: 1.1rem;
  text-align: center;
  padding: 0.5rem;
}

.slot {
  width: var(--slot);
  height: var(--slot);
  background: var(--bg);
  border: 1px solid var(--iron);
  border-radius: 3px;
  position: relative;
  overflow: hidden;
}
.slot img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: auto;
}
.slot .qty {
  position: absolute;
  right: 2px;
  bottom: 1px;
  font-size: 0.65rem;
  background: rgba(0,0,0,0.65);
  padding: 0 3px;
  border-radius: 2px;
}
.slot .plus {
  position: absolute;
  left: 2px;
  top: 1px;
  font-size: 0.65rem;
  color: var(--gold);
  font-weight: 700;
}
.slot.empty { opacity: 0.45; }
.slot[title] { cursor: help; }

.weapons-row {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 0.75rem;
}

.item-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
  gap: 0.4rem;
}
.item-grid .slot { width: 100%; aspect-ratio: 1; height: auto; }

.item-list {
  display: grid;
  gap: 0.4rem;
  max-height: 420px;
  overflow: auto;
}
.item-row {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 0.65rem;
  align-items: center;
  padding: 0.35rem 0.45rem;
  background: var(--bg);
  border-radius: 3px;
  border: 1px solid rgba(232, 226, 212, 0.05);
}
.item-row img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  background: #111;
  border-radius: 2px;
}
.item-row .name { font-size: 0.9rem; }
.item-row .sub { font-size: 0.75rem; color: var(--bone-dim); }
.item-row .amt { color: var(--bone-dim); font-variant-numeric: tabular-nums; }

.tabs {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
  flex-wrap: wrap;
}
.tab {
  background: transparent;
  border: 1px solid var(--iron);
  color: var(--bone-dim);
  padding: 0.4rem 0.75rem;
  border-radius: 3px;
  cursor: pointer;
  font-size: 0.85rem;
}
.tab.active {
  border-color: var(--patina);
  color: var(--bone);
  background: rgba(124, 143, 106, 0.12);
}

.msg {
  margin: 1rem 0;
  padding: 0.75rem;
  border-radius: 3px;
  display: none;
}
.msg.show { display: block; }
.msg.err { background: rgba(168, 80, 58, 0.18); color: #e0a090; }

.back { display: inline-block; margin-bottom: 1rem; font-size: 0.9rem; }
