:root {
  --ink: #eef7fb;
  --muted: #9aa6ae;
  --line: rgba(216, 226, 232, 0.18);
  --panel: rgba(9, 14, 20, 0.97);
  --panel-strong: rgba(8, 12, 17, 0.99);
  --soft: rgba(232, 246, 255, 0.07);
  --accent: #aab7c2;
  --accent-strong: #f2f7fb;
  --gold: #d7a640;
  --orange: #e1783d;
  --red: #e05050;
  --blue: #b8d8f0;
  --page-pad: clamp(14px, 1.6vw, 28px);
  --gap: 12px;
  --radius: 0;
  --profile-width: clamp(440px, 44vw, 560px);
  --rail-width: 92px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  height: 100%;
  margin: 0;
  overflow-x: clip;
}

body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    url("/assets/ice-scratches.svg?v=3"),
    radial-gradient(circle at 18% -10%, rgba(196, 211, 222, 0.13), transparent 28%),
    radial-gradient(circle at 82% 10%, rgba(255, 255, 255, 0.08), transparent 26%),
    linear-gradient(135deg, #030507 0%, #081119 42%, #020405 100%);
  background-attachment: fixed;
  background-position: center, center, center, center;
  background-size: cover, auto, auto, auto;
  overflow: hidden;
  overscroll-behavior-x: none;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
}

body::before {
  opacity: 0.42;
  background:
    url("/assets/ice-scratches.svg?v=3"),
    radial-gradient(ellipse at 24% 34%, rgba(255, 255, 255, 0.08), transparent 16%),
    radial-gradient(ellipse at 72% 62%, rgba(210, 224, 232, 0.07), transparent 20%);
  background-position: center, 10% 20%, 82% 60%;
  background-size: cover, 640px 420px, 760px 500px;
  mix-blend-mode: screen;
}

body::after {
  opacity: 0.58;
  background:
    radial-gradient(ellipse at center, transparent 0 44%, rgba(0, 0, 0, 0.58) 100%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(0, 0, 0, 0.24));
}

h1,
h2,
h3,
p {
  letter-spacing: 0;
}

button,
select,
input {
  font: inherit;
}

button {
  color: inherit;
}

img {
  max-width: 100%;
}

body > *,
.dashboard,
.main-panel,
.top-deck,
.top-controls,
.logo-band,
.team-selector,
#tradeScenario,
#teamNeeds,
.trade-scenario-panel,
.team-needs-panel,
.market-panel,
.table-container,
.player-profile {
  min-width: 0;
  max-width: 100%;
}

.app-header {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 74px;
  padding: 14px var(--page-pad);
  overflow: hidden;
  isolation: isolate;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(8, 13, 19, 0.72), rgba(6, 10, 15, 0.58));
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
  transition: min-height 0.18s ease, padding 0.18s ease;
}

.app-header::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  opacity: 0.6;
  background:
    url("/assets/ice-scratches.svg?v=3"),
    radial-gradient(ellipse at 22% 20%, rgba(255, 255, 255, 0.08), transparent 18%),
    linear-gradient(180deg, rgba(8, 13, 19, 0.3), rgba(6, 10, 15, 0.56));
  background-position: center top, 20% 10%, center;
  background-size: cover, 520px 180px, cover;
  mix-blend-mode: screen;
}

.app-header h1 {
  margin: 0;
  font-size: clamp(30px, 2.6vw, 46px);
  line-height: 1;
  transition: font-size 0.18s ease;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  transition: opacity 0.18s ease, height 0.18s ease, margin 0.18s ease;
}

body.has-active-context .app-header,
body.chrome-is-collapsed .app-header,
body.profile-is-open .app-header {
  min-height: 42px;
  padding-block: 7px;
}

body.has-active-context .app-header h1,
body.chrome-is-collapsed .app-header h1,
body.profile-is-open .app-header h1 {
  font-size: 18px;
}

