:root {
  --bg0: #0b1220;
  --bg1: #121a2b;
  --panel: rgba(18, 26, 43, 0.92);
  --ink: #e8eefc;
  --muted: #8fa0bf;
  --line: rgba(232, 238, 252, 0.12);
  --accent: #3dd6c6;
  --warn: #f0b429;
  --danger: #ff6b6b;
  --red: #ef4444;
  --blue: #3b82f6;
  --font: "IBM Plex Sans", system-ui, sans-serif;
  --display: "Outfit", "IBM Plex Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(61, 214, 198, 0.14), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(99, 102, 241, 0.12), transparent 50%),
    linear-gradient(180deg, var(--bg0), var(--bg1));
}

.top {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: space-between;
  align-items: end;
  padding: 22px 24px 10px;
  border-bottom: 1px solid var(--line);
}
.eyebrow {
  margin: 0 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  color: var(--accent);
}
h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.7rem;
  letter-spacing: -0.02em;
}
.sub { margin: 6px 0 0; color: var(--muted); font-size: 0.9rem; }
.top-actions { display: flex; gap: 8px; }

.phase-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(11, 18, 32, 0.92);
  backdrop-filter: blur(10px);
}
.phase-tab {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}
.phase-tab:hover { color: var(--ink); background: rgba(232, 238, 252, 0.06); }
.phase-tab.active { color: #04201f; background: var(--accent); }

.phase-badge, .sim-badge {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: rgba(232, 238, 252, 0.08);
}
.phase-badge[data-phase="playoffs"] { border-color: rgba(79, 70, 229, 0.5); color: #c7d2fe; }
.sim-badge { background: rgba(126, 34, 206, 0.35); color: #e9d5ff; }
body.sim-active .top { box-shadow: inset 0 -2px 0 rgba(126, 34, 206, 0.55); }

.nav-more {
  position: relative;
  margin-left: 4px;
}
.nav-more summary {
  list-style: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 999px;
}
.nav-more[open] summary {
  color: var(--ink);
  background: rgba(232, 238, 252, 0.08);
}
.nav-more summary::-webkit-details-marker { display: none; }
.nav-more-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 40;
  min-width: 11rem;
  padding: 6px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(15, 23, 42, 0.96);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
  display: grid;
  gap: 2px;
}
.nav-more .phase-tab {
  display: block;
  width: 100%;
  text-align: left;
  border-radius: 8px;
  white-space: nowrap;
}

.ops-rule { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
.sim-ops-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px 14px;
  margin: 10px 0 6px;
}
.sim-match-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--muted);
  flex: 1;
  min-width: 200px;
}
.sim-match-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}
.sim-match-input {
  width: 4.5rem;
  text-align: center;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}
.sim-step {
  min-width: 2.25rem;
  padding: 8px 10px;
  font-size: 1.1rem;
  line-height: 1;
}
.sim-max-hint {
  margin-bottom: 8px;
  white-space: nowrap;
}
body.sim-active .sim-ops-row {
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(126, 34, 206, 0.12);
  border: 1px solid rgba(167, 139, 250, 0.35);
}
.check-row {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  margin: 10px 0;
}
.audit-card { margin-bottom: 12px; }
.audit-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.data.compact td, .data.compact th { padding: 4px 8px; font-size: 0.8rem; }
.locked-row { opacity: 0.85; }
.mini-btn {
  border: 1px solid var(--line);
  background: rgba(232,238,252,0.08);
  color: var(--ink);
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 0.75rem;
}

.view-root { padding: 18px 24px 48px; max-width: 1400px; margin: 0 auto; }
.view-root:has(.alliance-war-room) {
  max-width: 1600px;
  padding-bottom: 16px;
}

.view-head {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  align-items: end;
  margin-bottom: 16px;
}
.view-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.35rem;
}
.view-head .hint { margin: 4px 0 0; color: var(--muted); font-size: 0.85rem; max-width: 52ch; }

.toolbar-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.toolbar-inline input,
.toolbar-inline select {
  background: rgba(0,0,0,0.28);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 8px;
  padding: 9px 11px;
  font-family: var(--mono);
  font-size: 0.85rem;
  min-width: 100px;
}

