@font-face {
  font-family: 'dogica_pixelregular';
  src: url('fonts/dogicapixel-0pwtcunc-webfont.woff2') format('woff2');
  font-weight: normal;
  font-style: normal;
  font-display: block;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'dogica_pixelregular';
}

body {
  min-height: 100vh;
  background: #bbeebb;
}

.loader {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.7);
  z-index: 9999;
  transition: opacity 0.3s ease;
  opacity: 1;
}

.container {
    max-width: 870px;
    margin: 0 auto;
    padding: 30px;
    border-radius: 15px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

h2 {
    color: #666;
    margin-bottom: 15px;
    font-size: 14px;
}

.search-section, .filter-section {
    margin-bottom: 30px;
    border-radius: 10px;
}

.search-section {
  display: flex;
  align-content: center;
  gap: 5px;
}

/* Selected IDs Section */
.selected-ids {
  display: none;
  margin-bottom: 30px;
  border-radius: 10px;
}

.selected-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px;
}

/* Close button for selected cards */
.close-btn {
  width: 14px;
  height: 14px;
  position: absolute;
  bottom: 3px;
  right: 3px;
  background: none;
  color: #ddd;
  border: 1.3px solid #eee;
  border-radius: 5px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all;
  z-index: 11;
  line-height: 1;
  padding: 2px 0 0 0.3px;
}

.close-btn:hover {
  background: #f0f0f0;
}

input[type="text"] {
  padding: 5px 8px;
  border: 1.5px solid #999;
  border-radius: 5px;
  font-size: 12px;
  width: 180px;
  height: 37px;
  color: #333;
  margin-right: 10px;
}

button {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

#clearBtn,
.sort-btn {
  width: 60px;
  height: 37px;
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 11px;
  cursor: pointer;
  transition: background 0.3s;
}

#searchBtn,
#clearSearchBtn,
#refreshDataBtn,
#refreshComplete {
  height: 37px;
  width: 37px;
  background: none;
  border-radius: 50%;
  cursor: pointer;
  position: relative;
  transition: background 0.3s;
}

#refreshDataBtn_svg {
  top: 1px;
  position: absolute;
}

#refreshDataBtn {
  margin-left: auto;
}

#refreshComplete {
  width: 32px;
  height: 32px;
}

#refreshDataBtn:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

#searchBtn_svg,
#clearSearchBtn_svg {
  position: absolute;
  top: 0;
  left: 0;
}

#clearBtn {
  background: #95a5a6;
}

#clearBtn {
  box-shadow: 1px 5px 0 0 rgba(25, 58, 43, 0.7);
}

#clearBtn:hover {
  box-shadow: 1px 3px 0 0 rgba(25, 58, 43, 0.7);
}

#searchBtn_svg:hover,
#clearSearchBtn_svg:hover,
#refreshDataBtn_svg:hover {
  fill: #55a9b0;
}

.sort-label {
  margin-bottom: 10px;
  font-size: 14px;
}

.sort-btn {
  background: #93bbbf;
  box-shadow: 1px 5px 0 0 #516668;
  font-size: 9px;
}

.sort-btn:hover {
  box-shadow: 1px 3px 0 0 #516668;
}

.sort-btn.active {
  background: #55a9b0;
  box-shadow: 1px 3px 0 0 #34656a;
  text-shadow: #eeeeee 0 -1px 4px, rgb(42, 135, 166) 0 1px 1px;
}

.sort-buttons {
  cursor: default;
}

.sort-btn {
  flex: 1;
  margin-bottom: 10px;
}

#clearBtn,
.sort-btn {
  transition: all 0.1s ease;
}

#clearBtn:hover,
.sort-btn:hover,
.sort-btn.active,
.sort-btn.active:hover {
  transform: translateY(2px);
}

#filterControls {
    margin-bottom: 15px;
}

/* Dropdown Wrapper */
.dropdown-wrapper {
  margin-bottom: 20px;
  padding: 15px;
  background: #f0f4ff;
  border-radius: 8px;
  border: 2px solid #999;
}

.dropdown-label {
  display: block;
  color: #667eea;
  font-weight: bold;
  font-size: 14px;
  margin-bottom: 10px;
}