body.has-active-context .eyebrow,
body.chrome-is-collapsed .eyebrow,
body.profile-is-open .eyebrow {
  height: 0;
  margin: 0;
  overflow: hidden;
  opacity: 0;
}

.dashboard {
  position: relative;
  z-index: 1;
  width: 100%;
  height: calc(100vh - 74px);
  overflow: hidden;
}

body.has-active-context .dashboard,
body.chrome-is-collapsed .dashboard,
body.profile-is-open .dashboard {
  height: calc(100vh - 42px);
}

.main-panel {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  padding: 16px var(--page-pad) 18px;
  overflow-x: clip;
  overflow-y: auto;
  transition: padding-right 0.2s ease;
}

.top-deck {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--gap);
  width: 100%;
  margin-bottom: 10px;
}

.top-controls {
  display: grid;
  gap: 6px;
  align-items: start;
}

.team-trade-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: var(--gap);
  min-width: 0;
}

.team-trade-row.has-trade-partners {
  grid-template-columns: minmax(300px, 42%) minmax(0, 1fr);
}

#tradePartnerRail {
  min-width: 0;
}

#tradePartnerRail:empty {
  display: none;
}

.team-trade-row .logo-band {
  grid-column: 1 / -1;
}

.team-trade-row.has-trade-partners .logo-band {
  grid-column: auto;
}

.control-band {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

select {
  min-height: 36px;
  max-width: 100%;
  margin: 0;
  padding: 0 34px 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(7, 13, 18, 0.9);
  color: var(--ink);
  font-size: 14px;
}

.logo-band,
.trade-scenario-panel,
.team-needs-panel,
.market-panel {
  width: 100%;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.team-selector {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
  grid-auto-rows: 40px;
  gap: 6px;
  width: 100%;
  padding: 8px;
}

.team-selector.is-expanded {
  grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
}

.team-selector.is-compact {
  display: flex;
  align-items: center;
  min-height: 60px;
}

.team-logo-btn,
.icon-toggle-btn,
.profile-team-btn,
.trade-partner-option,
.likely-team-alt {
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--soft);
  color: var(--ink);
  cursor: pointer;
}

.team-logo-btn {
  width: 100%;
  height: 100%;
  min-width: 0;
  overflow: hidden;
}

.team-logo-btn:hover,
.team-logo-btn.is-selected,
.icon-toggle-btn:hover,
.profile-team-btn:hover,
.trade-partner-option:hover,
.trade-partner-option.is-selected,
.likely-team-alt:hover {
  border-color: rgba(216, 226, 232, 0.42);
  background: rgba(216, 226, 232, 0.1);
}

.team-logo-btn.is-selected {
  box-shadow: inset 0 0 0 2px var(--accent), 0 0 18px rgba(216, 226, 232, 0.16);
}

.team-logo-btn img {
  display: block;
  width: min(36px, 86%);
  height: min(36px, 86%);
  object-fit: contain;
  transform: scale(1.18);
}

.icon-toggle-btn {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  border-color: var(--line);
  font-size: 17px;
  font-weight: 800;
  line-height: 1;
}

.team-selector.is-expanded .icon-toggle-btn,
.selector-collapse {
  width: 100%;
  height: 100%;
}

.compact-selector {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-width: 0;
}

.expandable-summary {
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.expandable-summary:hover {
  background: rgba(216, 226, 232, 0.07);
}

.expandable-summary:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: -2px;
  background: rgba(216, 226, 232, 0.09);
}

.team-selector.is-compact .compact-selector {
  margin: -8px;
  padding: 8px;
  width: calc(100% + 16px);
}

.team-needs-panel.is-compact .team-needs-header.expandable-summary {
  margin: -1px -4px 8px;
  padding: 5px 4px;
}

.compact-logo {
  display: grid;
  place-items: center;
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  overflow: hidden;
  border: 1px solid rgba(216, 226, 232, 0.28);
  background: rgba(255, 255, 255, 0.05);
}

.compact-logo img {
  width: 34px;
  height: 34px;
  object-fit: contain;
}

#activeFilters {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
  min-height: 26px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border: 1px solid rgba(216, 226, 232, 0.26);
  background: rgba(216, 226, 232, 0.08);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
}

