/* Colour tokens. Dark is the default; [data-theme="light"] (set before first paint by the
   inline script in index.html, from the saved choice or the system setting) swaps them. */
:root {
  --bg: #0B1120;
  --panel: #111827;
  --panel-2: #1E293B;
  --panel-3: #0F172A;
  --border: #334155;
  --text: #F8FAFC;
  --text-dim: #94A3B8;
  --text-faint: #64748B;
  --text-2: #CBD5E1;
  --att: #3B82F6;
  --def: #8B5CF6;
  --green: #10B981;
  --amber: #F59E0B;
  --red: #EF4444;
  --gold: #FFD700;
  --sky: #38BDF8;
  --att-soft: #93C5FD;
  --def-soft: #C4B5FD;
  --soft: rgba(255,255,255,0.05);
  --chip-bg: rgba(255,255,255,0.1);
  --chip-border: rgba(255,255,255,0.2);
  --warn-bg: rgba(255,179,0,0.15);
  --danger-bg: rgba(239,68,68,0.2);
  --drag-bg: rgba(59,130,246,0.08);
  --shadow: rgba(0,0,0,0.5);
  --shadow-sm: rgba(0,0,0,0.15);
  --statline-bg: rgba(20,20,25,0.6);
  --stat-k: #90CAF9;
  --stat-v: #FFFFFF;
  --mean-glow: 0 0 12px currentColor;
  --svg-label: #888888;
  /* attrition funnel: purple round the colour wheel to green, stepping away from the panel
     (dark to light here, light to dark in the light theme) */
  --c0: #7347af; --c1: #6469d3; --c2: #498beb; --c3: #04b2e0; --c4: #0fd3c3; --c5: #76e993;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --c0: #b88dfe; --c1: #7c83f7; --c2: #347ae0; --c3: #027493; --c4: #01655c; --c5: #005423;
  --bg: #F1F5F9;
  --panel: #FFFFFF;
  --panel-2: #F8FAFC;
  --panel-3: #FFFFFF;
  --border: #CBD5E1;
  --text: #0F172A;
  --text-dim: #475569;
  --text-faint: #64748B;
  --text-2: #334155;
  --att: #2563EB;
  --def: #7C3AED;
  --green: #047857;
  --amber: #B45309;
  --red: #DC2626;
  --gold: #D97706;
  --sky: #0369A1;
  --att-soft: #1D4ED8;
  --def-soft: #6D28D9;
  --soft: #F1F5F9;
  --chip-bg: #F1F5F9;
  --chip-border: #CBD5E1;
  --warn-bg: #FEF3C7;
  --danger-bg: #FEE2E2;
  --drag-bg: #EFF6FF;
  --shadow: rgba(15,23,42,0.12);
  --shadow-sm: rgba(15,23,42,0.06);
  --statline-bg: #F1F5F9;
  --stat-k: #1D4ED8;
  --stat-v: #0F172A;
  --mean-glow: none;
  --svg-label: #64748B;
  color-scheme: light;
}
* { box-sizing: border-box; }
/* hidden always hides, whatever display a class sets. */
[hidden] { display: none !important; }
html, body {
  margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
}
body { padding: 14px; padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)); max-width: 1400px; margin: 0 auto; }
select, input, button { font-family: inherit; }

