/* waaahgame — design system v2 (token-based, mobile-first, grimdark dark-default) */

/* ============================================================
   DESIGN TOKENS — GRIMDARK (dark is default)
   ============================================================ */
:root {
  /* ── Core palette: concreto/gunmetal escuro ── */
  --bg: #0c0e11;
  --bg-deep: #07090b;
  --bg-elev: #14171c;
  --bg-elev-2: #1c2027;
  --fg: #e6e3da;
  --fg-muted: #9a9b94;
  --fg-faint: #85877f;
  --accent: #b11d1d;
  --accent-fg: #f4f1ea;
  --accent-soft: rgba(177,29,29,0.14);
  --border: #262a31;
  --border-strong: #3a3f48;
  --success: #3a7a52;
  --warn: #a06820;
  --danger: #a03030;
  --info: #2a5a8a;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.55);

  /* ── Angular corners (grimdark é reto) ── */
  --r-sm: 2px;
  --r-md: 3px;
  --r-lg: 4px;

  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-5: 24px; --space-6: 32px; --space-7: 48px; --space-8: 64px;
  --text-xs: 0.75rem; --text-sm: 0.875rem; --text-base: 1rem;
  --text-lg: 1.125rem; --text-xl: 1.25rem; --text-2xl: 1.5rem; --text-3xl: 2rem;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-display: 'Oswald', 'Oswald-fallback', 'Arial Narrow', sans-serif;
  --font-heading: var(--font-display);
  --font-mono: "Courier New", monospace;
  --ink: var(--fg);
  --accent-text: #e86058;      /* red-on-dark TEXT, clears AA on all 3 dark surfaces */
  --success-text: #4a9d69;
  --warn-text: #ca8429;
  --danger-text: #d36d6d;
  --nav-height: 56px;
  --container-max: 1100px;

  /* ── Gold vira bronze fosco (vermelho é herói agora) ── */
  --gold: #8c7a52;
  --gold-deep: #6b5c3a;
  --gold-soft: rgba(140,122,82,0.12);
  --border-gold: rgba(140,122,82,0.40);

  /* ── Aliases legados → grimdark (compat para templates antigos; apontam p/ tokens theme-aware, sem duplicar no light) ── */
  --text-primary: var(--fg);
  --text-secondary: var(--fg-muted);
  --text-muted: var(--fg-faint);
  --color-text-muted: var(--fg-muted);
  --bg-parchment: var(--bg);
  --bg-parchment-card: var(--bg-elev);
  --bg-parchment-hover: var(--bg-elev-2);
  --border-parchment: var(--border);

  /* ── Motif grimdark ── */
  --hazard-stripe: repeating-linear-gradient(
    45deg,
    #14171c 0 12px,
    #8c7a52 12px 24px
  );
  --rivet: rgba(0,0,0,0.5);

  /* ── Grand alliance accents (dark-tuned) ── */
  --ga-order: #5a9ce3;
  --ga-order-soft: rgba(90,156,227,0.14);
  --ga-chaos: #d96a5f;
  --ga-chaos-soft: rgba(217,106,95,0.14);
  --ga-death: #a98ad1;
  --ga-death-soft: rgba(169,138,209,0.14);
  --ga-destruction: #6ec78b;
  --ga-destruction-soft: rgba(110,199,139,0.14);
  --ga-universal: #c9a96e;
  --ga-universal-soft: rgba(201,169,110,0.14);

  /* Game system identity tokens */
  --system-aos:        #8c7a52;   /* bronze fosco — Age of Sigmar */
  --system-aos-soft:   rgba(140,122,82,0.14);
  --system-aos-border: rgba(140,122,82,0.50);
  --system-40k:        #b11d1d;   /* vermelho imperial — Warhammer 40K */
  --system-40k-soft:   rgba(177,29,29,0.14);
  --system-40k-border: rgba(177,29,29,0.50);
  --system-tc:         #7c2d2d;   /* vermelho-sangue escuro — Trench Crusade */
  --system-tc-soft:    rgba(124,45,45,0.15);
  --system-tc-border:  rgba(124,45,45,0.55);
}

/* ── Light theme (secundário, opt-in) ── */
[data-theme="light"] {
  --bg: #f5f2eb;
  --bg-deep: #eceae3;
  --bg-elev: #fdfcf9;
  --bg-elev-2: #f0ede6;
  --fg: #1a1a1a;
  --fg-muted: #4a4640;
  --fg-faint: #6b6660;
  --accent: #a31818;
  --accent-fg: #ffffff;
  --accent-soft: rgba(163,24,24,0.09);
  --border: #d4cfc5;
  --border-strong: #b8b0a0;
  --success: #2d8a4e;
  --warn: #c47a1a;
  --danger: #b8443a;
  --info: #2a6db8;
  --accent-text: #a31818;
  --success-text: #1f6637;
  --warn-text: #9a5e10;
  --danger-text: #932e25;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 14px rgba(0,0,0,0.12);
  --r-sm: 2px;
  --r-md: 3px;
  --r-lg: 4px;

  /* Gold darkened for text legibility on parchment (~4.5:1 on --bg) */
  --gold: #7a6238;
  --gold-deep: #5c4820;
  --gold-soft: rgba(122,98,56,0.10);
  --border-gold: rgba(122,98,56,0.40);

  --hazard-stripe: repeating-linear-gradient(
    45deg,
    #e8e4d8 0 12px,
    #c8c0a8 12px 24px
  );
  --rivet: rgba(0,0,0,0.12);

  --ga-order: #2055a0;
  --ga-order-soft: rgba(32,85,160,0.10);
  --ga-chaos: #9c2e25;
  --ga-chaos-soft: rgba(156,46,37,0.10);
  --ga-death: #5a3a7a;
  --ga-death-soft: rgba(90,58,122,0.10);
  --ga-destruction: #1e6b3c;
  --ga-destruction-soft: rgba(30,107,60,0.10);
  --ga-universal: #7a6238;
  --ga-universal-soft: rgba(122,98,56,0.10);

  --system-aos:        #7a6238;
  --system-aos-soft:   rgba(122,98,56,0.12);
  --system-aos-border: rgba(122,98,56,0.45);
  --system-40k:        #a31818;
  --system-40k-soft:   rgba(163,24,24,0.10);
  --system-40k-border: rgba(163,24,24,0.45);
  --system-tc:         #6a2222;
  --system-tc-soft:    rgba(106,34,34,0.12);
  --system-tc-border:  rgba(106,34,34,0.48);
}

/* ── Light theme component overrides ── */

/* Hero section: replace hardcoded dark gradient */
[data-theme="light"] .hero {
  background: linear-gradient(180deg, #ede9df 0%, #f5f2eb 60%, #ede9df 100%);
}

/* Hero title: remove dark text-stroke/shadow that looks muddy on parchment */
[data-theme="light"] .hero-title-text {
  -webkit-text-stroke: 0;
  text-shadow: 0 1px 0 rgba(0,0,0,0.12), 0 0 1px var(--accent);
}

/* Scanlines in hero::before are dark-only; hide in light */
[data-theme="light"] .hero::before { display: none; }

/* Glossary portal tooltip: light parchment style */
[data-theme="light"] .gloss-portal {
  background: #fdfcf8;
  color: #1a1a1a;
  border: 1px solid var(--border-gold);
  box-shadow: 0 4px 14px rgba(0,0,0,0.14);
}

/* Army new form: replace dark card background */
[data-theme="light"] .army-new-form {
  background: var(--bg-elev);
}

/* Army new text input: replace opaque-black tint */
[data-theme="light"] .army-new-text-input {
  background: var(--bg);
  color: var(--fg);
  border-color: var(--border-gold);
}

/* Radio card: replace dark rgba tint */
[data-theme="light"] .radio-card {
  background: var(--bg-elev-2);
  border-color: var(--border-gold);
}
[data-theme="light"] .radio-card:hover {
  background: var(--gold-soft);
  border-color: var(--gold);
}

/* Compare table dark header rows */
[data-theme="light"] .compare-header-row th,
[data-theme="light"] .compare-section-row td {
  background: var(--bg-elev-2);
  color: var(--gold);
}

/* Print regiment header: replace dark gradient */
[data-theme="light"] .print-regiment-header {
  background: var(--bg-elev-2);
}
[data-theme="light"] .print-regiment-label {
  color: var(--gold);
}

/* btn-cta: border on parchment white */
[data-theme="light"] .btn-cta {
  border-color: rgba(0,0,0,0.08);
}

/* mobile bottom nav sheet backdrop in light */
[data-theme="light"] .mbn-sheet-backdrop {
  background: rgba(0,0,0,0.35);
}

/* Factions system summary: gold text on parchment needs darker gold */
[data-theme="light"] .factions-system-summary {
  background: linear-gradient(180deg, var(--bg-elev-2) 0%, var(--bg-elev) 100%);
}

/* select / option background in light (browser default may be white — fine, but enforce token) */
[data-theme="light"] select,
[data-theme="light"] .form-select,
[data-theme="light"] .filter-select {
  background: var(--bg-elev);
  color: var(--fg);
  border-color: var(--border);
}

/* Glossary page cat title: gold already overridden via token */
/* Gloss entry term fallback text color handled via token --fg */

/* mt-substat in light: --bg-deep #eceae3 on --bg-elev white — fine */
/* mt-round-pip.is-done uses --gold now #7a6238 — passes on light */

/* War room rank badge background */
[data-theme="light"] .wr-rank-badge {
  background: var(--bg-elev-2);
}

/* Ladder rows even: bg-deep is warm grey in light — ok */

/* Section divider label bg ensures no bleed on parchment */
[data-theme="light"] .section-divider-label {
  background: var(--bg-elev);
}

/* Gloss search default color fallback */
[data-theme="light"] .gloss-search {
  background: var(--bg-elev);
  color: var(--fg);
  border-color: var(--border-gold);
}

/* Enhancements desc text: undefined tokens bg-elev-1/fg-secondary — patch */
[data-theme="light"] .enhancements-desc-text {
  background: var(--gold-soft);
  color: var(--fg-muted);
}

/* ============================================================
   RESET + BASE
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

html, body {
  min-height: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--fg);
  font-size: var(--text-base);
  line-height: 1.5;
}

/* Textura grimdark: vinheta + granulado (somente dark) */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background:
    radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.45) 100%),
    repeating-linear-gradient(0deg, rgba(255,255,255,0.012) 0 1px, transparent 1px 3px);
}

[data-theme="light"] body::before { display: none; }

a {
  color: var(--accent-text);
  text-decoration: none;
  transition: opacity 0.2s;
}

a:hover {
  opacity: 0.8;
}

img, svg {
  display: block;
}

p { margin-bottom: var(--space-3); }
p:last-child { margin-bottom: 0; }

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  line-height: 1.2;
  color: var(--fg);
}

/* ============================================================
   LAYOUT UTILITY
   ============================================================ */
.container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--space-4);
}

@media (min-width: 640px) {
  .container { padding: 0 var(--space-5); }
}

.section-stack { display: flex; flex-direction: column; gap: var(--space-6); }

/* ============================================================
   SITE HEADER / NAV
   ============================================================ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 200;
  background: var(--bg-elev);
  border-bottom: 2px solid var(--accent);
  box-shadow: 0 0 8px rgba(177,29,29,0.25);
  height: var(--nav-height);
  /* Hazard stripe topo 6px */
  background-image: var(--hazard-stripe);
  background-size: 24px 6px;
  background-repeat: repeat-x;
  background-position: top left;
  /* overflow visível p/ dropdown "MAIS" escapar do header (stripe é background, não transborda) */
  overflow: visible;
}

/* Overlay para fundo sólido por cima da stripe */
.site-header::before {
  content: '';
  position: absolute;
  inset: 6px 0 0 0;
  background: var(--bg-elev);
  z-index: 0;
}

.site-header nav.container {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  height: var(--nav-height);
  position: relative;
  z-index: 1;
}

/* Brand */
.brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none;
  flex-shrink: 0;
  color: inherit;
}

.brand:hover { opacity: 1; }

.brand-mark {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.brand-mark svg { width: 22px; height: 22px; }

.brand-name {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg);
}

/* Nav links */
.nav-links {
  display: none;
  list-style: none;
  gap: var(--space-1);
  margin-left: var(--space-2);
}

@media (min-width: 769px) {
  .nav-links {
    display: flex;
    align-items: center;
  }
}

.nav-links a {
  position: relative;
  display: block;
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-muted);
  border-radius: var(--r-sm);
  border-bottom: 2px solid transparent;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.nav-links a:hover {
  opacity: 1;
  color: var(--fg);
  background: var(--accent-soft);
}

.nav-links .nav-active {
  color: var(--accent-text);
  background: var(--accent-soft);
  border-bottom: 2px solid var(--accent);
  box-shadow: 0 2px 6px rgba(177,29,29,0.2);
}

/* Entalhe vermelho no topo do link ativo */
.nav-links .nav-active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 16px;
  height: 5px;
  background: var(--accent);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
}

.nav-links .disabled {
  color: var(--fg-faint);
  cursor: not-allowed;
  pointer-events: none;
}

/* Nav auth */
.nav-auth {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  border-left: 1px solid var(--border);
  padding-left: var(--space-3);
  margin-left: var(--space-3);
}

.nav-auth-link {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--r-sm);
  transition: color 0.15s, background 0.15s;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

.nav-auth-link:hover {
  opacity: 1;
  color: var(--fg);
  background: var(--accent-soft);
}

.nav-auth-btn {
  display: inline-flex;
}

.nav-auth-link--profile {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.nav-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border-strong);
  flex-shrink: 0;
}

.btn-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-2) var(--space-4);
  background: var(--accent);
  color: var(--accent-fg);
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  border-radius: var(--r-sm);
  border: 1px solid rgba(255,255,255,0.12);
  cursor: pointer;
  text-decoration: none;
  transition: filter 0.15s, box-shadow 0.15s, transform 0.1s;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(177,29,29,0.4);
}

.btn-cta:hover:not(:disabled) {
  filter: brightness(1.12);
  color: var(--accent-fg);
  box-shadow: 0 4px 14px rgba(177,29,29,0.55);
}

.btn-cta:active {
  transform: translateY(1px);
}

.btn-cta:disabled,
.btn-cta[disabled] {
  opacity: 0.45;
  box-shadow: none;
  cursor: not-allowed;
}

/* ── Nav "MAIS" dropdown (desktop) ── */
.nav-dropdown { position: relative; display: flex; }
.nav-dropdown-details { position: relative; }
.nav-dropdown-summary {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-muted);
  border-radius: var(--r-sm);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.nav-dropdown-summary::-webkit-details-marker { display: none; }
.nav-dropdown-summary:hover { color: var(--fg); background: var(--accent-soft); }
.nav-dropdown-summary.nav-active {
  color: var(--accent-text);
  background: var(--accent-soft);
  border-bottom: 2px solid var(--accent);
}
.nav-dropdown-caret { width: 11px; height: 11px; transition: transform 0.18s; }
.nav-dropdown-details[open] .nav-dropdown-caret { transform: rotate(180deg); }

.nav-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 184px;
  display: flex;
  flex-direction: column;
  padding: var(--space-2);
  gap: 2px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-top: 2px solid var(--accent);
  border-radius: var(--r-sm);
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
  z-index: 250;
}
.nav-dropdown-menu a {
  display: block;
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-muted);
  text-decoration: none;
  border-radius: var(--r-sm);
  border-left: 2px solid transparent;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.nav-dropdown-menu a:hover {
  color: var(--fg);
  background: var(--accent-soft);
  border-left-color: var(--accent);
}
.nav-dropdown-menu a.is-active {
  color: var(--accent-text);
  background: var(--accent-soft);
  border-left-color: var(--accent);
}

/* CTA item no sheet mobile (guest "Alistar") */
.mbn-sheet-item--cta {
  color: var(--accent-text);
  border-color: var(--accent) !important;
  background: var(--accent-soft);
}

/* Theme toggle */
.theme-toggle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
}

.theme-toggle:hover { background: var(--accent-soft); }

.theme-toggle svg {
  width: 20px;
  height: 20px;
}

/* Icon swap: dark is default — default shows sun (switch-to-light), light shows moon (switch-to-dark) */
:root .icon-moon { display: none; }
[data-theme="light"] .icon-moon { display: inline; }
[data-theme="light"] .icon-sun { display: none; }

/* ============================================================
   MOBILE BOTTOM NAV
   ============================================================ */
.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(64px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--bg-elev);
  border-top: 2px solid var(--accent);
  box-shadow: 0 -2px 8px rgba(177,29,29,0.18);
  z-index: 100;
  display: flex;
  align-items: stretch;
}

@media (min-width: 769px) {
  .mobile-bottom-nav { display: none; }
}

.mbn-tab {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 11px;
  color: var(--fg-faint);
  text-decoration: none;
  transition: color 0.15s;
  min-width: 0;
}

.mbn-tab:hover { opacity: 1; color: var(--accent-text); }

.mbn-tab svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.mbn-tab span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  line-height: 1.1;
  font-size: clamp(9px, 2.6vw, 11px);
}

.mbn-tab--active {
  color: var(--accent-text);
}

.mbn-tab--active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent);
}

/* "Mais" trigger é <button> — zera estilo nativo p/ casar com .mbn-tab */
.mbn-more-trigger {
  background: none;
  border: none;
  font: inherit;
  cursor: pointer;
  padding: 0;
}

/* ── Sheet de overflow "Mais" ── */
.mbn-sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 110;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.mbn-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 120;
  background: var(--bg-elev);
  border-top: 2px solid var(--accent);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.5);
  padding: var(--space-3) var(--space-4) calc(var(--space-4) + env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}
body.mbn-sheet-open .mbn-sheet-backdrop { opacity: 1; }
body.mbn-sheet-open .mbn-sheet { transform: translateY(0); }

.mbn-sheet-handle {
  width: 40px;
  height: 3px;
  background: var(--fg-faint);
  margin: 0 auto var(--space-3);
}
.mbn-sheet-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
}
.mbn-sheet-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  min-height: 64px;
  padding: var(--space-2);
  color: var(--fg-muted);
  text-decoration: none;
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: clamp(9px, 2.8vw, 11px);
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.mbn-sheet-item svg { width: 22px; height: 22px; flex-shrink: 0; }
.mbn-sheet-item:hover,
.mbn-sheet-item:focus-visible { color: var(--accent-text); border-color: var(--accent); }
.mbn-sheet-item.is-active {
  color: var(--accent-text);
  border-color: var(--accent);
  background: var(--accent-soft);
}
.mbn-sheet-logout {
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
}
.mbn-sheet-logout .mbn-sheet-item { width: 100%; flex-direction: row; gap: var(--space-2); min-height: 48px; }
.mbn-sheet-item--danger:hover,
.mbn-sheet-item--danger:focus-visible { color: var(--danger-text); border-color: var(--danger); }

@media (min-width: 769px) {
  .mbn-sheet,
  .mbn-sheet-backdrop { display: none !important; }
}

/* ============================================================
   MAIN + FOOTER
   ============================================================ */
main {
  min-height: calc(100vh - var(--nav-height) - 80px);
  padding-bottom: 80px;
}

@media (min-width: 769px) {
  main { padding-bottom: 0; }
}

.site-footer {
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: var(--space-5) 0;
  text-align: center;
}

.footer-quote {
  font-family: var(--font-display);
  font-style: normal;
  font-size: var(--text-sm);
  letter-spacing: 0.08em;
  color: var(--fg-muted);
  margin-bottom: var(--space-1);
}

.footer-meta {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  color: var(--fg-faint);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* ============================================================
   FLASH MESSAGES
   ============================================================ */
.flash-container {
  position: sticky;
  top: var(--nav-height);
  z-index: 190;
}

.flash {
  padding: var(--space-3) 0;
  font-size: var(--text-sm);
  font-weight: 500;
  text-align: center;
}

.flash-success { background: var(--success); color: #fff; }
.flash-error   { background: var(--danger);  color: #fff; }
.flash-warning { background: var(--warn);    color: #fff; }
.flash-info    { background: var(--info);    color: #fff; }
.flash-danger  { background: var(--danger);  color: #fff; }
.flash-message { background: var(--info);    color: #fff; }

/* ============================================================
   TYPOGRAPHY HELPERS
   ============================================================ */
.eyebrow {
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg-faint);
  margin-bottom: var(--space-2);
}

.section-title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg);
  margin-bottom: var(--space-4);
}

.quote {
  font-family: var(--font-display);
  font-style: normal;
  font-size: var(--text-sm);
  letter-spacing: 0.04em;
  color: var(--fg-muted);
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn-primary,
.btn-secondary,
.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  min-height: 44px;
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.15s, background 0.15s, border-color 0.15s, box-shadow 0.15s, filter 0.15s, transform 0.1s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(177,29,29,0.35);
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.12);
  color: var(--accent-fg);
  box-shadow: 0 4px 14px rgba(177,29,29,0.5);
}

.btn-primary:active {
  transform: translateY(1px);
}

.btn-primary:disabled,
.btn-primary[disabled] {
  opacity: 0.45;
  box-shadow: none;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--bg-elev-2);
  color: var(--fg);
  border-color: var(--border);
}

.btn-secondary:hover { opacity: 1; background: var(--bg-elev); border-color: var(--border-strong); color: var(--fg); }

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.btn-danger:hover { opacity: 0.88; color: #fff; }

/* Anel de foco por teclado */
a:focus-visible,
button:focus-visible,
.btn-primary:focus-visible,
.btn-secondary:focus-visible,
.btn-danger:focus-visible,
.btn-cta:focus-visible,
.nav-links a:focus-visible,
.nav-auth-link:focus-visible,
.theme-toggle:focus-visible,
.mbn-tab:focus-visible,
.brand:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* Skip-link — fora da tela até receber foco por teclado */
.skip-link {
  position: absolute;
  left: var(--space-3);
  top: -56px;
  z-index: 1000;
  padding: var(--space-2) var(--space-4);
  background: var(--accent);
  color: #fff;
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: var(--text-sm);
  border-radius: 0;
  text-decoration: none;
  transition: top 0.15s ease;
}
.skip-link:focus {
  top: var(--space-3);
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.btn-sm {
  padding: var(--space-1) var(--space-3);
  min-height: 32px;
  font-size: var(--text-xs);
}

.btn-full { width: 100%; }

/* ============================================================
   FORMS
   ============================================================ */
.form-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin-bottom: var(--space-4);
}

.form-field label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--fg-muted);
}

.form-field-check {
  flex-direction: row;
  align-items: center;
}

.form-field-inline {
  flex-direction: row;
  align-items: center;
  gap: var(--space-2);
}

.check-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  cursor: pointer;
  color: var(--fg-muted);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
textarea,
select,
.form-input,
.form-select {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  background: var(--bg-elev);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size: var(--text-sm);
  line-height: 1.5;
  transition: border-color 0.15s;
  min-height: 40px;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="search"]:focus,
textarea:focus,
select:focus,
.form-input:focus,
.form-select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

textarea {
  min-height: 100px;
  resize: vertical;
}

.field-error {
  font-size: var(--text-xs);
  color: var(--danger-text);
}

/* ============================================================
   CARDS (base)
   ============================================================ */
.card-form {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  padding: var(--space-5);
}

.card-form-header {
  margin-bottom: var(--space-5);
}

.card-form-sub {
  font-size: var(--text-sm);
  color: var(--fg-muted);
}

.card-form-footer {
  margin-top: var(--space-5);
  font-size: var(--text-sm);
  color: var(--fg-muted);
  text-align: center;
}

/* ============================================================
   BADGES / PILLS
   ============================================================ */
.role-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-2);
  background: var(--bg-elev-2);
  color: var(--fg-muted);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.pts-badge {
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
  padding: 2px var(--space-2);
  background: var(--accent-soft);
  color: var(--accent-text);
  border: 1px solid var(--accent);
  border-radius: var(--r-sm);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.04em;
}

.pts-label {
  font-size: 0.65rem;
  font-weight: 500;
  opacity: 0.75;
}

.system-badge,
.ws-system-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-2);
  background: var(--fg);
  color: var(--bg);
  border-radius: var(--r-sm);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ── System identity badges ───────────────────────────── */
.sys-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-2);
  border-radius: var(--r-sm);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid transparent;
}
.sys-badge--aos {
  background: var(--system-aos-soft);
  color: var(--system-aos);
  border-color: var(--system-aos-border);
}
.sys-badge--40k {
  background: var(--system-40k-soft);
  color: var(--system-40k);
  border-color: var(--system-40k-border);
}
.sys-badge--tc {
  background: var(--system-tc-soft);
  color: var(--system-tc);
  border-color: var(--system-tc-border);
}
:root:not([data-theme="light"]) .sys-badge--aos { color: #d4a96e; border-color: rgba(212,169,110,0.5); background: rgba(184,147,90,0.18); }
:root:not([data-theme="light"]) .sys-badge--40k { color: #e05545; border-color: rgba(224,85,69,0.5);  background: rgba(192,57,43,0.18); }
:root:not([data-theme="light"]) .sys-badge--tc  { color: #c05050; border-color: rgba(192,80,80,0.5);  background: rgba(124,45,45,0.20); }

.alliance-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-2);
  border-radius: var(--r-sm);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--bg-elev-2);
  color: var(--fg-muted);
  border: 1px solid var(--border);
}

.legal-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-2);
  border-radius: var(--r-sm);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  border: 1px solid;
}

.legal-pill--legal {
  background: rgba(45,138,78,0.12);
  color: var(--success-text);
  border-color: rgba(45,138,78,0.35);
}

.legal-pill--illegal {
  background: rgba(184,68,58,0.12);
  color: var(--danger-text);
  border-color: rgba(184,68,58,0.35);
}

.legal-pill--outdated {
  background: rgba(200,140,40,0.14);
  color: #c88c28;
  border-color: rgba(200,140,40,0.40);
}

/* ── Data center (homepage / lockdown / manage) ───────────────────────────── */
.datacenter-intro {
  font-size: 1.02rem;
  opacity: 0.82;
  margin-top: 0.5rem;
  max-width: 64ch;
}
.datacenter-alert {
  margin: var(--space-3) 0;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--r-md);
  border: 1px solid transparent;
  font-size: 0.95rem;
  line-height: 1.45;
}
.datacenter-alert--outdated {
  background: rgba(200,140,40,0.10);
  border-color: rgba(200,140,40,0.40);
  color: #c88c28;
}
.datacenter-home { margin-top: var(--space-6); }
.datacenter-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  width: 100%;
}
.datacenter-form input[type="file"] { font-size: 0.8rem; max-width: 170px; }
.datacenter-card--outdated { border-color: rgba(200,140,40,0.40); }
.datacenter-card--locked { opacity: 0.92; }

.keyword-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-2);
  background: var(--bg-elev-2);
  color: var(--fg-muted);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.reinforced-tag {
  display: inline-flex;
  align-items: center;
  padding: 1px var(--space-2);
  background: rgba(196,122,26,0.12);
  color: var(--warn-text);
  border: 1px solid rgba(196,122,26,0.35);
  border-radius: var(--r-sm);
  font-size: var(--text-xs);
  font-weight: 600;
}

.unit-count-tag {
  font-size: var(--text-xs);
  color: var(--fg-faint);
}

/* Readonly enhancement chips (public army view) */
.enhancements-readonly,
.army-picks-readonly,
.au-card-enh-readonly {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-2);
}
.au-card-enh-readonly {
  padding: 0 var(--space-3) var(--space-3);
}
.pub-owner-label {
  font-size: var(--text-sm);
  color: var(--fg-muted);
  align-self: center;
  margin-right: var(--space-2);
}
.au-card--readonly { cursor: default; }
.pack-gate-banner {
  margin: 1rem 0 1.5rem;
  padding: 1rem 1.2rem;
  border: 1px solid var(--system-40k, #b11d1d);
  border-radius: 6px;
  background: rgba(177,29,29,0.08);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.pack-gate-banner p { margin: 0; max-width: 70ch; }
.ws-leader-leads {
  margin: 0 0 1rem;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--gold, #b48c3c);
  border-radius: 4px;
  background: rgba(180,140,60,0.08);
}
.ws-leader-leads-label {
  display: block;
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold, #b48c3c);
  margin-bottom: 0.5rem;
}
.ws-leader-leads-list { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.ws-leader-lead-tag { font-size: 0.78rem; }
.enh-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  padding: 2px var(--space-2);
  background: rgba(180,140,60,0.10);
  border: 1px solid rgba(180,140,60,0.35);
  border-radius: var(--r-sm);
  font-size: var(--text-xs);
  color: var(--fg);
}
.enh-chip-label {
  font-weight: 600;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 10px;
}

/* Expandable enhancement chips (click to reveal description) */
.enh-chip-wrap { display: inline-block; }
.enh-chip-wrap[open] { flex-basis: 100%; }
.enh-chip-wrap > summary.enh-chip {
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.enh-chip-wrap > summary.enh-chip::-webkit-details-marker { display: none; }
.enh-chip-wrap > summary.enh-chip::after {
  content: "\25BE"; /* down caret */
  font-size: 0.7em;
  opacity: 0.55;
  margin-left: 0.3em;
  transition: transform 0.15s ease;
}
.enh-chip-wrap[open] > summary.enh-chip {
  background: rgba(180,140,60,0.20);
  border-color: rgba(180,140,60,0.6);
}
.enh-chip-wrap[open] > summary.enh-chip::after { transform: rotate(180deg); }
.enh-chip-wrap > summary.enh-chip:hover { background: rgba(180,140,60,0.18); }
.enh-chip-body {
  margin-top: 0.4rem;
  max-width: 64ch;
  padding: 0.5rem 0.65rem;
  background: var(--surface-2, rgba(180,140,60,0.06));
  border: 1px solid rgba(180,140,60,0.25);
  border-left: 3px solid rgba(180,140,60,0.6);
  border-radius: var(--r-sm);
  font-size: var(--text-sm);
  line-height: 1.5;
  color: var(--fg);
}

/* ============================================================
   SECTIONS (generic)
   ============================================================ */
.factions-section,
.warscroll-section,
.armies-section,
.armies-builder-section,
.auth-section,
.friends-section {
  padding: var(--space-6) 0;
}

.factions-header,
.armies-header,
.builder-header {
  margin-bottom: var(--space-5);
}

.builder-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.builder-header-left { flex: 1; }

.builder-header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

/* ============================================================
   FACTIONS PAGE — grouped details/summary tree
   ============================================================ */
.factions-intro {
  color: var(--fg-muted);
  max-width: 640px;
  margin-bottom: var(--space-5);
  font-size: var(--text-sm);
  line-height: 1.6;
}

/* Game-system level (outer details) */
.factions-system-details {
  border: 1px solid var(--border-gold);
  border-radius: var(--r-md);
  margin-bottom: var(--space-4);
  background: var(--bg-elev);
  overflow: hidden;
}

.factions-system-summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
  background: linear-gradient(180deg, var(--bg-elev-2) 0%, var(--bg-elev) 100%);
  user-select: none;
}

.factions-system-summary::-webkit-details-marker { display: none; }
.factions-system-summary::marker { display: none; }

.factions-system-name { flex: 1; }

.factions-system-meta {
  font-size: var(--text-xs);
  font-weight: 400;
  letter-spacing: 0.06em;
  color: var(--fg-faint);
  text-transform: none;
}

.factions-system-chevron {
  font-size: 0.7rem;
  color: var(--fg-faint);
  transition: transform 0.2s ease;
}

.factions-system-details[open] > .factions-system-summary { border-bottom: 1px solid var(--border-gold); }
.factions-system-details[open] > .factions-system-summary .factions-system-chevron { transform: rotate(90deg); }

.factions-system-body {
  padding: var(--space-4) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

/* Alliance level (inner details) */
.factions-alliance-details {
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg);
  overflow: hidden;
}

.factions-alliance-summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-elev);
  user-select: none;
}

.factions-alliance-summary::-webkit-details-marker { display: none; }
.factions-alliance-summary::marker { display: none; }

.factions-alliance-count {
  font-size: var(--text-xs);
  color: var(--fg-faint);
  letter-spacing: 0.04em;
  flex: 1;
}

.factions-alliance-chevron {
  font-size: 0.65rem;
  color: var(--fg-faint);
  transition: transform 0.2s ease;
}

.factions-alliance-details[open] > .factions-alliance-summary { border-bottom: 1px solid var(--border); }
.factions-alliance-details[open] > .factions-alliance-summary .factions-alliance-chevron { transform: rotate(90deg); }

.factions-alliance-body {
  padding: var(--space-4);
}

/* Faction card grid */
.faction-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-4);
}

@media (max-width: 480px) {
  .faction-grid { grid-template-columns: 1fr; }
}

.faction-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  transition: box-shadow 0.2s, border-color 0.2s;
}

.faction-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-gold);
}

.faction-card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.faction-card-name {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--fg);
  line-height: 1.3;
}

.faction-card-blurb {
  font-size: var(--text-xs);
  color: var(--fg-muted);
  line-height: 1.5;
  flex: 1;
  /* show up to 5 lines, then ellipsize */
  display: -webkit-box;
  -webkit-line-clamp: 5;
  line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.faction-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-top: auto;
}

.faction-unit-count {
  font-size: var(--text-xs);
  color: var(--fg-faint);
}

.factions-empty {
  color: var(--fg-faint);
  font-size: var(--text-sm);
  padding: var(--space-4) 0;
}

/* detail page */
.faction-detail-section { padding: var(--space-6) 0; }
.faction-detail-header { margin-bottom: var(--space-5); }
.faction-detail-title-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-3);
}
.faction-detail-blurb {
  color: var(--fg-muted);
  max-width: 660px;
  line-height: 1.65;
}

/* ============================================================
   UNIT GRID (units/index)
   ============================================================ */
.unit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--space-4);
}

@media (min-width: 640px) {
  .unit-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}

@media (min-width: 960px) {
  .unit-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
}

.unit-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--bg-elev) 0%, var(--bg-elev-2) 100%);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow 0.2s, transform 0.15s, border-color 0.2s;
  cursor: pointer;
}

.unit-card:hover {
  box-shadow: 0 8px 22px rgba(0,0,0,0.38);
  transform: translateY(-3px);
  border-color: rgba(180,140,60,0.55);
}

.unit-card--bb {
  border-color: var(--accent);
}

.unit-card-link {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
}

.unit-image-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background:
    radial-gradient(120% 85% at 50% 15%, rgba(255,255,255,0.05), transparent 60%),
    var(--bg-elev-2);
  overflow: hidden;
}
/* soft bottom fade so studio shots (often white bg) sit into the dark card */
.unit-image-frame::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 40%;
  background: linear-gradient(180deg, transparent, rgba(13,15,19,0.5));
  pointer-events: none;
}

.unit-card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.35s ease;
}
.unit-card:hover .unit-card-img { transform: scale(1.05); }

/* broken-image fallback: onerror tags the frame and removes the <img> */
.unit-image-frame--empty::before {
  content: "\2694";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  color: var(--gold);
  opacity: 0.3;
}

