/* ============================================================
   STAR SAVIOR TIER LIST MAKER
   ============================================================ */

.ss-tlm-root {
  margin: 20px 0 40px;
}

/* ---- Toolbar ---- */
.ss-tlm-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.ss-tlm-mode-tabs {
  display: flex;
  gap: 4px;
  padding: 6px 8px;
  background: #1a1a1f;
  border: 1px solid #2a2a30;
  border-radius: 2px;
}

.ss-tlm-mode-tabs button {
  appearance: none;
  border: none;
  background: transparent;
  color: #a0a0a8;
  font-weight: 800;
  font-size: 1rem;
  padding: 12px 28px;
  border-radius: 2px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.ss-tlm-mode-tabs button:hover {
  color: #e8e8ec;
}

.ss-tlm-mode-tabs button.active {
  background: #2d2d36;
  color: #fff;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06);
}

.ss-tlm-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.ss-tlm-actions button {
  padding: 10px 18px;
  border-radius: 2px;
  border: 1px solid #32323e;
  background: #2c2d35;
  color: #e0e0e0;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.9rem;
}

.ss-tlm-actions button:hover {
  background: #363845;
}

.ss-tlm-actions button.ss-tlm-primary {
  background: #4a3f7a;
  border-color: #5a4a9a;
  color: #fff;
}

.ss-tlm-actions button.ss-tlm-primary:hover {
  background: #5a4f8a;
}

/* ---- Layout: Pool links (row-reverse), Tier-Liste rechts ---- */
.ss-tlm-layout {
  display: flex;
  flex-direction: row-reverse;
  gap: 24px;
  align-items: flex-start;
}

.ss-tlm-tier-area {
  flex: 1;
  min-width: 0;
}

.ss-tlm-roster {
  flex: 0 0 min(340px, 32vw);
  width: min(340px, 100%);
  max-width: 340px;
}

/* ---- Simple rows ---- */
.ss-tlm-simple-rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ss-tlm-simple-row {
  display: flex;
  background: #141417;
  border-radius: 2px;
  border: 1px solid #2a2a30;
  overflow: hidden;
  min-height: 100px;
  transition: background 0.12s ease;
}

.ss-tlm-simple-row.ss-tlm-cell-selected {
  outline: 2px solid var(--ty-accent-solid);
  outline-offset: -1px;
  background: rgba(122, 90, 248, 0.07);
}

.ss-tlm-simple-row.ss-tlm-drag-over {
  box-shadow: inset 0 0 0 2px rgba(122, 90, 248, 0.5);
}

@keyframes ss-row-flash {
  0%   { background: rgba(122, 90, 248, 0.35); }
  100% { background: transparent; }
}

.ss-tlm-simple-row.ss-tlm-row-flash {
  animation: ss-row-flash 0.45s ease-out forwards;
}

.ss-tlm-simple-cards {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px;
  align-content: flex-start;
  align-items: flex-start;
}

/* ---- Grid ---- */
.ss-tlm-grid-wrap .tier-row-bsr {
  position: relative;
}

.ss-tlm-cell {
  min-height: 72px;
  position: relative;
}

.ss-tlm-cell.ss-tlm-cell-selected {
  box-shadow: inset 0 0 0 2px var(--ty-accent-solid);
  border-radius: 2px;
}

.ss-tlm-cell.ss-tlm-drag-over {
  background: rgba(122, 90, 248, 0.12);
}

/* ---- Placed cards ---- */
.ss-tlm-card-wrap {
  position: relative;
  display: inline-block;
}

.ss-tlm-card-wrap .char-card-bsr {
  cursor: grab;
}

.ss-tlm-card-wrap .char-card-bsr:active {
  cursor: grabbing;
}

/* Remove-Button: sitzt auf dem Avatar, nur bei Hover/Fokus sichtbar (Desktop) */
.ss-tlm-char-avatar-stack {
  position: relative;
  display: inline-block;
  line-height: 0;
  vertical-align: top;
}

.ss-tlm-card-remove {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 20px;
  height: 20px;
  border-radius: 3px;
  border: none;
  background: rgba(180, 40, 40, 0.95);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
}

/* Erweiterte Tap-Area ohne visuellen Overflow */
.ss-tlm-card-remove::before {
  content: '';
  position: absolute;
  inset: -6px;
}

.ss-tlm-char-avatar-stack:hover .ss-tlm-card-remove,
.ss-tlm-char-avatar-stack:focus-within .ss-tlm-card-remove {
  opacity: 1;
  pointer-events: auto;
}

.ss-tlm-card-remove:hover {
  background: #c62828;
}

/* ---- Roster / Pool Panel ---- */
.ss-tlm-roster {
  background: #1a1a1f;
  border: 1px solid #2a2a30;
  border-radius: 2px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  /* Desktop: max-height mit scrollbarem Karten-Bereich */
  max-height: min(85vh, 900px);
}

.ss-tlm-roster-title {
  font-weight: 700;
  color: #e8e8ec;
  font-size: 1.05rem;
  flex-shrink: 0;
}

/* Aktive-Auswahl-Hint im Pool */
.ss-tlm-hint {
  font-size: 0.85rem;
  color: #a0a0a8;
  line-height: 1.4;
  padding: 8px 10px;
  background: rgba(122, 90, 248, 0.12);
  border-left: 3px solid var(--ty-accent-solid);
  border-radius: 2px;
  flex-shrink: 0;
}

.ss-tlm-hint strong {
  color: #c4b0ff;
}

/* Mobile-Tip (nur mobil sichtbar) */
.ss-tlm-mobile-tip {
  display: none;
  font-size: 0.82rem;
  color: #888;
  line-height: 1.45;
  flex-shrink: 0;
}

/* ---- Manual-Section (nur mobil sichtbar) ---- */
.ss-tlm-manual {
  display: none;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid #2a2a30;
  border-radius: 2px;
  flex-shrink: 0;
}

.ss-tlm-manual-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #666;
  font-weight: 600;
}