/* ---------- slim header + tabs ---------- */
:root { --top-h: 52px; }
.topbar {
  position: sticky; top: 0; z-index: 20; margin: -14px -14px 16px; padding: 0 14px;
  padding-top: env(safe-area-inset-top, 0px);
  background: var(--panel); border-bottom: 1px solid var(--border);
}
.topbar-in { max-width: 1400px; margin: 0 auto; height: var(--top-h); display: flex; align-items: center; gap: 18px; }
.logo { display: flex; align-items: baseline; gap: 8px; text-decoration: none; color: var(--text); min-width: 0; }
.logo h1 { margin: 0; font-size: 16px; font-weight: 900; letter-spacing: 0.06em; white-space: nowrap; }
.tagline { margin: 0; font-size: 11.5px; font-weight: 600; color: var(--text-faint); white-space: nowrap; }
.tabs { display: flex; gap: 2px; height: 100%; margin-left: auto; }
.tab {
  display: flex; align-items: center; gap: 6px; padding: 0 12px; height: 100%; text-decoration: none;
  color: var(--text-dim); font-weight: 700; font-size: 13.5px; border-bottom: 2px solid transparent; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab[aria-current] { color: var(--text); border-bottom-color: var(--def); }
.tab-i { font-size: 14px; }
.tab-short { display: none; }
.theme-toggle {
  flex: none; width: 34px; height: 34px; border-radius: 50%;
  background: var(--soft); border: 1px solid var(--border); color: var(--text); font-size: 16px;
  line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
/* The matchup pinned under the header (a second row of it) once the answer scrolls away. */
.pinbar {
  display: flex; align-items: center; gap: 10px; width: 100%; max-width: 1400px; margin: 0 auto; padding: 6px 2px 7px;
  background: none; border: none; border-top: 1px solid var(--border); color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.pinbar[hidden] { display: none; }
.pb-txt { min-width: 0; font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pb-txt b { font-size: 18px; font-weight: 900; color: var(--c5); }
.pb-txt small { margin-left: 8px; font-size: 12px; font-weight: 600; color: var(--text-faint); }
.pb-up { margin-left: auto; color: var(--text-faint); font-weight: 800; }
@media (max-width: 760px) { .pb-txt small { display: none; } }
.view { scroll-margin-top: calc(var(--top-h) + 12px + var(--pin-h, 0px)); }
.view + .view { margin-top: 28px; }
@media (max-width: 1100px) { .tagline { display: none; } }
/* Phones: the tabs become a bar along the bottom. */
@media (max-width: 760px) {
  :root { --top-h: 48px; }
  .topbar-in { justify-content: space-between; }
  .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; height: auto; margin: 0;
    display: grid; grid-template-columns: repeat(4, 1fr); background: var(--panel); border-top: 1px solid var(--border);
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 0px));
  }
  .tab { flex-direction: column; gap: 2px; padding: 6px 0; font-size: 11px; border-bottom: none; justify-content: center; }
  .tab-i { font-size: 18px; line-height: 1; }
  .tab[aria-current] { color: var(--att-soft); }
  .tab-long { display: none; }
  .tab-short { display: inline; }
  body { padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }
  .toast { bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }
}
.theme-toggle:hover { border-color: var(--text-dim); }

/* ---------- setup panel ---------- */
/* Weapon picker: one line per weapon, like a datasheet's weapon table. */
.wpick { margin: 0 0 6px; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.wp-head, .wp-row { display: grid; grid-template-columns: 22px minmax(0, 1fr) 40px 34px 34px 30px 32px 44px 50px; align-items: center; gap: 2px; }
.wp-head { font-size: 10px; font-weight: 700; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.04em; padding: 6px 0 3px; border-bottom: 1px solid var(--border); }
.wp-head:not(:first-child) { margin-top: 6px; }
.wp-row { border-bottom: 1px solid var(--border); border-radius: 6px; padding: 1px 0; }
.wp-row.active { background: color-mix(in srgb, var(--att) 10%, transparent); }
.wp-row.spare { opacity: 0.6; }
.wp-row.spare.fire, .wp-row.spare.active { opacity: 1; }
.wp-tick { accent-color: var(--att); width: 15px; height: 15px; margin: 0 0 0 4px; }
.wp-name { font: inherit; font-weight: 700; color: var(--text); background: none; border: none; text-align: left; padding: 7px 4px; cursor: pointer; min-width: 0; overflow-wrap: anywhere; }
.wp-row.active .wp-name { color: var(--att); }
.wp-name small { color: var(--text-faint); font-weight: 600; }
.wp-c { text-align: center; color: var(--text-dim); white-space: nowrap; }
.wp-ev { text-align: right; padding-right: 6px; white-space: nowrap; }
.wp-ev b { color: var(--text); }
.wp-ev small { display: block; font-size: 10px; color: var(--text-faint); }
.wp-head .wp-ev { font-size: 10px; }
@media (max-width: 480px) {
  .wp-head, .wp-row { grid-template-columns: 22px minmax(0, 1fr) 30px 30px 26px 28px 40px 44px; }
  .wp-head > :nth-child(3), .wp-row > :nth-child(3) { display: none; }
}

/* Each side is one card; its stat overrides fold away behind "✎ Edit stats". */
.setup-panel { margin-bottom: 12px; }
.setup-col { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; border-top: 3px solid var(--att); }
#defCol { border-top-color: var(--def); }
.setup-col .statline { border-top: none !important; }
.edit-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 2px 0 6px; }
.wr-summary { font-size: 12px; color: var(--text-dim); font-variant-numeric: tabular-nums; min-width: 0; }
.edit-btn { font-size: 12px; padding: 4px 10px; flex: none; }
.setup-col:not(.editing) .weapon-row { grid-template-columns: 1fr 76px; }
.setup-col:not(.editing) .weapon-row label:not(.keep) { display: none; }

.setup-grid { display: grid; grid-template-columns: 1fr 60px 1fr; gap: 12px; align-items: start; }
@media (max-width: 760px) { .setup-grid { grid-template-columns: 1fr; gap: 8px; } }

.setup-swap { display: flex; align-items: center; justify-content: center; align-self: center; }
#swapBtn {
  background: linear-gradient(135deg, #3B82F6 0%, #8B5CF6 100%); color: #fff; font-weight: 800;
  border: none; border-radius: 8px; padding: 10px 6px; font-size: 10.5px; line-height: 1.3;
  cursor: pointer; width: 100%;
}
#swapBtn:hover { filter: brightness(1.1); }
#swapBtn span { display: block; }
@media (max-width: 760px) { #swapBtn { width: auto; padding: 6px 16px; border-radius: 999px; font-size: 12px; } #swapBtn span { display: inline; } }

.side-label { font-weight: 700; font-size: 14px; margin-bottom: 6px; }
.side-label.att { color: var(--att); }
.side-label.def { color: var(--def); }

select {
  width: 100%; background: var(--panel-3); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 8px; font-size: 13px; margin-bottom: 6px;
}

.statline {
  background: var(--statline-bg); border-radius: 6px; padding: 4px 8px; display: flex;
  justify-content: space-between; gap: 4px; margin-bottom: 8px;
}
.statline .stat { text-align: center; flex: 1; }
.statline .stat .k { font-size: 9px; color: var(--stat-k); display: block; }
.statline .stat .v { font-size: 14px; font-weight: 900; color: var(--stat-v); }

.mini-label { font-size: 10px; color: var(--text-dim); font-weight: 700; margin-top: 8px; margin-bottom: 4px; letter-spacing: 0.3px; }

.weapon-row { display: grid; grid-template-columns: 1.5fr repeat(7, 0.7fr); gap: 4px; align-items: end; }
@media (max-width: 760px) { .weapon-row { grid-template-columns: 1fr 1fr 1fr 1fr; } }
.weapon-row label { display: flex; flex-direction: column; font-size: 10px; color: var(--text-dim); gap: 2px; }
.weapon-row input {
  background: var(--panel-3); color: var(--text); border: 1px solid var(--border); border-radius: 4px;
  padding: 3px 5px; font-size: 12.5px; height: 26px; width: 100%;
}
.weapon-label { display: flex; flex-direction: column; justify-content: flex-end; height: 100%; padding-bottom: 2px; grid-column: span 1; }
.weapon-name { font-size: 12.5px; font-weight: bold; color: var(--att); margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.weapon-name.def-name { color: var(--def); }
.badge-container { display: flex; flex-wrap: wrap; gap: 3px; }
.kw-badge {
  background: var(--chip-bg); color: var(--text-dim); padding: 1px 5px; border-radius: 4px;
  font-size: 8.5px; line-height: 1.3; border: 1px solid var(--chip-border); text-transform: uppercase;
}

/* ---------- main layout ---------- */
.main-layout { display: flex; flex-direction: column; gap: 12px; }
/* Datasheets still loading from BSData: the previous result stays, dimmed. */
.main-layout.loading { opacity: 0.45; transition: opacity 0.2s; pointer-events: none; }
.data-loading { margin: 6px 0; font-size: 12.5px; color: var(--text-dim); }
.data-loading::before { content: "⏳ "; }
.data-loading.error { color: var(--red); }
.data-loading.error::before { content: "⚠️ "; }
.data-loading .reset-btn { margin-left: 6px; }

/* ---------- modifier chips + the full panel ---------- */
/* The modifiers, a card under the defender (T-125). */
.def-stack { display: grid; gap: 12px; align-content: start; min-width: 0; }
.mods-card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; display: grid; gap: 10px; min-width: 0; }
.mods-bar { display: grid; gap: 8px; }
.mods-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.mods-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.mods-gl { font-size: 12px; font-weight: 700; color: var(--text-faint); margin-right: 2px; white-space: nowrap; }
.mods-card .modpanel { grid-template-columns: 1fr; border-top: 1px solid var(--border); padding-top: 10px; }
.mods-card .mods-col { border: none; background: none; padding: 0; }
/* Detachment rules (T-128): ⚡ chips beside the modifiers, with a tooltip naming the rule;
   struck through when not in play, dimmed when switched off. The pickers sit underneath. */
.mchip.det { position: relative; }
.mchip.det:hover, .mchip.det:focus-visible { z-index: 30; }
.mchip .tag { font-size: 10px; font-weight: 800; color: var(--amber); background: color-mix(in srgb, var(--amber) 16%, transparent); border-radius: 4px; padding: 0 4px; margin-right: 4px; }
.mchip.det.idle { color: var(--text-faint); background: transparent; text-decoration: line-through; cursor: default; }
.mchip.det.off { color: var(--text-faint); background: transparent; border-style: dashed; }
.mchip .mtip { display: none; position: absolute; left: 0; top: calc(100% + 6px); z-index: 20; width: max-content; max-width: 260px; white-space: normal; text-align: left;
  font-size: 12px; font-weight: 500; line-height: 1.4; color: var(--bg); background: var(--text); border-radius: 6px; padding: 6px 9px; box-shadow: 0 6px 18px var(--shadow); text-decoration: none; }
.mchip.det:hover .mtip, .mchip.det:focus-visible .mtip { display: block; }
.det-block { display: grid; gap: 10px; border-top: 1px solid var(--border); padding-top: 10px; }
.det-side { display: grid; gap: 6px; }
.det-row { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.4fr); gap: 8px; align-items: center; font-size: 12.5px; }
.det-row select { width: 100%; min-width: 0; }
.det-who { font-weight: 700; color: var(--text-dim); }
.det-sub .det-who { font-weight: 600; color: var(--text-faint); padding-left: 14px; }
.det-note { margin: 0; font-size: 11.5px; color: var(--text-faint); }
.det-fx { margin: 4px 0; padding-left: 0; list-style: none; display: grid; gap: 2px; font-size: 12.5px; }
.det-fx small { color: var(--text-faint); }
.mods-label { font-size: 12px; font-weight: 700; color: var(--text-faint); margin-right: 2px; }
.mchip {
  font: inherit; font-size: 12.5px; font-weight: 700; padding: 5px 11px; border-radius: 999px; cursor: pointer;
  background: var(--panel); color: var(--text); border: 1px solid var(--border);
}
.mchip.on.att { background: color-mix(in srgb, var(--att) 12%, var(--panel)); border-color: color-mix(in srgb, var(--att) 45%, var(--border)); }
.mchip.on.def { background: color-mix(in srgb, var(--def) 12%, var(--panel)); border-color: color-mix(in srgb, var(--def) 45%, var(--border)); }
.mchip .x { color: var(--text-faint); font-size: 11px; margin-left: 2px; }
.mchip.on:hover .x { color: var(--red); }
.mchip.add { border-style: dashed; color: var(--text-dim); background: transparent; }
.mchip.add:hover { color: var(--text); border-color: var(--text-dim); }
.modpanel { display: grid; grid-template-columns: 3fr 2fr; gap: 12px; }
.modpanel[hidden] { display: none; }
@media (max-width: 760px) { .modpanel { grid-template-columns: 1fr; } }
.mods-col { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 14px; min-width: 0; }

/* ---------- the answer ---------- */
.answer { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
.ans-big { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.ans-num { font-size: 52px; font-weight: 900; letter-spacing: -0.03em; line-height: 1; color: var(--c5); }
.ans-of { font-size: 17px; font-weight: 800; }
.ans-meter { height: 8px; border-radius: 999px; background: var(--soft); overflow: hidden; }
.ans-meter i { display: block; height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, var(--c0), var(--c2), var(--c5)); transition: width 0.3s; }
/* Each step with its middle-3-in-4 range underneath (T-126). */
.ans-range { font-size: 11.5px; color: var(--text-faint); }
.ans-range { font-size: 13px; font-variant-numeric: tabular-nums; }
.ans-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-dim); }
.ans-foot b { color: var(--text); }
.ans-foot .wipe { color: var(--red); }
@media (prefers-reduced-motion: reduce) { .ans-meter i { transition: none; } }

.mods-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.mods-head h4 { margin: 0; font-size: 14px; }
.att-color { color: var(--att); }
.def-color { color: var(--def); }
.reset-btn {
  background: var(--soft); color: var(--text-dim); border: 1px solid var(--border);
  padding: 3px 9px; font-size: 11px; height: 24px; border-radius: 6px; cursor: pointer;
}
.reset-btn:hover { background: var(--danger-bg); color: var(--red); border-color: var(--red); }

.mods-row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 8px; }
.mods-row2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; margin-bottom: 8px; }
.num-field, .sel-field { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.num-field label, .sel-field label { font-size: 9.5px; color: var(--text-dim); }
/* width + min-width: number inputs have an intrinsic minimum width that otherwise
   overflows the sidebar grid and covers the Hits card. */
.num-field input, .sel-field select {
  background: var(--panel-3); color: var(--text); border: 1px solid var(--border); border-radius: 5px;
  padding: 4px 6px; font-size: 12.5px; height: 28px; width: 100%; min-width: 0;
}

.mods-checkgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px 8px; margin-bottom: 6px; }
.mods-checkgrid2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 8px; }
.chk-field { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-dim); }
.chk-field input { accent-color: var(--att); width: 14px; height: 14px; }

