/* ===== RESET & BASE ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background-color: #121212;
  color: #fff;
  font-family: 'Inter', sans-serif;
  line-height: 1.5;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ===== HEADER / NAV ===== */
.header {
  background-color: #1e1e1e;
  height: 60px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 30px;
  border-bottom: 1px solid #2c2c2c;
  user-select: none;
  flex-shrink: 0;
  position: relative;
}

.header-title {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 35px;
  font-weight: 700;
  color: #ffffff;
  pointer-events: none;
  user-select: none;
}

.nav-left,
.nav-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.nav-link {
  color: white;
  font-weight: 600;
  font-size: 16px;
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 5px;
  transition: background-color 0.2s;
}

.nav-link:hover {
  background-color: #ff4d4d;
}

.dropdown {
  position: relative;
}

.dropbtn {
  background: none;
  border: none;
  color: white;
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 5px;
  transition: background-color 0.2s;
}

.dropbtn:hover {
  background-color: #ff4d4d;
}

.dropdown-content {
  display: none;
  position: absolute;
  top: 40px;
  right: 0;
  background-color: #1f1f1f;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  min-width: 140px;
  z-index: 1000;
}

.dropdown-content a {
  display: block;
  padding: 10px 14px;
  color: white;
  font-size: 15px;
  border-bottom: 1px solid #333;
  text-decoration: none;
}

.dropdown-content a:last-child {
  border-bottom: none;
}

.dropdown-content a:hover {
  background-color: #333;
}

.dropdown:hover .dropdown-content {
  display: block;
}

/* ===== MAIN LAYOUT ===== */
.main-container {
  flex-grow: 1;
  display: flex;
  gap: 25px;
  padding: 20px 30px;
  overflow: hidden;
}

/* Player List */
.player-list {
  background-color: #1e1e1e;
  width: 1280px;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 0 20px rgba(255, 77, 77, 0.2);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.player-list h1 {
  margin-bottom: 20px;
  font-weight: 700;
  font-size: 24px;
  color: #ffffff;
}

#players {
  list-style: none;
  flex-grow: 1;
  overflow-y: auto;
  max-height: 70vh;
  border: 1px solid #444;
  border-radius: 8px;
  background-color: #121212;
  padding: 10px;
}

/* Player items */
.player-item {
  background-color: #333;
  margin-bottom: 8px;
  padding: 10px 14px;
  border-radius: 8px;
  cursor: grab;
  user-select: none;
  font-weight: 600;
  font-size: 15px;
  transition: background-color 0.15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-item:hover {
  background-color: #ff4d4d;
  color: #fff;
}

/* Tier container */
.tier-container {
  display: flex;
  overflow-x: auto;
  flex-wrap: nowrap;
  scroll-behavior: smooth;
  gap: 20px;
  padding-bottom: 16px;
}

/* Each tier column */
.tier-column {
  border-radius: 12px;
  width: 420px;
  padding: 15px 10px;
  box-shadow: 0 0 15px rgba(255, 77, 77, 0.4);
  display: flex;
  flex-direction: column;
  max-height: 95vh;
  user-select: none;
  color: white;
  flex-shrink: 0;
}

.tier-column h2 {
  margin-bottom: 15px;
  text-align: center;
  font-weight: 700;
  font-size: 20px;
  border-bottom: 2px solid #ff4d4d;
  padding-bottom: 6px;
}

/* Dropzone */
.dropzone {
  flex-grow: 1;
  overflow-y: auto;
  list-style: none;
  padding: 5px 6px;
  border-radius: 8px;
  border: 1px dashed #555;
  min-height: 200px;
}

.tier-column .player-item {
  background-color: rgba(255, 77, 77, 0.2);
  margin-bottom: 8px;
  cursor: grab;
}

/* Scrollbars */
#players::-webkit-scrollbar,
.dropzone::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

#players::-webkit-scrollbar-thumb,
.dropzone::-webkit-scrollbar-thumb {
  background-color: #ff4d4d;
  border-radius: 10px;
}

/* Button Container */
#button-container {
  position: sticky;
  bottom: 10px;
  background-color: #121212;
  padding: 12px 0;
  display: flex;
  justify-content: center;
  gap: 16px;
  z-index: 1100;
}

