#teamBuilderView .team-coverage {
  --matrix-hard-win-bg: #1769e8;
  --matrix-hard-win-border: #0954c8;
  --matrix-hard-win-text: #fff;
  --matrix-soft-win-bg: #d9eafe;
  --matrix-soft-win-border: #b4d5fb;
  --matrix-soft-win-text: #1259a8;
  --matrix-neutral-bg: #ebe8e2;
  --matrix-neutral-border: #d9d4cc;
  --matrix-neutral-text: #595752;
  --matrix-soft-loss-bg: #ffd9dc;
  --matrix-soft-loss-border: #ffb8bf;
  --matrix-soft-loss-text: #c51e38;
  --matrix-hard-loss-bg: #f1253e;
  --matrix-hard-loss-border: #c90927;
  --matrix-hard-loss-text: #fff;
  padding: 16px;
  border-radius: 14px;
  box-shadow: 0 4px 14px var(--shadow);
}

body[data-theme="dark"] #teamBuilderView .team-coverage,
body[data-theme="neo"] #teamBuilderView .team-coverage {
  --matrix-hard-win-bg: #1d72ef;
  --matrix-hard-win-border: #55a0ff;
  --matrix-hard-win-text: #fff;
  --matrix-soft-win-bg: #173b63;
  --matrix-soft-win-border: #2e639b;
  --matrix-soft-win-text: #9bccff;
  --matrix-neutral-bg: #35363b;
  --matrix-neutral-border: #51535b;
  --matrix-neutral-text: #e5e2dc;
  --matrix-soft-loss-bg: #56242d;
  --matrix-soft-loss-border: #8f3a49;
  --matrix-soft-loss-text: #ffabb6;
  --matrix-hard-loss-bg: #f02a45;
  --matrix-hard-loss-border: #ff7285;
  --matrix-hard-loss-text: #fff;
}

#teamBuilderView .team-coverage-head {
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
}

#teamBuilderView .team-coverage-head h3 { font-size: 20px; }
#teamBuilderView .team-coverage-head p { font-size: 11px; }

#teamBuilderView .team-coverage-status-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  overflow-x: auto;
  padding: 2px 0;
  scrollbar-width: thin;
}

#teamBuilderView .team-coverage-status-legend > span {
  display: grid;
  grid-template-columns: 48px auto;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 7px;
  min-width: max-content;
  color: var(--ink);
  white-space: nowrap;
}

#teamBuilderView .team-coverage-status-legend .team-matchup-cell {
  grid-row: 1 / 3;
  width: 48px;
  min-height: 34px;
  pointer-events: none;
}

#teamBuilderView .team-coverage-status-legend b {
  align-self: end;
  font-size: 10px;
  line-height: 1.1;
}

#teamBuilderView .team-coverage-status-legend small {
  align-self: start;
  color: var(--muted);
  font-size: 8px;
  line-height: 1.1;
}

#teamBuilderView .team-coverage-desktop {
  max-width: 100%;
  max-height: min(680px, 68vh);
  overflow: auto;
  border-radius: 10px;
  overscroll-behavior: contain;
}

#teamBuilderView .team-coverage-table {
  width: var(--matrix-desktop-width, 100%);
  min-width: 0;
  max-width: 100%;
}

#teamBuilderView .team-coverage-opponent-column { width: 210px; }
#teamBuilderView .team-coverage-matchup-column { width: 130px; }

#teamBuilderView .team-coverage-table th,
#teamBuilderView .team-coverage-table td {
  padding: 6px 8px;
  border-right: 1px solid color-mix(in srgb, var(--line) 62%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 62%, transparent);
}

#teamBuilderView .team-coverage-table thead th { height: 74px; }

#teamBuilderView .team-coverage-table .team-coverage-opponent-head,
#teamBuilderView .team-coverage-table tbody th { width: 210px; }

#teamBuilderView .team-coverage-table .team-coverage-opponent-head {
  color: var(--ink);
  font-size: 12px;
}

#teamBuilderView .team-coverage-pokemon-head { gap: 3px; }
#teamBuilderView .team-coverage-pokemon-head img { width: 42px; height: 42px; }
#teamBuilderView .team-coverage-pokemon-head span { font-size: 10px; font-weight: 850; }

#teamBuilderView .team-coverage-opponent {
  grid-template-columns: 46px minmax(0, 1fr) auto;
  gap: 8px;
}

#teamBuilderView .team-coverage-opponent img { width: 44px; height: 44px; }
#teamBuilderView .team-coverage-opponent-copy strong { font-size: 12px; font-weight: 850; }
#teamBuilderView .team-coverage-opponent-copy small { font-size: 9px; font-weight: 700; }
#teamBuilderView .team-coverage-answer-count { font-size: 10px; font-weight: 900; }

#teamBuilderView .team-matchup-cell {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 44px;
  padding: 4px 6px;
  border: 1px solid var(--matrix-neutral-border);
  border-radius: 8px;
  background: var(--matrix-neutral-bg);
  color: var(--matrix-neutral-text);
  box-shadow: none;
}

