.team-builder {
  --roster-card-width: clamp(68px, 9.8vw, 132px);
  padding-block: 14px 48px;
}

.team-builder-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
  margin-bottom: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.team-builder h1 { font-size: clamp(24px, 3vw, 32px); font-weight: 500; letter-spacing: -.035em; }
.team-builder h2 { font-size: 17px; font-weight: 600; }
.team-builder-title-group { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 16px; min-width: 0; }
.team-builder-title-group h1 { overflow-wrap: anywhere; }
.team-builder-actions, .team-builder-total, .roster-summary, .roster-legality {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 16px;
}
.team-builder-total { color: var(--muted); font-variant-numeric: tabular-nums; }
.team-builder-total strong { color: var(--ink); font-weight: 600; }
.team-builder-actions { margin-left: auto; justify-content: flex-end; }
.roster-action-icon { display: block; flex: 0 0 16px; width: 16px; height: 16px; }
.roster-beta { display:inline-flex; flex:none; align-items:center; padding:4px 6px; border:1px solid currentColor; border-radius:4px; font:700 10px/1 var(--sans); letter-spacing:.06em; }
.roster-action, .roster-library-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface, var(--paper));
  color: var(--ink);
  font: 550 13px/1.4 var(--sans);
  text-decoration: none;
  white-space: nowrap;
}
.roster-library-link { padding-inline: 0; border-color: transparent; background: transparent; color: var(--muted); font-size: 13px; }
.roster-library-link:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 4px; }
.roster-action:not(:disabled):hover { border-color: color-mix(in srgb, var(--ink) 35%, var(--line)); background: var(--surface); }
.roster-action--primary { border-color: #275740; background: #275740; color: #fff; }
.roster-action--primary:not(:disabled):hover { border-color: #1d4632; background: #1d4632; }
.roster-action--quiet { background: transparent; }
.roster-action:disabled { color: var(--muted); opacity: .55; cursor: default; }
.roster-action--primary:disabled { color: #fff; }
.roster-action:focus-visible, .roster-library-link:focus-visible, .roster-format select:focus-visible, .roster-rules summary:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.roster-format { display: flex; align-items: center; flex-wrap: nowrap; gap: 6px 8px; }
.roster-format > span:first-child { color: var(--muted); font-size: 12px; font-weight: 500; }
.roster-format-control { position: relative; display: inline-flex; min-width: 0; }
.roster-format-control .roster-action-icon { position: absolute; top: 50%; right: 9px; transform: translateY(-50%); pointer-events: none; color: var(--muted); }
.roster-format select {
  min-width: 0;
  min-height: 36px;
  max-width: 100%;
  padding: 7px 30px 7px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface, var(--paper));
  color: var(--ink);
  font: 500 13px/1.4 var(--sans);
  appearance: none;
}
.roster-format select:hover { border-color: color-mix(in srgb, var(--ink) 35%, var(--line)); }
.roster-format select:disabled { opacity: .55; cursor: default; }
.roster-save-pdf { padding: 7px 10px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); }
.roster-save-pdf:disabled { color: var(--muted); cursor: default; }
.roster-shuffle-feedback { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; margin-block: 8px; color: var(--muted); font-size: 12px; }
.roster-shuffle-feedback p { margin: 0; }
.roster-shuffle-feedback:has([data-shuffle-status]:empty) { display: none; }
.roster-shuffle-feedback button { flex: none; }
.roster-summary { justify-content: space-between; }
.roster-legality {
  gap: 4px 12px;
  padding: 7px 10px;
  border: 1px solid currentColor;
  border-radius: 5px;
  background: var(--surface);
  color: var(--muted);
}
.roster-legality[data-status="valid"] { color: #23603b; background: #eaf5eb; }
.roster-legality[data-status="invalid"] { color: #862d34; background: #fcecea; }
[data-theme="dark"] .roster-legality[data-status="valid"] { color: #abe3b6; background: #233d2a; }
[data-theme="dark"] .roster-legality[data-status="invalid"] { color: #ffb4b9; background: #4b252b; }
.roster-notes { margin-block: 8px; padding-inline-start: 20px; color: var(--muted); }
.roster-rules { margin-top: 8px; color: var(--muted); }
.roster-rules summary { display: flex; align-items: center; gap: 5px; width: fit-content; min-height: 30px; color: var(--ink); font-weight: 550; cursor: pointer; list-style: none; }
.roster-rules summary::-webkit-details-marker { display: none; }
.roster-rules summary .roster-action-icon { transform: rotate(-90deg); }
.roster-rules[open] summary .roster-action-icon { transform: none; }
.roster-rules-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 32px; padding-block: 16px 8px; border-top: 1px solid var(--line); }
.roster-rules-grid h3 { color: var(--ink); font-size: 14px; font-weight: 600; }
.roster-rules p { margin-block: 6px; max-width: none; }
.roster-rules-source { display: inline-block; margin-block: 0 8px; text-underline-offset: 3px; }
.team-builder-roster { margin-top: 12px; }
.roster-print { display: none; }

.roster-support { display: grid; gap: 16px 20px; margin-top: 16px; }
.roster-field, .roster-pitchers, .roster-bench {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.roster-field {
  --field-grass: #e5ece5;
  --field-line: #a6b9a6;
  --field-infield: #d4d6bd;
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  align-items: start;
  gap: clamp(5px, 1vw, 12px) clamp(6px, 1.5vw, 20px);
  padding: clamp(9px, 1.2vw, 16px) clamp(10px, 2vw, 30px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field-grass);
}

[data-theme="dark"] .roster-field {
  --field-grass: #28382f;
  --field-line: #8ba591;
  --field-infield: #4a5041;
  --roster-slot-line: var(--field-line);
}

.roster-field::before, .roster-field::after {
  content: '';
  position: absolute;
  z-index: -1;
  pointer-events: none;
}

.roster-field::before {
  width: min(92%, 1200px);
  aspect-ratio: 1.75;
  left: 50%;
  bottom: 23%;
  border: 1px solid var(--field-line);
  border-radius: 50%;
  transform: translate(-50%, 0);
}

.roster-field::after {
  width: clamp(132px, 32%, 420px);
  aspect-ratio: 1;
  left: 50%;
  top: 63%;
  border: 1px solid var(--field-line);
  background: var(--field-infield);
  transform: translate(-50%, -50%) rotate(45deg);
}

.roster-field li:has([data-roster-slot="LF"]) { grid-area: 1 / 2 / 2 / 5; margin-top: 8px; }
.roster-field li:has([data-roster-slot="CF"]) { grid-area: 1 / 5 / 2 / 9; }
.roster-field li:has([data-roster-slot="RF"]) { grid-area: 1 / 9 / 2 / 12; margin-top: 8px; }
.roster-field li:has([data-roster-slot="3B"]) { grid-area: 2 / 1 / 3 / 4; margin-top: 8px; }
.roster-field li:has([data-roster-slot="SS"]) { grid-area: 2 / 4 / 3 / 7; }
.roster-field li:has([data-roster-slot="2B"]) { grid-area: 2 / 7 / 3 / 10; }
.roster-field li:has([data-roster-slot="1B"]) { grid-area: 2 / 10 / 3 / 13; margin-top: 8px; }
.roster-field li:has([data-roster-slot="C"]) { grid-area: 3 / 5 / 4 / 9; }
.roster-field li:has([data-roster-slot="DH"]) { grid-area: 3 / 9 / 4 / 12; }

.roster-slot { min-width: 0; width: min(100%, var(--roster-card-width)); }
.roster-field .roster-slot { justify-self: center; }
@media (min-width: 900px) {
  .roster-support { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); }
  .roster-field .roster-slot { --roster-card-width: clamp(68px, min(9.8vw, (100svh - 405px) / 4.3), 132px); }
}
.roster-slot button {
  display: grid;
  gap: 5px;
  width: 100%;
  padding: 4px;
  border: 1px solid var(--roster-slot-line, var(--line));
  border-radius: 5px;
  background: var(--paper);
  text-align: left;
}

.roster-slot button:hover, .roster-slot button:focus-visible { border-color: var(--accent); background: var(--surface); }
.roster-slot-meta {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  column-gap: 3px;
  min-width: 0;
  padding-inline: 1px;
  font-size: 11px;
  line-height: 1.22;
}
.roster-position { color: var(--muted); font-weight: 600; white-space: nowrap; }
.roster-slot-points { font-weight: 600; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.roster-slot-name { grid-column: 1 / -1; margin-top: 2px; overflow-wrap: anywhere; white-space: normal; }
.roster-fielding { color: var(--ink); }
.roster-card-art { display: grid; place-items: center; flex: none; width: 100%; aspect-ratio: 5 / 7; min-width: 0; overflow: hidden; }
.roster-card-art > img { width: 100%; height: 100%; object-fit: contain; border-radius: 4px; }
.roster-add, .roster-art-missing { background: var(--surface); border-radius: 4px; }
.roster-add { color: var(--accent); font-size: clamp(22px, 3vw, 34px); }
.roster-art-missing { padding: 4px; color: var(--muted); font-size: 11px; text-align: center; }
.roster-pitchers { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; max-width: 760px; }
.roster-bench-section { min-width: 0; }
.roster-bench-rail {
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-color: var(--line) transparent;
}
.roster-bench {
  --bench-card-width: clamp(85px, 9.1vw, 132px);
  display: flex;
  width: max-content;
  margin: 0 auto;
  padding: 12px 6px 8px;
}
.roster-bench .roster-slot { position: relative; flex: 0 0 var(--bench-card-width); }
.roster-bench .roster-slot + .roster-slot { margin-inline-start: calc(var(--bench-card-width) * -.23); }
.roster-bench .roster-slot:focus-within { z-index: 1; }
.roster-bench .roster-slot button:focus-visible { transform: translateY(-8px); }
@media (hover: hover) and (pointer: fine) {
  .roster-bench .roster-slot:hover { z-index: 1; }
  .roster-bench .roster-slot:hover button { transform: translateY(-8px); }
}
@media (prefers-reduced-motion: no-preference) {
  .roster-bench .roster-slot button { transition: transform 140ms ease-out; }
}
.team-builder-dialog {
  width: min(100% - 28px, 560px);
  max-height: 86dvh;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--ink);
  background: var(--paper);
  box-shadow: 0 18px 60px #0003;
}

.team-builder-dialog[open] { display: flex; flex-direction: column; gap: 9px; }
.team-builder-dialog:has(.roster-search-panel:not([hidden])) {
  height: min(820px, 86dvh);
}
.team-builder-dialog::backdrop { background: #0006; }
body:has(.team-builder-dialog[open]) { overflow: hidden; }
.roster-picker-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.roster-picker-heading h2 { font-size: 22px; font-weight: 600; letter-spacing: -.025em; }
.roster-close { width: 34px; height: 34px; border: 0; border-radius: 6px; background: var(--surface); font-size: 20px; line-height: 1; }
.roster-current-card {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
  gap: 14px;
  align-items: start;
}
.roster-current-card:has(> .roster-current-info:only-child) { grid-template-columns: 1fr; }
.roster-current-info h3 { font-size: 17px; }
.roster-current-info > p { margin-top: 5px; color: var(--muted); overflow-wrap: anywhere; }
.roster-current-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.roster-current-actions > *, .roster-pages button { padding: 7px 9px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); }
.roster-full-value { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
.roster-full-value input { accent-color: var(--accent); }
.roster-move-label { display: flex; align-items: center; gap: 8px; margin-top: 8px; color: var(--muted); }
.roster-move-label select, .roster-search-controls select, #roster-player-search { padding: 8px 10px; border: 1px solid var(--line); border-radius: 5px; color: var(--ink); background: var(--paper); }
.roster-move-label select { min-width: 0; max-width: 75%; }
.roster-search-panel { display: flex; flex: 1; flex-direction: column; min-height: 0; gap: 9px; }
.roster-search-controls {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
  gap: 10px;
}
.roster-search-controls label { display: grid; gap: 3px; min-width: 0; color: var(--muted); font-size: 12px; font-weight: 550; }
.roster-search-controls select { width: 100%; min-width: 0; min-height: 40px; font: 500 14px/1.4 var(--sans); }
.roster-search-filters { display: flex; align-items: center; flex-wrap: wrap; gap: 2px 16px; font-size: 13px; }
.roster-search-filters label { display: inline-flex; align-items: center; gap: 7px; min-height: 30px; font-weight: 500; cursor: pointer; }
.roster-search-filters input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.roster-result-count { margin-inline-start: auto; }
#roster-player-search { width: 100%; min-height: 40px; font-size: 16px; }
.roster-result-count, .roster-empty { color: var(--muted); }
.roster-picker-feedback, .roster-player-text .roster-unavailable { color: var(--muted); font-weight: 600; }
.roster-player-results { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; border-top: 1px solid var(--line); }

.roster-player-option {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 8px;
  border: 0;
  border-radius: 0;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  text-align: left;
}

.roster-player-option:hover { background: var(--surface); }
.roster-select { position: absolute; inset: 0; z-index: 1; width: 100%; border: 0; background: transparent; cursor: pointer; }
.roster-select:focus-visible { outline-offset: -2px; }
.roster-select[aria-disabled="true"] { cursor: default; }
a.roster-player-points { position: relative; z-index: 2; width: fit-content; text-decoration: none; }
.roster-player-option .roster-card-art { width: clamp(60px, 8vw, 76px); }
.roster-player-text, .roster-player-stats { display: grid; min-width: 0; gap: 2px; }
.roster-player-text { overflow-wrap: anywhere; }
.roster-player-text strong { font-size: 15px; line-height: 1.2; }
.roster-player-text span { color: var(--muted); font-size: 12px; }
.roster-player-text .roster-player-positions { color: var(--ink); }
.roster-player-points { display: flex; flex-wrap: wrap; gap: 2px 12px; margin-top: 3px; font-variant-numeric: tabular-nums; }
.roster-player-points > span { white-space: nowrap; }
.roster-player-points b { color: var(--ink); font-size: 13px; font-weight: 650; }
.roster-projection { margin-top: 3px; font-variant-numeric: tabular-nums; }
.roster-projection b { color: var(--ink); font-weight: 650; }
.roster-budget-margin { white-space: nowrap; }
a.roster-player-points:is(:hover, :focus-visible) b { text-decoration: underline; text-underline-offset: 2px; }
.roster-empty { padding: 14px 0; }
.roster-pages { display: flex; justify-content: space-between; }
.roster-pages button:disabled { color: var(--muted); cursor: default; }

@media (min-width: 850px), (min-width: 600px) and (max-height: 500px) {
  .team-builder-dialog:has(.roster-search-panel:not([hidden])) { width: min(100% - 64px, 900px); }
  .roster-search-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
    grid-template-rows: auto auto minmax(0, 1fr);
  }
  #roster-player-search { align-self: end; }
  .roster-search-filters, .roster-player-results, .roster-pages { grid-column: 1 / -1; }
}

@media (min-width: 850px) {
  .roster-player-results { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: start; column-gap: 20px; }
  .roster-empty { grid-column: 1 / -1; }
}

@media (max-height: 600px) {
  .team-builder-dialog:has(.roster-search-panel:not([hidden])) { height: calc(100dvh - 16px); max-height: calc(100dvh - 16px); }
}

@media (max-width: 470px) {
  .roster-search-filters { display: grid; grid-template-columns: 1fr auto; column-gap: 6px; }
  .roster-search-filters label:last-of-type { grid-column: 1 / -1; }
  .roster-result-count { grid-column: 2; grid-row: 1; }
  .team-builder { padding-block: 12px 40px; }
  .team-builder-heading { align-items: flex-start; flex-direction: column; gap: 8px; }
  .team-builder-actions { width: 100%; column-gap: 8px; }
  .team-builder-title-group { width: 100%; justify-content: space-between; }
  .team-builder-actions .roster-format { flex-basis: 100%; }
  .roster-format-control { flex: 1; }
  .roster-format select { width: 100%; }
  .team-builder-actions .roster-action { flex: 1 1 auto; }
  .team-builder-actions :is(select, button) { min-height: 40px; }
  .roster-rules summary { padding-block: 6px; }
  .roster-field { gap: 5px; }
  .roster-slot button { gap: 3px; padding: 3px; }
  .roster-slot-meta { font-size: 10px; }
  .team-builder-dialog { padding: 13px; }
}

@media (max-width: 405px) {
  .roster-search-controls { grid-template-columns: minmax(0, 1fr); gap: 5px; }
  .roster-search-controls label { grid-template-columns: 6ch minmax(0, 1fr); align-items: center; gap: 7px; }
  .roster-search-controls select { padding-inline: 6px; }
}

@media print {
  body:has(.team-builder) { color: #111; background: #fff; }
  body:has(.team-builder)::before, body:has(.team-builder)::after,
  body:has(.team-builder) > :not(main), .team-builder > :not(.roster-print) { display: none !important; }
  body:has(.team-builder) #main, .team-builder { width: 100%; max-width: none; margin: 0; padding: 0; }
  .roster-print { display: block; font-size: 10pt; }
  .roster-print h1 { color: #111; font-size: 21pt; }
  .roster-print p { margin: 5pt 0 12pt; }
  .roster-print table { width: 100%; border-collapse: collapse; }
  .roster-print tr { break-inside: avoid; }
  .roster-print th, .roster-print td { padding: 4pt; border-bottom: 1px solid #ccc; text-align: left; }
  .roster-print th:last-child, .roster-print td:last-child { text-align: right; white-space: nowrap; }
}

.roster-estimate { font-weight: 550; }
.roster-estimate[data-value="1"], .roster-player-points [data-value="1"] b, .roster-projection[data-budget="fits"] .roster-budget-margin { color: #23603b; }
.roster-estimate[data-value="-1"], .roster-player-points [data-value="-1"] b, .roster-projection[data-budget="over"] .roster-budget-margin { color: #862d34; }
[data-theme="dark"] .roster-estimate[data-value="1"], [data-theme="dark"] .roster-player-points [data-value="1"] b, [data-theme="dark"] .roster-projection[data-budget="fits"] .roster-budget-margin { color: #abe3b6; }
[data-theme="dark"] .roster-estimate[data-value="-1"], [data-theme="dark"] .roster-player-points [data-value="-1"] b, [data-theme="dark"] .roster-projection[data-budget="over"] .roster-budget-margin { color: #ffb4b9; }
.my-rosters { padding-block: 24px 52px; }
.my-rosters ul { list-style: none; padding: 0; }
.saved-roster-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding-block: 16px; border-bottom: 1px solid var(--line); }
.saved-roster-row a { display: grid; gap: 5px; min-width: 0; overflow-wrap: anywhere; text-decoration: none; }
.saved-roster-row a:hover { text-decoration: underline; text-underline-offset: 4px; }
.saved-roster-row a strong { font-size: 16px; font-weight: 600; }
.saved-roster-row small { color: var(--muted); }
.roster-name-form { display: grid; gap: 10px; }
.roster-name-form input { padding: 8px 10px; border: 1px solid var(--line); border-radius: 5px; background: var(--paper); color: var(--ink); font: inherit; }
.roster-name-form button { justify-self: start; }

/* One playmat: a large diamond, a card hand below, and reserves at the right. */
.team-builder { width: min(1320px, calc(100% - 40px)); --roster-card-width: 100%; }
body:has(.team-builder) { background: var(--paper); }
.team-builder-heading { padding-bottom: 12px; margin-bottom: 12px; }
.team-builder h1 { font-size: clamp(24px, 2.5vw, 30px); font-weight: 650; line-height: 1.15; }
.team-builder-actions { gap: 8px; font-size: 13px; }
.roster-save-pdf { padding: 6px 8px; }
.roster-summary { width: fit-content; max-width: 100%; justify-content: flex-start; padding: 0; gap: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); }
.team-builder-total { flex: initial; gap: 0; margin: 0; }
.roster-metric { display: grid; gap: 2px; padding: 6px 14px; border-right: 1px solid var(--line); }
.roster-metric small { font-size: 12px; line-height: 1.3; color: var(--muted); }
.roster-metric strong { font-size: 13px; line-height: 1.3; font-weight: 600; }
.roster-metric.roster-estimate strong { color: inherit; }
.roster-summary .roster-legality { align-self: stretch; margin: 0; padding: 8px 14px; border: 0; border-radius: 0; font-size: 12px; }
.roster-rules { margin-top: 8px; font-size: 13px; line-height: 1.55; }
.team-builder-mat { margin-top: 10px; overflow-x: auto; overscroll-behavior-inline: contain; border-radius: 10px; scrollbar-color: #b3c9b4 #173d2d; }
.team-builder-mat:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.team-builder-roster { display: grid; grid-template-columns: minmax(0, 1fr) 180px; grid-template-areas: "field reserves" "lineup reserves"; align-items: start; gap: 4px 20px; min-width: 900px; margin: 0; padding: 20px 16px 16px; border: 1px solid #517b5e; border-radius: 10px; background: #2b5140; }
[data-theme="dark"] .team-builder-roster { background-color: #1d4233; }
.team-builder-roster h2 { color: #e4e9d9; font-size: 12px; font-weight: 500; }
.roster-diamond { grid-area: field; position: relative; justify-self: center; width: 100%; max-width: 780px; aspect-ratio: 600 / 520; }
.roster-diamond-art { display: block; width: 100%; height: 100%; overflow: visible; }
.field-outfield { fill: #bcd8a408; stroke: #dbe5c329; stroke-width: 1; }
.field-infield { fill: #bc996450; stroke: #e1d9b780; stroke-width: 1.5; }
.field-grass { fill: #2b5140; }
[data-theme="dark"] .field-grass { fill: #1d4233; }
.field-foul-lines { fill: none; stroke: #e5e8cf60; stroke-width: 1.5; }
.field-mound { fill: #c4a67b61; }
.field-bases { fill: #f2ebce; }
.field-runner-zones { fill: transparent; stroke: #e4e3c54a; stroke-width: 1; stroke-dasharray: 3 4; }
.field-player { position: absolute; transform: translate(-50%, -50%); display: grid; gap: 3px; width: 12%; padding: 0; border: 0; background: transparent; color: #e5eadb; text-align: center; }
.field-player-label { font-size: 11px; line-height: 12px; font-weight: 600; }
.field-player .roster-card-art { border-radius: 4px; box-shadow: 0 3px 7px #0004; }
.field-player-empty { border: 1px solid #dedfc64a; color: #d5ddc5; background: #123a2420; font-size: 26px; box-shadow: none !important; }
.field-player:hover .roster-card-art, .field-player:focus-visible .roster-card-art { outline: 2px solid #e8e1b5; outline-offset: 2px; }
.field-player[data-position="CF"] { left: 50%; top: 10.58%; }
.field-player[data-position="LF"] { left: 16.67%; top: 10.58%; }
.field-player[data-position="RF"] { left: 83.33%; top: 10.58%; }
.field-player[data-position="SS"] { left: 36.67%; top: 28.85%; }
.field-player[data-position="2B"] { left: 63.33%; top: 28.85%; }
.field-player[data-position="3B"] { left: 15%; top: 53.85%; }
.field-player[data-position="1B"] { left: 85%; top: 53.85%; }
.field-player[data-position="P"] { left: 50%; top: 53.85%; }
.field-player[data-position="C"] { left: 50%; top: 88.46%; }
.field-player[data-position="DH"] { left: 85%; top: 88.46%; }
.roster-lineup { grid-area: lineup; min-width: 0; padding: 0; }
.roster-lineup h2 { width: min(100%, 654px); margin: 0 auto; padding-inline: 8px; }
.roster-batters { display: flex; justify-content: center; width: max-content; max-width: 100%; margin: 0 auto; padding: 20px 8px 8px; list-style: none; }
.roster-batters .roster-slot { position: relative; flex: 0 0 110px; width: 110px; }
.roster-batters .roster-slot + .roster-slot { margin-left: -44px; }
.roster-reserves { grid-area: reserves; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-self: stretch; gap: 14px; min-width: 0; min-height: 0; padding-left: 12px; border-left: 1px solid #dbe5c329; }
.roster-rotation, .roster-bench-section { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 0; }
.roster-reserves h2 { text-align: center; }
.roster-pitchers, .roster-bench { display: flex; flex: 1 1 0; flex-direction: column; align-items: center; width: 100%; height: 0; min-height: 0; max-width: none; gap: 0; margin: 0; padding: 14px 3px 12px; overflow-y: auto; overscroll-behavior: contain; list-style: none; scrollbar-width: thin; scrollbar-color: #b3c9b4 #173d2d; }
.roster-pitchers .roster-slot, .roster-bench .roster-slot { position: relative; flex: 0 0 auto; width: 70px; }
.roster-pitchers .roster-slot + .roster-slot, .roster-bench .roster-slot + .roster-slot { margin: -49px 0 0; }
.roster-pitchers .roster-slot:not(.roster-slot--filled), .roster-bench .roster-slot:not(.roster-slot--filled) { margin-top: 8px; }
.team-builder-roster .roster-slot button { display: block; width: 100%; min-height: 0; padding: 0; border: 0; border-radius: 4px; background: transparent; text-align: center; box-shadow: 0 2px 5px #0004; }
.team-builder-roster .roster-slot button:hover, .team-builder-roster .roster-slot button:focus-visible { background: transparent; }
.team-builder-roster .roster-card-art { max-height: none; border-radius: 4px; }
.team-builder-roster .roster-add { display: grid; place-items: center; border: 1px solid #dedfc64a; background: #123a2420; color: #d5ddc5; font-size: 26px; line-height: 1; }
.roster-batters .roster-add { font-size: 24px; }
.roster-slot:focus-within { z-index: 20; }
.roster-batters .roster-slot:focus-within button { transform: translateY(-12px); outline: 2px solid #e8e1b5; outline-offset: 2px; }
.roster-reserves .roster-slot:focus-within button { transform: translateY(-4px); outline: 2px solid #e8e1b5; outline-offset: 1px; }
@media (hover: hover) and (pointer: fine) {
  .roster-batters .roster-slot:hover, .roster-reserves .roster-slot:hover { z-index: 20; }
  .roster-batters .roster-slot:hover button { transform: translateY(-12px); }
  .roster-reserves .roster-slot:hover button { transform: translateY(-4px); }
}
@media (prefers-reduced-motion: no-preference) {
  .roster-batters .roster-slot button, .roster-reserves .roster-slot button { transition: transform 140ms ease-out; }
}
@media (max-width: 760px) {
  .team-builder { width: calc(100% - 24px); }
  .team-builder-heading { align-items: flex-start; flex-direction: column; }
  .team-builder-actions { width: 100%; flex-wrap: wrap; justify-content: flex-start; }
  .roster-summary, .team-builder-total { gap: 0; }
  .roster-summary { flex-direction: row; }
  .roster-metric { padding: 5px 8px; }
  .roster-summary .roster-legality { flex: 1; }
}
@media (min-width: 600px) and (max-width: 900px) {
  .roster-rules-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 24px; }
}
@media (max-width: 599px) {
  .roster-rules-grid { grid-template-columns: minmax(0, 1fr); gap: 8px; }
}

.roster-move-feedback { margin-block: 6px; color: var(--muted); font-size: 13px; }
.roster-move-feedback:empty { display: none; }
.team-builder-roster [data-roster-slot][draggable="true"] { cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; }
.team-builder-roster img { -webkit-user-drag: none; user-select: none; }
.team-builder-roster .roster-drag-source { opacity: .4; cursor: grabbing; }
.team-builder-roster .roster-drop-allowed { outline: 1px dashed #e8e1b5a8; outline-offset: 3px; }
.team-builder-roster .roster-drop-target { outline: 3px solid #f7e9a2; outline-offset: 3px; }
.team-builder-roster .roster-drop-invalid { outline: 2px solid #e99787; outline-offset: 3px; }
.team-builder-roster.roster-is-dragging .roster-slot button { transform: none; transition: none; }
.roster-drag-ghost { position: fixed; z-index: 12000; display: grid; padding: 0; border: 0; border-radius: 4px; color: #e5eadb; background: transparent; transform: translate(-50%, -50%); pointer-events: none; opacity: .9; box-shadow: 0 10px 25px #0006; }
.roster-drag-ghost .field-player-label { display: none; }
.roster-drag-ghost .roster-card-art { width: 100%; height: 100%; }