.unit-card-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-faint);
  background: radial-gradient(circle at 50% 42%, rgba(180,140,60,0.10), transparent 65%);
}

.unit-card-placeholder svg { width: 60px; height: 60px; opacity: 0.55; }

.unit-card-body {
  position: relative;
  z-index: 2;
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  flex: 1;
}

.unit-card-name,
.unit-name {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--fg);
  margin-bottom: 0;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.unit-card-name a,
.unit-name a { color: inherit; text-decoration: none; transition: color 0.15s; }
.unit-card:hover .unit-card-name a { color: var(--gold); }

.unit-card-meta,
.unit-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: auto;
}

.unit-pts { font-size: var(--text-xs); font-weight: 700; color: var(--accent-text); }

/* Role chip overlaid on the unit image (top-left) */
.unit-card-role-overlay {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 2;
  padding: 2px 8px;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg);
  background: rgba(13,15,19,0.72);
  backdrop-filter: blur(2px);
  border: 1px solid rgba(180,140,60,0.4);
  border-radius: 9999px;
  pointer-events: none;
}

/* unit rows partial (_unit_rows.html) */
.unit-rows-wrap {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--space-4);
}

@media (min-width: 640px) {
  .unit-rows-wrap { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}

/* ============================================================
   WARSCROLL CARD (units/detail)
   ============================================================ */
.ws-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  margin-bottom: var(--space-6);
}

.ws-header {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-5);
  background: var(--bg-elev-2);
  border-bottom: 1px solid var(--border);
}

@media (min-width: 640px) {
  .ws-header {
    flex-direction: row;
    align-items: flex-start;
  }
}

.ws-header-image {
  flex-shrink: 0;
  width: 100%;
  max-width: 180px;
}

.ws-hero-img {
  width: 100%;
  border-radius: var(--r-md);
  object-fit: cover;
}

.ws-hero-placeholder {
  width: 100%;
  aspect-ratio: 1/1;
  max-width: 180px;
  background: var(--bg-elev);
  border: 1px dashed var(--border);
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-faint);
}

.ws-header-meta { flex: 1; min-width: 0; }

.ws-header-top-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  margin-bottom: var(--space-2);
}

.ws-name {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--fg);
  margin-bottom: var(--space-3);
  line-height: 1.15;
}

.ws-badges-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  margin-bottom: var(--space-3);
}

.ws-pts { font-size: var(--text-sm); }

.ws-ruleset-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px var(--space-2);
  background: var(--accent-soft);
  color: var(--accent-text);
  border: 1px solid var(--accent);
  border-radius: var(--r-sm);
  font-size: var(--text-xs);
  font-weight: 600;
}

/* Stats bar — C2: flex nowrap, single horizontal line */
.ws-stats-bar {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: var(--space-1);
  margin-bottom: var(--space-3);
  /* subtle scrollbar */
  scrollbar-width: thin;
  scrollbar-color: var(--border-gold) transparent;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
}
.ws-stats-bar::-webkit-scrollbar { height: 3px; }
.ws-stats-bar::-webkit-scrollbar-track { background: transparent; }
.ws-stats-bar::-webkit-scrollbar-thumb { background: var(--border-gold); border-radius: 2px; }

.ws-stat-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-1) var(--space-2);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  min-width: 36px;
  flex-shrink: 0;
}

.ws-stat-val {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--fg);
  line-height: 1.2;
  white-space: nowrap;
}

.ws-stat-key {
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--fg-faint);
  text-transform: uppercase;
  white-space: nowrap;
}

.ws-stat-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-2);
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--fg);
  gap: 4px;
}

/* Admin row */
.ws-admin-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}

/* Body */
.ws-body {
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.ws-section-title {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-muted);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-3);
}

.ws-table-wrap {
  overflow-x: auto;
}

.weapons-table,
.ws-weapons-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.weapons-table th,
.ws-weapons-table th {
  text-align: left;
  padding: var(--space-2) var(--space-3);
  background: var(--bg-elev-2);
  border-bottom: 1px solid var(--border);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-muted);
}

.weapons-table td,
.ws-weapons-table td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border);
  color: var(--fg);
  vertical-align: top;
}

.weapons-table tr:last-child td,
.ws-weapons-table tr:last-child td {
  border-bottom: none;
}

/* Abilities */
.ws-abilities-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
}

@media (min-width: 640px) {
  .ws-abilities-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
}

.ability-card,
.ws-ability-card {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--space-4) var(--space-5);
}
/* Source-bordered cards need extra inside-left breathing room */
.ws-ability-card[class*="ws-ability-card--"] {
  padding-left: calc(var(--space-5) + 4px);
}

.ability-name {
  font-weight: 700;
  font-size: var(--text-sm);
  color: var(--fg);
  margin-bottom: var(--space-2);
}

.ability-desc { font-size: var(--text-sm); color: var(--fg-muted); }

.ws-ability-card-pt {
  font-size: var(--text-sm);
  color: var(--fg);
  margin-bottom: var(--space-2);
}

.ws-ability-card-en {
  font-size: var(--text-xs);
  color: var(--fg-faint);
  font-style: italic;
}

/* Flavour lore shown below an ability's effect */
.ws-ability-lore {
  font-size: var(--text-xs);
  color: var(--fg-muted);
  font-style: italic;
  line-height: 1.45;
  margin-top: var(--space-2);
  padding-top: var(--space-2);
  border-top: 1px dashed var(--border);
}
.ws-ability-lore--en { color: var(--fg-faint); }

.ws-ability-timing {
  display: inline-flex;
  align-items: center;
  margin-top: var(--space-2);
  padding: 1px var(--space-2);
  background: var(--accent-soft);
  color: var(--accent-text);
  border-radius: var(--r-sm);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
}

/* ── Ability card: source grouping (2026-06) ── */

/* Header row: name + source badge side by side */
.ws-ability-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border);
}
.ws-ability-card-header .ability-name {
  margin-bottom: 0;
  flex: 1 1 auto;
  line-height: 1.3;
}

/* Source badge */
.ws-ability-source {
  display: inline-block;
  flex-shrink: 0;
  padding: 1px 6px;
  border-radius: var(--r-sm);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* Per-source color coding via left-border + badge tint */
.ws-ability-card--warscroll  { border-left: 3px solid var(--gold); }
.ws-ability-source--warscroll { background: var(--gold-soft); color: var(--gold); }

.ws-ability-card--passive    { border-left: 3px solid var(--info); }
.ws-ability-source--passive  { background: rgba(42,90,138,0.16); color: #5a9ce3; }

.ws-ability-card--command    { border-left: 3px solid var(--accent); }
.ws-ability-source--command  { background: var(--accent-soft); color: var(--accent-text); }

.ws-ability-card--reaction   { border-left: 3px solid var(--warn); }
.ws-ability-source--reaction { background: rgba(160,104,32,0.16); color: var(--warn-text); }

.ws-ability-card--keyword    { border-left: 3px solid var(--fg-faint); }
.ws-ability-source--keyword  { background: rgba(133,135,127,0.16); color: var(--fg-muted); }

.ws-ability-card--core       { border-left: 3px solid #3a8f8f; }
.ws-ability-source--core     { background: rgba(58,143,143,0.16); color: #4fb3b3; }

/* Faction rules: golden-bronze accent */
.ws-ability-card--faction    { border-left: 3px solid var(--system-aos); }
.ws-ability-source--faction  { background: var(--system-aos-soft); color: var(--system-aos); }

/* Faction subtitle uses muted gold to visually separate from unit abilities */
.ws-section-subtitle--faction {
  color: var(--system-aos);
  margin-top: var(--space-5);
  border-top: 1px solid var(--border);
  padding-top: var(--space-3);
}

/* ── Detachment picker (unit detail page) ── */
.det-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.5rem;
  margin: 0.75rem 0 1rem;
}
.det-picker-card {
  display: block;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-parchment-card);
  color: var(--fg);
  text-decoration: none;
  transition: border-color .14s, background .14s;
  cursor: pointer;
}
.det-picker-card:hover {
  border-color: var(--system-40k-border);
  background: var(--system-40k-soft);
}
.det-picker-card.is-active {
  border-color: var(--system-40k);
  background: var(--system-40k-soft);
  box-shadow: inset 0 0 0 1px var(--system-40k);
}
.det-picker-name {
  font-family: var(--font-display);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 0.25rem;
}
.det-picker-card.is-active .det-picker-name { color: var(--system-40k); }
.det-picker-desc {
  font-size: 0.72rem;
  color: var(--fg-muted);
  line-height: 1.35;
}
.det-picker-desc--empty { font-style: italic; opacity: 0.6; }

/* ── Selected detachment rule panel ── */
.ws-det-rule-panel {
  margin-top: 0.5rem;
  margin-bottom: 1rem;
}
.ws-det-rule-panel-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}
.ws-det-rule-panel-label {
  font-family: var(--font-display);
  font-size: 0.6rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-muted);
}
.ws-det-rule-panel-name {
  font-family: var(--font-display);
  font-size: 0.78rem;
  color: var(--system-40k);
  font-weight: 600;
}
.ws-det-enhancements {
  margin-top: 0.75rem;
}
.ws-det-enhancements-label {
  font-family: var(--font-display);
  font-size: 0.6rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin-bottom: 0.4rem;
}
.enh-chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.enh-pts {
  font-size: 0.7em;
  opacity: 0.7;
  margin-left: 0.15em;
}

/* ── Layout polish v2 (2026-06-12) ── */

/* Hover lift on cards */
.ws-ability-card {
  transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}
.ws-ability-card:hover {
  border-color: var(--fg-faint);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

/* Group subtitle: tiny dot left + count chip right */
.ws-section-subtitle {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-5);
  margin-bottom: var(--space-3);
}
.ws-section-subtitle:first-child { margin-top: 0; }
.ws-abilities-grid + .ws-section-subtitle { margin-top: var(--space-5); }
.ws-grp-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.ws-grp-dot--warscroll { background: var(--gold); }
.ws-grp-dot--passive   { background: var(--info); }
.ws-grp-dot--command   { background: var(--accent); }
.ws-grp-dot--reaction  { background: var(--warn); }
.ws-grp-dot--keyword   { background: var(--fg-faint); }
.ws-grp-dot--core      { background: #3a8f8f; }
.ws-grp-dot--faction   { background: var(--system-aos); }

.ws-grp-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.4rem;
  padding: 0 6px;
  background: var(--bg-elev-1);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--fg-muted);
  letter-spacing: 0;
}

/* Phase pill (top-right of timing context inside card) — colored by game phase */
.ws-ability-phase {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  margin-bottom: var(--space-2);
  border-radius: var(--r-sm);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid currentColor;
  background: transparent;
}
.ws-ability-cast {
  display: inline-flex; align-items: center; gap: 3px;
  margin: 0 0 var(--space-2) 6px;
  padding: 2px 8px; border-radius: var(--r-sm);
  font-size: 0.65rem; font-weight: 700; letter-spacing: 0.04em;
  color: #b98cd9; border: 1px solid #7a5aa0; background: rgba(120,90,160,0.14);
  white-space: nowrap;
}
.ws-regiment-options {
  margin: 0.5rem 0; padding: 0.5rem 0.75rem;
  border: 1px solid var(--border-gold, #8c7a52); border-left: 3px solid var(--gold, #c9a44a);
  border-radius: 6px; background: rgba(140,122,82,0.10); font-size: 0.85rem; line-height: 1.4;
}
.ws-regiment-options-label {
  display: block; font-family: var(--font-display); font-size: 0.62rem; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--gold, #c9a44a); margin-bottom: 2px;
}
.ws-regiment-options-text { color: var(--parchment, #e8dcc0); font-size: 0.92rem; }
.ws-regiment-help { font-size: 0.8rem; color: var(--fg-faint, #9a8f78); margin: 0 0 0.5rem; }
.ws-ability-phase--phase-hero       { color: #c98b3a; }   /* Hero/Command */
.ws-ability-phase--phase-movement   { color: #6ec07a; }   /* Movement */
.ws-ability-phase--phase-shooting   { color: #5a9ce3; }   /* Shooting */
.ws-ability-phase--phase-charge     { color: #d97757; }   /* Charge */
.ws-ability-phase--phase-combat     { color: #d04848; }   /* Combat/Fight */
.ws-ability-phase--phase-end        { color: #8a7fb0; }   /* End */
.ws-ability-phase--phase-any        { color: var(--gold); }
.ws-ability-phase--phase-passive    { color: var(--info); }
.ws-ability-phase--phase-setup      { color: #a08c64; }   /* Pre-game */
.ws-ability-phase--phase-generic    { color: var(--fg-muted); }

/* Subtler EN-fallback text (only shown when PT missing) */
.ws-ability-card-en {
  border-left: 2px solid var(--fg-faint);
  padding-left: var(--space-2);
  margin-top: var(--space-1);
}

/* Inline keyword chips inside an ability card */
.ws-ability-keywords {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: var(--space-2);
}
.ws-ability-kw-chip {
  padding: 1px 6px;
  background: var(--bg-elev-1);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-muted);
}

/* Tighter grid on phones — single column, no horizontal overflow */
@media (max-width: 480px) {
  .ws-abilities-grid { gap: var(--space-2); }
  .ws-ability-card { padding: var(--space-2) var(--space-3); }
  .ws-ability-card-header .ability-name { font-size: var(--text-xs); }
  .ws-ability-source { font-size: 0.6rem; padding: 1px 4px; }
}

/* ── Painted card (collection) + Museum gallery (2026-06-12) ── */
.painted-card { position: relative; border-radius: var(--r-md); overflow: hidden; background: var(--bg-elev-1); }
.painted-card-img { width: 100%; height: 100%; object-fit: cover; display: block; aspect-ratio: 1/1; }
.painted-card-img--grey { filter: grayscale(1) brightness(0.55) contrast(1.1); transition: filter .2s ease; }
.painted-card-empty { display: block; position: relative; cursor: pointer; }
.painted-card-empty:hover .painted-card-img--grey { filter: grayscale(1) brightness(0.75); }
.painted-card-overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-2); background: rgba(0,0,0,0.45); color: var(--fg); opacity: 0; transition: opacity .2s ease; }
.painted-card-empty:hover .painted-card-overlay { opacity: 1; }
.painted-card-overlay-icon { font-size: 1.8rem; }
.painted-card-overlay-text { font-size: 0.78rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; text-align: center; padding: 0 var(--space-3); }
.painted-card-actions { position: absolute; bottom: 6px; right: 6px; display: flex; gap: 4px; opacity: 0; transition: opacity .2s ease; }
.painted-card:hover .painted-card-actions { opacity: 1; }
.painted-replace-btn { cursor: pointer; }

/* Museum gallery */
.museum-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--space-3); margin-top: var(--space-3); }
.museum-card { display: block; background: var(--bg-elev-1); border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; text-decoration: none; color: inherit; transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease; }
.museum-card:hover { transform: translateY(-2px); border-color: var(--gold); box-shadow: 0 4px 12px rgba(0,0,0,0.3); }
.museum-card img { width: 100%; aspect-ratio: 1/1; object-fit: cover; display: block; }
.museum-card-meta { padding: var(--space-2) var(--space-3); }
.museum-card-name { font-weight: 700; font-size: 0.85rem; color: var(--fg); margin: 0 0 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.museum-card-user { font-size: 0.7rem; color: var(--fg-muted); margin: 0; }
.museum-card-user strong { color: var(--gold); }

/* Keywords */
.warscroll-keywords {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* Properties strip */
.ws-props-strip {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
}

.ws-prop {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ws-prop-label {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-faint);
}

.ws-prop-val {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--fg);
}

/* Unit lore */
.unit-lore-section {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--space-4) var(--space-5);
}

.unit-lore-title {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin-bottom: var(--space-3);
}

/* Companions list */
.companions-list {
  list-style: disc;
  padding-left: var(--space-5);
  font-size: var(--text-sm);
  color: var(--fg);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.warscroll-back { margin-top: var(--space-5); }

/* Warscroll stats table (also used in unit pool) */
.warscroll-stats,
.up-stats {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-xs);
  margin-top: var(--space-2);
}

.warscroll-stats th,
.up-stats th {
  padding: var(--space-1) var(--space-2);
  background: var(--bg-elev-2);
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--fg-faint);
}

.warscroll-stats td,
.up-stats td {
  padding: var(--space-1) var(--space-2);
  text-align: center;
  font-weight: 700;
  color: var(--fg);
}

/* ============================================================
   ARMY LIST (armies/index)
   ============================================================ */
.armies-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  margin-bottom: var(--space-5);
}

/* ── Abas da área de Exércitos (Meus / Públicos / Pré-criados) ── */
.armies-tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-top: var(--space-2);
}
.armies-tab {
  padding: 0.6rem 1.1rem;
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--fg-faint);
  text-decoration: none;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  margin-bottom: -1px;
  transition: color .12s, background .12s, border-color .12s;
}
.armies-tab:hover { color: var(--fg); background: var(--bg-elev-2); }
.armies-tab--active {
  color: var(--gold);
  background: var(--bg-card);
  border-color: var(--border);
  border-bottom: 1px solid var(--bg-card);
}
.roster-card-author {
  font-size: 0.78rem;
  color: var(--fg-faint);
  margin: 0.35rem 0 0;
}

.roster-card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-5);
}

@media (min-width: 640px) {
  .roster-card-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 960px) {
  .roster-card-grid { grid-template-columns: repeat(3, 1fr); }
}

.roster-card {
  position: relative;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow 0.2s;
  display: flex;
  flex-direction: column;
}

.roster-card:hover {
  box-shadow: var(--shadow-md);
}

.roster-card-link {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.roster-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  background: var(--bg-elev-2);
  border-bottom: 1px solid var(--border);
}

.roster-card-system-badge {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--fg-muted);
}

.roster-card-header {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
}

.roster-card-body {
  padding: var(--space-5) var(--space-5);
  flex: 1;
}

.roster-card-name {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--fg);
  margin-bottom: var(--space-3);
}

.roster-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}

.roster-card-summary {
  margin-top: var(--space-3);
  font-size: 0.86rem;
  line-height: 1.45;
  color: var(--fg-muted);
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.roster-card-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  flex-wrap: wrap;
  position: relative;
  z-index: 2;
}

.roster-card-pts {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.roster-pts-bar {
  height: 4px;
  width: 110px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.roster-pts-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.roster-pts-bar-fill--over { background: var(--danger); }

.roster-card-actions {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

.roster-card-updated {
  padding: var(--space-2) var(--space-5);
  font-size: var(--text-xs);
  color: var(--fg-faint);
  border-top: 1px solid var(--border);
}

.armies-empty {
  padding: var(--space-7) 0;
  text-align: center;
  color: var(--fg-muted);
  font-style: italic;
}

/* ============================================================
   ARMY BUILDER (armies/show)
   ============================================================ */
.army-topbar {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-4);
}

@media (min-width: 640px) {
  .army-topbar {
    flex-direction: row;
    align-items: flex-start;
    justify-content: space-between;
  }
}

.army-topbar-left { flex: 1; min-width: 0; }

.army-topbar-title-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-2);
}

.army-topbar-name {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--fg);
}

.army-topbar-sys {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--fg-faint);
}

.army-topbar-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}

.army-topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  flex-shrink: 0;
}

/* Builder layout */
.builder {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

@media (min-width: 960px) {
  .builder {
    flex-direction: row;
    align-items: flex-start;
  }

  .builder-center {
    flex: 1;
    min-width: 0;
  }

  .builder-rail {
    width: 240px;
    flex-shrink: 0;
    position: sticky;
    top: calc(var(--nav-height) + var(--space-4));
    max-height: calc(100vh - var(--nav-height) - var(--space-8));
    overflow-y: auto;
  }

  .builder--no-left .builder-center {
    flex: 1;
  }
}

/* ── Three-column builder layout (catalog | center | details+summary) ── */
@media (min-width: 1100px) {
  .builder--three-col {
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr) 340px;
    gap: var(--space-4);
    align-items: start;
  }
  .builder--three-col .builder-rail--left,
  .builder--three-col .builder-rail--right {
    width: auto;
    position: sticky;
    top: calc(var(--nav-height) + var(--space-4));
    max-height: calc(100vh - var(--nav-height) - var(--space-6));
    overflow-y: auto;
    flex: 0 0 auto;
  }
  .builder--three-col .builder-center {
    min-width: 0;
  }
}

/* Compact catalog rows in narrow left rail */
.builder-rail--left .up-row {
  padding: var(--space-2);
  gap: var(--space-2);
  cursor: pointer;
}
.builder-rail--left .up-row-head {
  gap: var(--space-2);
}
.builder-rail--left .up-thumb,
.builder-rail--left .up-thumb-placeholder {
  width: 36px;
  height: 36px;
}
.builder-rail--left .up-row-name {
  font-size: 0.82rem;
  line-height: 1.15;
}
.builder-rail--left .up-row-meta {
  font-size: 0.7rem;
}
.up-row--active {
  outline: 2px solid var(--gold);
  outline-offset: -2px;
}
.au-row[data-slug] {
  cursor: pointer;
}

/* Right-rail unit details panel */
.unit-details-panel {
  background: var(--bg-elev);
  border: 1px solid var(--border-gold);
  border-radius: var(--r-md);
  padding: var(--space-3);
  margin-bottom: var(--space-4);
  box-shadow: var(--shadow-sm);
}
.unit-details-empty {
  text-align: center;
  color: var(--muted);
  padding: var(--space-4) var(--space-2);
}
.unit-details-empty-icon {
  font-size: 2rem;
  opacity: 0.45;
  margin-bottom: var(--space-2);
}
.unit-details-empty-title {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  margin-bottom: var(--space-1);
  color: var(--ink);
}
.unit-details-empty-hint {
  font-size: 0.78rem;
  line-height: 1.35;
  margin: 0;
}
.unit-details-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.unit-details-image {
  text-align: center;
}
.unit-details-img {
  max-width: 100%;
  max-height: 180px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
}
.unit-details-name {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  margin: 0 0 var(--space-1) 0;
}
.unit-details-meta {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  align-items: center;
}
.unit-details-keywords {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}
.keyword-pill {
  font-size: 0.65rem;
  padding: 0.1rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-parchment-card);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.unit-details-stats {
  font-size: 0.78rem;
  width: 100%;
}
.unit-details-section {
  font-size: 0.8rem;
}
.unit-details-section strong {
  display: block;
  font-family: var(--font-heading);
  margin-bottom: var(--space-1);
  color: var(--gold);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.unit-details-weapons,
.unit-details-abilities {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.unit-details-footer {
  margin: 0;
  text-align: right;
}

/* Warlord button on army-unit row */
.warlord-form {
  display: inline-block;
  margin: 0;
}
.warlord-btn {
  background: linear-gradient(180deg, #2b2418 0%, #1a1610 100%);
  color: var(--gold);
  border: 1px solid var(--border-gold);
  border-radius: var(--r-sm);
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.3rem 0.55rem;
  cursor: pointer;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  transition: background 0.15s, transform 0.1s;
}
.warlord-btn:hover:not(:disabled) {
  background: linear-gradient(180deg, #3a3120 0%, #251f15 100%);
  transform: translateY(-1px);
}
.warlord-btn--active {
  background: linear-gradient(180deg, var(--gold) 0%, #a07a2a 100%);
  color: #1a1610;
  cursor: default;
}
.warlord-btn:disabled {
  opacity: 0.95;
}

/* Bottom panels (faction rules + detachment enhancements) */
.builder-bottom-panels {
  margin-top: var(--space-6);
}

/* ── Summary panel as TOP STRIP above three-col builder ── */
.summary-top-wrap {
  margin-bottom: var(--space-3);
}
.summary-top-wrap .summary-panel {
  padding: var(--space-2) var(--space-3);
  background: var(--bg-elev);
  border: 1px solid var(--border-gold);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  gap: var(--space-2);
}

/* ── Compact summary band ── */
.sb-band {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.sb-points {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 0 0 auto;
  min-width: 232px;
}
.sb-pts-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
}
.sb-pts-label {
  font-family: var(--font-display);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-muted);
}
.sb-pts-val {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1;
  color: var(--fg);
}
.sb-pts-lim { font-size: 0.82rem; font-weight: 600; color: var(--fg-muted); }
.sb-pts-bar {
  height: 7px;
  border-radius: 999px;
  background: var(--bg-elev-2, rgba(0,0,0,0.3));
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.35);
}
.sb-pts-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.35s ease, background 0.25s ease;
}
.sb-pts-fill--ok   { background: linear-gradient(90deg, #2d8a4e, #3fae63); }
.sb-pts-fill--high { background: linear-gradient(90deg, #c08a2a, #e0b34a); }
.sb-pts-fill--over { background: linear-gradient(90deg, #9a1c1c, #e0584f); animation: sb-pts-pulse 1.3s ease-in-out infinite; }
@keyframes sb-pts-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.5; }
}
.sb-pts-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
}
.sb-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  padding: 0.28rem 0.55rem;
  border-radius: 999px;
  white-space: nowrap;
}
.sb-chip--ok    { color: var(--success, #2d8a4e); background: rgba(45,138,78,0.14); }
.sb-chip--over  { color: #e0584f; background: rgba(184,68,58,0.16); }
.sb-chip--info  { color: var(--fg-muted); background: var(--bg-elev-2); cursor: help; }
.sb-tip-i { opacity: 0.7; font-size: 0.85em; }

.sb-div {
  width: 1px;
  align-self: stretch;
  min-height: 38px;
  background: var(--border);
  flex: 0 0 auto;
}
.sb-totals {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.78rem;
  color: var(--fg-muted);
  flex: 0 0 auto;
}
.sb-totals b { color: var(--fg); font-size: 0.92rem; }

.sb-issues {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  margin-left: auto;          /* push validation to the right edge */
  max-width: 60%;
}
.sb-issues--clean {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--success, #2d8a4e);
  opacity: 0.85;
}
.sb-issue {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  max-width: 280px;
  font-size: 0.74rem;
  line-height: 1.2;
  padding: 0.28rem 0.55rem;
  border-radius: var(--r-sm);
}
.sb-issue-msg {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sb-issue--error   { color: #e0584f; background: rgba(184,68,58,0.12); }
.sb-issue--warning { color: var(--warn-text, #c08a2a); background: rgba(192,138,42,0.12); }
.sb-issue-ic { flex: 0 0 auto; }

/* ── Hover/focus popover for info chips ── */
.sb-tip { position: relative; }
.sb-tip-pop {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 40;
  width: max-content;
  max-width: 320px;
  padding: 0.6rem 0.75rem;
  font-size: 0.74rem;
  font-weight: 500;
  line-height: 1.45;
  color: var(--fg);
  background: var(--bg-elev-2);
  border: 1px solid var(--border-gold);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-md);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 0.14s, transform 0.14s, visibility 0.14s;
  pointer-events: none;
  white-space: normal;
}
.sb-tip:hover .sb-tip-pop,
.sb-tip:focus .sb-tip-pop,
.sb-tip:focus-within .sb-tip-pop {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

@media (max-width: 720px) {
  .sb-issues { margin-left: 0; max-width: 100%; }
  .sb-div { display: none; }
}

/* ── Right-rail details: contain overflow, narrow table ── */
.builder-rail--right {
  min-width: 0;
}
.unit-details-panel {
  max-width: 100%;
  overflow: hidden;
  box-sizing: border-box;
}
.unit-details-panel * {
  max-width: 100%;
  box-sizing: border-box;
}
.unit-details-stats {
  display: block;
  width: 100%;
  overflow-x: auto;
  font-size: 0.7rem;
  white-space: nowrap;
}
.unit-details-stats th,
.unit-details-stats td {
  padding: 0.25rem 0.4rem;
}
.unit-details-keywords {
  gap: 0.2rem;
}
.unit-details-keywords .keyword-pill {
  font-size: 0.6rem;
  padding: 0.08rem 0.32rem;
}
.unit-details-weapons li,
.unit-details-abilities li {
  word-break: break-word;
  overflow-wrap: anywhere;
  font-size: 0.78rem;
  line-height: 1.3;
}
.uda-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.4rem 0.5rem;
  border-left: 2px solid var(--border-gold);
  background: var(--gold-soft);
  border-radius: 0 4px 4px 0;
}
.uda-name {
  font-weight: 600;
  color: var(--fg);
  font-family: var(--font-heading);
  letter-spacing: 0.01em;
}
.uda-timing {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-text);
  font-weight: 600;
}
.uda-desc {
  color: var(--fg-muted);
  font-size: 0.74rem;
  line-height: 1.35;
}
.uda-desc--en {
  font-style: italic;
  opacity: 0.85;
}
/* Ability origin groups */
.uda-group {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.uda-group + .uda-group {
  margin-top: 0.5rem;
}
.uda-group-label {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent-text);
  opacity: 0.7;
  padding-left: 0.2rem;
}
.unit-details-image {
  overflow: hidden;
}
.unit-details-img {
  height: auto;
  object-fit: contain;
}

/* Aux card */
.aux-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--space-4);
  transition: border-color 0.15s;
}

.aux-card-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev-2);
  border-radius: var(--r-md) var(--r-md) 0 0;
}

.aux-label {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--fg-muted);
}

.aux-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 50%;
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--fg-muted);
}

.aux-unit-list { padding: var(--space-2); }
.aux-empty {
  padding: var(--space-4);
  font-size: var(--text-sm);
  color: var(--fg-faint);
  font-style: italic;
}

/* Regiment card */
.regiment-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--space-4);
  transition: border-color 0.15s;
}

.regiment-card.leader-missing {
  border-color: var(--warn);
}

.regiment-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev-2);
  border-radius: var(--r-md) var(--r-md) 0 0;
}

.regiment-label {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--fg-muted);
}

.regiment-card-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.leader-slot {
  padding: var(--space-2);
  border-bottom: 1px solid var(--border);
  background: rgba(177,29,29,0.04);
}

.leader-empty {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  color: var(--warn-text);
  font-style: italic;
  border-bottom: 1px solid var(--border);
}

.companion-list { padding: var(--space-2); }

.companions-empty {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  color: var(--fg-faint);
  font-style: italic;
}

/* Drop hint */
.drop-hint {
  font-size: var(--text-xs);
  color: var(--fg-faint);
  font-style: italic;
}

/* Drop zones */
[data-drop-target] { transition: outline 0.15s ease, background 0.15s ease; }

.drop-target--active {
  outline: 2px dashed var(--accent);
  outline-offset: 2px;
  background: var(--accent-soft);
}

/* Army unit row */
.au-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--r-sm);
  transition: background 0.12s;
}

.au-row:hover { background: var(--bg-elev-2); }

.au-row-image { flex-shrink: 0; }

.au-thumb {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
}

.au-thumb-placeholder {
  width: 40px;
  height: 40px;
  background: var(--bg-elev-2);
  border: 1px dashed var(--border);
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.au-thumb-placeholder svg { width: 24px; height: 24px; }

.au-row-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.au-row-name {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.au-row-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.au-general-star { color: var(--warn-text); margin-right: 2px; }
.au-leader-crown { color: var(--accent-text); margin-right: 2px; }

/* Stats peek */
.au-stats-peek {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 2px;
}

.au-stat-peek {
  font-size: var(--text-xs);
  color: var(--fg-faint);
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 1px 5px;
}

.au-stat-peek b { color: var(--fg); }

/* Dropdown */
.au-row-actions {
  flex-shrink: 0;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 4px;
}
.au-row-actions > form { margin: 0; display: inline-flex; }
/* Warlord button compacto: só estrela + tooltip; texto escondido em telas estreitas */
.warlord-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  min-width: 26px;
  padding: 0;
  font-size: 0.75rem;
  font-weight: 700;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--fg-muted);
  cursor: pointer;
  transition: all .15s ease;
}
.warlord-btn span,
.warlord-btn-label { display: none; }
.warlord-btn:hover { border-color: var(--gold); color: var(--gold); }
.warlord-btn--active {
  background: var(--gold);
  border-color: var(--gold);
  color: #fff;
}
.warlord-btn:disabled { cursor: default; }
/* Aprimorar toggle compacto */
.au-enh-toggle {
  display: inline-block;
  position: relative;
}
.au-enh-toggle-btn {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 26px;
  padding: 0 8px;
  font-size: 0.7rem;
  font-weight: 600;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--fg-muted);
  white-space: nowrap;
  transition: all .15s ease;
}
.au-enh-toggle-btn::-webkit-details-marker { display: none; }
.au-enh-toggle--active .au-enh-toggle-btn,
.au-enh-toggle-btn:hover {
  background: var(--accent-soft);
  color: var(--accent-text);
  border-color: var(--accent);
}
.au-enh-toggle[open] .au-enh-inline-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 50;
  width: 280px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  padding: var(--space-2);
}
.enh-panel-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: var(--space-2);
}
.enh-panel-row:last-child { margin-bottom: 0; }
.enh-panel-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.enhancements-select {
  width: 100%;
  padding: var(--space-1) var(--space-2);
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--fg);
  font-size: var(--text-sm);
}
.enh-panel-empty {
  font-size: var(--text-xs);
  color: var(--fg-muted);
  font-style: italic;
  margin: 0;
}
/* Dropdown ▼ compacto */
.au-dropdown > .au-dropdown-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
}

.au-dropdown { position: relative; }

.au-dropdown-toggle {
  list-style: none;
  cursor: pointer;
  padding: var(--space-1) var(--space-2);
  color: var(--fg-muted);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: var(--text-xs);
  background: var(--bg-elev-2);
}

.au-dropdown-toggle:hover { background: var(--accent-soft); color: var(--accent-text); }

.au-dropdown-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 50;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  min-width: 180px;
  padding: var(--space-2);
}

.au-dropdown[open] .au-dropdown-menu { display: flex; flex-direction: column; gap: 2px; }

.au-action-btn {
  width: 100%;
  text-align: left;
  padding: var(--space-2) var(--space-3);
  background: none;
  border: none;
  border-radius: var(--r-sm);
  font-size: var(--text-sm);
  color: var(--fg);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s;
}

.au-action-btn:hover { background: var(--bg-elev-2); }

.au-action-btn--danger { color: var(--danger-text); }
.au-action-btn--danger:hover { background: rgba(184,68,58,0.1); }

.au-action-label {
  display: block;
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  color: var(--fg-faint);
}

.au-move-select {
  width: calc(100% - var(--space-6));
  margin: 0 var(--space-3) var(--space-2);
}

/* Army unit row dragging */
.up-row--dragging { opacity: 0.5; transform: scale(0.98); }