.trait-dropdown {
  width: 100%;
  padding: 10px 12px;
  font-size: 12px;
  font-family: 'dogica_pixelregular';
  color: #333;
  background: white;
  border: 2px solid #999;
  border-radius: 5px;
  cursor: pointer;
  transition: border-color 0.3s;
}

.trait-dropdown:hover {
  border-color: #667eea;
}

.trait-dropdown:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.trait-dropdown option {
  font-size: 20px;
}

/* Filter Groups Container */
#filterGroupsContainer {
  margin-top: 15px;
}

/* Selected Traits Display */
.selected-traits-display {
  margin-top: 20px;
  margin-bottom: 15px;
  padding: 15px;
  background: #fff7e6;
  border-radius: 8px;
  border: 2px solid #ffa500;
}

.selected-traits-header {
  color: #ff8c00;
  font-weight: bold;
  font-size: 14px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid #ffd699;
}

.selected-traits-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.selected-trait-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 12px;
}

.trait-type {
  color: #ff8c00;
  font-weight: bold;
  min-width: 100px;
}

.trait-values {
  color: #555;
  flex: 1;
}

.filter-group {
  margin-bottom: 20px;
  padding: 10px 10px 30px 10px;
  background: #f0f4ff;
  border-radius: 8px;
  border: 2px solid #999;
}

.filter-header {
  color: #667eea;
  font-weight: bold;
  font-size: 14px;
  margin: 10px 10px;
  padding-bottom: 15px;
  border-bottom: 1px solid #ddd;
}

/* Trait search input styling */
.trait-search {
  width: 100%;
  padding: 8px 12px;
  margin: 0 9px;
  border: 2px solid #ddd;
  border-radius: 5px;
  transition: border-color 0.3s;
}

.checkbox-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  margin-top: 5px;
  max-height: 300px;
  overflow-y: auto;
  padding: 5px;
}

/* Scrollbar styling */
.checkbox-container::-webkit-scrollbar {
  width: 8px;
}

.checkbox-container::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 10px;
}

.checkbox-container::-webkit-scrollbar-thumb {
  background: #667eea;
  border-radius: 10px;
}

.checkbox-container::-webkit-scrollbar-thumb:hover {
  background: #5568d3;
}

.checkbox-label {
  display: flex;
  align-items: center;
  padding: 2px 4px;
  cursor: pointer;
  border-radius: 5px;
  transition: background 0.2s;
  user-select: none;
}

.checkbox-label:hover {
  background: #e8eeff;
}

.checkbox-label input[type="checkbox"] {
  margin-right: 8px;
  cursor: pointer;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  accent-color: #667eea;
}

.trait-label-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.trait-name {
  color: #333;
  font-size: 11px;
  font-weight: bold;
  word-wrap: break-word;
}

.trait-count {
  color: #667eea;
  font-size: 9px;
}

/* No trait results message */
.no-trait-results {
  grid-column: 1 / -1;
  text-align: center;
  padding: 20px;
  color: #999;
  font-style: italic;
}

/* Count header styling */
.count-header {
  grid-column: 1 / -1;
  text-align: center;
  padding: 15px;
  font-weight: bold;
  color: #667eea;
  background: #f0f4ff;
  border-radius: 8px;
  border: 2px solid #999;
  margin-bottom: 10px;
}

.note {
  font-size: 10px;
  color: #333;
  margin-top: 10px;
}

/* Loading indicator */
.loading-indicator {
  grid-column: 1 / -1;
  text-align: center;
  padding: 20px;
  color: #667eea;
  font-size: 12px;
  font-style: italic;
}

#results,
.selected-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 20px;
}

.nft-card {
  position: relative;
  background: white;
  border: 2px solid #333;
  border-radius: 10px;
  padding: 1px 8px 5px 8px;
  transition: transform 0.3s, box-shadow 0.3s;
  box-shadow: 0px 2px 2px rgba(0,0,0,0.2);
}

/* Rank and Stat Color Container */
.rank-stat-container {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  margin-bottom: 1px;
  position: relative;
}

.rank-stat-container:has(.stat-color-box) {
  justify-content: center;
}

.rank-stat-container:has(.stat-color-box) .rank-badge {
  position: absolute;
  left: 0;
}