.chip:hover {
  background: rgba(216, 226, 232, 0.14);
}

.trade-scenario-panel,
.team-needs-panel {
  margin-bottom: 12px;
  padding: 12px;
}

.trade-scenario-header,
.team-needs-header,
.market-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.market-header {
  flex: 0 0 auto;
  min-height: 46px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
}

.market-header h2,
.trade-scenario-header h2,
.team-needs-header h2 {
  margin: 0;
  font-size: 16px;
  line-height: 1.1;
}

.market-header span,
.trade-scenario-header span,
.team-needs-header span {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scenario-trades {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(250px, 100%), 1fr));
  gap: 8px;
  max-height: 96px;
  margin-top: 10px;
  overflow: auto;
}

.scenario-trade,
.team-need-card,
.proposal-piece,
.custom-piece,
.future-panel,
.likely-trade-card,
.selected-need-summary {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.045);
}

.scenario-trade {
  padding: 9px;
}

.scenario-trade strong,
.scenario-trade span {
  display: block;
}

.scenario-trade span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.secondary-action,
.primary-action {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 700;
}

.secondary-action {
  padding: 0 9px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
  font-size: 12px;
}

.secondary-action:hover {
  background: rgba(216, 226, 232, 0.1);
}

.team-needs-panel.is-compact {
  padding: 9px 12px;
}

.team-needs-header {
  margin-bottom: 8px;
}

.team-needs-header > div,
.trade-partner-primary,
.trade-partner-card span,
.team-need-card,
.team-need-title,
.team-need-metrics {
  min-width: 0;
}

