:root {
  --bg-primary: #222222;
  --bg-secondary: #333333;
  --bg-tertiary: #444444;
  --border-action: #666666;
  --gradient-end: #111111;
  --text-primary: #ffffff;
  --text-secondary: #000000;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  touch-action: manipulation;
}

body {
  -moz-osx-font-smoothing: grayscale;
  -webkit-font-smoothing: antialiased;
  align-items: flex-start;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  display: flex;
  flex-direction: row;
  font-family: "Roboto Condensed", sans-serif;
  font-size: 0.875rem;
  font-weight: 400;
  height: calc(100vh - env(safe-area-inset-top));
  height: calc(100dvh - env(safe-area-inset-top));
  overflow: hidden;
  padding-top: env(safe-area-inset-top);
  text-rendering: optimizeLegibility;
  touch-action: manipulation;
  width: 100vw;
}

header {
  align-items: center;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
}

.header-left {
  align-items: center;
  display: flex;
  gap: 8px;
}

.sport-selector {
  -webkit-user-select: none;
  position: relative;
  user-select: none;
}

.sport-selector-button {
  -webkit-tap-highlight-color: transparent;
  align-items: center;
  cursor: pointer;
  display: flex;
  gap: 0;
}

.sport-selector-button svg {
  flex-shrink: 0;
}

.sport-selector .custom-dropdown.open .sport-selector-button svg {
  transform: rotate(180deg) translateY(1px);
}

.sport-selector .custom-dropdown-menu {
  border-bottom: 1px solid var(--border-action);
  border-top: 1px solid var(--border-action);
  bottom: auto;
  left: 0;
  margin-top: 0.25rem;
  right: auto;
  top: 100%;
  width: 160px;
}

.header-right {
  align-items: center;
  display: flex;
  gap: 0.5rem;
}

header h2,
header p {
  font-size: 1rem;
  font-weight: 400;
  line-height: 1;
}

header h2 {
  font-weight: 600;
}

footer {
  align-items: center;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
}

.footer-left {
  align-items: center;
  display: flex;
  gap: 0.5rem;
}

.footer-right {
  align-items: center;
  display: flex;
  gap: 0.5rem;
}

.left {
  container-type: inline-size;
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 1rem;
  height: calc(100vh - env(safe-area-inset-top));
  height: calc(100dvh - env(safe-area-inset-top));
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  padding: 1rem;
}

@container (max-width: 575px) {
  footer {
    flex-direction: column;
    gap: 0.5rem;
  }

  .footer-left,
  .footer-right {
    width: 100%;
  }

  .footer-right .action-btn {
    flex: 1;
  }

  .axis-selection {
    flex: 1;
  }

  .axis-selector {
    flex: 1;
  }

  .custom-dropdown-button {
    width: 100% !important;
  }

  .custom-dropdown-menu {
    width: 100% !important;
  }

  .sport-selector .custom-dropdown-menu {
    width: 160px !important;
  }
}

.right {
  background-color: var(--bg-secondary);
  border-left: 1px solid var(--border-action);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100%;
  overflow: hidden;
  padding: 1rem;
  padding-bottom: 0;
  width: 400px;
}

.hidden {
  display: none !important;
}

.right.closed {
  width: 0;
  padding: 0;
  border-left: none;
  overflow: hidden;
}

.right.closed .sidebar-header,
.right.closed .sidebar-content {
  display: none;
}

.attribution {
  color: var(--text-primary);
  font-size: 0.875rem;
}

.attribution a {
  color: var(--text-primary);
  text-decoration: underline;
}

.attribution a:hover {
  text-decoration: none;
}

.welcome {
  align-items: center;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  display: none;
  flex-direction: column;
  height: calc(100vh - env(safe-area-inset-top));
  height: calc(100dvh - env(safe-area-inset-top));
  justify-content: center;
  left: 0;
  position: fixed;
  top: env(safe-area-inset-top);
  width: 100vw;
  z-index: 99999;
}

.welcome.show {
  display: flex;
}

.welcome .modal {
  align-items: center;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-action);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 320px;
  padding: 1.5rem;
  text-align: center;
}

.welcome .modal h2 {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1;
  margin: 0;
}

.welcome .modal p {
  font-size: 0.875rem;
  font-weight: 400;
  line-height: 1.4;
  margin: 0;
}