.rank-badge {
  font-size: 9px;
  color: #937d1aff;
  border-radius: 2px;
  width: 52px;
  height: 12px;
  padding: 1px 0 0 5px;
  background: rgba(255, 240, 31, 0.3);
  border: 1px solid rgba(147, 125, 26, 0.3);
}

/* Stat Color Box - Square indicator */
.stat-color-box {
  width: 24px;
  height: 12px;
  border-radius: 2px;
  border: 1px solid rgba(147, 125, 26, 0.3);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: normal;
  color: #fff;
  padding: 1px 0 0 0;
}

.nft-card img {
  width: 130px;
  height: 130px;
  object-fit: cover;
  border-radius: 5px;
  border: 2px solid #333;
  margin-bottom: 5px;
  color: transparent;
  font-size: 0;
}

.nft-id {
  font-size: 10px;
  color: #667eea;
  margin-bottom: 7px;
  font-weight: bold;
}

.trait {
  margin: 3px 0;
  color: #333;
  font-size: 8px;
}

.no-results {
  text-align: center;
  padding: 40px;
  color: #999;
  font-size: 14px;
  grid-column: 1 / -1;
}

.count-header-trait-btn {
    background-color: #f0f0f0;
    color: #333;
    border: 1px solid #ccc;
    padding: 3px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: background-color 0.2s;
}

.count-header-trait-btn:hover {
    background-color: #e0e0e0;
}

.count-header-trait-btn span {
    font-weight: bold;
    color: #888;
}

.scroll-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
}

.scroll-to-top,
.scroll-to-top svg {
  width: 40px;
  height: 40px;
}

.scroll-to-top:hover {
    transform: translateY(-3px);
}

.scroll-to-top:active {
    transform: translateY(-1px);
}

.scroll-to-top.show {
    opacity: 1;
    visibility: visible;
}

/* NEW Badge Styling */
.new-badge {
    position: absolute;
    top: 1px;
    right: 3px;
    background: linear-gradient(135deg, #e8a6ee 0%, #bc63d2 100%);
    color: white;
    padding: 2px 2px 2px 3px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 7px;
    letter-spacing: 0.5px;
    z-index: 10;
    animation: newBadgePulse 2s ease-in-out infinite;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

@keyframes newBadgeSparkle {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.8;
  }
}

.new-badge {
    animation: newBadgeSparkle 1.5s ease-in-out infinite;
}

.nft-card {
    position: relative;
}

.trait-name-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}