.team-needs-header h2,
.team-needs-header p {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.team-needs-header p,
.team-need-card p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.team-rail-identity,
.team-needs-mini-grid {
  display: none;
}

.trade-partner-panel {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  max-width: 100%;
  margin: 0;
  border: 1px solid rgba(216, 226, 232, 0.3);
  padding: 6px;
  background: rgba(216, 226, 232, 0.075);
  overflow: visible;
}

.trade-partner-cluster {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.trade-partner-label {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.trade-partner-label span {
  color: var(--accent-strong);
  font-size: 18px;
  line-height: 1;
}

.trade-partner-option {
  position: relative;
  flex: 0 0 46px;
  width: 46px;
  min-height: 46px;
  border-color: var(--line);
}

.trade-partner-option img {
  display: block;
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.trade-partner-option::after {
  content: attr(data-reason);
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  z-index: 20;
  display: none;
  width: max-content;
  max-width: min(280px, calc(100vw - (var(--page-pad) * 2)));
  padding: 7px 9px;
  border: 1px solid rgba(216, 226, 232, 0.34);
  background: rgba(5, 9, 13, 0.98);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
  pointer-events: none;
  text-align: left;
  white-space: normal;
}

.trade-partner-option:hover::after,
.trade-partner-option:focus-visible::after {
  display: block;
}

.trade-partner-clear,
.close-btn,
.remove-piece-btn {
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
}

.trade-partner-clear {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 22px;
  height: 22px;
  font-size: 16px;
}

.team-needs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(520px, 100%), 1fr));
  gap: 8px;
}

.team-need-card {
  padding: 10px 12px;
  overflow: hidden;
  border-left-width: 4px;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.team-need-card:hover {
  border-color: rgba(216, 226, 232, 0.3);
  background: rgba(216, 226, 232, 0.09);
}

.team-need-card:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: -2px;
  background: rgba(216, 226, 232, 0.09);
}

.team-need-card.is-selected {
  outline: 2px solid rgba(216, 226, 232, 0.76);
  outline-offset: -2px;
}

.team-need-card.urgent_need,
.team-need-mini.urgent_need,
.selected-need-summary.urgent_need {
  border-left-color: var(--red);
}

.team-need-card.high_need,
.team-need-mini.high_need,
.selected-need-summary.high_need {
  border-left-color: #cc4f2b;
}

.team-need-card.need,
.team-need-mini.need,
.selected-need-summary.need {
  border-left-color: var(--orange);
}

.team-need-card.want,
.team-need-mini.want,
.selected-need-summary.want {
  border-left-color: var(--gold);
}

.team-need-card.none,
.team-need-mini.none {
  border-left-color: var(--accent);
}

.team-need-title {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.team-need-title span {
  font-size: 12px;
  font-weight: 700;
}

.team-need-metrics {
  display: grid;
  gap: 4px;
  font-size: 12px;
}

.team-need-card small,
.team-need-card p,
.team-need-title strong,
.team-need-title span {
  overflow-wrap: anywhere;
}

.team-need-card small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.selected-need-summary {
  display: grid;
  gap: 3px;
  padding: 8px 10px;
  border-left: 4px solid var(--accent);
}

.selected-need-summary span {
  color: var(--muted);
  font-size: 12px;
}

.market-panel.is-hidden {
  display: none;
}

.market-panel {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  margin-bottom: 12px;
}

.table-container {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  overflow: auto;
}

table {
  width: 100%;
  min-width: 0;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  padding: 10px 12px;
  overflow: hidden;
  border-bottom: 1px solid rgba(173, 210, 225, 0.12);
  text-overflow: ellipsis;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  cursor: pointer;
  background: rgba(10, 18, 24, 0.98);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: left;
  text-transform: uppercase;
}

th:hover {
  background: rgba(216, 226, 232, 0.1);
}

td:first-child,
th:first-child {
  width: 25%;
}

td:nth-child(2),
th:nth-child(2) {
  width: 8%;
}

tbody tr:hover {
  background: rgba(216, 226, 232, 0.065);
}

tbody tr[data-player-id] {
  cursor: pointer;
}

tbody tr[data-player-id]:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: -2px;
  background: rgba(216, 226, 232, 0.09);
}

tbody tr.is-trade-target {
  background: rgba(215, 166, 64, 0.12);
  box-shadow: inset 3px 0 0 var(--gold);
}

.player-link {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  border: 0;
  background: none;
  color: var(--blue);
  font-size: inherit;
  font-weight: 750;
  text-align: left;
  text-overflow: ellipsis;
  vertical-align: bottom;
  white-space: nowrap;
}

.player-link:hover,
tbody tr[data-player-id]:hover .player-link {
  text-decoration: underline;
}

th.sort-asc::after {
  content: " ↑";
}

th.sort-desc::after {
  content: " ↓";
}

.pagination {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: auto;
  color: var(--muted);
  font-size: 13px;
}

.pagination button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
}

.pagination button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.player-profile {
  position: fixed;
  top: 12px;
  right: var(--page-pad);
  z-index: 10;
  width: min(440px, calc(100vw - (var(--page-pad) * 2)));
  max-width: 440px;
  height: calc(100vh - 24px);
  padding: 18px;
  overflow-x: hidden;
  overflow-y: auto;
  visibility: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-strong);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.52);
  transform: translateX(calc(100% + var(--page-pad)));
  transition: transform 0.2s ease, right 0.2s ease, width 0.2s ease;
  overflow-wrap: anywhere;
  contain: layout paint;
}

.player-profile.is-open {
  visibility: visible;
  transform: translateX(0);
}

.player-header {
  position: sticky;
  top: -18px;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin: -18px -18px 14px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 12, 17, 0.98);
}

.player-header h2 {
  margin: 0;
  font-size: 21px;
  line-height: 1.2;
}

.close-btn {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  color: var(--ink);
  font-size: 20px;
}

.player-profile > img {
  display: block;
  width: min(45%, 160px);
  height: auto;
  margin: 0 auto 10px;
}

.value-card {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 18px;
  padding: 12px;
  border: 1px solid rgba(216, 226, 232, 0.26);
  background: rgba(216, 226, 232, 0.08);
}

