:root {
  --text-xs: clamp(0.75rem, 0.72rem + 0.1vw, 0.8rem);
  --text-sm: clamp(0.8125rem, 0.78rem + 0.15vw, 0.875rem);
  --text-base: clamp(0.9375rem, 0.9rem + 0.15vw, 1rem);
  --text-lg: clamp(1.125rem, 1.05rem + 0.3vw, 1.3rem);
  --text-xl: clamp(1.4rem, 1.2rem + 0.8vw, 1.9rem);
  --font-display: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --font-body: 'IBM Plex Sans', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
  --r: 8px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
}
[data-theme='dark'] {
  color-scheme: dark;
  --bg: #0d100f;
  --surface: #141917;
  --surface-2: #1a201e;
  --surface-3: #222a27;
  --border: #2a332f;
  --border-strong: #3a4540;
  --text: #e4e9e6;
  --muted: #8d9993;
  --faint: #5e6a64;
  --cpt: #e8b33a;
  --cpt-soft: rgba(232, 179, 58, 0.14);
  --accent: #4fb38a;
  --accent-soft: rgba(79, 179, 138, 0.14);
  --danger: #e0685a;
  --danger-soft: rgba(224, 104, 90, 0.14);
  --teamA: #6aa3e8;
  --teamB: #e8806a;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.02), 0 8px 24px rgba(0, 0, 0, 0.25);
}
[data-theme='light'] {
  color-scheme: light;
  --bg: #f3f1ec;
  --surface: #fbfaf7;
  --surface-2: #f2f0ea;
  --surface-3: #e8e5dd;
  --border: #dcd8ce;
  --border-strong: #c6c1b5;
  --text: #1b201e;
  --muted: #5d6762;
  --faint: #8b938f;
  --cpt: #a8740a;
  --cpt-soft: rgba(168, 116, 10, 0.12);
  --accent: #1f7d58;
  --accent-soft: rgba(31, 125, 88, 0.1);
  --danger: #b6422f;
  --danger-soft: rgba(182, 66, 47, 0.1);
  --teamA: #2a64b0;
  --teamB: #b8502f;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
h2, h3, h4 { font-family: var(--font-display); font-weight: 600; letter-spacing: 0.02em; margin: 0; }
h2 { font-size: var(--text-lg); text-transform: uppercase; }
h3 { font-size: var(--text-base); text-transform: uppercase; color: var(--muted); margin-bottom: var(--s3); }
h4 { font-size: var(--text-base); text-transform: uppercase; margin: var(--s4) 0 var(--s1); }
.hidden { display: none !important; }
.r { text-align: right; }
.c { text-align: center; }
.mono, td.r { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* top bar */
.topbar {
  display: flex; align-items: center; gap: var(--s5);
  padding: var(--s3) var(--s5);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky; top: 0; z-index: 20;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: var(--s3); }
.logo { width: 34px; height: 34px; color: var(--text); flex-shrink: 0; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: var(--text-lg); text-transform: uppercase; letter-spacing: 0.04em; line-height: 1; }
.brand-sub { color: var(--muted); font-size: var(--text-xs); margin-top: 2px; }
.game-strip { display: flex; align-items: center; gap: var(--s3); font-family: var(--font-display); font-size: var(--text-lg); font-weight: 600; margin-left: auto; margin-right: auto; }
.game-strip .tm { padding: 2px 10px; border-radius: 4px; letter-spacing: 0.05em; }
.game-strip .tmA { background: color-mix(in srgb, var(--teamA) 18%, transparent); color: var(--teamA); }
.game-strip .tmB { background: color-mix(in srgb, var(--teamB) 18%, transparent); color: var(--teamB); }
.game-strip .at { color: var(--faint); font-size: var(--text-sm); }
.game-strip .cap { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--muted); font-weight: 500; margin-left: var(--s3); }
.top-actions { display: flex; gap: var(--s2); align-items: center; }

/* buttons */
.btn {
  border: 1px solid var(--border-strong); background: var(--surface-2);
  padding: 7px 14px; border-radius: 6px; cursor: pointer;
  font-size: var(--text-sm); font-weight: 500;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-ghost { background: transparent; }
.btn-primary { background: var(--cpt); border-color: var(--cpt); color: #1a1405; font-weight: 600; }
.btn-primary:hover { background: color-mix(in srgb, var(--cpt) 88%, white); }
.btn-sim { background: var(--accent); border-color: var(--accent); color: #04140d; font-weight: 600; }
.btn-sim:hover { background: color-mix(in srgb, var(--accent) 88%, white); }
[data-theme='light'] .btn-primary, [data-theme='light'] .btn-sim { color: #fff; }
.wide { width: 100%; margin-top: var(--s3); padding: 10px; font-family: var(--font-display); font-size: var(--text-base); text-transform: uppercase; letter-spacing: 0.06em; }
.icon-btn { background: transparent; border: 1px solid var(--border-strong); border-radius: 6px; width: 34px; height: 34px; display: grid; place-items: center; cursor: pointer; }
.file-btn { display: inline-flex; align-items: center; }
button:focus-visible, input:focus-visible, select:focus-visible, .tab:focus-visible { outline: 2px solid var(--cpt); outline-offset: 2px; }

/* layout */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  grid-template-areas: 'pool ctl' 'res ctl';
  gap: var(--s4);
  padding: var(--s4) var(--s5);
  align-items: start;
}
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow); min-width: 0; }
.pool-panel { grid-area: pool; padding: var(--s4); }
.control-panel { grid-area: ctl; padding: var(--s4); position: sticky; top: 76px; max-height: calc(100dvh - 92px); overflow-y: auto; }
.results-panel { grid-area: res; padding: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); flex-wrap: wrap; margin-bottom: var(--s2); }
.pool-tools { display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center; }
.pool-tools input[type='search'] { background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 5px 10px; width: 160px; }
.note { color: var(--muted); font-size: var(--text-xs); margin-bottom: var(--s2); }

.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.seg button { background: transparent; border: 0; padding: 4px 10px; cursor: pointer; font-size: var(--text-xs); font-weight: 600; color: var(--muted); border-right: 1px solid var(--border); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--surface-3); color: var(--text); }

