body {
  font-family: Arial, sans-serif;
  margin: 0;
  background: #111827;
  color: #f9fafb;
}

* {
  box-sizing: border-box;
}

header {
  text-align: center;
  padding: 32px 16px;
  background: #1f2937;
}

.header-content {
  max-width: 900px;
  margin: 0 auto;
}

h1 {
  margin-bottom: 8px;
}

main {
  max-width: 1320px;
  margin: 24px auto;
  padding: 0 16px;
}

.creator-bar {
  max-width: 900px;
  margin: 0 auto;
}

.creator-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  align-items: center;
  gap: 12px;
}

#customListToggle,
.save-list-button,
.reset-list-button {
  width: 180px;
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 8px;
  color: #111827;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

#customListToggle {
  justify-self: start;
  background: #64b5f6;
}

.is-editing #customListToggle {
  background: #80cbc4;
}

.save-list-button {
  justify-self: center;
  background: #b39ddb;
}

.reset-list-button {
  justify-self: end;
  background: #e57373;
}

.edit-mode-message {
  margin: 10px 0 0;
  color: #d1d5db;
  font-size: 13px;
  line-height: 1.3;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(17, 24, 39, 0.72);
}

.modal-backdrop.is-hidden {
  display: none;
}

.save-dialog {
  width: min(360px, 100%);
  padding: 18px;
  border-radius: 8px;
  background: #1f2937;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

.save-dialog h2 {
  margin: 0 0 14px;
  font-size: 20px;
}

.save-dialog button {
  display: block;
  width: 100%;
  min-height: 42px;
  margin-top: 10px;
  border: 0;
  border-radius: 8px;
  background: #f9fafb;
  color: #111827;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.save-dialog .dialog-close-button {
  background: #374151;
  color: #f9fafb;
}

.controls {
  display: flex;
  gap: 12px;
  margin: 24px auto 20px;
  max-width: 900px;
  width: 100%;
  align-items: flex-end;
}

.controls > input,
.controls > select {
  margin-top: 20px;
}

.team-count-control {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: #f9fafb;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.team-count-control.is-hidden {
  display: none;
}

.team-count-control select {
  width: 110px;
}

input,
select {
  height: 44px;
  padding: 0 14px;
  font-size: 16px;
  border-radius: 8px;
  border: 1px solid #374151;
  background-color: #f9fafb;
  color: #111827;
  box-sizing: border-box;
}

input {
  flex: 1;
  min-width: 0;
}

select {
  width: 160px;
  flex-shrink: 0;
  cursor: pointer;
}

.tier-select {
  width: 100%;
  min-width: 0;
  height: 34px;
  padding: 0 6px;
  border: 0;
  border-radius: 999px;
  color: #111827;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

.draggable-row {
  cursor: grab;
  transition: background-color 80ms ease, opacity 80ms ease;
}

.draggable-row:active {
  cursor: grabbing;
}

.drag-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  font-weight: 700;
}

.drag-rank::before {
  content: "::";
  margin-right: 5px;
  color: #9ca3af;
  font-weight: 700;
}

.is-row-dragging {
  opacity: 0.55;
  background: #273449;
}

.is-swap-selected td {
  background: #93c5fd;
  color: #111827;
}

.is-swap-selected .team,
.is-swap-selected .experience {
  color: #111827;
}

.is-dragging-row {
  user-select: none;
}

.rankings-layout {
  max-width: 900px;
  margin: 0 auto;
  position: relative;
}

table {
  width: 100%;
  margin-top: 0;
  border-collapse: collapse;
  background: #1f2937;
  border-radius: 8px;
  overflow: hidden;
  table-layout: fixed;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid #374151;
  text-align: center;
  overflow-wrap: anywhere;
}

th {
  background: #374151;
}

th:nth-child(1),
td:nth-child(1) {
  width: 112px;
}

th:nth-child(2),
td:nth-child(2) {
  width: 78px;
}

th:nth-child(3),
td:nth-child(3) {
  width: auto;
  overflow-wrap: anywhere;
}

th:nth-child(4),
td:nth-child(4) {
  width: 110px;
}

th:nth-child(5),
td:nth-child(5) {
  width: 78px;
}

th:nth-child(6),
td:nth-child(6) {
  width: 156px;
}

.round-divider-row td {
  padding: 0;
  height: 24px;
  background: #111827;
  border-bottom: 1px solid #374151;
}

.round-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 24px;
  color: #f9fafb;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-align: center;
}

.round-divider::before,
.round-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #f9fafb;
  opacity: 0.85;
}

.round-divider span {
  padding: 0 10px;
  white-space: nowrap;
}

.experience,
.team {
  font-weight: 700;
  letter-spacing: 0;
}

.tier {
  font-weight: bold;
  padding: 6px 10px;
  border-radius: 999px;
  color: #111827;
  display: inline-block;
}