.ss-tlm-manual-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.ss-tlm-manual select {
  flex: 1;
  min-width: 80px;
  background: #212126;
  color: #e0e0e0;
  border: 1px solid #32323e;
  border-radius: 2px;
  padding: 8px 10px;
  font-size: 16px; /* verhindert iOS-Zoom */
  min-height: 42px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.ss-tlm-manual button.ss-tlm-place-btn {
  padding: 8px 16px;
  border-radius: 2px;
  border: 1px solid #5a4a9a;
  background: #4a3f7a;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  font-size: 0.9rem;
  min-height: 42px;
  white-space: nowrap;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}

.ss-tlm-manual button.ss-tlm-place-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.ss-tlm-manual button.ss-tlm-place-btn:not(:disabled):hover {
  background: #5a4f8a;
}

/* ---- Suche ---- */
.ss-tlm-roster-search {
  width: 100%;
  background: #212126;
  color: #e0e0e0;
  border: 1px solid #32323e;
  border-radius: 2px;
  padding: 8px 10px;
  font-size: 0.9rem;
  flex-shrink: 0;
}

/* ---- Filter-Buttons ---- */
.ss-tlm-roster-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
  flex-shrink: 0;
}

.ss-tlm-roster-filters button {
  padding: 5px 9px;
  border-radius: 2px;
  border: 1px solid #32323e;
  background: #25252c;
  color: #bbb;
  font-size: 0.73rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.ss-tlm-roster-filters button.active {
  background: #2d2d36;
  color: #fff;
  border-color: #4a4a55;
}

.ss-tlm-roster-filters button img {
  width: 18px;
  height: 18px;
  object-fit: contain;
}

.ss-tlm-class-filter-fallback {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: capitalize;
  line-height: 1;
  max-width: 56px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- Karten-Pool ---- */
.ss-tlm-roster-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  overflow-y: auto;
  padding: 4px 2px 8px;
  flex: 1;
  min-height: 80px;
  align-content: flex-start;
}

.ss-tlm-roster-cards .char-card-bsr {
  cursor: grab;
  width: 88px;
}

.ss-tlm-roster-cards .char-avatar-bsr {
  width: 72px !important;
  height: 72px !important;
}

.ss-tlm-roster-cards .char-name-bsr {
  font-size: 0.65rem;
  max-width: 88px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- Toast ---- */
.ss-tlm-copy-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(30, 30, 40, 0.97);
  color: #fff;
  padding: 12px 20px;
  border-radius: 2px;
  border: 1px solid #3a3a48;
  z-index: 10000;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  white-space: nowrap;
}

/* ---- Grid helpers ---- */
.ss-tlm-grid-wrap .empty-role {
  display: none;
}

/* Header-Zeile: eigene Klasse, kein tier-row-bsr */
.ss-tlm-grid-header-row {
  display: flex;
  margin-bottom: 12px;
}

/* Header-Label unsichtbar mit Body-Hintergrundfarbe (überschreibt Tier-Farben) */
.ss-tlm-grid-wrap .tier-label-bsr.tier-header-label-invisible {
  visibility: hidden;
  border: 0;
  background: var(--ty-body-bg);
}

.ss-tlm-grid-wrap .tier-cell-empty .role-characters-bsr {
  min-height: 48px;
}

/* ============================================================
   TOUCH-GERÄTE: Remove-Button immer sichtbar
   ============================================================ */
@media (hover: none), (pointer: coarse) {
  .ss-tlm-card-remove {
    opacity: 1;
    pointer-events: auto;
    width: 22px;
    height: 22px;
    font-size: 15px;
    top: 2px;
    right: 2px;
  }
}

/* ============================================================
   TABLET / MOBILE ≤1024px
   ============================================================ */
@media (max-width: 1024px) {
  /* Layout: nur Tier-Bereich, kein Pool mehr */
  .ss-tlm-layout {
    display: block;
  }

  .ss-tlm-tier-area {
    width: 100%;
    min-width: 0;
    overflow-x: hidden;
  }

  /* Roster (Desktop-Pool) auf Mobile komplett ausblenden */
  .ss-tlm-roster {
    display: none;
  }

  /* Simple-Rows: Tier-Label oben, Karten darunter */
  .ss-tlm-simple-rows {
    gap: 0;
  }

  .ss-tlm-simple-row {
    flex-direction: column;
    min-height: unset;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-top: none;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    cursor: default;
    user-select: none;
  }

  .ss-tlm-simple-rows > :first-child .ss-tlm-simple-row,
  .ss-tlm-simple-rows > :first-child {
    border-top: 1px solid #2a2a30;
  }

  .ss-tlm-simple-row .tier-label-bsr {
    width: 100%;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    letter-spacing: 0.08em;
    font-weight: 900;
    flex-shrink: 0;
    border-radius: 0;
  }

  .ss-tlm-simple-cards {
    padding: 8px 10px 10px;
    gap: 6px;
    min-height: 50px;
  }

  /* + Button nach jeder Tier-Zeile */
  .ss-tlm-add-to-tier-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px 16px;
    background: #1a1a1f;
    border: none;
    border-bottom: 1px solid #2a2a30;
    color: var(--ty-accent-solid);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.12s ease, color 0.12s ease;
    letter-spacing: 0.02em;
  }

  .ss-tlm-add-to-tier-btn:active {
    background: rgba(122, 90, 248, 0.12);
  }

  .ss-tlm-add-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid var(--ty-accent-solid);
    font-size: 1.1rem;
    line-height: 1;
    flex-shrink: 0;
    font-weight: 700;
  }

  /* Toolbar-Buttons: Touch-Targets */
  .ss-tlm-mode-tabs button {
    min-height: 44px;
    padding: 10px 18px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  .ss-tlm-actions button {
    min-height: 44px;
    padding: 10px 14px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  /* Toast: mehr Abstand unten */
  .ss-tlm-copy-toast {
    bottom: 32px;
    font-size: 0.9rem;
  }
}

/* ---- Modal: Character Pool Bottom Sheet ---- */
.ss-tlm-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 2000;
  display: flex;
  align-items: flex-end;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.ss-tlm-modal {
  width: 100%;
  max-height: 88vh;
  background: #18181d;
  border-radius: 16px 16px 0 0;
  border-top: 1px solid #2a2a30;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: ss-slide-up 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes ss-slide-up {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* Drag Handle */
.ss-tlm-modal::before {
  content: '';
  display: block;
  width: 36px;
  height: 4px;
  background: #3a3a46;
  border-radius: 2px;
  margin: 10px auto 0;
  flex-shrink: 0;
}

.ss-tlm-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px 12px;
  flex-shrink: 0;
  border-bottom: 1px solid #2a2a30;
  gap: 10px;
}

.ss-tlm-modal-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1rem;
  font-weight: 700;
  color: #e8e8ec;
}

