:root {
  --bg: #10141d;
  --bg-elevated: #151a24;
  --ink: #eceff1;
  --muted: #8b93a0;
  --label: #a48e6c;
  --panel: #1c212b;
  --panel-2: #232936;
  --line: #2c3340;
  --line-soft: #252b36;
  --gold: #e5b045;
  --gold-bright: #f0c14d;
  --maroon: #5c191c;
  --maroon-deep: #3a0f11;
  --danger: #d45b5b;
  --strength: #c75a5a;
  --ok: #81c784;
  --timber: #bcaaa4;
  --shellins: #b19cd9;
  --chip: #2a3140;
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Segoe UI", "Helvetica Neue", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--gold-bright); text-decoration: underline; }

.shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 1rem;
  align-items: center;
  padding: 0.95rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg-elevated) 92%, transparent);
  backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 10;
}
.topbar-left {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.7rem;
  min-width: 0;
  justify-self: start;
}
.topbar-left-main {
  display: flex;
  align-items: center;
  gap: 1.05rem;
  min-width: 0;
}
.topbar-resources {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem 1.4rem;
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.topbar-resources > span {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.topbar-resources svg {
  width: 1.1rem;
  height: 1.1rem;
  flex-shrink: 0;
}
.resource-inline.grain { color: #b7e0bf; }
.resource-inline.grain svg { stroke: #b7e0bf; }
.resource-inline.timber { color: #e4d2c7; }
.resource-inline.timber svg { stroke: #e4d2c7; }
.resource-inline.gold { color: #f0d48a; }
.resource-inline.gold svg { stroke: #f0d48a; }
.brand { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.brand strong { font-size: 1.1rem; letter-spacing: -0.02em; color: #fff; }
.brand span { color: var(--label); font-size: 0.82rem; }
.turn-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  min-width: 4.6rem;
  padding: 0.3rem 0.6rem;
  border: 1px solid color-mix(in srgb, var(--gold) 35%, var(--line));
  border-radius: 10px;
  background: #1a1810;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.turn-chip .label {
  color: var(--label);
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
}
.turn-chip .value {
  color: var(--gold);
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.turn-chip .sublabel {
  color: color-mix(in srgb, var(--label) 80%, var(--muted));
  font-size: 0.58rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  margin-top: 0.05rem;
}
.turn-chip.urgent {
  border-color: color-mix(in srgb, var(--strength) 55%, var(--line));
  background: #1a1012;
}
.turn-chip.urgent .value { color: var(--strength); }
.turn-chip.expired,
.turn-chip.syncing {
  border-color: color-mix(in srgb, var(--ok) 50%, var(--line));
  background: #101a12;
}
.turn-chip.expired .value,
.turn-chip.syncing .value { color: var(--ok); }
.strength-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  min-width: 3.75rem;
  padding: 0.3rem 0.55rem;
  border: 1px solid color-mix(in srgb, var(--strength) 45%, var(--line));
  border-radius: 10px;
  background: #1a1012;
}
.strength-chip .label {
  color: color-mix(in srgb, var(--strength) 75%, var(--muted));
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
}
.strength-chip .value {
  color: var(--strength);
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.1;
}
.xp-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  min-width: 3.75rem;
  padding: 0.3rem 0.55rem;
  border: 1px solid color-mix(in srgb, var(--ok) 45%, var(--line));
  border-radius: 10px;
  background: #101a12;
}
.xp-chip .label {
  color: color-mix(in srgb, var(--ok) 75%, var(--muted));
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
}
.xp-chip .value {
  color: var(--ok);
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.1;
}
.nav {
  display: flex;
  gap: 0.15rem;
  flex-wrap: nowrap;
  justify-content: center;
  justify-self: center;
  align-items: center;
}
.nav a {
  padding: 0.45rem 0.75rem; border-radius: 8px; color: var(--muted);
  text-decoration: none; font-weight: 600; font-size: 0.88rem;
  border-bottom: 2px solid transparent;
  position: relative;
}
.nav a.nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.55rem;
  height: 2.55rem;
  padding: 0;
  flex: 0 0 auto;
}
.nav a.nav-icon svg {
  width: 1.35rem;
  height: 1.35rem;
  stroke: currentColor;
}
.nav a:hover { color: var(--ink); text-decoration: none; background: var(--panel); }
.nav a.active {
  color: var(--gold);
  background: transparent;
  border-bottom-color: var(--gold);
  border-radius: 0;
}
.nav a.nav-icon.active {
  border-radius: 8px 8px 0 0;
}
.nav-link-with-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0;
}
.nav-link-with-badge .nav-badge {
  position: absolute;
  top: -0.2rem;
  right: -0.2rem;
}
.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.05rem;
  height: 1.05rem;
  padding: 0 0.25rem;
  border-radius: 999px;
  background: var(--strength);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 800;
  line-height: 1;
}
.nav-badge[hidden] {
  display: none !important;
}
.nav-badge-label {
  background: var(--label);
  color: #1a1510;
}
.nav-incoming-alert {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  min-width: 2.4rem;
  height: 2.55rem;
  padding: 0 0.5rem !important;
  border-radius: 8px !important;
  border: 1px solid color-mix(in srgb, var(--strength) 55%, var(--line)) !important;
  background: #2a1416 !important;
  color: var(--strength) !important;
  border-bottom: 1px solid color-mix(in srgb, var(--strength) 55%, var(--line)) !important;
}
.nav-incoming-alert[hidden] { display: none !important; }
.nav-incoming-alert.is-active { display: inline-flex; }
.nav-incoming-alert svg {
  width: 1.2rem;
  height: 1.2rem;
  stroke: var(--strength);
}
.nav-incoming-count {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--strength);
}
.nav-incoming-alert:hover {
  background: #3a181b !important;
  color: #f0a0a0 !important;
}
.session {
  text-align: right;
  font-size: 0.82rem;
  color: var(--muted);
  justify-self: end;
}
.session b { color: var(--ink); }

main { width: min(1100px, calc(100% - 2rem)); margin: 1.25rem auto 2.5rem; }
.grid { display: grid; gap: 1rem; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) {
  .topbar {
    gap: 0.55rem;
    padding: 0.55rem 0.75rem;
  }
  .topbar-left {
    gap: 0.4rem;
  }
  .topbar-left-main {
    gap: 0.55rem;
  }
  .brand strong { font-size: 0.95rem; }
  .brand span { font-size: 0.72rem; }
  .topbar-resources {
    gap: 0.45rem 0.75rem;
    font-size: 0.8rem;
  }
  .topbar-resources svg {
    width: 0.95rem;
    height: 0.95rem;
  }
  .turn-chip,
  .strength-chip,
  .xp-chip {
    min-width: 0;
    padding: 0.18rem 0.4rem;
    border-radius: 8px;
  }
  .turn-chip { min-width: 3.6rem; }
  .turn-chip .label,
  .strength-chip .label,
  .xp-chip .label {
    font-size: 0.54rem;
  }
  .turn-chip .value { font-size: 0.88rem; }
  .strength-chip .value,
  .xp-chip .value { font-size: 0.85rem; }
  .turn-chip .sublabel { display: none; }
  .nav { gap: 0.05rem; }
  .nav a.nav-icon {
    width: 2rem;
    height: 2rem;
  }
  .nav a.nav-icon svg {
    width: 1.05rem;
    height: 1.05rem;
  }
  .nav-incoming-alert {
    min-width: 1.9rem;
    height: 2rem;
    padding: 0 0.35rem !important;
  }
  .nav-incoming-alert svg {
    width: 0.95rem;
    height: 0.95rem;
  }
  .nav-incoming-count { font-size: 0.64rem; }
  .nav-badge {
    min-width: 0.9rem;
    height: 0.9rem;
    font-size: 0.55rem;
  }
  .session {
    font-size: 0.72rem;
  }
  .session select {
    max-width: 9.5rem;
    padding: 0.35rem 0.45rem;
    font-size: 0.72rem;
  }
}

@media (max-width: 860px) {
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
  .topbar {
    grid-template-columns: 1fr;
    justify-items: start;
    gap: 0.45rem;
    padding: 0.5rem 0.65rem;
  }
  .nav, .session { justify-self: start; }
  .session { text-align: left; }
  .topbar-left-main {
    flex-wrap: wrap;
    gap: 0.4rem;
  }
  .nav a.nav-icon {
    width: 1.85rem;
    height: 1.85rem;
  }
  .nav a.nav-icon svg {
    width: 0.98rem;
    height: 0.98rem;
  }
  .nav-incoming-alert {
    height: 1.85rem;
  }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
}
.panel h2, .panel h3 { margin: 0 0 0.65rem; letter-spacing: -0.02em; color: #fff; }
.muted { color: var(--muted); }
.row { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }
.space { justify-content: space-between; }

.stat {
  padding: 0.85rem 0.95rem; border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
}
.stat .label {
  color: var(--label);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}
.stat .value {
  font-size: 1.25rem;
  font-weight: 700;
  margin-top: 0.25rem;
  color: var(--gold);
}

.flash {
  margin-bottom: 1rem; padding: 0.75rem 0.9rem; border-radius: 10px;
  border: 1px solid #35503a; background: #1a2a1f; color: var(--ok);
}
.flash.error { background: #2a1718; color: var(--danger); border-color: #5c2a2d; }
.flash.warn { background: #2a2315; color: var(--gold); border-color: #5a4a28; }

table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 0.55rem 0.35rem; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
th {
  color: var(--label);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
}
tr:last-child td { border-bottom: 0; }

.badge {
  display: inline-block; padding: 0.15rem 0.5rem; border-radius: 6px;
  background: #3a3420; color: #f0e2b8; font-size: 0.72rem; font-weight: 700;
}
.badge.locked { background: #2a2f3a; color: var(--muted); }
.badge.ready { background: #243328; color: var(--ok); }
.badge.done { background: #243044; color: #9ec0e6; }
.badge.busy { background: #3a3018; color: var(--gold); }
.badge.danger { background: #3a181b; color: var(--strength); }

.reports-table tr.report-won td:first-child {
  box-shadow: inset 3px 0 0 var(--ok);
}
.reports-table tr.report-lost td:first-child {
  box-shadow: inset 3px 0 0 var(--strength);
}
.reports-table tr.report-draw td:first-child {
  box-shadow: inset 3px 0 0 var(--gold);
}
.report-actions {
  justify-content: flex-end;
  flex-wrap: nowrap;
}
.report-actions .icon-btn {
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 10px;
}
.report-actions .icon-btn svg {
  width: 1.05rem;
  height: 1.05rem;
  stroke: currentColor;
}

button, .btn, select, input {
  font: inherit;
}
input, select {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  background: var(--bg-elevated);
  color: var(--ink);
}
input:focus, select:focus {
  outline: 1px solid color-mix(in srgb, var(--gold) 55%, transparent);
  border-color: color-mix(in srgb, var(--gold) 45%, var(--line));
}
button, .btn {
  border: 0; border-radius: 10px; padding: 0.55rem 0.95rem; cursor: pointer;
  background: linear-gradient(180deg, #6a1f23 0%, var(--maroon-deep) 100%);
  color: #f2c7c7;
  font-weight: 700;
}
button:hover, .btn:hover { filter: brightness(1.08); text-decoration: none; }
button.secondary, .btn.secondary {
  background: transparent;
  color: var(--gold);
  border: 1px solid color-mix(in srgb, var(--gold) 40%, var(--line));
}
button:disabled, .btn:disabled { opacity: 0.45; cursor: not-allowed; filter: none; }
.btn-row { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; }

.race-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: flex-end;
  max-width: 34rem;
}
.race-btn {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  font-weight: 600;
  padding: 0.45rem 0.8rem;
}
.race-btn:hover {
  color: var(--ink);
  border-color: color-mix(in srgb, var(--gold) 35%, var(--line));
  filter: none;
}
.race-btn.is-active {
  background: linear-gradient(180deg, #6a1f23 0%, var(--maroon-deep) 100%);
  color: #f2c7c7;
  border-color: transparent;
  font-weight: 700;
}
.race-btn.is-active:hover { filter: brightness(1.08); }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3.35rem;
  height: 3.35rem;
  padding: 0;
  border-radius: 12px;
}
.icon-btn svg {
  width: 1.35rem;
  height: 1.35rem;
  stroke-width: 2.25;
}
.assign-resource-btns { gap: 1rem; justify-content: center; }
.assign-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 100%;
}
.assign-panel h2 { margin-top: 0; }
.resource-btn.grain {
  background: linear-gradient(180deg, #2f5a38 0%, #1d3a24 100%);
  color: #b7e0bf;
  border: 1px solid color-mix(in srgb, var(--ok) 40%, var(--line));
}
.resource-btn.timber {
  background: linear-gradient(180deg, #6a5246 0%, #3f312a 100%);
  color: #e4d2c7;
  border: 1px solid color-mix(in srgb, var(--timber) 45%, var(--line));
}
.resource-btn.gold {
  background: linear-gradient(180deg, #8a6a24 0%, #4d3a12 100%);
  color: #f0d48a;
  border: 1px solid color-mix(in srgb, var(--gold) 45%, var(--line));
}
.resource-btn.grain svg { stroke: #b7e0bf; }
.resource-btn.timber svg { stroke: #e4d2c7; }
.resource-btn.gold svg { stroke: #f0d48a; }

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: var(--bg); }
.login-card { width: min(420px, 100%); }
.login-card h1 { margin: 0 0 0.25rem; font-size: 1.6rem; letter-spacing: -0.03em; color: #fff; }
.login-card label { display: block; margin: 0.85rem 0 0.35rem; font-weight: 600; font-size: 0.9rem; color: var(--label); }
.login-card input { width: 100%; }
.login-card .actions { margin-top: 1rem; }

.empty { color: var(--muted); padding: 0.6rem 0; font-size: 0.92rem; }
.unit-card, .tech-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.85rem;
  background: var(--panel-2);
}
.unit-card h3, .tech-card h3 { margin: 0 0 0.35rem; font-size: 1rem; color: #fff; }
.cost { font-size: 0.85rem; color: var(--muted); }
.stack { display: grid; gap: 0.75rem; }
.barracks-train-form {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  flex-wrap: nowrap;
}
.barracks-train-form input[type="number"] {
  width: 5.25rem;
  padding: 0.4rem 0.5rem;
}
.barracks-table td {
  vertical-align: middle;
}

.enemy-list { display: grid; gap: 0.55rem; margin-top: 0.85rem; }
.enemy-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  overflow: hidden;
}
.enemy-card.you-card {
  border-color: #3a4a38;
  box-shadow: inset 0 0 0 1px rgba(90, 160, 100, 0.12);
}
.enemy-card.out-of-range {
  opacity: 0.55;
  filter: grayscale(0.45);
  background: #161a22;
}
.enemy-card.out-of-range .enemy-main b {
  color: var(--muted);
}
.enemy-card.you-card {
  border-color: #3a4a38;
  box-shadow: inset 0 0 0 1px rgba(90, 160, 100, 0.12);
}
.enemy-card > summary {
  list-style: none;
  cursor: pointer;
  padding: 0.85rem 0.95rem;
}
.enemy-card > summary::-webkit-details-marker { display: none; }
.enemy-summary {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.75rem;
  align-items: center;
}
.enemy-main { display: flex; flex-wrap: wrap; gap: 0.45rem; align-items: center; }
.enemy-main b { color: #fff; font-size: 1.02rem; }
.enemy-stats { display: flex; flex-wrap: wrap; gap: 0.75rem; font-size: 0.86rem; justify-content: flex-end; color: var(--muted); }
.enemy-stats span:nth-child(1),
.enemy-stats span:nth-child(3) { color: var(--gold); }
.enemy-actions { display: flex; justify-content: flex-end; gap: 0.4rem; align-items: center; }
.inline-form { display: inline; margin: 0; }
.enemy-detail {
  padding: 0.85rem 0.95rem 0.95rem;
  border-top: 1px solid var(--line);
  background: var(--bg-elevated);
}
@media (max-width: 860px) {
  .enemy-summary { grid-template-columns: 1fr; }
  .enemy-stats, .enemy-actions { justify-content: flex-start; }
}

.army-list { display: grid; gap: 0.65rem; margin-top: 0.75rem; }
.army-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
  padding: 0.85rem 0.95rem;
  border-left: 3px solid var(--gold);
}
.army-card.tone-danger { border-left-color: var(--strength); }
.army-card.tone-ok { border-left-color: var(--ok); }
.army-card.tone-gold { border-left-color: var(--gold); }
.army-kicker {
  color: var(--label);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  margin-bottom: 0.2rem;
}
.army-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}
.army-title b { color: #fff; }
.army-eta { text-align: right; }
.army-eta .label {
  color: var(--label);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.army-eta .value { font-size: 1.05rem; font-weight: 700; }
.army-units {
  margin: 0.65rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}
.army-footer {
  margin-top: 0.65rem;
  align-items: center;
}
.army-footer .army-units { margin: 0; flex: 1; }

.docs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.75rem;
}
.unit-doc-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
  padding: 0.85rem;
}
.unit-doc-card h3 { margin: 0; color: #fff; font-size: 1.02rem; }
.docs-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem 0.75rem;
  margin-top: 0.75rem;
}
.docs-stats .label,
.docs-costs .label,
.docs-targets .label {
  display: block;
  color: var(--label);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
}
.docs-stats .value { font-weight: 700; color: var(--ink); }
.docs-costs, .docs-targets {
  margin-top: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
  font-size: 0.88rem;
}

.table-wrap { overflow-x: auto; }
.docs-table { min-width: 920px; }
.docs-table th, .docs-table td {
  white-space: nowrap;
  padding: 0.65rem 0.45rem;
  vertical-align: middle;
}
.docs-table td b { color: #fff; }
.docs-table .badge { margin-right: 0.2rem; }

.race-lens-table tr.is-yours td {
  background: rgba(61, 120, 80, 0.16);
}
.race-lens-detail.is-yours {
  border-color: rgba(90, 170, 120, 0.45);
}
.race-lens-standouts {
  display: grid;
  gap: 0.35rem;
  font-size: 0.9rem;
}
.race-lens-summary {
  min-width: 14rem;
  text-align: right;
}

.roster-history-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  justify-content: flex-end;
}
.roster-history-window {
  min-width: 12rem;
  text-align: center;
  font-size: 0.9rem;
}
.roster-chart-wrap {
  position: relative;
  height: min(62vh, 520px);
  min-height: 320px;
}
.roster-chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}
.roster-swatch-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
}
.roster-swatch {
  display: inline-block;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 999px;
}
#roster-players-table tr.is-yours td {
  background: rgba(61, 120, 80, 0.16);
}
#roster-players-table tr.is-dimmed td {
  opacity: 0.45;
}
.roster-self-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  user-select: none;
}
.roster-metric-toggle {
  display: inline-flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.autobuy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
  gap: 0.75rem;
}
.autobuy-grid input,
.autobuy-grid select {
  width: 100%;
}
.autobuy-form .autobuy-enable {
  user-select: none;
}

/* Resource-ish accents used on home/resources */
.value-gold { color: var(--gold); }
.value-ok { color: var(--ok); }
.value-timber { color: var(--timber); }
.value-shellins { color: var(--shellins); }
.value-strength { color: var(--strength); }

.report-player-strength {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 1.2rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.report-strength-icon {
  width: 1.05rem;
  height: 1.05rem;
  stroke: var(--strength);
  flex-shrink: 0;
}
.report-strength-sent {
  color: var(--label);
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
  opacity: 0.95;
}
.report-strength-remaining {
  color: var(--strength);
}

code {
  color: #d7dee8;
  background: #141820;
  padding: 0.1rem 0.35rem;
  border-radius: 6px;
}

pre {
  margin: 0;
  padding: 1rem;
  overflow: auto;
  max-height: 70vh;
  border-radius: 12px;
  background: #0c1017;
  color: #d7ecda;
  font-size: 0.82rem;
  line-height: 1.45;
  border: 1px solid var(--line);
}

/* Calculator */
.calc-mode {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
  color: var(--ink);
}
.calc-army-panel .race-filters {
  max-width: 100%;
  margin-top: 0.35rem;
}
.calc-result-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.75rem;
  margin-top: 0.5rem;
}
.calc-stat {
  font-size: 1.35rem;
  font-weight: 800;
  color: #fff;
  margin-top: 0.15rem;
}
.calc-accuracy {
  border-color: color-mix(in srgb, var(--ok) 35%, var(--line));
}

/* Defense briefing */
.defense-briefing-main { min-width: 0; flex: 1; }
.defense-status-sentence {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 650;
  color: var(--ink);
  line-height: 1.35;
  max-width: 46rem;
}
.defense-detail-line {
  margin: 0.65rem 0 0;
  font-size: 0.8rem;
}
.defense-goal-form {
  flex: 0 0 auto;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
}
.defense-goal-form input[type="number"] { width: 10rem; }
.defense-progress-block { margin-top: 0.85rem; max-width: 28rem; }
.defense-progress-track {
  height: 0.55rem;
  border-radius: 999px;
  background: #141820;
  border: 1px solid var(--line);
  overflow: hidden;
}
.defense-progress-track.is-inline { height: 0.42rem; }
.defense-progress-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #6a1f23 0%, var(--gold) 100%);
  max-width: 100%;
}
.defense-action-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 0.75rem;
}
.defense-adapt-slot,
.defense-adapt-cards {
  display: contents;
}
.defense-action-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0;
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
}
.defense-action-card.is-adapt {
  border-color: color-mix(in srgb, var(--strength) 40%, var(--line));
}
.defense-action-card.is-pending { opacity: 0.85; }
.defense-action-title {
  font-weight: 750;
  color: #fff;
}
.defense-class-heading {
  margin: 0.85rem 0 0.4rem;
  font-size: 0.95rem;
}
.defense-plan-table.is-complete { opacity: 0.82; }
.defense-complete-details,
.defense-advanced-details {
  margin-top: 0.85rem;
}
.defense-complete-details > summary,
.defense-advanced-details > summary {
  cursor: pointer;
  color: var(--gold);
  font-weight: 650;
  list-style: none;
}
.defense-complete-details > summary::-webkit-details-marker,
.defense-advanced-details > summary::-webkit-details-marker { display: none; }
.defense-advanced-details > summary {
  color: var(--ink);
}
.defense-advanced-summary {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}
.defense-threat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.55rem;
  margin-top: 0.85rem;
}
.defense-threat-card {
  padding: 0.7rem 0.8rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #171c26;
}
.defense-threat-card.is-fail {
  border-color: color-mix(in srgb, var(--strength) 45%, var(--line));
  background: #1a1214;
}
.defense-plan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.65rem 1rem;
  align-items: end;
}
.defense-plan-check {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 600;
  color: var(--ink);
}
.defense-theater-controls .defense-subject-btn.is-active {
  background: linear-gradient(180deg, #6a1f23 0%, var(--maroon-deep) 100%);
  color: #f2c7c7;
  border-color: transparent;
}
.defense-theater-layout {
  display: grid;
  grid-template-columns: minmax(180px, 240px) minmax(0, 1fr);
  gap: 0.85rem;
  margin-top: 0.85rem;
  align-items: start;
}
.defense-threat-list {
  max-height: 22rem;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding-right: 0.15rem;
}
.defense-threat-chip {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  text-align: left;
  background: #171c26;
  border: 1px solid var(--line);
  color: var(--ink);
  font-weight: 600;
  padding: 0.45rem 0.55rem;
}
.defense-threat-chip .ratio { color: var(--muted); font-variant-numeric: tabular-nums; }
.defense-threat-chip.is-fail { border-color: color-mix(in srgb, var(--strength) 40%, var(--line)); }
.defense-threat-chip.is-pass { border-color: color-mix(in srgb, var(--ok) 35%, var(--line)); }
.defense-threat-chip.has-replay .ratio::after {
  content: " ▶";
  color: var(--gold);
  font-size: 0.7em;
}
.defense-theater-stage {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #141820;
  padding: 0.75rem 0.85rem;
  min-height: 16rem;
}
.defense-theater-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
.defense-theater-stacks { display: grid; gap: 0.4rem; }
.defense-theater-stack-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.4rem;
  font-size: 0.82rem;
}
.defense-theater-stack .count { font-variant-numeric: tabular-nums; color: var(--gold); }
.defense-theater-stack .count-input {
  width: 5.5rem;
  min-width: 4.5rem;
  padding: 0.15rem 0.35rem;
  font-variant-numeric: tabular-nums;
  color: var(--gold);
  background: #0c1017;
  border: 1px solid var(--line);
  border-radius: 4px;
  text-align: right;
  font-size: 0.82rem;
}
.defense-theater-stack .count-input:focus {
  outline: none;
  border-color: var(--gold);
}
.defense-theater-stack .count-input:disabled {
  opacity: 0.7;
}
.defense-theater-stack.is-tick .count-input { color: #fff; }
.defense-theater-bar {
  height: 0.35rem;
  border-radius: 999px;
  background: #0c1017;
  overflow: hidden;
  border: 1px solid var(--line);
}
.defense-theater-bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #6a1f23, var(--gold));
}
.defense-theater-stack.is-tick .count { color: #fff; }
.defense-theater-stack.is-dead { opacity: 0.4; }
.defense-theater-log {
  margin: 0.65rem 0 0;
  min-height: 1.2rem;
  font-size: 0.85rem;
}
@media (max-width: 860px) {
  .defense-theater-layout,
  .defense-theater-columns { grid-template-columns: 1fr; }
  .defense-threat-list { max-height: 10rem; }
}
@media (max-width: 860px) {
  .defense-briefing .row.space { align-items: stretch; }
  .defense-goal-form { width: 100%; }
  .defense-goal-form input[type="number"] { width: 100%; }
}
