<style>
/* Flash Cards Grid */
.flash-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 20px;
}

/* Each module card with colorful background */
.flash-card {
  padding: 12px;
  border-radius: 8px;
  cursor: pointer;
  text-align: center;
  font-weight: bold;
  color: #fff;
  transition: transform 0.2s, box-shadow 0.3s;
}

/* Hover effect */
.flash-card:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
</style>

<script>
/* ===== Colors Array ===== */
const colors = ["#e74c3c","#3498db","#f39c12","#1abc9c","#9b59b6","#e67e22","#2ecc71","#e84393"];

/* ===== Flash Modal ===== */
function showFlashModal(title, modules){
  flashTitle.textContent = title;
  flashList.innerHTML = "";
  if(!modules || modules.length===0){
    flashList.innerHTML = `<p>${texts[lang].noOutline}</p>`;
  } else {
    modules.forEach((mod, index)=>{
      const card = document.createElement("div");
      card.className = "flash-card";
      card.textContent = mod;

      // Assign color cyclically
      card.style.backgroundColor = colors[index % colors.length];

      card.addEventListener("click",()=> showLessonModal(mod));
      flashList.appendChild(card);
    });
  }
  flashModal.style.display = "flex";
}
</script>