/* tables */
.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: 6px; }
.pool-wrap { max-height: 520px; }
table.grid { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.grid th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface-2); color: var(--muted);
  font-family: var(--font-display); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; font-size: var(--text-xs);
  text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.grid th[data-sort], .grid th[data-ssort] { cursor: pointer; user-select: none; }
.grid th[data-sort]:hover, .grid th[data-ssort]:hover { color: var(--text); }
.grid th.sorted { color: var(--cpt); }
.grid td { padding: 5px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.grid tbody tr:hover td { background: var(--surface-2); }
.grid tr.excluded td { opacity: 0.38; }
.grid tr.locked td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.grid tr.cptlocked td:first-child { box-shadow: inset 3px 0 0 var(--cpt); }
.grid tr.selected td { background: var(--cpt-soft); }
.grid td input.cell {
  width: 64px; text-align: right; background: transparent; border: 1px solid transparent; border-radius: 4px; padding: 2px 4px;
  font-family: var(--font-mono); font-size: var(--text-sm);
}
.grid td input.cell:hover { border-color: var(--border-strong); }
.grid td input.cell:focus { border-color: var(--cpt); background: var(--surface-2); outline: none; }
.grid td input.cell.sal { width: 72px; }
.pname { font-weight: 500; }
.pos { font-family: var(--font-mono); font-size: var(--text-xs); font-weight: 600; padding: 1px 6px; border-radius: 3px; background: var(--surface-3); }
.tmchip { font-family: var(--font-mono); font-size: var(--text-xs); font-weight: 600; }
.tmchip.A { color: var(--teamA); }
.tmchip.B { color: var(--teamB); }
.up { color: var(--accent); }
.down { color: var(--danger); }

.rulebtns { display: inline-flex; gap: 3px; }
.rulebtns button {
  width: 22px; height: 22px; border-radius: 4px; border: 1px solid var(--border-strong); background: transparent; cursor: pointer;
  font-family: var(--font-mono); font-size: 11px; font-weight: 600; color: var(--faint); padding: 0;
}
.rulebtns button.on.l { background: var(--accent); border-color: var(--accent); color: #04140d; }
.rulebtns button.on.c { background: var(--cpt); border-color: var(--cpt); color: #1a1405; }
.rulebtns button.on.x { background: var(--danger); border-color: var(--danger); color: #fff; }
.legend { display: flex; flex-wrap: wrap; gap: var(--s4); color: var(--muted); font-size: var(--text-xs); margin-top: var(--s2); align-items: center; }
.tag { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 3px; font-family: var(--font-mono); font-size: 11px; margin-right: 4px; }
.tag.lock { background: var(--accent); color: #04140d; }
.tag.cptlock { background: var(--cpt); color: #1a1405; }
.tag.excl { background: var(--danger); color: #fff; }

/* controls */
.ctl-section { padding-bottom: var(--s4); margin-bottom: var(--s4); border-bottom: 1px solid var(--border); }
.ctl-section:last-child { border-bottom: 0; margin-bottom: 0; padding-bottom: 0; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); margin-top: var(--s2); }
.field-row.three { grid-template-columns: 1fr 1fr 1fr; }
.field-row label, .block-label { display: flex; flex-direction: column; gap: 3px; font-size: var(--text-xs); color: var(--muted); font-weight: 500; }
.block-label { margin-top: var(--s3); }
.field-row input[type='number'], .field-row select, .rule select {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: 5px 7px; color: var(--text); font-family: var(--font-mono); font-size: var(--text-sm); width: 100%;
}
.rule select { width: auto; padding: 1px 4px; font-size: var(--text-xs); }
input[type='range'] { accent-color: var(--cpt); width: 100%; }
output { font-family: var(--font-mono); color: var(--text); font-size: var(--text-xs); }
.implied { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s2); font-family: var(--font-mono); font-size: var(--text-xs); }
.implied span { flex: 1; padding: 5px 8px; border-radius: 5px; background: var(--surface-2); border: 1px solid var(--border); }
.script-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 4px; }
.script-grid button {
  text-align: left; border: 1px solid var(--border); background: var(--surface-2); border-radius: 6px; padding: 7px 9px; cursor: pointer;
  font-size: var(--text-xs); font-weight: 600; color: var(--muted); line-height: 1.25;
}
.script-grid button:hover { border-color: var(--border-strong); color: var(--text); }
.script-grid button.on { border-color: var(--cpt); color: var(--text); background: var(--cpt-soft); }
.script-grid button:first-child { grid-column: span 2; }
.hint { color: var(--muted); font-size: var(--text-xs); margin: var(--s2) 0 0; }
.rule { display: flex; gap: var(--s3); align-items: center; padding: 5px 0; }
.rule-text { font-size: var(--text-sm); line-height: 1.3; }
.switch { position: relative; width: 32px; height: 18px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--surface-3); border: 1px solid var(--border-strong); border-radius: 18px; cursor: pointer; transition: 0.15s; }
.switch span::after { content: ''; position: absolute; width: 12px; height: 12px; left: 2px; top: 2px; border-radius: 50%; background: var(--muted); transition: 0.15s; }
.switch input:checked + span { background: var(--accent-soft); border-color: var(--accent); }
.switch input:checked + span::after { transform: translateX(14px); background: var(--accent); }
.switch input:focus-visible + span { outline: 2px solid var(--cpt); outline-offset: 2px; }
.mix { display: grid; gap: 4px; }
.mix-row { display: grid; grid-template-columns: 1fr 90px 36px; gap: var(--s2); align-items: center; font-size: var(--text-xs); color: var(--muted); }
.mix-row output { text-align: right; }
.status { margin-top: var(--s2); font-size: var(--text-xs); color: var(--muted); min-height: 1.2em; font-family: var(--font-mono); }
.status.err { color: var(--danger); }

/* results */
.tabs { display: flex; border-bottom: 1px solid var(--border); padding: 0 var(--s3); overflow-x: auto; }
.tab {
  background: transparent; border: 0; padding: 12px 14px; cursor: pointer; color: var(--muted);
  font-family: var(--font-display); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; font-size: var(--text-base);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab.active { color: var(--text); border-bottom-color: var(--cpt); }
.tab-body { padding: var(--s4); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: var(--s2); margin-bottom: var(--s4); }
.kpis:empty { display: none; }
.kpi { background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 9px 12px; }
.kpi .k { font-size: var(--text-xs); color: var(--muted); text-transform: uppercase; font-family: var(--font-display); letter-spacing: 0.05em; font-weight: 600; }
.kpi .v { font-family: var(--font-mono); font-size: var(--text-lg); font-weight: 600; margin-top: 2px; }
.empty { color: var(--muted); padding: var(--s6) var(--s4); text-align: center; border: 1px dashed var(--border-strong); border-radius: 8px; max-width: 640px; margin: 0 auto; line-height: 1.6; }
.lineup-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: var(--s3); }
.lineup-grid > .empty { grid-column: 1 / -1; }
.lu {
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); overflow: hidden; cursor: pointer; transition: border-color 0.15s;
}
.lu:hover { border-color: var(--border-strong); }
.lu.sel { border-color: var(--cpt); }
.lu-head { display: flex; justify-content: space-between; align-items: baseline; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.lu-head .n { font-family: var(--font-display); font-weight: 700; font-size: var(--text-base); }
.lu-head .pts { font-family: var(--font-mono); font-weight: 600; }
.lu-head .sal { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--muted); }
.lu-row { display: grid; grid-template-columns: 38px 1fr 34px 54px 44px; gap: 6px; align-items: center; padding: 4px 10px; font-size: var(--text-sm); }
.lu-row .slot { font-family: var(--font-mono); font-size: 11px; font-weight: 600; color: var(--faint); }
.lu-row.cpt { background: var(--cpt-soft); }
.lu-row.cpt .slot { color: var(--cpt); }
.lu-row .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lu-row .num { font-family: var(--font-mono); text-align: right; font-size: var(--text-xs); color: var(--muted); }
.lu-row .num.p { color: var(--text); }
.lu-tags { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px 10px; border-top: 1px solid var(--border); }
.chip { font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 10px; background: var(--surface-3); color: var(--muted); font-family: var(--font-mono); }
.chip.stack { background: var(--cpt-soft); color: var(--cpt); }
.chip.bb { background: var(--accent-soft); color: var(--accent); }

.sim-layout { display: grid; grid-template-columns: 1fr; gap: var(--s4); }
.sim-layout .table-wrap { max-height: 460px; }
.sim-side { display: grid; grid-template-columns: 1.4fr 1fr; gap: var(--s3); align-content: start; }
.chart-card { border: 1px solid var(--border); border-radius: 8px; padding: var(--s3); background: var(--surface-2); }
.chart-title { font-family: var(--font-display); font-weight: 600; text-transform: uppercase; font-size: var(--text-sm); letter-spacing: 0.04em; color: var(--muted); margin-bottom: var(--s2); }
.chart-box { position: relative; height: 220px; }
.sub-h { margin-top: var(--s5); }
#playerSimTable { }
.bar-row { display: grid; grid-template-columns: 110px 1fr 52px; gap: var(--s2); align-items: center; font-size: var(--text-xs); margin: 5px 0; }
.bar-row .track { height: 10px; background: var(--surface-3); border-radius: 5px; overflow: hidden; }
.bar-row .fill { height: 100%; background: var(--cpt); border-radius: 5px; }
.bar-row .val { font-family: var(--font-mono); text-align: right; }
.win-bar { display: inline-block; height: 6px; background: var(--accent); border-radius: 3px; vertical-align: middle; margin-right: 6px; }

.corr-wrap { overflow: auto; margin-top: var(--s3); }
table.corr { border-collapse: separate; border-spacing: 2px; font-family: var(--font-mono); font-size: 11px; }
table.corr th { font-family: var(--font-body); font-weight: 500; color: var(--muted); padding: 3px 6px; white-space: nowrap; font-size: 11px; }
table.corr th.rot { writing-mode: vertical-rl; transform: rotate(180deg); text-align: left; height: 110px; }
table.corr td { width: 42px; height: 30px; text-align: center; border-radius: 3px; }

#exportBox { width: 100%; min-height: 300px; margin-top: var(--s3); background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: var(--s3); font-family: var(--font-mono); font-size: var(--text-xs); resize: vertical; }
.export-actions { display: flex; align-items: center; gap: var(--s3); margin-top: var(--s3); }

.method { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s6); max-width: 1100px; }
.method p { color: var(--muted); margin: 0 0 var(--s2); max-width: 62ch; }
.method h4:first-child { margin-top: 0; }
table.mini { width: auto; margin: var(--s2) 0; }
table.mini th { position: static; }

.foot { color: var(--faint); font-size: var(--text-xs); text-align: center; padding: var(--s4) var(--s5) var(--s6); }

@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; grid-template-areas: 'pool' 'ctl' 'res'; }
  .control-panel { position: static; max-height: none; }
  .sim-side, .method { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .layout { padding: var(--s2); gap: var(--s2); }
  .topbar { padding: var(--s2) var(--s3); gap: var(--s2); }
  .game-strip { order: 3; width: 100%; justify-content: center; font-size: var(--text-base); }
  .brand-sub { display: none; }
  .topbar { position: static; }
  .top-actions { margin-left: auto; }
  .top-actions .btn { padding: 6px 9px; font-size: var(--text-xs); }
  .field-row.three { grid-template-columns: 1fr 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.brand-by { color: var(--cpt); font-weight: 600; }

.slate-pick { background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 6px; padding: 7px 10px; font-size: var(--text-sm); font-weight: 500; cursor: pointer; }
.inj { font-family: var(--font-mono); font-size: 10px; font-weight: 600; padding: 1px 5px; border-radius: 3px; background: var(--danger-soft); color: var(--danger); margin-left: 6px; vertical-align: middle; }
.src { color: var(--faint); font-size: 10px; margin-left: 4px; }
.zero-tog { display: inline-flex; align-items: center; gap: 5px; font-size: var(--text-xs); color: var(--muted); cursor: pointer; }
.zero-tog input { accent-color: var(--cpt); }

select { background-color: var(--surface-2); color: var(--text); }
select option, select optgroup { background-color: var(--surface); color: var(--text); }
select option:disabled { color: var(--faint); }
.slate-pick { color: var(--text); background-color: var(--surface-2); min-width: 190px; }

.btn-live { display: inline-flex; align-items: center; gap: 6px; border-color: var(--accent); color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.btn-live:hover { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.btn-live.busy svg { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.refresh-msg { color: var(--accent); }
.refresh-msg:empty { display: none; }
@media (max-width: 640px) { .btn-live span { display: none; } }

#exportBox { white-space: pre; overflow-x: auto; min-height: 220px; }
.idtag { display: block; font-family: var(--font-mono); font-size: 11px; color: var(--faint); }
.mini-exp td { vertical-align: top; }

.lu-toolbar { display: flex; align-items: center; gap: var(--s2); margin-bottom: var(--s3); flex-wrap: wrap; }
.lu-toolbar label { font-family: var(--font-display); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; font-size: var(--text-sm); color: var(--muted); }
.lu-toolbar select { background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 6px; padding: 6px 9px; font-size: var(--text-sm); }
.lu-toolbar .hint { margin: 0; }

.preset-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); margin-bottom: var(--s2); }
#presetPick button { padding: 5px 12px; font-size: var(--text-xs); }
#presetPick button.on { background: var(--cpt-soft); color: var(--cpt); }

.lev-block { border: 1px solid var(--border); border-radius: 8px; padding: var(--s3); margin-bottom: var(--s3); background: var(--surface-2); }
.lev-head { display: flex; justify-content: space-between; align-items: baseline; }
.lev-head label { font-family: var(--font-display); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; font-size: var(--text-sm); }
.lev-head output { font-family: var(--font-mono); color: var(--cpt); }
#leverage { width: 100%; margin: 6px 0 2px; accent-color: var(--cpt); }
.lev-row { display: flex; align-items: flex-end; gap: var(--s2); margin-top: var(--s2); }
.lev-row .lev-field { flex: 1; display: flex; flex-direction: column; gap: 4px; font-size: var(--text-xs); color: var(--muted); }
.lev-row input { background: var(--surface); border: 1px solid var(--border-strong); border-radius: 6px; padding: 6px 8px; width: 100%; }
.btn-sm { padding: 6px 10px; font-size: var(--text-xs); white-space: nowrap; }
.cell.own { width: 50px; }
.cell.own.man { color: var(--cpt); font-weight: 600; }
.chip.own { border-color: var(--border-strong); }

.implied .line-src { flex-basis: 100%; color: var(--muted); }
.sp-tag { font-family: var(--font-mono); font-size: 10px; font-weight: 600; padding: 1px 5px; border-radius: 3px; background: var(--cpt-soft); color: var(--cpt); margin-left: 6px; vertical-align: middle; }

/* Backtest */
.bt-bar { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.bt-bar .hint { margin: 0; }
.bt-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: var(--s3); margin-bottom: var(--s4); }
@media (max-width: 900px) { .bt-grid { grid-template-columns: minmax(0, 1fr); } }
.bt-lu { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: var(--text-sm); line-height: 1.5; }
.bt-lu .pl { white-space: nowrap; }
.bt-lu .pl b { font-family: var(--font-mono); font-weight: 600; margin-left: 3px; color: var(--muted); }
.bt-lu .pl.cpt { color: var(--cpt); font-weight: 600; }
.bt-lu .pl.hit { text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 3px; }
.bt-card { border: 1px solid var(--border); border-radius: 8px; padding: var(--s3); background: var(--surface-2); }
.bt-card h4 { margin: 0 0 var(--s2); font-size: var(--text-sm); }
.bt-card + .bt-card { margin-top: var(--s3); }
td.top1 { color: var(--cpt); font-weight: 700; }
td.top10 { color: var(--accent); font-weight: 600; }
#tab-backtest .kpis { margin-top: var(--s3); }
#btOwnTable td, #btTable td.r { white-space: nowrap; }
.bt-struct { margin-bottom: var(--s4); }
.bt-struct table.mini th { position: static; }
@media (max-width: 600px) { .slate-pick { max-width: 38vw; min-width: 0; text-overflow: ellipsis; } }

/* Captain mix */
.cm-rows { display: grid; gap: 6px; margin: var(--s2) 0; }
.cm-rows.off { opacity: 0.45; }
.cm-row { display: grid; grid-template-columns: 56px minmax(0, 1fr) 84px; gap: var(--s2); align-items: center; font-size: var(--text-xs); color: var(--muted); }
.cm-row output { white-space: nowrap; text-align: right; font-family: var(--font-mono); color: var(--text); }
.cm-num { width: 52px; padding: 1px 4px; font-size: var(--text-xs); background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 4px; color: var(--text); }
.bt-struct-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); flex-wrap: wrap; margin-bottom: var(--s2); }
.bt-struct-head h4 { margin: 0; }
.cm-row input[type='range'] { width: 100%; min-width: 0; }

/* Saved lineups */
.save-btn { margin-left: 8px; font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 6px; border: 1px solid var(--border-strong); background: var(--surface-3); color: var(--muted); cursor: pointer; white-space: nowrap; font-family: var(--font-mono); }
.save-btn:hover { color: var(--text); border-color: var(--cpt); }
.save-btn.on { background: var(--cpt-soft); color: var(--cpt); border-color: var(--cpt); }
.lu.is-saved { border-color: var(--cpt); box-shadow: inset 3px 0 0 var(--cpt); }
.lu-head { align-items: center; gap: 6px; }
.lu-head .from { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--faint); font-weight: 500; }
.lu-toolbar .ml { margin-left: var(--s3); }
.saved-actions { flex-wrap: wrap; margin-bottom: var(--s3); }
.saved-actions .sep { width: 1px; height: 22px; background: var(--border-strong); margin: 0 var(--s1); }
.saved-actions select, .saved-actions input.cell { background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 6px; padding: 6px 8px; font-size: var(--text-sm); }
.saved-actions input.cell { width: 64px; }
#savedExpo { margin-bottom: var(--s3); max-height: 360px; overflow: auto; }
.saved-box { width: 100%; height: 90px; margin-top: var(--s3); background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: var(--s3); font-family: var(--font-mono); font-size: var(--text-xs); white-space: pre; overflow-x: auto; }