.ss-tlm-modal-tier-badge {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  min-height: 36px;
  font-size: 0.9rem !important;
  font-weight: 900 !important;
  border-radius: 4px;
  flex-shrink: 0;
  padding: 0 10px !important;
}

.ss-tlm-modal-close {
  background: #2a2a32;
  border: 1px solid #36363f;
  color: #a0a0a8;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.ss-tlm-modal-close:active {
  background: #3a3a46;
  color: #fff;
}

.ss-tlm-modal-search-wrap {
  padding: 10px 14px 8px;
  flex-shrink: 0;
}

.ss-tlm-modal-search {
  width: 100%;
  background: #212126;
  color: #e0e0e0;
  border: 1px solid #32323e;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 16px; /* iOS-Zoom verhindern */
  outline: none;
}

.ss-tlm-modal-search:focus {
  border-color: #5a4a9a;
}

/* Karten-Grid im Modal */
.ss-tlm-modal-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 8px;
  padding: 8px 14px 12px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
  align-content: flex-start;
}

.ss-tlm-modal-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: 1px solid #2a2a30;
  border-radius: 6px;
  padding: 6px 4px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.1s ease, border-color 0.1s ease;
  min-height: 96px;
  justify-content: center;
}

.ss-tlm-modal-card:active {
  background: rgba(122, 90, 248, 0.2);
  border-color: var(--ty-accent-solid);
  transform: scale(0.96);
}

