.roster-modal[hidden],
.roster-undo-toast[hidden] {
  display: none !important;
}

body.modal-open {
  overflow: hidden;
}

.roster-modal {
  position: fixed;
  inset: 0;
  z-index: 99999;
}

.roster-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.58);
  backdrop-filter: blur(2px);
}

.roster-modal__panel {
  position: relative;
  z-index: 1;
  width: min(600px, calc(100vw - 18px));
  max-height: calc(100vh - 18px);
  margin: 9px auto;
  background: #10151d;
  color: #fff;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 60px rgba(0,0,0,0.42);
}

.roster-modal__header,
.roster-modal__footer {
  padding: 12px 14px;
  flex: 0 0 auto;
}

.roster-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.roster-modal__header h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

.roster-modal__close {
  appearance: none;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
}

.roster-modal__close:hover {
  background: rgba(255,255,255,0.08);
}

.roster-modal__body {
  padding: 12px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1 1 auto;
}

.roster-modal__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.roster-modal__footer-left {
  min-height: 20px;
  font-size: 13px;
  color: rgba(255,255,255,0.75);
}

.roster-toolbar {
  margin-bottom: 12px;
}

.roster-toolbar__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.roster-toolbar__team {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 4px;
}

.roster-toolbar__hint {
  font-size: 12px;
  line-height: 1.35;
  color: rgba(255,255,255,0.74);
}

.roster-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.roster-slot {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 8px;
  align-items: stretch;
  transition: transform 0.12s ease;
}

.roster-slot__label {
  background: #1a2330;
  color: #dce6f3;
  border-radius: 10px;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 6px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.15;
  border: 1px solid rgba(255,255,255,0.05);
}

.roster-slot__label.long-label{
  font-size:9px;
  letter-spacing:-0.04em;
  line-height:1.05;
}

.roster-slot__label.very-long-label{
  font-size:9px;
  letter-spacing:-0.03em;
  line-height:1.05;
  overflow-wrap:anywhere;
  word-break:break-word;
}

.roster-slot__card,
.roster-slot__empty {
  min-height: 60px;
  border-radius: 10px;
  background: #18212c;
  border: 1px solid transparent;
  transition: border-color 0.12s ease, background 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
}

.roster-slot__empty {
  display: flex;
  align-items: center;
  padding: 0 12px;
  color: rgba(255,255,255,0.42);
  font-size: 14px;
}

.roster-slot {
  transition: background 120ms ease, transform 120ms ease;
}

.roster-slot.is-hovered {
  transform: scale(1.02);
}

.roster-player {
  transition: transform 120ms ease, opacity 120ms ease;
  display: flex;
  align-items: center;
  gap: 10px;
}

