/* ==========================================================================
   PITBORN — app.css
   Torchlit-arena design system. Plain CSS, no build step, system fonts only.
   Sections: 1 tokens · 2 base · 3 layout (topbar/nav/view/footer) · 4 buttons
   & forms · 5 panels/grid · 6 tables · 7 badges · 8 stats/radar/sparkline ·
   9 timeline · 10 chronicle · 11 fight viewer · 12 body map · 13 sigils ·
   14 trading card · 15 tabs · 16 modals · 17 toasts · 18 placeholder/boot ·
   19 utilities · 20 responsive · 21 print · 22 motion & focus
   ========================================================================== */

/* 1. Tokens ------------------------------------------------------------- */
:root {
  color-scheme: dark;

  --bg-0: #070504;
  --bg-1: #0d0a08;
  --bg-2: #14100e;
  --bg-3: #1c1613;
  --bg-4: #261e19;
  --bg-5: #322822;

  --line: rgba(224, 164, 88, 0.14);
  --line-strong: rgba(224, 164, 88, 0.34);
  --line-soft: rgba(224, 164, 88, 0.07);

  --text: #d9cdb8;
  --text-strong: #f3e9d4;
  --text-muted: #8f8371;
  --text-faint: #5c5347;

  --parchment: #eadcc0;
  --parchment-soft: #cbbb9c;
  --parchment-bg: #1a1411;
  --parchment-bg-2: #211a15;

  --gold: #e0a458;
  --gold-bright: #f5cf85;
  --gold-dim: #9c7133;
  --gold-ink: #2a1b08;
  --ember: #d9742a;
  --ember-hot: #ff8f3a;
  --blood: #a3171d;
  --blood-bright: #d8262e;
  --blood-dark: #5a0d10;
  --ok: #6f9c6a;
  --ok-bright: #8fc487;
  --info: #7f9bb5;
  --warn: #d9a23a;

  --font-display: "Palatino Linotype", Palatino, "Iowan Old Style", "Book Antiqua", Georgia, "Times New Roman", serif;
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --radius-sm: 4px;
  --radius: 6px;
  --radius-lg: 10px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.55), 0 1px 0 rgba(255, 220, 160, 0.04) inset;
  --shadow-soft: 0 4px 14px rgba(0, 0, 0, 0.4);
  --glow-gold: 0 0 0 1px rgba(224, 164, 88, 0.35), 0 0 18px rgba(224, 164, 88, 0.2);
  --glow-blood: 0 0 0 1px rgba(216, 38, 46, 0.4), 0 0 18px rgba(216, 38, 46, 0.22);

  --topbar-h: 56px;
  --maxw: 1280px;
  --gap: 16px;
  --t-fast: 120ms;
  --t: 220ms;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* 2. Base ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font: 15px/1.5 var(--font-ui);
  color: var(--text);
  background: var(--bg-1);
  background-image:
    radial-gradient(ellipse 70% 42% at 50% -6%, rgba(217, 116, 42, 0.20), transparent 68%),
    radial-gradient(ellipse 40% 30% at 100% 100%, rgba(163, 23, 29, 0.10), transparent 70%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
/* grain: makes the black feel like stone instead of a screen */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.topbar, .view, .footer, .toasts, .modal-root { position: relative; z-index: 1; }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--text-strong);
  letter-spacing: 0.01em;
  line-height: 1.15;
  margin: 0 0 0.5em;
}
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }
h4 { font-size: 1rem; }
p { margin: 0 0 1em; }
a { color: var(--gold); text-decoration: none; transition: color var(--t-fast); }
a:hover { color: var(--gold-bright); text-decoration: underline; text-decoration-color: var(--gold-dim); text-underline-offset: 3px; }
code, kbd, .mono { font-family: var(--font-mono); font-size: 0.9em; }
code { color: var(--gold-bright); background: rgba(224, 164, 88, 0.08); padding: 0.1em 0.35em; border-radius: 3px; }
kbd {
  display: inline-block; padding: 0.05em 0.5em; border-radius: 4px; color: var(--text-strong);
  background: var(--bg-4); border: 1px solid var(--line-strong); border-bottom-width: 2px; font-size: 0.8em; line-height: 1.6;
}
hr { border: 0; border-top: 1px solid var(--line); margin: var(--gap) 0; }
img, svg { max-width: 100%; }
svg { display: inline-block; vertical-align: middle; }
::selection { background: rgba(224, 164, 88, 0.32); color: var(--text-strong); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-1); }
::-webkit-scrollbar-thumb { background: var(--bg-5); border-radius: 6px; border: 2px solid var(--bg-1); }
::-webkit-scrollbar-thumb:hover { background: var(--gold-dim); }

.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 8px; top: -60px; z-index: 50; padding: 8px 12px; background: var(--gold); color: var(--gold-ink); border-radius: var(--radius); font-weight: 600; }
.skip-link:focus { top: 8px; }

/* 3. Layout -------------------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(180deg, #1a1411 0%, #110d0b 100%);
  border-bottom: 1px solid var(--line-strong);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
}
.topbar::before {
  /* torch line */
  content: "";
  position: absolute; left: 0; right: 0; top: 0; height: 2px;
  background: linear-gradient(90deg, transparent 0%, var(--ember) 25%, var(--gold-bright) 50%, var(--ember) 75%, transparent 100%);
  opacity: 0.9;
}
.topbar-row {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 var(--gap);
  min-height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 20px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text-strong); flex: none; }