.ghost-btn,
.primary-btn,
.tool-btn,
.mini-btn {
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font);
}
.ghost-btn {
  background: rgba(232, 238, 252, 0.08);
  color: var(--ink);
  border: 1px solid var(--line);
}
.primary-btn {
  background: var(--accent);
  color: #04201f;
}
.tool-btn {
  width: 100%;
  margin-bottom: 8px;
  background: rgba(232, 238, 252, 0.08);
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 10px 14px;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
}
.mini-btn {
  padding: 4px 8px;
  font-size: 0.75rem;
  background: rgba(232, 238, 252, 0.1);
  color: var(--ink);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 16px;
}
.panel h3 {
  margin: 0 0 10px;
  font-family: var(--display);
  font-size: 1rem;
}
.hint { color: var(--muted); font-size: 0.82rem; }

.table-wrap { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
table.data th {
  background: #1e293b;
  color: #fff;
  text-align: left;
  padding: 8px 10px;
  font-family: var(--display);
  font-weight: 600;
  white-space: nowrap;
}
table.data td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
/* Team column: allow long names to wrap instead of stretching the table */
table.data td:has(.team-label) {
  max-width: min(22rem, 42vw);
  min-width: 7.5rem;
}
table.data tr.toi td { background: rgba(254, 243, 199, 0.12); }
/* TOI tables: compact single-line labels; truncation via .toi-truncate in JS */
table.data.toi-table td:has(.team-label) {
  max-width: none;
  white-space: nowrap;
}
table.data.toi-table .team-label.toi-truncate {
  flex-wrap: nowrap;
  max-width: none;
  white-space: nowrap;
}
table.data.toi-table .team-label.toi-truncate .team-name {
  white-space: nowrap;
}
table.data.toi-compact {
  font-size: 0.8rem;
}
table.data.toi-compact th,
table.data.toi-compact td {
  padding: 5px 6px;
}
table.data.toi-compact th.num,
table.data.toi-compact td.num {
  padding-left: 4px;
  padding-right: 4px;
  text-align: right;
  white-space: nowrap;
}
table.data.toi-compact th.num {
  font-size: 0.72rem;
  letter-spacing: -0.01em;
}
.toi-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
}
.toi-filter-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 4px;
}
.toi-filter-btn {
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.2);
  color: var(--ink);
  font-size: 0.78rem;
  font-family: var(--mono);
  cursor: pointer;
  white-space: nowrap;
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toi-filter-btn:hover {
  border-color: rgba(254, 240, 138, 0.5);
  background: rgba(254, 240, 138, 0.08);
}
.toi-filter-btn.active {
  border-color: #fef08a;
  background: rgba(254, 240, 138, 0.22);
  color: #fef9c3;
  font-weight: 600;
}
table.data tr:hover td { background: rgba(232, 238, 252, 0.04); }
.mono { font-family: var(--mono); }
.num { font-variant-numeric: tabular-nums; font-family: var(--mono); }
td.sos-easy { color: #86efac; font-weight: 600; }
td.sos-hard { color: #fca5a5; font-weight: 600; }

.alliance-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 900px) {
  .alliance-grid { grid-template-columns: 1fr; }
}
.alliance-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.alliance-card.red .card-head { background: rgba(239, 68, 68, 0.18); color: #fecaca; }
.alliance-card.blue .card-head { background: rgba(59, 130, 246, 0.18); color: #bfdbfe; }
.card-head {
  padding: 10px 12px;
  font-family: var(--display);
  font-weight: 700;
}
.robot-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 10px;
}
.robot {
  background: rgba(0,0,0,0.2);
  border-radius: 10px;
  padding: 10px;
}
.robot.pre-fallback { background: rgba(99, 102, 241, 0.12); }
.robot .team-num { font-family: var(--mono); font-size: 1.1rem; font-weight: 700; }
.robot .metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 8px;
  margin-top: 8px;
  font-size: 0.78rem;
}
.robot .metrics em {
  display: block;
  color: var(--muted);
  font-style: normal;
  font-size: 0.7rem;
}

.prediction-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--line);
  margin: 12px 0;
}
.prediction-bar.playoff {
  border-color: rgba(79, 70, 229, 0.5);
  box-shadow: inset 0 0 0 1px rgba(79, 70, 229, 0.25);
}
.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(232, 238, 252, 0.1);
  font-size: 0.75rem;
  font-weight: 600;
}
.pill.red { background: rgba(239, 68, 68, 0.2); color: #fecaca; }
.pill.blue { background: rgba(59, 130, 246, 0.2); color: #bfdbfe; }

.matrix-box, .playbook-box, .outlook-box {
  white-space: pre-wrap;
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.45;
  background: rgba(248, 250, 252, 0.04);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  color: #dbe4f5;
}

/* Compact Match Brief (Sheets-style grid) */
.brief-wrap { display: grid; gap: 14px; }
.brief-wrap.playoff .brief-meta .pill {
  background: rgba(79, 70, 229, 0.35);
  color: #c7d2fe;
}
.brief-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}
.brief-table-wrap { overflow-x: auto; }
.brief-grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
  min-width: 720px;
}
.brief-grid th,
.brief-grid td {
  border-bottom: 1px solid var(--line);
  padding: 6px 8px;
  text-align: center;
  vertical-align: top;
}
.brief-grid td.brief-cell {
  max-width: 11rem;
}
.brief-grid th:first-child,
.brief-grid td:first-child {
  text-align: left;
  width: 190px;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}