.tier-legend {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-start;
}

.tier-legend-mobile {
  display: none;
}

.tier-legend-desktop {
  position: absolute;
  top: 4px;
  left: calc(100% + 32px);
  width: 170px;
  padding-top: 2px;
}

.legend-tier {
  position: relative;
  cursor: help;
  white-space: nowrap;
}

.legend-tier::after {
  content: attr(data-description);
  position: absolute;
  top: 50%;
  left: var(--tooltip-left, calc(100% + 3px));
  z-index: 10;
  width: 220px;
  max-width: 220px;
  padding: 10px 12px;
  border-radius: 8px;
  background: inherit;
  color: #111827;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
  white-space: normal;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-50%) translateX(-4px);
  transition: opacity 140ms ease, transform 140ms ease;
}

.legend-tier:hover::after,
.legend-tier:focus-visible::after {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

.elite {
  background: #e57373;
}

.great {
  background: #ffb74d;
}

.good {
  background: #fff176;
}

.flex {
  background: #a5d6a7;
}

.bench {
  background: #80cbc4;
}

.dart {
  background: #64b5f6;
}

.undrafted {
  background: #b39ddb;
}

@media (max-width: 900px) {
  main {
    width: 100%;
    padding: 0 10px;
  }

  header {
    min-height: 56vh;
    padding: 34px 16px;
    position: relative;
    text-align: left;
  }

  .header-content {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
  }

  .header-copy {
    min-width: 0;
  }

  h1 {
    margin: 0 0 4px;
    font-size: 24px;
    line-height: 1.05;
  }

  header p {
    margin: 0;
    font-size: 13px;
    line-height: 1.25;
  }

  .tier-legend-desktop {
    display: none;
  }

  .tier-legend-mobile {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    justify-content: flex-end;
    gap: 8px;
    width: min-content;
    flex-shrink: 0;
  }

  .tier-legend-mobile .legend-tier {
    position: static;
    font-size: 13px;
    padding: 5px 9px;
  }

  .tier-legend-mobile .legend-tier::after {
    position: absolute;
    top: 46vh;
    right: 16px;
    left: 16px;
    width: auto;
    max-width: none;
    transform: translateY(-4px);
  }

  .tier-legend-mobile .legend-tier:hover::after,
  .tier-legend-mobile .legend-tier:focus-visible::after {
    transform: translateY(0);
  }
}

@media (max-width: 600px) {
  .controls {
    gap: 8px;
    align-items: flex-end;
    flex-wrap: nowrap;
  }

  .creator-bar {
    margin-bottom: 14px;
  }

  .creator-actions {
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
  }

  #customListToggle,
  .save-list-button,
  .reset-list-button {
    width: 100%;
    min-height: 40px;
    padding: 0 8px;
    font-size: 14px;
  }

  .edit-mode-message {
    font-size: 12px;
  }

  input,
  select {
    height: 40px;
    padding: 0 10px;
    font-size: 14px;
  }

  select {
    width: 120px;
  }

  input {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
  }

  .team-count-control {
    flex: 0 0 74px;
    font-size: 10px;
    min-width: 0;
    white-space: normal;
    line-height: 1.05;
  }

  .team-count-control select {
    width: 74px;
    padding: 0 8px;
  }

  #positionFilter {
    flex: 0 0 116px;
    width: 116px;
  }

  th,
  td {
    padding: 10px 4px;
    font-size: 12px;
  }

  th {
    padding-right: 2px;
    padding-left: 2px;
    font-size: 9px;
    line-height: 1.1;
    white-space: nowrap;
  }

  th:nth-child(1),
  td:nth-child(1) {
    width: 48px;
  }

  th:nth-child(2),
  td:nth-child(2) {
    width: 32px;
  }

  th:nth-child(3),
  td:nth-child(3) {
    width: auto;
    overflow-wrap: anywhere;
  }

  th:nth-child(4),
  td:nth-child(4) {
    width: 52px;
  }

  th:nth-child(5),
  td:nth-child(5) {
    width: 36px;
  }

  th:nth-child(6),
  td:nth-child(6) {
    width: 76px;
  }

  .tier {
    padding: 5px 5px;
    font-size: 11px;
    line-height: 1.1;
    text-align: center;
    white-space: normal;
  }

  .experience,
  .team {
    font-size: 12px;
  }

  .is-editing th:nth-child(2),
  .is-editing td:nth-child(2) {
    width: 48px;
  }

  .is-editing th:nth-child(6),
  .is-editing td:nth-child(6) {
    width: 72px;
  }

  .tier-select {
    height: 34px;
    padding: 0 2px;
    font-size: 10px;
  }

  .draggable-row {
    touch-action: none;
  }

  .drag-rank::before {
    margin-right: 2px;
  }
}