.value-score {
  flex: 0 0 82px;
  width: 82px;
  text-align: center;
}

.value-number {
  display: block;
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
}

.value-label {
  display: block;
  margin-top: 4px;
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 750;
}

.score-components {
  margin-top: 12px;
  border-top: 1px solid var(--line);
}

.score-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.primary-action {
  width: 100%;
  margin-top: 14px;
  padding: 0 12px;
  border-color: var(--accent);
  background: linear-gradient(180deg, #dbe4ea, #8d9ca8);
  color: #070b10;
}

.primary-action:hover {
  background: linear-gradient(180deg, #f3f7fb, #aebbc5);
}

.primary-action:disabled,
.primary-action.is-disabled {
  border-color: rgba(173, 210, 225, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  cursor: not-allowed;
}

.destination-picker,
.trade-proposal,
.custom-trade,
.trend-section,
.contract-section {
  margin-top: 18px;
}

.destination-picker h3,
.trade-proposal h3,
.custom-trade h3,
.trend-section h3,
.contract-section h3 {
  margin: 18px 0 8px;
  font-size: 16px;
}

.likely-trade-card,
.future-panel {
  margin-top: 10px;
  padding: 10px;
}

.likely-trade-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.likely-trade-header span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.likely-team-primary {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 58px;
  padding: 8px;
  border: 1px solid rgba(216, 226, 232, 0.36);
  background: rgba(216, 226, 232, 0.08);
  cursor: pointer;
  text-align: left;
}

.likely-team-primary strong,
.likely-team-primary small {
  display: block;
}

.likely-team-primary small,
.contract-note,
.future-panel p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.likely-team-primary img {
  width: 36px;
  height: 36px;
  transform: scale(1.16);
}

.likely-team-alternates,
.profile-team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
  gap: 6px;
  margin-top: 8px;
}

.likely-team-alt {
  min-height: 48px;
  padding: 5px;
  border-color: var(--line);
}

.likely-team-alt img,
.profile-team-btn img {
  width: 28px;
  height: 28px;
}

.profile-team-btn {
  aspect-ratio: 1;
  border-color: var(--line);
}

.proposal-pieces,
.custom-trade-list,
.heat-list {
  display: grid;
  gap: 8px;
}

.proposal-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.proposal-actions .secondary-action {
  flex: 1;
}

.proposal-piece {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 8px;
}

.proposal-piece-main {
  min-width: 0;
}

.proposal-piece-main strong,
.proposal-piece-main span,
.proposal-piece-main small {
  display: block;
}

.proposal-piece-main span,
.proposal-piece-main small,
.custom-piece span {
  color: var(--muted);
  font-size: 13px;
}

.remove-piece-btn {
  width: 26px;
  height: 26px;
  font-size: 18px;
}

.remove-piece-btn:hover {
  border-color: var(--red);
  color: var(--red);
}

.custom-trade-list {
  max-height: 260px;
  overflow: auto;
}

.custom-piece {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 8px;
  padding: 8px;
  cursor: pointer;
}

.custom-piece input {
  margin-top: 2px;
}

.contract-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin-bottom: 8px;
  padding: 0 8px;
  border: 1px solid rgba(216, 226, 232, 0.3);
  background: rgba(216, 226, 232, 0.09);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
}

.contract-badge.is-estimate {
  border-color: rgba(215, 166, 64, 0.5);
  background: rgba(215, 166, 64, 0.14);
  color: #ffd88a;
}

.profile-error {
  color: var(--red);
}

.heat-row-label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}

.heat-bar {
  height: 8px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
}

.heat-bar span {
  display: block;
  height: 100%;
}

.heat-good {
  background: var(--accent);
}

.heat-warn {
  background: var(--gold);
}

.heat-risk {
  background: var(--red);
}

.heat-missing {
  background: #72838b;
}

.season-history {
  max-height: 240px;
  overflow: auto;
  border: 1px solid var(--line);
}