.download {
  background-color: var(--bg-primary);
  display: flex;
  flex-direction: column;
  height: calc(100vh - env(safe-area-inset-top));
  height: calc(100dvh - env(safe-area-inset-top));
  left: 0;
  position: fixed;
  top: env(safe-area-inset-top);
  width: 100vw;
  z-index: 99999;
}

.download-content {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 1rem;
  min-height: 0;
  overflow: hidden;
  padding: 1rem;
}

.download-header {
  align-items: center;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
}

.download-text {
  font-size: 0.875rem;
  font-weight: 400;
  line-height: 1;
  margin: 0;
}

.download-content img {
  border: 1px solid var(--border-action);
  flex: 1;
  height: 0;
  object-fit: contain;
  width: 100%;
}

.action-btn {
  align-items: center;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-action);
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  font-family: "Roboto Condensed", sans-serif;
  font-size: 0.875rem;
  font-weight: 400;
  height: 26px;
  justify-content: center;
  outline: none;
  padding: 0 0.5rem;
  text-decoration: none;
  width: auto;
}

.action-btn:hover:not(:disabled) {
  background-color: var(--bg-tertiary);
  text-decoration: none;
}

.action-btn:disabled {
  cursor: default;
  font-style: italic;
  opacity: 0.5;
}

.icon-btn {
  align-items: center;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-action);
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  font-family: "Roboto Condensed", sans-serif;
  font-size: 0.875rem;
  font-weight: 400;
  height: 26px;
  justify-content: center;
  outline: none;
  padding: 0;
  text-decoration: none;
  width: 26px;
}

.icon-btn:hover {
  background-color: var(--bg-tertiary);
  text-decoration: none;
}

.icon-btn svg {
  display: block;
  height: 16px;
  width: 16px;
}

.axis-selection {
  display: flex;
  gap: 0.5rem;
}

.axis-selector {
  position: relative;
}

.custom-dropdown {
  position: relative;
}

.custom-dropdown-button {
  align-items: center;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-action);
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  font-family: "Roboto Condensed", sans-serif;
  font-size: 0.875rem;
  font-weight: 400;
  gap: 0.5rem;
  outline: none;
  padding: 0.25rem 0.5rem;
  width: 160px;
}

.custom-dropdown-button:hover {
  background-color: var(--bg-tertiary);
}

.custom-dropdown-text {
  flex: 1;
  font-size: 0.875rem;
  font-weight: 400 !important;
  line-height: 1;
  min-width: 0;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-dropdown-arrow {
  flex-shrink: 0;
  transition: transform 0.2s;
}

.custom-dropdown.open .custom-dropdown-arrow {
  transform: rotate(180deg);
}

.custom-dropdown-menu {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-action);
  border-bottom: none;
  bottom: 100%;
  display: none;
  max-height: 200px;
  overflow-y: auto;
  position: absolute;
  right: 0;
  scrollbar-width: none;
  width: 160px;
  z-index: 1000;
}

.custom-dropdown-menu::-webkit-scrollbar {
  display: none;
}

.custom-dropdown.open .custom-dropdown-menu {
  display: block;
}