.trait-info-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.trait-affinity {
    display: inline-block;
    padding: 2px 6px;
    color: white;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.trait-affinity.NORMAL {
  background: rgb(192, 194, 205);
}

.trait-affinity.SCRAP {
  background: #d38d50;
}

.trait-affinity.EERIE {
  background: #b575d0;
}

.trait-affinity.INSECT {
  background: #a1c181;
}

.trait-stats {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.trait-stat {
    display: inline-block;
    padding: 2px 5px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.3px;
    color: #fff;
}

.trait-stat.harmony,
.stat-item.harmony,
.stat-color-box.harmony {
  background: #9cbcd2;
}

.trait-stat.health,
.stat-item.health,
.stat-color-box.health {
  background: #d7bce8;
}

.trait-stat.power,
.stat-item.power,
.stat-color-box.power {
  background: #f9db6d;
}

.trait-stat.violence,
.stat-item.violence,
.stat-color-box.violence {
  background: #df829b;
}

.checkbox-label .trait-label-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.checkbox-label {
    padding: 8px 10px !important;
    min-height: 50px;
    align-items: flex-start !important;
}

.hover_wrapper {
  position: relative;
  display: inline-block;
  cursor: help;
  user-select: none;
  -webkit-user-select: none;
}

.kami-stats {
  border-radius: 8px;
  width: 100%;
  background: #fff;
  border: 2px solid #999;
  position: absolute;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
  
  padding: 8px 0px;
  border-radius: 4px;
  z-index: 10;

  bottom: 0%;
  left: 50%;
  transform: translate(-50%, -10px);
}

.hover_wrapper:hover .kami-stats,
.hover_wrapper.is-active .kami-stats {
  opacity: 0.9;
  visibility: visible;
  transform: translate(-50%, -5px);
}

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

.stat-row.one {
    margin-bottom: 10px;
}

.stat-item {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 3px 0px;
    border-radius: 15px;
    font-size: 11px;
    margin: 0px 10px;
    height: 25px;
    border: 2px solid #999;
}
    
.stat-value {
    color: #333;
    text-align: center;
}

@media (max-width: 820px){
  .checkbox-label input[type="checkbox"] {
    width: 24px;
    height: 24px;
  }

  .trait-name {
    font-size: 18px;
  }

  .trait-count {
    font-size: 16px;
  }

  .container {
    max-width: 720px;
  }

  .nft-id {
    font-size: 9px;
  }

  .nft-card img {
    width: 120px;
    height: 120px;
  }

  #results,
  .selected-cards-grid {
    gap: 20px;
  }
}

@media (max-width: 720px) {
  #results,
  .selected-cards-grid {
    gap: 10px;
  }
}

@media (max-width: 640px) {
  .container {
    max-width: 400px;
    padding: 10px 5px;
  }

  #results,
  .selected-cards-grid {
    gap: 20px;
  }

  .nft-card {
    padding: 3px 10px 8px 10px;
  }

  .nft-card img {
    width: 160px;
    height: 160px;
  }

  .rank-stat-container {
    margin-bottom: 3px;
  }

  .trait {
    font-size: 9px;
  }

  .nft-card-content img,
  .nft-id {
    margin-bottom: 3px;
  }

  .new-badge {
    top: 2px;
  }
}

@media (max-width: 390px) {
  
  .loader {
    transform: translate(-50%, -50%) scale(0.35);
  }

  .nft-card-content {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 20px;
    width: 100%;
  }
  
  .rank-badge {
    font-size: 12px;
    margin-bottom: 3px;
    border-radius: 2px;
    width: 66px;
    height: 16px;
  }

  .stat-color-box {
    width: 32px;
    height: 16px;
  }

  .nft-card-content img {
    width: 160px;
    height: 160px;
    margin-bottom: 0;
  }
   
  .nft-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding-top: 1px;
  }

  .trait {
    font-size: 11px;
    margin: 2px 0;
    font-weight: bold;
  }
  
  .nft-id {
    font-size: 13px;
    margin-bottom: 5px;
  }
  .scroll-to-top {
    width: 45px;
    height: 45px;
    bottom: 10px;
    right: 10px;
  }

  .container {
    padding: 10px;
    max-width: 360px;
  }

  #results,
  .selected-cards-grid {
    gap: 15px;
  }

  .nft-card {
    padding: 3px 10px 10px 10px;
  }

  #results,
  .selected-cards-grid {
   grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  }

  .new-badge {
    font-size: 10px;
    top: 3px;
    right: 3px;
  }

  #searchInput {
    width: 130px;
  }
}

@media (max-width: 326px) {
  .trait {
    font-size: 9px;
  }
  
  .nft-id {
    font-size: 12px;
    margin-bottom: 3px;
  }

  .nft-card-content img {
    width: 130px;
    height: 130px;
  }

  .rank-badge {
    font-size: 10px;
    width: 58px;
    margin-bottom: 1px;
    height: 14px;
  }

  .stat-color-box {
    width: 28px;
    height: 14px;
  }

  .container {
    max-width: 300px;
  }

  .nft-card-content {
    gap: 8px;
  }

  .new-badge {
    font-size: 8px;
    top: 2px;
  }

  .nft-card {
    padding: 2px 9px 9px 9px;
  }
}

@media (max-width: 280px) {
  .container {
    max-width: 250px;
  }

  .trait {
    font-size: 7px;
    margin: 1px 0;
  }
  
  .nft-id {
    font-size: 9px;
  }

  .nft-card img {
    width: 110px;
    height: 110px;
  }

  #searchInput {
    width: 70px;
  }

  .nft-id {
    margin-bottom: 3px;
  }

  .rank-badge {
    font-size: 8px;
    width: 48px;
    height: 11px;
  }

  .stat-color-box {
    width: 25px;
    height: 11px;
  }

  .nft-card {
    padding: 2px 7px 7px 7px;
  }

  .scroll-to-top {
    right: 5px;
  }

  .new-badge {
    font-size: 6px;
    top: 2px;
    right: 3px;
  }
}