:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-alt: #eef2f6;
  --text: #1d2733;
  --muted: #657384;
  --line: #d8dee8;
  --accent: #1f7a5b;
  --accent-dark: #155d45;
  --red: #b73535;
  --red-bg: #fff1f1;
  --blue: #255ea8;
  --blue-bg: #eef5ff;
  --warn: #a46809;
  --warn-bg: #fff7df;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, "Segoe UI", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

button,
input {
  font: inherit;
}

button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

button:disabled {
  border-color: var(--line);
  background: #e5e9ef;
  color: #8c97a5;
  cursor: not-allowed;
}

select {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: var(--surface);
  color: var(--text);
}

label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 76px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.topbar h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 760;
  letter-spacing: 0;
}

.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.status {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

#simulator-button,
#elimination-button {
  padding: 0 14px;
  font-weight: 750;
}

#simulator-button {
  border-color: #bfd4c9;
  background: #edf8f2;
  color: var(--accent-dark);
}

#simulator-button:hover {
  border-color: var(--accent);
  background: #e5f4ec;
}

#elimination-button.enabled {
  border-color: #c9d6e4;
  background: #f8fbff;
}

#elimination-button.active,
#elimination-button.enabled:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--muted);
  font-weight: 700;
}

.pill.live {
  background: #e9f7f0;
  color: var(--accent-dark);
}

.pill.error {
  background: var(--red-bg);
  color: var(--red);
}

.layout {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  min-height: calc(100vh - 76px);
}

.sidebar {
  padding: 18px;
  border-right: 1px solid var(--line);
  background: #fbfcfe;
}

.control-group {
  margin-bottom: 16px;
}

.inline {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 66px;
  gap: 8px;
}

.toolbar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.team-list {
  display: grid;
  gap: 6px;
  max-height: calc(100vh - 300px);
  overflow: auto;
  padding-right: 4px;
}

.team-choice {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  min-height: 34px;
  padding: 6px 8px;
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
}

.team-choice:hover {
  background: var(--surface-alt);
}

.team-choice input {
  min-height: 0;
  width: 16px;
  height: 16px;
}

.content {
  min-width: 0;
  padding: 20px 24px 32px;
}

.section {
  margin-bottom: 28px;
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-heading h2 {
  margin: 0;
  font-size: 17px;
  letter-spacing: 0;
}

.section-heading span {
  color: var(--muted);
  font-size: 13px;
}

.message-area,
.conflict-area {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.message,
.conflict {
  border-radius: 6px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
}

.message.error,
.conflict {
  border-color: #ecc7c7;
  background: var(--red-bg);
  color: var(--red);
}

.message.warn {
  border-color: #ead89a;
  background: var(--warn-bg);
  color: var(--warn);
}

.division-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.division-cell {
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface);
}

.division-name {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.division-progress {
  margin-top: 10px;
  font-size: 19px;
  font-weight: 760;
}

.team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 14px;
}

.team-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.team-card-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--line);
}

.team-card h3 {
  margin: 0;
  font-size: 21px;
}

.team-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(72px, 1fr));
  gap: 8px;
  min-width: 160px;
}

.metric {
  padding: 8px;
  border-radius: 6px;
  background: var(--surface-alt);
}

.metric-label {
  color: var(--muted);
  font-size: 11px;
}

.metric-value {
  margin-top: 4px;
  font-size: 17px;
  font-weight: 760;
}

.next-match {
  margin: 12px 14px;
  border-radius: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--surface-alt);
}

.next-match.red {
  border-color: #efc7c7;
  background: var(--red-bg);
}

.next-match.blue {
  border-color: #c7d9f0;
  background: var(--blue-bg);
}

.next-match.teamwork {
  border-color: #c8ddcf;
  background: #eef8f1;
}

.next-match.teamwork .detail-grid span:nth-of-type(3),
.next-match.teamwork .detail-grid strong:nth-of-type(3) {
  display: none;
}

.next-title {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  font-weight: 760;
}

.next-title .red-text {
  color: var(--red);
}

.next-title .blue-text {
  color: var(--blue);
}

.iq-side {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
}

.iq-side.red {
  color: var(--red);
  background: #fff1f1;
  border: 1px solid #efc7c7;
}

.iq-side.blue {
  color: var(--blue);
  background: #eef5ff;
  border: 1px solid #c7d9f0;
}

.iq-side.unknown {
  color: var(--muted);
  background: var(--surface-alt);
  border: 1px solid var(--line);
}

.detail-grid {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 5px 10px;
  color: var(--muted);
  font-size: 13px;
}

.detail-grid strong {
  color: var(--text);
  font-weight: 650;
}

.match-toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  width: calc(100% - 28px);
  margin: 0 14px 12px;
  padding: 0 12px;
  border-color: #cfd7e2;
  background: #fbfcfe;
  color: var(--text);
  font-weight: 750;
}