/* Summary panel — C5: premium grimdark redesign */
.summary-panel {
  background: var(--bg-elev);
  border: 1px solid var(--border-gold);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

/* C5: legal badge as crisp pill/badge */
.legal-banner {
  display: inline-flex;
  align-self: flex-start;
  align-items: center;
  padding: 0.25rem 0.9rem;
  border-radius: 999px;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  line-height: 1.4;
  transition: opacity 0.15s;
}

.legal-banner--legal {
  color: #fff;
  background: #1e6b3a;
  border: 1px solid rgba(45,138,78,0.60);
  box-shadow: 0 0 8px rgba(30,107,58,0.35);
}

.legal-banner--illegal {
  color: #fff;
  background: #9a1c1c;
  border: 1px solid rgba(184,68,58,0.60);
  box-shadow: 0 0 8px rgba(154,28,28,0.35);
}

/* Light theme overrides for legal banner */
[data-theme="light"] .legal-banner--legal {
  background: #2d8a4e;
  border-color: rgba(45,138,78,0.55);
  box-shadow: 0 0 6px rgba(45,138,78,0.25);
}
[data-theme="light"] .legal-banner--illegal {
  background: #b8443a;
  border-color: rgba(184,68,58,0.55);
  box-shadow: 0 0 6px rgba(184,68,58,0.25);
}

/* C5: Progress ring — polished */
.pts-gauge-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3);
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}

.progress-ring {
  width: 80px;
  height: 80px;
  flex-shrink: 0;
  filter: drop-shadow(0 0 6px rgba(177,29,29,0.25));
}

.progress-ring-bg {
  fill: none;
  stroke: var(--border-strong);
  stroke-width: 7;
}

.progress-ring-fill {
  fill: none;
  stroke: var(--accent);
  stroke-width: 7;
  stroke-linecap: butt;
  transition: stroke-dasharray 0.45s cubic-bezier(0.4,0,0.2,1);
}

.progress-ring-fill--over {
  stroke: var(--danger);
  filter: drop-shadow(0 0 4px rgba(160,48,48,0.6));
}

.ring-label-pts {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 800;
  fill: var(--accent);
  letter-spacing: -0.02em;
}

.ring-label-limit {
  font-family: var(--font-display);
  font-size: 9px;
  fill: var(--fg-faint);
  letter-spacing: 0.04em;
}

.pts-gauge-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.pts-over-label {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--danger-text);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.pts-buffer-label {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--fg-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.pts-surcharge-label {
  font-size: var(--text-xs);
  color: var(--warn-text, #c08a2a);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 600;
}

/* Points breakdown when auxiliary cumulative surcharge applies */
.pts-breakdown {
  margin: 0.6rem 0 0.2rem;
  padding: 0.5rem 0.6rem;
  background: rgba(180,140,60,0.08);
  border: 1px solid rgba(180,140,60,0.3);
  border-radius: var(--r-md);
  font-size: var(--text-sm);
}
.pts-breakdown-row {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 2px 0;
  color: var(--fg-muted);
}
.pts-breakdown-row small { opacity: 0.75; }
.pts-breakdown-row--surcharge { color: var(--warn-text, #c08a2a); font-weight: 600; }
.pts-breakdown-row--total {
  margin-top: 2px;
  padding-top: 4px;
  border-top: 1px solid rgba(180,140,60,0.3);
  color: var(--fg);
  font-weight: 700;
}
.pts-breakdown-note {
  margin: 0.4rem 0 0;
  font-size: var(--text-xs);
  line-height: 1.45;
  color: var(--fg-muted);
}
.pts-breakdown-note strong { color: var(--fg); }

/* Auxiliary surcharge hint in the composition column */
.aux-surcharge-hint {
  margin: 0.3rem 0 0.6rem;
  padding: 0.45rem 0.6rem;
  font-size: var(--text-xs);
  line-height: 1.5;
  color: var(--fg-muted);
  background: rgba(180,140,60,0.07);
  border-left: 3px solid rgba(180,140,60,0.45);
  border-radius: var(--r-sm);
}
.aux-surcharge-hint strong { color: var(--fg); }

/* Issues list — C5: carded rows with clearer hierarchy */
.issues-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}

.issues-list-title {
  font-family: var(--font-display);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  padding: var(--space-2) var(--space-3);
  background: var(--bg-elev-2);
  border-bottom: 1px solid var(--border-gold);
}

.issue {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  border-left: 2px solid transparent;
  transition: background 0.12s;
}
.issue:last-child { border-bottom: none; }

.issue-error   {
  background: rgba(184,68,58,0.08);
  color: var(--danger-text);
  border-left-color: var(--danger);
}
.issue-warning {
  background: rgba(196,122,26,0.08);
  color: var(--warn-text);
  border-left-color: var(--warn);
}
.issue-info    {
  background: color-mix(in srgb, var(--info) 14%, transparent);
  color: var(--fg);
  border-left-color: var(--info);
}

.issue-bullet { flex-shrink: 0; font-size: 0.8rem; }
.issue-msg { flex: 1; line-height: 1.4; }

.aux-cp-bonus {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--accent-soft);
  color: var(--accent-text);
  border-radius: var(--r-sm);
  font-size: var(--text-xs);
  margin-top: var(--space-3);
}

/* "Por que está ilegal?" panel — abaixo do Lembrete, só quando ilegal */
.illegal-reasons {
  margin-top: var(--space-3);
  padding: var(--space-3);
  background: rgba(184, 68, 58, 0.10);
  border: 1px solid var(--danger);
  border-left: 4px solid var(--danger);
  border-radius: var(--r-md);
  color: var(--fg);
}
.illegal-reasons-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--danger-text, var(--danger));
  margin-bottom: var(--space-2);
}
.illegal-reasons-icon {
  font-size: 1rem;
}
.illegal-reasons-list {
  margin: 0;
  padding-left: 1.2em;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  font-size: var(--text-xs);
  line-height: 1.45;
}
.illegal-reason {
  color: var(--fg);
}
.illegal-reason-code {
  display: inline-block;
  font-family: var(--font-mono, monospace);
  font-size: 0.65rem;
  color: var(--danger-text, var(--danger));
  background: rgba(184, 68, 58, 0.15);
  padding: 0 4px;
  border-radius: 3px;
  margin-right: 4px;
  letter-spacing: 0.03em;
}
.illegal-reasons-hint {
  margin-top: var(--space-2);
  margin-bottom: 0;
  font-size: 0.7rem;
  color: var(--fg-muted);
  font-style: italic;
}

/* ============================================================
   PICKS INLINE (Escolhas da Facção — pickers expansíveis)
   ============================================================ */
/* Flat container — no extra gold border (the summary panel already has one);
   just a subtle top separator so it doesn't read as a box-in-a-box. */
.faction-picks-inline {
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
}
.faction-picks-inline-title {
  font-family: var(--font-display);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: var(--space-2);
}

.pick-row {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  margin-bottom: var(--space-1);
  overflow: hidden;
}
.pick-row:last-child { margin-bottom: 0; }
.pick-row[open] {
  border-color: var(--accent, var(--gold));
}
.pick-row-summary {
  cursor: pointer;
  list-style: none;
  padding: var(--space-2) var(--space-3);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  user-select: none;
  transition: background .12s;
}
.pick-row-summary::-webkit-details-marker { display: none; }
.pick-row-summary:hover { background: var(--accent-soft); }
.pick-bullet {
  color: var(--accent-text, var(--gold));
  font-size: 0.7rem;
  flex-shrink: 0;
}
.pick-label {
  font-weight: 700;
  color: var(--fg);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  flex-shrink: 0;
}
.pick-value {
  flex: 1;
  color: var(--fg);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pick-value--empty {
  color: var(--accent-text, var(--gold));
  font-style: italic;
  font-weight: 500;
}
.pick-chevron {
  font-size: 0.65rem;
  color: var(--accent-text, var(--gold));
  transition: transform .18s ease;
  flex-shrink: 0;
}
.pick-row[open] > .pick-row-summary > .pick-chevron { transform: rotate(90deg); }
.pick-row-body {
  padding: var(--space-3);
  background: var(--bg-elev-2, var(--bg-elev));
  border-top: 1px solid var(--border);
}
.pick-hint {
  font-size: var(--text-xs);
  color: var(--fg-muted);
  font-style: italic;
  margin: 0 0 var(--space-3);
  padding-left: var(--space-2);
  border-left: 2px solid var(--border-gold);
}

/* Options stacked full-width — dense rules text reads far better than in two
   narrow columns (which forced heavy wrapping / ragged heights). */
.pick-options-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.pick-option-card {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-3);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all .12s ease;
}
.pick-option-card input[type="radio"] {
  position: absolute;
  width: 1px; height: 1px;
  opacity: 0;
  pointer-events: none;
  margin: 0;
  padding: 0;
}
.pick-option-radio {
  display: inline-flex;
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  margin-top: 2px;
  border: 2px solid var(--border-strong, #555);
  border-radius: 50%;
  background: var(--bg-elev-2, var(--bg-elev));
  transition: all .12s ease;
  position: relative;
}
.pick-option-card:hover {
  background: var(--accent-soft);
  border-color: var(--accent, var(--gold));
  transform: translateY(-1px);
  box-shadow: 0 2px 5px rgba(0,0,0,.25);
}
.pick-option-card:hover > .pick-option-radio {
  border-color: var(--accent, var(--gold));
}
.pick-option-card--active {
  background: var(--accent-soft);
  border-color: var(--accent, var(--gold));
  box-shadow: 0 0 0 2px var(--accent, var(--gold)) inset, 0 2px 5px rgba(0,0,0,.25);
}
.pick-option-card--active > .pick-option-radio {
  background: var(--accent, var(--gold));
  border-color: var(--accent, var(--gold));
}
.pick-option-card--active > .pick-option-radio::after {
  content: '';
  position: absolute;
  inset: 2px;
  border-radius: 50%;
  background: #fff;
}

.pick-option-inner {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.pick-option-name {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  line-height: 1.2;
}
.pick-option-name-text {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--fg);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.pick-option-ability {
  display: block;
  font-size: var(--text-xs);
  color: var(--accent-text, var(--gold));
  font-style: italic;
  font-weight: 600;
}
.pick-option-timing {
  display: inline-block;
  align-self: flex-start;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 0.65rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: var(--r-sm);
  letter-spacing: 0.02em;
}
.pick-option-active-tag {
  background: var(--accent, var(--gold));
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--r-sm);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.pick-option-desc {
  display: block;
  font-size: 0.76rem;
  color: var(--fg-muted);
  margin: 6px 0 0;
  line-height: 1.5;
}
.pick-option-desc p { margin: 0 0 5px; }
.pick-option-desc p:last-child { margin-bottom: 0; }
.pick-option-desc strong { color: var(--fg); }
.pick-option-desc--en { font-style: italic; opacity: 0.8; }
/* flavour/lore line under an option's effect — visually distinct from rules */
.pick-option-lore {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dotted var(--border);
  font-size: 0.72rem;
  font-style: italic;
  color: var(--fg-faint, var(--fg-muted));
  line-height: 1.45;
  opacity: 0.9;
}
.pick-option-lore p { margin: 0; }

/* Compact 2-col layout for the collapsed pick rows (saves vertical space).
   align-items:start so an expanded row doesn't stretch its neighbour. */
.faction-picks-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-1);
  align-items: start;
}
@media (min-width: 760px) {
  .faction-picks-grid { grid-template-columns: 1fr 1fr; gap: var(--space-2); }
  /* an open picker spans both columns so its option cards have room */
  .faction-picks-grid > .pick-row[open] { grid-column: 1 / -1; }
}
.pick-option-card--clear { align-items: center; opacity: 0.85; }
.pick-option-card--clear .pick-option-name-text { font-style: italic; color: var(--fg-muted); }

/* Nested spell / prayer list inside a lore option — each spell its own tidy
   block with a left accent, so the lore card doesn't read as a text wall. */
.pick-spell-list {
  list-style: none;
  margin: var(--space-2) 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pick-spell {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 6px 0 6px 10px;
  border-left: 2px solid var(--border-gold);
}
.pick-spell-name {
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  color: var(--fg);
}
.pick-spell-cv {
  align-self: flex-start;
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--accent-text);
  background: var(--accent-soft);
  padding: 1px 6px;
  border-radius: var(--r-sm);
}
.pick-spell-desc { font-size: 0.74rem; color: var(--fg-muted); line-height: 1.5; }
.pick-spell-desc p { margin: 0 0 4px; }
.pick-spell-desc p:last-child { margin: 0; }
.pick-spell-desc strong { color: var(--fg); }

/* ── Regras da Facção (reference accordion inside the picks panel) ── */
.fref-accordion {
  margin-top: var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-elev);
  overflow: hidden;
}
.fref-accordion[open] { border-color: var(--accent, var(--gold)); }
.fref-accordion-summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  user-select: none;
  transition: background .12s;
}
.fref-accordion-summary::-webkit-details-marker { display: none; }
.fref-accordion-summary:hover { background: var(--accent-soft); }
.fref-accordion-hint {
  flex: 1;
  font-size: 0.68rem;
  font-style: italic;
  color: var(--fg-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fref-accordion[open] > .fref-accordion-summary > .pick-chevron { transform: rotate(90deg); }
.fref-accordion-body {
  padding: var(--space-3);
  background: var(--bg-elev-2, var(--bg-elev));
  border-top: 1px solid var(--border);
}
.fref-section { margin-bottom: var(--space-3); }
.fref-section:last-child { margin-bottom: 0; }
.fref-section-title {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.fref-count {
  font-size: 0.62rem;
  background: var(--accent-soft);
  color: var(--accent-text);
  padding: 0 6px;
  border-radius: 999px;
}
.fref-section-note {
  font-size: var(--text-xs);
  color: var(--fg-muted);
  font-style: italic;
  margin: 2px 0 var(--space-2);
}
.fref-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-1);
}
@media (min-width: 760px) { .fref-cards { grid-template-columns: 1fr 1fr; } }
.fref-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: var(--space-2);
}
.fref-card-name {
  font-weight: 700;
  font-size: 0.78rem;
  color: var(--fg);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-bottom: 2px;
}
.fref-card-text {
  font-size: 0.75rem;
  color: var(--fg-muted);
  line-height: 1.5;
}
.fref-card-text p { margin: 0 0 4px; }
.fref-card-text p:last-child { margin-bottom: 0; }
.fref-card-text strong { color: var(--fg); }

/* ============================================================
   FACTION DETAIL — REGRAS DA FACÇÃO
   ============================================================ */
.faction-rules { margin: var(--space-5) 0 var(--space-6); }
.faction-rules-h2 {
  font-family: var(--font-display);
  font-size: 1.2rem; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--gold);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border-gold);
  margin-bottom: var(--space-3);
}
.fr-block {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin-bottom: var(--space-3);
  overflow: hidden;
}
.fr-block[open] { border-color: var(--accent, var(--gold)); }
.fr-block-header {
  cursor: pointer; list-style: none;
  padding: var(--space-3) var(--space-4);
  display: flex; align-items: center; gap: var(--space-2);
  background: var(--bg-elev-2, var(--bg-elev));
  user-select: none;
}
.fr-block-header::-webkit-details-marker { display: none; }
.fr-block-header h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 0.95rem; font-weight: 700;
  letter-spacing: 0.04em; color: var(--fg);
}
.fr-block-icon {
  font-size: 0.7rem;
  color: var(--accent-text, var(--gold));
  transition: transform .15s ease;
}
.fr-block[open] > .fr-block-header > .fr-block-icon,
.fr-subblock[open] > .fr-subblock-header > .fr-block-icon {
  transform: rotate(90deg);
}
.fr-block-count {
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 0.7rem; font-weight: 700;
  padding: 1px 6px; border-radius: var(--r-sm);
  margin-left: 4px;
}
.fr-block-body {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border);
}
.fr-subblock {
  background: var(--bg-elev-2, var(--bg-elev));
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  margin-bottom: var(--space-2);
}
.fr-subblock[open] { border-color: var(--accent, var(--gold)); }
.fr-subblock-header {
  cursor: pointer; list-style: none;
  padding: var(--space-2) var(--space-3);
  display: flex; align-items: center; gap: var(--space-2);
  user-select: none;
}
.fr-subblock-header::-webkit-details-marker { display: none; }
.fr-subblock-name { font-weight: 700; color: var(--fg); }
.fr-subblock-ref { color: var(--fg-muted); font-size: 0.85em; font-style: italic; }
.fr-subblock-body {
  padding: var(--space-2) var(--space-3) var(--space-3);
  border-top: 1px dashed var(--border);
}
.fr-section-label {
  font-family: var(--font-display);
  font-size: 0.75rem; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--gold);
  margin: var(--space-3) 0 var(--space-2);
}
.fr-note {
  font-size: var(--text-xs);
  color: var(--fg-muted); font-style: italic;
  margin-bottom: var(--space-2);
}
.fr-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent, var(--gold));
  border-radius: var(--r-sm);
  padding: var(--space-2) var(--space-3);
  margin-bottom: var(--space-2);
}
.fr-card:last-child { margin-bottom: 0; }
.fr-card-name {
  font-weight: 700;
  font-size: var(--text-sm);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--fg);
  margin-bottom: var(--space-1);
  display: flex; align-items: center; gap: var(--space-2);
  flex-wrap: wrap;
}
.fr-card-timing {
  font-size: 0.7rem;
  background: var(--accent-soft);
  color: var(--accent-text);
  padding: 1px 5px; border-radius: var(--r-sm);
  text-transform: none; letter-spacing: normal; font-weight: 600;
}
.fr-card-text { font-size: var(--text-sm); color: var(--fg); line-height: 1.45; }
.fr-card-ability {
  font-size: 0.7rem; font-weight: 600;
  color: var(--accent-text, var(--gold)); letter-spacing: 0.02em;
}
.fr-card-lore {
  margin-top: 5px; padding-top: 5px;
  border-top: 1px dotted var(--border);
  font-size: 0.78rem; font-style: italic;
  color: var(--fg-faint, var(--fg-muted)); line-height: 1.45;
}
.fr-card-lore p { margin: 0; }
.fr-chips-row { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: var(--space-2); }
.fr-chip-wrap { display: inline-block; }
.fr-chip {
  cursor: pointer; list-style: none;
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px;
  background: var(--bg-elev-2, var(--bg-elev));
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 0.75rem; color: var(--fg);
  transition: all .15s ease;
}
.fr-chip::-webkit-details-marker { display: none; }
.fr-chip:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-text);
}
.fr-chip-pts {
  background: var(--accent-soft); color: var(--accent-text);
  padding: 0 4px; border-radius: var(--r-sm);
  font-size: 0.65rem; font-weight: 700;
}
.fr-chip-body {
  margin-top: 4px;
  padding: var(--space-2) var(--space-3);
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--r-sm); font-size: var(--text-xs); line-height: 1.4;
}

/* Callout on unit detail pointing to faction page */
.ws-faction-link-callout {
  margin-top: var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--accent-soft);
  border: 1px dashed var(--accent, var(--gold));
  border-radius: var(--r-md);
  font-size: var(--text-sm); color: var(--fg-muted);
}
.ws-faction-link-callout p { margin: 0; }
.ws-faction-link {
  color: var(--accent-text, var(--gold));
  font-weight: 700; text-decoration: none;
  margin-left: 4px;
}
.ws-faction-link:hover { text-decoration: underline; }

/* ============================================================
   AOS COMPOSITION VIEW (regiment-grouped)
   ============================================================ */
.comp-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) 0;
  margin: var(--space-4) 0 var(--space-2);
  border-bottom: 1px solid var(--border-gold);
}
.comp-section-header:first-child { margin-top: 0; }
.comp-section-header--aux {
  margin-top: var(--space-4);
  border-bottom-color: var(--border);
}
.comp-section-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gold);
}
.comp-section-meta {
  font-size: var(--text-xs);
  color: var(--fg-muted);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.comp-section-meta--off {
  color: var(--danger);
}
.comp-section-bp {
  font-weight: 400;
  font-size: 0.7rem;
  color: var(--fg-faint);
  font-style: italic;
}
.regiments-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}
.regiments-empty {
  background: var(--bg-elev-2, var(--bg-elev));
  border: 1px dashed var(--border);
  border-radius: var(--r-md);
  padding: var(--space-4);
  font-size: var(--text-sm);
  color: var(--fg-muted);
  text-align: center;
  margin-bottom: var(--space-3);
}
.regiments-empty p { margin: 0 0 var(--space-2); }
.regiments-empty p:last-child { margin-bottom: 0; }
.add-regiment-form {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0 0 var(--space-3);
}
.add-regiment-btn {
  flex: 1;
  padding: var(--space-2) var(--space-3);
  background: var(--accent-soft);
  border: 1px dashed var(--accent, var(--gold));
  border-radius: var(--r-sm);
  color: var(--accent-text, var(--gold));
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 600;
  transition: all .15s ease;
}
.add-regiment-btn:hover:not(:disabled) {
  background: var(--accent, var(--gold));
  color: #fff;
  border-style: solid;
}
.add-regiment-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.add-regiment-hint {
  font-size: 0.7rem;
  color: var(--fg-faint);
  font-style: italic;
}

/* ============================================================
   AOS REGIMENTS PANEL (header de composição)
   ============================================================ */
.aos-regs-panel {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--space-3);
  margin-bottom: var(--space-3);
}
.aos-regs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-2);
}
.aos-regs-title {
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
}
.aos-regs-count {
  font-size: var(--text-xs);
  color: var(--fg-muted);
  font-weight: 600;
}
.aos-regs-count--off {
  color: var(--danger);
}
.aos-regs-bp {
  font-weight: 400;
  font-size: 0.7rem;
  color: var(--fg-faint);
  margin-left: 2px;
}
.aos-regs-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin: 0 0 var(--space-2);
  padding: 0;
}
.aos-reg {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--bg-elev-2, var(--bg-elev));
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent, var(--gold));
  border-radius: var(--r-sm);
  font-size: var(--text-xs);
}
.aos-reg--no-leader {
  border-left-color: var(--warn, #c47a1a);
  background: rgba(196, 122, 26, 0.08);
}
.aos-reg-info {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  min-width: 0;
}
.aos-reg-pos {
  font-weight: 700;
  color: var(--accent-text, var(--gold));
  font-family: var(--font-display);
}
.aos-reg-leader {
  color: var(--fg);
  font-weight: 600;
}
.aos-reg-ror {
  color: var(--gold);
  font-weight: 600;
}
.aos-reg-empty {
  color: var(--warn, #c47a1a);
  font-style: italic;
}
.aos-reg-general {
  color: var(--gold);
  font-size: 0.9rem;
}
.aos-reg-comps {
  color: var(--fg-muted);
  font-size: 0.7rem;
}
.aos-reg-remove-form { margin: 0; }
.aos-reg-remove-btn {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--fg-faint);
  cursor: pointer;
  font-size: 0.7rem;
  transition: all .15s ease;
}
.aos-reg-remove-btn:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.aos-regs-empty {
  padding: var(--space-2) var(--space-3);
  background: var(--bg-elev-2, var(--bg-elev));
  border: 1px dashed var(--border);
  border-radius: var(--r-sm);
  font-size: var(--text-xs);
  color: var(--fg-muted);
  font-style: italic;
  text-align: center;
  margin-bottom: var(--space-2);
}
.aos-reg-add-form {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
}
.aos-reg-add-btn {
  flex: 1;
  padding: var(--space-2) var(--space-3);
  background: var(--accent-soft);
  border: 1px dashed var(--accent, var(--gold));
  border-radius: var(--r-sm);
  color: var(--accent-text);
  cursor: pointer;
  font-size: var(--text-xs);
  font-weight: 600;
  transition: all .15s ease;
}
.aos-reg-add-btn:hover:not(:disabled) {
  background: var(--accent, var(--gold));
  color: #fff;
  border-style: solid;
}
.aos-reg-add-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.aos-reg-add-hint {
  font-size: 0.7rem;
  color: var(--fg-faint);
  font-style: italic;
}

/* ============================================================
   FACTION RULES PANEL
   ============================================================ */
.faction-rules-panel {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin-bottom: var(--space-4);
  overflow: hidden;
}

.faction-rules-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  background: var(--bg-elev-2);
  list-style: none;
  user-select: none;
}

.faction-rules-toggle::-webkit-details-marker { display: none; }

.faction-rules-toggle-title {
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--fg);
}

.faction-rules-toggle-chevron {
  font-size: var(--text-xs);
  color: var(--fg-faint);
  transition: transform 0.2s ease;
}

details[open] .faction-rules-toggle-chevron { transform: rotate(180deg); }

.faction-rules-body {
  padding: var(--space-4);
}

.faction-rules-lore {
  font-size: var(--text-sm);
  color: var(--fg-muted);
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border);
}

.faction-rules-section {
  margin-bottom: var(--space-5);
}

.faction-rules-section-title {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border);
}

.faction-rules-traits {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.faction-rules-trait {
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  overflow: hidden;
}

.faction-rules-trait-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  background: var(--bg-elev-2);
  list-style: none;
}

.faction-rules-trait-toggle::-webkit-details-marker { display: none; }

.faction-rules-trait-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--fg);
  flex: 1;
}

.faction-rules-trait-timing {
  padding: 1px var(--space-2);
  background: var(--accent-soft);
  color: var(--accent-text);
  border-radius: var(--r-sm);
  font-size: var(--text-xs);
  font-weight: 600;
}

.faction-rules-trait-chevron {
  font-size: var(--text-xs);
  color: var(--fg-faint);
  transition: transform 0.2s;
}

.faction-rules-trait-ref {
  font-size: var(--text-xs);
  color: var(--fg-faint);
  margin-left: auto;
  margin-right: var(--space-2);
}

details[open] .faction-rules-trait-chevron { transform: rotate(180deg); }

.faction-rules-trait-body {
  padding: var(--space-3) var(--space-4);
}

.faction-rules-text-pt {
  font-size: var(--text-sm);
  color: var(--fg);
  margin-bottom: var(--space-2);
}

.faction-rules-text-en {
  font-size: var(--text-xs);
  color: var(--fg-faint);
  font-style: italic;
}

/* EN fallback (não traduzido ainda) na página de detalhe da facção */
.fr-card-text-en {
  color: var(--fg-faint);
  font-style: italic;
}

/* === STRATAGEM GROUPS === */
.strat-group {
  margin-bottom: var(--space-4);
}

.strat-group-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--r-sm);
  margin-bottom: var(--space-3);
  background: var(--bg-elev-1);
  border-left: 3px solid var(--border);
  color: var(--fg-muted);
}

.strat-group-header--tactic  { border-left-color: #c0392b; color: #e07060; }
.strat-group-header--ploy    { border-left-color: #2472a4; color: #5ba3d6; }
.strat-group-header--epic    { border-left-color: #b8960c; color: #d4ac0d; }
.strat-group-header--wargear { border-left-color: #1e8449; color: #2ecc71; }

.strat-group-count {
  margin-left: auto;
  background: rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 0.1rem 0.45rem;
  font-size: var(--text-xs);
  font-weight: 600;
}

.strat-kw-row {
  display: flex;
  gap: 0.2rem;
  flex-shrink: 0;
}

.strat-kw {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  white-space: nowrap;
}

.strat-kw--cp      { background: rgba(255,215,0,0.12);  color: #c9a800; border: 1px solid rgba(255,215,0,0.25); }
.strat-kw--tactic  { background: rgba(192,57,43,0.12);  color: #e07060; border: 1px solid rgba(192,57,43,0.25); }
.strat-kw--ploy    { background: rgba(36,114,164,0.12); color: #5ba3d6; border: 1px solid rgba(36,114,164,0.25); }
.strat-kw--epic    { background: rgba(184,150,12,0.12); color: #d4ac0d; border: 1px solid rgba(184,150,12,0.25); }
.strat-kw--wargear { background: rgba(30,132,73,0.12);  color: #2ecc71; border: 1px solid rgba(30,132,73,0.25); }

/* Picker grid */
.faction-rules-picker-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
}

@media (min-width: 640px) {
  .faction-rules-picker-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }
}

.faction-rules-pick-card {
  display: block;
  cursor: pointer;
  border: 2px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  transition: border-color 0.15s, background 0.15s;
}

.faction-rules-pick-card:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.faction-rules-pick-card input[type="radio"] {
  display: none;
}

.faction-rules-pick-card:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.faction-rules-pick-inner {
  padding: var(--space-3) var(--space-4);
}

.faction-rules-pick-name {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--fg);
  margin-bottom: var(--space-1);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.faction-rules-pick-selected-badge {
  padding: 1px var(--space-2);
  background: var(--accent);
  color: var(--accent-fg);
  border-radius: var(--r-sm);
  font-size: var(--text-xs);
  font-weight: 700;
}

.faction-rules-pick-desc {
  font-size: var(--text-xs);
  color: var(--fg-muted);
}

/* Structured battle formation card */
.faction-rules-pick-timing {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent);
  opacity: 0.85;
  margin-bottom: 2px;
}

.faction-rules-pick-ability {
  font-size: var(--text-xs);
  font-weight: 600;
  font-style: italic;
  color: var(--fg);
  opacity: 0.88;
  margin-bottom: var(--space-2);
}

.faction-rules-pick-line {
  font-size: var(--text-xs);
  color: var(--fg-muted);
  line-height: 1.45;
  margin-bottom: var(--space-1);
}

.faction-rules-pick-tag {
  display: inline-block;
  font-weight: 700;
  font-size: 0.58rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  margin-right: var(--space-1);
}

.faction-rules-pick-lore {
  font-size: var(--text-xs);
  font-style: italic;
  color: var(--fg-muted);
  opacity: 0.8;
  margin-top: var(--space-2);
  padding-top: var(--space-2);
  border-top: 1px dashed var(--border);
  line-height: 1.4;
}

/* Picks bar */
.faction-picks-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  padding: var(--space-3) 0;
  margin-bottom: var(--space-3);
}

.faction-pick-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-3);
  background: var(--accent-soft);
  color: var(--accent-text);
  border: 1px solid var(--accent);
  border-radius: 9999px;
  font-size: var(--text-xs);
  font-weight: 600;
}

.faction-pick-chip-label {
  opacity: 0.7;
  font-weight: 400;
}

.faction-rules-placeholder {
  font-size: var(--text-sm);
  color: var(--fg-faint);
  font-style: italic;
  padding: var(--space-3) 0;
}

/* ============================================================
   UNIT POOL (builder)
   ============================================================ */
.unit-pool {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--space-4);
  overflow: hidden;
}

.unit-pool-summary {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  background: var(--bg-elev-2);
  list-style: none;
  user-select: none;
}

.unit-pool-summary::-webkit-details-marker { display: none; }

.unit-pool-title {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--fg);
  flex: 1;
}

.unit-pool-count {
  font-size: var(--text-xs);
  color: var(--fg-faint);
}

.unit-pool-chevron {
  font-size: var(--text-xs);
  color: var(--fg-faint);
  transition: transform 0.2s;
}

details[open] .unit-pool-chevron { transform: rotate(180deg); }

.unit-pool-body {
  padding: var(--space-3);
}

.unit-pool-controls {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.unit-pool-search {
  width: 100%;
}

.unit-pool-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.filter-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px var(--space-3);
  background: var(--bg-elev-2);
  color: var(--fg-muted);
  border: 1px solid var(--border);
  border-radius: 9999px;
  font-size: var(--text-xs);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  font-family: inherit;
}

.filter-pill:hover {
  background: var(--accent-soft);
  color: var(--accent-text);
  border-color: var(--accent);
}

.filter-pill--active {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(160,40,40,0.3);
}

.unit-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: var(--space-5) 0 var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border);
}

.unit-pool-groups {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.unit-pool-group-title {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-faint);
  padding: var(--space-1) 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-2);
}

.unit-pool-group-count { font-weight: 400; }

.unit-pool-rows {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.unit-pool-empty {
  padding: var(--space-5) 0;
  text-align: center;
  color: var(--fg-faint);
  font-style: italic;
  font-size: var(--text-sm);
}

/* Unit pool row */
.up-row {
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-elev);
  cursor: grab;
  transition: border-color 0.12s, transform 0.12s;
  overflow: hidden;
}

.up-row:hover { border-color: var(--accent); }
.up-row--expanded { border-color: var(--accent); }

.up-row-head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
}

.up-row-thumb {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  overflow: hidden;
}

.up-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.up-thumb-placeholder {
  width: 36px;
  height: 36px;
  background: var(--bg-elev-2);
  border: 1px dashed var(--border);
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.up-row-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.up-row-name {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.up-row-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.up-row-actions {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex-shrink: 0;
}

.up-expand-btn {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-elev-2);
  color: var(--fg-muted);
  font-size: var(--text-xs);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
}

.up-expand-btn:hover { background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent); }

.up-add-wrap { position: relative; }

.up-add-btn {
  width: 28px;
  height: 28px;
  border: 1px solid var(--accent);
  border-radius: var(--r-sm);
  background: var(--accent);
  color: var(--accent-fg);
  font-size: var(--text-lg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  line-height: 1;
}

.up-add-btn:hover { opacity: 0.85; }

.up-add-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 50;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  min-width: 150px;
  padding: var(--space-1);
  flex-direction: column;
  gap: 2px;
}

.up-add-menu.is-open { display: flex; }

.up-add-menu-item {
  width: 100%;
  text-align: left;
  padding: var(--space-2) var(--space-3);
  background: none;
  border: none;
  border-radius: var(--r-sm);
  font-size: var(--text-sm);
  color: var(--fg);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s;
}

.up-add-menu-item:hover { background: var(--accent-soft); color: var(--accent-text); }

/* Expanded row */
.up-row-expanded {
  border-top: 1px solid var(--border);
  padding: var(--space-3);
}

.up-expanded-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
}

@media (min-width: 640px) {
  .up-expanded-grid { grid-template-columns: 80px 1fr; }
}

.up-expanded-image img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: var(--r-sm);
}

.up-keywords {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-bottom: var(--space-2);
}

.up-weapons, .up-abilities {
  font-size: var(--text-xs);
  color: var(--fg-muted);
  margin-top: var(--space-2);
}

.up-weapons ul, .up-abilities ul {
  list-style: disc;
  padding-left: var(--space-4);
  margin-top: var(--space-1);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Hover zoom overlay */
.up-zoom-overlay {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  background: var(--bg-elev);
}

.up-zoom-overlay img {
  width: 360px;
  height: 360px;
  object-fit: cover;
  display: block;
}

/* ============================================================
   MODALS
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
}

.modal-box {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-6);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--fg);
  margin-bottom: var(--space-4);
}

.modal-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
  margin-top: var(--space-5);
}

/* ============================================================
   AUTH PAGES
   ============================================================ */
.auth-section {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - var(--nav-height) - 80px);
  padding: var(--space-6) var(--space-4);
}

.auth-section .card-form {
  width: 100%;
  max-width: 400px;
}

/* ============================================================
   FRIENDS
   ============================================================ */
.friend-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.friend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}

.friend-name {
  font-weight: 700;
  font-size: var(--text-sm);
  color: var(--fg);
}