.brand:hover { text-decoration: none; color: var(--gold-bright); }
.brand-mark { width: 30px; height: 30px; filter: drop-shadow(0 0 6px rgba(255, 143, 58, 0.45)); animation: torch 3.2s ease-in-out infinite alternate; }
.brand-word {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.28rem;
  letter-spacing: 0.22em;
  background: linear-gradient(180deg, var(--gold-bright) 0%, var(--gold) 55%, var(--gold-dim) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 22px rgba(224, 164, 88, 0.15);
}
@keyframes torch { from { filter: drop-shadow(0 0 4px rgba(255, 143, 58, 0.35)); } to { filter: drop-shadow(0 0 9px rgba(255, 143, 58, 0.65)); } }

.world-strip {
  display: flex; align-items: baseline; gap: 8px; min-width: 0; flex: 1 1 auto;
  padding-left: 20px; border-left: 1px solid var(--line);
  white-space: nowrap; overflow: hidden;
}
.world-strip-label { font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.16em; color: var(--text-faint); }
.world-name { font-family: var(--font-display); font-style: italic; font-size: 1.05rem; color: var(--parchment); overflow: hidden; text-overflow: ellipsis; }
.world-sep { color: var(--text-faint); }
.world-date { font-size: 0.85rem; color: var(--gold); letter-spacing: 0.04em; }
.world-date.tick { animation: tick var(--t) var(--ease); }
@keyframes tick { from { color: var(--gold-bright); transform: translateY(-2px); } to { color: var(--gold); transform: none; } }

.sim-controls { display: flex; align-items: center; gap: 6px; flex: none; }
.sim-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); margin-right: 4px; transition: background var(--t), box-shadow var(--t); }
.sim-dot[data-state="running"] { background: var(--gold-bright); box-shadow: 0 0 10px var(--gold); animation: pulse 1.2s ease-in-out infinite; }
.sim-dot[data-state="busy"] { background: var(--ember); box-shadow: 0 0 8px var(--ember); }
.sim-dot[data-state="error"] { background: var(--blood-bright); box-shadow: 0 0 8px var(--blood-bright); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
.ico { width: 18px; height: 18px; fill: currentColor; }
#btn-play .ico-pause { display: none; }
#btn-play[aria-pressed="true"] .ico-play { display: none; }
#btn-play[aria-pressed="true"] .ico-pause { display: block; }
#btn-play[aria-pressed="true"] { color: var(--gold-bright); border-color: var(--gold-dim); box-shadow: var(--glow-gold); }
.sim-speed-wrap { display: inline-flex; margin-left: 4px; }

.nav {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 var(--gap);
  display: flex;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }
.nav a {
  position: relative;
  padding: 8px 12px 10px;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: color var(--t-fast), border-color var(--t-fast);
}
.nav a:hover { color: var(--text-strong); text-decoration: none; }
.nav a[aria-current="page"] { color: var(--gold-bright); border-bottom-color: var(--gold); text-shadow: 0 0 12px rgba(245, 207, 133, 0.35); }

.view {
  flex: 1 0 auto;
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 24px var(--gap) 48px;
  outline: none;
}
.view-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.view-head h1 { margin: 0; }
.view-head .sub { color: var(--text-muted); font-size: 0.9rem; }
.eyebrow { font-size: 0.68rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--gold-dim); font-weight: 600; margin-bottom: 4px; }

.footer {
  border-top: 1px solid var(--line);
  padding: 14px var(--gap) calc(14px + env(safe-area-inset-bottom));
  font-size: 0.72rem;
  color: var(--text-faint);
  display: flex; flex-wrap: wrap; justify-content: center; gap: 8px;
  letter-spacing: 0.06em;
}
.footer-brand { font-family: var(--font-display); letter-spacing: 0.2em; color: var(--gold-dim); }
.footer code { color: var(--text-muted); background: none; padding: 0; }

/* 4. Buttons & forms ----------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 7px 14px;
  font: 600 0.82rem/1.2 var(--font-ui);
  letter-spacing: 0.06em;
  color: var(--text);
  background: linear-gradient(180deg, var(--bg-4), var(--bg-3));
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast), transform var(--t-fast);
  user-select: none;
}
.btn:hover { color: var(--text-strong); border-color: var(--gold); box-shadow: var(--glow-gold); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; box-shadow: none; transform: none; }
.btn-primary {
  color: var(--gold-ink);
  background: linear-gradient(180deg, var(--gold-bright), var(--gold) 60%, #c88c3f);
  border-color: #b3823a;
  text-shadow: 0 1px 0 rgba(255, 240, 200, 0.4);
}
.btn-primary:hover { color: var(--gold-ink); background: linear-gradient(180deg, #ffe0a0, var(--gold-bright) 60%, var(--gold)); }
.btn-danger { color: #ffd9d9; background: linear-gradient(180deg, var(--blood-bright), var(--blood)); border-color: var(--blood); }
.btn-danger:hover { border-color: var(--blood-bright); box-shadow: var(--glow-blood); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--bg-3); box-shadow: none; border-color: var(--line); }
.btn-sm { padding: 4px 10px; font-size: 0.74rem; }
.btn-lg { padding: 11px 22px; font-size: 0.95rem; }
.btn-icon { padding: 6px; width: 34px; height: 34px; }
.btn-icon.btn-sm { width: 28px; height: 28px; padding: 4px; }
.btn-block { width: 100%; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: var(--radius) 0 0 var(--radius); margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.btn-group .btn[aria-pressed="true"] { color: var(--gold-bright); background: var(--bg-5); border-color: var(--gold-dim); position: relative; z-index: 1; }

.input, .select, .textarea,
input[type="text"], input[type="number"], input[type="search"], input[type="password"], input[type="email"], select, textarea {
  font: 0.9rem/1.3 var(--font-ui);
  color: var(--text-strong);
  background: var(--bg-1);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 7px 10px;
  min-width: 0;
  max-width: 100%;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
.input:focus, .select:focus, .textarea:focus, input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); box-shadow: var(--glow-gold); }
.select, select {
  appearance: none; -webkit-appearance: none;
  padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23e0a458' stroke-width='1.6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
}
.select-sm, select.select-sm { padding: 4px 26px 4px 8px; font-size: 0.78rem; }
textarea, .textarea { resize: vertical; min-height: 80px; }
input[type="range"] { accent-color: var(--gold); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--gold); width: 15px; height: 15px; }
.mono-input, .input.mono { font-family: var(--font-mono); letter-spacing: 0.02em; }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field > label, .field-label { font-size: 0.7rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-muted); font-weight: 600; }
.field .hint { font-size: 0.76rem; color: var(--text-faint); }
.field-row { display: flex; align-items: center; gap: 8px; }
.field-row > .input, .field-row > input, .field-row > select, .field-row > .select { flex: 1 1 auto; }
.field.locked > label, .field.locked .field-label { color: var(--gold); }
.field.locked input, .field.locked select, .field.locked textarea, .field.locked .input, .field.locked .select { border-color: var(--gold-dim); background: #1b140e; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 16px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 0.9rem; cursor: pointer; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  font-size: 0.76rem; background: var(--bg-3); border: 1px solid var(--line); color: var(--text); cursor: pointer;
}
.chip[aria-pressed="true"], .chip.on { border-color: var(--gold); color: var(--gold-bright); background: #241a10; }

/* lock toggle: a padlock drawn in CSS; aria-pressed="true" = locked */
.lock {
  --lc: var(--text-muted);
  position: relative;
  flex: none;
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--bg-3);
  cursor: pointer;
  padding: 0;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}