.brief-grid .alliance-h.red { background: rgba(239, 68, 68, 0.18); color: #fecaca; }
.brief-grid .alliance-h.blue { background: rgba(59, 130, 246, 0.18); color: #bfdbfe; }
.brief-grid .slot-h { font-size: 0.72rem; color: var(--muted); font-weight: 600; }
.brief-grid .divider-h {
  width: 12px;
  padding: 0;
  background: rgba(241, 245, 249, 0.08);
  border-bottom: none;
}
.brief-cell.toi { background: rgba(254, 240, 138, 0.22); color: #fef9c3; }
.brief-cell.pre-fallback { background: rgba(99, 102, 241, 0.16); color: #c7d2fe; }
.brief-cell.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.brief-grid .pred-row th,
.brief-grid .pred-row td { border-top: 1px solid rgba(61, 214, 198, 0.35); }
.brief-grid .pred.red { background: rgba(239, 68, 68, 0.12); font-weight: 700; }
.brief-grid .pred.blue { background: rgba(59, 130, 246, 0.12); font-weight: 700; }
.brief-grid .pred-margin { text-align: left !important; }
.panel.tight { padding: 12px 14px; }
.panel.tight h3 { margin: 0 0 8px; font-size: 0.95rem; }
.team-notes {
  border-top: 1px solid var(--line);
  padding: 10px 0;
}
.team-notes.toi { border-left: 3px solid #fef08a; padding-left: 10px; }
.note-line { margin-top: 4px; font-size: 0.86rem; }

.config-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  font-size: 0.85rem;
  color: var(--muted);
}
.config-form .config-label {
  cursor: help;
}
.config-form .config-label:hover {
  color: var(--ink);
}
.config-form textarea,
.config-form input,
.config-form select {
  background: rgba(0,0,0,0.28);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 8px;
  padding: 10px;
  font-family: var(--mono);
  font-size: 0.9rem;
  cursor: auto;
}
.config-form select {
  font-family: var(--sans, inherit);
}
.config-form .check-row {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  cursor: help;
}
.config-form .check-row input {
  width: auto;
  margin: 0;
}
.config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.draft-grid { display: grid; gap: 8px; }
.draft-banner {
  margin-bottom: 14px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  font-size: 0.9rem;
  background: rgba(232, 238, 252, 0.05);
}
.draft-banner.on-clock {
  border-color: rgba(254, 240, 138, 0.55);
  background: rgba(254, 240, 138, 0.1);
  color: #fef9c3;
}
.draft-banner.done {
  border-color: rgba(134, 239, 172, 0.4);
  background: rgba(134, 239, 172, 0.08);
  color: #bbf7d0;
}
.draft-row.on-clock-row {
  outline: 1px solid rgba(254, 240, 138, 0.45);
  border-radius: 10px;
  background: rgba(254, 240, 138, 0.06);
  padding: 6px;
}
.draft-slot {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px;
  border-radius: 8px;
}
.draft-slot.on-clock {
  background: rgba(254, 240, 138, 0.16);
  box-shadow: inset 0 0 0 1px rgba(254, 240, 138, 0.45);
}
.draft-slot-head {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 600;
}
.draft-slot-name {
  min-height: 1.2em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.declined-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}
.badge-available { background: rgba(134, 239, 172, 0.18); color: #86efac; }
.badge-drafted { background: rgba(148, 163, 184, 0.2); color: #94a3b8; }
.badge-declined { background: rgba(251, 191, 36, 0.2); color: #fcd34d; }
tr.pickable { cursor: pointer; }
tr.pickable:hover td { background: rgba(254, 240, 138, 0.1) !important; }
tr.dimmed td { opacity: 0.55; }
.team-label {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.2em 0.45em;
  max-width: min(22rem, 100%);
  line-height: 1.35;
  vertical-align: top;
}
.team-label .mono {
  flex-shrink: 0;
  white-space: nowrap;
}
.team-name {
  color: var(--ink);
  font-weight: 500;
  font-size: 0.92em;
  min-width: 0;
  overflow-wrap: break-word;
  word-break: normal;
  hyphens: auto;
}
.brief-cell .team-name {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 500;
  white-space: normal;
  line-height: 1.25;
  margin-top: 2px;
  max-width: min(14rem, 100%);
  overflow-wrap: break-word;
  hyphens: auto;
}
.robot .team-num .team-label {
  max-width: 100%;
}
.draft-row {
  display: grid;
  gap: 8px;
  align-items: start;
}
.draft-row input {
  width: 100%;
  background: rgba(0,0,0,0.28);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 8px;
  padding: 8px;
  font-family: var(--mono);
}

.split-2 {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 16px;
}
@media (max-width: 1000px) {
  .split-2 { grid-template-columns: 1fr; }
  .draft-row:not(.compact) { grid-template-columns: 1fr; }
}

/* Alliance war room: draft left, remaining teams right, tight density */
.view-head.tight {
  margin-bottom: 8px;
  align-items: start;
}
.view-head.tight h2 { font-size: 1.15rem; }
.view-head.tight .hint { font-size: 0.78rem; max-width: 70ch; }
.draft-banner.compact {
  margin-bottom: 8px;
  padding: 6px 10px;
  font-size: 0.8rem;
  border-radius: 8px;
}
.alliance-war-room {
  display: grid;
  grid-template-columns: minmax(220px, 0.85fr) minmax(0, 1.55fr);
  gap: 10px;
  align-items: start;
  max-height: calc(100vh - 150px);
}
.alliance-war-room > .panel.tight {
  padding: 8px 10px;
  margin-bottom: 0;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: calc(100vh - 150px);
}
.panel-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 6px;
}
.panel-toolbar h3 {
  margin: 0;
  font-size: 0.9rem;
}
.draft-grid.compact {
  gap: 4px;
  overflow-y: auto;
  min-height: 0;
  flex: 1;
}
.draft-row.compact {
  gap: 4px;
  align-items: center;
  padding: 2px 4px;
  border-radius: 6px;
}
.draft-row.compact.on-clock-row {
  padding: 2px 4px;
  outline-width: 1px;
}
.draft-a-label {
  font-size: 0.72rem;
  font-family: var(--mono);
  color: var(--muted);
  text-align: center;
}
.draft-slot.compact {
  padding: 1px 2px;
  gap: 0;
  min-width: 0;
}
.draft-slot.compact .draft-slot-head {
  font-size: 0.58rem;
  letter-spacing: 0.02em;
  line-height: 1.1;
}
.draft-slot.compact input {
  padding: 3px 4px;
  font-size: 0.75rem;
  border-radius: 4px;
  min-width: 0;
}
.draft-slot.compact .draft-slot-name {
  font-size: 0.62rem;
  min-height: 1.5em;
  color: var(--muted);
  line-height: 1.15;
  white-space: normal;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
}
.partner-lookup {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}
.partner-lookup-row {
  gap: 6px;
  margin-bottom: 6px;
}
.lookup-label {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.65rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.lookup-label select,
.lookup-label input,
.syn-cap-label select {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  font-size: 0.75rem;
  padding: 4px 6px;
  min-width: 0;
  background: rgba(0,0,0,0.28);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 4px;
  font-family: var(--mono);
}
.lookup-label input { width: 5.5rem; }
.syn-cap-label {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 4px;
  font-size: 0.68rem;
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  margin-left: 2px;
}
.syn-cap-label select {
  max-width: 9.5rem;
}
.alliance-sort-bar {
  align-items: center;
}
.synergy-hint {
  margin: 0 0 4px;
  font-size: 0.72rem;
}
.partner-detail {
  background: rgba(0,0,0,0.22);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  font-size: 0.75rem;
  max-height: 14rem;
  overflow: auto;
}
.partner-detail.empty {
  color: var(--muted);
  text-align: left;
  padding: 10px;
}
.partner-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.detail-kicker {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 700;
}
.detail-title {
  font-weight: 700;
  margin: 2px 0 6px;
  font-size: 0.82rem;
}
.detail-dl {
  margin: 0;
  display: grid;
  gap: 2px;
}
.detail-dl > div {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  gap: 4px;
}
.detail-dl dt {
  margin: 0;
  color: var(--muted);
  font-size: 0.68rem;
}
.detail-dl dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.72rem;
}
.detail-comments {
  font-size: 0.68rem;
  line-height: 1.35;
  color: var(--ink);
  opacity: 0.9;
}
@media (max-width: 520px) {
  .partner-detail-grid { grid-template-columns: 1fr; }
}
.declined-row.compact {
  margin-top: 8px;
  padding-top: 8px;
  gap: 6px;
}
.declined-row.compact input {
  width: 5.5rem;
  padding: 4px 6px;
  font-size: 0.75rem;
  background: rgba(0,0,0,0.28);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 4px;
  font-family: var(--mono);
}
.sim-details {
  margin-top: 8px;
  border-top: 1px solid var(--line);
  padding-top: 6px;
  font-size: 0.78rem;
}
.sim-details summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 6px;
}
.sim-details .toolbar-inline input {
  min-width: 4.5rem;
  padding: 4px 6px;
  font-size: 0.75rem;
}
.playbook-box.compact {
  margin-top: 6px;
  padding: 6px 8px;
  font-size: 0.75rem;
  max-height: 8rem;
  overflow: auto;
}
.picks-panel {
  min-width: 0;
}
.picks-panel .toi-filter {
  gap: 4px;
  flex-wrap: wrap;
}
.compact-check {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  color: var(--muted);
  margin-left: 4px;
  white-space: nowrap;
}
.picks-scroll {
  overflow: auto;
  flex: 1;
  min-height: 0;
  max-height: calc(100vh - 210px);
}
table.data.compact th,
table.data.compact td {
  padding: 3px 6px;
  font-size: 0.78rem;
  line-height: 1.25;
  vertical-align: middle;
  white-space: nowrap;
}
table.data.compact th {
  padding: 4px 6px;
  font-size: 0.72rem;
  position: sticky;
  top: 0;
  z-index: 1;
}
table.data.compact td.team-cell {
  white-space: nowrap;
  max-width: 11rem;
  overflow: hidden;
  text-overflow: ellipsis;
}
table.data.compact td.num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
table.data.compact .status-badge {
  padding: 1px 5px;
  font-size: 0.65rem;
}
table.data.compact .team-label {
  max-width: 11rem;
  flex-wrap: nowrap;
}
table.data.compact .team-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.78em;
}
.panel.tight .mini-btn {
  padding: 5px 8px;
  font-size: 0.72rem;
  border-radius: 6px;
}
@media (max-width: 900px) {
  .alliance-war-room {
    grid-template-columns: 1fr;
    max-height: none;
  }
  .alliance-war-room > .panel.tight {
    max-height: none;
  }
  .picks-scroll {
    max-height: min(55vh, 28rem);
  }
}

.flag { color: var(--danger); font-weight: 700; }
.ok { color: var(--accent); }
.warn { color: var(--warn); }
.empty { color: var(--muted); padding: 24px; text-align: center; }

.drawer {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(380px, 100%);
  z-index: 40;
}
.drawer[hidden], .drawer-backdrop[hidden] { display: none !important; }
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 30;
}
.drawer-panel {
  height: 100%;
  background: #0f172a;
  border-left: 1px solid var(--line);
  padding: 18px;
  overflow: auto;
}
.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.drawer-head h2 { margin: 0; font-family: var(--display); font-size: 1.1rem; }
.icon-close {
  background: transparent;
  border: 0;
  color: var(--ink);
  font-size: 1.6rem;
  cursor: pointer;
}
.drawer-panel label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
  font-size: 0.8rem;
  color: var(--muted);
}
.drawer-panel input,
.drawer-panel select {
  background: rgba(0,0,0,0.28);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: var(--mono);
}
.auth-status { font-size: 0.8rem; color: var(--muted); }
.auth-status.ok { color: var(--accent); }

.leaderboards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
@media (max-width: 900px) {
  .leaderboards { grid-template-columns: 1fr; }
}
.pacing { color: var(--danger); font-weight: 700; font-size: 0.78rem; }

/* Double-elim bracket board */
.bracket-board {
  display: grid;
  gap: 18px;
  margin-bottom: 16px;
}
.bracket-half {
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px 16px;
}
.bracket-half.upper {
  border-color: rgba(61, 214, 198, 0.28);
}
.bracket-half.lower {
  border-color: rgba(249, 115, 22, 0.28);
}
.bracket-half.finals {
  border-color: rgba(167, 139, 250, 0.35);
}
.bracket-half-title {
  margin: 0 0 10px;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}
.bracket-cols {
  display: flex;
  gap: 14px;
  align-items: stretch;
  overflow-x: auto;
  padding-bottom: 4px;
}
.bracket-col {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  gap: 12px;
  min-width: 168px;
  flex: 0 0 auto;
}
.bracket-match {
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  display: grid;
  gap: 4px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset;
}
.bracket-match.source-actual {
  border-color: rgba(52, 211, 153, 0.55);
}
.bracket-match.source-override {
  border-color: rgba(250, 204, 21, 0.5);
  border-style: dashed;
}
.bracket-match.skipped {
  opacity: 0.45;
  min-height: 72px;
  place-content: center;
}
.bracket-match-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
}
.bracket-match-id {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.78rem;
  color: var(--accent);
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.bracket-match-id:hover { color: #fff; }
.bracket-round-tag {
  font-size: 0.65rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.bracket-side {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px;
  align-items: center;
  padding: 5px 7px;
  border-radius: 6px;
  font-size: 0.78rem;
  min-height: 1.9rem;
}
.bracket-side.red { background: rgba(239, 68, 68, 0.14); }
.bracket-side.blue { background: rgba(59, 130, 246, 0.14); }
.bracket-side.winner {
  outline: 1px solid rgba(255, 255, 255, 0.35);
  font-weight: 700;
}
.bracket-side.empty { opacity: 0.55; }
.bracket-seed {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.72rem;
  min-width: 2.2rem;
}
.bracket-roster {
  color: var(--muted);
  font-size: 0.7rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bracket-side.winner .bracket-roster { color: var(--ink); }
.bracket-match-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}
.bracket-score {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--muted);
}
.bracket-match-foot select {
  font-size: 0.68rem;
  padding: 2px 4px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 4px;
  max-width: 4.5rem;
}
.bracket-pacing {
  color: var(--danger);
  font-size: 0.65rem;
  font-weight: 700;
}
@media (max-width: 900px) {
  .bracket-cols { gap: 10px; }
  .bracket-col { min-width: 148px; }
}

.header-select {
  background: rgba(15, 23, 42, 0.45);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 8px;
  padding: 6px 12px;
  font-family: var(--body);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s ease, background-color 0.15s ease;
  max-width: 260px;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}
.header-select:hover {
  background: rgba(15, 23, 42, 0.7);
  border-color: var(--accent);
}
.header-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25);
}

/* ── Horizontal double-elim bracket (new layout) ─────────────────────────── */
.bracket-board-h {
  margin-bottom: 20px;
}
.bracket-rounds-wrap {
  overflow-x: auto;
  padding-bottom: 8px;
}
.bracket-legend {
  display: flex;
  gap: 18px;
  margin-bottom: 8px;
  padding: 0 2px;
}
.legend-item {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 10px;
  border-radius: 30px;
}
.upper-leg {
  background: rgba(61, 214, 198, 0.12);
  color: rgba(61, 214, 198, 0.9);
  border: 1px solid rgba(61, 214, 198, 0.28);
}
.lower-leg {
  background: rgba(249, 115, 22, 0.1);
  color: rgba(249, 115, 22, 0.9);
  border: 1px solid rgba(249, 115, 22, 0.28);
}
.bracket-rounds {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  min-width: max-content;
  padding: 0 2px 8px;
}
.bracket-round-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 172px;
  flex: 0 0 auto;
}
.bracket-round-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  text-align: center;
  padding: 4px 0;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}