.custom-dropdown-item {
  color: var(--text-primary);
  cursor: pointer;
  font-family: "Roboto Condensed", sans-serif;
  font-size: 0.875rem;
  font-weight: 400;
  overflow: hidden;
  padding: 0.5rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-dropdown-item:hover:not(.disabled):not(.selected) {
  background-color: var(--bg-tertiary);
}

.custom-dropdown-item.disabled {
  -webkit-user-select: none;
  cursor: default;
  opacity: 0.5;
  pointer-events: none;
  user-select: none;
}

.custom-dropdown-item.selected {
  background-color: var(--bg-tertiary);
}

.grid-container {
  align-items: center;
  display: flex;
  flex: 1;
  justify-content: center;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

.diamond-wrapper {
  position: relative;
  transform: rotate(45deg) translate(10px, 10px);
}

.diamond-grid {
  aspect-ratio: 1;
  display: grid;
  gap: var(--grid-gap, 8px);
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  margin: 0 auto;
  position: relative;
}

.spectrum-line {
  -webkit-user-select: none;
  background-color: rgba(255, 255, 255, 0.25);
  pointer-events: none;
  position: absolute;
  user-select: none;
  z-index: 1;
}

.spectrum-line-right {
  height: 1px;
  left: 0;
  top: -1rem;
}

.spectrum-line-left {
  height: 0;
  left: -1rem;
  top: 0;
  width: 1px;
}

.spectrum-line-right::before {
  background-color: rgba(255, 255, 255, 1);
  content: "";
  height: 1px;
  left: 0;
  opacity: 0;
  position: absolute;
  width: 100%;
}

.spectrum-line-right.highlight-left::before {
  left: 0;
  opacity: 1;
  width: calc(33.333% - var(--grid-gap-half, 4px));
}

.spectrum-line-right.highlight-middle::before {
  left: calc(33.333% + var(--grid-gap-half, 4px));
  opacity: 1;
  width: calc(33.333% - var(--grid-gap, 8px));
}

.spectrum-line-right.highlight-right::before {
  left: calc(66.666% + var(--grid-gap-half, 4px));
  opacity: 1;
  width: calc(33.333% - var(--grid-gap-half, 4px));
}

.spectrum-line-left::before {
  background-color: rgba(255, 255, 255, 1);
  content: "";
  height: 100%;
  left: 0;
  opacity: 0;
  position: absolute;
  width: 1px;
}

.spectrum-line-left.highlight-top::before {
  height: calc(33.333% - var(--grid-gap-half, 4px));
  opacity: 1;
  top: 0;
}

.spectrum-line-left.highlight-middle::before {
  height: calc(33.333% - var(--grid-gap, 8px));
  opacity: 1;
  top: calc(33.333% + var(--grid-gap-half, 4px));
}

.spectrum-line-left.highlight-bottom::before {
  height: calc(33.333% - var(--grid-gap-half, 4px));
  opacity: 1;
  top: calc(66.666% + var(--grid-gap-half, 4px));
}

.slot {
  align-items: center;
  background: linear-gradient(
    135deg,
    var(--team-color, var(--bg-secondary)) 0%,
    var(--gradient-end) 100%
  );
  border: 1px solid var(--bg-primary);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.slot[draggable="true"] {
  cursor: grab;
}

.slot[draggable="true"]:active {
  cursor: grabbing;
}

.slot.empty {
  background: var(--bg-secondary);
  border-color: var(--border-action);
}

.slot.empty::before {
  content: "?";
  font-size: calc(var(--slot-name-font-size, 1rem) * 1.25);
  opacity: 0.5;
  transform: rotate(-45deg);
}

.slot.drag-over {
  background-color: var(--bg-tertiary);
  border-color: var(--text-primary);
}

.slot:hover:not(.empty) {
  background: linear-gradient(
    135deg,
    var(--team-color, var(--bg-tertiary)) 0%,
    var(--gradient-end) 100%
  );
  border-color: var(--text-primary);
}

.slot.empty:hover {
  background: var(--bg-tertiary);
  border-color: var(--text-primary);
}

.slot-content {
  align-items: center;
  display: flex;
  flex-direction: column;
  height: 100%;
  justify-content: center;
  left: 0;
  max-height: 100%;
  max-width: 100%;
  position: absolute;
  text-align: center;
  top: 0;
  transform: rotate(-45deg);
  width: 100%;
}

.slot-name-container {
  align-items: center;
  display: flex;
  flex-shrink: 0;
  justify-content: center;
  overflow: hidden;
  position: absolute;
  top: 0;
  transform: translateY(25%);
  width: 100%;
}

.slot-name {
  -webkit-user-select: none;
  color: var(--text-secondary);
  font-size: var(--slot-name-font-size, 1rem);
  font-style: italic;
  font-weight: 800;
  letter-spacing: -1px;
  max-width: 100%;
  opacity: 0.25;
  text-align: center;
  text-overflow: ellipsis;
  text-shadow: -1px -1px 0 rgba(255, 255, 255, 0.1),
    1px -1px 0 rgba(255, 255, 255, 0.1), -1px 1px 0 rgba(255, 255, 255, 0.1),
    1px 1px 0 rgba(255, 255, 255, 0.1);
  user-select: none;
  white-space: nowrap;
}

.slot-avatar-container {
  align-items: center;
  bottom: 0;
  display: flex;
  flex-shrink: 0;
  justify-content: center;
  position: absolute;
  transform: translateY(25%);
  width: 100%;
}

.slot-avatar {
  -webkit-user-select: none;
  aspect-ratio: 1;
  flex-shrink: 0;
  height: var(--avatar-size, 100px);
  max-height: 100%;
  max-width: 100%;
  object-fit: cover;
  pointer-events: none;
  user-select: none;
  width: var(--avatar-size, 100px);
}

.axis-label {
  -webkit-user-select: none;
  color: var(--text-primary);
  pointer-events: none;
  position: absolute;
  user-select: none;
  z-index: 10;
}

.axis-horizontal {
  align-items: center;
  display: flex;
  justify-content: space-between;
  left: 0;
  top: 0;
  transform: translateY(calc(-100% - 1.5rem));
}

.axis-vertical {
  align-items: center;
  display: flex;
  flex-direction: column;
  height: 0;
  justify-content: space-between;
  left: 0;
  top: 0;
  transform: translateX(calc(-100% - 1.5rem));
}

.axis-name {
  font-size: var(--axis-name-font-size, 1rem);
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
}

.axis-vertical .axis-name {
  transform: rotate(180deg);
  writing-mode: vertical-rl;
}

.spectrum-label {
  font-size: var(--spectrum-label-font-size, 0.875rem);
  font-style: italic;
  opacity: 0.5;
}

.spectrum-label.highlighted {
  opacity: 1;
}

.spectrum-label-left {
  text-align: left;
}

.spectrum-label-right {
  text-align: right;
}

.spectrum-label-top {
  text-align: center;
  transform: rotate(180deg);
  writing-mode: vertical-rl;
}

.spectrum-label-bottom {
  text-align: center;
  transform: rotate(180deg);
  writing-mode: vertical-rl;
}

.autocomplete-container {
  position: fixed;
  z-index: 1000;
}

#autocomplete-input {
  -webkit-autofill: none;
  -webkit-autofill-preview: none;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-action);
  color: var(--text-primary);
  font-family: "Roboto Condensed", sans-serif;
  font-size: 0.875rem;
  outline: none;
  padding: 0.5rem;
  width: 100%;
}

#autocomplete-input:-webkit-autofill,
#autocomplete-input:-webkit-autofill:hover,
#autocomplete-input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 30px var(--bg-secondary) inset;
  -webkit-text-fill-color: var(--text-primary);
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-action);
  transition: background-color 5000s ease-in-out 0s;
}