.friend-actions {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

.friends-empty {
  font-size: var(--text-sm);
  color: var(--fg-faint);
  font-style: italic;
  padding: var(--space-4) 0;
}

/* ============================================================
   HERO (index.html landing) — GRIMDARK
   ============================================================ */
.hero {
  position: relative;
  text-align: center;
  padding: var(--space-8) var(--space-4) var(--space-7);
  /* Gradiente concreto escuro */
  background: linear-gradient(180deg, #0c0e11 0%, #14171c 60%, #0c0e11 100%);
  border-bottom: 2px solid var(--accent);
  overflow: hidden;
}

/* Hazard stripe sutil na borda inferior do hero */
.hero::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 7px;
  background: var(--hazard-stripe);
  background-size: 24px 7px;
  background-repeat: repeat-x;
  opacity: 0.85;
}

/* Scanlines no hero */
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,0.18) 0 1px, transparent 1px 4px);
  opacity: 0.5;
}

.hero-inner {
  max-width: 700px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

.hero-eyebrow {
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--accent-text);
  margin-bottom: var(--space-4);
  opacity: 0.9;
}

.hero-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.hero-title-text {
  font-family: var(--font-display);
  font-size: clamp(var(--text-3xl), 9vw, 5rem);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg);
  -webkit-text-stroke: 1px rgba(0,0,0,0.55);
  text-shadow: 0 2px 0 #000, 0 0 1px var(--accent), 3px 3px 0 rgba(0,0,0,0.7);
}

.hero-sub {
  font-size: var(--text-lg);
  color: var(--fg-muted);
  max-width: 560px;
  margin: 0 auto var(--space-6);
  line-height: 1.6;
}

.hero-cta { display: flex; justify-content: center; }

/* Btn primary grimdark no hero */
.hero-cta .btn-primary {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  padding: var(--space-4) var(--space-7);
  border-radius: var(--r-sm);
  box-shadow: 0 4px 16px rgba(177,29,29,0.45);
}

/* Welcome section */
.welcome {
  padding: var(--space-8) 0 var(--space-7);
  background: var(--bg);
}

.welcome-text {
  max-width: 640px;
}

.welcome-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-6);
}

@media (min-width: 640px) {
  /* Sem ilustração — full-width */
  .welcome-grid { grid-template-columns: 1fr; }
}

.welcome-text .eyebrow {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--accent-text);
}

/* Features */
.features {
  padding: var(--space-8) 0;
  background: var(--bg-elev);
}

.feature-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-5);
  counter-reset: feat;
}

@media (min-width: 640px) {
  .feature-grid { grid-template-columns: repeat(3, 1fr); }
}

/* Corte chanfrado angular reaproveitável */
.panel-cut {
  clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 14px, 100% 100%, 14px 100%, 0 calc(100% - 14px));
  border-radius: 0;
}

/* Painéis blindados/dossiê */
.feature-card {
  position: relative;
  padding: 0;
  background: var(--bg-elev-2);
  border: 1px solid var(--border-strong);
  border-radius: 0;
  clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 14px, 100% 100%, 14px 100%, 0 calc(100% - 14px));
  text-align: center;
  overflow: hidden;
}

/* Faixa vermelha no topo do card */
.feature-card::before {
  content: '';
  display: block;
  height: 3px;
  background: var(--accent);
  width: 100%;
}

/* Rebites nos cantos */
.feature-card::after {
  content: '';
  position: absolute;
  inset: 7px;
  pointer-events: none;
  background-image:
    radial-gradient(circle, rgba(0,0,0,0.55) 1.5px, transparent 2px),
    radial-gradient(circle, rgba(0,0,0,0.55) 1.5px, transparent 2px),
    radial-gradient(circle, rgba(0,0,0,0.55) 1.5px, transparent 2px),
    radial-gradient(circle, rgba(0,0,0,0.55) 1.5px, transparent 2px);
  background-size: 5px 5px;
  background-repeat: no-repeat;
  background-position: top left, top right, bottom left, bottom right;
}

.feature-card-body {
  position: relative;
  padding: var(--space-6) var(--space-5);
}

/* Índice estêncil "// 01" */
.feature-card-body::before {
  counter-increment: feat;
  content: '// ' counter(feat, decimal-leading-zero);
  position: absolute;
  top: var(--space-2);
  left: var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.12em;
  color: var(--accent-text);
  opacity: 0.8;
}

.feature-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto var(--space-4);
}

.feature-icon svg { width: 48px; height: 48px; }

.feature-card h3 {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg);
  margin-bottom: var(--space-3);
}

.feature-card p { font-size: var(--text-sm); color: var(--fg-muted); }

/* Separador grimdark com título de seção */
.section-divider {
  text-align: center;
  margin-bottom: var(--space-5);
  position: relative;
}

.section-divider::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--border-strong);
  transform: translateY(-50%);
}

.section-divider-label {
  position: relative;
  display: inline-block;
  background: var(--bg-elev);
  padding: 2px var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: 0;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--fg-faint);
}

/* Prefixo estêncil "Nº 001" */
.section-divider-label::before {
  content: 'Nº 001 / ';
  color: var(--accent-text);
}

/* ============================================================
   TABLES (generic)
   ============================================================ */
.table-wrap { overflow-x: auto; }

/* ============================================================
   HTMX / LOADING STATES
   ============================================================ */
.htmx-request .htmx-indicator { display: inline; }
.htmx-indicator { display: none; }
.htmx-request { opacity: 0.7; }

/* ============================================================
   RESPONSIVE UTILITIES
   ============================================================ */
@media (max-width: 768px) {
  .hide-mobile { display: none !important; }
  .nav-links { display: none; }
}

@media (min-width: 769px) {
  .hide-desktop { display: none !important; }
}

/* ============================================================
   RULES HUB + SECTION PAGES
   ============================================================ */
.rules-hub-section { padding: var(--space-6) 0 var(--space-7); }
.rules-hub-header { margin-bottom: var(--space-6); }
.rules-hub-sub {
  color: var(--fg-muted);
  max-width: 70ch;
  margin-top: var(--space-3);
}

.rules-system-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}
@media (min-width: 768px) {
  .rules-system-grid { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 1100px) {
  .rules-system-grid { grid-template-columns: 1fr 1fr 1fr; }
}

.rules-system-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}
.rules-system-card--stub { opacity: 0.72; }

/* Per-system card accent stripe */
.rules-system-card--aos {
  border-top: 3px solid var(--system-aos);
}
.rules-system-card--40k {
  border-top: 3px solid var(--system-40k);
}
.rules-system-card--tc {
  border-top: 3px solid var(--system-tc);
}

.rules-system-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: var(--space-3);
  margin-bottom: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.rules-system-name {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 600;
}
.rules-system-edition {
  font-size: var(--text-sm);
  color: var(--fg-muted);
}
.rules-system-ruleset {
  font-size: var(--text-xs);
  color: var(--fg-faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.rules-section-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.rules-section-link {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  color: var(--fg);
  transition: background 0.15s, border-color 0.15s;
}
.rules-section-link:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  opacity: 1;
}
.rules-section-icon {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  background: var(--accent-soft);
  color: var(--accent-text);
}
.rules-section-icon svg {
  width: 20px;
  height: 20px;
}
.rules-section-title {
  display: block;
  font-weight: 600;
  font-size: var(--text-base);
  margin-bottom: 2px;
}
.rules-section-desc {
  display: block;
  font-size: var(--text-sm);
  color: var(--fg-muted);
  line-height: 1.4;
}

.rules-stub-notice {
  color: var(--fg-muted);
  font-style: italic;
  font-size: var(--text-sm);
}

/* Rules section pages (turn, abilities, composition, aos/index) */
.rules-section-page { padding: var(--space-6) 0 var(--space-7); }
.rules-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-5);
}
@media (min-width: 960px) {
  .rules-layout { grid-template-columns: 220px 1fr; gap: var(--space-6); }
}

.rules-toc {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--space-4);
  font-size: var(--text-sm);
  align-self: start;
  position: sticky;
  top: calc(var(--nav-height) + var(--space-3));
}
.rules-toc ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin-bottom: var(--space-3);
}
.rules-toc a {
  color: var(--fg-muted);
  display: block;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--r-sm);
}
.rules-toc a:hover { background: var(--accent-soft); color: var(--accent-text); opacity: 1; }
.rules-toc-label {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-faint);
  margin-bottom: var(--space-2);
}
.rules-toc-divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-3) 0;
}

.rules-body {
  min-width: 0;
  max-width: 70ch;
}
.rules-body h2 {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 600;
  margin-top: var(--space-6);
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border);
}
.rules-body h3 {
  font-size: var(--text-lg);
  font-weight: 600;
  margin-top: var(--space-4);
  margin-bottom: var(--space-2);
}
.rules-body p { margin-bottom: var(--space-3); }

.rules-ruleset-badge {
  display: inline-block;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-text);
  background: var(--accent-soft);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--r-sm);
  margin: var(--space-2) 0 var(--space-5);
}

.rules-callout {
  background: var(--bg-elev-2);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-sm);
  padding: var(--space-3) var(--space-4);
  margin: var(--space-3) 0;
  font-size: var(--text-sm);
}
.rules-callout p:last-child { margin-bottom: 0; }

/* ── REGRAS — DETAILS EXPANSÍVEIS (single page) ── */
.rules-body { max-width: 78ch; }
.rules-detail {
  margin: var(--space-3) 0;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-elev);
  overflow: hidden;
  scroll-margin-top: calc(var(--nav-height) + 12px);
}
.rules-detail[open] {
  background: var(--bg-elev-2, var(--bg-elev));
  border-color: var(--accent, var(--border-strong));
}
.rules-detail-summary {
  cursor: pointer;
  list-style: none;
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  user-select: none;
  background: transparent;
  transition: background .15s ease;
}
.rules-detail-summary::-webkit-details-marker { display: none; }
.rules-detail-summary::before {
  content: '▶';
  font-size: 0.75rem;
  color: var(--accent-text, var(--fg-faint));
  transition: transform .15s ease;
  flex-shrink: 0;
}
.rules-detail[open] > .rules-detail-summary::before { transform: rotate(90deg); }
.rules-detail-summary:hover { background: var(--accent-soft); }
.rules-detail-summary h2 {
  display: inline;
  margin: 0;
  padding: 0;
  border: none;
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
}
.rules-detail-body {
  padding: var(--space-2) var(--space-4) var(--space-4);
  border-top: 1px solid var(--border);
}
.rules-detail-body > h3:first-child { margin-top: var(--space-3); }

.rules-expand-all,
.rules-collapse-all {
  display: block;
  width: 100%;
  margin-top: var(--space-2);
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-xs);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--fg-muted);
  cursor: pointer;
  transition: all .15s ease;
}
.rules-expand-all:hover,
.rules-collapse-all:hover {
  background: var(--accent-soft);
  color: var(--accent-text);
  border-color: var(--accent);
}

/* Diagramas embedados do Wahapedia (educational fair use, paraphrased context) */
.rules-figure {
  margin: var(--space-3) 0;
  padding: var(--space-2);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  text-align: center;
}
.rules-figure img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
  border-radius: var(--r-sm);
  background: #fff;
}
.rules-figure figcaption {
  font-size: var(--text-xs);
  color: var(--fg-muted);
  margin-top: var(--space-2);
  font-style: italic;
  padding: 0 var(--space-2);
}

.rules-list {
  padding-left: var(--space-5);
  margin-bottom: var(--space-3);
}
.rules-list li { margin-bottom: var(--space-2); }
.rules-list--ordered { list-style: decimal; }

.rules-battlepack-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
  margin: var(--space-3) 0;
}
@media (min-width: 640px) {
  .rules-battlepack-grid { grid-template-columns: 1fr 1fr; }
}
.rules-battlepack-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--space-4);
}
.rules-battlepack-name {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
}
.rules-battlepack-pts {
  font-size: var(--text-sm);
  color: var(--accent-text);
  margin-bottom: var(--space-2);
}

.rules-nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-4);
}
.rules-nav-link {
  display: block;
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-elev);
  color: var(--fg);
}
.rules-nav-link:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  opacity: 1;
}

.keyword-inline {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 0.78em;
  font-weight: 600;
  letter-spacing: 0.04em;
  background: var(--accent-soft);
  color: var(--accent-text);
  padding: 0 var(--space-1);
  border-radius: 2px;
}

/* ============================================================
   REGIMENTS OF RENOWN
   ============================================================ */
.rules-infobox {
  background: var(--bg-elev);
  border-left: 3px solid var(--accent);
  padding: var(--space-2) var(--space-3);
  border-radius: 0 4px 4px 0;
  margin-bottom: var(--space-4);
  font-size: 0.92em;
  color: var(--fg-muted);
}

.ror-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

.ror-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.ror-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-2);
}

.ror-card-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95em;
  color: var(--fg);
  line-height: 1.3;
}

.ror-card-pts {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95em;
  color: var(--accent-text);
  white-space: nowrap;
  flex-shrink: 0;
}

.ror-label {
  font-size: 0.78em;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--fg-muted);
  text-transform: uppercase;
}

.ror-unit-list {
  list-style: none;
  padding: 0;
  margin: var(--space-1) 0 0 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ror-unit-list li {
  font-size: 0.85em;
  color: var(--fg);
  padding-left: var(--space-2);
  position: relative;
}

.ror-unit-list li::before {
  content: '\2022';
  position: absolute;
  left: 0;
  color: var(--accent-text);
}

.ror-card-factions {
  font-size: 0.82em;
  color: var(--fg-muted);
  border-top: 1px solid var(--border);
  padding-top: var(--space-2);
}

.ror-factions {
  display: block;
  margin-top: 2px;
  color: var(--fg);
  font-size: 0.95em;
}

.badge-new {
  display: inline-block;
  font-size: 0.7em;
  font-weight: 700;
  letter-spacing: 0.06em;
  background: var(--accent);
  color: var(--bg);
  padding: 1px 5px;
  border-radius: 3px;
  vertical-align: middle;
  margin-right: 3px;
}

/* ============================================================
   UNIT CARD — STAT BLOCK (BB-style 4-column)
   ============================================================ */
.unit-card-stats-peek {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2px;
  margin-top: var(--space-2);
  padding: var(--space-2) var(--space-1);
  background: rgba(177,29,29,0.06);
  border: 1px solid rgba(177,29,29,0.18);
  border-radius: var(--r-sm);
}

.unit-stat-peek-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2px 1px;
  line-height: 1.1;
}

.unit-stat-peek-val {
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--fg);
  letter-spacing: -0.01em;
  font-family: 'Cinzel', serif;
}

.unit-stat-peek-key {
  font-size: 0.52rem;
  font-weight: 600;
  color: var(--fg-faint);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 1px;
}

/* ============================================================
   UNIT CARD — LEGACY BADGE & TOOLTIP — C9
   ============================================================ */
.legacy-badge {
  display: inline-flex;
  align-items: center;
  background: rgba(80,72,55,0.55);
  color: rgba(210,185,120,0.70);
  font-family: var(--font-display);
  font-size: 0.52rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid rgba(140,122,82,0.30);
  line-height: 1.5;
  vertical-align: middle;
  white-space: nowrap;
}
/* When used as absolutely-positioned overlay on unit card image */
.unit-image-frame .legacy-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 2;
}
[data-theme="light"] .legacy-badge {
  background: rgba(200,190,165,0.65);
  color: rgba(90,75,40,0.85);
  border-color: rgba(120,100,60,0.35);
}

