.species-grid-container {
  margin: 0 auto;
  padding: 20px 15px;
  container-type: inline-size;
  container-name: species-grid;
  border-radius: 0.5rem;
}

.species-grid-heading {
  text-align: center;
  margin-bottom: 30px;
  font-size: clamp(24px, 5cqi, 36px);
  font-weight: 600;
}

.species-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
  justify-items: center;
}

.species-item {
  text-align: center;
  cursor: pointer;
  width: clamp(92px, 100%, 92px);
}

.species-item a {
  text-decoration: none;
  color: inherit;
  display: block;
}

.species-icon-wrapper {
  background-color: #f5f5f5;
  border: 1px solid rgba(216, 216, 216, 0.41);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
  transition: all 0.3s ease;
  aspect-ratio: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.species-item:hover .species-icon-wrapper {
  background-color: rgba(242, 84, 88, 0.2);
  border-color: rgba(242, 84, 88, 1);
}

.species-icon {
  width: 100%;
  height: 100%;
  max-width: 68px;
  max-height: 68px;
  object-fit: contain;
}

.species-name {
  font-size: 14px;
  margin: 5px 0 0;
  font-weight: 500;
  line-height: 1.2;
}

/* Container query based styles */
@container species-grid (min-width: 375px) {
  .species-icon {
    max-width: 68px;
    max-height: 68px;
  }
}

@container species-grid (min-width: 576px) {
  .species-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    max-width: 50rem;
    margin-left: auto;
    margin-right: auto;
    margin-bottom: 2rem;
  }
  
  .species-icon {
    max-width: 72px;
    max-height: 72px;
  }
}

@container species-grid (min-width: 768px) {
  .species-name {
    font-size: 16px;
  }
}

@container species-grid (min-width: 992px) {
  .species-grid {
    grid-template-columns: repeat(8, 1fr);
  }
  
  .species-icon {
    max-width: 76px;
    max-height: 76px;
  }
}

/* Fallback for browsers that don't support container queries */
@supports not (container-type: inline-size) {
  @media (min-width: 576px) {
    .species-grid {
      grid-template-columns: repeat(4, 1fr);
      justify-items: center;
      max-width: 50rem;
      margin-left: auto;
      margin-right: auto;
      margin-bottom: 2rem;
    }
  }
  
  @media (min-width: 768px) {
    .species-grid {
      grid-template-columns: repeat(5, 1fr);
    }
  }
  
  @media (min-width: 992px) {
    .species-grid {
      grid-template-columns: repeat(6, 1fr);
    }
  }
  
  @media (min-width: 1200px) {
    .species-grid {
      grid-template-columns: repeat(8, 1fr);
    }
  }
}