.reroll-row { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.reroll-label { font-size: 11px; color: var(--text-dim); width: 40px; }
.radio-row { display: flex; gap: 6px; flex-wrap: wrap; }
.radio-row label { display: flex; align-items: center; gap: 3px; font-size: 11px; color: var(--text-dim); }
.radio-row input { accent-color: var(--def); }

.divider { height: 1px; background: var(--border); margin: 14px 0; }

/* ---------- charts ---------- */

.chart-card {
  text-align: center; padding: 14px; border-radius: 8px;
  background: linear-gradient(145deg, var(--panel-2), var(--panel-3));
  border: 1px solid var(--border); box-shadow: 0 4px 6px var(--shadow-sm);
}
.chart-card .title { font-size: 24px; line-height: 1.1; color: var(--text); font-weight: 900; letter-spacing: 0.06em; text-transform: uppercase; }
.chart-card .target { font-size: 13px; font-weight: 600; color: var(--text-dim); margin: 2px 0 4px; }
.chart-card .conv { font-size: 12px; color: var(--sky); font-weight: 700; margin: -2px 0 5px; }
.chart-card .conv .sub { font-size: 9.5px; color: var(--text-dim); font-weight: 400; display: block; }
.chart-card .mean { font-size: 38px; font-weight: 900; margin-top: -4px; text-shadow: var(--mean-glow); }
.chart-card .stats-line { font-size: 12px; color: var(--text-2); margin-top: 6px; background: var(--soft); padding: 5px; border-radius: 4px; }
.chart-card .wipe-warn {
  color: var(--amber); font-size: 11.5px; font-weight: 900; margin-top: 6px;
  background: var(--warn-bg); padding: 4px; border-radius: 4px;
}
.chart-card svg { width: 100%; height: 110px; margin-top: 6px; display: block; }

/* ---------- footer ---------- */
.footer { text-align: center; margin-top: 40px; padding-top: 16px; border-top: 1px solid var(--border); }
.footer p { color: var(--text-faint); font-size: 11px; font-style: italic; margin: 0; }
.footer p + p { margin-top: 6px; }
.footer .data-info, .footer .disclaimer { font-style: normal; font-size: 10.5px; max-width: 640px; margin-left: auto; margin-right: auto; line-height: 1.5; }
.footer a { color: var(--text-dim); }

/* ---------- army rosters ---------- */
.roster-section { margin-top: 26px; }
.section-head { margin-bottom: 10px; }
.section-head h2 { margin: 0; font-size: 16px; font-weight: 800; letter-spacing: 0.5px; }
.section-head p { margin: 3px 0 0; color: var(--text-dim); font-size: 12px; }
.roster-grid { display: grid; grid-template-columns: 1fr 44px 1fr; gap: 12px; align-items: start; }
@media (max-width: 760px) {
  .roster-grid { grid-template-columns: 1fr; }
  .roster-swap { order: -1; }
}
.roster-col { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 12px; min-width: 0; }
.roster-swap { display: flex; justify-content: center; padding-top: 40px; }
@media (max-width: 760px) { .roster-swap { padding-top: 0; } }
#rosterSwap {
  background: linear-gradient(135deg, #3B82F6 0%, #8B5CF6 100%); color: #fff; font-weight: 800;
  border: none; border-radius: 8px; padding: 8px 10px; font-size: 15px; cursor: pointer;
}
#rosterSwap span { display: none; font-size: 12px; }
@media (max-width: 760px) { #rosterSwap { width: 100%; } #rosterSwap span { display: inline; } }

.roster-empty {
  border: 1.5px dashed var(--border); border-radius: 8px; padding: 14px; text-align: center;
  color: var(--text-dim); font-size: 12.5px;
}
.roster-empty.drag { border-color: var(--att); background: var(--drag-bg); }
.roster-empty p { margin: 0 0 8px; }
.roster-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.btn {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 6px;
  padding: 7px 12px; font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.btn:hover { border-color: var(--text-dim); }
.btn.primary { background: var(--att); border-color: var(--att); color: #fff; }
.roster-hint { margin-top: 10px !important; font-size: 11px; color: var(--text-faint); }
.paste-box { margin-top: 10px; text-align: left; }
.paste-box textarea {
  width: 100%; background: var(--panel-3); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 8px; font: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; resize: vertical;
}
.paste-row { display: flex; gap: 8px; margin-top: 6px; }
.paste-row select { margin: 0; flex: 1; min-width: 0; }
.roster-err { color: var(--red); font-size: 12px; margin-top: 8px !important; }

.roster-head .reset-btn { white-space: nowrap; }
.roster-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 6px; }
.roster-title { min-width: 0; }
.roster-name { font-weight: 800; font-size: 14px; overflow-wrap: anywhere; }
.roster-meta { color: var(--text-dim); font-size: 11.5px; margin-top: 2px; }
.roster-warn { color: var(--amber); font-size: 11.5px; margin: 0 0 6px; }
.roster-role {
  font-size: 10px; font-weight: 800; color: var(--text-faint); letter-spacing: 1px;
  margin: 10px 0 4px; padding-bottom: 3px; border-bottom: 1px solid var(--border);
}
.roster-unit {
  display: block; width: 100%;
  background: transparent; color: var(--text); border: 1px solid transparent; border-radius: 6px;
  padding: 6px 8px; text-align: left; cursor: pointer; font-size: 13px;
}
.roster-unit:hover { background: var(--panel-2); }
.roster-unit.selected { border-color: currentColor; background: var(--panel-2); }
#roster0 .roster-unit.selected { color: var(--att-soft); }
#roster1 .roster-unit.selected { color: var(--def-soft); }
.roster-unit.nodata { opacity: 0.45; cursor: default; }
.roster-unit.nodata:hover { background: transparent; }
.ru-name { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.ru-sub { display: block; font-weight: 400; font-size: 11px; color: var(--text-dim); }
.ru-pts { color: var(--text-dim); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }

.toast {
  position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 150%);
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px var(--shadow);
  padding: 10px 12px; display: flex; gap: 12px; align-items: center; font-size: 13px;
  max-width: calc(100vw - 32px); transition: transform 0.2s ease, visibility 0.2s; z-index: 10; visibility: hidden;
}
.toast.show { transform: translate(-50%, 0); visibility: visible; }
.toast { width: max-content; }
.toast span { min-width: 0; }
.toast button { background: none; border: none; color: var(--att-soft); font-weight: 700; cursor: pointer; white-space: nowrap; font-size: 13px; }

.ru-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

/* ---------- army comparator ---------- */
/* Your selected unit: unmistakable, and named in a pinned bar when scrolled away. */
#roster0 .roster-unit.selected {
  color: var(--text); border: 1px solid var(--att); border-left: 5px solid var(--att);
  background: color-mix(in srgb, var(--att) 16%, var(--panel));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--att) 22%, transparent);
}
.att-badge {
  display: inline-block; margin-left: 6px; padding: 1px 6px; border-radius: 999px; vertical-align: 1px;
  background: var(--att); color: #fff; font-size: 9.5px; font-weight: 800; letter-spacing: 0.6px;
}

.cmp-banner {
  background: var(--panel); border: 1px solid var(--att); border-radius: 10px; padding: 10px 12px;
  margin-bottom: 10px; display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between;
}
.cmp-title { font-size: 13px; }
.cmp-sub { display: block; color: var(--text-dim); font-size: 11.5px; margin-top: 2px; }
.cmp-opts { display: flex; flex-wrap: wrap; gap: 4px 14px; }