/* ===== LEGENDS — army flag + chips + filters ===== */
.legends-flag-banner {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  margin: 0.6rem 0;
  padding: 0.6rem 0.85rem;
  border: 1px solid rgba(200,90,70,0.55);
  border-left: 4px solid rgba(200,90,70,0.9);
  border-radius: 6px;
  background: rgba(120,40,30,0.18);
  color: var(--parchment, #e8dcc0);
  font-size: 0.85rem;
  line-height: 1.4;
}
.legends-flag-icon { font-size: 1.1rem; color: rgba(230,140,90,0.95); flex: none; }
.legends-flag-text strong { color: rgba(235,160,110,0.95); }
.legends-flag-list { display: block; margin-top: 2px; opacity: 0.8; font-style: italic; font-size: 0.78rem; }

.legends-chip {
  display: inline-flex; align-items: center;
  background: rgba(150,55,40,0.85); color: #f3dfc8;
  font-family: var(--font-display); font-size: 0.55rem; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase;
  padding: 1px 7px; border-radius: 999px; border: 1px solid rgba(220,120,90,0.5);
  line-height: 1.5; vertical-align: middle; white-space: nowrap;
}
.legends-chip--sm { font-size: 0.5rem; padding: 0 5px; }

.filter-field--legends { min-width: 150px; }

.unit-pool-legends-toggle {
  display: inline-flex; align-items: center; gap: 0.35rem;
  font-size: 0.78rem; color: var(--parchment, #d8c9a8); white-space: nowrap;
  cursor: pointer; user-select: none;
}
.unit-pool-legends-toggle input { accent-color: rgba(200,90,70,0.9); }

/* legacy-badge tooltip handled by gloss-portal (see GLOSSARY PORTAL block below) */

/* ============================================================
   GLOSSARY TERM TOOLTIPS (auto-injected by glossary.js)
   ============================================================ */
.glossary-term {
  position: relative;
  border-bottom: 1px dotted rgba(184, 147, 90, 0.55);
  cursor: help;
  color: inherit;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.glossary-term:hover,
.glossary-term:focus {
  color: var(--gold, #b8935a);
  border-bottom-color: var(--gold, #b8935a);
  outline: none;
}

.glossary-term:focus-visible {
  outline: 2px solid var(--gold, #b8935a);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Tooltip popup is rendered via a single .gloss-portal element appended to <body>
   by glossary.js — escapes ancestor overflow:hidden (e.g. .unit-card on /units). */

/* ============================================================
   GLOSSARY PORTAL TOOLTIP (rendered by glossary.js into <body>)
   ============================================================ */
.gloss-portal {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 9999;
  max-width: 320px;
  min-width: 160px;
  width: max-content;
  background: #1e1c17;
  color: #e8dfc0;
  font-family: var(--font-body, system-ui, sans-serif);
  font-size: 0.72rem;
  font-weight: 400;
  line-height: 1.45;
  padding: 7px 10px;
  border-radius: 5px;
  border: 1px solid rgba(184, 147, 90, 0.5);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.55);
  letter-spacing: 0.01em;
  white-space: normal;
  text-align: left;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.gloss-portal--visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.gloss-portal-arrow {
  position: absolute;
  width: 0;
  height: 0;
  border: 6px solid transparent;
  pointer-events: none;
}

.gloss-portal--above .gloss-portal-arrow {
  bottom: -12px;
  border-top-color: rgba(184, 147, 90, 0.5);
}

.gloss-portal--below .gloss-portal-arrow {
  top: -12px;
  border-bottom-color: rgba(184, 147, 90, 0.5);
}

.gloss-portal-content {
  display: block;
}

@media (max-width: 640px) {
  .gloss-portal { display: none; }
}

/* ============================================================
   GLOSSARY PAGE (dynamic)
   ============================================================ */
.gloss-search {
  width: 100%;
  max-width: 420px;
  padding: 9px 12px;
  background: var(--bg-elev, #1c1a16);
  border: 1px solid var(--border-gold, rgba(184, 147, 90, 0.4));
  border-radius: 5px;
  color: var(--fg, #e8dfc0);
  font-size: 0.9rem;
  margin: 14px 0 22px;
}
.gloss-search:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }

.gloss-cat-section { margin: 28px 0 18px; }
.gloss-cat-title {
  font-family: 'Cinzel', serif;
  font-size: 1.1rem;
  color: var(--gold, #b8935a);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-gold, rgba(184, 147, 90, 0.3));
}

.gloss-entry {
  padding: 10px 0;
  border-bottom: 1px dashed rgba(184, 147, 90, 0.18);
}
.gloss-entry:target {
  background: rgba(184, 147, 90, 0.08);
  border-left: 3px solid var(--gold, #b8935a);
  padding-left: 10px;
  border-radius: 3px 3px 0 0;
}
.gloss-entry-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.gloss-entry-term {
  font-family: 'Cinzel', serif;
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--fg, #e8dfc0);
}
.gloss-entry-pt {
  font-size: 0.82rem;
  color: var(--fg-faint, #a8a08c);
  font-style: italic;
}
.gloss-entry-cat {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 8px;
  border-radius: 99px;
  background: rgba(184, 147, 90, 0.12);
  border: 1px solid rgba(184, 147, 90, 0.3);
  color: var(--gold, #b8935a);
}
.gloss-entry-short {
  margin: 5px 0 0;
  font-size: 0.88rem;
  color: var(--fg, #e8dfc0);
  line-height: 1.5;
}
.gloss-entry-long {
  margin: 6px 0 0;
  font-size: 0.83rem;
  color: var(--fg-faint, #b9b09a);
  line-height: 1.55;
}
.gloss-hidden { display: none !important; }

/* unit-card name truncation */
.unit-card-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.unit-card-name a {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}

/* ============================================================
   SCROLLBAR (optional polish)
   ============================================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--fg-faint); }

/* ============================================================
   ENHANCEMENTS PANEL (AoS rules 24-26, 30)
   ============================================================ */
.enhancements-panel {
  border-top: 1px dashed var(--border-gold);
  background: rgba(184,147,90,0.04);
}
.enhancements-panel > .enhancements-header {
  cursor: pointer;
  user-select: none;
  padding: var(--space-2) var(--space-3);
  margin-bottom: 0;
  list-style: none;
}
.enhancements-panel > .enhancements-header::-webkit-details-marker { display: none; }
.enhancements-panel[open] > .enhancements-header {
  border-bottom: 1px dashed var(--border-gold);
  margin-bottom: var(--space-2);
}
.enhancements-toggle-icon {
  display: inline-block;
  font-size: 0.7rem;
  color: var(--accent-text, var(--gold));
  transition: transform .15s ease;
  flex-shrink: 0;
}
.enhancements-panel[open] > .enhancements-header > .enhancements-toggle-icon {
  transform: rotate(90deg);
}
.enhancements-count--filled {
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 700;
}
.enhancements-panel[open] {
  padding-bottom: var(--space-2);
  padding-left: var(--space-3);
  padding-right: var(--space-3);
}

.enhancements-unavailable {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  color: var(--fg-faint);
  font-style: italic;
  border-top: 1px dashed var(--border);
}

.enhancements-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.enhancements-title {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--gold);
}

.enhancements-count {
  font-size: var(--text-xs);
  color: var(--fg-faint);
  background: var(--bg-elev-2);
  border-radius: var(--r-sm);
  padding: 1px 6px;
}

.enhancements-free-badge {
  font-size: var(--text-xs);
  color: #4caf50;
  background: rgba(76,175,80,0.12);
  border-radius: var(--r-sm);
  padding: 1px 6px;
  margin-left: auto;
}

.enhancements-cp-badge {
  font-size: var(--text-xs);
  color: var(--warn-text);
  background: rgba(255,193,7,0.1);
  border-radius: var(--r-sm);
  padding: 1px 6px;
  margin-left: auto;
}

.enhancements-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: var(--space-2);
}

.enhancements-label {
  font-size: var(--text-xs);
  color: var(--fg-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.enhancements-select {
  font-size: var(--text-sm);
  background: var(--bg-parchment-card);
  border: 1px solid var(--border-gold);
  color: var(--fg);
  border-radius: var(--r-sm);
  padding: 3px 6px;
  max-width: 100%;
}

.enhancements-select:focus {
  outline: none;
  border-color: var(--gold);
}

.enhancement-pick-desc {
  margin: 0.35rem 0 0.15rem;
  font-size: 0.78rem;
  line-height: 1.35;
  color: var(--fg-muted);
  padding-left: 0.4rem;
  border-left: 2px solid var(--gold);
}

.enhancements-desc {
  margin-top: 2px;
}

.enhancements-desc-toggle {
  font-size: var(--text-xs);
  color: var(--fg-faint);
  cursor: pointer;
  list-style: none;
}

.enhancements-desc-toggle::-webkit-details-marker { display: none; }

.enhancements-desc-text {
  font-size: var(--text-xs);
  color: var(--fg-secondary);
  margin: var(--space-1) 0 0;
  padding: var(--space-1) var(--space-2);
  border-left: 2px solid var(--border-gold);
  background: var(--bg-elev-1);
}

/* ============================================================
   REGIMENT OF RENOWN — ARMY BUILDER
   ============================================================ */

/* RoR regiment card variant */
.regiment-card--ror {
  border-color: var(--border-gold);
  background: var(--bg-elev);
}

.regiment-card--ror .regiment-card-header {
  background: rgba(184, 147, 90, 0.12);
  border-bottom-color: var(--border-gold);
}

/* RoR badge next to regiment label */
.ror-badge {
  display: inline-block;
  font-size: 0.68em;
  font-weight: 700;
  letter-spacing: 0.07em;
  background: var(--border-gold);
  color: #1a1208;
  padding: 1px 5px;
  border-radius: 3px;
  vertical-align: middle;
  margin-left: var(--space-2);
}

/* RoR name displayed under regiment header */
.ror-name-label {
  font-size: var(--text-xs);
  color: var(--fg-muted);
  font-style: italic;
  flex: 1;
  text-align: center;
}

/* RoR fixed points row */
.ror-pts-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--border);
  background: rgba(184,147,90,0.06);
  font-size: var(--text-sm);
}

.ror-pts-label { color: var(--fg-muted); }

/* RoR locked units container */
.ror-units-locked {
  padding: var(--space-2);
  opacity: 0.9;
}

.ror-units-empty {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  color: var(--fg-faint);
  font-style: italic;
}

/* Lock icon for RoR unit rows */
.ror-lock-icon {
  display: inline-block;
  font-size: 0.9em;
  color: var(--fg-faint);
  padding: var(--space-1);
  cursor: default;
  title: "Composição fixa";
}

/* Add regiment row: button pair */
.add-regiment-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}

/* RoR picker modal rows */
.ror-picker-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-elev);
  transition: border-color 0.12s;
}

.ror-picker-row:hover { border-color: var(--border-gold); }

.ror-picker-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.ror-picker-name {
  font-weight: 600;
  font-size: var(--text-sm);
}

.ror-picker-meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.ror-picker-units {
  font-size: 0.75em;
  color: var(--fg-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================================
   UNITS PAGE v3 — Grand Alliance accents, faction headers,
   refined card, filter chips, empty placeholders, detail nav
   ============================================================ */

/* Grand-alliance badge color variants (apply to .alliance-badge) */
.alliance-order       { color: var(--ga-order);       background: var(--ga-order-soft);       border-color: var(--ga-order); }
.alliance-chaos       { color: var(--ga-chaos);       background: var(--ga-chaos-soft);       border-color: var(--ga-chaos); }
.alliance-death       { color: var(--ga-death);       background: var(--ga-death-soft);       border-color: var(--ga-death); }
.alliance-destruction { color: var(--ga-destruction); background: var(--ga-destruction-soft); border-color: var(--ga-destruction); }
.alliance-universal   { color: var(--ga-universal);   background: var(--ga-universal-soft);   border-color: var(--ga-universal); }
/* 40K grand-alliance (Chaos reuses .alliance-chaos above) */
.alliance-imperium    { color: #d4a830; background: rgba(212,168,48,0.14); border-color: rgba(212,168,48,0.55); }
.alliance-xenos       { color: #4caa6b; background: rgba(76,170,107,0.14); border-color: rgba(76,170,107,0.55); }
.alliance-unaligned   { color: #999;    background: rgba(153,153,153,0.12); border-color: rgba(153,153,153,0.4); }
/* Trench Crusade */
.alliance-humans      { color: #7ea5d4; background: rgba(126,165,212,0.14); border-color: rgba(126,165,212,0.55); }
.alliance-demons      { color: #c45050; background: rgba(196,80,80,0.14);  border-color: rgba(196,80,80,0.55); }

/* ── Playstyle archetype badges (faction_meta.ARCHETYPES) ── */
.archetype-badges { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.archetype-badge {
  display: inline-flex; align-items: center;
  padding: 1px var(--space-2);
  border-radius: var(--r-sm);
  font-size: 0.66rem; font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase;
  background: var(--bg-elev-2); color: var(--fg-muted);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.archetype-aggressive { color:#d96a4f; border-color:rgba(217,106,79,.5);  background:rgba(217,106,79,.12); }
.archetype-melee      { color:#d99a4a; border-color:rgba(217,154,74,.5);  background:rgba(217,154,74,.12); }
.archetype-defensive  { color:#5e94b0; border-color:rgba(94,148,176,.5);  background:rgba(94,148,176,.12); }
.archetype-resilient  { color:#6fae8f; border-color:rgba(111,174,143,.5); background:rgba(111,174,143,.12); }
.archetype-horde      { color:#caa94e; border-color:rgba(202,169,78,.5);  background:rgba(202,169,78,.12); }
.archetype-elite      { color:#c98fd0; border-color:rgba(201,143,208,.5); background:rgba(201,143,208,.12); }
.archetype-magic      { color:#8a86d6; border-color:rgba(138,134,214,.5); background:rgba(138,134,214,.12); }
.archetype-shooting   { color:#9c8b3e; border-color:rgba(156,139,62,.5);  background:rgba(156,139,62,.12); }
.archetype-fast       { color:#5fb0c4; border-color:rgba(95,176,196,.5);  background:rgba(95,176,196,.12); }
.archetype-fragile    { color:#b8728f; border-color:rgba(184,114,143,.5); background:rgba(184,114,143,.12); }
.archetype-versatile  { color:#9aa0a8; border-color:rgba(154,160,168,.5); background:rgba(154,160,168,.12); }
.archetype-monster    { color:#b34444; border-color:rgba(179,68,68,.5);   background:rgba(179,68,68,.12); }
.archetype-psychic    { color:#6c8fd6; border-color:rgba(108,143,214,.5); background:rgba(108,143,214,.12); }
.archetype-vehicles   { color:#7d8a99; border-color:rgba(125,138,153,.5); background:rgba(125,138,153,.12); }
.archetype-ambush     { color:#6b9e5a; border-color:rgba(107,158,90,.5);  background:rgba(107,158,90,.12); }

/* Archetype tag tooltips reuse the shared glossary portal (glossary.js handles
   any [data-tooltip] element), so no dedicated popup element is needed here. */
.archetype-badge[data-tooltip] { cursor: help; }

/* ── Rules-source badge (Index vs Battletome) ── */
.rules-source-badge {
  display:inline-flex; align-items:center;
  padding:1px var(--space-2);
  border-radius: var(--r-sm);
  font-size:0.6rem; font-weight:700;
  letter-spacing:0.05em; text-transform:uppercase;
  border:1px solid var(--border); color:var(--fg-faint);
  background: var(--bg-elev-2); white-space:nowrap;
}
.rules-source-battletome { color: var(--gold); border-color: var(--border-gold); background: rgba(184,147,90,.12); }

/* ── Faction intro block (top of expanded units-faction-body) ── */
.faction-intro-block {
  margin: 0 0 var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-left: 3px solid var(--border-gold);
  background: var(--bg-elev-2);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
}
.faction-intro-blurb { margin:0; font-size: var(--text-sm); line-height:1.55; color: var(--fg-muted); }
.faction-intro-link { color: var(--gold); white-space:nowrap; font-weight:600; text-decoration:none; }
.faction-intro-link:hover { text-decoration:underline; }
.faction-intro-tags { display:flex; flex-wrap:wrap; gap:4px; margin-top: var(--space-2); }

/* ── Faction sub-axis grouping (e.g. Skaven clans) ── */
.faction-subgroup { margin-bottom: var(--space-4); }
.faction-subgroup-title {
  display:flex; align-items:center; gap: var(--space-2);
  font-family: var(--font-display);
  font-size: var(--text-sm); letter-spacing:0.08em; text-transform:uppercase;
  color: var(--fg-muted);
  padding: var(--space-1) 0;
  margin-bottom: var(--space-2);
  border-bottom:1px dashed var(--border);
}
.faction-subgroup-axis {
  font-size:0.58rem; font-weight:700; letter-spacing:0.08em;
  color: var(--gold); border:1px solid var(--border-gold);
  border-radius: var(--r-sm); padding:0 6px; line-height:1.5;
}
.faction-subgroup-name { font-weight:600; }
.faction-subgroup-title .count { opacity:.6; font-weight:400; }

/* Faction card / detail tag rows */
.faction-card-tags, .faction-detail-tags { display:flex; flex-wrap:wrap; gap:4px; margin: var(--space-2) 0; }
.filter-field--archetype .form-select { min-width: 150px; }

/* Unit-rows wrapper: counter + faction blocks */
.units-results-count {
  font-size: var(--text-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-faint);
  margin-bottom: var(--space-4);
}

.units-system-block { margin-bottom: var(--space-6); }

.units-system-heading {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  font-family: var(--font-display);
  font-size: var(--text-lg);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  border-bottom: 1px solid var(--border-gold);
  padding-bottom: var(--space-2);
  margin-bottom: var(--space-4);
  font-weight: 600;
}

.units-system-heading .sys-edition {
  font-size: var(--text-xs);
  letter-spacing: 0.06em;
  font-weight: 400;
  color: var(--fg-faint);
}

/* Per-system heading color overrides */
.units-system-block--aos .units-system-heading  { color: var(--system-aos);  border-bottom-color: var(--system-aos-border); }
.units-system-block--40k .units-system-heading  { color: var(--system-40k);  border-bottom-color: var(--system-40k-border); }
.units-system-block--tc  .units-system-heading  { color: var(--system-tc);   border-bottom-color: var(--system-tc-border); }

/* Alliance grouping inside a system block (Imperium/Xenos/Chaos, Order/Death…, Humans/Demons) */
.units-alliance-block { margin-bottom: var(--space-5); }
.units-alliance-heading {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--fg-muted);
  padding: var(--space-1) var(--space-2);
  margin: 0 0 var(--space-3);
  border-left: 3px solid var(--border-gold);
  background: linear-gradient(90deg, color-mix(in srgb, var(--gold) 8%, transparent) 0%, transparent 70%);
}
.units-alliance-heading .units-alliance-counts {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  margin-left: auto;
}
.units-alliance-heading .units-alliance-chip {
  display: inline-flex;
  align-items: center;
  padding: 1px var(--space-2);
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, currentColor 32%, transparent);
  background: color-mix(in srgb, currentColor 10%, transparent);
  font-family: var(--font-body);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: none;
  color: inherit;
  opacity: 0.92;
}
/* Alliance accent tints */
.units-alliance--imperium .units-alliance-heading,
.units-alliance--humans   .units-alliance-heading,
.units-alliance--order    .units-alliance-heading { color: #d9c47a; border-left-color: #d9c47a; }
.units-alliance--chaos  .units-alliance-heading { color: #c0564b; border-left-color: #c0564b; }
.units-alliance--xenos  .units-alliance-heading { color: #5fae8c; border-left-color: #5fae8c; }
.units-alliance--demons .units-alliance-heading,
.units-alliance--death  .units-alliance-heading { color: #9b6fc4; border-left-color: #9b6fc4; }
.units-alliance--destruction .units-alliance-heading { color: #c98a4b; border-left-color: #c98a4b; }
.units-alliance--unaligned .units-alliance-heading,
.units-alliance--universal .units-alliance-heading,
.units-alliance--outros    .units-alliance-heading { color: var(--fg-muted); border-left-color: var(--border); }

/* Per-system factions summary accent */
.factions-system-details--aos > .factions-system-summary { border-left: 3px solid var(--system-aos); padding-left: var(--space-3); }
.factions-system-details--40k > .factions-system-summary { border-left: 3px solid var(--system-40k); padding-left: var(--space-3); }
.factions-system-details--tc  > .factions-system-summary { border-left: 3px solid var(--system-tc);  padding-left: var(--space-3); }

/* Expand/collapse-all toolbar */
.units-expand-bar {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
  justify-content: flex-end;
}
.units-expand-bar .btn-expand {
  font-size: var(--text-xs);
  padding: 4px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--bg-elev);
  color: var(--fg-muted);
  cursor: pointer;
  letter-spacing: 0.04em;
  transition: border-color 0.15s, color 0.15s;
}
.units-expand-bar .btn-expand:hover {
  border-color: var(--gold);
  color: var(--gold);
}

/* ── System picker (step 1 of /units) ── */
.system-picker {
  margin-top: var(--space-4);
}
.system-picker-intro {
  color: var(--fg-muted);
  font-size: var(--text-sm);
  margin-bottom: var(--space-4);
}
.system-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-4);
}
.system-picker-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-5);
  border: 1px solid var(--border-strong);
  border-left-width: 4px;
  border-radius: var(--r-md, 8px);
  background: var(--bg-elev);
  color: var(--fg);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, transform 0.1s, box-shadow 0.15s;
}
.system-picker-card:hover {
  border-color: var(--gold);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
}
.system-picker-card--aos { border-left-color: #b8935a; }
.system-picker-card--40k { border-left-color: #c0392b; }
.system-picker-card--tc  { border-left-color: #7c2d2d; }
.system-picker-name {
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: 0.01em;
}
.system-picker-edition {
  font-size: var(--text-xs);
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.system-picker-count {
  font-size: var(--text-sm);
  color: var(--fg-muted);
}
.system-picker-go {
  margin-top: var(--space-2);
  font-size: var(--text-sm);
  color: var(--gold);
  font-weight: 600;
}

/* ── System bar above units (with "trocar sistema") ── */
.units-system-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
  flex-wrap: wrap;
}
.btn-change-system {
  font-size: var(--text-xs);
  padding: 4px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--bg-elev);
  color: var(--fg-muted);
  cursor: pointer;
  letter-spacing: 0.04em;
  transition: border-color 0.15s, color 0.15s;
}
.btn-change-system:hover {
  border-color: var(--gold);
  color: var(--gold);
}

/* ── Official-review legal-status badges ── */
.ws-badge {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: var(--r-sm, 4px);
  border: 1px solid currentColor;
  line-height: 1.3;
  white-space: nowrap;
  vertical-align: middle;
}
.ws-badge--seasonal   { color: #6fae8e; background: rgba(111,174,142,0.12); }
.ws-badge--legends    { color: #c8a24a; background: rgba(200,162,74,0.12); }
.ws-badge--aor        { color: #7e8fd0; background: rgba(126,143,208,0.12); }
.ws-badge--component  { color: #b08bd0; background: rgba(176,139,208,0.12); }
.ws-badge--deprecated { color: #b5765a; background: rgba(181,118,90,0.12); }
.ws-badge--verify     { color: #d08a3a; background: rgba(208,138,58,0.14); }
.ws-badge--sunset     { color: #c98a4a; background: rgba(201,138,74,0.12); }
.ws-badge--verified   { color: #6fae8e; background: rgba(111,174,142,0.14); }
.ws-badge--tierwarn   { color: #d08a3a; background: rgba(208,138,58,0.14); }
.ws-seasonal-banner   { border-left: 3px solid #6fae8e; }

/* 40K multi-size points tiers on the warscroll */
.ws-points-tiers {
  display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: baseline;
  margin: 0.4rem 0 0.2rem; font-size: 0.84rem; color: var(--fg-muted);
}
.ws-points-tiers-label { text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.72rem; }
.ws-points-tier { color: var(--fg); }

/* Scourge of Ghyran corner marker on listing cards (sibling of .legacy-badge) */
.sog-corner-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 3;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: var(--r-sm, 4px);
  color: #6fae8e;
  background: rgba(20, 30, 26, 0.85);
  border: 1px solid rgba(111, 174, 142, 0.6);
  cursor: help;
}

/* Normal ↔ Scourge of Ghyran version toggle on the warscroll detail */
.ws-version-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0.4rem 0 0.2rem;
  flex-wrap: wrap;
}
.ws-version-toggle-label {
  font-size: 0.72rem;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-right: 2px;
}
.ws-version-tab {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  color: var(--fg-muted);
  background: var(--bg-elev);
  text-decoration: none;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.ws-version-tab:hover { border-color: var(--gold); color: var(--gold); }
.ws-version-tab.is-active {
  color: #0f1512;
  background: #6fae8e;
  border-color: #6fae8e;
  cursor: default;
}

/* Scourge of Ghyran explanatory note on the warscroll */
.ws-seasonal-note {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 0.6rem 0 0.3rem;
  padding: 10px 14px;
  border-radius: var(--r-md, 8px);
  border: 1px solid rgba(111, 174, 142, 0.4);
  border-left: 3px solid #6fae8e;
  background: rgba(111, 174, 142, 0.08);
  max-width: 760px;
}
.ws-seasonal-note-icon { color: #6fae8e; font-size: 1.1rem; line-height: 1.4; flex-shrink: 0; }
.ws-seasonal-note-body { font-size: 0.85rem; line-height: 1.5; color: var(--fg); }
.ws-seasonal-note-link { color: #6fae8e; font-weight: 600; white-space: nowrap; }
.ws-seasonal-note-link:hover { text-decoration: underline; }

/* Army of Renown rules panel (army builder) */
.aor-rules-block {
  border: 1px solid rgba(126, 143, 208, 0.4); border-left: 3px solid #7e8fd0;
  border-radius: var(--r-md, 8px); background: rgba(126, 143, 208, 0.07);
  padding: 10px 14px; margin-bottom: 12px;
}
.aor-rules-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.aor-rules-badge {
  font-size: 0.6rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: #0f1512; background: #7e8fd0; padding: 2px 7px; border-radius: var(--r-sm, 4px);
}
.aor-rules-name { font-weight: 700; font-size: 1rem; }
.aor-rules-summary { font-size: 0.85rem; color: var(--fg-muted); margin: 6px 0 0; }
.aor-rules-note { font-size: 0.82rem; color: #7e8fd0; margin: 6px 0 0; }
.aor-rules-restrict { font-size: 0.82rem; margin: 6px 0 0; }
.aor-rules-section-title { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--fg-muted); margin: 10px 0 4px; }
.aor-rules-empty { font-size: 0.8rem; font-style: italic; color: var(--fg-muted); margin: 8px 0 0; }

/* SoG photo carousel on /units cards (flip Normal <-> Scourge face) */
.unit-card-wrap .ws-card-img-sog { display: none; }
.unit-card-wrap.show-sog .ws-card-img-normal { display: none; }
.unit-card-wrap.show-sog .ws-card-img-sog { display: block; }
.sog-mode-label {
  position: absolute; bottom: 6px; left: 6px; z-index: 3; display: none;
  font-size: 0.6rem; font-weight: 700; letter-spacing: 0.04em;
  padding: 2px 7px; border-radius: var(--r-sm, 4px);
  color: #0f1512; background: #6fae8e;
}
.unit-card-wrap.show-sog .sog-mode-label { display: inline-block; }
.sog-photo-toggle {
  position: absolute; bottom: 6px; right: 6px; z-index: 4;
  width: 26px; height: 26px; border-radius: 50%;
  border: 1px solid rgba(111, 174, 142, 0.7); background: rgba(20, 30, 26, 0.85);
  color: #6fae8e; font-size: 0.95rem; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.sog-photo-toggle:hover { background: #6fae8e; color: #0f1512; }
.sog-photo-toggle[aria-pressed="true"] { background: #6fae8e; color: #0f1512; }
.unit-card-wrap .pts-sog { display: none; }
.unit-card-wrap.show-sog .pts-normal { display: none; }
.unit-card-wrap.show-sog .pts-sog { display: inline-flex; }

/* Battlekit & Armoury module */
.armoury-link { display: inline-block; margin-top: 8px; font-size: 0.85rem; color: var(--gold); font-weight: 600; }
.armoury-link:hover { text-decoration: underline; }
.armoury-intro { color: var(--fg-muted); font-size: 0.9rem; max-width: 72ch; margin-top: 0.5rem; line-height: 1.5; }
.armoury-group { margin-top: 1.5rem; }
.armoury-group-title { font-size: 1.1rem; display: flex; align-items: baseline; gap: 10px; }
.armoury-group-sys { font-size: 0.7rem; color: var(--fg-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.armoury-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin-top: 10px; }
.armoury-card {
  display: block; padding: 12px 14px; border: 1px solid var(--border-strong);
  border-left: 3px solid var(--gold); border-radius: var(--r-md, 8px);
  background: var(--bg-elev); color: var(--fg); transition: border-color 0.15s;
}
.armoury-card:hover { border-color: var(--gold); }
.armoury-card-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.armoury-card-name { font-weight: 700; }
.armoury-card-cost { display: flex; gap: 6px; flex-wrap: wrap; }
.armoury-cost { font-size: 0.72rem; padding: 2px 6px; border-radius: var(--r-sm, 4px); border: 1px solid currentColor; white-space: nowrap; }
.armoury-cost--ducats { color: #c8a24a; }
.armoury-cost--glory { color: #b08bd0; }
.armoury-card-lore { font-size: 0.8rem; color: var(--fg-muted); margin: 6px 0 0; }
.armoury-card-meta { font-size: 0.7rem; color: var(--fg-muted); }

/* 40K unit-size (points tier) picker in the au-card dropdown */
.au-size-form { padding: 4px 8px 6px; border-bottom: 1px solid var(--border-subtle, rgba(255,255,255,0.08)); margin-bottom: 4px; }
.au-size-label { display: block; font-size: 0.66rem; color: var(--fg-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.au-size-select {
  width: 100%; margin-top: 3px; font-size: 0.8rem; padding: 4px 6px;
  background: var(--bg-elev); color: var(--fg);
  border: 1px solid var(--border-strong); border-radius: var(--r-sm, 4px); cursor: pointer;
}

/* RoR resolved components in the picker */
.ror-comp-link    { color: var(--gold); text-decoration: underline dotted; }
.ror-comp-link:hover { text-decoration: underline; }
.ror-comp-special { color: var(--fg-muted); font-style: italic; border-bottom: 1px dashed var(--border-strong); }

/* Faction collapsible block */
.units-faction-block {
  margin-bottom: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-elev);
  overflow: hidden;
}

.units-faction-block[open] { box-shadow: var(--shadow-sm); }

.units-faction-heading {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-display);
  font-size: var(--text-base);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg);
  background: linear-gradient(180deg, var(--bg-elev-2) 0%, var(--bg-elev) 100%);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s, background 0.2s;
}

.units-faction-block[open] > .units-faction-heading {
  border-bottom-color: var(--border-gold);
}

.units-faction-heading::-webkit-details-marker { display: none; }

.units-faction-heading .chev {
  display: inline-block;
  width: 10px;
  color: var(--gold);
  transition: transform 0.2s;
  font-size: 0.7em;
}

.units-faction-block[open] > .units-faction-heading .chev {
  transform: rotate(90deg);
}

.units-faction-heading .faction-count {
  font-size: var(--text-xs);
  letter-spacing: 0.06em;
  color: var(--fg-faint);
  font-weight: 400;
}

.units-faction-heading .faction-spacer { flex: 1; }

.units-faction-body { padding: var(--space-4); }

/* Unit grid (BB style v3) */
.unit-grid--bb {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: var(--space-3);
}
@media (min-width: 640px) {
  .unit-grid--bb { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: var(--space-4); }
}
@media (min-width: 960px) {
  .unit-grid--bb { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
}

/* Card v3 */
.unit-card--bb {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  text-decoration: none;
  color: var(--fg);
  transition: transform 0.15s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

/* Top stripe (alliance accent) */
.unit-card--bb::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--gold);
  z-index: 3;
}
.unit-card--bb.ga-order::before       { background: var(--ga-order); }
.unit-card--bb.ga-chaos::before       { background: var(--ga-chaos); }
.unit-card--bb.ga-death::before       { background: var(--ga-death); }
.unit-card--bb.ga-destruction::before { background: var(--ga-destruction); }
.unit-card--bb.ga-universal::before   { background: var(--ga-universal); }

.unit-card--bb:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-gold);
  opacity: 1;
}

.unit-card--bb.unit-card--legends {
  background: repeating-linear-gradient(
    135deg,
    var(--bg-elev) 0px,
    var(--bg-elev) 14px,
    var(--bg-elev-2) 14px,
    var(--bg-elev-2) 16px
  );
}

.unit-card--bb.unit-card--incomplete {
  border-style: dashed;
}

.unit-card-bb-image {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--bg-elev-2);
  overflow: hidden;
  position: relative;
}

.unit-card-bb-body {
  padding: var(--space-3) var(--space-3) var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  flex: 1;
}

.unit-card--bb .unit-card-name {
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--fg);
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.unit-card--bb .unit-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  align-items: center;
}

.unit-card--bb .pts-badge {
  background: var(--gold-soft);
  border-color: var(--gold);
  color: var(--gold-deep);
  font-weight: 700;
  padding: 2px 7px;
  font-size: 0.78rem;
}
:root:not([data-theme="light"]) .unit-card--bb .pts-badge { color: var(--gold); }

.unit-card-bb-body .unit-card-stats-peek {
  margin-top: auto;
  background: var(--gold-soft);
  border-color: var(--border-gold);
}

/* Incomplete chip on card */
.incomplete-chip {
  position: absolute;
  top: 6px;
  right: 6px;
  background: var(--bg);
  color: var(--gold-deep);
  font-size: 0.6rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 9px;
  border: 1px solid var(--gold);
  line-height: 1.4;
  z-index: 4;
}
:root:not([data-theme="light"]) .incomplete-chip { color: var(--gold); }

/* Manifestations subsection */
.manifestations-subsection {
  margin-top: var(--space-4);
  padding: var(--space-3) var(--space-3) var(--space-2);
  background: var(--gold-soft);
  border-left: 2px solid var(--border-gold);
  border-radius: var(--r-sm);
}

.manifestations-subsection-title {
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-faint);
  margin-bottom: var(--space-2);
}

.manifestations-subsection-title .count { opacity: 0.7; font-weight: 400; }

.unit-grid--manifestations {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: var(--space-2);
}

.unit-card--manifestation {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  border: 1px dashed var(--border-gold);
  border-radius: var(--r-sm);
  overflow: hidden;
  text-decoration: none;
  color: var(--fg);
  opacity: 0.85;
  transition: opacity 0.18s, transform 0.15s;
}
.unit-card--manifestation:hover { opacity: 1; transform: translateY(-1px); }

.unit-card--manifestation .unit-image-frame {
  aspect-ratio: 4 / 3;
  max-height: 86px;
}
.unit-card--manifestation .unit-card-body {
  padding: var(--space-2);
}
.unit-card--manifestation .unit-card-name {
  font-size: 0.7rem;
  line-height: 1.2;
  letter-spacing: 0.04em;
}

/* ============================================================
   FILTER BAR v3 (units/index)
   ============================================================ */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: flex-end;
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-5);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}

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

.filter-field-label {
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-faint);
  font-weight: 600;
}

.filter-field--system  .form-select { min-width: 140px; }
.filter-field--faction .form-select { min-width: 180px; }
.filter-field--search  .form-input  { min-width: 200px; }
.filter-field--pts     .form-input  { width: 88px; }

.filter-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--fg-muted);
  white-space: nowrap;
  padding-bottom: 6px;
}

.filter-toggle input[type=checkbox] {
  accent-color: var(--gold);
  width: 13px; height: 13px;
}

.filter-toggle .chip-q {
  background: var(--gold-soft);
  color: var(--gold-deep);
  font-size: 0.6rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 8px;
  border: 1px solid var(--gold);
}
:root:not([data-theme="light"]) .filter-toggle .chip-q { color: var(--gold); }

/* ============================================================
   WARSCROLL — section nav + alliance accent + empty states
   ============================================================ */
.ws-section-nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: var(--nav-height);
  z-index: 50;
}

/* Anchor targets dentro do warscroll: offset pra não ficarem sob a tab nav sticky */
.ws-card [id^="sec-"] {
  scroll-margin-top: calc(var(--nav-height) + 70px);
}

.ws-section-nav a {
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: var(--r-sm);
  color: var(--fg-muted);
  border: 1px solid transparent;
  background: transparent;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.ws-section-nav a:hover {
  color: var(--gold-deep);
  background: var(--gold-soft);
  border-color: var(--border-gold);
  opacity: 1;
}
:root:not([data-theme="light"]) .ws-section-nav a:hover { color: var(--gold); }

/* Warscroll header alliance top stripe */
.ws-card { position: relative; }
.ws-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--gold);
  z-index: 2;
}
.ws-card.ga-order::before       { background: var(--ga-order); }
.ws-card.ga-chaos::before       { background: var(--ga-chaos); }
.ws-card.ga-death::before       { background: var(--ga-death); }
.ws-card.ga-destruction::before { background: var(--ga-destruction); }
.ws-card.ga-universal::before   { background: var(--ga-universal); }

/* Empty-state placeholders within warscroll body */
.ws-empty {
  font-size: var(--text-sm);
  font-style: italic;
  color: var(--fg-faint);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-elev-2);
  border: 1px dashed var(--border);
  border-radius: var(--r-sm);
  text-align: center;
}

.ws-empty .ws-empty-hint {
  display: block;
  font-size: var(--text-xs);
  font-style: normal;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-faint);
  margin-top: 4px;
  opacity: 0.7;
}

/* Explanatory note under a warscroll section subtitle (e.g. Formations scope) */
.ws-section-note {
  margin: -0.2rem 0 0.6rem;
  padding: 0.45rem 0.6rem;
  font-size: var(--text-sm);
  line-height: 1.45;
  color: var(--fg-muted);
  background: rgba(180,140,60,0.07);
  border-left: 3px solid rgba(180,140,60,0.45);
  border-radius: var(--r-sm);
}
.ws-section-note strong { color: var(--fg); }

/* Lore section refined (warscroll) */
.unit-lore-section {
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--fg);
}

.unit-lore-section p {
  margin-bottom: var(--space-3);
}

/* ============================================================
   ARMY NEW FORM v3 — step-by-step layout
   ============================================================ */
.army-new-form {
  max-width: 880px;
  margin: var(--space-6) auto;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--space-6) var(--space-5) var(--space-5);
  box-shadow: var(--shadow-md);
}

.army-new-header {
  text-align: center;
  margin-bottom: var(--space-5);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border);
}

.army-new-header .eyebrow {
  justify-content: center;
}

.army-new-sub {
  color: var(--fg-muted);
  font-size: 0.92rem;
  margin-top: 0.4rem;
}

.army-new-step {
  margin-bottom: var(--space-5);
}

.army-new-step-head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.army-new-step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg-elev-2);
  border: 1px solid var(--border-strong);
  color: var(--fg-muted);
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 600;
}

.army-new-step-label {
  font-family: var(--font-display);
  font-size: 0.82rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin: 0;
}

.army-new-text-input {
  width: 100%;
  padding: 0.7rem 0.9rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 0.95rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.army-new-text-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.army-new-pts-hint {
  margin-top: 0.6rem;
  font-size: 0.82rem;
  color: var(--fg-muted);
  font-family: var(--font-display);
  letter-spacing: 0.06em;
}

.army-new-submit {
  margin-top: 1rem;
}

/* ── radio-card primitive (used by system/ruleset/battlepack/faction) ── */
.radio-card-grid {
  display: grid;
  gap: var(--space-2);
}

.radio-card-grid--system {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.radio-card-grid--ruleset {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.radio-card-grid--battlepack {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.radio-card {
  position: relative;
  display: block;
  padding: var(--space-3);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}

.radio-card:hover {
  border-color: var(--border-strong);
  background: var(--bg-elev-2);
}

.radio-card input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.radio-card:has(input[type="radio"]:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.radio-card-body {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.radio-card-title {
  font-family: var(--font-display);
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--fg);
  letter-spacing: 0.02em;
}

.radio-card:has(input[type="radio"]:checked) .radio-card-title {
  color: var(--accent-text);
}

.radio-card-meta {
  font-size: 0.7rem;
  color: var(--fg-faint);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* ── faction picker (grouped by alliance) ── */
.faction-picker {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.faction-picker-system {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.faction-picker-group {
  border-top: 1px solid var(--border);
  padding-top: 0.7rem;
}

.faction-picker-group:first-child {
  border-top: none;
  padding-top: 0;
}

.faction-picker-group-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.faction-picker-group-count {
  font-size: 0.7rem;
  color: var(--fg-muted);
  font-family: var(--font-display);
}

.faction-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.45rem;
}

.radio-card--faction {
  padding: 0.55rem 0.7rem;
}

.radio-card--faction .radio-card-title {
  font-size: 0.82rem;
}

/* Alliance accent on faction cards */
.radio-card--faction.ga-order:has(input:checked) { box-shadow: inset 0 0 0 1px var(--ga-order); border-color: var(--ga-order); background: var(--ga-order-soft); }
.radio-card--faction.ga-chaos:has(input:checked) { box-shadow: inset 0 0 0 1px var(--ga-chaos); border-color: var(--ga-chaos); background: var(--ga-chaos-soft); }
.radio-card--faction.ga-death:has(input:checked) { box-shadow: inset 0 0 0 1px var(--ga-death); border-color: var(--ga-death); background: var(--ga-death-soft); }
.radio-card--faction.ga-destruction:has(input:checked) { box-shadow: inset 0 0 0 1px var(--ga-destruction); border-color: var(--ga-destruction); background: var(--ga-destruction-soft); }
.radio-card--faction.ga-universal:has(input:checked) { box-shadow: inset 0 0 0 1px var(--ga-universal); border-color: var(--ga-universal); background: var(--ga-universal-soft); }

.radio-card--faction.ga-order:has(input:checked) .radio-card-title { color: var(--ga-order); }
.radio-card--faction.ga-chaos:has(input:checked) .radio-card-title { color: var(--ga-chaos); }
.radio-card--faction.ga-death:has(input:checked) .radio-card-title { color: var(--ga-death); }
.radio-card--faction.ga-destruction:has(input:checked) .radio-card-title { color: var(--ga-destruction); }
.radio-card--faction.ga-universal:has(input:checked) .radio-card-title { color: var(--ga-universal); }

@media (max-width: 640px) {
  .army-new-form {
    padding: var(--space-4) var(--space-3) var(--space-4);
    margin: var(--space-3);
  }
  .faction-picker-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }
}

/* ── Legacy subsection (dropdown per faction) ── */
.legacy-subsection {
  margin-top: var(--space-4);
  padding: var(--space-2) var(--space-3);
  background: rgba(184, 147, 90, 0.04);
  border: 1px dashed var(--border-gold);
  border-radius: var(--r-sm);
}

.legacy-subsection > .unit-grid {
  margin-top: var(--space-3);
}

.legacy-subsection-summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-display);
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-faint);
  padding: var(--space-1) 0;
  user-select: none;
}

.legacy-subsection-summary::-webkit-details-marker { display: none; }

.legacy-subsection-summary .chev {
  display: inline-block;
  font-size: 0.6rem;
  transition: transform 0.15s ease;
  color: var(--gold);
}

.legacy-subsection[open] > .legacy-subsection-summary .chev {
  transform: rotate(90deg);
}

.legacy-subsection-summary .count {
  opacity: 0.7;
  font-weight: 400;
  font-size: 0.72rem;
}

.legacy-subsection-hint {
  font-family: var(--font-body, inherit);
  font-size: 0.7rem;
  letter-spacing: 0;
  text-transform: none;
  color: var(--fg-faint);
  opacity: 0.75;
  margin-left: auto;
  font-style: italic;
}

@media (max-width: 640px) {
  .legacy-subsection-hint { display: none; }
}

/* ============================================================
   3-COL BUILDER — ADD BUTTON (pool col1)
   ============================================================ */
.up-add-btn--label {
  width: auto;
  height: 26px;
  padding: 0 10px;
  background: var(--gold, #b8935a);
  border: none;
  border-radius: var(--r-sm);
  color: #000;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.12s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.up-add-btn--label:hover { opacity: 0.82; }

/* ============================================================
   3-COL BUILDER — COMPOSITION PANEL (col2)
   ============================================================ */
.comp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev-2);
}
.comp-header-title {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-muted);
}
.comp-header-total {
  font-size: var(--text-xs);
  color: var(--fg-faint);
}

.comp-group {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border);
}
.comp-group:last-child { border-bottom: none; }

.comp-group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-faint);
  margin-bottom: var(--space-2);
  padding-bottom: var(--space-1);
  border-bottom: 1px solid var(--border);
}
.comp-count {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 9999px;
  padding: 0 6px;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
}

.comp-empty {
  padding: var(--space-5) var(--space-3);
  text-align: center;
  color: var(--fg-faint);
  font-size: var(--text-sm);
}
.comp-empty-hint { font-size: var(--text-xs); margin-top: var(--space-1); }

/* ============================================================
   3-COL BUILDER — AU CARD (New Recruit style)
   ============================================================ */
.au-card {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background 0.1s;
  border: 1px solid transparent;
  margin-bottom: 2px;
}
.au-card:hover { background: var(--bg-elev-2); border-color: var(--border); }
.au-card--active { outline: 2px solid var(--gold, #b8935a); outline-offset: -2px; }

.au-card-thumb {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  overflow: hidden;
}
.au-card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.au-card-img-placeholder {
  width: 36px;
  height: 36px;
  background: var(--bg-elev-2);
  border: 1px dashed var(--border);
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.au-card-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.au-card-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.au-card-pts {
  display: flex;
  gap: 4px;
  align-items: center;
  font-size: var(--text-xs);
}

.au-card-actions {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 4px;
}
.au-card-icon-btn {
  width: 24px;
  height: 24px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-elev-2);
  color: var(--fg-muted);
  font-size: 0.75rem;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.1s, color 0.1s;
}
.au-card-icon-btn:hover { background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent); }
.au-card-icon-btn--active { background: var(--gold, #b8935a); color: #000; border-color: var(--gold, #b8935a); }

/* Quick-remove X — always reads as a danger/remove action */
.au-quick-remove {
  color: var(--danger-text);
  border-color: color-mix(in srgb, var(--danger) 45%, var(--border));
}
.au-quick-remove:hover {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.au-card-dot-btn {
  width: 24px;
  height: 24px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-elev-2);
  color: var(--fg-muted);
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  list-style: none;
  transition: background 0.1s, color 0.1s;
  user-select: none;
}
.au-card-dot-btn::-webkit-details-marker { display: none; }
.au-card-dot-btn:hover { background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent); }

.au-card-dropdown { position: relative; }
.au-dropdown-menu--card {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 60;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  min-width: 160px;
  padding: var(--space-1);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* ============================================================
   3-COL BUILDER — DATASHEET STAT BAR (col3) — C2: single line
   ============================================================ */
.datasheet-statbar {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 3px;
  margin: var(--space-2) 0;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: var(--space-1) var(--space-2);
  /* subtle scrollbar */
  scrollbar-width: thin;
  scrollbar-color: var(--border-gold) transparent;
  -webkit-overflow-scrolling: touch;
}
.datasheet-statbar::-webkit-scrollbar { height: 3px; }
.datasheet-statbar::-webkit-scrollbar-track { background: transparent; }
.datasheet-statbar::-webkit-scrollbar-thumb { background: var(--border-gold); border-radius: 2px; }
.ds-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  flex-shrink: 0;
  padding: 2px 4px;
}
.ds-stat-val {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  white-space: nowrap;
}
.ds-stat-lbl {
  font-size: 0.52rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-faint);
  margin-top: 1px;
  white-space: nowrap;
}

/* ============================================================
   SEARCH — full page (/search)
   ============================================================ */

/* ── Search full page ── */
.search-section {
  margin-bottom: 2rem;
}

.search-section-heading {
  font-size: var(--text-base);
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--gold-deep);
  border-bottom: 1px solid var(--border-gold);
  padding-bottom: 6px;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 7px;
}

.search-result-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.search-result-item {
  border-radius: var(--r-sm);
  overflow: hidden;
}

.search-result-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 9px var(--space-3);
  text-decoration: none;
  color: var(--fg);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  transition: background 0.12s, border-color 0.12s;
}

.search-result-link:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.search-result-name {
  font-size: var(--text-sm);
  font-weight: 600;
}

.search-result-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.search-result-faction {
  font-size: var(--text-xs);
  color: var(--fg-muted);
}


/* ============================================================
   COMPARE — units & armies (Feature A & B)
   ============================================================ */

/* Floating compare bar */
.compare-bar {
  position: sticky;
  top: var(--nav-height);
  z-index: 90;
  background: var(--bg-elev);
  border-bottom: 2px solid var(--gold);
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  padding: var(--space-2) var(--space-4);
}
.compare-bar-inner {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  max-width: var(--container-max);
  margin: 0 auto;
}
.compare-bar-label {
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold-deep);
  white-space: nowrap;
}
.compare-bar-names {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  flex: 1;
}
.compare-bar-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 0.1rem 0.55rem;
  font-size: 0.78rem;
  color: var(--fg);
}
.compare-bar-chip-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--fg-muted);
  padding: 0;
  font-size: 0.7rem;
  line-height: 1;
}
.compare-bar-chip-remove:hover { color: var(--danger-text); }
.compare-bar-actions {
  display: flex;
  gap: var(--space-2);
  flex-shrink: 0;
}

/* Unit card wrap for checkbox overlay */
.unit-card-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
}
.unit-card-wrap > .unit-card {
  flex: 1;
}
.compare-check-label {
  position: absolute;
  top: 4px;
  left: 4px;
  z-index: 10;
  width: 22px;
  height: 22px;
  background: var(--bg-elev);
  border: 1px solid var(--border-gold);
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--gold-deep);
  transition: background 0.12s, border-color 0.12s;
  box-shadow: var(--shadow-sm);
}
.compare-check-label:hover {
  background: var(--gold-soft);
  border-color: var(--gold);
}
.compare-check-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}
.compare-check-input:checked ~ .compare-check-icon,
.compare-check-label:has(.compare-check-input:checked) {
  background: var(--gold);
  color: #fff;
  border-color: var(--gold);
}
.compare-check-label--army {
  position: static;
  display: inline-flex;
  width: auto;
  height: auto;
  padding: 0.28rem 0.55rem;
  font-size: 0.72rem;
  border-radius: var(--r-sm);
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}
.unit-card--selected {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* Compare page layout */
.compare-wrap {
  margin-top: var(--space-5);
}
.compare-scroll {
  overflow-x: auto;
  border-radius: var(--r-md);
  border: 1px solid var(--border-gold);
  margin-bottom: var(--space-5);
}
.compare-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-elev);
  font-size: 0.88rem;
}
.compare-table th,
.compare-table td {
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--border);
  vertical-align: top;
}
.compare-header-row th {
  background: linear-gradient(180deg, #2b2418 0%, #1c1810 100%);
  color: var(--gold);
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: center;
  vertical-align: middle;
}
.compare-attr-col {
  width: 140px;
  min-width: 120px;
  text-align: left !important;
}
.compare-unit-col {
  min-width: 180px;
}
.compare-unit-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2) 0;
}
.compare-unit-img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-gold);
}
.compare-sys-badge {
  font-size: 0.6rem;
}
.compare-unit-name {
  font-family: var(--font-display);
  font-size: 0.85rem;
  color: var(--gold);
  text-decoration: none;
  text-align: center;
}
.compare-unit-name:hover { text-decoration: underline; }
.compare-unit-faction {
  font-size: 0.7rem;
  color: var(--fg-muted);
  text-align: center;
}
.compare-section-row td {
  background: linear-gradient(180deg, #2b2418 0%, #1c1810 100%);
  color: var(--gold);
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: center;
  font-weight: 700;
  border-color: var(--border-gold);
}
.compare-attr {
  font-weight: 600;
  color: var(--fg-muted);
  font-size: 0.82rem;
  text-align: left;
}
.compare-val {
  text-align: center;
}
.compare-stat-val {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 1rem;
  color: var(--fg);
}
.compare-na {
  color: var(--fg-faint);
}
.compare-kw-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem;
  justify-content: center;
}
.compare-pts-over  { color: var(--danger-text); font-weight: 700; }
.compare-pts-exact { color: var(--success-text); font-weight: 700; }
.compare-pts-under { color: var(--fg); }
.compare-pts-bar { margin: 0.2rem auto; max-width: 120px; }
.compare-pct-label { font-size: 0.75rem; color: var(--fg-muted); }
.compare-pts-val { text-align: center; }

/* Weapons/abilities side-by-side block */
.compare-section-block {
  margin-bottom: var(--space-5);
}
.compare-section-title {
  font-family: var(--font-display);
  font-size: 1rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gold-deep);
  margin: 0 0 var(--space-3) 0;
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border-gold);
}
.compare-units-grid {
  display: grid;
  grid-template-columns: repeat(var(--compare-cols, 2), 1fr);
  gap: var(--space-4);
}
@media (max-width: 640px) {
  .compare-units-grid { grid-template-columns: 1fr; }
}
.compare-unit-block {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--space-4);
}
.compare-unit-block-name {
  font-family: var(--font-display);
  font-size: 0.88rem;
  color: var(--gold-deep);
  margin: 0 0 var(--space-2) 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.compare-block-subtitle {
  font-size: 0.78rem;
  color: var(--fg-muted);
  margin: 0 0 var(--space-2) 0;
}
.compare-weapons-subtitle {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-muted);
  margin: var(--space-2) 0 var(--space-1) 0;
}
.compare-table-wrap {
  font-size: 0.78rem;
  overflow-x: auto;
}
.compare-abilities-grid {
  gap: var(--space-2);
}
.compare-regiment-block {
  border-left: 2px solid var(--border-gold);
  padding-left: var(--space-3);
  margin-bottom: var(--space-3);
}
.compare-regiment-label {
  display: block;
  font-family: var(--font-display);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: var(--space-1);
}
.compare-au-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-2);
  padding: 0.2rem 0;
  font-size: 0.82rem;
  border-bottom: 1px dotted var(--border);
}
.compare-au-row:last-child { border-bottom: none; }
.compare-au-name { flex: 1; min-width: 0; }
.compare-enh-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem;
  padding: 0.2rem 0 0.4rem;
}

.compare-back-bar {
  margin: var(--space-5) 0;
}
.compare-error-box {
  background: var(--bg-elev);
  border: 1px solid var(--border-gold);
  border-radius: var(--r-md);
  padding: var(--space-5);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  color: var(--fg-muted);
}


/* ============================================================
   ARMY PRINT (Feature C)
   ============================================================ */

.print-section {
  padding: var(--space-6) 0;
}
.print-container {
  max-width: 800px;
}
.print-actions {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}
.print-actions--bottom {
  margin-top: var(--space-5);
  justify-content: flex-end;
}
.print-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}
.print-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}
.print-header-main {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.print-sys-badge {
  align-self: flex-start;
}
.print-army-name {
  font-family: var(--font-display);
  font-size: 1.8rem;
  margin: 0;
  color: var(--fg);
}
.print-meta-chips {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  align-items: center;
}
.print-pts-badge {
  font-size: 0.95rem;
  padding: 0.2rem 0.6rem;
}
.print-picks {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}
.print-divider {
  border: none;
  border-top: 2px solid var(--border-gold);
  margin: var(--space-4) 0;
}
.print-regiment {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin-bottom: var(--space-4);
  overflow: hidden;
  page-break-inside: avoid;
}
.print-regiment-header {
  background: linear-gradient(180deg, #2b2418 0%, #1c1810 100%);
  padding: 0.4rem 0.8rem;
}
.print-regiment-label {
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
}
.print-unit-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  padding: 0.45rem 0.8rem;
  border-bottom: 1px dotted var(--border);
}
.print-unit-row:last-child { border-bottom: none; }
.print-unit-row--leader {
  background: rgba(184,147,90,0.05);
}
.print-unit-left {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 1;
  min-width: 0;
}
.print-unit-name {
  font-weight: 600;
  font-size: 0.9rem;
}
.print-enh-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.2rem 0.8rem 0.4rem;
  background: var(--bg-elev-2);
}
.print-abilities-mini {
  padding: 0.35rem 0.8rem 0.5rem 1.4rem;
  background: var(--bg-elev-2);
  border-top: 1px dotted var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.print-ability-mini {
  font-size: 0.78rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  align-items: baseline;
}
.print-ability-name {
  font-weight: 700;
  color: var(--gold-deep);
}
.print-ability-desc {
  color: var(--fg-muted);
}
.print-abilities-more {
  font-size: 0.72rem;
  color: var(--fg-faint);
  font-style: italic;
}
.print-totals {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
  padding: var(--space-3) 0;
}
.print-totals-label {
  font-family: var(--font-display);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-muted);
}
.print-totals-units {
  font-size: 0.82rem;
  color: var(--fg-muted);
}
.print-issues {
  margin-top: var(--space-4);
  padding: var(--space-3);
  border: 1px solid var(--warn);
  border-radius: var(--r-md);
  background: rgba(196,122,26,0.06);
}
.print-issues-title {
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--warn-text);
  margin: 0 0 var(--space-2);
}

/* === ARMY PRINT === */
@media print {
  .no-print,
  nav, footer, .nav-bar, .site-footer,
  .print-actions, .compare-bar,
  .army-topbar-actions, .builder-rail {
    display: none !important;
  }
  body {
    background: #fff !important;
    color: #000 !important;
  }
  .print-section, .print-container {
    padding: 0 !important;
    max-width: 100% !important;
  }
  .print-regiment {
    page-break-inside: avoid;
    border-color: #999 !important;
  }
  .print-regiment-header {
    background: #eee !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .print-regiment-label { color: #333 !important; }
  .print-divider { border-top-color: #999 !important; }
  .pts-badge {
    background: transparent !important;
    color: #000 !important;
    border: 1px solid #999 !important;
  }
  .sys-badge, .role-tag, .alliance-badge, .legal-pill, .enh-chip {
    border: 1px solid #999 !important;
    background: transparent !important;
    color: #000 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  a { color: #000 !important; text-decoration: none !important; }
}

/* ============================================================
   COLLECTION / WISHLIST
   ============================================================ */

/* ── Collection toggle row in unit detail ── */
.ws-collection-row {
  margin-top: var(--space-3);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}

.collection-loading {
  font-size: var(--text-xs);
  color: var(--fg-faint);
}

.collection-toggle {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.btn-collection {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  padding: 0.35rem 0.8rem;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--bg-elev);
  color: var(--fg-muted);
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.07em;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.1s;
}
.btn-collection:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-text);
}
.btn-collection--active {
  color: #fff;
  border-color: transparent;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.18) inset, 0 2px 6px rgba(0,0,0,0.35);
  font-weight: 700;
}
.btn-collection--owned   { background: var(--success); border-color: var(--success); }
.btn-collection--wanted  { background: var(--info);    border-color: var(--info); }
.btn-collection--painted { background: #9b5ea2;        border-color: #9b5ea2; }
.btn-collection-check { font-size: 0.85em; margin-left: 0.15em; }
.btn-collection.htmx-request { opacity: 0.6; cursor: progress; }

/* ── Collection index page ── */
.collection-section { padding: var(--space-7) 0; }

.collection-filters { margin-bottom: var(--space-5); }
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}
.filter-select {
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-elev);
  color: var(--fg);
  font-size: var(--text-sm);
  cursor: pointer;
}

.collection-stats-strip {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-bottom: var(--space-5);
}
.coll-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-elev);
  min-width: 80px;
}
.coll-stat--active {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.coll-stat-count {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--fg);
}
.coll-stat-label {
  font-size: var(--text-xs);
  color: var(--fg-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.collection-group { margin-bottom: var(--space-7); }
.collection-group-title {
  font-family: var(--font-display);
  font-size: var(--text-base);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.collection-group-count {
  font-size: var(--text-xs);
  color: var(--fg-faint);
  font-weight: 400;
}

.collection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--space-4);
}

.collection-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-elev);
  overflow: hidden;
  transition: box-shadow 0.15s;
}
.collection-card:hover { box-shadow: var(--shadow-md); }

.collection-card-img {
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--bg-elev-2);
  display: flex;
  align-items: center;
  justify-content: center;
}
.collection-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.coll-img-placeholder {
  width: 64px;
  height: 64px;
  opacity: 0.4;
}

.collection-card-body {
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  flex: 1;
}
.collection-unit-name {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1.2;
  margin: 0;
}
.collection-unit-name a {
  color: var(--fg);
  text-decoration: none;
}
.collection-unit-name a:hover { color: var(--accent-text); }
.collection-faction-name {
  font-size: var(--text-xs);
  color: var(--fg-faint);
  margin: 0;
}

/* Quantity controls */
.collection-qty {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.btn-qty {
  width: 1.5rem;
  height: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-elev-2);
  color: var(--fg-muted);
  font-size: 0.85rem;
  cursor: pointer;
  line-height: 1;
}
.btn-qty:hover:not(:disabled) { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); }
.btn-qty:disabled { opacity: 0.35; cursor: default; }
.collection-qty-val {
  font-size: var(--text-sm);
  font-weight: 600;
  min-width: 1.5rem;
  text-align: center;
}