.season-history table {
  font-size: 12px;
}

.season-history th,
.season-history td {
  padding: 6px;
}

@media (min-width: 1180px) {
  body.profile-is-open .main-panel {
    padding-right: calc(var(--profile-width) + var(--rail-width) + (var(--page-pad) * 3));
  }

  body.profile-is-open .player-profile {
    top: 54px;
    right: calc(var(--rail-width) + (var(--page-pad) * 2));
    width: var(--profile-width);
    max-width: 560px;
    height: calc(100vh - 66px);
  }

  body.profile-is-open #teamNeeds {
    position: fixed;
    top: 54px;
    right: var(--page-pad);
    z-index: 11;
    width: var(--rail-width);
    max-height: calc(100vh - 66px);
    overflow: hidden;
  }

  body.profile-is-open #teamNeeds .team-needs-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: calc(100vh - 66px);
    margin: 0;
    padding: 8px;
    overflow-y: auto;
    background: var(--panel-strong);
  }

  body.profile-is-open #teamNeeds .team-needs-header > div,
  body.profile-is-open #teamNeeds .team-needs-header > span,
  body.profile-is-open #teamNeeds .team-needs-grid,
  body.profile-is-open #teamNeeds .team-need-card,
  body.profile-is-open #teamNeeds .trade-partner-panel,
  body.profile-is-open #teamNeeds .icon-toggle-btn {
    display: none;
  }

  body.profile-is-open #teamNeeds .team-rail-identity {
    display: grid;
    place-items: center;
    height: 54px;
    overflow: hidden;
    border: 1px solid rgba(216, 226, 232, 0.24);
    background: rgba(255, 255, 255, 0.05);
  }

  body.profile-is-open #teamNeeds .team-rail-identity img {
    width: 44px;
    height: 44px;
    object-fit: contain;
    transform: scale(1.18);
  }

  body.profile-is-open #teamNeeds .team-needs-mini-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 7px;
  }

  body.profile-is-open #teamNeeds .team-need-mini {
    display: grid;
    gap: 3px;
    min-height: 50px;
    padding: 7px 5px;
    border: 1px solid var(--line);
    border-left-width: 3px;
    background: rgba(255, 255, 255, 0.045);
    cursor: pointer;
    font: inherit;
    text-align: left;
  }

  body.profile-is-open #teamNeeds .team-need-mini strong {
    overflow: hidden;
    font-size: 11px;
    line-height: 1.1;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.profile-is-open #teamNeeds .team-need-mini span {
    font-size: 15px;
    font-weight: 800;
    line-height: 1;
  }
}

@media (min-width: 901px) {
  body.chrome-is-collapsed .main-panel {
    padding-top: 8px;
  }

  body.chrome-is-collapsed .top-deck,
  body.chrome-is-collapsed #tradeScenario,
  body.chrome-is-collapsed #teamNeeds {
    display: none;
  }
}

@media (max-width: 900px) {
  :root {
    --page-pad: clamp(12px, 3vw, 20px);
  }

  html,
  body {
    height: auto;
    min-height: 100%;
  }

  body {
    overflow-y: auto;
    overscroll-behavior-y: none;
  }

  .app-header {
    position: sticky;
    top: 0;
  }

  .dashboard {
    height: auto;
    min-height: calc(100vh - 74px);
    overflow: visible;
  }

  .main-panel {
    height: auto;
    min-height: 0;
    padding-top: 12px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
    overflow: visible;
  }

  .team-selector {
    grid-template-columns: repeat(auto-fit, minmax(84px, 1fr));
  }

  .team-trade-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .team-trade-row.has-trade-partners {
    grid-template-columns: minmax(180px, 1fr) minmax(0, 1fr);
  }

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

  .market-panel {
    flex: 0 0 auto;
  }

  .table-container {
    max-height: none;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
  }

  table {
    min-width: 720px;
  }

  th,
  td {
    padding-inline: 10px;
  }

  .pagination {
    justify-content: space-between;
    margin-top: 4px;
  }

  .player-profile {
    inset: max(8px, env(safe-area-inset-top)) 8px 0;
    width: auto;
    max-width: none;
    height: calc(100dvh - max(8px, env(safe-area-inset-top)));
    padding-bottom: calc(18px + env(safe-area-inset-bottom));
    border-bottom: 0;
    transform: translateY(105%);
    transition: transform 0.24s ease;
    contain: layout paint;
  }

  .player-profile.is-open {
    transform: translateY(0);
  }

  body.profile-is-open {
    overflow: hidden;
  }
}