#teamBuilderView .team-matchup-cell.result-hard-win { border-color: var(--matrix-hard-win-border); background: var(--matrix-hard-win-bg); color: var(--matrix-hard-win-text); }
#teamBuilderView .team-matchup-cell.result-soft-win { border-color: var(--matrix-soft-win-border); background: var(--matrix-soft-win-bg); color: var(--matrix-soft-win-text); }
#teamBuilderView .team-matchup-cell.result-neutral { border-color: var(--matrix-neutral-border); background: var(--matrix-neutral-bg); color: var(--matrix-neutral-text); }
#teamBuilderView .team-matchup-cell.result-soft-loss { border-color: var(--matrix-soft-loss-border); background: var(--matrix-soft-loss-bg); color: var(--matrix-soft-loss-text); }
#teamBuilderView .team-matchup-cell.result-hard-loss { border-color: var(--matrix-hard-loss-border); background: var(--matrix-hard-loss-bg); color: var(--matrix-hard-loss-text); box-shadow: inset 0 0 0 1px rgba(120, 0, 18, .16); }

#teamBuilderView .team-matchup-cell.has-status-icon {
  min-height: 40px;
  padding: 0;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

#teamBuilderView .team-coverage-status-legend .team-matchup-cell.has-status-icon {
  width: 40px;
  min-height: 40px;
}

#teamBuilderView .team-matchup-cell:hover,
#teamBuilderView .team-matchup-cell:focus-visible {
  outline: 3px solid color-mix(in srgb, currentColor 30%, transparent);
  outline-offset: 1px;
  transform: none;
}

#teamBuilderView .team-matchup-cell strong {
  display: grid;
  place-items: center;
  font-size: 18px;
  line-height: 1;
}

#teamBuilderView .team-matchup-symbol {
  display: inline-grid;
  min-width: 1ch;
  place-items: center;
  color: inherit;
  font-size: inherit;
  font-style: normal;
  font-weight: 900;
  line-height: 1;
}

#teamBuilderView .team-matchup-symbol.is-icon {
  width: 40px;
  height: 40px;
  min-width: 40px;
}

#teamBuilderView .team-matchup-icon {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

#teamBuilderView .team-matchup-cell::after {
  padding: 6px 8px;
  font-size: 9px;
  font-weight: 750;
}

#teamBuilderView .team-coverage-table td.is-column-focus .team-matchup-cell {
  outline: 2px solid color-mix(in srgb, var(--accent) 26%, transparent);
  outline-offset: 1px;
}

#teamBuilderView .team-matchup-cell.is-pending { opacity: .58; }

@media (max-width: 760px) {
  #teamBuilderView .team-coverage { padding: 10px; }
  #teamBuilderView .team-coverage-head { align-items: stretch; }
  #teamBuilderView .team-coverage-status-legend { width: 100%; gap: 10px; }
  #teamBuilderView .team-coverage-status-legend > span { grid-template-columns: 42px auto; }
  #teamBuilderView .team-coverage-status-legend .team-matchup-cell { width: 42px; }
  #teamBuilderView .team-coverage-desktop { display: block; width: 100%; max-height: min(70vh, 620px); overflow: auto; }
  #teamBuilderView .team-coverage-mobile { display: none; }
  #teamBuilderView .team-coverage-table {
    width: min(100%, var(--matrix-mobile-width, 100%));
    min-width: min(280px, var(--matrix-mobile-width, 100%));
    max-width: 100%;
  }
  #teamBuilderView .team-coverage-opponent-column { width: 76px; }
  #teamBuilderView .team-coverage-matchup-column {
    width: calc((100% - 76px) / var(--matrix-team-count, 6));
  }
  #teamBuilderView .team-coverage-table .team-coverage-opponent-head,
  #teamBuilderView .team-coverage-table tbody th { width: 76px; }
  #teamBuilderView .team-coverage-table th,
  #teamBuilderView .team-coverage-table td { padding: 3px; }
  #teamBuilderView .team-coverage-table thead th { height: 64px; }
  #teamBuilderView .team-coverage-pokemon-head img { width: 100%; max-width: 38px; height: auto; aspect-ratio: 1; }
  #teamBuilderView .team-coverage-pokemon-head span { width: 100%; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 7px; }
  #teamBuilderView .team-coverage-form-badge { box-sizing: border-box; max-width: 100%; padding: 1px 2px; overflow: hidden; font-size: 5px; letter-spacing: 0; text-overflow: clip; }
  #teamBuilderView .team-coverage-opponent { grid-template-columns: minmax(0, 1fr); grid-template-areas: "sprite" "copy" "count"; justify-items: center; gap: 1px; text-align: center; }
  #teamBuilderView .team-coverage-opponent-sprite { grid-area: sprite; }
  #teamBuilderView .team-coverage-opponent-copy { grid-area: copy; width: 100%; gap: 0; }
  #teamBuilderView .team-coverage-answer-count { grid-area: count; }
  #teamBuilderView .team-coverage-opponent img { width: 28px; height: 28px; }
  #teamBuilderView .team-coverage-opponent-copy strong { font-size: 9px; }
  #teamBuilderView .team-coverage-opponent-copy small { display: none; }
  #teamBuilderView .team-coverage-answer-count { min-width: 0; font-size: 6px; text-align: center; }
  #teamBuilderView .team-matchup-cell.has-status-icon { min-height: 36px; }
  #teamBuilderView .team-coverage-status-legend .team-matchup-cell.has-status-icon { width: 36px; min-height: 36px; }
  #teamBuilderView .team-matchup-symbol.is-icon { width: 36px; height: 36px; min-width: 36px; }
  #teamBuilderView .team-matchup-cell::after { display: none; }
}