.autocomplete-dropdown {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-action);
  border-top: none;
  max-height: 300px;
  overflow-y: auto;
  position: absolute;
  scrollbar-width: none;
  top: 100%;
  width: 100%;
  z-index: 1000;
}

.autocomplete-dropdown::-webkit-scrollbar {
  display: none;
}

.autocomplete-item {
  align-items: center;
  cursor: pointer;
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem;
}

.autocomplete-item:hover:not(.selected),
.autocomplete-item.selected {
  background-color: var(--bg-tertiary);
}

.autocomplete-item:hover:not(.selected) .autocomplete-avatar-container,
.autocomplete-item.selected .autocomplete-avatar-container {
  background: linear-gradient(
    to bottom,
    var(--team-color, var(--bg-tertiary)) 0%,
    var(--gradient-end) 100%
  );
  border: 1px solid var(--text-primary);
}

.autocomplete-item.placed:hover:not(.selected),
.autocomplete-item.placed.selected {
  opacity: 1;
}

.autocomplete-item.placed:hover:not(.selected) .autocomplete-avatar-container,
.autocomplete-item.placed.selected .autocomplete-avatar-container {
  background: linear-gradient(
    to bottom,
    var(--team-color, var(--bg-tertiary)) 0%,
    var(--gradient-end) 100%
  );
  border: 1px solid var(--text-primary);
}

.autocomplete-item.current-slot {
  border-bottom: 1px solid var(--border-action);
}

.autocomplete-item.current-slot:hover,
.autocomplete-item.current-slot.selected {
  background-color: var(--bg-tertiary);
}

.autocomplete-item.current-slot .autocomplete-avatar-container {
  background: linear-gradient(
    to bottom,
    var(--team-color, var(--bg-tertiary)) 0%,
    var(--gradient-end) 100%
  );
}

.autocomplete-item.current-slot:hover .autocomplete-avatar-container,
.autocomplete-item.current-slot.selected .autocomplete-avatar-container {
  background: linear-gradient(
    to bottom,
    var(--team-color, var(--bg-tertiary)) 0%,
    var(--gradient-end) 100%
  );
  border: 1px solid var(--text-primary);
}

.autocomplete-item.placed .autocomplete-avatar-container {
  background: linear-gradient(
    to bottom,
    var(--team-color, var(--bg-tertiary)) 0%,
    var(--gradient-end) 100%
  );
}