@media (max-width: 560px) {
  :root {
    --page-pad: 12px;
  }

  .app-header {
    min-height: auto;
    padding-block: 12px;
  }

  .app-header h1 {
    font-size: 24px;
  }

  .team-selector {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-auto-rows: 48px;
    gap: 5px;
  }

  .team-trade-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }


  .team-trade-row.has-trade-partners {
    grid-template-columns: minmax(96px, 0.45fr) minmax(0, 1.55fr);
  }

  .trade-partner-panel {
    gap: 4px;
    padding: 4px;
  }

  .trade-partner-option {
    flex-basis: 40px;
    width: 40px;
    min-height: 40px;
  }

  .trade-partner-option img {
    width: 28px;
    height: 28px;
  }

  .trade-partner-label {
    font-size: 11px;
  }

  .control-band {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
  }

  .control-band > div {
    width: 100%;
  }

  select {
    width: 100%;
    min-height: 44px;
  }

  .trade-scenario-header,
  .team-needs-header,
  .market-header {
    align-items: flex-start;
  }

  .trade-scenario-header,
  .team-needs-header {
    flex-wrap: wrap;
  }

  .team-needs-header > div,
  .trade-scenario-header > div {
    flex: 1 1 220px;
  }

  .team-needs-header p,
  .team-needs-header h2 {
    white-space: normal;
  }

  .trade-scenario-panel,
  .team-needs-panel {
    padding: 10px;
  }

  .scenario-trades {
    max-height: none;
  }

  .market-header {
    min-height: 50px;
  }

  .table-container {
    overflow: visible;
  }

  table,
  thead,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  table {
    min-width: 0;
  }

  thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
  }

  tbody {
    display: grid;
    gap: 1px;
  }

  tbody tr {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    padding: 11px 12px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.025);
  }

  tbody tr.is-trade-target {
    box-shadow: inset 3px 0 0 var(--gold);
  }

  td,
  td:first-child,
  td:nth-child(2) {
    display: flex;
    width: auto;
    min-width: 0;
    padding: 7px 5px;
    overflow: visible;
    border: 0;
    flex-direction: column;
    gap: 3px;
    white-space: normal;
  }

  td:first-child {
    grid-column: 1 / -1;
    padding-bottom: 10px;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
  }

  .player-link {
    min-height: 32px;
    font-size: 16px;
    white-space: normal;
  }

  .pagination {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    width: 100%;
    gap: 8px;
  }

  .pagination button {
    min-height: 44px;
  }

  .pagination button:last-child {
    justify-self: stretch;
  }

  .pagination button:first-child {
    justify-self: stretch;
  }

  .player-profile {
    inset-inline: 0;
    top: max(24px, env(safe-area-inset-top));
    height: calc(100dvh - max(24px, env(safe-area-inset-top)));
    padding: 16px;
    border-inline: 0;
  }

  .player-header {
    top: -16px;
    margin: -16px -16px 14px;
    padding: 14px 16px 10px;
  }

  .close-btn {
    width: 44px;
    height: 44px;
    flex-basis: 44px;
  }

  .value-card {
    align-items: flex-start;
  }

  .likely-team-primary {
    grid-template-columns: 38px minmax(0, 1fr);
  }

  .likely-team-primary > strong:last-child {
    grid-column: 2;
  }

  .proposal-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .secondary-action,
  .primary-action {
    min-height: 44px;
  }
}