.match-toggle::before {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 160ms ease;
}

.match-toggle.expanded::before {
  transform: rotate(45deg);
}

.match-toggle span {
  min-width: 0;
  margin-right: auto;
}

.match-toggle small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.match-table-wrap {
  padding: 0 14px 14px;
  overflow-x: auto;
}

.match-table-wrap.collapsed {
  display: none;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

tr.pending {
  background: #fff9ea;
}

.result-win {
  color: var(--accent-dark);
  font-weight: 800;
}

.result-loss {
  color: var(--red);
  font-weight: 800;
}

.empty {
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface);
}

.hidden {
  display: none !important;
}

.bracket-heading {
  align-items: center;
}

.bracket-heading > div:first-child {
  min-width: 0;
}

.bracket-heading h2 {
  font-size: 20px;
}

.bracket-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bracket-controls select {
  min-width: 180px;
}

.champion-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  border: 1px solid #c8ddcf;
  border-radius: 8px;
  padding: 12px 14px;
  background: #eef8f1;
}

.champion-banner span {
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.champion-banner strong {
  font-size: 18px;
}

.bracket-board {
  overflow-x: auto;
  padding-bottom: 8px;
}

.official-iq-teamwork {
  width: min(920px, 100%);
}

.official-iq-list {
  display: grid;
  gap: 10px;
}

.official-iq-final {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  align-items: stretch;
  min-height: 74px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.official-iq-final.completed {
  border-color: #c8ddcf;
}

.official-iq-final.pending {
  background: #fff9ea;
}

.official-iq-seed {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8fafc;
  font-weight: 850;
  border-right: 1px solid var(--line);
  color: var(--muted);
}

.official-iq-main {
  min-width: 0;
  padding: 10px 12px;
}

.official-iq-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
}

.official-iq-teamwork-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 64px;
  align-items: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.official-iq-teamwork-row > span {
  min-width: 0;
  padding: 8px 10px;
  font-size: 17px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.iq-final-team {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 2px;
}

.official-iq-teamwork-row strong {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  border-left: 1px solid var(--line);
  color: var(--accent-dark);
  font-size: 20px;
  font-weight: 850;
}

.official-bracket {
  display: grid;
  grid-template-columns: minmax(780px, 1fr) 300px minmax(780px, 1fr);
  align-items: center;
  gap: 28px;
  min-width: 1900px;
}

.bracket-side {
  display: grid;
  grid-template-columns: repeat(3, minmax(240px, 1fr));
  align-items: center;
  gap: 28px;
}

.bracket-round {
  min-width: 0;
}

.bracket-round h3 {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
  text-transform: uppercase;
}

.bracket-stack {
  display: grid;
  gap: 12px;
}

.bracket-round.r16 .bracket-stack {
  gap: 12px;
}

.bracket-round.qf .bracket-stack {
  gap: 82px;
}

.bracket-round.sf .bracket-stack {
  gap: 270px;
}

.finals-column {
  align-self: center;
}

.finals-column h3 {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
  text-align: center;
  text-transform: uppercase;
}

.finals-stack {
  gap: 12px;
}

.bracket-match {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: visible;
}

.bracket-match.center {
  overflow: visible;
}

.bracket-match-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  border-radius: 7px 7px 0 0;
  background: #f8fafc;
  font-size: 12px;
}

.bracket-match-head span {
  color: var(--muted);
  white-space: nowrap;
}

.bracket-alliance {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  align-items: stretch;
  min-height: 42px;
  border-left: 4px solid transparent;
}

.bracket-alliance + .bracket-alliance {
  border-top: 1px solid var(--line);
}

.bracket-alliance:last-child {
  border-radius: 0 0 7px 7px;
}

.bracket-alliance.red {
  border-left-color: var(--red);
}

.bracket-alliance.blue {
  border-left-color: var(--blue);
}

.bracket-alliance.advancing {
  background: #eef8f1;
}

.team-names,
.score {
  display: flex;
  align-items: center;
  padding: 8px 10px;
}

.team-names {
  min-width: 0;
  font-weight: 720;
  overflow-wrap: anywhere;
}

.score {
  justify-content: center;
  border-left: 1px solid var(--line);
  font-size: 17px;
  font-weight: 850;
}

.bracket-alliance.advancing .score {
  color: var(--accent-dark);
}

body.modal-open {
  overflow: hidden;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 32, 0.42);
}

.modal-panel {
  width: min(1440px, 100%);
  max-height: min(860px, calc(100vh - 48px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 22px 70px rgba(20, 31, 44, 0.24);
  overflow: hidden;
}

.simulator-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfe;
}

.modal-header h2 {
  margin: 0;
  font-size: 20px;
}

.modal-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.simulator-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.simulator-actions select {
  min-width: 220px;
}

.simulator-number-field {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.simulator-number-field[hidden] {
  display: none;
}

.simulator-number-field input {
  width: 82px;
  height: 38px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 760;
}

#simulator-mode-select {
  min-width: 150px;
}

#simulator-status {
  margin: 12px 18px 0;
}