.ss-tlm-modal-card .char-avatar-bsr {
  width: 64px !important;
  height: 64px !important;
}

.ss-tlm-modal-card-name {
  font-size: 0.6rem;
  color: #c8c8d0;
  text-align: center;
  line-height: 1.2;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}

.ss-tlm-modal-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: #666;
  font-size: 0.9rem;
  padding: 24px 0;
}

.ss-tlm-modal-footer {
  padding: 10px 14px 14px;
  flex-shrink: 0;
  border-top: 1px solid #2a2a30;
}

.ss-tlm-modal-done {
  width: 100%;
  padding: 13px;
  background: #4a3f7a;
  border: 1px solid #5a4a9a;
  border-radius: 8px;
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.12s ease;
}

.ss-tlm-modal-done:active {
  background: #5a4f8a;
}

/* ============================================================
   KLEINE SMARTPHONES ≤599px
   ============================================================ */
@media (max-width: 599px) {
  /* Toolbar: zweizeilig */
  .ss-tlm-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    margin-bottom: 14px;
  }

  .ss-tlm-mode-tabs {
    width: 100%;
    padding: 4px;
    justify-content: center;
  }

  .ss-tlm-mode-tabs button {
    flex: 1;
    text-align: center;
    font-size: 0.875rem;
    padding: 10px 6px;
  }

  .ss-tlm-actions {
    width: 100%;
    gap: 8px;
  }

  .ss-tlm-actions button {
    flex: 1;
    text-align: center;
    font-size: 0.82rem;
    padding: 10px 8px;
  }

  /* Tier-Label kompakter */
  .ss-tlm-simple-row .tier-label-bsr {
    min-height: 38px;
    font-size: 0.95rem;
  }

  .ss-tlm-simple-cards {
    padding: 6px 8px 8px;
    min-height: 44px;
  }

  /* + Button kompakter */
  .ss-tlm-add-to-tier-btn {
    padding: 8px 14px;
    font-size: 0.8rem;
  }

  /* Modal-Karten: enger */
  .ss-tlm-modal-cards {
    grid-template-columns: repeat(auto-fill, minmax(68px, 1fr));
    gap: 6px;
    padding: 8px 10px 10px;
  }

  .ss-tlm-modal-card .char-avatar-bsr {
    width: 56px !important;
    height: 56px !important;
  }

  .ss-tlm-modal-card {
    min-height: 86px;
  }
}
