/* The squad editor places Match plan, Manager Career's pitch and Bench in order.
   Formation coordinates follow Snake Draft's own canonical slot ordering. */
.sd-lineup-panel {
  width: 100%;
  max-width: 940px;
  margin: 0 auto;
}

.sd-tactics-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 366px) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.sd-squad-card {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--site-line);
  border-radius: 6px;
  background: var(--site-panel);
}

.sd-squad-card .sd-panel-heading {
  margin-bottom: 8px;
}

.sd-pitch-card {
  width: 100%;
  max-width: 366px;
  justify-self: center;
}

.sd-plan-card .sd-panel-heading {
  display: grid;
  gap: 6px;
  justify-items: start;
}

.sd-plan-toggle {
  display: none;
}

.sd-squad-card .sd-panel-heading h2 {
  font-size: 16px;
  font-weight: 600;
}

.sd-squad-card .sd-panel-heading > span {
  color: var(--site-muted);
  font-size: 12px;
}

.sd-pitch {
  position: relative;
  width: min(100%, 340px);
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid #81b69850;
  border-radius: 8px;
  background:
    radial-gradient(ellipse at 50% 25%, #397e4525, #071e2a60),
    repeating-linear-gradient(0deg, #174c3c 0 10%, #1b5541 10% 20%);
  box-shadow: inset 0 0 65px #06191770;
}

.sd-pitch::before,
.sd-pitch::after,
.sd-pitch-lines::before,
.sd-pitch-lines::after {
  position: absolute;
  pointer-events: none;
  content: "";
}

.sd-pitch::before {
  inset: 50% 0 auto;
  border-top: 1px solid #ffffff50;
}

.sd-pitch::after {
  top: 50%;
  left: 50%;
  width: 22%;
  aspect-ratio: 1;
  border: 1px solid #ffffff50;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.sd-pitch-lines::before,
.sd-pitch-lines::after {
  left: 23%;
  width: 54%;
  height: 15%;
  border: 1px solid #ffffff50;
}

.sd-pitch-lines::before {
  top: -1px;
}

.sd-pitch-lines::after {
  bottom: -1px;
}

.sd-pitch-player {
  position: absolute;
  z-index: 2;
  top: var(--pitch-y);
  left: var(--pitch-x);
  display: grid;
  width: 18%;
  min-width: 44px;
  max-width: 80px;
  min-height: 44px;
  gap: 0;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 7px;
  color: #fff;
  background: transparent;
  transform: translate(-50%, -50%);
  touch-action: none;
  user-select: none;
}

.sd-pitch-players {
  position: relative;
  width: 100%;
  margin-top: 44px;
  aspect-ratio: .7;
}

.sd-pitch-player.is-selected {
  border-color: #fff;
  outline: 2px solid #9bf3be;
  outline-offset: 2px;
  background: #ffffff18;
}

.sd-pitch-player.is-out-of-position .sd-pitch-position {
  color: #ffda89;
}

.sd-pitch-face {
  position: relative;
  display: block;
  min-width: 0;
}

.sd-pitch-player .sd-pitch-portrait {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1.2;
  filter: drop-shadow(0 3px 3px #071b2a80);
}

.sd-pitch-portrait img {
  /* A grid image's intrinsic height exceeded this shallow portrait box.
     Fill its established bounds so contain preserves the entire cutout. */
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
}

.sd-pitch-portrait .sd-portrait-fallback {
  background: #295544;
  color: #d7e9dc;
}

.sd-pitch-rating {
  position: absolute;
  top: 0;
  right: 0;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  text-shadow: 0 1px 3px #000, 0 0 5px #000;
  font-variant-numeric: tabular-nums;
}

.sd-pitch-rating .sd-rating-penalty {
  display: block;
  margin-top: 1px;
  color: #ffda89;
  font-size: 9px;
  line-height: 1;
}

.sd-position-rating {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: baseline;
  gap: 4px;
  color: var(--site-text);
  font-size: 14px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.sd-rating-penalty {
  color: var(--site-muted);
  font-size: 10px;
  font-weight: 800;
}

.sd-bench-list .sd-position-rating,
.sd-bench-list .sd-rating-penalty {
  color: #fff;
}

.sd-pitch-info {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 3px 0;
  color: #fff;
  text-shadow: 0 1px 3px #000, 0 0 5px #000;
}

.sd-pitch-info > strong {
  overflow: hidden;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sd-pitch-position {
  display: block;
  color: #e0e9e2;
  font-size: 10px;
  font-weight: 500;
  line-height: 1.1;
}

.sd-bench-list {
  --sd-bench-colour: #245f8d;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 6px;
}

.sd-bench-list,
.sd-picker-options {
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--site-muted) 50%, transparent) transparent;
}

.sd-bench-list::-webkit-scrollbar,
.sd-picker-options::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.sd-bench-list::-webkit-scrollbar-thumb,
.sd-picker-options::-webkit-scrollbar-thumb {
  border: 1px solid transparent;
  border-radius: 6px;
  background: color-mix(in srgb, var(--site-muted) 50%, transparent);
  background-clip: padding-box;
}

.sd-bench-list::-webkit-scrollbar-track,
.sd-picker-options::-webkit-scrollbar-track {
  background: transparent;
}

.sd-bench-list button {
  display: flex;
  min-width: 0;
  min-height: 56px;
  align-items: center;
  gap: 8px;
  padding: 7px;
  border: 1px solid var(--site-line);
  border-radius: 6px;
  color: #fff;
  background: var(--sd-bench-colour);
  text-align: left;
  touch-action: pan-y;
  user-select: none;
}

.sd-bench-list .sd-portrait {
  width: 30px;
  height: 36px;
}

.sd-bench-copy {
  display: grid;
  flex: 1;
  min-width: 0;
  gap: 4px;
}

.sd-bench-copy strong {
  overflow: hidden;
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sd-bench-copy small {
  color: #ffffffdc;
  font-size: 11px;
}

.sd-bench-list b {
  font-size: 14px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.sd-drag-handle {
  display: grid;
  flex: 0 0 22px;
  place-items: center;
  align-self: stretch;
  min-height: 44px;
  margin-left: -6px;
  margin-right: -4px;
  color: #ffffffbc;
  font-size: 20px;
  touch-action: none;
  cursor: grab;
}

.sd-lineup-panel [data-lineup-drag]:not(:disabled) {
  cursor: grab;
}

.sd-lineup-panel [data-lineup-drag].is-dragging {
  opacity: .35;
}

.sd-lineup-panel [data-lineup-drag].is-drop-target {
  border-color: #b5ffcf;
  outline: 2px solid #b5ffcf;
  outline-offset: 2px;
  background: #4b916654;
}

#snakeDraftContent.is-lineup-dragging,
#snakeDraftContent.is-lineup-dragging [data-lineup-drag] {
  cursor: grabbing;
  user-select: none;
}

.sd-drag-ghost {
  position: fixed !important;
  z-index: 10000;
  margin: 0;
  padding: 6px;
  border: 1px solid #b5ffcf;
  border-radius: 7px;
  color: var(--site-text);
  background: var(--site-panel);
  box-shadow: 0 12px 32px #0008;
  pointer-events: none !important;
  transform: translate(-50%, -50%) !important;
  opacity: .95;
}

.sd-drag-ghost:not(.sd-pitch-player) {
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
}

.sd-drag-ghost .sd-drag-handle {
  display: none;
}

.sd-drag-ghost .sd-portrait:not(.sd-pitch-portrait) {
  width: 35px;
  height: 41px;
}

.sd-selected-position {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--site-line);
}

.sd-selected-position > span {
  min-width: 0;
  color: var(--site-muted);
  font-size: 12px;
}

.sd-selected-position .sd-selected-player-copy,
.sd-selected-position .sd-selected-player-copy > span {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.sd-selected-position .sd-selected-player-copy {
  flex-direction: column;
}

.sd-selected-position .sd-selected-player-copy > strong {
  color: var(--site-text);
  font-weight: 700;
}

.sd-selected-position .sd-button {
  flex-shrink: 0;
}

.sd-tactical-controls {
  display: grid;
  margin-top: 10px;
}

.sd-lineup-panel .sd-choice-field legend {
  margin-bottom: 8px;
  color: var(--site-text);
  font-size: 12px;
  font-weight: 700;
}

.sd-lineup-panel .sd-choice-options {
  display: grid;
  gap: 6px;
}

.sd-tactic-choice .sd-choice-options {
  grid-template-columns: minmax(0, 1fr);
}

.sd-lineup-panel .sd-choice-options button {
  min-height: 44px;
  padding: 8px;
  border-radius: 6px;
  background: transparent;
  color: var(--site-text);
  font-size: 12px;
  font-weight: 600;
}

.sd-lineup-panel .sd-choice-options button[aria-pressed="true"] {
  border-color: var(--sd-highlight);
  color: var(--site-text);
  background: color-mix(in srgb, var(--sd-highlight) 12%, var(--site-panel));
  font-weight: 800;
  box-shadow: inset 0 -2px 0 var(--sd-highlight);
}

.sd-pitch-tools {
  position: absolute;
  z-index: 5;
  top: 8px;
  left: 8px;
}

.sd-formation-menu {
  position: relative;
  width: fit-content;
  max-width: 100%;
}

.sd-formation-menu > summary {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  background: var(--site-panel);
  list-style: none;
  cursor: pointer;
}

.sd-formation-menu > summary::-webkit-details-marker {
  display: none;
}

.sd-formation-menu > summary strong {
  font-weight: 800;
}

.sd-formation-menu > summary svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

.sd-formation-menu[open] > summary {
  border-color: var(--sd-highlight);
}

.sd-formation-menu[open] > summary svg {
  transform: rotate(180deg);
}

.sd-formation-menu > summary[aria-disabled="true"] {
  opacity: .5;
  pointer-events: none;
}

.sd-formation-options {
  position: absolute;
  z-index: 6;
  top: calc(100% + 5px);
  left: 0;
  width: max(100%, 170px);
  max-height: min(320px, 60dvh);
  padding: 8px;
  overflow-y: auto;
  border: 1px solid var(--site-line);
  border-radius: 6px;
  background: var(--site-panel);
  box-shadow: 0 10px 24px #0005;
  scrollbar-width: thin;
  scrollbar-color: var(--site-muted) var(--site-panel);
}

.sd-lineup-panel .sd-formation-options legend {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  overflow: hidden;
  clip-path: inset(50%);
}

.sd-formation-options .sd-choice-options {
  grid-template-columns: minmax(0, 1fr);
}

.sd-plan-description {
  margin: 8px 0 0 !important;
  color: var(--site-muted);
  font-size: 12px;
  line-height: 1.5;
}

.sd-player-picker .sd-position-rating {
  flex: 0 0 auto;
}

.sd-player-picker .sd-rating-penalty {
  display: inline;
  margin: 0;
}

.sd-lineup-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.sd-lineup-actions .sd-button {
  flex: 1 1 auto;
  min-height: 44px;
}

.sd-squad-card .sd-lineup-save-state:is([data-save-state="pending"], [data-save-state="saving"], [data-save-state="offline"], [data-save-state="error"]) {
  color: #ffd18a;
}

@media (hover: hover) and (pointer: fine) {
  .sd-pitch-player:hover:not(:disabled) {
    border-color: #d6efde;
    background: #ffffff12;
  }

  .sd-bench-list button:hover:not(:disabled) {
    border-color: #ffffffa3;
    background: color-mix(in srgb, var(--sd-bench-colour) 88%, white);
  }
}

@media (max-width: 999px) {
  .sd-plan-card {
    position: relative;
    z-index: 6;
    padding: 0;
    border: 0;
    background: transparent;
  }

  .sd-plan-card .sd-panel-heading {
    margin: 0;
  }

  .sd-plan-card h2 {
    display: none;
  }

  .sd-plan-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 44px;
    font-weight: 700;
  }

  .sd-plan-toggle svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
  }

  .sd-plan-toggle[aria-expanded="true"] svg {
    transform: rotate(180deg);
  }

  .sd-plan-options {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    inset-inline: 0;
    padding: 12px;
    border: 1px solid var(--site-line);
    border-radius: 6px;
    background: var(--site-panel);
    box-shadow: 0 8px 24px #0005;
  }

  .sd-plan-card:has(.sd-plan-toggle[aria-expanded="true"]) .sd-plan-options {
    display: block;
  }

  .sd-lineup-panel {
    max-width: 366px;
  }

  .sd-tactics-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .sd-bench-list button {
    gap: 6px;
    padding: 7px;
  }

  .sd-tactic-choice .sd-choice-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sd-lineup-actions {
    flex-direction: row;
    align-items: center;
  }

  .sd-lineup-actions [data-action="ready"] {
    flex-basis: 100%;
  }
}

@media (max-width: 440px) {
  .sd-squad-card {
    padding: 12px;
  }

  .sd-pitch-player .sd-pitch-portrait {
    aspect-ratio: 1.35;
  }

  .sd-pitch-info > strong {
    font-size: 11px;
  }

  .sd-pitch-rating {
    font-size: 11px;
  }

  .sd-selected-position {
    align-items: stretch;
    flex-direction: column;
  }
}
