#stickyControls {
  position: sticky;
  top: 50px;
  z-index: 20;
  padding: 10px 0;
}

.search-container {
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-wrapper {
  position: relative;
  flex: 1;
}

#tableSearch {
  width: 100%;
  padding: 14px 44px 14px 42px;
  border: none;
  border-radius: 999px;
  outline: none;
  font-size: 16px;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow:
    0 2px 10px rgba(0,0,0,0.08),
    0 10px 24px rgba(0,0,0,0.06);
  transition:
    box-shadow 0.2s ease,
    background 0.2s ease;
  -webkit-appearance: none;
}

#tableSearch:focus {
  box-shadow:
    0 4px 12px rgba(0,0,0,0.10),
    0 12px 28px rgba(0,0,0,0.10);
}

#tableSearch::-webkit-search-cancel-button,
#mobileTableSearch::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

#tableSearch::placeholder,
#mobileTableSearch::placeholder {
  color: rgba(0,0,0,0.5);
}

.search-icon {
  position: absolute;
  left: 24px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #000;
  pointer-events: none;
  z-index: 2;
}

#clearSearchBtn,
#mobileClearSearchBtn {
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: rgba(0,0,0,0.08);
  color: #555;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

#clearSearchBtn {
  position: absolute;
  right: 22px;
  top: 50%;
  transform: translateY(-50%);
}

#clearSearchBtn:hover,
#mobileClearSearchBtn:hover {
  background: rgba(0,0,0,0.14);
}

.filter-wrapper {
  position: relative;
}

.search-action-btn,
#mobileFilterToggle {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: #fff;
  color: #000;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 2px 6px rgba(0,0,0,0.06),
    0 8px 20px rgba(0,0,0,0.06);
  transition:
    transform 0.15s ease,
    background 0.15s ease,
    color 0.15s ease;
}

.search-action-btn:hover,
#mobileFilterToggle:hover {
  transform: scale(1.05);
}

.search-action-btn.active,
#mobileFilterToggle.active {
  background: #A8B842;
  color: #fff;
}

.filter-panel {
  position: absolute;
  display: none;
  flex-direction: column;
  gap: 6px;
  min-width: 180px;
  max-height: 70vh;
  padding: 8px;
  border-radius: 10px;
  background: #fff;
  overflow-y: auto;
  box-shadow:
    0 4px 12px rgba(0,0,0,0.08),
    0 12px 28px rgba(0,0,0,0.08);
  z-index: 30;
}

.filter-panel.open {
  display: flex;
}

#filterPanel {
  top: 110%;
  right: 0;
}

#mobileFilterPanel {
  right: 0;
  bottom: 54px;
}

.filter-panel button {
  padding: 8px 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-panel button > span {
  width: 14px;
  color: transparent;
  font-weight: 800;
}

.filter-panel button:hover {
  background: #f5f5f5;
}

.filter-panel button.active {
  background: #A8B842;
  color: #fff;
}

.filter-panel button.active > span {
  color: currentColor;
}

.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-top: 18px;
}

.master-set-table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
  table-layout: auto;
}

.master-set-table th,
.master-set-table td {
  border: 1px solid #ddd;
  padding: 10px 8px;
  line-height: 1.4;
  white-space: normal;
  overflow-wrap: break-word;
}

.master-set-table thead th {
  background: #fafafa;
  font-weight: 600;
  font-size: 13px;
}

.master-set-table tbody tr:nth-child(even) {
  background: #fafafa;
}

.master-set-table tbody tr:hover {
  background: #f2f2f2;
}

.master-set-table th:nth-child(1),
.master-set-table td:nth-child(1) {
  width: 80px;
}

.master-set-table th:nth-child(2),
.master-set-table td:nth-child(2) {
  width: 170px;
  font-weight: 600;
}

.master-set-table th:nth-child(3),
.master-set-table td:nth-child(3) {
  width: 220px;
}

.master-set-table th:nth-child(4),
.master-set-table td:nth-child(4) {
  width: 180px;
}

.master-set-table th:nth-child(5),
.master-set-table td:nth-child(5) {
  width: 100px;
}

.master-set-table th:nth-child(6),
.master-set-table td:nth-child(6) {
  width: 120px;
}

.master-set-table a {
 color: #A8B842;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.master-set-table a:hover {
  opacity: 0.8;
}

.empty-message {
  text-align: center;
  padding: 40px 20px;
  font-size: 15px;
  color: #666;
  background: #fafafa;
}

/* Card image preview */
#cardImagePreview {
  position: fixed;
  z-index: 10000;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition:
    opacity 0.15s ease,
    transform 0.15s ease;
  border-radius: 12px;
  background: #fff;
  box-shadow:
    0 6px 18px rgba(0,0,0,0.18),
    0 16px 40px rgba(0,0,0,0.22);
}

#cardImagePreview.visible {
  opacity: 1;
  transform: translateY(0);
}

#cardImagePreview.touch-preview {
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0.98);
}

#cardImagePreview.touch-preview.visible {
  transform: translate(-50%, -50%) scale(1);
}

#cardImagePreview img {
  display: block;
  width: 240px;
  max-width: min(78vw, 280px);
  height: auto;
  max-height: 76vh;
  border-radius: 12px;
}