.btn-collection-remove {
  margin-top: auto;
  align-self: flex-end;
  background: transparent;
  border: none;
  color: var(--fg-faint);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0.1rem 0.3rem;
  border-radius: var(--r-sm);
  line-height: 1;
}
.btn-collection-remove:hover { color: var(--danger-text); background: rgba(184,68,58,0.07); }

/* Painted toggle button */
.btn-painted-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.35rem;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg-muted);
  font-size: 0.65rem;
  font-family: var(--font-display);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 0.15rem 0.45rem;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.btn-painted-toggle:hover {
  color: var(--accent-text);
  border-color: var(--accent-text);
}
.btn-painted-toggle--active {
  color: #c47b2a;
  border-color: #c47b2a;
  background: rgba(196,123,42,0.08);
}

.collection-empty {
  text-align: center;
  padding: var(--space-8) 0;
  color: var(--fg-muted);
}
.collection-empty p { margin-bottom: var(--space-3); }

/* Dark mode overrides */
:root:not([data-theme="light"]) .btn-collection {
  background: var(--bg-elev);
  border-color: var(--border-strong);
  color: var(--fg-muted);
}
:root:not([data-theme="light"]) .collection-card { background: var(--bg-elev); }
:root:not([data-theme="light"]) .filter-select { background: var(--bg-elev); color: var(--fg); border-color: var(--border); }

/* ============================================================
   WEAPON TABLES — unit details panel (.ds-weap-*)
   ============================================================ */
.ds-weap-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-top: var(--space-3);
}
.ds-weap-group {
  margin-top: var(--space-3);
}
.ds-weap-group:first-child {
  margin-top: 0;
}
.ds-weap-title {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin-bottom: 3px;
  padding-bottom: 2px;
  border-bottom: 1px solid var(--border);
}

/* ── Model count (sempre visível) ── */
.ds-modelcount {
  display: inline-flex; align-items: baseline; gap: 5px;
  margin: 6px 0 2px;
  font-size: 0.74rem; color: var(--fg-muted);
}
.ds-modelcount-num {
  font-family: var(--font-display); font-weight: 800;
  font-size: 0.95rem; color: var(--gold);
}

/* ── Core (Keywords explicadas) ── */
.ds-core-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.ds-core-item { display: flex; flex-direction: column; gap: 1px; }
.ds-core-kw {
  font-family: var(--font-display); font-weight: 700; font-size: 0.76rem;
  letter-spacing: .03em; color: var(--fg);
}
.ds-core-desc { font-size: 0.76rem; line-height: 1.35; color: var(--fg-muted); }

/* ── Bloco de Destacamento + Aprimoramentos no warscroll ── */
.ds-detach { margin-top: 0.75rem; }
.ds-detach-rule { margin-bottom: .4rem; }
.ds-detach-rule-name, .ds-strat-name {
  font-weight: 700; font-size: 0.8rem; color: var(--fg);
}
.ds-detach-text, .ds-strat-text {
  display: block; font-size: 0.78rem; line-height: 1.4; color: var(--fg-muted); margin-top: 2px;
}
.ds-detach-subtitle {
  font-size: 0.62rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--fg-faint); margin: .5rem 0 .25rem;
}
.ds-strat-list, .ds-enh-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.ds-strat-item, .ds-enh-item {
  padding: 5px 7px; border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--bg-elev-2);
}
.ds-strat-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ds-strat-cp {
  font-family: var(--font-display); font-weight: 800; font-size: 0.68rem;
  color: var(--gold); background: var(--gold-soft, rgba(200,160,50,.12));
  border: 1px solid var(--border-gold, rgba(200,160,50,.4)); border-radius: var(--r-sm); padding: 0 5px;
}
.ds-strat-cat {
  font-size: 0.6rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--fg-faint); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 0 5px;
}
/* destaque quando o destacamento/estratagema afeta esta unidade */
.ds-affect-badge {
  font-size: 0.58rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: #4caf50; background: rgba(76,175,80,.14);
  border: 1px solid rgba(76,175,80,.4); border-radius: var(--r-sm); padding: 0 5px;
}
.ds-detach--affects {
  border-left: 2px solid #4caf50;
  padding-left: 6px;
}
.ds-weap-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.76rem;
  line-height: 1.3;
}
.ds-weap-table thead th {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--fg-faint);
  border-bottom: 1px solid var(--border-strong);
  padding: 2px 4px;
  text-align: center;
  white-space: nowrap;
}
.ds-weap-table thead th.ds-wn {
  text-align: left;
}
.ds-weap-table tbody td {
  padding: 2px 4px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.ds-weap-table tbody tr:last-child td {
  border-bottom: none;
}
.ds-weap-table tbody td.ds-wn {
  text-align: left;
  font-weight: 500;
  white-space: nowrap;
  color: var(--fg);
}
.ds-weap-table tbody td.ds-wkw {
  text-align: left;
  font-size: 0.68rem;
  color: var(--fg-faint);
  white-space: normal;
  min-width: 80px;
}
/* Dark mode — no extra override needed (uses tokens already) */
:root:not([data-theme="light"]) .ds-weap-title {
  color: var(--fg-muted);
  border-color: var(--border);
}
:root:not([data-theme="light"]) .ds-weap-table thead th {
  color: var(--fg-faint);
  border-color: var(--border-strong);
}
:root:not([data-theme="light"]) .ds-weap-table tbody td {
  border-color: var(--border);
}
:root:not([data-theme="light"]) .ds-weap-table tbody td.ds-wkw {
  color: var(--fg-faint);
}

/* ============================================================
   PWA — Install bar + offline indicators
   ============================================================ */

#pwa-install-bar {
  position: fixed;
  bottom: calc(var(--nav-height) + 8px); /* sit above mobile bottom nav */
  left: 50%;
  transform: translateX(-50%);
  z-index: 9000;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-elev);
  border: 1px solid var(--border-gold);
  border-radius: var(--r-lg);
  padding: 10px 16px;
  box-shadow: var(--shadow-md);
  max-width: 340px;
  width: calc(100% - 32px);
  animation: pwa-slide-up 0.3s ease;
}

@keyframes pwa-slide-up {
  from { opacity: 0; transform: translateX(-50%) translateY(16px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.pwa-install-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  background: var(--accent);
  color: var(--accent-fg, #fff);
  border: none;
  border-radius: var(--r-md);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.02em;
  font-family: var(--font-body);
  transition: opacity 0.15s;
}

.pwa-install-btn:hover { opacity: 0.88; }

.pwa-install-dismiss {
  background: transparent;
  border: none;
  color: var(--fg-muted);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--r-sm);
  font-family: var(--font-body);
  transition: color 0.15s;
}

.pwa-install-dismiss:hover { color: var(--fg); }

/* On desktop, pin install bar to top-right instead of bottom */
@media (min-width: 768px) {
  #pwa-install-bar {
    top: calc(var(--nav-height) + 12px);
    bottom: auto;
    right: 16px;
    left: auto;
    transform: none;
    animation: pwa-slide-down 0.3s ease;
  }

  @keyframes pwa-slide-down {
    from { opacity: 0; transform: translateY(-12px); }
    to   { opacity: 1; transform: translateY(0); }
  }
}

/* ============================================================
   FONTE FALLBACK MÉTRICA — reduz CLS antes do Oswald carregar
   ============================================================ */
@font-face {
  font-family: 'Oswald-fallback';
  src: local('Arial Narrow');
  size-adjust: 90%;
  ascent-override: 105%;
}

/* ============================================================
   MOVIMENTO REDUZIDO — respeita prefers-reduced-motion
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================================
   REVIEW FIXES — mobile / touch / table containment
   ============================================================ */

/* Wide rules tables (40K/TC) scroll inside their column instead of
   forcing page-wide horizontal scroll on phones. */
.rules-table {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

/* Match history rows were built as flex layouts but .army-row had no
   rule, so columns stacked vertically on every screen. */
.army-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

@media (pointer: coarse) {
  /* Compact secondary buttons (pagination etc.) easier to tap. */
  .btn-sm { min-height: 40px; }

  /* Army builder controls: extend the tappable area to ~44px via a
     transparent overlay WITHOUT reflowing the tight 3-col builder. */
  .up-add-btn,
  .up-expand-btn,
  .au-card-icon-btn,
  .au-card-dot-btn { position: relative; }

  .up-add-btn::after,
  .up-expand-btn::after,
  .au-card-icon-btn::after,
  .au-card-dot-btn::after {
    content: "";
    position: absolute;
    inset: -8px;
  }

  .up-add-btn--label { min-height: 44px; }

  .up-row-actions,
  .au-card-actions { gap: 8px; }
}

/* Hide the redundant logged-in header auth controls on mobile — the
   bottom-nav "Mais" sheet already exposes Perfil/Sair. Logged-out
   ENTRAR/ALISTAR stay visible (scoped via modifier class). */
@media (max-width: 768px) {
  .nav-auth--user { display: none; }
}

/* â”€â”€ Drag-to-add (army builder): grab a unit thumbnail, drop onto the
   army column. Pointer-events based â†’ works on mouse and touch. The ADD
   button stays as the click/keyboard fallback. â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
.up-row-head { touch-action: pan-y ; -webkit-user-select: none ; user-select: none ; }
.up-row-thumb { -webkit-user-select: none ; user-select: none ; }
.up-row-thumb img, .up-thumb-img { -webkit-user-drag: none ; user-drag: none ; -webkit-touch-callout: none ; }
@media (pointer: fine) {
  .up-row-head { cursor: grab ; }
  .up-row-head:active { cursor: grabbing ; }
}
.dnd-ghost {
  position: fixed ; z-index: 9999 ; left: 0 ; top: 0 ; transform: translate(-50%, -130%) ; pointer-events: none ; background: var(--accent) ; color: #fff ; padding: 0.3rem 0.6rem ; border-radius: 4px ; border: 1px solid var(--accent-text) ; font-family: var(--font-display, var(--font-heading)) ; font-size: 0.72rem ; text-transform: uppercase ; letter-spacing: 0.04em ; white-space: nowrap ; max-width: 60vw ; overflow: hidden ; text-overflow: ellipsis ; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5) ; }
body.dnd-active { cursor: grabbing ; -webkit-user-select: none ; user-select: none ; }
#regiments-aux-container.dnd-target {
  outline: 2px dashed var(--border-gold) ; outline-offset: 4px ; border-radius: 6px ; }
#regiments-aux-container.dnd-over {
  outline-style: solid ; outline-color: var(--accent) ; background: var(--gold-soft) ; }

/* Drag a unit card back onto the catalog (left rail) to remove it */
.builder-rail--left.dnd-target {
  outline: 2px dashed var(--danger) ; outline-offset: 4px ; border-radius: 6px ; }
.builder-rail--left.dnd-over {
  outline-style: solid ; background: color-mix(in srgb, var(--danger) 12%, transparent) ; }
.dnd-ghost--remove { background: var(--danger) ; border-color: var(--danger-text) ; }

/* ============================================================
   MATCH TRACKER (grimdark) — deploy header, scorecards,
   objectives map, result panel, battle log.  v11
   ============================================================ */

/* --- Deployment header --- */
.mt-deploy {
  background: var(--bg-elev-2);
  border: 1px solid var(--border-gold);
  border-radius: 4px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
}
.mt-deploy-top {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 1rem; flex-wrap: wrap;
}
.mt-deploy-eyebrow {
  font-family: var(--font-heading);
  font-size: 0.7rem; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--gold); margin: 0 0 0.2rem;
}
.mt-deploy-title {
  font-family: var(--font-heading);
  font-size: 1.4rem; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--fg); margin: 0; line-height: 1.05;
}
.mt-elapsed {
  display: flex; flex-direction: column; align-items: flex-end;
  border-left: 2px solid var(--border-gold); padding-left: 0.9rem;
}
.mt-elapsed-label {
  font-family: var(--font-heading); font-size: 0.62rem;
  letter-spacing: 0.16em; color: var(--fg-faint);
}
.mt-elapsed-clock {
  font-family: var(--font-heading); font-size: 1.25rem;
  letter-spacing: 0.06em; color: var(--accent-text);
  font-variant-numeric: tabular-nums;
}

/* --- Round stepper row --- */
.mt-round-row {
  display: flex; align-items: center; gap: 1rem;
  flex-wrap: wrap; margin-top: 1rem;
  padding-top: 0.9rem; border-top: 1px solid var(--border-gold);
}
.mt-round-stepper { display: flex; gap: 0.4rem; }
.mt-round-pip {
  width: 30px; height: 30px; display: flex; align-items: center;
  justify-content: center; border-radius: 50%;
  border: 1px solid var(--border-gold);
  font-family: var(--font-heading); font-size: 0.85rem;
  color: var(--fg-faint); background: var(--bg-deep);
}
.mt-round-pip.is-done { color: var(--gold); border-color: var(--gold); }
.mt-round-pip.is-current {
  background: var(--system-accent, var(--accent)); border-color: var(--system-accent, var(--accent));
  color: #fff; box-shadow: 0 0 0 2px color-mix(in srgb, var(--system-accent, var(--accent)) 40%, transparent);
}
/* NOVA — Trench Crusade: pip sem cap numérico, exibe "Turno N" */
.mt-round-pip.mt-round-unbounded {
  width: auto; height: auto; border-radius: 4px;
  padding: 0.2rem 0.75rem; min-width: 0; font-size: 0.8rem;
  letter-spacing: 0.06em; text-transform: uppercase;
}
.mt-round-meta { display: flex; flex-direction: column; gap: 0.15rem; }
.mt-phase-tag {
  font-family: var(--font-heading); font-size: 0.8rem;
  letter-spacing: 0.06em; color: var(--fg); text-transform: uppercase;
}
.mt-active-tag { font-size: 0.78rem; color: var(--fg-muted); }
.mt-round-actions {
  display: flex; gap: 0.5rem; margin-left: auto; flex-wrap: wrap;
}
.mt-round-actions form { margin: 0; }

.mt-final-banner, .mt-await-banner, .mt-dispute-banner {
  margin-top: 0.9rem; padding: 0.6rem 0.9rem; border-radius: 4px;
  font-family: var(--font-heading); letter-spacing: 0.08em;
  text-transform: uppercase; font-size: 0.95rem; text-align: center;
}
.mt-final-banner { background: var(--gold-soft); color: var(--gold); border: 1px solid var(--border-gold); }
.mt-await-banner { background: rgba(140,122,82,0.10); color: var(--fg-muted); border: 1px dashed var(--border-gold); }
.mt-dispute-banner { background: rgba(177,29,29,0.12); color: var(--accent-text); border: 1px solid var(--accent); }

/* --- Score cards --- */
.mt-scorewrap { margin-bottom: 1.25rem; }
.mt-scorecards {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1rem;
}
.mt-scorecard {
  background: var(--bg-elev); border: 1px solid var(--border-gold);
  border-radius: 4px; padding: 1rem 1.1rem; position: relative;
}
.mt-scorecard.is-leading {
  border-color: var(--accent); box-shadow: inset 0 0 0 1px rgba(177,29,29,0.3);
}
.mt-sc-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 0.5rem; margin-bottom: 0.4rem;
}
.mt-sc-name {
  font-family: var(--font-heading); font-size: 1rem;
  letter-spacing: 0.05em; text-transform: uppercase; color: var(--fg);
}
.mt-leading-badge {
  font-family: var(--font-heading); font-size: 0.6rem;
  letter-spacing: 0.14em; background: var(--accent); color: #fff;
  padding: 0.15rem 0.45rem; border-radius: 2px;
}
.mt-sc-vp { display: flex; align-items: baseline; gap: 0.35rem; margin-bottom: 0.75rem; }
.mt-sc-vp-num {
  font-family: var(--font-heading); font-size: 2.6rem; line-height: 1;
  color: var(--accent-text); font-variant-numeric: tabular-nums;
}
.mt-sc-vp-label { font-family: var(--font-heading); font-size: 0.85rem; color: var(--fg-faint); letter-spacing: 0.1em; }
.mt-substats { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.mt-substat {
  background: var(--bg-deep); border: 1px solid var(--border-gold);
  border-radius: 3px; padding: 0.4rem 0.5rem;
}
.mt-substat-label {
  display: block; font-size: 0.62rem; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--fg-faint); margin-bottom: 0.25rem;
}
.mt-stepper { display: flex; align-items: center; justify-content: space-between; gap: 0.3rem; }
.mt-stepper form { margin: 0; display: flex; }
.mt-step-btn {
  width: 40px; height: 40px; border-radius: 3px;
  border: 1px solid var(--border-gold); background: var(--bg-elev-2);
  color: var(--fg); font-size: 1rem; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-heading); transition: background .12s, border-color .12s;
}
.mt-step-btn:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.mt-substat-val {
  font-family: var(--font-heading); font-size: 1.15rem;
  color: var(--fg); min-width: 1.5ch; text-align: center;
  font-variant-numeric: tabular-nums;
}