.simulator-grid {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  gap: 16px;
  min-height: 0;
  padding: 16px 18px 18px;
}

.rank-collapsed .simulator-grid {
  grid-template-columns: 54px minmax(0, 1fr);
}

.simulator-rank-panel,
.simulator-bracket-panel {
  min-width: 0;
  min-height: 0;
}

.simulator-panel-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.simulator-panel-heading h3 {
  margin: 0;
  font-size: 15px;
}

.simulator-panel-heading span {
  color: var(--muted);
  font-size: 12px;
}

.simulator-rank-panel .simulator-panel-heading {
  align-items: center;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
}

.rank-collapsed .simulator-rank-panel {
  border-right: 1px solid var(--line);
}

.rank-collapsed .simulator-rank-panel .simulator-panel-heading {
  display: flex;
  justify-content: center;
  margin-bottom: 0;
}

.rank-collapsed .simulator-rank-panel h3,
.rank-collapsed #simulator-rank-count,
.rank-collapsed .simulator-manual-row,
.rank-collapsed .simulator-rank-list {
  display: none;
}

#simulator-rank-toggle {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 760;
}

.rank-collapsed #simulator-rank-toggle {
  width: 34px;
  min-height: 140px;
  padding: 8px 0;
  line-height: 1.2;
  writing-mode: vertical-rl;
}

.simulator-bracket-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.simulator-manual-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 68px;
  gap: 8px;
  margin-bottom: 10px;
}

.simulator-rank-list {
  display: grid;
  gap: 7px;
  max-height: calc(100vh - 240px);
  overflow: auto;
  padding-right: 4px;
}

.sim-rank-item {
  display: grid;
  grid-template-columns: 34px minmax(72px, 1fr) minmax(96px, 1.4fr) minmax(70px, auto) 28px;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 7px 9px;
  background: var(--surface);
  cursor: grab;
}

.sim-rank-item:hover {
  border-color: #b9c6d5;
  background: #f8fafc;
}

.sim-rank-item:active {
  cursor: grabbing;
}

.sim-rank-item.captain {
  border-left: 4px solid var(--accent);
}

.sim-rank-item.partner {
  border-left: 4px solid var(--blue);
  background: var(--blue-bg);
}

.sim-rank-item.iq-red {
  border-left: 4px solid var(--red);
}

.sim-rank-item.iq-blue {
  border-left: 4px solid var(--blue);
}

.sim-rank-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.sim-team-number {
  min-width: 0;
  font-weight: 820;
  overflow-wrap: anywhere;
}

.sim-team-record {
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.sim-rank-badge {
  justify-self: end;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 760;
  white-space: nowrap;
}

.sim-rank-badge.red {
  color: var(--red);
}

.sim-rank-badge.blue {
  color: var(--blue);
}

.delete-sim-team {
  min-height: 26px;
  width: 26px;
  padding: 0;
  border-radius: 999px;
  color: var(--muted);
  line-height: 1;
}

.delete-sim-team:hover {
  border-color: #ecc7c7;
  color: var(--red);
}

.simulator-bracket {
  min-width: 0;
}

.sim-bracket-scroll {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  overflow: auto;
  max-height: calc(100vh - 240px);
  padding-bottom: 6px;
}

.rank-collapsed .sim-bracket-scroll {
  justify-content: center;
  overflow: hidden;
  max-height: calc(100vh - 220px);
}

.sim-bracket-fit-frame {
  position: relative;
  flex: 0 0 auto;
  min-width: 0;
}

.iq-teamwork-scroll {
  width: 100%;
}

.rank-collapsed .iq-teamwork-scroll {
  overflow: auto;
}

.iq-teamwork-finals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  width: min(960px, 100%);
}