#mobileSearchFab,
#mobileFilterFab {
  display: none;
}

@media (max-width: 640px) {
  html,
  body {
    overflow-anchor: none;
  }

  .search-container {
    display: none;
  }

  #stickyControls {
    position: static;
    padding: 0;
  }

  #mobileSearchFab,
  #mobileFilterFab {
    display: flex;
    position: fixed;
    right: 16px;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);
    transition:
      opacity 0.2s ease,
      transform 0.2s ease;
  }

  #mobileSearchFab {
    bottom: 80px;
  }

  #mobileFilterFab {
    bottom: 146px;
  }

  #mobileSearchFab.visible,
  #mobileFilterFab.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
  }

  #mobileSearchToggle {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    border-radius: 999px;
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow:
      0 4px 14px rgba(0,0,0,0.12),
      0 10px 28px rgba(0,0,0,0.10);
    overflow: hidden;
    transition:
      width 0.25s ease,
      box-shadow 0.2s ease;
  }

  #mobileSearchFab.active #mobileSearchToggle {
    width: calc(100vw - 32px);
  }

  .mobile-search-icon {
    min-width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000;
    border: none;
    background: transparent;
    padding: 0;
    cursor: pointer;
  }

  #mobileTableSearch {
    display: none;
    width: 100%;
    border: none;
    outline: none;
    background: transparent;
    font-size: 16px;
    padding-right: 12px;
    -webkit-appearance: none;
  }

  #mobileSearchFab.active #mobileTableSearch {
    display: block;
  }

  #mobileClearSearchBtn {
    min-width: 24px;
    margin-right: 12px;
  }

  #mobileSearchFab.active #mobileClearSearchBtn.has-value {
    display: flex;
  }

  .master-set-table th,
  .master-set-table td {
    font-size: 14px;
    padding: 10px 6px;
  }

  .master-set-table th:nth-child(1),
  .master-set-table td:nth-child(1) {
    width: 70px;
  }

  .master-set-table th:nth-child(2),
  .master-set-table td:nth-child(2) {
    min-width: 140px;
  }

  .master-set-table th:nth-child(3),
  .master-set-table td:nth-child(3) {
    width: 110px;
  }

  .master-set-table th:nth-child(4),
  .master-set-table td:nth-child(4) {
    min-width: 150px;
  }

  .master-set-table th:nth-child(5),
  .master-set-table td:nth-child(5),
  .master-set-table th:nth-child(6),
  .master-set-table td:nth-child(6) {
    min-width: 105px;
  }
}

#cardImagePreview.touch-preview.visible {
  pointer-events: auto;
}

@media (prefers-reduced-motion: reduce) {
  #mobileSearchFab,
  #mobileFilterFab,
  #mobileSearchToggle,
  .search-action-btn,
  #mobileFilterToggle,
  #cardImagePreview {
    transition: none;
  }
}

/* Dark forest table theme */
.table-wrapper,
.master-set-table,
.empty-message {
  background: transparent;
  color: #fff;
}

.master-set-table th,
.master-set-table td,
.master-set-table tbody tr {
  background: transparent;
  color: #fff;
}

.master-set-table thead th {
  background: #07110c;
  color: #fff;
}

.master-set-table th,
.master-set-table td {
  border-color: #2b4035;
}

.master-set-table a,
.master-set-table a:visited {
  color: #caef7d;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Transparent control area with white search and filter controls */
#stickyControls,
.search-container,
.search-wrapper,
.filter-wrapper {
  background: transparent;
}

#tableSearch,
.search-action-btn,
#mobileFilterToggle,
#mobileSearchToggle,
.filter-panel,
.search-action-btn.active,
#mobileFilterToggle.active {
  background: #fff;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

#tableSearch:focus {
  background: #fff;
}

#tableSearch,
#mobileTableSearch,
.filter-panel button {
  color: #000;
}

.filter-panel button:hover,
.filter-panel button.active,
.search-action-btn.active,
#mobileFilterToggle.active {
  background: #e4e0d5;
  color: #000;
}

.filter-panel button.active > span {
  color: #000;
}

/* Compact and align utility columns */
.master-set-table th:nth-child(1),
.master-set-table td:nth-child(1) {
  width: 56px;
  min-width: 56px;
  text-align: center;
}

.master-set-table th:nth-child(4),
.master-set-table td:nth-child(4),
.master-set-table th:nth-child(5),
.master-set-table td:nth-child(5),
.master-set-table th:nth-child(6),
.master-set-table td:nth-child(6) {
  text-align: center;
}

/* Quiet alternating rows */
.master-set-table tbody#tableBody tr:nth-child(odd),
.master-set-table tbody#tableBody tr:nth-child(odd) td {
  background: transparent;
  color: #fff;
}

.master-set-table tbody#tableBody tr:nth-child(even),
.master-set-table tbody#tableBody tr:nth-child(even) td {
  background: rgba(24, 43, 33, 0.72);
  color: #fff;
}

.master-set-table tbody#tableBody tr:nth-child(odd):hover td,
.master-set-table tbody#tableBody tr:nth-child(even):hover td {
  background: rgba(34, 58, 45, 0.84);
}