/* --- Objectives map --- */
.mt-objmap {
  margin-top: 1rem; background: var(--bg-elev);
  border: 1px solid var(--border-gold); border-radius: 4px; padding: 1rem;
}
.mt-objmap-head { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; margin-bottom: 0.7rem; }
.mt-objmap-title { font-family: var(--font-heading); font-size: 0.8rem; letter-spacing: 0.14em; color: var(--gold); }
.mt-objmap-hint { font-size: 0.7rem; color: var(--fg-faint); font-style: italic; }
.mt-objmap-field {
  display: flex; gap: 0.75rem; justify-content: center; flex-wrap: wrap;
  padding: 1.1rem 0.75rem; border: 1px dashed var(--border-gold);
  border-radius: 4px;
  background:
    repeating-linear-gradient(45deg, transparent, transparent 9px, rgba(140,122,82,0.04) 9px, rgba(140,122,82,0.04) 10px),
    var(--bg-deep);
}
.mt-objmarker-form { margin: 0; }
.mt-objmarker {
  width: 42px; height: 42px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-heading); font-size: 1rem;
  border: 2px solid var(--border-gold); background: var(--bg-elev-2);
  color: var(--fg-muted); cursor: pointer; transition: transform .1s, box-shadow .12s;
}
button.mt-objmarker:hover { transform: scale(1.08); }
.mt-objmarker.holder-neutral { border-color: var(--fg-faint); color: var(--fg-faint); }
.mt-objmarker.holder-host { border-color: var(--accent); background: rgba(177,29,29,0.22); color: var(--accent-text); }
.mt-objmarker.holder-opponent { border-color: var(--opp-marker, #4f86c6); background: var(--opp-marker-bg, rgba(79,134,198,0.22)); color: var(--opp-marker-text, #8fb4e0); }
.mt-objmarker.holder-contested { border-color: var(--gold); background: var(--gold-soft); color: var(--gold); }
.mt-obj-tally {
  display: flex; justify-content: space-between; gap: 0.5rem;
  margin-top: 0.7rem; font-family: var(--font-heading);
  font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase;
}
.mt-tally-host { color: var(--accent-text); }
.mt-tally-contested { color: var(--gold); }
.mt-tally-opp { color: var(--opp-marker-text, #8fb4e0); }

/* --- Result panel --- */
.mt-resultpanel { margin-bottom: 1.25rem; }
.mt-result-report, .mt-result-confirm, .mt-result-waiting,
.mt-result-disputed, .mt-result-final {
  background: var(--bg-elev); border: 1px solid var(--border-gold);
  border-radius: 4px; padding: 1rem 1.25rem; text-align: center;
}
.mt-result-disputed { border-color: var(--accent); }
.mt-result-final { background: var(--gold-soft); border-color: var(--gold); }
.mt-result-prompt {
  font-family: var(--font-heading); letter-spacing: 0.04em;
  font-size: 1rem; color: var(--fg); margin: 0 0 0.5rem;
}
.mt-result-value { color: var(--accent-text); }
.mt-result-sub { font-size: 0.85rem; color: var(--fg-muted); margin: 0 0 0.75rem; }
.mt-result-btns { display: flex; gap: 0.6rem; justify-content: center; flex-wrap: wrap; }
.mt-result-btns form { margin: 0; }
.mt-result-final-head {
  font-family: var(--font-heading); font-size: 1.3rem;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--gold); margin: 0 0 0.6rem;
}
.mt-result-deltas { display: flex; gap: 1.5rem; justify-content: center; }
.mt-delta { font-size: 0.85rem; color: var(--fg-muted); }
.mt-delta strong { font-family: var(--font-heading); font-size: 1.05rem; margin-left: 0.3rem; }
.mt-delta strong.up { color: #5b8c6f; }
.mt-delta strong.down { color: var(--accent-text); }

/* --- Battle log --- */
.mt-battlelog {
  background: var(--bg-deep); border: 1px solid var(--border-gold);
  border-radius: 4px; padding: 0.75rem 1rem; margin-bottom: 1rem;
}
.mt-battlelog-body { max-height: 280px; overflow-y: auto; }

/* --- Mobile --- */
@media (max-width: 640px) {
  .mt-scorecards { grid-template-columns: 1fr; }
  .mt-sc-vp-num { font-size: 2.1rem; }
  .mt-round-actions { margin-left: 0; width: 100%; }
  .mt-deploy-top { flex-direction: column; }
  .mt-elapsed { align-items: flex-start; border-left: 0; padding-left: 0; }
  .mt-objmarker { width: 38px; height: 38px; }
  .mt-step-btn { width: 44px; height: 44px; }
}

/* ── Live-screen layout grids (stack on mobile) ───────────────────────────── */
.mt-army-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem;
  margin: 1.5rem 0;
}
.mt-bottom-grid {
  display: grid; grid-template-columns: 1fr 320px; gap: 1.5rem;
}
@media (max-width: 820px) {
  .mt-army-grid, .mt-bottom-grid { grid-template-columns: 1fr; }
}

/* ── Dominant phase banner (the headline "where are we now") ───────────────── */
.mt-phase-banner {
  flex: 1 1 220px; min-width: 0;
  display: flex; flex-direction: column; gap: 0.15rem;
  padding: 0.55rem 0.9rem; border-radius: 6px;
  border: 1px solid var(--border-gold);
  border-left: 5px solid var(--phase-accent, var(--system-accent, var(--gold)));
  background: linear-gradient(90deg, color-mix(in srgb, var(--phase-accent, var(--gold)) 14%, transparent), transparent 70%);
  position: relative;
}
.mt-phase-banner-meta { font-size: 0.74rem; color: var(--text-secondary); letter-spacing: 0.02em; }
.mt-phase-banner-meta strong { color: var(--fg); }
.mt-pb-sep { opacity: 0.6; }
.mt-phase-banner-name {
  font-family: var(--font-heading); font-size: 1.5rem; line-height: 1.05;
  letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--phase-accent, var(--gold));
}
.mt-phase-banner-cp {
  position: absolute; top: 0.5rem; right: 0.7rem;
  font-family: var(--font-heading); font-size: 0.95rem; font-weight: 700;
  color: var(--gold); background: var(--bg-deep);
  border: 1px solid var(--border-gold); border-radius: 4px; padding: 0.1rem 0.45rem;
}
/* Per-phase accent colours (work across AoS/40K/TC phase keys) */
.mt-phase--hero, .mt-phase--command, .mt-phase--initiative { --phase-accent: #c9a227; }
.mt-phase--move    { --phase-accent: #5fb0c4; }
.mt-phase--shoot   { --phase-accent: #9c8b3e; }
.mt-phase--charge  { --phase-accent: #d99a4a; }
.mt-phase--combat, .mt-phase--fight, .mt-phase--action { --phase-accent: #d96a4f; }
.mt-phase--morale  { --phase-accent: #8a86d6; }
.mt-phase--end     { --phase-accent: #9aa0a8; }

.mt-round-row { display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap; }
.mt-round-actions { display: flex; gap: 0.5rem; margin-left: auto; flex-wrap: wrap; }
.mt-advance-phase { min-height: 40px; }
@media (max-width: 640px) {
  .mt-phase-banner-name { font-size: 1.25rem; }
  .mt-round-actions { margin-left: 0; width: 100%; }
  .mt-round-actions form { flex: 1; }
  .mt-round-actions .btn-sm { width: 100%; min-height: 44px; }
}

/* ── Phase Assistant: "what you can do / spend now" ────────────────────────── */
.mt-assist {
  background: var(--bg-deep); border: 1px solid var(--border-gold);
  border-radius: 6px; padding: 0.85rem 1rem; margin-bottom: 1.5rem;
}
.mt-assist-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem; }
.mt-assist-titles { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.mt-assist-eyebrow { font-size: 0.66rem; letter-spacing: 0.14em; color: var(--text-secondary); }
.mt-assist-phase {
  font-family: var(--font-heading); font-size: 1.05rem; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--gold);
}
.mt-assist-side { font-size: 0.8rem; color: var(--text-secondary); }
.mt-assist-side em { opacity: 0.8; }
.mt-assist-cp {
  flex-shrink: 0; text-align: center; line-height: 1;
  background: var(--bg-elev); border: 1px solid var(--border-gold);
  border-radius: 6px; padding: 0.35rem 0.6rem;
}
.mt-assist-cp-num { display: block; font-family: var(--font-heading); font-size: 1.5rem; color: var(--gold); }
.mt-assist-cp-lbl { font-size: 0.6rem; letter-spacing: 0.12em; color: var(--text-secondary); }
.mt-assist-tip {
  font-size: 0.84rem; color: var(--text-secondary); margin: 0.6rem 0 0.4rem;
  padding: 0.4rem 0.6rem; background: var(--bg-elev); border-radius: 4px;
  border-left: 3px solid var(--border-gold);
}
.mt-assist-group { margin-top: 0.7rem; }
.mt-assist-group-title {
  font-family: var(--font-heading); font-size: 0.8rem; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--fg);
  display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0.3rem;
  padding-bottom: 0.2rem; border-bottom: 1px solid var(--border);
}
.mt-assist-ico { color: var(--gold); }
.mt-assist-count {
  margin-left: auto; font-size: 0.68rem; color: var(--text-secondary);
  background: var(--bg-elev); border-radius: 10px; padding: 0.02rem 0.45rem;
}
.mt-assist-items { display: flex; flex-direction: column; gap: 0.25rem; }
.mt-assist-item { border: 1px solid var(--border); border-radius: 4px; background: var(--bg-elev); }
.mt-assist-item > summary {
  list-style: none; cursor: pointer; padding: 0.4rem 0.6rem;
  display: flex; align-items: center; gap: 0.45rem; flex-wrap: wrap;
}
.mt-assist-item > summary::-webkit-details-marker { display: none; }
.mt-assist-item[open] > summary { border-bottom: 1px solid var(--border); }
.mt-assist-name { font-weight: 600; font-size: 0.88rem; }
.mt-assist-cost {
  font-family: var(--font-heading); font-size: 0.72rem; color: var(--bg-deep);
  background: var(--gold); border-radius: 3px; padding: 0.05rem 0.4rem; white-space: nowrap;
}
.mt-assist-cost.is-unaffordable { background: var(--bg-elev-2); color: var(--text-secondary); border: 1px solid var(--border); }
.mt-assist-unit { font-size: 0.72rem; color: var(--gold); }
.mt-assist-timing { font-size: 0.7rem; color: var(--text-secondary); margin-left: auto; }
.mt-assist-text { margin: 0; padding: 0.5rem 0.6rem; font-size: 0.83rem; line-height: 1.45; color: var(--text-secondary); }
.mt-assist-empty, .mt-assist-passive { font-size: 0.82rem; color: var(--text-secondary); margin: 0.6rem 0 0; }
.mt-assist-passive { opacity: 0.75; font-style: italic; }
@media (max-width: 640px) {
  .mt-assist-timing { margin-left: 0; width: 100%; }
}

/* --- Action Bar (Companion / active match sticky controls) --- */
.mt-action-bar {
  position: sticky; bottom: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center; gap: 0.6rem;
  flex-wrap: wrap; margin-top: 1.5rem; padding: 0.75rem 1rem;
  background: var(--bg-elev); border-top: 2px solid var(--border-gold);
  border-radius: 4px 4px 0 0;
}
.mt-action-bar form { margin: 0; }
.mt-action-round {
  font-family: var(--font-heading); font-size: 0.9rem;
  letter-spacing: 0.06em; color: var(--gold);
}
@media (max-width: 640px) {
  .mt-action-bar { gap: 0.4rem; padding: 0.6rem; }
  .mt-action-bar .btn-sm { flex: 1; min-width: 0; }
}

/* ── Per-unit battle tracking rows (Fase 3) ───────────────── */
.mt-cas-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.5rem; padding: 0.35rem 0; border-bottom: 1px solid var(--border-gold);
}
.mt-cas-row.is-below-half { background: rgba(214, 158, 46, 0.08); }
.mt-cas-row.is-removed { opacity: 0.7; }
.mt-cas-main { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.mt-cas-name { font-size: 0.85rem; }
.mt-cas-dim { opacity: 0.55; font-size: 0.75rem; }
.mt-cas-meta { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.mt-cas-stat {
  font-size: 0.7rem; font-family: var(--font-heading);
  letter-spacing: 0.04em; color: var(--text-secondary);
}
.mt-cas-tag {
  font-size: 0.65rem; padding: 0.05rem 0.4rem; border-radius: 3px;
  letter-spacing: 0.04em; white-space: nowrap;
}
.mt-cas-tag--dead { background: var(--bg-elev-2); color: var(--text-secondary); }
.mt-cas-tag--shock {
  background: rgba(214, 158, 46, 0.18); color: var(--gold);
  border: 1px solid var(--border-gold);
}
.mt-cas-actions { display: flex; align-items: center; gap: 0.25rem; flex-wrap: wrap; }
.mt-cas-actions form { margin: 0; }
.mt-cas-btn {
  min-width: 40px; height: 38px; padding: 0 0.4rem;
  font-size: 0.78rem; font-family: var(--font-heading);
  background: var(--bg-elev); color: var(--fg); cursor: pointer;
  border: 1px solid var(--border-gold); border-radius: 3px;
}
.mt-cas-btn:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.mt-cas-btn-wide { padding: 0.1rem 0.5rem; font-size: 0.72rem; }
@media (max-width: 640px) {
  .mt-cas-row { flex-wrap: wrap; }
  .mt-cas-btn { min-width: 42px; height: 40px; }
}

/* ── Companion mode chooser (online vs local) ───────────────────── */
.wg-mode-chooser {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin-bottom: 1.25rem;
}
@media (max-width: 480px) { .wg-mode-chooser { grid-template-columns: 1fr; } }
.wg-mode-opt {
  display: flex; flex-direction: column; gap: 0.2rem; text-align: left;
  padding: 0.85rem 0.95rem; cursor: pointer;
  background: var(--bg-parchment-card); border: 1px solid var(--border-gold);
  border-radius: 5px; font-family: var(--font-body); color: var(--fg);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.wg-mode-opt:hover { border-color: var(--gold); }
.wg-mode-opt.is-active {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px var(--gold), inset 0 1px 0 rgba(255,255,255,0.05);
  background: var(--bg-parchment-hover, var(--bg-parchment-card));
}
.wg-mode-ico { font-size: 1.4rem; line-height: 1; }
.wg-mode-name { font-weight: 600; font-size: 0.98rem; }
.wg-mode-sub { font-size: 0.8rem; color: var(--fg-muted); }
.wg-mode-pane[hidden] { display: none; }

/* Deploy phase panel */
.mt-deploy-panel .mt-init-opt { font-size: 0.95rem; cursor: pointer; }

/* U1 — initiative fieldset no deploy */
.mt-initiative {
  border: 1px solid var(--border-gold);
  border-radius: 4px;
  padding: 0.6rem 0.9rem;
  margin: 0 0 1rem;
  background: var(--bg-deep);
}
.mt-initiative legend {
  font-family: var(--font-heading);
  font-size: 0.7rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--gold); padding: 0 0.3rem;
}

/* ── Battle manager: army panel + expandable unit cards ─────────── */
.mt-army-panel {
  background: var(--bg-parchment-card); border: 1px solid var(--border-gold);
  border-radius: 5px; padding: 0.85rem 0.95rem;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04), 0 2px 8px rgba(0,0,0,0.25);
}
.mt-army-panel-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 0.5rem; margin-bottom: 0.35rem;
}
.mt-army-pts {
  font-family: var(--font-heading); font-size: 0.72rem; letter-spacing: 0.05em;
  color: var(--gold); white-space: nowrap;
}
.mt-army-name {
  font-family: var(--font-heading); font-size: 1.05rem; color: var(--gold);
  margin-bottom: 0.65rem; padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border-gold);
}
.mt-unit-list { display: flex; flex-direction: column; gap: 0.3rem; }
.mt-unit {
  border: 1px solid transparent; border-radius: 4px;
  transition: border-color 0.12s, background 0.12s;
}
.mt-unit-head {
  display: flex; align-items: center; gap: 0.35rem;
  padding: 0 0.4rem; border-radius: 4px;
}
.mt-unit-head[data-sheet-toggle] { cursor: pointer; }
.mt-unit-head[data-sheet-toggle]:hover { background: rgba(214, 158, 46, 0.06); }
.mt-unit-head .mt-cas-row { flex: 1; min-width: 0; border-bottom: none; }
.mt-unit:not(:last-child) .mt-unit-head .mt-cas-row { border-bottom: 1px solid var(--border-gold); }
.mt-unit.is-open {
  border-color: var(--border-gold); background: rgba(0,0,0,0.12);
}
.mt-unit.is-open .mt-unit-head .mt-cas-row { border-bottom: none; }
.mt-unit-chevron {
  flex: 0 0 auto; font-size: 0.7rem; color: var(--gold); opacity: 0.7;
  transition: transform 0.14s ease; user-select: none;
}
.mt-unit.is-open .mt-unit-chevron { transform: rotate(90deg); opacity: 1; }
.mt-unit--flat .mt-unit-head { padding-left: 1.1rem; }
.mt-unit-sheet { display: none; padding: 0.5rem 0.6rem 0.7rem; }
.mt-unit.is-open .mt-unit-sheet { display: block; animation: mt-sheet-in 0.16s ease-out; }
@keyframes mt-sheet-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}
.mt-unit-sheet .datasheet-statbar { margin-bottom: 0.55rem; }
.mt-unit-sheet .ds-weap-scroll { max-height: none; }
.ds-abilities { margin-top: 0.55rem; }
.ds-sheet-footer {
  margin-top: 0.6rem; display: flex; flex-direction: column; gap: 0.4rem;
}
.ds-kw-row { display: flex; flex-wrap: wrap; gap: 0.25rem; }

/* ============================================================
   PUBLIC LADDER (ranking) — tabs, tier legend, ranked table. v11
   ============================================================ */
.ladder-tabs { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.ladder-tab {
  font-family: var(--font-heading); font-size: 0.85rem;
  letter-spacing: 0.05em; text-transform: uppercase;
  padding: 0.45rem 0.9rem; border: 1px solid var(--border-gold);
  border-radius: 3px; background: var(--bg-elev); color: var(--fg-muted);
  text-decoration: none; transition: background .12s, color .12s, border-color .12s;
}
.ladder-tab:hover { color: var(--fg); border-color: var(--gold); }
.ladder-tab.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }

.ladder-legend {
  display: flex; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 1.25rem;
  padding: 0.75rem 1rem; background: var(--bg-deep);
  border: 1px solid var(--border-gold); border-radius: 4px;
}
.ladder-tier-chip {
  display: inline-flex; align-items: center; gap: 0.35rem;
  font-family: var(--font-heading); font-size: 0.72rem;
  letter-spacing: 0.05em; text-transform: uppercase; color: var(--fg-muted);
}
.ladder-tier-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--tier-color, var(--gold));
  box-shadow: 0 0 0 1px rgba(0,0,0,0.4);
}
.ladder-tier-min { color: var(--fg-faint); font-size: 0.66rem; }

.ladder-table {
  border: 1px solid var(--border-gold); border-radius: 4px; overflow: hidden;
}
.ladder-row {
  display: grid;
  grid-template-columns: 48px 1fr 1.2fr 78px 84px 96px;
  align-items: center; gap: 0.5rem;
  padding: 0.65rem 1rem; border-bottom: 1px solid var(--border-gold);
}
.ladder-row:last-child { border-bottom: 0; }
.ladder-head {
  background: var(--bg-elev-2); font-family: var(--font-heading);
  font-size: 0.66rem; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--fg-faint);
}
.ladder-row:not(.ladder-head) { background: var(--bg-elev); }
.ladder-row:not(.ladder-head):nth-child(even) { background: var(--bg-deep); }
.ladder-row.is-me { background: var(--gold-soft); box-shadow: inset 3px 0 0 var(--accent); }
.ladder-rank { font-family: var(--font-heading); font-size: 1rem; color: var(--fg-muted); text-align: center; }
.ladder-top1 .ladder-rank { color: var(--gold); }
.ladder-top2 .ladder-rank { color: #c7c9c0; }
.ladder-top3 .ladder-rank { color: #c6953f; }
.ladder-name { font-family: var(--font-heading); font-size: 0.95rem; color: var(--fg); letter-spacing: 0.02em; }
.ladder-name em { color: var(--accent-text); font-style: normal; font-size: 0.8rem; }
.ladder-tier-col {
  display: inline-flex; align-items: center; gap: 0.35rem;
  font-family: var(--font-heading); font-size: 0.78rem;
  letter-spacing: 0.04em; text-transform: uppercase; color: var(--fg-muted);
}
.ladder-rating {
  font-family: var(--font-heading); font-size: 1.05rem;
  color: var(--accent-text); text-align: right; font-variant-numeric: tabular-nums;
}
.ladder-record { font-size: 0.85rem; color: var(--fg-muted); text-align: center; font-variant-numeric: tabular-nums; }
.ladder-streak { text-align: center; font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.streak-win { color: #5b8c6f; }
.streak-loss { color: var(--accent-text); }
.streak-none { color: var(--fg-faint); }

@media (max-width: 640px) {
  .ladder-row { grid-template-columns: 32px 1fr 64px 70px; }
  .ladder-tier-col, .ladder-streak { display: none; }
}

/* ============================================================
   WAR ROOM (logged-in home dashboard). v11
   ============================================================ */
.warroom { padding: 2rem 0 3rem; }

.wr-banner {
  display: flex; justify-content: space-between; align-items: center;
  gap: 1.5rem; flex-wrap: wrap;
  background: var(--bg-elev-2); border: 1px solid var(--border-gold);
  border-left: 4px solid var(--accent); border-radius: 4px;
  padding: 1.5rem 1.75rem; margin-bottom: 1.25rem;
}
.wr-welcome {
  font-family: var(--font-heading); font-size: 1.9rem;
  letter-spacing: 0.03em; text-transform: uppercase; color: var(--fg);
  margin: 0.1rem 0;
}
.wr-sub { color: var(--fg-muted); font-size: 0.92rem; margin: 0; }
.wr-banner-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }

.wr-stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem;
  margin-bottom: 1.5rem;
}
.wr-stat {
  background: var(--bg-elev); border: 1px solid var(--border-gold);
  border-radius: 4px; padding: 1rem; text-align: center;
}
.wr-stat-num {
  display: block; font-family: var(--font-heading); font-size: 2.1rem;
  line-height: 1; color: var(--accent-text); font-variant-numeric: tabular-nums;
}
.wr-stat-unit { font-size: 1.1rem; color: var(--fg-faint); }
.wr-stat-label {
  display: block; margin-top: 0.35rem; font-size: 0.68rem;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--fg-faint);
}

.wr-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem; align-items: start;
}
.wr-card {
  background: var(--bg-elev); border: 1px solid var(--border-gold);
  border-radius: 4px; padding: 1.25rem;
}
.wr-card-match { border-left: 3px solid var(--accent); }
.wr-card-head {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 0.5rem; margin-bottom: 0.9rem;
  border-bottom: 1px solid var(--border-gold); padding-bottom: 0.5rem;
}
.wr-card-title {
  font-family: var(--font-heading); font-size: 0.82rem;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--gold);
}
.wr-card-link { font-size: 0.75rem; color: var(--fg-muted); text-decoration: none; }
.wr-card-link:hover { color: var(--accent-text); }

.wr-match-vs {
  font-family: var(--font-heading); font-size: 1.2rem; color: var(--fg);
  margin: 0 0 0.5rem; letter-spacing: 0.02em;
}
.wr-match-vs span { color: var(--fg-faint); font-size: 0.85rem; margin: 0 0.3rem; }
.wr-match-meta { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 0.9rem; }

.wr-standing-row { display: flex; gap: 1rem; align-items: center; }
.wr-rank-badge {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; width: 72px; height: 72px; flex-shrink: 0;
  border: 2px solid var(--tier-color, var(--gold)); border-radius: 50%;
  background: var(--bg-deep);
}
.wr-rank-num { font-family: var(--font-heading); font-size: 1.4rem; color: var(--fg); line-height: 1; }
.wr-rank-of { font-size: 0.62rem; color: var(--fg-faint); }
.wr-standing-info { display: flex; flex-direction: column; gap: 0.15rem; }
.wr-tier-name {
  font-family: var(--font-heading); font-size: 1.05rem;
  letter-spacing: 0.05em; text-transform: uppercase;
}
.wr-standing-sub { font-size: 0.8rem; color: var(--fg-muted); }

.wr-army-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.7rem; }
.wr-army { display: grid; grid-template-columns: 1fr 90px auto; align-items: center; gap: 0.6rem; }
.wr-army-link { display: flex; flex-direction: column; text-decoration: none; min-width: 0; }
.wr-army-name { font-family: var(--font-heading); font-size: 0.92rem; color: var(--fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wr-army-faction { font-size: 0.72rem; color: var(--fg-faint); }
.wr-army-fill { height: 6px; background: var(--bg-deep); border: 1px solid var(--border-gold); border-radius: 3px; overflow: hidden; }
.wr-army-fill-bar { height: 100%; background: var(--accent); }
.wr-army-pts { font-family: var(--font-heading); font-size: 0.78rem; color: var(--fg-muted); font-variant-numeric: tabular-nums; text-align: right; }

.wr-empty { color: var(--fg-muted); font-size: 0.88rem; margin: 0 0 0.75rem; }

@media (max-width: 640px) {
  .wr-stats { grid-template-columns: repeat(2, 1fr); }
  .wr-banner { flex-direction: column; align-items: flex-start; }
  .wr-welcome { font-size: 1.5rem; }
}


/* ====== APPENDED FEATURE PARTIALS (community/ranking/profile/paint) v12 ====== */
/* ============================================================
   COMMUNITY — A Mesa de Pintura
   Partial: concatenate into app.css via build step.
   All selectors prefixed with .community- or .cc- to avoid collisions.
   Mobile-first, grimdark token-only.
   ============================================================ */

/* ── Section wrapper ── */
.community-section {
  padding: var(--space-6) 0 var(--space-8);
}

/* ── Header ── */
.community-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}
.community-header-left {
  flex: 1 1 0;
  min-width: 0;
}
.community-header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}
.community-login-hint {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  letter-spacing: 0.06em;
  color: var(--fg-muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.community-login-hint:hover {
  color: var(--accent-text);
}

/* ── Filters ── */
.community-filters {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
}
.community-filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.community-tab {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--fg-muted);
  background: transparent;
  text-decoration: none;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  white-space: nowrap;
}
.community-tab:hover {
  color: var(--fg);
  border-color: var(--border-strong);
}
.community-tab--active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-text);
}
.community-tab--chip {
  font-size: 0.72rem;
  padding: 2px var(--space-2);
}

/* ── Grid ── */
.community-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-5);
}

/* ── Card ── */
.community-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.community-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

/* ── Card image ── */
.cc-img-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--bg-deep);
  flex-shrink: 0;
}
.cc-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ── Badges (over image) ── */
.cc-badge-row {
  position: absolute;
  top: var(--space-2);
  left: var(--space-2);
  display: flex;
  gap: var(--space-1);
  flex-wrap: wrap;
}
.cc-badge {
  font-family: var(--font-display);
  font-size: 0.68rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  padding: 2px var(--space-2);
  border-radius: var(--r-sm);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  line-height: 1.4;
}
.cc-badge--showcase {
  background: var(--accent-soft);
  color: var(--accent-text);
  border: 1px solid var(--accent);
}
.cc-badge--wip {
  background: rgba(160,104,32,0.18);
  color: var(--warn-text);
  border: 1px solid rgba(160,104,32,0.45);
}
.cc-badge--golden {
  background: var(--gold-soft);
  color: var(--gold);
  border: 1px solid var(--border-gold);
}
.cc-badge-icon {
  width: 12px;
  height: 12px;
  vertical-align: middle;
  flex-shrink: 0;
}

/* ── Card body ── */
.cc-body {
  padding: var(--space-3) var(--space-4) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  flex: 1;
}

/* ── Author row ── */
.cc-author {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.cc-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-elev-2);
  border: 1px solid var(--border-gold);
  color: var(--gold);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: 0;
}
.cc-avatar--sm {
  width: 24px;
  height: 24px;
  font-size: 0.7rem;
}
.cc-author-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.cc-author-name {
  font-size: var(--text-sm);
  color: var(--fg);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cc-author-meta {
  font-size: var(--text-xs);
  color: var(--fg-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Title ── */
.cc-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--fg);
  margin: 0;
  line-height: 1.25;
}

/* ── Caption ── */
.cc-caption {
  font-size: var(--text-sm);
  color: var(--fg-muted);
  line-height: 1.5;
  margin: 0;
}

/* ── Tags ── */
.cc-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}
.cc-tag {
  font-size: 0.7rem;
}
.cc-tag--system {
  background: var(--gold-soft);
  color: var(--gold);
  border-color: var(--border-gold);
}

/* ── Footer (likes + comments) ── */
.cc-footer {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: auto;
  padding-top: var(--space-2);
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

/* ── Like button ── */
.cc-like-form {
  display: inline-flex;
  margin: 0;
  padding: 0;
}
.cc-like {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  padding: 4px var(--space-2);
  border-radius: var(--r-sm);
  cursor: pointer;
  color: var(--fg-muted);
  font-size: var(--text-sm);
  font-family: var(--font-body);
  transition: color 0.15s, background 0.15s;
}
.cc-like:hover:not(:disabled) {
  color: var(--accent-text);
  background: var(--accent-soft);
}
.cc-like--liked {
  color: var(--accent-text);
}
.cc-like--liked .cc-like-icon path {
  fill: currentColor;
}
.cc-like:disabled {
  cursor: default;
  opacity: 0.55;
}
.cc-like-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.cc-like-count {
  font-size: var(--text-xs);
  font-family: var(--font-display);
  letter-spacing: 0.05em;
}

/* ── Comment count ── */
.cc-comment-count {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--fg-muted);
  font-size: var(--text-sm);
}
.cc-foot-icon {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

/* ── Comment toggle btn ── */
.cc-comment-toggle {
  margin-left: auto;
}

/* ── Comments panel ── */
.cc-comments-wrap {
  border-top: 1px solid var(--border);
  padding-top: var(--space-3);
  margin-top: var(--space-2);
}
.community-comments {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.cc-comment-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.cc-comment {
  display: flex;
  gap: var(--space-2);
  align-items: flex-start;
}
.cc-comment-body {
  flex: 1;
  min-width: 0;
}
.cc-comment-author {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--fg);
  display: inline;
  margin-right: var(--space-1);
}
.cc-comment-date {
  font-size: var(--text-xs);
  color: var(--fg-faint);
}
.cc-comment-text {
  font-size: var(--text-sm);
  color: var(--fg-muted);
  margin: 2px 0 0;
  line-height: 1.5;
  word-break: break-word;
}
.cc-no-comments {
  font-size: var(--text-sm);
  color: var(--fg-faint);
  margin: 0;
}
.cc-no-comments a {
  color: var(--accent-text);
}
.cc-comment-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.cc-comment-input {
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  padding: var(--space-2) var(--space-3);
  resize: vertical;
  width: 100%;
  box-sizing: border-box;
  transition: border-color 0.15s;
}
.cc-comment-input:focus {
  outline: none;
  border-color: var(--border-strong);
}

/* ── Empty state ── */
.community-empty {
  text-align: center;
  padding: var(--space-8) var(--space-5);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  border: 1px dashed var(--border);
  border-radius: var(--r-lg);
}
.community-empty-sub {
  color: var(--fg-muted);
  font-size: var(--text-sm);
  max-width: 360px;
  margin: 0;
}

/* ── New post form ── */
.community-new-header {
  margin-bottom: var(--space-5);
}
.community-new-sub {
  color: var(--fg-muted);
  font-size: var(--text-sm);
  margin: var(--space-2) 0 0;
}
.community-new-form {
  max-width: 560px;
}

/* Form field helpers (reusing .card-form pattern) */
.cf-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin-bottom: var(--space-4);
}
.cf-label {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--fg-muted);
}
.cf-required {
  color: var(--accent-text);
}
.cf-input,
.cf-select,
.cf-textarea {
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: var(--text-base);
  padding: var(--space-2) var(--space-3);
  width: 100%;
  box-sizing: border-box;
  transition: border-color 0.15s;
}
.cf-input:focus,
.cf-select:focus,
.cf-textarea:focus {
  outline: none;
  border-color: var(--border-strong);
}
.cf-select {
  appearance: none;
  cursor: pointer;
}
.cf-textarea {
  resize: vertical;
  min-height: 72px;
}
.cf-file-input {
  color: var(--fg-muted);
  font-size: var(--text-sm);
}
.cf-hint {
  font-size: var(--text-xs);
  color: var(--fg-faint);
}
.cf-radio-row {
  display: flex;
  gap: var(--space-4);
  align-items: center;
}
.cf-radio-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--fg);
  cursor: pointer;
}
.cf-actions {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  padding-top: var(--space-2);
  flex-wrap: wrap;
}

/* ── Responsive adjustments ── */
@media (min-width: 640px) {
  .community-filters {
    flex-direction: row;
    align-items: flex-start;
  }
}

@media (max-width: 400px) {
  .community-grid {
    grid-template-columns: 1fr;
  }
  .cc-footer {
    gap: var(--space-2);
  }
  .cc-comment-toggle {
    width: 100%;
    text-align: center;
    margin-left: 0;
  }
}
/* ==========================================================================
   _ranking.css.tmp — Ranking page partial
   All selectors prefixed .rk- to avoid collision with app.css
   Design tokens only — no hardcoded colours except subtle medal accents
   ========================================================================== */

/* ── Banner — "Your Rank" strip ──────────────────────────────────────────── */
.rk-banner {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
  background: var(--gold-soft);
  border: 1px solid var(--border-gold);
  border-left: 4px solid var(--gold);
  border-radius: var(--r-lg);
  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-5);
}

.rk-banner-rank {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--gold);
  line-height: 1;
  white-space: nowrap;
}

.rk-banner-rank small {
  font-size: 0.8rem;
  color: var(--fg-muted);
  font-family: inherit;
  margin-left: 2px;
}

.rk-banner-meta {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  flex: 1 1 120px;
}

.rk-banner-tier {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-display);
  font-size: 0.85rem;
  letter-spacing: 0.04em;
}

.rk-banner-tier-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--tier-color, var(--fg-muted));
  flex-shrink: 0;
}

.rk-banner-record {
  font-size: 0.85rem;
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
}

.rk-banner-streak {
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.rk-banner-streak--up   { color: #4caf50; }
.rk-banner-streak--down { color: var(--accent-text); }
.rk-banner-streak--flat { color: var(--fg-faint); }

/* ── Podium ───────────────────────────────────────────────────────────────── */
.rk-podium {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
  padding: var(--space-5) 0 0;
}

/* Order: 2nd left, 1st center, 3rd right — handled via CSS order */
.rk-plinth--1 { order: 2; }
.rk-plinth--2 { order: 1; }
.rk-plinth--3 { order: 3; }

.rk-plinth {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  flex: 0 1 160px;
  min-width: 0;
}

/* The standing platform */
.rk-plinth-base {
  width: 100%;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-top: 3px solid var(--plinth-accent, var(--border));
  border-radius: var(--r-md) var(--r-md) 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: var(--space-3);
}

.rk-plinth--1 .rk-plinth-base {
  --plinth-accent: var(--gold);
  height: 64px;
}
.rk-plinth--2 .rk-plinth-base {
  --plinth-accent: #b0b3a8;
  height: 44px;
}
.rk-plinth--3 .rk-plinth-base {
  --plinth-accent: #8b6a44;
  height: 32px;
}

.rk-medal {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--medal-color, var(--fg-muted));
}

.rk-plinth--1 .rk-medal { --medal-color: var(--gold); }
.rk-plinth--2 .rk-medal { --medal-color: #b0b3a8; }
.rk-plinth--3 .rk-medal { --medal-color: #8b6a44; }

/* Avatar circle with initials */
.rk-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--bg-elev-2);
  border: 2px solid var(--avatar-border, var(--border));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--fg);
  flex-shrink: 0;
}

.rk-plinth--1 .rk-avatar {
  --avatar-border: var(--gold);
  width: 62px;
  height: 62px;
  font-size: 1.3rem;
  background: var(--gold-soft);
}

.rk-plinth--2 .rk-avatar { --avatar-border: #b0b3a8; }
.rk-plinth--3 .rk-avatar { --avatar-border: #8b6a44; }

.rk-plinth-info {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
  width: 100%;
}

.rk-plinth-name {
  font-family: var(--font-display);
  font-size: 0.9rem;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.03em;
}

.rk-plinth--1 .rk-plinth-name {
  font-size: 1rem;
  color: var(--gold);
}

.rk-plinth-tier {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  font-size: 0.7rem;
  color: var(--fg-muted);
  font-family: var(--font-display);
  letter-spacing: 0.04em;
}

.rk-plinth-tier-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--tier-color, var(--fg-muted));
  flex-shrink: 0;
}

.rk-plinth-rating {
  font-family: var(--font-display);
  font-size: 0.8rem;
  color: var(--fg-faint);
  font-variant-numeric: tabular-nums;
}

/* ── Full Ladder Table ────────────────────────────────────────────────────── */
.rk-table {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  width: 100%;
}

.rk-row {
  display: grid;
  grid-template-columns: 40px 1fr 70px 70px 80px 28px;
  align-items: center;
  gap: 0;
  border-bottom: 1px solid var(--border);
  padding: 0 var(--space-3);
  min-height: 44px;
}

.rk-row:last-child { border-bottom: 0; }

.rk-head {
  background: var(--bg-elev-2);
  min-height: 36px;
  font-family: var(--font-display);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-faint);
}

.rk-row:not(.rk-head) {
  background: var(--bg-elev);
  transition: background 0.15s;
}

.rk-row:not(.rk-head):nth-child(even) {
  background: var(--bg-elev-2);
}

.rk-row:not(.rk-head):hover {
  background: var(--gold-soft);
}

.rk-row.is-me {
  background: var(--gold-soft) !important;
  box-shadow: inset 3px 0 0 var(--accent);
}

/* Rank # cell */
.rk-cell-rank {
  font-family: var(--font-display);
  font-size: 0.95rem;
  color: var(--fg-muted);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.rk-top1 .rk-cell-rank { color: var(--gold); }
.rk-top2 .rk-cell-rank { color: #b0b3a8; }
.rk-top3 .rk-cell-rank { color: #8b6a44; }

/* General (commander + tier) */
.rk-cell-general {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-2) var(--space-3);
  min-width: 0;
}

.rk-general-name {
  font-family: var(--font-display);
  font-size: 0.9rem;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.02em;
}

.rk-general-name em {
  color: var(--accent-text);
  font-style: normal;
  font-size: 0.75rem;
  margin-left: var(--space-1);
}

.rk-tier-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.68rem;
  color: var(--fg-muted);
  font-family: var(--font-display);
  letter-spacing: 0.04em;
}

.rk-tier-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--tier-color, var(--fg-muted));
  flex-shrink: 0;
}

/* Record W-L */
.rk-cell-record {
  font-size: 0.82rem;
  color: var(--fg-muted);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* DIFF */
.rk-cell-diff {
  font-size: 0.82rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.rk-diff--pos { color: #4caf50; }
.rk-diff--neg { color: var(--accent-text); }
.rk-diff--zero { color: var(--fg-faint); }

/* League Pts (Elo) */
.rk-cell-pts {
  font-family: var(--font-display);
  font-size: 0.88rem;
  color: var(--fg);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* Movement arrow */
.rk-cell-move {
  text-align: center;
  font-size: 0.75rem;
}

.rk-move--up   { color: #4caf50; }
.rk-move--down { color: var(--accent-text); }
.rk-move--flat { color: var(--fg-faint); }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 700px) {
  .rk-podium { gap: var(--space-2); }
  .rk-plinth { flex: 0 1 100px; }
  .rk-plinth--1 .rk-avatar { width: 50px; height: 50px; font-size: 1.1rem; }
  .rk-avatar { width: 42px; height: 42px; font-size: 0.95rem; }
}

@media (max-width: 560px) {
  /* Compact table: hide DIFF and LEAGUE PTS labels; collapse to 3-col grid */
  .rk-row {
    grid-template-columns: 32px 1fr 62px 22px;
  }
  .rk-cell-diff,
  .rk-head .rk-cell-diff,
  .rk-head .rk-cell-pts,
  .rk-head .rk-cell-move { display: none; }

  /* Show pts inline with record using data-label technique */
  .rk-cell-pts {
    display: none;
  }

  .rk-general-name::after {
    /* pts shown via data attr on the row — we skip data approach, just hide pts column */
    content: '';
  }

  .rk-cell-record {
    /* Show record + pts stacked as small text when pts hidden */
    display: flex;
    flex-direction: column;
    font-size: 0.75rem;
    align-items: center;
  }

  .rk-banner {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
  }
}
/* ==========================================================================
   _profile.css.tmp — Profile page partial
   Selectors prefixed .pf- to avoid collision with app.css
   Design tokens only — no hardcoded colours
   Mobile-first, theme-aware (dark default + light via [data-theme="light"])
   ========================================================================== */

/* ── Page wrapper ─────────────────────────────────────────────────────────── */
.pf-page {
  min-height: 60vh;
}

/* ── Banner ───────────────────────────────────────────────────────────────── */
.pf-banner {
  position: relative;
  height: 120px;
  background: var(--hazard-stripe);
  overflow: hidden;
}

.pf-banner-inner {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    var(--bg-elev) 0%,
    var(--bg-deep) 60%,
    var(--accent-soft) 100%
  );
  opacity: 0.85;
}

.pf-banner-inner--img {
  background-size: cover;
  background-position: center;
  opacity: 1;
}

@media (min-width: 600px) {
  .pf-banner { height: 160px; }
}

@media (min-width: 900px) {
  .pf-banner { height: 200px; }
}

/* ── Container that sits below/overlaps the banner ───────────────────────── */
.pf-container {
  position: relative;
  padding-top: 0;
}

/* ── Avatar circle ────────────────────────────────────────────────────────── */
.pf-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--bg-elev-2);
  border: 3px solid var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent-text);
  margin-top: -36px;
  flex-shrink: 0;
  box-shadow: var(--shadow-md);
  position: relative;
  z-index: 1;
}

@media (min-width: 600px) {
  .pf-avatar {
    width: 88px;
    height: 88px;
    font-size: 1.8rem;
    margin-top: -44px;
  }
}

/* ── Avatar image (when user has uploaded one) ────────────────────────────── */
.pf-avatar-img {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
  display: block;
}

/* ── Edit form: file inputs and upload previews ───────────────────────────── */
.pf-input--file {
  padding: var(--space-2) 0;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--fg);
}

.pf-upload-preview {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
  flex-wrap: wrap;
}

.pf-upload-thumb {
  display: block;
  object-fit: cover;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
}

.pf-upload-thumb--avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
}

.pf-upload-thumb--banner {
  width: 140px;
  height: 36px;
}

.pf-remove-label {
  font-size: var(--text-sm);
  color: var(--fg-muted);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
}

/* ── Identity block ───────────────────────────────────────────────────────── */
.pf-identity {
  padding: var(--space-3) 0 var(--space-5);
}

.pf-identity-top {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.pf-name {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--fg);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  margin: 0;
  line-height: 1.1;
}

@media (min-width: 600px) {
  .pf-name { font-size: var(--text-3xl); }
}

/* Tier badge */
.pf-tier-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  background: var(--bg-elev-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  padding: 2px var(--space-2);
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--tier-color, var(--fg-muted));
  white-space: nowrap;
  flex-shrink: 0;
}

.pf-tier-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--tier-color, var(--fg-muted));
  flex-shrink: 0;
}

/* Meta line */
.pf-meta {
  font-size: var(--text-sm);
  color: var(--fg-muted);
  margin: 0 0 var(--space-2);
  line-height: 1.5;
}

/* Bio */
.pf-bio {
  font-size: var(--text-sm);
  color: var(--fg);
  line-height: 1.65;
  max-width: 640px;
  margin: var(--space-2) 0 var(--space-3);
}

.pf-edit-btn {
  margin-top: var(--space-2);
}

/* ── Stats strip ──────────────────────────────────────────────────────────── */
.pf-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  margin-bottom: var(--space-5);
}

@media (min-width: 600px) {
  .pf-stats { grid-template-columns: repeat(6, 1fr); }
}

.pf-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  padding: var(--space-3) var(--space-2);
  background: var(--bg-elev);
  text-align: center;
}

.pf-stat-num {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--fg);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.pf-stat-num--muted {
  color: var(--fg-faint);
}

.pf-stat-unit {
  font-size: 0.7em;
  color: var(--fg-muted);
  margin-left: 1px;
}

.pf-stat-label {
  font-family: var(--font-display);
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-faint);
}

/* Streak colours (match home.html naming) */
.streak-win  { color: #4caf50; }
.streak-loss { color: var(--accent-text); }

/* ── Tabs ─────────────────────────────────────────────────────────────────── */
.pf-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: var(--space-5);
  overflow-x: auto;
  scrollbar-width: none;
}

.pf-tabs::-webkit-scrollbar { display: none; }

.pf-tab {
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--fg-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
  margin-bottom: -2px;
}

.pf-tab:hover {
  color: var(--fg);
}

.pf-tab.is-active {
  color: var(--accent-text);
  border-bottom-color: var(--accent-text);
}

/* ── Panels (hidden by default) ───────────────────────────────────────────── */
.pf-panel {
  display: none;
}

.pf-panel.is-active {
  display: block;
}

/* ── Collection grid ──────────────────────────────────────────────────────── */
.pf-collection-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
}

@media (min-width: 480px) {
  .pf-collection-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 800px) {
  .pf-collection-grid { grid-template-columns: repeat(3, 1fr); }
}

/* Army card */
.pf-army-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--space-4);
  transition: border-color 0.15s, background 0.15s;
  text-decoration: none;
  color: inherit;
}

a.pf-army-card:hover {
  border-color: var(--border-strong);
  background: var(--bg-elev-2);
}

.pf-army-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.pf-army-name {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--fg);
  letter-spacing: 0.02em;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Paint bar */
.pf-paintbar {
  height: 6px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  overflow: hidden;
}