.roster-player {
  position: relative;
  padding: 10px 12px;
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.roster-player:active {
  cursor: grabbing;
}

.roster-player__handle {
  flex: 0 0 auto;
  width: 22px;
  text-align: center;
  font-size: 16px;
  line-height: 1;
  opacity: 0.7;
}

.roster-player__content {
  flex: 1 1 auto;
  min-width: 0;
}
.roster-player__name {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.18;
  color: #fff;
}

.roster-player__meta {
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.2;
  color: rgba(255,255,255,0.72);
}

.roster-slot--bench .roster-slot__label {
  background: #23232f;
}

.roster-slot--milb .roster-slot__label {
  background: #203122;
}

.roster-slot.is-valid .roster-slot__card,
.roster-slot.is-valid .roster-slot__empty {
  border-color: #22c55e;
  box-shadow: 0 0 0 1px #22c55e inset;
}

.roster-slot.is-invalid .roster-slot__card,
.roster-slot.is-invalid .roster-slot__empty {
  opacity: 0.38;
}

.roster-slot.is-hovered .roster-slot__card,
.roster-slot.is-hovered .roster-slot__empty {
  background: #223041;
}

.roster-slot.is-selected .roster-slot__card {
  border-color: #60a5fa;
  box-shadow: 0 0 0 1px #60a5fa inset;
}

.roster-player.dragging-source {
  opacity: 0.30;
}

.roster-drag-ghost {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 100001;
  width: min(340px, calc(100vw - 24px));
  pointer-events: none;
  transform: translate3d(-9999px, -9999px, 0);
  border-radius: 10px;
  background: #18212c;
  border: 1px solid rgba(255,255,255,0.10);
  box-shadow: 0 8px 18px rgba(0,0,0,.35);
}

.roster-undo-toast {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 100002;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #10151d;
  color: #fff;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 14px 28px rgba(0,0,0,0.30);
}

.roster-undo-toast button,
.btn {
  appearance: none;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
}

.roster-undo-toast button,
.btn:not(.btn--secondary) {
  background: #2563eb;
  color: #fff;
}

.roster-modal .btn--secondary {
  background: rgba(255,255,255,0.08);
  color: #fff;
}

.roster-modal .btn--secondary:hover,
.roster-undo-toast button:hover,
.btn:not(.btn--secondary):hover {
  filter: brightness(1.07);
}

@media (max-width: 700px) {
  .roster-modal__panel {
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    margin: 0;
    border-radius: 0;
  }

  .roster-modal__header,
  .roster-modal__footer {
    padding: 12px;
  }

  .roster-modal__body {
    padding: 10px;
  }

  .roster-slot {
    grid-template-columns: 46px 1fr;
    gap: 7px;
  }

  .roster-slot__label,
  .roster-slot__card,
  .roster-slot__empty {
    min-height: 56px;
  }

  .roster-player {
    padding: 9px 10px;
  }

  .roster-player__name {
    font-size: 14px;
  }

  .roster-player {
    touch-action: pan-y;
  }

  .roster-player__handle {
    cursor: grab;
    touch-action: none;
  }
}

.roster-modal__panel {
  transform: translateY(0);
  opacity: 1;
  transition: transform .18s ease, opacity .18s ease;
}

.roster-modal.is-opening .roster-modal__panel {
  transform: translateY(18px);
  opacity: 0.96;
}

.roster-loading-state {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 220px;
  color: rgba(255,255,255,0.82);
  font-size: 14px;
}

.roster-loading-state__inner {
  display: flex;
  align-items: center;
  gap: 10px;
}

.roster-loading-spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.18);
  border-top-color: rgba(255,255,255,0.9);
  animation: rosterSpin .8s linear infinite;
}

@keyframes rosterSpin {
  to { transform: rotate(360deg); }
}

@media (max-width: 700px) {
  .roster-modal {
    display: flex;
    align-items: flex-end;
  }

  .roster-modal__backdrop {
    background: rgba(0, 0, 0, 0.5);
  }

  .roster-modal__panel {
    width: 100vw;
    height: min(92vh, 100vh);
    max-height: min(92vh, 100vh);
    margin: 0;
    border-radius: 18px 18px 0 0;
    border-bottom: 0;
  }

  .roster-modal__header::before {
    content: "";
    display: block;
    width: 42px;
    height: 5px;
    border-radius: 999px;
    background: rgba(255,255,255,0.22);
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: 8px;
  }

  .roster-modal__header {
    position: relative;
    padding-top: 20px;
  }
}
.roster-player,
.open-edit-roster,
.roster-modal__close,
#rosterCancelSelectionBtn,
#undoRosterMoveBtn,
[data-close-roster-modal] {
  -webkit-tap-highlight-color: transparent;
}

.roster-player {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
.roster-player.is-pending {
  background: rgba(255,193,7,0.16);
  border-left: 3px solid #ffc107;
}

.roster-player.is-pending .roster-player__name::after {
  content: "Pending";
  font-size: 10px;
  margin-left: 6px;
  color: #ffc107;
  font-weight: 700;
  letter-spacing: .3px;
}
.roster-temp-area {
  margin-bottom: 12px;
  padding: 10px;
  border-radius: 12px;
  background: rgba(239, 68, 68, 0.10);
  border: 1px solid rgba(239, 68, 68, 0.28);
}

.roster-temp-area__title {
  font-size: 13px;
  font-weight: 700;
  color: #fca5a5;
  margin-bottom: 8px;
}

.roster-temp-list {
  display: grid;
  gap: 8px;
}

.roster-player.is-temp {
  background: rgba(239, 68, 68, 0.14);
  border-left: 3px solid #ef4444;
}

.roster-player.is-temp .roster-player__name::after {
  content: "Emergency";
  font-size: 10px;
  margin-left: 6px;
  color: #fca5a5;
  font-weight: 700;
  letter-spacing: .3px;
}