.best-badge {
  display: inline-block; font-size: 10px; font-weight: 700; color: var(--amber);
  background: var(--warn-bg); border-radius: 4px; padding: 0 5px; margin-left: 4px; vertical-align: 1px;
}
.cmp { display: block; margin-top: 6px; }
.cmp-line { display: block; padding: 4px 0; border-top: 1px dashed var(--border); }
.cmp-head { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.cmp-kind { width: 78px; flex: none; color: var(--text-dim); font-weight: 600; white-space: nowrap; }
.cmp-kills { flex: none; white-space: nowrap; color: var(--text); }
.cmp-kills b { font-size: 14px; }
.cmp-bar { flex: 1; min-width: 30px; height: 6px; background: var(--soft); border-radius: 3px; overflow: hidden; }
.cmp-bar i { display: block; height: 100%; background: var(--att); border-radius: 3px; }
.cmp-pct { flex: none; width: 34px; text-align: right; color: var(--text-dim); font-size: 11px; font-variant-numeric: tabular-nums; }
.cmp-detail { display: block; color: var(--text-dim); font-size: 11px; line-height: 1.4; margin-top: 2px; font-weight: 400; }
.cmp-none { color: var(--text-faint); font-size: 11.5px; }
.cmp-line.none .cmp-kind { display: inline-block; }
.cmp-pts { display: block; text-align: right; font-size: 11px; color: var(--text-dim); margin-top: 2px; }

.cmp-via { display: block; font-size: 11px; color: var(--text-faint); margin-top: 1px; font-weight: 400; }
.cmp-weps { display: block; margin: 6px 0 2px; border-left: 2px solid var(--att); padding-left: 8px; }
.cw-head { display: block; font-size: 10px; font-weight: 800; letter-spacing: 0.6px; text-transform: uppercase; color: var(--text-faint); margin: 6px 0 2px; }
.cw-head:first-child { margin-top: 0; }
.cw { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 10px; align-items: baseline; font-size: 11.5px; line-height: 1.35; padding: 2px 0; font-weight: 400; }
.cw-name { color: var(--text); min-width: 0; overflow-wrap: anywhere; }
.cw-badge { display: inline-block; width: 20px; }
.cw-status { display: block; padding-left: 20px; color: var(--text-faint); font-size: 10.5px; }
.cw-val { color: var(--text-dim); white-space: nowrap; text-align: right; }
.cw-val b { color: var(--text); }
.cw.option .cw-name { color: var(--text-dim); }
.roster-unit.expanded { border-color: var(--def); }
@media (max-width: 520px) {
  .cw { grid-template-columns: 1fr; }
  .cw-val { grid-column: 1; text-align: left; padding-left: 20px; }
}

/* ---------- efficiency rankings ---------- */
.rank-section { margin-top: 30px; }
.rank-controls { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: flex-end; margin-bottom: 10px; }
.rk-field { display: flex; flex-direction: column; gap: 2px; font-size: 10.5px; color: var(--text-dim); min-width: 0; }
.rk-field select, .rk-field input {
  margin: 0; background: var(--panel-3); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 8px; font-size: 13px; max-width: 260px; min-width: 0;
}
.rk-search input { width: 180px; }
.rk-legends { padding-bottom: 6px; }
.rk-mix { flex: 1 1 100%; display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
.rk-mix-h { flex: 1 1 100%; font-size: 10.5px; font-weight: 800; letter-spacing: 0.5px; text-transform: uppercase; color: var(--text-faint); }
.rk-w { display: flex; flex-direction: column; gap: 2px; font-size: 11.5px; color: var(--text-dim); flex: 1 1 120px; }
.rk-w input { width: 100%; accent-color: var(--att); }
.rk-traits { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 10px; }
.rk-trait { font-size: 11px; font-weight: 700; border: 1px solid var(--border); background: var(--panel); border-radius: 999px; padding: 2px 8px; }
.rank-list { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.rk-head, .rk-main {
  display: grid; grid-template-columns: 36px minmax(0, 1fr) 190px 300px; gap: 10px; align-items: center; padding: 8px 12px;
}
.rk-head { font-size: 10px; font-weight: 800; letter-spacing: 0.6px; text-transform: uppercase; color: var(--text-faint); border-bottom: 1px solid var(--border); }
.rk-targets-h, .rk-targets { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; text-align: center; }
.rk-targets-h span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rk-row { border-bottom: 1px solid var(--border); }
.rk-row:last-of-type { border-bottom: none; }
.rk-row.open { background: var(--panel-2); }
.rk-main { cursor: pointer; }
.rk-main:hover { background: var(--panel-2); }
.rk-rank { color: var(--text-faint); font-variant-numeric: tabular-nums; font-size: 12px; }
.rk-name { font-weight: 700; font-size: 13px; min-width: 0; overflow-wrap: anywhere; }
.rk-sub { display: block; font-weight: 400; font-size: 11px; color: var(--text-dim); }
.rk-tag { display: inline-block; font-size: 9.5px; font-weight: 700; color: var(--text-dim); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; margin-left: 5px; vertical-align: 1px; }
.rk-scores { display: flex; gap: 8px; }
.rk-score { display: flex; flex-direction: column; align-items: center; gap: 1px; }
.rk-lbl { font-size: 9px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.4px; }
.rk-chip { display: inline-block; min-width: 30px; text-align: center; border-radius: 5px; padding: 2px 4px; font-weight: 800; font-size: 12px; font-variant-numeric: tabular-nums; }
.rk-t { border-radius: 4px; padding: 3px 0; font-size: 11.5px; font-variant-numeric: tabular-nums; }
.h5 { background: rgba(16,185,129,0.30); color: var(--text); }
.h4 { background: rgba(16,185,129,0.16); color: var(--text); }
.h3 { background: var(--soft); color: var(--text); }
.h2 { background: rgba(245,158,11,0.14); color: var(--text); }
.h1 { background: rgba(239,68,68,0.16); color: var(--text); }
.rk-detail { padding: 4px 12px 14px 58px; }
.rk-tables { display: grid; grid-template-columns: 3fr 2fr 2fr; gap: 16px; }
/* The unit's datasheet, loaded from BSData when a row opens (T-142): statline, then weapons. */
.rk-sheet { display: grid; gap: 8px; margin: 2px 0 12px; font-variant-numeric: tabular-nums; }
.rk-stats { border-collapse: collapse; background: var(--statline-bg); border-radius: 6px; font-size: 13px; width: 100%; max-width: 420px; }
.rk-stats th { font-size: 9.5px; font-weight: 700; color: var(--stat-k); padding: 4px 8px 0; text-align: center; }
.rk-stats td { font-weight: 900; color: var(--stat-v); padding: 0 8px 4px; text-align: center; }
.rk-stats td.rk-mname { font-size: 11px; font-weight: 700; text-align: left; color: var(--text-dim); padding-left: 10px; }
.rk-weps { border-collapse: collapse; width: 100%; max-width: 640px; font-size: 12px; }
.rk-weps th { font-size: 9.5px; font-weight: 700; color: var(--text-faint); text-transform: uppercase; padding: 0 4px 3px; text-align: center; }
.rk-weps td { padding: 3px 4px; border-top: 1px solid var(--border); text-align: center; color: var(--text-dim); white-space: nowrap; }
.rk-weps td.rk-wname { text-align: left; color: var(--text); font-weight: 700; white-space: normal; width: 100%; }
.rk-wname small { color: var(--text-faint); font-weight: 600; }
.rk-wname .rk-wkw { display: block; font-size: 10px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.02em; }
.rk-wi { font-size: 11px; opacity: 0.7; margin-right: 4px; }
.rk-more-w summary { cursor: pointer; font-size: 11.5px; color: var(--text-dim); }
.rk-more-w[open] summary { margin-bottom: 4px; }
.rk-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.rk-table caption { text-align: left; font-size: 10px; font-weight: 800; letter-spacing: 0.6px; text-transform: uppercase; color: var(--text-faint); padding-bottom: 4px; }
.rk-table th, .rk-table td { text-align: left; vertical-align: top; padding: 4px 6px; border-top: 1px solid var(--border); font-weight: 400; }
.rk-table tr:first-child th { border-top: none; font-size: 10.5px; color: var(--text-dim); font-weight: 700; }
.rk-table th { color: var(--text); font-weight: 700; white-space: nowrap; }
.rk-table small { display: block; color: var(--text-faint); font-size: 10.5px; white-space: normal; }
.rk-table b { font-variant-numeric: tabular-nums; }
.rk-opt { color: var(--amber) !important; }
.rk-none { color: var(--text-faint); }
.rk-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.rk-basis { color: var(--text-faint); font-size: 10.5px; margin: 8px 0 0; line-height: 1.45; }
.rk-more { display: block; width: calc(100% - 24px); margin: 10px 12px; }
.rk-empty { color: var(--text-dim); padding: 16px; margin: 0; }
@media (max-width: 900px) {
  .rk-head, .rk-main { grid-template-columns: 30px minmax(0, 1fr) 180px; }
  .rk-targets-h, .rk-targets { display: none; }
  .rk-detail { padding-left: 12px; }
  .rk-tables { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .rk-head .rk-scores-h { display: none; }
  .rk-head { grid-template-columns: 30px 1fr; }
  .rk-main { grid-template-columns: 26px minmax(0, 1fr) auto; gap: 8px; padding: 8px 10px; }
  .rk-scores { gap: 5px; }
  .rk-chip { min-width: 26px; font-size: 11.5px; }
  .rk-field { flex: 1 1 45%; }
  .rk-field select, .rk-field input, .rk-search input { max-width: none; width: 100%; }
}

/* ---------- detachments + comparator buffs ---------- */
.det-row { display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap; margin: 2px 0 6px; }
.det-pick { display: flex; flex-direction: column; gap: 2px; font-size: 10.5px; color: var(--text-dim); min-width: 0; flex: 1 1 200px; }
.det-pick select { margin: 0; font-size: 12.5px; padding: 4px 6px; }
.det-pick select + select { margin-top: 4px; }
.det-rules .det-name { font-weight: 700; color: var(--text); margin: 8px 0 2px; }
.det-rules .det-name:first-child { margin-top: 0; }
.det-toggle { height: 28px; }
.det-rules { background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; font-size: 12px; line-height: 1.45; color: var(--text-2); max-height: 260px; overflow: auto; }
.det-rules p { margin: 0 0 8px; }
.det-rules p:last-child { margin-bottom: 0; }
.cmp-buffs { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; width: 100%; padding-top: 6px; border-top: 1px dashed var(--border); }
.buff-grp { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.buff-lbl { font-size: 11px; font-weight: 700; color: var(--text-dim); margin-right: 2px; }
.chip { background: var(--soft); color: var(--text-dim); border: 1px solid var(--border); border-radius: 999px; padding: 2px 9px; font-size: 11.5px; cursor: pointer; }
.chip:hover { border-color: var(--text-dim); }
.chip.on { background: var(--att); border-color: var(--att); color: #fff; }
.buff-grp select { margin: 0; width: auto; font-size: 11.5px; padding: 2px 6px; height: 24px; }

/* ---------- supporter badge ---------- */
.cmp-meter { display: inline-block; margin-top: 4px; font-size: 11px; font-weight: 700; color: var(--amber); }
.cmp-meter.pro { color: var(--green); }

.footer .footer-links { font-style: normal; margin-top: 8px; }
.footer .lang-pick { font-style: normal; margin-top: 8px; }
.footer .lang-pick select { font: inherit; margin-left: 6px; background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 2px 6px; }

/* ---------- intro line (search engines read it; players get the links) ---------- */
.intro { max-width: 860px; margin: -6px auto 16px; text-align: center; color: var(--text-dim); font-size: 13px; line-height: 1.5; }
.intro a { color: var(--att); }
.intro strong { color: var(--text); }

/* Affiliate "find this unit" links (shop.js): one quiet line, never a banner. */
.shop { margin: 10px 0; font-size: 13px; color: var(--text-dim); }
.shop a { font-weight: 600; }
.shop small { display: block; margin-top: 2px; font-size: 11px; opacity: 0.8; }

/* Share this matchup */

/* ---------- recent winning lists ---------- */
.lists-section { margin-top: 18px; }
.wl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 10px; }
.wl-card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; min-width: 0; }
.wl-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.wl-place { font-weight: 800; font-size: 14px; white-space: nowrap; }
.wl-place small { font-weight: 600; color: var(--text-dim); font-size: 11px; }
.wl-fac { font-weight: 700; font-size: 13px; text-align: right; overflow-wrap: anywhere; }
.wl-det { color: var(--att-soft); font-size: 12px; font-weight: 600; margin-top: 2px; overflow-wrap: anywhere; }
.wl-sub { color: var(--text-dim); font-size: 11.5px; margin-top: 3px; overflow-wrap: anywhere; }
.wl-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.wl-actions .btn { font-size: 12px; padding: 5px 9px; }
.wl-actions a.reset-btn { text-decoration: none; display: inline-flex; align-items: center; }
.wl-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 11.5px; line-height: 1.45; background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; margin: 8px 0 0; max-height: 360px; overflow: auto; }
.lists-credit { color: var(--text-faint); font-size: 10.5px; margin: 10px 0 0; line-height: 1.5; }

/* ---------- results breakdown: attrition funnel + dice charts ---------- */
.charts-col { min-width: 0; }
.breakdown { min-width: 0; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; }
.bd-panel { position: relative; padding: 12px 14px 14px; }
.bd-panel[hidden] { display: none; }
/* Classic: all five dice charts at once, three then two. */
.bd-charts { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.bd-charts .chart-card { grid-column: span 2; }
.bd-charts .chart-card:nth-child(n + 4) { grid-column: span 3; }
@media (max-width: 700px) { .bd-charts { grid-template-columns: 1fr; } .bd-charts .chart-card, .bd-charts .chart-card:nth-child(n + 4) { grid-column: auto; } }
/* The weapons firing, as a row of buttons right above the chart (T-124). One line that scrolls
   sideways on a phone; wraps on wider screens. */
.ws-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.ws-lbl { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-faint); margin-right: 2px; }
.ws-sep { width: 1px; align-self: stretch; background: var(--border); margin: 2px 2px; }
.ws-chip { font: inherit; font-size: 13px; font-weight: 600; display: inline-flex; align-items: baseline; gap: 5px; white-space: nowrap; cursor: pointer;
  color: var(--text-dim); background: var(--soft); border: 1px solid var(--border); border-radius: 999px; padding: 4px 11px; }
.ws-chip small { font-size: 11px; font-weight: 500; color: var(--text-faint); }
.ws-chip .ws-ico { font-size: 12px; opacity: 0.8; }
.ws-chip:hover { color: var(--text); border-color: var(--att-soft); }
.ws-chip[aria-pressed="true"] { color: var(--text); background: color-mix(in srgb, var(--att) 16%, transparent); border-color: var(--att); }
.ws-chip:focus-visible { outline: 2px solid var(--att); outline-offset: 2px; }
@media (max-width: 560px) {
  .ws-row { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding: 8px; }
  .ws-row::-webkit-scrollbar { display: none; }
  .ws-chip { flex: none; }
}
.bd-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; border-bottom: 1px solid var(--border); padding-right: 8px; }
.mode-switch { display: flex; flex: none; background: var(--soft); border: 1px solid var(--border); border-radius: 999px; padding: 2px; }
.mode-switch button { font: inherit; font-size: 12px; font-weight: 700; border: none; background: none; color: var(--text-dim); padding: 4px 10px; border-radius: 999px; cursor: pointer; white-space: nowrap; }
.mode-switch button[aria-pressed="true"] { background: var(--panel); color: var(--text); box-shadow: 0 1px 3px var(--shadow-sm); }
@media (max-width: 560px) { .bd-bar { flex-direction: column-reverse; align-items: stretch; padding: 8px 8px 0; } .mode-switch { align-self: flex-end; } }

/* The support card (T-112): an occasional ask for a coffee, over the page. */
.support-pop { position: fixed; inset: 0; z-index: 45; display: grid; place-items: center; padding: 16px; background: rgba(2, 6, 23, 0.55); }
.sc-card { position: relative; width: min(440px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--panel); border: 1px solid var(--amber); border-radius: 16px; box-shadow: 0 20px 50px var(--shadow); }
.sc-x { position: absolute; top: 8px; right: 8px; z-index: 1; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border); background: var(--soft); color: var(--text); font: inherit; font-size: 15px; cursor: pointer; }
.sc-stage { position: relative; background: var(--panel-3); border-bottom: 1px solid var(--border); }
.sc-stage canvas { display: block; width: 100%; height: auto; image-rendering: pixelated; }
.sc-scheme { position: absolute; left: 10px; top: 8px; font-size: 10.5px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-dim); background: var(--panel); border: 1px solid var(--border); border-radius: 999px; padding: 2px 8px; }
.sc-body { padding: 14px 16px 16px; display: grid; gap: 8px; }
.sc-body h2 { margin: 0; font-size: 19px; font-weight: 900; padding-right: 30px; text-wrap: balance; }
.sc-body p { margin: 0; color: var(--text-dim); font-size: 14px; line-height: 1.45; }
.sc-body .sc-count { color: var(--text); font-weight: 800; font-variant-numeric: tabular-nums; }
.sc-acts, .sc-foot { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sc-acts .btn { text-decoration: none; }
.sc-link { border: 0; background: none; color: var(--text-faint); font: inherit; font-size: 13px; text-decoration: underline; cursor: pointer; padding: 6px 2px; }
.sc-body .sc-note { font-size: 12px; color: var(--text-faint); }

/* A roll's dice chart popped out over the funnel. */
.stage-pop { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; background: rgba(2, 6, 23, 0.55); }
.sp-card { width: min(520px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 20px 50px var(--shadow); padding: 10px 12px 12px; touch-action: pan-y; }
.sp-head { display: flex; align-items: center; gap: 6px; }
.sp-mid { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.sp-title { font-size: 13px; font-weight: 800; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.08em; }
.sp-dots { display: flex; gap: 5px; }
.sp-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--border); }
.sp-dots i.on { background: var(--def); }
.sp-nav, .sp-close { font: inherit; font-size: 20px; line-height: 1; width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border); background: var(--soft); color: var(--text); cursor: pointer; }
.sp-close { font-size: 15px; }
.sp-body .chart-card, .sp-body { text-align: center; }
.sp-body svg { width: 100%; height: 140px; margin-top: 6px; display: block; }
.sp-hint { margin: 8px 0 0; text-align: center; font-size: 11.5px; color: var(--text-faint); }
.flow-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 12px; color: var(--text-dim); margin: 8px 0; }
.flow-legend span { display: inline-flex; align-items: center; gap: 6px; }
.flow-legend i { display: inline-block; width: 14px; height: 12px; border-radius: 3px; }
.k-core { background: linear-gradient(90deg, var(--c0), var(--c2), var(--c5)); }
.k-avg { border-top: 2px solid var(--c2); border-bottom: 2px solid var(--c2); background: color-mix(in srgb, var(--c2) 50%, transparent); }
.k-haze { background: color-mix(in srgb, var(--c2) 20%, transparent); }
.flow { position: relative; width: 100%; min-height: 260px; }
.flow svg { display: block; overflow: visible; }
.flow canvas { position: absolute; left: 0; top: 0; pointer-events: none; image-rendering: pixelated; }
.flow text { font-family: inherit; }
.flow .stage { fill: var(--text-dim); font-size: 10.5px; font-weight: 600; }
.flow .stage.narrow { font-size: 9px; }
.flow .stage-v { fill: var(--text); font-size: 13px; font-weight: 800; }
.flow .gate { fill: var(--text-faint); font-size: 10.5px; font-weight: 600; }
.flow .gate-v { fill: var(--text); font-size: 11.5px; font-weight: 800; }
.flow .gate-v.long { font-size: 8.5px; }   /* "mixed" on a phone, when weapons need different rolls */
.flow .gate-line { stroke: var(--text-faint); stroke-opacity: 0.55; stroke-width: 1; }
.flow .lost { fill: var(--text-faint); font-size: 10.5px; font-weight: 700; }
.flow .hit { cursor: pointer; outline: none; }
.flow .hit.on, .flow .hit:focus-visible { fill: var(--text); fill-opacity: 0.05; }
.flow-tip { position: absolute; z-index: 3; pointer-events: none; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; font-size: 12px; color: var(--text-dim); box-shadow: 0 6px 18px var(--shadow-sm); min-width: 160px; }
.flow-tip b { color: var(--text); font-size: 15px; }
.flow-tip .muted { color: var(--text-faint); margin-top: 2px; }
.flow-tbl { margin-top: 6px; font-size: 12px; color: var(--text-dim); }
.flow-tbl summary { cursor: pointer; color: var(--text-faint); }
.flow-tbl table { border-collapse: collapse; margin-top: 6px; width: 100%; font-variant-numeric: tabular-nums; }
.flow-tbl th, .flow-tbl td { text-align: left; padding: 4px 8px; border-bottom: 1px solid var(--border); }
.flow-tbl th { color: var(--text-faint); font-weight: 600; }
.so-caption { margin: 6px 0 0; font-size: 12px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.so-caption[hidden] { display: none; }
.so-actions { display: flex; gap: 6px; margin-left: auto; }
.so-actions [hidden] { display: none; }
.so-actions .btn { font-size: 12px; padding: 5px 10px; }

/* ---------- saved lists (in an empty roster slot) ---------- */
.lib { margin-top: 10px; border-top: 1px solid var(--border); padding-top: 8px; }
.lib-head { font-size: 10px; font-weight: 800; color: var(--text-faint); letter-spacing: 1px; margin-bottom: 4px; }
.lib-row { display: flex; align-items: stretch; gap: 4px; }
.lib-load { flex: 1; min-width: 0; text-align: left; background: transparent; border: 1px solid transparent; border-radius: 6px; padding: 5px 8px; cursor: pointer; color: var(--text); }
.lib-load:hover { background: var(--panel-2); border-color: var(--border); }
.lib-name { display: block; font-weight: 600; font-size: 13px; overflow-wrap: anywhere; }
.lib-sub { display: block; font-size: 11px; color: var(--text-dim); }
.lib-del { background: transparent; border: none; color: var(--text-faint); cursor: pointer; padding: 0 8px; font-size: 13px; border-radius: 6px; }
.lib-del:hover { color: var(--red); background: var(--panel-2); }
.lib-more { margin-top: 4px; }

/* ---------- points changed since last visit ---------- */
.pts-notice { position: relative; background: color-mix(in srgb, var(--amber) 14%, var(--panel)); border: 1px solid var(--amber); border-radius: 8px; padding: 8px 34px 8px 10px; margin: 0 0 8px; font-size: 12.5px; }
.pts-notice ul { margin: 4px 0 0; padding-left: 18px; }
.pts-notice li { margin: 1px 0; }
.pts-notice .up { color: var(--red); }
.pts-notice .down { color: var(--green); }
.pts-delta { color: var(--text-dim); font-weight: 600; }
.pts-notice [data-pts-dismiss] { position: absolute; top: 6px; right: 6px; }

/* ---------- first-visit welcome ---------- */
.welcome { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px;
  background: color-mix(in srgb, var(--bg, #0b1120) 70%, transparent); backdrop-filter: blur(3px); }
.w-card { width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--panel); border: 1px solid var(--border);
  border-radius: 16px; padding: 20px; box-shadow: 0 20px 50px var(--shadow); text-align: center; }
.w-brand { font-weight: 900; letter-spacing: 1px; font-size: 15px; color: var(--att-soft); }
.w-brand small { display: block; font-size: 10.5px; letter-spacing: 1.5px; color: var(--text-dim); font-weight: 700; text-transform: uppercase; margin-top: 2px; }
.w-card h2 { margin: 14px 0 6px; font-size: 22px; }
.w-lede { color: var(--text-dim); font-size: 13.5px; margin: 0 0 16px; line-height: 1.5; }
.w-sides { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 480px) { .w-sides { grid-template-columns: 1fr; } }
.w-side { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 16px 10px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--panel-2); color: var(--text); cursor: pointer; font-size: 15px; }
.w-side:hover, .w-side:focus-visible { border-color: var(--att); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--att) 25%, transparent); }
.w-icon { font-size: 30px; }
.w-side small { color: var(--text-dim); font-size: 11px; line-height: 1.35; }
.w-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-top: 10px; }
.w-army { padding: 10px 8px; border-radius: 10px; border: 1px solid var(--border); background: var(--panel-2); color: var(--text); cursor: pointer; font-weight: 700; font-size: 13px; }
.w-army:hover, .w-army:focus-visible { border-color: var(--att); outline: none; }
.w-back { display: block; margin: 10px 0 0; background: none; border: none; color: var(--att-soft); cursor: pointer; font-size: 13px; padding: 0; }
.w-skip { margin-top: 16px; background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 12.5px; text-decoration: underline; }
/* ---------- the BETA strip, "what's new" and feedback (T-184, T-064) ---------- */
.beta-strip { display: flex; align-items: center; gap: 10px; margin: -14px -14px 0; padding: 6px 14px; min-height: 36px; box-sizing: border-box;
  background: var(--warn-bg); border-bottom: 1px solid var(--amber); color: var(--text); font-size: 12.5px; }