.pf-paintbar-fill {
  height: 100%;
  background: var(--gold);
  border-radius: var(--r-sm);
  transition: width 0.4s ease;
  min-width: 2px;
}

.pf-army-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-2);
}

.pf-army-pts {
  font-size: var(--text-xs);
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
}

.pf-paint-label {
  font-size: var(--text-xs);
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

/* ── Honours grid ─────────────────────────────────────────────────────────── */
.pf-honours-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}

@media (min-width: 480px) {
  .pf-honours-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 800px) {
  .pf-honours-grid { grid-template-columns: repeat(3, 1fr); }
}

.pf-honour {
  background: var(--bg-elev);
  border: 1px solid var(--border-gold);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.pf-honour-img-wrap {
  width: 100%;
  aspect-ratio: 4/3;
  background: var(--bg-elev-2);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pf-honour-img-wrap--empty {
  font-size: 2rem;
  color: var(--gold);
}

.pf-honour-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.pf-honour-body {
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.pf-honour-badge {
  font-family: var(--font-display);
  font-size: 0.65rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--gold);
}

.pf-honour-title {
  font-size: var(--text-sm);
  color: var(--fg);
  font-weight: 500;
  line-height: 1.4;
  margin: 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.pf-honour-date {
  font-size: var(--text-xs);
  color: var(--fg-faint);
}

/* ── Match history ────────────────────────────────────────────────────────── */
.pf-history {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.pf-history-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  background: var(--bg-elev);
  padding: var(--space-3) var(--space-4);
  transition: background 0.12s;
}

.pf-history-row:nth-child(even) {
  background: var(--bg-elev-2);
}

.pf-history-row:hover {
  background: var(--gold-soft);
}

.pf-result {
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 700;
  width: 24px;
  height: 24px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: 0;
}

.pf-result--win  { background: rgba(74,157,105,0.18); color: #4a9d69; }
.pf-result--loss { background: var(--accent-soft);    color: var(--accent-text); }
.pf-result--draw { background: var(--bg-elev-2);       color: var(--fg-muted); }

.pf-history-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.pf-history-vs {
  font-size: var(--text-sm);
  color: var(--fg);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pf-history-meta {
  font-size: var(--text-xs);
  color: var(--fg-muted);
}

/* ── Empty states ─────────────────────────────────────────────────────────── */
.pf-empty {
  color: var(--fg-muted);
  font-size: var(--text-sm);
  padding: var(--space-6) 0;
  text-align: center;
}

.pf-empty-link {
  color: var(--accent-text);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ── Edit page ────────────────────────────────────────────────────────────── */
.pf-edit-page {
  padding: var(--space-6) 0;
}

.pf-edit-container {
  max-width: 560px;
}

.pf-edit-header {
  margin-bottom: var(--space-4);
}

.pf-edit-card {
  padding: var(--space-5);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}

.pf-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin-bottom: var(--space-4);
}

.pf-label {
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--fg-muted);
}

.pf-input,
.pf-textarea {
  background: var(--bg-elev-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: var(--text-base);
  padding: var(--space-2) var(--space-3);
  width: 100%;
  box-sizing: border-box;
  transition: border-color 0.15s;
  outline: none;
}

.pf-input:focus,
.pf-textarea:focus {
  border-color: var(--accent-text);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.pf-textarea {
  resize: vertical;
  min-height: 100px;
}

.pf-hint {
  font-size: var(--text-xs);
  color: var(--fg-faint);
}

.pf-edit-actions {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  flex-wrap: wrap;
  padding-top: var(--space-2);
}
/* ============================================================
   PAINT TRACKING — toggle button, painted badges, paint bars
   ============================================================ */
.paint-form { display: inline-flex; margin: 0; }
.paint-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; padding: 0;
  font-size: 0.95rem; line-height: 1;
  background: var(--bg-elev-2);
  color: var(--fg-faint);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  cursor: pointer;
  filter: grayscale(1) opacity(0.55);
  transition: filter .12s ease, border-color .12s ease, background .12s ease;
}
.paint-btn:hover { border-color: var(--border-strong); filter: grayscale(0.4) opacity(0.9); }
.paint-btn--active {
  filter: none;
  background: var(--gold-soft);
  border-color: var(--border-gold);
}
.painted-tag {
  display: inline-flex; align-items: center; gap: 2px;
  font-family: var(--font-display);
  font-size: 0.62rem; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase;
  padding: 1px 6px;
  color: var(--gold-deep, var(--gold));
  background: var(--gold-soft);
  border: 1px solid var(--border-gold);
  border-radius: var(--r-sm);
}
.au-row--painted { box-shadow: inset 2px 0 0 var(--gold); }

/* ── OWNERSHIP 1-BUTTON CYCLING (Tenho → Quero → Neutro → Tenho) ── */
.ownership-form { display: inline-flex; margin: 0; }
.owned-btn.au-card-icon-btn,
.owned-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; min-width: 22px; padding: 0;
  font-size: 0.75rem; font-weight: 800; line-height: 1;
  border-radius: 50%;
  cursor: pointer;
  transition: all .15s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,.35);
}
.owned-btn:hover { filter: brightness(1.15); transform: scale(1.05); }
.owned-btn:active { transform: scale(.92); }
/* TENHO → verde */
.owned-btn--owned.au-card-icon-btn,
.owned-btn--owned {
  background: rgba(76, 175, 80, .28);
  border: 1.5px solid #4caf50;
  color: #6fdc73;
}
/* QUERO → azul */
.owned-btn--wanted.au-card-icon-btn,
.owned-btn--wanted {
  background: rgba(33, 150, 243, .25);
  border: 1.5px solid #2196f3;
  color: #79c5ff;
}
/* NEUTRO → cinza */
.owned-btn--neutral.au-card-icon-btn,
.owned-btn--neutral {
  background: rgba(150, 150, 150, .12);
  border: 1.5px solid var(--border-strong, #888);
  color: #b0b0b0;
}
.owned-btn.htmx-request { opacity: .4; cursor: progress; }

.unowned-tag--neutral {
  background: rgba(150,150,150,.18);
  color: #b0b0b0;
}

/* ── UNOWNED ROW / CARD ── */
.au-row--unowned { opacity: .75; }
.au-row--unowned .au-row-name {
  text-decoration: line-through;
  text-decoration-color: rgba(255, 152, 0, .5);
}
.au-card--unowned { opacity: .72; }
.au-card--unowned .au-card-name {
  text-decoration: line-through;
  text-decoration-color: rgba(255, 152, 0, .55);
}
.unowned-tag {
  display: inline-flex; align-items: center;
  font-family: var(--font-display);
  font-size: 0.62rem; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase;
  padding: 1px 6px;
  color: #ff9800;
  background: rgba(255, 152, 0, .12);
  border: 1px solid rgba(255, 152, 0, .4);
  border-radius: var(--r-sm);
}
.enhanced-tag {
  display: inline-flex; align-items: center;
  font-size: 0.7rem;
  color: var(--gold);
  opacity: .8;
}

/* ── ENHANCEMENT — botão no card que abre o modal ── */
.au-enh-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px;
  font-size: 0.72rem; font-weight: 600; letter-spacing: .03em;
  color: var(--fg-faint);
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: all .12s ease;
}
.au-enh-btn:hover { border-color: var(--border-strong); color: var(--gold); }
.au-enh-btn--active {
  background: var(--gold-soft, rgba(200, 160, 50, .12));
  border-color: var(--border-gold, rgba(200, 160, 50, .5));
  color: var(--gold);
}

/* ── ENHANCEMENT MODAL (escolha detalhada e explicativa) ── */
.enh-modal-box {
  max-width: 600px; width: 100%;
  max-height: 86vh; overflow-y: auto;
}
.enh-modal-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1rem; margin-bottom: 1rem;
}
.enh-modal-sub {
  margin: .15rem 0 0; font-size: .9rem; color: var(--gold);
  font-family: var(--font-display); letter-spacing: .02em;
}
.enh-modal-close {
  background: none; border: none; color: var(--fg-faint);
  font-size: 1.1rem; cursor: pointer; line-height: 1; padding: 4px;
  border-radius: var(--r-sm); transition: color .12s;
}
.enh-modal-close:hover { color: var(--fg); }
.enh-modal-empty { color: var(--fg-muted); font-style: italic; }

.enh-group { margin-bottom: 1.25rem; }
.enh-group:last-of-type { margin-bottom: 0; }
.enh-group-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: .5rem; border-bottom: 1px solid var(--border); padding-bottom: .3rem;
}
.enh-group-label {
  font-family: var(--font-display); font-size: .95rem; font-weight: 700;
  letter-spacing: .03em; color: var(--gold);
}
.enh-group-current { font-size: .72rem; color: var(--fg-faint); }
.enh-group-hint { font-size: .76rem; color: var(--fg-faint); margin: .35rem 0 .6rem; }

.enh-options { display: flex; flex-direction: column; gap: .5rem; }
.enh-options form { margin: 0; }
.enh-option {
  display: flex; flex-direction: column; gap: .3rem;
  width: 100%; text-align: left;
  padding: .6rem .75rem;
  background: var(--bg-elev-2);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md, 8px);
  cursor: pointer;
  transition: border-color .12s, background .12s, transform .06s;
}
.enh-option:hover { border-color: var(--gold); background: var(--bg-elev-3, var(--bg-card)); }
.enh-option:active { transform: scale(.995); }
.enh-option--active {
  border-color: var(--gold);
  background: var(--gold-soft, rgba(200, 160, 50, .12));
}
.enh-option--none { border-style: dashed; }
.enh-option-top {
  display: flex; align-items: center; gap: .5rem;
}
.enh-option-name {
  font-weight: 700; font-size: .9rem; color: var(--fg);
  flex: 1 1 auto;
}
.enh-option-check { color: var(--gold); font-weight: 800; }
.enh-option-text {
  font-size: .82rem; line-height: 1.4; color: var(--fg-muted);
}
.enh-option-text--missing { font-style: italic; color: var(--fg-faint); }

/* ── Compact enhancement panel on the leader card (opens the modal picker) ── */
.enh-panel {
  margin-top: var(--space-2);
  padding: var(--space-2);
  background: var(--bg-elev-2, var(--bg-elev));
  border: 1px solid var(--border);
  border-left: 3px solid var(--gold);
  border-radius: var(--r-sm);
}
.enh-panel-head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.enh-panel-title {
  font-family: var(--font-display);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gold);
}
.enh-panel-count {
  font-size: 0.66rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--bg-elev);
  color: var(--fg-muted);
  border: 1px solid var(--border);
}
.enh-panel-count.is-filled { color: var(--gold); border-color: var(--border-gold); }
.enh-panel-badge {
  font-size: 0.6rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: var(--r-sm);
  background: var(--bg-elev);
  color: var(--fg-faint);
}
.enh-panel-badge--free { color: var(--success, #3fae63); background: rgba(45,138,78,0.12); }
.enh-panel-btn {
  margin-left: auto;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.3rem 0.7rem;
  border-radius: var(--r-sm);
  background: var(--gold);
  color: #1a1a1a;
  border: none;
  cursor: pointer;
  transition: filter .12s, transform .06s;
}
.enh-panel-btn:hover { filter: brightness(1.1); }
.enh-panel-btn:active { transform: scale(.97); }
.enh-panel-empty {
  margin: var(--space-2) 0 0;
  font-size: 0.74rem;
  color: var(--fg-muted);
  line-height: 1.4;
}
.enh-picks {
  margin-top: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.enh-pick {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  overflow: hidden;
}
.enh-pick[open] { border-color: var(--border-gold); }
.enh-pick-summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 5px 8px;
  font-size: 0.76rem;
}
.enh-pick-summary::-webkit-details-marker { display: none; }
.enh-pick-summary:hover { background: var(--accent-soft); }
.enh-pick-label {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--fg-faint);
  flex: 0 0 auto;
}
.enh-pick-name { font-weight: 700; color: var(--fg); flex: 1 1 auto; }
.enh-pick-chevron { color: var(--gold); font-size: 0.7rem; transition: transform .15s; }
.enh-pick[open] .enh-pick-chevron { transform: rotate(90deg); }
.enh-pick-text {
  padding: 0 8px 8px;
  font-size: 0.74rem;
  line-height: 1.5;
  color: var(--fg-muted);
}
.enh-pick-text p { margin: 0 0 4px; }
.enh-pick-text p:last-child { margin: 0; }
.enh-pick-text strong { color: var(--fg); }

/* ── WISHLIST PANEL ── */
.wishlist-panel {
  margin-top: 1.25rem;
  border: 1px solid rgba(255, 152, 0, .25);
  border-radius: var(--r-md, 8px);
  overflow: hidden;
}
.wishlist-header {
  display: flex; align-items: center; gap: .5rem;
  padding: .45rem .75rem;
  background: rgba(255, 152, 0, .08);
  font-size: .8rem; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase;
  color: #ff9800;
}
.wishlist-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px;
  font-size: .7rem; font-weight: 700;
  background: rgba(255, 152, 0, .25);
  border-radius: 50%;
  padding: 0 4px;
}
.wishlist-list {
  list-style: none; margin: 0; padding: 0;
}
.wishlist-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: .3rem .75rem;
  border-top: 1px solid rgba(255,255,255,.04);
  font-size: .8rem;
}
.wishlist-unit-name { color: var(--text-main, var(--fg)); }

/* war-room army paint bar tweaks */
.wr-army-pts-unit { font-size: 0.7em; color: var(--fg-faint); text-transform: uppercase; letter-spacing: .03em; }

/* ============================================================
   UNIT AUTOCOMPLETE — community "Share a Mini" combobox
   ============================================================ */

/* Wrapper — establishes stacking context for the dropdown */
.unit-ac {
  position: relative;
}

/* The dropdown list */
.unit-ac-list {
  position: absolute;
  top: calc(100% + 3px);
  left: 0;
  right: 0;
  max-height: 280px;
  overflow-y: auto;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-top: 2px solid var(--accent);
  border-radius: 0 0 var(--r-sm) var(--r-sm);
  box-shadow: 0 8px 24px rgba(0,0,0,.45);
  z-index: 50;
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Individual option */
.unit-ac-opt {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  min-height: 44px; /* comfortable tap target on mobile */
  transition: background .08s ease, border-left-color .08s ease;
}
.unit-ac-opt:last-child { border-bottom: none; }
.unit-ac-opt:hover,
.unit-ac-opt.is-highlighted {
  background: var(--accent-soft);
  border-left: 2px solid var(--accent);
  padding-left: 12px; /* compensate for border-left width */
}

/* Option text */
.unit-ac-opt-name {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--fg);
  letter-spacing: .02em;
}
.unit-ac-opt-meta {
  font-size: var(--text-xs, 0.72rem);
  color: var(--fg-muted);
  letter-spacing: .02em;
}

/* Chosen chip — shown after a unit is selected */
.unit-ac-chosen[hidden] { display: none; }
.unit-ac-chosen {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  padding: 4px 10px;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: var(--r-sm);
}
.unit-ac-chosen-name {
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent-text, var(--fg));
  letter-spacing: .03em;
}

/* ✕ trocar button inside chip */
.unit-ac-clear-btn {
  background: none;
  border: none;
  padding: 0 2px;
  font-size: 0.75rem;
  color: var(--fg-muted);
  cursor: pointer;
  line-height: 1;
  transition: color .1s ease;
}
.unit-ac-clear-btn:hover { color: var(--accent-text, var(--accent)); }

/* Card feed — unit title link */
.community-card-title-link {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color .12s ease, border-color .12s ease;
}
.community-card-title-link:hover {
  color: var(--accent-text, var(--accent));
  border-bottom-color: var(--accent);
}

/* Mobile adjustments */
@media (max-width: 480px) {
  .unit-ac-list { max-height: 220px; }
  .unit-ac-opt  { padding: 12px 12px; min-height: 48px; }
}

/* ══════════════════════════════════════════════════════════════
   ── B3 MOBILE RESPONSIVE FIXES ─────────────────────────────
   Appended 2026-06-02. All changes are max-width guards only —
   zero impact on desktop (≥769px).
   ══════════════════════════════════════════════════════════════ */

/* ── 1. Global horizontal-overflow safety net ── */
html, body {
  overflow-x: hidden;
}

/* ── 2. Global media safety: images and video can't overflow their container ──
   SVG excluded intentionally — nav icons rely on fixed svg sizes. */
img, video {
  max-width: 100%;
  height: auto;
}

/* ── 3. Filter bar: remove hard min-widths on small phones ── */
@media (max-width: 640px) {
  .filter-field--system  .form-select,
  .filter-field--faction .form-select { min-width: 0; width: 100%; }
  .filter-field--search  .form-input  { min-width: 0; width: 100%; }
  .filter-field--pts     .form-input  { width: 100%; }
  .filter-bar { padding: var(--space-2) var(--space-3); }
}

/* ── 4. Builder header actions — wrap on mobile ── */
@media (max-width: 768px) {
  .builder-header {
    flex-wrap: wrap;
  }
  .builder-header-actions {
    flex-wrap: wrap;
    flex-shrink: 1;
  }
}

/* ── 5. Army topbar actions — full-width wrap on phone ── */
@media (max-width: 640px) {
  .army-topbar-actions {
    width: 100%;
    justify-content: flex-start;
  }
  /* Reduce topbar heading size on very small screens */
  .army-topbar-name {
    font-size: var(--text-lg);
  }
}

/* ── 6. Roster card actions — wrap buttons and bump touch targets ── */
@media (max-width: 640px) {
  .roster-card-actions {
    flex-wrap: wrap;
    gap: var(--space-2);
  }
  /* .btn-sm touch target on coarse-pointer already handled via (pointer:coarse),
     but max-width ensures it also fires on phone regardless of pointer hint */
  .roster-card-actions .btn-sm,
  .armies-toolbar .btn-secondary,
  .armies-toolbar .btn-primary {
    min-height: 40px;
  }
}

/* ── 7. Section-title size reduction on small phones ── */
@media (max-width: 480px) {
  .section-title {
    font-size: var(--text-xl);
  }
}

/* ── 8. Community grid — force single-column up to 640px ──
   The existing rule only kicks in at 400px; 401–640px showed 2-col on
   narrow phones because minmax(280px,1fr) fits only one column below ~580px,
   but explicitly forcing it ensures consistent single-col behaviour. */
@media (max-width: 640px) {
  .community-grid {
    grid-template-columns: 1fr;
  }
}

/* ── 9. Community header — stack vertically on phone ── */
@media (max-width: 640px) {
  .community-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-3);
  }
  .community-header-actions {
    width: 100%;
  }
  .community-header-actions .btn-primary {
    width: 100%;
    justify-content: center;
  }
}

/* ── 10. Compare table — ensure the scroll wrapper is touch-scrollable ── */
@media (max-width: 768px) {
  .compare-scroll {
    -webkit-overflow-scrolling: touch;
  }
  /* Give the compare-units-grid a clear mobile scroll hint via its container */
  .compare-section-block {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ── 11. Compare units grid — already 1-col at 640px, extend to 768px ── */
@media (max-width: 768px) {
  .compare-units-grid {
    grid-template-columns: 1fr;
  }
}

/* ── 12. Matches lobby — invite/active cards stack on narrow phones ──
   The cards use inline display:flex/justify-content:space-between; we cannot
   change inline styles, but we can override the card-form wrapper behaviour
   inside the matches section on small screens. */
@media (max-width: 560px) {
  /* Target card-form flex rows that sit inside the matches builder section */
  .armies-builder-section .card-form {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: var(--space-3) !important;
  }
  .armies-builder-section .card-form > div:last-child,
  .armies-builder-section .card-form > span:last-child {
    width: 100%;
  }
  .armies-builder-section .card-form > div:last-child {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
  }
}

/* ── 13. Compare bar (floating) — wrap chips on phone ── */
@media (max-width: 640px) {
  .compare-bar-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
  }
  .compare-bar-actions {
    width: 100%;
    justify-content: flex-end;
  }
}

/* ── 14. Podium on very small phones — shrink further ── */
@media (max-width: 400px) {
  .rk-podium {
    gap: var(--space-1);
  }
  .rk-plinth {
    flex: 0 1 80px;
  }
  .rk-plinth-name {
    font-size: 0.75rem;
  }
}

/* ── 15. Profile stats strip — already 3-col on mobile.
   At 360px the 3-col is very tight; reduce internal padding. ── */
@media (max-width: 400px) {
  .pf-stat {
    padding: var(--space-2) var(--space-1);
  }
  .pf-stat-num {
    font-size: var(--text-lg);
  }
}

/* ── 16. Armies toolbar buttons — full-width stack on very small phones ── */
@media (max-width: 480px) {
  .armies-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .armies-toolbar .btn-secondary,
  .armies-toolbar .btn-primary {
    width: 100%;
    justify-content: center;
  }
}

/* ══════════════════════════════════════════════════════════════
   ── EPIC-C feature styles ──
   C2, C3, C5, C7, C8, C9 — all new classes in one block.
   ══════════════════════════════════════════════════════════════ */

/* ────────────────────────────────────────────────────────────
   C5 — .unit-image-frame: ensure position:relative for fav star
   ──────────────────────────────────────────────────────────── */
.unit-image-frame {
  position: relative;
}

/* ────────────────────────────────────────────────────────────
   C7 — Army totals chips
   ──────────────────────────────────────────────────────────── */
.army-totals {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
  padding: var(--space-2) var(--space-3);
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}

.army-total {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  font-size: var(--text-xs);
  color: var(--fg-muted);
  letter-spacing: 0.04em;
}

.army-total b {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 800;
  color: var(--gold);
  line-height: 1;
}

[data-theme="light"] .army-total b { color: var(--gold); }

/* C7 — Models badge (inline, subordinate to pts-badge) */
.models-badge {
  display: inline-flex;
  align-items: baseline;
  gap: 1px;
  padding: 1px 6px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border-gold);
  border-radius: var(--r-sm);
  font-size: 0.65rem;
  color: var(--fg-muted);
  letter-spacing: 0.04em;
  vertical-align: middle;
  white-space: nowrap;
}

.models-badge-lbl {
  font-size: 0.58rem;
  color: var(--fg-faint);
  letter-spacing: 0.05em;
  text-transform: lowercase;
}

/* ────────────────────────────────────────────────────────────
   C8 — Favorite star button
   ──────────────────────────────────────────────────────────── */
.fav-star-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--fg-faint);
  border-radius: var(--r-sm);
  transition: color 0.15s, transform 0.15s;
  padding: 0;
  line-height: 1;
  /* absolute positioning within .unit-image-frame */
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 3;
}

.fav-star-btn svg {
  width: 16px;
  height: 16px;
  display: block;
  pointer-events: none;
}

.fav-star-btn:hover {
  color: var(--gold);
  transform: scale(1.15);
}

/* Owned state — filled gold star */
.fav-star-btn.is-owned {
  color: var(--gold);
}

/* Wanted state — filled crimson star */
.fav-star-btn.is-wanted {
  color: var(--accent);
}

/* Mobile: enlarge touch target */
@media (pointer: coarse) {
  .fav-star-btn {
    width: 40px;
    height: 40px;
    top: 2px;
    right: 2px;
  }
}

/* C8 — Collection popup modal */
.collection-popup-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 9500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.collection-popup {
  background: var(--bg-elev);
  border: 1px solid var(--border-gold);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md), 0 0 0 1px rgba(140,122,82,0.12);
  padding: var(--space-5);
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  animation: popup-appear 0.18s ease;
}

@keyframes popup-appear {
  from { opacity: 0; transform: scale(0.95) translateY(6px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.collection-popup-title {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--fg);
  text-align: center;
  line-height: 1.3;
}

.collection-popup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  justify-content: center;
}

.collection-popup-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--r-sm);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: opacity 0.15s, transform 0.1s;
  min-width: 100px;
  justify-content: center;
}

.collection-popup-btn:hover { opacity: 0.88; transform: translateY(-1px); }
.collection-popup-btn:active { transform: translateY(0); }

/* Owned — gold */
.collection-popup-btn--owned {
  background: var(--gold);
  color: var(--bg-deep);
  border-color: var(--gold-deep);
}

/* Wanted — crimson */
.collection-popup-btn--wanted {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: #8a1515;
}

/* Remove — muted/ghost */
.collection-popup-btn--remove {
  background: transparent;
  color: var(--fg-muted);
  border-color: var(--border-strong);
}
.collection-popup-btn--remove:hover { color: var(--danger-text); border-color: var(--danger); opacity: 1; }

/* Cancel — ghost */
.collection-popup-btn--cancel {
  background: transparent;
  color: var(--fg-faint);
  border-color: var(--border);
  font-size: 0.72rem;
  min-width: auto;
  padding: var(--space-1) var(--space-3);
}
.collection-popup-btn--cancel:hover { color: var(--fg); border-color: var(--border-strong); opacity: 1; }

/* Light theme overrides */
[data-theme="light"] .collection-popup {
  background: var(--bg-elev);
  border-color: var(--border-gold);
}

/* ────────────────────────────────────────────────────────────
   C3 — Keyword pill tooltip hint + tooltip card
   ──────────────────────────────────────────────────────────── */
.keyword-pill--has-tip {
  cursor: help;
  border-bottom: 1px dotted var(--border-gold);
  text-decoration: none;
}

.keyword-pill--has-tip:hover {
  border-bottom-color: var(--gold);
  color: var(--gold);
}

/* .kw-tooltip — positioned by JS, visible via .is-visible */
.kw-tooltip {
  position: absolute; /* JS overrides to fixed */
  z-index: 9999;
  max-width: 280px;
  background: var(--bg-elev-2);
  color: var(--fg);
  border: 1px solid var(--border-gold);
  border-radius: var(--r-md);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  line-height: 1.45;
  box-shadow: var(--shadow-md);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  word-break: break-word;
}

.kw-tooltip.is-visible {
  opacity: 1;
}

[data-theme="light"] .kw-tooltip {
  background: var(--bg-elev);
  border-color: var(--border-gold);
  box-shadow: 0 4px 14px rgba(0,0,0,0.12);
}

/* ── End EPIC-C feature styles ── */

/* ── Subnav segmented control — alterna membros de um grupo de navegação ── */
.subnav-wrap {
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
}
.subnav {
  display: flex;
  gap: 0;
  align-items: stretch;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.subnav::-webkit-scrollbar { display: none; }
.subnav-tab {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 1.15rem;
  font-family: 'Oswald', sans-serif;
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-secondary);
  text-decoration: none;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: color .12s ease, border-color .12s ease, background .12s ease;
}
.subnav-tab:hover {
  color: var(--text-primary);
  background: var(--accent-soft);
}
.subnav-tab--active {
  color: var(--accent-text);
  border-bottom-color: var(--accent);
}
@media (max-width: 640px) {
  .subnav-tab { padding: 0.6rem 0.95rem; font-size: var(--text-xs); }
}

/* ============================================================
   VTT BOARD — Phase A (40K online)
   ============================================================ */
.vtt-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: var(--space-4);
  height: calc(100vh - var(--nav-height) - 16px);
  padding: var(--space-3) var(--space-4);
  box-sizing: border-box;
  overflow: hidden;
}
@media (max-width: 820px) {
  .vtt-layout {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }
}

.vtt-map-col {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
  overflow: hidden;
}

.vtt-map-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

.vtt-map-title {
  flex: 1;
  font-size: var(--text-xs);
  letter-spacing: 0.1em;
  color: var(--fg-muted);
}

.vtt-back-link {
  white-space: nowrap;
}

.vtt-canvas-wrap {
  flex: 1;
  min-height: 0;
  background: #1a1d21;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
}

.vtt-canvas {
  display: block;
  cursor: default;
}

.vtt-rail {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  overflow-y: auto;
  min-width: 0;
}
@media (max-width: 820px) {
  .vtt-rail {
    max-height: none;
    overflow-y: visible;
  }
}

.vtt-ruler-active {
  background: var(--accent) !important;
  color: #fff !important;
  border-color: var(--accent) !important;
}

.vtt-deploy-note {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}

.vtt-cas-section {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--space-3) var(--space-4);
}

/* ============================================================
   GRIMDARK-V22 FIXES
   ============================================================ */

/* IS6 — match lobby cards: link wrapper herda accent-text vermelho.
   Neutralizar com gold para não conflitar com o accent do sistema. */
.armies-builder-section a[href*="/matches/"] > .card-form,
.armies-builder-section a > .card-form {
  color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.armies-builder-section a > .card-form:hover {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px var(--gold);
}
/* Override global a { color: var(--accent-text) } para wrappers de card */
.armies-builder-section a[href*="/matches/"] {
  color: var(--fg);
}
.armies-builder-section a[href*="/matches/"]:hover {
  opacity: 1;
  color: var(--fg);
}

/* IS4/IS5 — timestamp com float:right no event row quebra flex.
   O _event_row.html usa inline style="float:right" — overrido via contexto. */
.mt-battlelog-body > div {
  display: flex !important;
  align-items: baseline;
  flex-wrap: wrap;
  float: none !important;
}
.mt-battlelog-body > div > span:last-child {
  float: none !important;
  margin-left: auto;
}

/* Sistema accent — expõe --system-accent via Jinja (set no show.html).
   Aqui os seletores que passam a usar a var com fallback --gold / --accent. */
.mt-phase-tag {
  color: var(--system-accent, var(--fg));
}
.mt-leading-badge {
  background: var(--system-accent, var(--accent));
}
.mt-sc-vp-num {
  color: var(--system-accent, var(--accent-text));
}
.mt-scorecard.is-leading {
  border-color: var(--system-accent, var(--accent));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--system-accent, var(--accent)) 35%, transparent);
}
.mt-elapsed-clock {
  color: var(--system-accent, var(--accent-text));
}

/* ============================================================
   ARMY BUILDER — inline datasheet expand/collapse (au-ds-*)
   Mirrors the battle-manager .mt-unit / .mt-unit-sheet pattern.
   ============================================================ */
.au-ds-wrap {
  border: 1px solid transparent;
  border-radius: 4px;
  transition: border-color 0.12s, background 0.12s;
  margin-bottom: 0.15rem;
}
.au-ds-wrap.au-ds-open {
  border-color: var(--border-gold);
  background: rgba(0,0,0,0.10);
}
/* Chevron button sits inside .au-card-name — reset button defaults */
.au-ds-chevron {
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: none; padding: 0 0.25rem;
  cursor: pointer;
  font-size: 0.7rem; color: var(--gold); opacity: 0.65;
  transition: transform 0.14s ease, opacity 0.12s;
  user-select: none; vertical-align: middle;
  line-height: 1;
}
.au-ds-chevron:hover { opacity: 1; color: var(--gold); }
.au-ds-wrap.au-ds-open .au-ds-chevron {
  transform: rotate(90deg); opacity: 1;
}
/* Hidden collapsed sheet */
.au-ds-sheet {
  display: none;
  padding: 0.5rem 0.6rem 0.7rem;
  border-top: 1px solid var(--border-gold);
}
.au-ds-wrap.au-ds-open .au-ds-sheet {
  display: block;
  animation: au-sheet-in 0.16s ease-out;
}
@keyframes au-sheet-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}
/* Inherit battle-manager datasheet inner styles */
.au-ds-sheet .datasheet-statbar { margin-bottom: 0.55rem; }
.au-ds-sheet .ds-weap-scroll { max-height: none; }
.au-ds-sheet .ds-abilities { margin-top: 0.55rem; }
.au-ds-sheet .ds-sheet-footer {
  margin-top: 0.6rem; display: flex; flex-direction: column; gap: 0.4rem;
}
.au-ds-sheet .ds-kw-row { display: flex; flex-wrap: wrap; gap: 0.25rem; }


/* ============================================================
   Logged-out landing — refinements (dual CTA, how-it-works, final CTA)
   ============================================================ */
.hero-cta { gap: var(--space-3); flex-wrap: wrap; }
.hero-cta .btn-secondary {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: var(--space-4) var(--space-7);
  border-radius: var(--r-sm);
}
.hero-note {
  margin: var(--space-4) auto 0;
  max-width: 520px;
  text-align: center;
  font-size: var(--text-sm);
  color: var(--fg-muted);
  line-height: 1.6;
}
.hero-note strong { color: var(--fg); }

/* ===== Logged-out (guest) mobile polish ===== */
/* Guests have no bottom tab bar → reclaim the reserved 80px gap. */
body.is-guest main { padding-bottom: 0; }

/* Compact header on phones: brand left, auth group right, no divider. */
@media (max-width: 600px) {
  .site-header nav.container { gap: var(--space-2); }
  .brand { margin-right: auto; }
  .nav-auth { border-left: none; padding-left: 0; margin-left: 0; gap: var(--space-1); }
  .nav-auth-link { padding: var(--space-2); font-size: 0.72rem; letter-spacing: 0.04em; }
  .nav-auth .btn-cta { padding: var(--space-2) var(--space-3); letter-spacing: 0.08em; }
}

/* ============================================================
   /units — mobile/responsive fixes (narrow phones)
   ============================================================ */
@media (max-width: 600px) {
  /* System picker: single column, tighter cards */
  .system-picker-grid { grid-template-columns: 1fr !important; gap: var(--space-3); }
  .system-picker-card { padding: var(--space-4); }

  /* Filter bar: tighten; big fields take the full row, points stay small */
  .filter-bar { padding: var(--space-3); gap: var(--space-2); }
  .filter-field { flex: 1 1 100%; }
  .filter-field--pts { flex: 0 1 auto; }
  .filter-field--system  .form-select,
  .filter-field--faction .form-select,
  .filter-field--archetype .form-select,
  .filter-field--legends .form-select,
  .filter-field--search  .form-input { min-width: 0; width: 100%; }

  /* Faction heading: tighter, allow wrap, drop the decorative archetype badges */
  .units-faction-heading { gap: var(--space-2); padding: var(--space-3); font-size: var(--text-sm); flex-wrap: wrap; }
  .units-faction-heading .archetype-badges { display: none; }
  .units-faction-body { padding: var(--space-3); }

  /* Unit grids: snug columns + full unit names (no nowrap truncation) */
  .unit-grid--bb { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: var(--space-2); }
  .unit-grid--manifestations { grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); }
  .unit-card--bb .unit-card-name { font-size: 0.8rem; white-space: normal; }
}

@media (max-width: 380px) {
  .unit-grid--bb { grid-template-columns: 1fr 1fr; }
}

/* Phase Assistant — spend-CP action button */
.mt-assist-spend-form { margin-top: var(--space-2); }
.mt-assist-spend {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 11px;
  font-family: var(--font-display); font-size: 0.72rem; font-weight: 700;
  letter-spacing: 0.05em; text-transform: uppercase;
  color: #fff; background: var(--accent);
  border: none; border-radius: var(--r-sm); cursor: pointer;
  transition: filter 0.15s, opacity 0.15s;
}
.mt-assist-spend:hover:not(:disabled) { filter: brightness(1.1); }
.mt-assist-spend:disabled { opacity: 0.4; cursor: not-allowed; }