.iq-final-match {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  align-items: center;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.iq-final-seed {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  border-right: 1px solid var(--line);
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.iq-final-teams {
  display: grid;
  gap: 6px;
  padding: 10px;
}

.iq-final-side {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}

.iq-final-side span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 12px;
  font-weight: 850;
  line-height: 1.2;
}

.iq-final-side.red span {
  color: var(--red);
  background: #fff1f1;
  border: 1px solid #efc7c7;
}

.iq-final-side.blue span {
  color: var(--blue);
  background: #eef5ff;
  border: 1px solid #c7d9f0;
}

.iq-final-side strong {
  min-width: 0;
  overflow-wrap: anywhere;
  text-align: left;
}

.sim-first-round-bracket {
  position: absolute;
  left: 0;
  top: 0;
  display: grid;
  grid-template-columns: 360px minmax(260px, 1fr) 360px;
  align-items: center;
  gap: 24px;
  width: 1080px;
  min-width: 0;
  transform: scale(var(--sim-zoom, 1));
  transform-origin: top left;
}

.sim-first-round-bracket.size-8 {
  grid-template-columns: 340px minmax(220px, 1fr) 340px;
  width: 960px;
}

.sim-first-round-bracket.size-4 {
  grid-template-columns: 320px minmax(160px, 1fr) 320px;
  width: 820px;
}

.sim-first-round-bracket.size-2 {
  grid-template-columns: minmax(320px, 420px);
  width: 420px;
}

.sim-first-round-bracket.size-2 .sim-first-round-side.right,
.sim-first-round-bracket.size-2 .sim-path-column {
  display: none;
}

.sim-round h4 {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.sim-round-stack {
  display: grid;
  gap: 12px;
}

.sim-round.r16 .sim-round-stack {
  gap: 12px;
}

.sim-round.qf .sim-round-stack {
  gap: 20px;
}

.sim-round.sf .sim-round-stack {
  gap: 20px;
}

.sim-path-column {
  position: relative;
  display: flex;
  align-items: stretch;
  min-height: 100%;
  padding-top: 22px;
}

.sim-path-column svg {
  width: 100%;
  min-height: 620px;
  overflow: visible;
}

.sim-path-column.size-8 svg {
  min-height: 320px;
}

.sim-path-column.size-4 svg {
  min-height: 150px;
}

.sim-path-lines path {
  fill: none;
  stroke: #c6d1df;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sim-path-label {
  fill: var(--muted);
  font-size: 18px;
  font-weight: 850;
  letter-spacing: 0;
}

.sim-path-labels {
  paint-order: stroke;
  stroke: var(--surface);
  stroke-width: 6px;
}

.sim-match {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.sim-match-head {
  min-height: 34px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
  font-size: 12px;
}

.sim-alliance-line {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  min-height: 58px;
  border-left: 4px solid transparent;
}

.sim-alliance-line + .sim-alliance-line {
  border-top: 1px solid var(--line);
}

.sim-alliance-line.red {
  border-left-color: var(--red);
}

.sim-alliance-line.blue {
  border-left-color: var(--blue);
}

.sim-alliance-line.muted {
  display: flex;
  align-items: center;
  padding: 10px;
  color: var(--muted);
  font-weight: 700;
}

.sim-seed {
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.sim-alliance-main {
  display: grid;
  gap: 6px;
  padding: 8px;
}

.sim-alliance-team {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  cursor: grab;
}

.sim-alliance-team span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.sim-alliance-team strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.partner-drop {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  border: 1px dashed #aeb9c6;
  border-radius: 6px;
  padding: 5px 7px;
  color: var(--muted);
  background: #fbfcfe;
}

.partner-drop.filled {
  border-style: solid;
  border-color: #b7d0c4;
  color: var(--text);
  background: #f0f8f4;
  font-weight: 760;
}

.partner-drop span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.clear-partner {
  min-height: 24px;
  width: 24px;
  padding: 0;
  border-radius: 999px;
  line-height: 1;
}

@media (max-width: 860px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .team-list {
    max-height: 240px;
  }

  .content {
    padding: 16px;
  }

  .team-grid {
    grid-template-columns: 1fr;
  }

  .topbar-actions {
    align-items: flex-start;
    flex-direction: column;
    width: 100%;
  }

  .topbar-actions > button {
    width: 100%;
  }

  .bracket-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .bracket-controls {
    width: 100%;
  }

  .bracket-controls select {
    min-width: 0;
    width: 100%;
  }

  .modal-backdrop {
    padding: 10px;
  }

  .modal-panel {
    max-height: calc(100vh - 20px);
  }

  .modal-header,
  .simulator-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .simulator-actions select,
  .simulator-number-field,
  .simulator-number-field input,
  .simulator-actions button {
    width: 100%;
  }

  .simulator-grid {
    grid-template-columns: 1fr;
  }

  .rank-collapsed .simulator-grid {
    grid-template-columns: 44px minmax(0, 1fr);
  }

  .simulator-panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .simulator-rank-panel .simulator-panel-heading {
    align-items: center;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .simulator-bracket-tools {
    justify-content: flex-start;
    width: 100%;
  }

  .simulator-rank-list,
  .sim-bracket-scroll {
    max-height: none;
  }

  .sim-rank-item {
    grid-template-columns: 30px minmax(74px, 1fr) 28px;
  }

  .sim-team-record,
  .sim-rank-badge {
    grid-column: 2;
    justify-self: start;
  }

  .delete-sim-team {
    grid-column: 3;
    grid-row: 1 / span 3;
    align-self: center;
  }
}