/* Buttons */
.btn {
  padding: 12px 36px;
  font-size: 18px;
  font-weight: 700;
  border-radius: 25px;
  cursor: pointer;
  border: none;
  box-shadow: 0 4px 12px rgba(255, 77, 77, 0.6);
  transition: background-color 0.3s ease;
  color: white;
  user-select: none;
  min-width: 140px;
}

.save-btn {
  background: linear-gradient(135deg, #d10d0d, #f55c5c);
}

.save-btn:hover {
  background: linear-gradient(135deg, #0a20df, #6386f6);
}

.clear-btn {
  background: linear-gradient(135deg, #f55c5c, #d10d0d);
}

.clear-btn:hover {
  background: linear-gradient(135deg, #01a728, #68f571);
}

/* Toast */
#toast {
  visibility: hidden;
  min-width: 250px;
  background-color: #222;
  color: #ff4d4d;
  text-align: center;
  border-radius: 12px;
  padding: 18px 24px;
  position: fixed;
  z-index: 9999;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 18px;
  opacity: 0;
  transition: opacity 0.4s ease-in-out;
  box-shadow: 0 0 20px #ff4d4d;
  user-select: none;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0; /* replaces top: 0; left: 0; width: 100vw; height: 100vh */
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  padding: 0 12px;

  /* Fix mobile viewport issues */
  max-height: 100dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.modal-content {
  position: relative;
  background-color: #1e1e1e;
  padding: 30px 40px;
  border-radius: 16px;
  box-shadow: 0 0 20px rgba(255, 77, 77, 0.4);
  text-align: center;
  color: #fff;
  width: 100%;
  max-width: 500px;
  box-sizing: border-box;
}

.modal-content p {
  font-size: 18px;
  margin-bottom: 20px;
  line-height: 1.6;
}

.modal-actions {
  display: flex;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 18px;
  font-size: 28px;
  font-weight: bold;
  color: #ff4d4d;
  cursor: pointer;
  user-select: none;
}

/* Hidden Utility */
.hidden {
  display: none;
}

/* Tier Colors */
.tier-column[data-tier="1"]  { background-color: #003f5c; }
.tier-column[data-tier="2"]  { background-color: #ffa600; }
.tier-column[data-tier="3"]  { background-color: #a05195; }
.tier-column[data-tier="4"]  { background-color: #007f5f; }
.tier-column[data-tier="5"]  { background-color: #f95d6a; }
.tier-column[data-tier="6"]  { background-color: #665191; }
.tier-column[data-tier="7"]  { background-color: #f4d35e; }
.tier-column[data-tier="8"]  { background-color: #2f4b7c; }
.tier-column[data-tier="9"]  { background-color: #d45087; }
.tier-column[data-tier="10"] { background-color: #bc5090; }

/* ===== MOBILE ===== */
@media (max-width: 900px) {
  .main-container {
    flex-direction: column;
    padding: 10px 20px;
  }

  .player-list {
    width: 100%;
    max-height: 380px;
    padding: 14px;
  }

  .tier-container {
    width: 100%;
    max-height: calc(100vh - 420px);
    gap: 16px;
    padding: 10px;
  }

  .tier-column {
    width: 300px;
    max-height: 300px;
  }

  #button-container {
    position: fixed;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: transparent;
    border-radius: 0;
    padding: 0;
    z-index: 1100;
  }

  #button-container .btn {
    font-size: 14px;
    padding: 10px 24px;
  }

  .tier-column .player-item {
    font-size: 13px;
    padding: 6px 10px;
  }

  .tier-column h2 {
    font-size: 18px;
  }

  .header-title {
    font-size: 28px;
  }

  #scale-wrapper {
    transform: scale(0.75);
    transform-origin: top left;
    width: 133.33%;
    overflow-x: hidden;
  }
}

@media (max-width: 600px) {
  #button-container {
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
  }

  body {
    padding-bottom: env(safe-area-inset-bottom);
  }
}
