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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
    Ubuntu, Cantarell, sans-serif;
  background: #eef0f4;
  color: #1a1a2e;
  padding: 24px 16px;
  min-height: 100vh;
}

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

.title {
  text-align: center;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: #2c3e50;
  margin-bottom: 16px;
}

/* Toolbar */
.toolbar {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.toolbar-btn {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  background: #e8ecf0;
  color: #4a5568;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
}

.toolbar-btn:hover {
  background: #d0d6dd;
}

.toolbar-btn.btn-danger {
  color: #c0392b;
  background: #fce8e6;
}

.toolbar-btn.btn-danger:hover {
  background: #f5d0cc;
}

/* Tier List */
.tier-list {
  margin-bottom: 16px;
}

.tier-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.tier-label {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 24px;
  border-radius: 8px;
  width: 64px;
  min-height: 80px;
  flex-shrink: 0;
  user-select: none;
}

.tier-label[data-tier="S"] { background: #ffb703; color: #1a1a2e; }
.tier-label[data-tier="A"] { background: #27ae60; color: #fff; }
.tier-label[data-tier="B"] { background: #008080; color: #fff; }
.tier-label[data-tier="C"] { background: #1a237e; color: #fff; }
.tier-label[data-tier="D"] { background: #c2185b; color: #fff; }
.tier-label[data-tier="F"] { background: #6a1b9a; color: #fff; }

.tier-items {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-content: flex-start;
  padding: 14px;
  min-height: 80px;
  background: #f8f9fa;
  border: 2px dashed #e0e0e0;
  border-radius: 8px;
  transition: border-color 0.15s, background 0.15s;
}

.tier-items:empty::after {
  content: 'Drop items here';
  color: #bbb;
  font-size: 13px;
  font-style: italic;
}

/* Tier Delete Zone */
.tier-delete {
  width: 56px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed #e74c3c;
  border-radius: 8px;
  background: #fdf0ef;
  color: #e74c3c;
  font-size: 20px;
  user-select: none;
  transition: background 0.15s, border-color 0.15s;
}

/* Input Area */
.input-area {
  margin-bottom: 14px;
}

.input-row {
  display: flex;
  gap: 8px;
}

.input-area input[type="text"] {
  padding: 10px 14px;
  font-size: 15px;
  border: 2px solid #dce0e5;
  border-radius: 8px;
  outline: none;
  transition: border-color 0.15s;
}

.input-area input[type="text"]:focus {
  border-color: #2980b9;
}

#item-input {
  flex: 1;
}

.url-input {
  width: 100%;
  margin-top: 8px;
  font-size: 13px !important;
  color: #888;
  background: #fafbfc;
}

.url-input::placeholder {
  color: #bbb;
  font-style: italic;
}

.url-input:focus {
  color: #333;
  background: #fff;
}

.input-area button {
  padding: 10px 22px;
  font-size: 15px;
  font-weight: 600;
  background: #2980b9;
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.input-area button:hover {
  background: #2471a3;
}

.input-area button:active {
  background: #1f618d;
}

/* Search Results */
.search-results {
  display: none;
  gap: 10px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 10px 4px 8px;
  margin-bottom: 12px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.search-results.visible {
  display: flex;
}

.search-result {
  flex-shrink: 0;
  width: 200px;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  user-select: none;
}

.search-result:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.15);
}

.search-result:active {
  transform: translateY(-1px);
}

.search-result img {
  display: block;
  width: 200px;
  height: 140px;
  object-fit: cover;
  background: #e8e8e8;
}

.search-result-title {
  display: block;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #333;
  background: #fff;
}

/* Unranked Pool */
.unranked {
  background: #f8f9fa;
  border: 2px dashed #d0d4dc;
  border-radius: 10px;
  padding: 14px;
}

.unranked-label {
  font-weight: 600;
  font-size: 14px;
  color: #7f8c9b;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.pool-items {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 40px;
}

.pool-items:empty::after {
  content: 'Add items above';
  color: #bbb;
  font-size: 13px;
  font-style: italic;
}

/* Items */
.item {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border-radius: 12px;
  padding: 8px 22px 8px 8px;
  font-size: 16px;
  font-weight: 500;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.1);
  cursor: grab;
  user-select: none;
  white-space: nowrap;
  transition: box-shadow 0.15s, transform 0.15s;
}

.item:active {
  cursor: grabbing;
}

.item-img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 8px;
  background: #e8e8e8;
  flex-shrink: 0;
}

.item-name {
  line-height: 1.3;
}

.item-ghost {
  opacity: 0.35;
}

.sortable-drag {
  opacity: 0.9;
}

@media (max-width: 640px) {
  .container {
    padding: 0 4px;
  }

  .title {
    font-size: 22px;
    margin-bottom: 12px;
  }

  .tier-row {
    gap: 4px;
    margin-bottom: 4px;
  }

  .tier-label {
    width: 40px;
    min-height: 56px;
    font-size: 16px;
  }

  .tier-items {
    padding: 8px;
    gap: 4px;
    min-height: 56px;
  }

  .tier-delete {
    width: 36px;
    font-size: 14px;
    border-width: 1px;
  }

  .item {
    gap: 6px;
    border-radius: 8px;
    padding: 4px 10px 4px 4px;
    font-size: 13px;
  }

  .item-img {
    width: 32px;
    height: 32px;
    border-radius: 5px;
  }

  .search-result {
    width: 130px;
  }

  .search-result img {
    width: 130px;
    height: 90px;
  }

  .search-result-title {
    padding: 6px 8px;
    font-size: 11px;
  }

  .input-area input[type="text"] {
    font-size: 16px;
  }

  .url-input {
    font-size: 12px !important;
  }

  .toolbar-btn {
    font-size: 11px;
    padding: 5px 8px;
  }
}