/* Actual scores */
.has-act .lu-row { grid-template-columns: 38px 1fr 34px 54px 40px 44px; }
.lu-row .num.a { color: var(--cpt); font-weight: 600; }
.lu-head .act { font-family: var(--font-mono); font-weight: 700; color: var(--cpt); margin-left: 6px; }
.act-col { display: none; }
.has-act .act-col { display: table-cell; color: var(--cpt); font-weight: 600; }
.act-note { margin: 0 0 var(--s3); font-family: var(--font-mono); font-size: var(--text-xs); color: var(--cpt); }
.lu-head { flex-wrap: wrap; row-gap: 2px; }
.lu-head > span { white-space: nowrap; }
.has-act .lu-head .sal { flex-basis: 100%; order: 5; }

/* Gold-area highlight */
.lu.gold-hl { box-shadow: 0 0 0 2px var(--cpt); border-color: var(--cpt); }
.lu.gold-hl .lu-head { background: var(--cpt-soft); }
.lu.gold-hl.is-saved { box-shadow: 0 0 0 2px var(--cpt), inset 3px 0 0 var(--cpt); }
.chip.goldc { background: var(--cpt); color: #1a1407; font-weight: 700; }
.chip[title] { cursor: help; }

/* Delete slate */
.slate-del:hover:not(:disabled) { color: var(--danger, #d9534f); border-color: currentColor; }
.slate-del:disabled { opacity: 0.4; cursor: not-allowed; }

/* Confirmed batting order */
.bo-tag { display: inline-flex; align-items: center; gap: 2px; font-family: var(--font-mono); font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 3px; background: var(--accent); color: #fff; margin-left: 6px; vertical-align: middle; line-height: 1.4; cursor: help; }
[data-theme="dark"] .bo-tag, :root:not([data-theme="light"]) .bo-tag { color: #08130d; }
