/* --- Styles de Base des Tableaux --- */
table {
  table-layout: auto;
  width: 100%;
  max-width: 100%;
  border-collapse: separate; 
  border-spacing: 0 10px; 
  background-color: transparent;
  color: #e0e0e0;
  
  /* NOUVEAU : On transforme le table en flex column pour gérer l'espace restant */
  display: flex;
  flex-direction: column;
  flex: 1; /* Prend tout l'espace disponible sous les filtres */
  min-height: 0; /* Crucial : empêche le tableau de forcer le conteneur à s'agrandir */
}

tbody,
tr {
  display: block;
}

tbody {
  flex: 1; /* Prend tout l'espace restant dans le table */
  overflow-y: auto; /* C'est lui seul qui doit scroller */
  width: 100%;
  padding-right: 5px; 
  /* Suppression du height: 100% qui causait le bug */
}

/* --- SCROLLBAR HARMONISÉE (Tableaux) --- */

/* Cible le tbody qui a le défilement */
tbody::-webkit-scrollbar {
  width: 6px; /* Fin pour l'élégance */
}

tbody::-webkit-scrollbar-track {
  background: rgba(104, 253, 214, 0.05); /* Piste très subtile */
  border-radius: 3px;
}

tbody::-webkit-scrollbar-thumb {
  background-color: rgba(104, 253, 214, 0.3); /* Cyan sombre par défaut */
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.2); /* Petit contour pour la netteté */
}

tbody::-webkit-scrollbar-thumb:hover {
  background-color: #68fdd6; /* Cyan vif au survol */
  box-shadow: 0 0 8px rgba(104, 253, 214, 0.6); /* Effet néon */
}

/* Compatibilité Firefox (si supporté) */
tbody {
  scrollbar-width: thin;
  scrollbar-color: rgba(104, 253, 214, 0.3) rgba(104, 253, 214, 0.05);
}

/* --- Styles des Cellules (td) --- */
td {
  text-align: center;
  flex: 1;
  box-sizing: border-box;
  padding: 15px; /* Un peu plus d'air */
  
  /* PREMIUM GLASSMORPHISM */
  background: rgba(18, 22, 26, 0.7); /* Plus sombre pour le contraste */
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  
  border-radius: 4px; /* Coins légèrement arrondis style "Tech" */
  
  /* Bordure subtile Cyan */
  border: 1px solid rgba(104, 253, 214, 0.1); 
  border-bottom: 1px solid rgba(104, 253, 214, 0.2);

  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  
  /* Typographie */
  font-family: 'h73light', sans-serif;
  letter-spacing: 1px;
  color: #fff;
}

/* --- Styles de Rareté des Cellules (td) --- */
/* On garde la logique de couleur mais on ajoute un effet "Glow" */

.basique-rarete {
  border-left: 4px solid #777;
  box-shadow: inset 15px 0 20px -10px rgba(119, 119, 119, 0.2);
}

.commun-rarete {
  border-left: 4px solid rgb(79, 115, 90);
  box-shadow: inset 15px 0 20px -10px rgba(79, 115, 90, 0.2);
}

.rare-rarete {
  border-left: 4px solid rgb(90, 129, 145);
  box-shadow: inset 15px 0 20px -10px rgba(90, 129, 145, 0.2);
}

.epique-rarete {
  border-left: 4px solid rgb(115, 78, 165);
  box-shadow: inset 15px 0 20px -10px rgba(115, 78, 165, 0.2);
}

.legendaire-rarete {
  border-left: 4px solid rgb(217, 164, 74);
  box-shadow: inset 15px 0 20px -10px rgba(217, 164, 74, 0.15);
  /* Animation subtile pour le légendaire */
  animation: pulseLegendary 4s infinite alternate;
}

@keyframes pulseLegendary {
  0% { border-left-color: rgb(217, 164, 74); }
  100% { border-left-color: #ffe082; }
}

.mythique-rarete {
  border-left: 4px solid #ff2a5f;
  box-shadow: inset 15px 0 20px -10px rgba(255, 42, 95, 0.2);
  /* Animation spécifique pour le mythique, un peu plus rapide et intense */
  animation: pulseMythic 3s infinite alternate;
}

@keyframes pulseMythic {
  0% { border-left-color: #ff2a5f; box-shadow: inset 15px 0 20px -10px rgba(255, 42, 95, 0.2); }
  100% { border-left-color: #ff7596; box-shadow: inset 15px 0 30px -5px rgba(255, 42, 95, 0.4); }
}

/* --- Styles des Types d'Anomalies --- */
.gadget-type {
  background: linear-gradient(90deg, rgba(34, 199, 221, 0.1), transparent);
  border: 1px solid rgba(34, 199, 221, 0.3);
}

.territoire-type {
  background: linear-gradient(90deg, rgba(240, 230, 140, 0.1), transparent);
  border: 1px solid rgba(240, 230, 140, 0.3);
}

.combat-type {
  background: linear-gradient(90deg, rgba(243, 18, 56, 0.1), transparent);
  border: 1px solid rgba(243, 18, 56, 0.3);
}

/* --- Styles des Lignes (tr) --- */
tr {
  transition: transform 0.2s ease;
  display: flex;
  width: 100%;
  margin-bottom: 8px; /* Espacement entre les tuiles */
}

tr:last-child {
  margin-bottom: 0;
}

/* --- Styles au Survol et Sélection --- */
td:hover,
td.selected,
.selected {
  /* Effet de sélection "Once Human" */
  transform: translateX(5px);
  background-color: rgba(104, 253, 214, 0.05); /* Tint Cyan très léger */
  border-color: #68fdd6;
  box-shadow: 
    inset 0 0 15px rgba(104, 253, 214, 0.1),
    0 0 10px rgba(104, 253, 214, 0.2);
  z-index: 10;
  cursor: pointer;
}

/* --- Images et Animations --- */
.table-image {
  transition: filter 0.3s ease, transform 0.3s ease;
  position: relative;
  z-index: 2;
  filter: drop-shadow(0 5px 5px rgba(0,0,0,0.5)); /* Ombre portée sur l'image */
}

td:hover .table-image {
  transform: scale(1.05);
  filter: drop-shadow(0 8px 8px rgba(0,0,0,0.7));
}

.animation-container-cell {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-top: 13px;
  margin-right: 3px;
  border-radius: 5px;
  opacity: 0.6; /* Un peu plus discret */
}

.animation-container-cell img.animation-image-cell {
  width: 236px;
  height: 176px;
  mix-blend-mode: screen; /* Meilleure intégration sur fond sombre */
}