.bracket-upper-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 6px 0;
  border-left: 3px solid rgba(61, 214, 198, 0.28);
  padding-left: 8px;
  margin-bottom: 10px;
}
.bracket-lower-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 6px 0;
  border-left: 3px solid rgba(249, 115, 22, 0.28);
  padding-left: 8px;
}

/* Grand Finals strip */
.bracket-grand-finals {
  margin-top: 20px;
  background: rgba(167, 139, 250, 0.06);
  border: 1px solid rgba(167, 139, 250, 0.3);
  border-radius: 14px;
  padding: 14px 18px 18px;
}
.grand-finals-title {
  color: rgba(196, 181, 253, 0.95) !important;
}
.bracket-gf-cols {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  overflow-x: auto;
  padding-bottom: 4px;
}
.bracket-gf-col {
  min-width: 172px;
  flex: 0 0 auto;
}
.bracket-gf-label {
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 700;
  color: rgba(196, 181, 253, 0.85);
  text-align: center;
  margin-bottom: 6px;
  letter-spacing: 0.04em;
}

/* ── Print / PDF export ───────────────────────────────────────────────────── */
@media print {
  /* Reset to white page */
  *, *::before, *::after {
    background: #fff !important;
    color: #111 !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }

  /* Hide UI chrome */
  header, nav, .sidebar, #sidebar, .nav-tabs, .nav-pills,
  .header-select, .toolbar-inline, .view-head .toolbar-inline,
  #match-print, #match-load, #match-input,
  .brief-view-head .toolbar-inline,
  [data-override], select, button,
  .hint, .pacing, .bracket-match-foot select {
    display: none !important;
  }

  /* Page setup */
  @page {
    size: landscape;
    margin: 10mm 12mm;
  }

  body {
    font-family: sans-serif;
    font-size: 9pt;
  }

  /* Show only the match briefing content */
  #view-root {
    display: block !important;
    width: 100%;
  }

  /* Force colours for alliance headers */
  .alliance-h.red { background: #ffe4e4 !important; color: #c00 !important; }
  .alliance-h.blue { background: #e4eeff !important; color: #005 !important; }
  .brief-cell.red { background: #fff0f0 !important; }
  .brief-cell.blue { background: #f0f0ff !important; }
  .pred-row td, .pred-row th { background: #f7f7f7 !important; }

  /* Matrix box */
  .matrix-box {
    font-size: 7pt;
    white-space: pre;
    border: 1px solid #ccc !important;
    padding: 6px !important;
    background: #fafafa !important;
    page-break-inside: avoid;
  }

  /* Keep briefing tables together */
  .brief-wrap { page-break-inside: avoid; }
  .panel { break-inside: avoid; margin-bottom: 10px; }

  table { width: 100%; border-collapse: collapse; }
  th, td { border: 1px solid #ccc !important; padding: 3px 5px !important; }
  th { background: #f0f0f0 !important; }

  /* Strip decorative borders from cards */
  .brief-grid th { font-size: 8pt; }

  /* Prediction rows */
  .pred-row { font-weight: bold; }

  /* Remove underlines from links in print */
  a { text-decoration: none !important; }
}