.lock::before {
  content: "";
  position: absolute; left: 50%; top: 6px;
  width: 10px; height: 8px; margin-left: -5px;
  border: 2px solid var(--lc); border-bottom: 0;
  border-radius: 6px 6px 0 0;
  transform-origin: 85% 100%;
  transform: translateX(-3px) rotate(-28deg);
  transition: transform var(--t-fast) var(--ease), border-color var(--t-fast);
}
.lock::after {
  content: "";
  position: absolute; left: 50%; top: 13px;
  width: 13px; height: 9px; margin-left: -6.5px;
  background: var(--lc);
  border-radius: 2px;
  transition: background var(--t-fast);
}
.lock:hover { border-color: var(--line-strong); --lc: var(--text); }
.lock[aria-pressed="true"] { --lc: var(--gold-bright); border-color: var(--gold); background: #2a1e12; box-shadow: var(--glow-gold); }
.lock[aria-pressed="true"]::before { transform: none; }
.lock.lock-sm { width: 24px; height: 24px; }
.lock.lock-sm::before { top: 4px; width: 8px; height: 6px; margin-left: -4px; }
.lock.lock-sm::after { top: 10px; width: 11px; height: 7px; margin-left: -5.5px; }

/* 5. Panels, grids ------------------------------------------------------- */
.panel {
  background: linear-gradient(180deg, var(--bg-3), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft), inset 0 1px 0 rgba(255, 225, 170, 0.04);
  padding: 16px 18px;
  min-width: 0;
}
.panel.tight { padding: 10px 12px; }
.panel.flush { padding: 0; overflow: hidden; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin: -4px 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.panel-head h2, .panel-head h3 { margin: 0; font-size: 0.78rem; font-family: var(--font-ui); letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold); font-weight: 700; }
.panel.flush .panel-head { margin: 0; padding: 10px 14px; }
.panel-hero {
  background:
    radial-gradient(ellipse 60% 80% at 50% 0%, rgba(217, 116, 42, 0.14), transparent 70%),
    linear-gradient(180deg, var(--bg-3), var(--bg-2));
  border-color: var(--line-strong);
}
.grid { display: grid; gap: var(--gap); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid-cards { grid-template-columns: repeat(auto-fill, minmax(var(--card-w, 250px), 1fr)); justify-items: center; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.spacer { flex: 1 1 auto; }

.stat-strip { display: flex; flex-wrap: wrap; gap: 8px; }
.stat-tile {
  flex: 1 1 120px; min-width: 110px;
  padding: 10px 12px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.stat-tile .k { font-size: 0.66rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-muted); }
.stat-tile .v { font-family: var(--font-display); font-size: 1.5rem; color: var(--gold-bright); line-height: 1.1; }
.stat-tile .v.blood { color: var(--blood-bright); }
.stat-tile .d { font-size: 0.74rem; color: var(--text-faint); }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: 0.88rem; }
.kv dt { color: var(--text-muted); font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; align-self: baseline; }
.kv dd { margin: 0; color: var(--text-strong); }

/* 6. Tables -------------------------------------------------------------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--bg-2); }
.table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.table th, .table td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table th {
  position: sticky; top: 0; z-index: 1;
  background: var(--bg-3);
  font-size: 0.68rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-muted); font-weight: 700;
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
}
.table th.sortable { padding: 0; }
.table .th-btn {
  all: unset;
  display: flex; align-items: center; gap: 6px;
  width: 100%; padding: 9px 12px; cursor: pointer; box-sizing: border-box;
}
.table .th-btn:hover { color: var(--text-strong); }
.table .th-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }
.table .th-btn::after { content: "▴▾"; font-size: 0.6rem; letter-spacing: -0.15em; opacity: 0.35; }
.table th[aria-sort="ascending"] .th-btn { color: var(--gold-bright); }
.table th[aria-sort="ascending"] .th-btn::after { content: "▴"; opacity: 1; color: var(--gold); }
.table th[aria-sort="descending"] .th-btn { color: var(--gold-bright); }
.table th[aria-sort="descending"] .th-btn::after { content: "▾"; opacity: 1; color: var(--gold); }
.table tbody tr:nth-child(even) { background: rgba(255, 220, 160, 0.015); }
.table tbody tr:hover { background: rgba(224, 164, 88, 0.06); }
.table tbody tr[tabindex] { cursor: pointer; }
.table tbody tr[tabindex]:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }
.table tbody tr.selected { background: rgba(224, 164, 88, 0.12); }
.table tbody tr.dead { color: var(--text-muted); }
.table td.num, .table th.num, .table .align-right { text-align: right; font-variant-numeric: tabular-nums; }
.table .align-center { text-align: center; }
.table td.empty { text-align: center; color: var(--text-faint); padding: 28px; font-style: italic; }
.table td.name { font-family: var(--font-display); font-size: 0.98rem; color: var(--text-strong); }
.table .compact th, .table .compact td, .table.compact th, .table.compact td { padding: 4px 8px; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; font-size: 0.76rem; color: var(--text-muted); border-top: 1px solid var(--line); }
.pager:empty { display: none; }

/* 7. Badges -------------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px;
  border-radius: 3px;
  font: 700 0.64rem/1.5 var(--font-ui);
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text); background: var(--bg-4); border: 1px solid var(--line);
  white-space: nowrap; vertical-align: middle;
}
.badge.lg { font-size: 0.78rem; padding: 4px 12px; }
/* rank tiers */
.badge.rank-novice        { color: #a49a8d; border-color: #4c453f; background: #221d1a; }
.badge.rank-pit_fodder    { color: #c38e6b; border-color: #5b3a26; background: #24180f; }
.badge.rank-journeyman    { color: #d9a56a; border-color: #7a5424; background: #2a1d0f; }
.badge.rank-contender     { color: #d7dbe0; border-color: #6f7780; background: #22262b; }
.badge.rank-champion      { color: var(--gold-bright); border-color: var(--gold-dim); background: #2e2110; box-shadow: 0 0 10px rgba(224, 164, 88, 0.18); }
.badge.rank-grand_champion{ color: #fff0c8; border-color: var(--gold); background: linear-gradient(180deg, #4a3414, #2e2110); box-shadow: 0 0 14px rgba(245, 207, 133, 0.3); }
.badge.rank-legend        { color: #fff5e0; border-color: var(--ember-hot); background: linear-gradient(180deg, #5a2a10, #3a1a0c); box-shadow: 0 0 16px rgba(255, 143, 58, 0.45); text-shadow: 0 0 6px rgba(255, 200, 120, 0.6); }
/* status */
.badge.status-active  { color: var(--ok-bright); border-color: #3b5a3a; background: #14201a; }
.badge.status-retired { color: var(--text-muted); border-color: #4a4239; background: #1e1a17; }
.badge.status-master  { color: #b6c8dc; border-color: #4a5f78; background: #171d26; }
.badge.status-dead    { color: #f0a0a4; border-color: var(--blood); background: #2a0f11; }
.badge.status-ward    { color: var(--parchment-soft); border-style: dashed; border-color: #6b5f4a; background: transparent; }
.badge.status-missing { color: #d4b36a; border-style: dotted; border-color: #7a6432; background: #201a10; }
.badge.status-dead::before { content: "✝"; font-size: 0.8em; }
/* rarity text badges (frames are in §14) */
.badge.rarity-common    { color: #b9b4ae; border-color: #55504b; }
.badge.rarity-uncommon  { color: #8fd0ae; border-color: #3f6f58; }
.badge.rarity-rare      { color: #9cc3f0; border-color: #3f5f8a; }
.badge.rarity-epic      { color: #cfa8f5; border-color: #6b4693; }
.badge.rarity-legendary { color: #ffe8b0; border-color: var(--gold); box-shadow: 0 0 12px rgba(245, 207, 133, 0.3); }
/* semantic */
.badge.gold { color: var(--gold-bright); border-color: var(--gold-dim); }
.badge.blood { color: #f0a0a4; border-color: var(--blood); }
.badge.ok { color: var(--ok-bright); border-color: #3b5a3a; }
.badge.info { color: #b6c8dc; border-color: #4a5f78; }
.badge.warn { color: #ffd88a; border-color: #7a6432; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--dot, var(--gold)); vertical-align: middle; }

/* 8. Stat bars, radar, sparkline ---------------------------------------- */
.statbars { display: grid; grid-template-columns: max-content 1fr max-content; gap: 6px 10px; align-items: center; font-size: 0.82rem; }
.statbars .k { color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.1em; font-size: 0.66rem; font-weight: 600; }
.statbars .v { font-family: var(--font-display); color: var(--text-strong); font-variant-numeric: tabular-nums; text-align: right; min-width: 2.2em; }
.bar { position: relative; height: 8px; background: #0a0706; border: 1px solid var(--line-soft); border-radius: 4px; overflow: hidden; }
.bar .fill {
  height: 100%; width: calc(var(--v, 0) * 1%);
  background: linear-gradient(90deg, var(--gold-dim), var(--gold) 70%, var(--gold-bright));
  border-radius: 4px;
  transition: width var(--t) var(--ease);
}
.bar .fill.blood { background: linear-gradient(90deg, var(--blood-dark), var(--blood), var(--blood-bright)); }
.bar .fill.ok { background: linear-gradient(90deg, #2f5230, var(--ok), var(--ok-bright)); }
.bar .fill.info { background: linear-gradient(90deg, #2b3d52, var(--info), #a9c3dc); }
.bar .pot { position: absolute; top: -1px; bottom: -1px; left: calc(var(--p, 0) * 1%); width: 2px; background: var(--parchment); opacity: 0.6; }
.bar.lg { height: 12px; }
.bar.thin { height: 4px; }
/* bipolar style-axis bars (-1..1) */
.axis { display: grid; grid-template-columns: 5.5em 1fr 5.5em; align-items: center; gap: 8px; font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; }
.axis .track { position: relative; height: 6px; background: #0a0706; border-radius: 3px; border: 1px solid var(--line-soft); }
.axis .track::before { content: ""; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--line-strong); }
.axis .knob { position: absolute; top: 50%; left: calc(50% + var(--x, 0) * 50%); width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 6px rgba(224, 164, 88, 0.6); }
.axis .r { text-align: right; }

.radar { display: inline-block; width: var(--s, 220px); max-width: 100%; }
.radar svg { width: 100%; height: auto; }
.radar-ring { fill: none; stroke: var(--line-strong); stroke-width: 1; }
.radar-ring.outer { stroke: var(--gold-dim); }
.radar-axis { stroke: var(--line); stroke-width: 1; }
.radar-area { fill: rgba(224, 164, 88, 0.28); stroke: var(--gold); stroke-width: 1.5; stroke-linejoin: round; }
.radar-area.b { fill: rgba(216, 38, 46, 0.22); stroke: var(--blood-bright); }
.radar-dot { fill: var(--gold-bright); }
.radar-label { fill: var(--text-muted); font: 600 10px var(--font-ui); letter-spacing: 0.08em; text-transform: uppercase; }

.spark { display: inline-block; vertical-align: middle; color: var(--gold); }
.spark .spark-area { fill: currentColor; opacity: 0.16; }
.spark .spark-line { fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.spark .spark-end { fill: var(--gold-bright); }

/* 9. Timeline ------------------------------------------------------------ */
.timeline { list-style: none; margin: 0; padding: 0 0 0 18px; position: relative; }
.timeline::before { content: ""; position: absolute; left: 4px; top: 6px; bottom: 6px; width: 1px; background: linear-gradient(180deg, var(--gold-dim), var(--line) 40%, var(--line)); }
.timeline-item { position: relative; padding: 4px 0 12px 8px; }
.timeline-item::before {
  content: ""; position: absolute; left: -18px; top: 10px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--dot, var(--bg-5)); border: 1px solid var(--gold-dim);
  box-shadow: 0 0 0 3px var(--bg-1);
}
.timeline-item.major::before { --dot: var(--gold); box-shadow: 0 0 0 3px var(--bg-1), 0 0 10px rgba(224, 164, 88, 0.6); }
.timeline-item.blood::before { --dot: var(--blood-bright); border-color: var(--blood); }
.timeline-item.ok::before { --dot: var(--ok); border-color: #3b5a3a; }
.timeline-date { font: 600 0.66rem var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); }
.timeline-title { font-family: var(--font-display); color: var(--text-strong); font-size: 1rem; }
.timeline-text { color: var(--parchment-soft); font-size: 0.88rem; }

/* 10. Chronicle feed ---------------------------------------------------- */
.chronicle { display: flex; flex-direction: column; gap: 8px; }
.entry {
  position: relative;
  padding: 10px 14px 10px 16px;
  border-left: 2px solid var(--line);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: transparent;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.entry:hover { background: rgba(255, 225, 170, 0.025); border-left-color: var(--line-strong); }
.entry-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 2px; }
.entry-date { font: 600 0.64rem var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); }
.entry-kind { font-size: 0.62rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold-dim); font-weight: 700; }
.entry-title { font-family: var(--font-display); font-size: 1.05rem; color: var(--parchment); margin: 0; }
.entry-text { color: var(--parchment); opacity: 0.86; line-height: 1.6; margin: 4px 0 0; font-size: 0.93rem; }
.entry-text a { color: var(--gold-bright); }
.entry-refs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.entry.followed { border-left-color: var(--gold); background: rgba(224, 164, 88, 0.05); }
.entry.followed::after { content: "★"; position: absolute; right: 10px; top: 8px; color: var(--gold); font-size: 0.8rem; opacity: 0.8; }
/* weight 0: minor; 1: default; 2: notable; 3: headline */
.entry.w0 { padding: 4px 12px 4px 14px; opacity: 0.72; }
.entry.w0 .entry-title { font-size: 0.9rem; font-family: var(--font-ui); color: var(--parchment-soft); }
.entry.w0 .entry-text { font-size: 0.84rem; margin-top: 0; }
.entry.w2 { border-left-color: var(--ember); background: rgba(217, 116, 42, 0.05); }
.entry.w2 .entry-title { font-size: 1.25rem; color: var(--text-strong); }
.entry.w3 {
  border-left: 0;
  padding: 18px 22px 20px;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(224, 164, 88, 0.10), transparent 70%),
    linear-gradient(180deg, var(--parchment-bg-2), var(--parchment-bg));
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
}
.entry.w3::before {
  content: ""; display: block; height: 3px; margin: -6px 0 12px;
  border-top: 1px solid var(--gold); border-bottom: 1px solid var(--gold-dim);
}
.entry.w3 .entry-title { font-size: 1.7rem; line-height: 1.15; color: var(--text-strong); letter-spacing: 0.005em; }
.entry.w3 .entry-text { font-size: 1.02rem; line-height: 1.65; opacity: 0.95; }
.entry.w3 .entry-text::first-letter { font-family: var(--font-display); font-size: 2.4em; float: left; line-height: 0.8; padding: 4px 6px 0 0; color: var(--gold); }
.entry.kind-death_bout, .entry.kind-death_wound, .entry.kind-death_illness, .entry.kind-death_age { border-left-color: var(--blood); }
.entry.kind-death_bout .entry-kind, .entry.kind-death_wound .entry-kind { color: var(--blood-bright); }
.entry.kind-birth, .entry.kind-twinBirth { border-left-color: var(--ok); }
.entry.kind-legendInducted { border-left-color: var(--ember-hot); }
.ticker { display: flex; flex-direction: column; gap: 14px; align-items: center; text-align: center; padding: 6vh 4vw; }
.ticker .entry-title { font-size: clamp(1.6rem, 4vw, 3rem); }

/* 11. Fight viewer -------------------------------------------------------- */
.fv { display: grid; grid-template-columns: 1fr auto 1fr; gap: 14px; align-items: start; }
.fv-side { min-width: 0; }
.fv-side.b { text-align: right; }
.fv-name { font-family: var(--font-display); font-size: 1.15rem; color: var(--text-strong); }
.fv-vs { font-family: var(--font-display); color: var(--blood-bright); font-size: 1.3rem; letter-spacing: 0.1em; align-self: center; }
.fv-bar { position: relative; height: 12px; margin-top: 6px; background: #0a0706; border: 1px solid var(--line); border-radius: 3px; overflow: hidden; }
.fv-health .fill {
  height: 100%;
  width: calc(var(--p, 100) * 1%);
  background: var(--blood-bright);
  background: linear-gradient(90deg, hsl(calc(var(--p, 100) * 1.15deg) 60% 36%), hsl(calc(var(--p, 100) * 1.15deg) 70% 50%));
  transition: width 260ms var(--ease), background 260ms;
}
.fv-side.b .fv-health .fill { margin-left: auto; }
.fv-bar.fv-momentum { height: 8px; }
.fv-momentum .fill {
  position: absolute; top: 0; bottom: 0; left: 50%;
  width: calc(var(--m, 0) * 50%);
  background: linear-gradient(90deg, var(--gold-dim), var(--gold-bright));
  transition: width 260ms var(--ease);
}
.fv-momentum .fill.neg { left: auto; right: 50%; width: calc(var(--m, 0) * -50%); background: linear-gradient(270deg, var(--bg-5), var(--text-faint)); }
.fv-momentum::before { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: var(--line-strong); z-index: 1; }
.fv-bar-label { display: flex; justify-content: space-between; font-size: 0.62rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-muted); margin-top: 6px; }
.fv-log { max-height: 320px; overflow: auto; font-size: 0.92rem; line-height: 1.55; color: var(--parchment); }
.fv-ex { padding: 6px 10px; border-left: 2px solid transparent; }
.fv-ex.hit { border-left-color: var(--ember); }
.fv-ex.injury { border-left-color: var(--blood-bright); background: rgba(216, 38, 46, 0.06); }
.fv-ex.special { border-left-color: var(--gold); }
.fv-ex.current { background: rgba(224, 164, 88, 0.08); }
.fv-round { font-size: 0.66rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold-dim); font-weight: 700; margin: 10px 10px 4px; }
.fv-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.flash-hit { animation: flash-hit 420ms ease-out; }
@keyframes flash-hit { 0% { filter: brightness(1.8) drop-shadow(0 0 10px var(--blood-bright)); } 100% { filter: none; } }

/* 12. Body map ----------------------------------------------------------- */
.bodymap-panel { display: grid; grid-template-columns: minmax(160px, 250px) 1fr; gap: 16px; align-items: start; }
.bodymap {
  display: flex; justify-content: center; align-items: center;
  padding: 10px;
  background: radial-gradient(ellipse 70% 60% at 50% 45%, rgba(224, 164, 88, 0.08), transparent 70%), var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}
.bodymap svg { width: 100%; height: auto; max-height: 460px; }
.bodymap [data-part] { cursor: pointer; transition: filter var(--t-fast); }
.bodymap [data-part]:hover { filter: brightness(1.35); }
.bodymap.lit [data-part].hit { animation: flash-hit 420ms ease-out; }
.bodymap-legend { list-style: none; margin: 0; padding: 0; font-size: 0.84rem; }
.bodymap-legend li { display: flex; align-items: baseline; gap: 8px; padding: 5px 0; border-bottom: 1px dashed var(--line-soft); }
.bodymap-legend li:last-child { border-bottom: 0; }
.bodymap-legend .legend-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--dot, var(--gold)); align-self: center; }
.bodymap-legend .legend-dot.scar { border-radius: 1px; transform: rotate(-30deg); height: 3px; }
.bodymap-legend .legend-dot.mod { border-radius: 2px; background: var(--info); }
.bodymap-legend .legend-dot.mark { background: var(--parchment); }
.bodymap-legend .legend-dot.lost { background: transparent; border: 1px dashed var(--blood-bright); }
.bodymap-legend .part { color: var(--text-muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; margin-left: auto; }
.sev-1 { --dot: #d9a23a; } .sev-2 { --dot: #e08a2a; } .sev-3 { --dot: #d8552a; } .sev-4 { --dot: var(--blood-bright); } .sev-5 { --dot: #ff2a3c; }

/* 13. Sigils ------------------------------------------------------------- */
.sigil { display: inline-block; width: var(--s, 48px); height: var(--s, 48px); flex: none; vertical-align: middle; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5)); }
.sigil svg { width: 100%; height: 100%; display: block; }
.sigil.xs { --s: 20px; } .sigil.sm { --s: 28px; } .sigil.md { --s: 48px; } .sigil.lg { --s: 96px; } .sigil.xl { --s: 160px; }
.sigil.framed { padding: 4px; background: var(--bg-1); border: 1px solid var(--line-strong); border-radius: 50%; }

/* 14. Trading card ------------------------------------------------------- */
.pb-card {
  --w: 280px;
  --frame: linear-gradient(160deg, #7c7773 0%, #3a3634 45%, #8a8580 100%);
  --frame-glow: transparent;
  width: var(--w);
  font-size: clamp(8px, calc(var(--w) / 23), 15px);
  aspect-ratio: 5 / 7;
  padding: 0.55em;
  border-radius: 1em;
  background: var(--frame);
  box-shadow: var(--shadow), 0 0 22px var(--frame-glow);
  position: relative;
  display: flex;
  color: var(--text-strong);
  font-family: var(--font-ui);
  line-height: 1.3;
  break-inside: avoid;
  flex: none;
}
.pb-card.rarity-common    { --frame: linear-gradient(160deg, #7c7773 0%, #3a3634 45%, #8a8580 100%); }
.pb-card.rarity-uncommon  { --frame: linear-gradient(160deg, #6fb08f 0%, #234534 45%, #7fc09f 100%); --frame-glow: rgba(111, 176, 143, 0.18); }
.pb-card.rarity-rare      { --frame: linear-gradient(160deg, #6f9fd8 0%, #1f3556 45%, #86b3ea 100%); --frame-glow: rgba(111, 159, 216, 0.22); }
.pb-card.rarity-epic      { --frame: linear-gradient(160deg, #b07fe0 0%, #3b1f5c 45%, #c497ef 100%); --frame-glow: rgba(176, 127, 224, 0.26); }
.pb-card.rarity-legendary { --frame: linear-gradient(160deg, #ffe2a6 0%, #a5702c 35%, #5a3a12 55%, #f5cf85 100%); --frame-glow: rgba(245, 207, 133, 0.38); }
.pb-card.rarity-legendary::before {
  content: ""; position: absolute; inset: 0; border-radius: 1em; pointer-events: none;
  background: linear-gradient(115deg, transparent 30%, rgba(255, 245, 220, 0.35) 48%, transparent 62%);
  background-size: 250% 100%;
  animation: sheen 5s linear infinite;
  mix-blend-mode: screen;
}
@keyframes sheen { from { background-position: 120% 0; } to { background-position: -130% 0; } }
.pb-card-inner {
  flex: 1;
  display: flex; flex-direction: column;
  min-width: 0;
  border-radius: 0.55em;
  border: 1px solid rgba(0, 0, 0, 0.7);
  background: linear-gradient(180deg, #1a1411 0%, #0e0a08 100%);
  box-shadow: inset 0 1px 0 rgba(255, 225, 170, 0.06);
  overflow: hidden;
}
.pb-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.5em; padding: 0.7em 0.8em 0.4em; }
.pb-card-name { font-family: var(--font-display); font-size: 1.28em; font-weight: 700; line-height: 1.05; letter-spacing: 0.01em; color: var(--text-strong); }
.pb-card-epithet { font-family: var(--font-display); font-style: italic; color: var(--gold); font-size: 0.86em; margin-top: 0.15em; }
.pb-card-house { flex: none; width: 2.2em; height: 2.2em; }
.pb-card-house svg { width: 100%; height: 100%; }
.pb-card-portrait {
  position: relative;
  margin: 0 0.7em;
  aspect-ratio: 3 / 4;
  border: 1px solid var(--line-strong);
  border-radius: 0.3em;
  overflow: hidden;
  background: radial-gradient(ellipse 70% 60% at 50% 30%, rgba(217, 116, 42, 0.22), transparent 70%), #0a0706;
  display: flex; align-items: center; justify-content: center;
}
.pb-card-portrait img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pb-card-portrait svg { width: 100%; height: 100%; }
.pb-card-portrait .placeholder { color: var(--text-faint); font-size: 0.7em; letter-spacing: 0.14em; text-transform: uppercase; }
.pb-card-rank { position: absolute; left: 0.5em; bottom: 0.5em; font-size: 0.72em; }
.pb-card-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.3em 0.5em; padding: 0.6em 0.8em 0.3em; }
.pb-stat { font-size: 0.6em; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); min-width: 0; }
.pb-stat b { display: block; font-family: var(--font-display); font-size: 1.55em; font-weight: 600; color: var(--text-strong); line-height: 1.1; letter-spacing: 0; }
.pb-stat i { display: block; height: 0.35em; margin-top: 0.25em; background: #2a211c; border-radius: 2px; overflow: hidden; }
.pb-stat i::after { content: ""; display: block; height: 100%; width: calc(var(--v, 0) * 1%); background: linear-gradient(90deg, var(--gold-dim), var(--gold-bright)); }
.pb-card-record { display: flex; justify-content: space-between; padding: 0.15em 0.8em; font-family: var(--font-mono); font-size: 0.7em; color: var(--parchment-soft); letter-spacing: 0.06em; }
.pb-card-mods { display: flex; flex-wrap: wrap; gap: 0.3em; padding: 0.2em 0.8em; min-height: 1.6em; }
.pb-mod { width: 1.35em; height: 1.35em; border-radius: 50%; border: 1px solid var(--line-strong); background: #221a16; display: grid; place-items: center; font-size: 0.7em; color: var(--gold); }
.pb-mod.injury { border-color: var(--blood); color: var(--blood-bright); }
.pb-mod.prosthetic { border-color: var(--info); color: #b6c8dc; }
.pb-mod.mark { border-color: var(--parchment-soft); color: var(--parchment); }
.pb-card-lineage {
  margin-top: auto;
  padding: 0.45em 0.8em 0.55em;
  border-top: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.3);
  font-size: 0.58em;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  display: flex; justify-content: space-between; gap: 0.6em;
  white-space: nowrap; overflow: hidden;
}
.pb-card-lineage span { overflow: hidden; text-overflow: ellipsis; }
.pb-card-lineage .gen { color: var(--gold); font-weight: 700; }
.pb-card.sm { --w: 180px; }
.pb-card.lg { --w: 360px; }
.pb-card.flat { box-shadow: none; }
.pb-card.dead .pb-card-portrait { filter: grayscale(0.7) brightness(0.7); }

/* 15. Tabs ------------------------------------------------------------- */
.tabs-bar { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; margin-bottom: 14px; }
.tabs-bar::-webkit-scrollbar { display: none; }
.tab {
  padding: 8px 14px;
  background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px;
  color: var(--text-muted);
  font: 600 0.72rem/1.4 var(--font-ui); letter-spacing: 0.12em; text-transform: uppercase;
  cursor: pointer; white-space: nowrap;
  transition: color var(--t-fast), border-color var(--t-fast);
}
.tab:hover { color: var(--text-strong); }
.tab[aria-selected="true"] { color: var(--gold-bright); border-bottom-color: var(--gold); }
.tab .count { margin-left: 6px; color: var(--text-faint); font-weight: 400; letter-spacing: 0; }
.tabs-panel { min-height: 40px; }

/* 16. Modals ------------------------------------------------------------ */
.modal-root:empty { display: none; }
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center; padding: 16px;
  background: rgba(5, 3, 2, 0.74);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  animation: fade var(--t) ease-out;
}
.modal {
  width: min(560px, 100%);
  max-height: min(90vh, 90dvh);
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, var(--bg-3), var(--bg-2));
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow), 0 0 0 1px #000, 0 0 40px rgba(217, 116, 42, 0.08);
  animation: rise var(--t) var(--ease);
}
.modal.lg { width: min(920px, 100%); }
.modal.sm { width: min(420px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-title { margin: 0; font-size: 1.3rem; color: var(--gold-bright); }
.modal-body { padding: 16px 18px; overflow: auto; }
.modal-body > :last-child { margin-bottom: 0; }
.modal-foot { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--line); }
body.modal-open { overflow: hidden; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px) scale(0.98); } }

/* 17. Toasts ------------------------------------------------------------ */
.toasts {
  position: fixed; right: 16px; bottom: 16px; z-index: 200;
  display: flex; flex-direction: column; gap: 8px;
  width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px 10px 14px;
  background: var(--bg-3);
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--gold);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 0.88rem; line-height: 1.4;
  color: var(--text-strong);
  animation: toast-in var(--t) var(--ease);
}
.toast .msg { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.toast .btn { flex: none; }
.toast.success { border-left-color: var(--ok-bright); }
.toast.warn { border-left-color: var(--warn); }
.toast.error { border-left-color: var(--blood-bright); background: #221213; }
.toast.leaving { animation: toast-out var(--t) ease-in forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(12px); } }

/* 18. Placeholder, boot, empty states ----------------------------------- */
.boot { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; min-height: 50vh; color: var(--text-muted); }
.boot-mark { width: 56px; height: 56px; opacity: 0.8; animation: torch 1.6s ease-in-out infinite alternate; }
.boot-text { font-family: var(--font-display); font-style: italic; letter-spacing: 0.04em; }
.nojs { max-width: 480px; text-align: center; padding: 24px; border: 1px solid var(--line-strong); border-radius: var(--radius-lg); background: var(--bg-2); }
.nojs h1 { font-size: 1.4rem; color: var(--gold-bright); }

.placeholder {
  max-width: 720px; margin: 6vh auto 0;
  text-align: center;
  padding: 40px 28px 34px;
  background:
    radial-gradient(ellipse 60% 50% at 50% 0%, rgba(217, 116, 42, 0.16), transparent 70%),
    linear-gradient(180deg, var(--bg-3), var(--bg-2));
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.placeholder-mark { width: 72px; height: 72px; margin-bottom: 8px; filter: drop-shadow(0 0 12px rgba(255, 143, 58, 0.35)); }
.placeholder h1 { font-size: clamp(1.6rem, 4vw, 2.4rem); color: var(--gold-bright); margin-bottom: 6px; }
.placeholder .lede { font-family: var(--font-display); font-style: italic; color: var(--parchment); font-size: 1.08rem; max-width: 46ch; margin: 0 auto 18px; }
.placeholder .meta { display: inline-flex; flex-wrap: wrap; gap: 6px 14px; justify-content: center; font-family: var(--font-mono); font-size: 0.74rem; color: var(--text-muted); margin-bottom: 18px; }
.placeholder .halls { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.placeholder .dev { margin-top: 18px; font-size: 0.74rem; color: var(--text-faint); }
.placeholder details { margin-top: 14px; text-align: left; font-size: 0.8rem; }
.placeholder details pre { white-space: pre-wrap; color: var(--blood-bright); background: var(--bg-1); padding: 10px; border-radius: var(--radius); overflow: auto; }
.empty { text-align: center; padding: 32px 16px; color: var(--text-faint); font-style: italic; font-family: var(--font-display); font-size: 1.05rem; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line-strong); border-top-color: var(--gold); animation: spin 0.8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 19. Utilities -------------------------------------------------------- */
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.gold { color: var(--gold); }
.gold-bright { color: var(--gold-bright); }
.blood { color: var(--blood-bright); }
.ok { color: var(--ok-bright); }
.parchment { color: var(--parchment); }
.serif { font-family: var(--font-display); }
.italic { font-style: italic; }
.small { font-size: 0.82rem; }
.tiny { font-size: 0.7rem; }
.caps { text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.7rem; font-weight: 600; }
.num, .tabular { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden, [hidden] { display: none !important; }
.mt0 { margin-top: 0; } .mt1 { margin-top: 8px; } .mt2 { margin-top: 16px; } .mt3 { margin-top: 24px; }
.mb0 { margin-bottom: 0; } .mb1 { margin-bottom: 8px; } .mb2 { margin-bottom: 16px; } .mb3 { margin-bottom: 24px; }
.prose { max-width: 68ch; color: var(--parchment); line-height: 1.7; font-size: 1rem; }
.prose p { margin-bottom: 1em; }
.prose.bio p:first-of-type::first-letter { font-family: var(--font-display); font-size: 3em; float: left; line-height: 0.85; padding: 4px 8px 0 0; color: var(--gold); }
.divider { display: flex; align-items: center; gap: 12px; color: var(--gold-dim); font-size: 0.68rem; letter-spacing: 0.2em; text-transform: uppercase; margin: 18px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, transparent, var(--line-strong), transparent); }
.portrait { border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; background: var(--bg-1); aspect-ratio: 3 / 4; }
.portrait img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* 20. Responsive ------------------------------------------------------- */
@media (max-width: 960px) {
  .topbar-row { gap: 12px; }
  .brand-word { font-size: 1.1rem; letter-spacing: 0.18em; }
  .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  :root { --topbar-h: 50px; --gap: 12px; }
  .topbar-row { flex-wrap: nowrap; }
  .brand-word { display: none; }
  .world-strip { padding-left: 12px; gap: 6px; }
  .world-strip-label { display: none; }
  .world-name { font-size: 0.95rem; }
  .sim-speed-wrap { display: none; }
  .nav a { padding: 8px 10px 9px; font-size: 0.7rem; }
  .view { padding: 16px var(--gap) 40px; }
  h1 { font-size: 1.6rem; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .fv { grid-template-columns: 1fr; }
  .fv-side.b { text-align: left; }
  .fv-side.b .fv-health .fill { margin-left: 0; }
  .fv-vs { text-align: center; }
  .bodymap-panel { grid-template-columns: 1fr; }
  .bodymap { max-width: 260px; margin: 0 auto; }
  .toasts { right: 12px; left: 12px; bottom: 12px; width: auto; }
  .modal-backdrop { padding: 0; align-items: end; }
  .modal { width: 100%; max-height: 92dvh; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
  .statbars { grid-template-columns: 5.5em 1fr 2.5em; }
  .footer { font-size: 0.66rem; }
}
@media (max-width: 420px) {
  .world-name { display: none; }
  .world-sep { display: none; }
  .sim-controls { gap: 3px; }
  .btn-icon { width: 32px; height: 32px; }
}
@media (hover: none) {
  .btn:hover { box-shadow: none; }
}

/* 21. Print (cards) ------------------------------------------------------ */
@media print {
  body { background: #fff; color: #000; display: block; }
  body::before, .topbar, .nav, .footer, .toasts, .modal-root, .no-print, .sim-controls { display: none !important; }
  .view { max-width: none; padding: 0; }
  .panel { border-color: #999; box-shadow: none; background: #fff; color: #000; }
  .print-cards, .grid-cards { display: flex; flex-wrap: wrap; gap: 6mm; justify-content: flex-start; }
  .pb-card {
    --w: 63mm;
    box-shadow: none;
    break-inside: avoid; page-break-inside: avoid;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
    outline: 0.2mm dashed #bbb; outline-offset: 2mm;
  }
  .pb-card.rarity-legendary::before { display: none; }
  a { color: inherit; text-decoration: none; }
  @page { margin: 12mm; }
}

/* 22. Motion & focus ---------------------------------------------------- */
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 2px; }
.btn:focus-visible, .lock:focus-visible, .tab:focus-visible { outline-offset: 1px; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .brand-mark, .boot-mark, .sim-dot, .pb-card.rarity-legendary::before { animation: none !important; }
}
@media (prefers-contrast: more) {
  :root { --line: rgba(224, 164, 88, 0.35); --line-strong: rgba(224, 164, 88, 0.6); --text-muted: #b3a894; --text-faint: #8a7f6e; }
}