.autocomplete-item.placed:hover .autocomplete-avatar-container {
  background: linear-gradient(
    to bottom,
    var(--team-color, var(--bg-tertiary)) 0%,
    var(--gradient-end) 100%
  );
  border: 1px solid var(--text-primary);
}

.autocomplete-avatar-container {
  align-items: center;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--bg-secondary);
  display: flex;
  flex-shrink: 0;
  height: 32px;
  width: 32px;
}

.autocomplete-avatar {
  -webkit-user-select: none;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  user-select: none;
  width: 100%;
}

.autocomplete-info {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.25rem;
}

.autocomplete-name {
  align-items: center;
  display: flex;
  font-size: 0.875rem;
  font-weight: 600;
  gap: 8px;
}

.autocomplete-team {
  font-size: 0.75rem;
  opacity: 0.7;
}

.autocomplete-remove-btn {
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  font-family: "Roboto Condensed", sans-serif;
  font-size: 0.875rem;
  margin-left: auto;
  padding: 0;
  pointer-events: auto;
  text-decoration: none;
}

.autocomplete-remove-btn:hover,
.autocomplete-item.current-slot:hover .autocomplete-remove-btn,
.autocomplete-item.current-slot.selected .autocomplete-remove-btn {
  text-decoration: underline;
}

.autocomplete-flag {
  -webkit-user-select: none;
  height: 10px;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  width: auto;
}

.sidebar-header {
  align-items: center;
  display: flex;
  font-size: 1rem;
  font-weight: 600;
  height: 26px;
  justify-content: space-between;
  line-height: 1;
  margin-bottom: 1.5rem;
}

.sidebar-header h3 {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1;
  margin: 0;
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: none;
}

.sidebar-content::-webkit-scrollbar {
  display: none;
}

.team-section {
  margin-bottom: 1.5rem;
}

.team-header {
  align-items: center;
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.team-logo {
  height: 24px;
  object-fit: contain;
  width: 24px;
}

.team-name {
  font-size: 0.875rem;
  font-weight: 600;
}

.players-list {
  display: grid;
  gap: 0.5rem;
  grid-template-columns: repeat(4, 1fr);
}

.player-item {
  cursor: grab;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  text-align: center;
}

.player-avatar-container {
  align-items: center;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--bg-secondary);
  display: flex;
  position: relative;
  width: 100%;
}

.player-item:hover .player-avatar-container {
  background: linear-gradient(
    to bottom,
    var(--team-color, var(--bg-tertiary)) 0%,
    var(--gradient-end) 100%
  );
  border: 1px solid var(--text-primary);
}

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

.player-item.placed {
  cursor: grab;
  -webkit-user-select: none;
  user-select: none;
}

.player-item.placed:active {
  cursor: grabbing;
}

.player-item.placed .player-avatar-container {
  background: linear-gradient(
    to bottom,
    var(--team-color, var(--bg-tertiary)) 0%,
    var(--gradient-end) 100%
  );
}

.player-item.placed:hover .player-avatar-container {
  background: linear-gradient(
    to bottom,
    var(--team-color, var(--bg-tertiary)) 0%,
    var(--gradient-end) 100%
  );
  border: 1px solid var(--text-primary);
}

.player-item.filler {
  cursor: default;
  pointer-events: none;
}

.player-item.filler .filler-container {
  aspect-ratio: 1;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--bg-secondary);
  opacity: 0.25;
}

.player-avatar {
  -webkit-user-select: none;
  aspect-ratio: 1;
  object-fit: cover;
  pointer-events: none;
  user-select: none;
  width: 100%;
}

.player-name {
  font-size: 0.875rem;
  text-align: center;
}

.player-item.placed .player-name {
  -webkit-user-select: none;
  pointer-events: none;
  user-select: none;
}

.player-flag {
  -webkit-user-select: none;
  bottom: 6px;
  height: 12px;
  object-fit: contain;
  pointer-events: none;
  position: absolute;
  right: 6px;
  user-select: none;
  width: auto;
}

@media (max-width: 575px) {
  .right {
    background-color: var(--bg-primary);
    border-left: none;
    display: none;
    height: calc(100vh - env(safe-area-inset-top));
    height: calc(100dvh - env(safe-area-inset-top));
  }

  .right:not(.closed) {
    display: flex;
    width: 100%;
  }

  body:has(.right:not(.closed)) .left {
    display: none;
  }

  body:has(.right.closed) .left {
    display: flex;
  }
}