.beta-strip + .topbar { margin-top: 0; }
.bs-tag { flex: none; padding: 2px 7px; border-radius: 99px; background: var(--amber); color: #111827; font-size: 10.5px; font-weight: 900; letter-spacing: 0.08em; }
.bs-txt { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bs-short { display: none; }
.bs-btn { flex: none; min-height: 30px; padding: 3px 10px; border-radius: 8px; border: 1px solid var(--amber); background: none; color: var(--text); font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.bs-fb { background: var(--amber); color: #111827; border-color: var(--amber); }
@media (max-width: 760px) { .bs-long { display: none; } .bs-short { display: inline; } .beta-strip { gap: 6px; padding: 5px 10px; } .bs-btn { padding: 3px 8px; } }
@media (max-width: 420px) { .bs-txt { display: none; } .beta-strip { justify-content: flex-end; } .bs-tag { margin-right: auto; } }
.news, .fb-sheet { position: fixed; inset: 0; z-index: 45; display: grid; place-items: center; padding: 16px;
  background: color-mix(in srgb, var(--bg, #0b1120) 70%, transparent); backdrop-filter: blur(3px); }
.fb-sheet { z-index: 46; }
.fb-back { position: absolute; inset: 0; }
.nw-card, .fb-card { position: relative; width: min(480px, 100%); max-height: calc(100vh - 32px); overflow: auto; box-sizing: border-box; background: var(--panel);
  border: 1px solid var(--border); border-top: 3px solid var(--amber); border-radius: 16px; padding: 20px; box-shadow: 0 20px 50px var(--shadow); }
.nw-x, .fb-x { position: absolute; top: 8px; right: 8px; width: 44px; height: 44px; border: 0; background: none; color: var(--text-dim); font-size: 18px; cursor: pointer; border-radius: 10px; }
.nw-kicker, .fb-kicker { font-size: 11px; font-weight: 900; letter-spacing: 0.08em; color: var(--amber); }
.nw-card h2, .fb-card h2 { margin: 6px 40px 8px 0; font-size: 22px; line-height: 1.25; }
.nw-p, .fb-p { margin: 0 0 12px; font-size: 14.5px; line-height: 1.55; color: var(--text-2); }
.nw-small { font-size: 13px; }
.nw-sub { margin: 4px 0 6px; font-size: 11px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-dim); }
.nw-list { margin: 0 0 14px; padding-left: 18px; font-size: 13.5px; line-height: 1.5; color: var(--text-2); }
.nw-list li + li { margin-top: 5px; }
.nw-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.nw-go, .fb-go { flex: 1; min-height: 48px; padding: 0 16px; border: 0; border-radius: 10px; background: var(--amber); color: #111827; font: inherit; font-size: 15px; font-weight: 800; cursor: pointer; }
.nw-fb { flex: 1; min-height: 48px; padding: 0 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel-2); color: var(--text); font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; }
.fb-go { width: 100%; }
.fb-go[disabled] { opacity: 0.6; cursor: wait; }
.fb-form { display: flex; flex-direction: column; gap: 12px; }
.fb-types { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.fb-type { min-height: 44px; border-radius: 10px; border: 1px solid var(--border); background: var(--panel-2); color: var(--text); font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.fb-type[aria-checked="true"] { border-color: var(--amber); background: var(--warn-bg); }
.fb-l { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; font-weight: 700; color: var(--text-dim); }
.fb-l textarea, .fb-l input { font: inherit; font-size: 16px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--panel-3); color: var(--text); resize: vertical; }
.fb-note { margin: 0; font-size: 12px; line-height: 1.5; color: var(--text-faint); }
.fb-alt { margin-top: 12px; }
:root[data-theme="light"] .nw-kicker, :root[data-theme="light"] .fb-kicker { color: #8a6100; }
:root[data-theme="light"] .bs-tag, :root[data-theme="light"] .bs-fb, :root[data-theme="light"] .nw-go, :root[data-theme="light"] .fb-go { color: #fff; }
.lists-title { margin: 4px 0 10px; font-size: 14px; font-weight: 800; color: var(--text-dim); }

/* Army vs Army sources (T-133): List · Faction · Unit type on each side, the unit-type chips
   and the note under them. */
.src-tabs { display: flex; gap: 2px; background: var(--soft); border: 1px solid var(--border); border-radius: 999px; padding: 2px; margin: 6px 0 10px; }
.src-tabs button { flex: 1; font: inherit; font-size: 12.5px; font-weight: 700; border: none; background: none; color: var(--text-dim); padding: 5px 8px; border-radius: 999px; cursor: pointer; white-space: nowrap; }
.src-tabs button[aria-pressed="true"] { background: var(--panel); color: var(--text); box-shadow: 0 1px 3px var(--shadow-sm); }
.src-tabs button:focus-visible, .src-types button:focus-visible, .src-link:focus-visible { outline: 2px solid var(--att); outline-offset: 2px; }
.src-pick { display: grid; gap: 8px; margin-bottom: 8px; }
.src-pick select { width: 100%; }
.src-types { display: flex; gap: 5px; overflow-x: auto; scrollbar-width: thin; padding-bottom: 2px; }
.src-types button { flex: none; font: inherit; font-size: 12px; font-weight: 600; border: 1px solid var(--border); background: var(--soft); color: var(--text-dim); border-radius: 999px; padding: 4px 10px; cursor: pointer; }
.src-types button[aria-pressed="true"] { color: var(--text); border-color: var(--att); background: color-mix(in srgb, var(--att) 14%, transparent); }
.src-note { margin: 0 0 6px; font-size: 12px; color: var(--text-faint); }
.src-link { font: inherit; font-size: 12px; border: none; background: none; padding: 0; color: var(--att); text-decoration: underline; cursor: pointer; }
.roster-unit.loading { opacity: 0.6; cursor: progress; }

/* The volley's bullet colours, one per weapon firing (T-136). */
.so-key { display: inline-flex; flex-wrap: wrap; gap: 4px 12px; margin-left: 8px; }
.so-key span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.so-key i { width: 12px; height: 4px; border-radius: 1px; box-shadow: 0 0 0 1px rgba(0,0,0,.45); }

/* ---------- the compact layout (T-140, T-141, T-143; the default since T-146) ---------- */
.src-tabs .st-short { display: none; }
/* 1: one card. The answer on top, then the funnel, which carries each roll's average and range;
   the roll tabs and the line of numbers under the answer go (a bar opens its dice chart). */
.main-layout { gap: 0; }
.answer { border-radius: 12px 12px 0 0; border-bottom: none; padding-bottom: 6px; gap: 8px; }
.breakdown { border-radius: 0 0 12px 12px; }
/* 🎲 Roll a volley · 🎬 On on the left, Funnel / Classic on the right, one line (T-141). */
.bd-bar { flex-direction: row; align-items: center; justify-content: space-between; padding: 6px 8px; }
.bd-bar .so-actions { display: flex; gap: 6px; margin-left: 0; }
.bd-bar .btn { font-size: 12px; padding: 4px 9px; white-space: nowrap; }
.breakdown:has(#bdFlow[hidden]) .so-actions { visibility: hidden; }
.bd-panel { padding-top: 6px; }
.flow-legend { margin-top: 0; }
.ans-foot { position: absolute; right: 14px; top: 12px; }
.answer { position: relative; }
.ans-big { padding-right: 44px; }
#shareBtn { font-size: 0; padding: 5px 9px; }
#shareBtn::before { content: "🔗"; font-size: 14px; }
#ansSafe:empty { display: none; }
.flow .stage-r { fill: var(--text-faint); font-size: 10.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
/* The pinned matchup, as a compact funnel that stays while you pick units further down (T-141). */
.pb-stages { display: none; }
.pinbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 8px; padding: 4px 2px 6px; }
.pb-txt small { display: block; margin: 0; font-size: 11px; overflow: hidden; text-overflow: ellipsis; }
.pb-rng { font-size: 12px; font-weight: 600; color: var(--text-faint); }
.pb-stages { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; text-align: center; font-variant-numeric: tabular-nums; }
.pbs { display: grid; justify-items: center; line-height: 1.15; min-width: 0; }
.pbs-l { font-size: 9.5px; font-weight: 600; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.pbs-bar { display: flex; align-items: center; justify-content: center; width: 100%; height: 22px; }
.pbs-bar i { display: block; width: 55%; min-height: 2px; border-radius: 2px; }
.pbs b { font-size: 12.5px; font-weight: 800; }
.pbs small { font-size: 9.5px; color: var(--text-faint); min-height: 11px; }
@media (min-width: 761px) {
  .pinbar { grid-template-columns: minmax(0, 340px) minmax(0, 1fr) auto; gap: 0 16px; }
  .pb-stages { grid-column: 2; grid-row: 1; max-width: 560px; }
  .pb-up { grid-column: 3; grid-row: 1; }
}
/* 2: Army vs Army, one line per target: 🎯 ranged and ⚔️ melee as a share of the unit slain. */
.cmp-mini { display: flex; align-items: center; gap: 10px; margin-top: 4px; font-size: 11.5px; font-variant-numeric: tabular-nums; }
.cm-m { display: inline-flex; align-items: center; gap: 4px; flex: 1 1 0; min-width: 0; max-width: 150px; }
.cm-m .cmp-bar { min-width: 20px; }
.cm-m.none { opacity: 0.45; }
.cm-i { font-size: 11px; }
.cm-p { width: 32px; text-align: right; color: var(--text-dim); font-weight: 700; }
.cm-pts { margin-left: auto; color: var(--text-dim); white-space: nowrap; font-size: 11px; }
.cm-m:nth-child(2) .cmp-bar i { background: var(--def); }
.roster-unit.expanded .cmp-mini { display: none; }
.cmp-detail-panel { margin-top: 0; background: var(--panel); border: 1px solid var(--def); border-radius: 10px; padding: 10px 12px; font-size: 13px; }
.cmp-detail-panel[hidden] { display: none; }
.cd-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.cd-head .ru-sub { display: inline; }
.cd-head .reset-btn { margin-left: auto; }
.cd-mini { display: none; font-size: 11.5px; font-weight: 700; color: var(--text-dim); white-space: nowrap; font-variant-numeric: tabular-nums; }
.cmp-detail-panel { display: none; }
/* 3: phones, attacker and defender side by side. The cards show the unit; the weapons are the
   row above the funnel, and ✎ Edit opens the full table (one column again while it's open). */
@media (max-width: 760px) {
  .setup-grid { grid-template-columns: minmax(0, 1fr) 26px minmax(0, 1fr); gap: 8px 5px; }
  .setup-grid:has(.setup-col.editing) { grid-template-columns: minmax(0, 1fr); }
  .setup-grid:has(.setup-col.editing) .def-stack { display: grid; }
  .def-stack { display: contents; }
  .mods-card { grid-column: 1 / -1; padding: 8px 10px; }
  .setup-grid:not(:has(.editing)) .setup-col { padding: 8px 8px 6px; border-radius: 10px; }
  .setup-grid:not(:has(.editing)) .side-label { font-size: 11px; letter-spacing: 0.04em; margin-bottom: 4px; }
  .setup-grid:not(:has(.editing)) select { font-size: 12px; padding: 4px 5px; margin-bottom: 4px; }
  .setup-grid:not(:has(.editing)) .statline { padding: 3px 2px; gap: 1px; margin-bottom: 4px; }
  .setup-grid:not(:has(.editing)) .statline .stat .v { font-size: 11.5px; }
  .setup-grid:not(:has(.editing)) .statline .stat .k { font-size: 8px; }
  .setup-grid:not(:has(.editing)) .wr-summary { display: none; }
  .setup-grid:not(:has(.editing)) .edit-bar { justify-content: flex-end; }
  .setup-grid:not(:has(.editing)) .edit-bar { flex-wrap: wrap; gap: 2px 6px; margin: 0; }
  .setup-grid:not(:has(.editing)) .edit-btn { font-size: 11px; padding: 3px 7px; }
  .setup-col:not(.editing) .wpick, #defCol:not(.editing) #defWeapon { display: none; }
  /* Folded, each card keeps just its Models box, small. */
  .setup-grid:not(:has(.editing)) .weapon-row { grid-template-columns: minmax(0, 1fr); margin-top: 2px; }
  .setup-grid:not(:has(.editing)) .weapon-row .weapon-label { display: none; }
  .setup-grid:not(:has(.editing)) .weapon-row label.keep { flex-direction: row; align-items: center; justify-content: space-between; gap: 6px; font-size: 10.5px; }
  .setup-grid:not(:has(.editing)) .weapon-row label.keep input { width: 52px; height: 24px; font-size: 12px; padding: 2px 4px; }
  .setup-swap { align-self: start; margin-top: 44px; }
  .setup-grid:not(:has(.editing)) #swapBtn { width: 26px; height: 26px; padding: 0; border-radius: 8px; font-size: 13px; }
  .setup-grid:not(:has(.editing)) #swapBtn span:not(:first-child) { display: none; }
  .ans-num { font-size: 40px; }
  .ans-of { font-size: 15px; }
  .flow-legend { font-size: 10.5px; gap: 2px 10px; margin: 4px 0; }

  /* Army vs Army: two columns once rows are one line; the tapped target's breakdown sits below. */
  .roster-grid { grid-template-columns: minmax(0, 1fr) 22px minmax(0, 1fr); gap: 6px 4px; }
  .roster-grid:has(.roster-empty), .roster-grid.expand-all { grid-template-columns: minmax(0, 1fr); }
  .roster-grid:not(:has(.roster-empty)):not(.expand-all) .roster-swap { order: 0; padding-top: 34px; }
  .roster-grid:not(:has(.roster-empty)):not(.expand-all) #rosterSwap { width: 22px; padding: 6px 0; font-size: 12px; }
  .roster-grid:not(:has(.roster-empty)):not(.expand-all) #rosterSwap span { display: none; }
  .roster-grid:not(.expand-all) .roster-col { padding: 7px 6px; }
  .roster-grid:not(.expand-all) .side-label { font-size: 11px; margin-bottom: 2px; }
  .roster-grid:not(.expand-all) .src-tabs { margin: 4px 0 6px; }
  .roster-grid:not(:has(.roster-empty)):not(.expand-all) .src-tabs .st-long { display: none; }
  .roster-grid:not(:has(.roster-empty)):not(.expand-all) .src-tabs .st-short { display: inline; }
  .roster-grid:not(.expand-all) .src-tabs button { font-size: 10.5px; padding: 4px 2px; min-width: 0; }
  .roster-grid:not(.expand-all) .roster-unit { padding: 5px 4px; font-size: 12px; }
  .roster-grid:not(.expand-all) .ru-sub { font-size: 10px; }
  .roster-grid:not(.expand-all) .ru-pts { font-size: 10.5px; }
  .roster-grid:not(.expand-all) .ru-top { gap: 4px; align-items: flex-start; }
  .roster-grid:not(.expand-all) .roster-name { font-size: 12.5px; }
  .roster-grid:not(.expand-all) .roster-meta, .roster-grid:not(.expand-all) .roster-role { font-size: 9.5px; }
  .roster-grid:not(.expand-all) .roster-head { flex-wrap: wrap; gap: 2px 6px; }
  .roster-grid:not(.expand-all) .det-pick select, .roster-grid:not(.expand-all) .src-pick select { font-size: 11px; padding: 3px 4px; }
  .roster-grid:not(.expand-all) .src-types button { font-size: 10.5px; }
  .roster-grid:not(.expand-all) .src-note { font-size: 10.5px; }
  .roster-grid:not(.expand-all) .att-badge, .roster-grid:not(.expand-all) .best-badge { font-size: 8.5px; margin-left: 0; }
  .roster-grid:not(.expand-all) .cmp-mini { gap: 4px; font-size: 10.5px; }
  .roster-grid:not(.expand-all) .cm-p { width: 26px; }
  .roster-grid:not(.expand-all) .cm-pts { display: none; }
  .roster-grid:not(.expand-all) .roster-unit.expanded .cmp-mini { display: flex; }
  .roster-grid:not(.expand-all) .cmp-inline { display: none; }
  /* A tapped target's breakdown: a sheet along the bottom of the screen, above the tabs, while
     the lists are on screen (T-143). Tap other units and it follows; ✕ closes it. */
  .roster-grid:not(.expand-all) .cmp-detail-panel:not([hidden]) {
    display: block; position: fixed; left: 0; right: 0; bottom: calc(54px + env(safe-area-inset-bottom, 0px)); z-index: 15;
    max-height: 38svh; overflow-y: auto; overscroll-behavior: contain; margin: 0; padding: 0 12px 10px; font-size: 12px;
    border: 1px solid var(--def); border-bottom: none; border-radius: 14px 14px 0 0; box-shadow: 0 -10px 28px var(--shadow);
    transition: transform 0.2s ease, visibility 0.2s;
  }
  .roster-grid:not(.expand-all) .cmp-detail-panel.away { transform: translateY(calc(100% + 80px)); visibility: hidden; }
  .cmp-detail-panel .cd-head { position: sticky; top: 0; background: var(--panel); margin: 0 -12px 4px; padding: 10px 12px 6px; z-index: 1; border-bottom: 1px solid var(--border); }
  .cmp-detail-panel .cd-head { cursor: pointer; }
  .cmp-detail-panel .cd-head b { font-size: 13.5px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .cmp-detail-panel .cd-head .ru-sub { white-space: nowrap; }
  .cmp-detail-panel.min .cd-body { display: none; }
  .cmp-detail-panel.min { padding-bottom: 0; }
  .cmp-detail-panel.min .cd-head { margin-bottom: 0; border-bottom: none; }
  .cmp-detail-panel.min .cd-mini { display: inline; }
  .roster-section:has(.cmp-detail-panel.min:not([hidden])) { padding-bottom: 60px; }
  .cmp-detail-panel .cd-head::before { content: ""; position: absolute; left: 50%; top: 4px; width: 36px; height: 4px; margin-left: -18px; border-radius: 2px; background: var(--border); }
  /* Room under the lists so the sheet never hides the last units. */
  .roster-section:has(.cmp-detail-panel:not([hidden])) { padding-bottom: 38svh; }
  @media (prefers-reduced-motion: reduce) { .cmp-detail-panel { transition: none; } }
  .bd-bar { padding: 6px; gap: 4px; }
  .bd-bar .btn, .bd-bar .mode-switch button { font-size: 11px; padding: 4px 7px; }
  .bd-bar .so-actions { gap: 4px; }
  .cmp-detail-panel .cmp-weps { padding-left: 6px; }
  .roster-grid:not(.expand-all) #roster1 .roster-unit.expanded { border-color: var(--def); background: color-mix(in srgb, var(--def) 12%, var(--panel)); }
}
@media (max-width: 480px) {
  .rk-stats { font-size: 12px; }
  .rk-stats th, .rk-stats td { padding-left: 5px; padding-right: 5px; }
  .rk-weps { font-size: 11px; }
  .rk-weps td, .rk-weps th { padding-left: 2px; padding-right: 2px; }
}

/* Text for screen readers only: the answer's line of numbers, which the funnel shows as a picture. */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- characters joined to the target (T-145) ---------- */
.joins { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.join-m { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 4px; padding: 5px 4px 6px 8px; border-radius: 9px; background: var(--warn-bg); font-size: 12px; }
.join-role { font-size: 10px; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase; color: var(--amber); }
.join-x { border: 0; background: none; color: var(--text-dim); font-size: 14px; line-height: 1; padding: 2px 5px; border-radius: 6px; cursor: pointer; }
.join-x:hover { color: var(--red); }
.join-n { grid-column: 1 / -1; font-weight: 700; font-size: 12.5px; min-width: 0; overflow-wrap: anywhere; }
.join-st { grid-column: 1 / -1; color: var(--text-dim); font-size: 11px; font-variant-numeric: tabular-nums; }
.join-adds { display: flex; flex-wrap: wrap; gap: 6px; }
.join-add { border: 1px dashed var(--amber); color: var(--amber); background: none; font: inherit; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 99px; cursor: pointer; }
.join-add[aria-expanded="true"] { background: var(--warn-bg); border-style: solid; }
.join-menu { border: 1px solid var(--border); background: var(--panel); border-radius: 10px; box-shadow: 0 6px 20px var(--shadow); overflow: hidden; max-height: 260px; overflow-y: auto; }
.join-mh { font-size: 11px; color: var(--text-faint); padding: 6px 10px 4px; }
.join-menu button { display: flex; flex-wrap: wrap; width: 100%; justify-content: space-between; align-items: baseline; column-gap: 8px; row-gap: 2px; border: 0; border-top: 1px solid var(--border); background: none; color: var(--text); font: inherit; font-size: 12.5px; padding: 7px 10px; cursor: pointer; text-align: left; }
.join-menu button:hover, .join-menu button:focus-visible { background: var(--warn-bg); }
.join-menu small { color: var(--text-dim); white-space: nowrap; }
.ans-lead { display: flex; flex-direction: column; gap: 4px; margin: 4px 0 2px; }
.ans-lead-l { font-size: 13.5px; padding: 6px 10px; border-radius: 10px; background: var(--warn-bg); }
.ans-lead-l b { color: var(--amber); font-variant-numeric: tabular-nums; }
.join-ws { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 3px; }
.join-ws .join-st { width: auto; }
.join-w { border: 1px solid var(--border); background: var(--panel); color: var(--text-dim); font: inherit; font-size: 11px; padding: 2px 8px; border-radius: 99px; cursor: pointer; }
.join-w[aria-pressed="true"] { border-color: var(--amber); color: var(--text); font-weight: 700; }
.wp-lead > :nth-child(2) { color: var(--amber); text-transform: none; letter-spacing: 0; font-size: 11.5px; }
.wp-edit { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; padding: 4px 4px 8px 26px; border-bottom: 1px solid var(--border); }
.wp-edit label { display: flex; flex-direction: column; gap: 2px; font-size: 10px; font-weight: 700; color: var(--text-faint); text-transform: uppercase; }
.wp-edit input { width: 100%; min-width: 0; font-size: 12.5px; padding: 3px 4px; }
.join-pick { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 2px; margin-top: 4px; font-size: 11px; color: var(--text-dim); }
.join-pick select { font: inherit; font-size: 12px; padding: 3px 6px; border: 1px solid var(--border); border-radius: 7px; background: var(--panel); color: var(--text); max-width: 100%; }
.ru-joined { color: var(--amber); }
.ru-split { align-self: flex-start; border: 0; background: none; color: var(--text-dim); font: inherit; font-size: 11.5px; padding: 0 4px 4px; margin-top: -2px; cursor: pointer; text-decoration: underline; }
.ru-join { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-dim); padding: 0 4px 4px; margin-top: -2px; }
.ru-join select { font: inherit; font-size: 11.5px; padding: 2px 4px; border: 1px solid var(--border); border-radius: 6px; background: var(--panel); color: var(--text); max-width: 100%; min-width: 0; }
.cm-lead { font-size: 11px; font-weight: 700; color: var(--amber); white-space: nowrap; font-variant-numeric: tabular-nums; }
.cmp-lead { display: block; font-size: 12px; color: var(--amber); margin-top: 4px; }

/* The beta site's marker (T-179): shown only on beta.tacticalreroll.com and *.pages.dev. */
.beta-flag { position: fixed; left: 8px; bottom: calc(env(safe-area-inset-bottom, 0px) + 72px); z-index: 60; padding: 3px 8px; border-radius: 6px; background: var(--amber); color: #111827; font: 800 11px/1.2 Inter, system-ui, sans-serif; letter-spacing: 0.08em; pointer-events: none; opacity: 0.9; }

/* Supporter sign-in sheet (T-116): a bottom sheet on phones, a centred card on wider screens. */
.sup-sheet { position: fixed; inset: 0; z-index: 90; display: flex; align-items: flex-end; justify-content: center; }
.sup-back { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.55); }
.sup-card { position: relative; width: 100%; max-width: 440px; box-sizing: border-box; background: var(--panel); color: var(--text); border-top: 2px solid var(--gold); border-radius: 16px 16px 0 0; padding: 18px 18px calc(22px + env(safe-area-inset-bottom, 0px)); box-shadow: 0 -8px 30px var(--shadow); }
@media (min-width: 700px) { .sup-sheet { align-items: center; } .sup-card { border-radius: 16px; border: 1px solid var(--border); border-top: 2px solid var(--gold); } }
.sup-x { position: absolute; top: 8px; right: 8px; width: 44px; height: 44px; border: 0; background: none; color: var(--text-dim); font-size: 18px; cursor: pointer; border-radius: 10px; }
.sup-kicker { font-size: 11px; font-weight: 800; letter-spacing: 0.08em; color: var(--gold); }
.sup-card h2 { margin: 6px 0 8px; font-size: 20px; }
.sup-p { margin: 0 0 12px; font-size: 13.5px; line-height: 1.5; color: var(--text-2); }
.sup-form { display: flex; flex-direction: column; gap: 12px; }
.sup-l { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 700; color: var(--text-dim); }
.sup-l input { font: inherit; font-size: 16px; padding: 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--panel-3); color: var(--text); }
.sup-l input.sup-code { font-size: 24px; letter-spacing: 0.3em; text-align: center; }
.sup-go { min-height: 48px; border: 0; border-radius: 10px; background: var(--gold); color: #111827; font: inherit; font-size: 15px; font-weight: 800; cursor: pointer; }
.sup-go[disabled] { opacity: 0.6; cursor: wait; }
.sup-ghost { margin-top: 8px; width: 100%; min-height: 44px; border: 1px solid var(--border); border-radius: 10px; background: none; color: var(--text-dim); font: inherit; font-size: 13px; cursor: pointer; }
.sup-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.sup-chip { padding: 5px 10px; border-radius: 99px; border: 1px solid var(--border); font-size: 12px; font-weight: 700; color: var(--text-2); }
.sup-chip.gold { border-color: var(--amber); color: var(--gold); background: var(--warn-bg); }
.sup-note { margin: 0; font-size: 12px; color: var(--text-faint); line-height: 1.5; }
.sup-msg { margin: 12px 0 0; font-size: 13px; color: var(--red); }
.sup-ok { margin: 0 0 10px; font-size: 13.5px; font-weight: 700; color: var(--gold); }
.sup-l input.sup-gift { font-size: 20px; letter-spacing: 0.12em; text-align: center; text-transform: uppercase; }
:root[data-theme="light"] .sup-kicker, :root[data-theme="light"] .sup-chip.gold, :root[data-theme="light"] .sup-ok { color: #8a6100; }

