* {
  box-sizing: border-box;
}

:root {
  --text-cols: 1;
  --card-height: 56px;
}

body {
  font-family: system-ui, sans-serif;
  background: #77a9e9;
  margin: 0;
  padding: 16px;
  text-align: center;
}

.blokBoven {
  display: flex;
  justify-content: space-around;
}

h1 {
  margin: 0 0 6px;
  font-size: clamp(1.4rem, 3vw, 2rem);
}

p {
  margin: 0 0 10px;
}

#dataset-selector {
  margin: 0 0 12px;
  padding: 6px 10px;
  font-size: 1rem;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, .15);
}

#scoreboard {
  display: flex;
  gap: 16px;
  justify-content: center;
  align-items: center;
  font-size: clamp(1rem, 2vw, 1.2rem);
  margin-bottom: 12px;
}

#game {
  display: grid;
  grid-template-columns: 0.7fr 2.3fr;
  gap: 4vw;
  max-width: 1600px;
  margin: 0 auto;
  height: calc(100vh - 220px);
}

.column {
  display: grid;
  gap: 10px;
  padding: 8px;
  background: rgba(255, 255, 255, .15);
  border-radius: 12px;
  overflow-y: auto;
  align-content: start;
  touch-action: none;
}

.text-column {
  grid-template-columns: repeat(var(--text-cols, 1), 1fr);
  grid-auto-rows: minmax(32px, min(var(--card-height), 56px));
  justify-items: stretch;
}

.text-card {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;

  background: white;
  border: 2px solid #ddd;
  border-radius: 10px;
  padding: 6px 8px;
  font-size: clamp(.8rem, .95vw, 1rem);
  white-space: nowrap;

  transition: background-color .2s, border-color .2s, transform .1s, opacity .2s;
}

.text-card.drag-over {
  background: #eaf2ff;
  border-color: #007bff;
  outline: 3px dashed #007bff;
  transform: scale(1.02);
}

.text-card.locked {
  opacity: .45;
  filter: grayscale(100%);
  pointer-events: none;
}

.image-column {
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  align-content: start;
  justify-items: stretch;
  min-height: 410px;
}

.image-card {
  /* width: 100%; */
  aspect-ratio: 1 / 1;
  max-width: 90px;
  max-height: 90px;
  /* object-fit: contain; */
  background: white;
  border: 2px solid #ddd;
  border-radius: 14px;
  padding: 5px;

  cursor: grab;
  transition: transform .15s ease, box-shadow .15s ease, opacity .2s;
}

.image-card:active,
.image-card.dragging {
  cursor: grabbing;
  transform: scale(1.06);
  opacity: 50%;
  box-shadow: 0 12px 28px rgba(0, 0, 0, .3);
}

.image-card.locked {
  opacity: 0.35;
  filter: grayscale(100%);
  cursor: default;
  transform: none !important;
  box-shadow: none !important;
  pointer-events: none;
}

#feedback {
  margin-top: 12px;
  min-height: 30px;
  font-weight: 700;
}

.success {
  color: #1b7e2a;
}

.error {
  color: #b30000;
}

.confetti {
  position: fixed;
  pointer-events: none;
  z-index: 3000;
}

@keyframes trailFloat {
  0% {
    transform: translate(0, 0) rotate(0deg);
    opacity: 1;
  }

  100% {
    transform: translate(0px, 25px) rotate(360deg);
    opacity: .6;
  }
}

@media (max-width: 768px) {

  /* Algemene layout */
  body {
    padding: 8px;
  }

  #game {
    display: flex;
    flex-direction: column;
    gap: 8px;
    height: calc(100vh - 160px);
    /* header + score */
  }

  /* =========================
     TEKSTGEBIED ≈ 1/4
     ========================= */
  .text-column {
    flex: 0 0 20vh;
    max-height: 20vh;
    overflow: hidden;

    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    justify-content: center;

    gap: 4px;
    padding: 4px;
  }

  .text-card {
    font-size: 0.8rem;
    padding: 3px 5px;
    min-height: 6vh;
    min-width: 11vw;

    line-height: 1.05;
    white-space: normal;
  }

  /* =========================
     IMAGEGEBIED ≈ 7/12
     ========================= */




  .image-column {
    flex: 0 0 68%;
    min-height: 68%;
    flex-wrap: wrap;
    overflow: hidden;

    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 3px;
    padding: 3px;

    /* 🔑 DIT IS DE FIX */
    grid-auto-rows: min-content;


  }


  .image-card {

    aspect-ratio: 1 / 1;
    padding: 2px;
    border-radius: 6px;
    min-height: 8vh;
    min-width: 8vh;
    max-width: 100%;
    /* max-height: 100%; */
    max-width: 8vh;
    margin: 0 auto;
  }

  /* Score & tekst iets compacter */
  #scoreboard {
    font-size: 0.9rem;
    gap: 10px;
  }

  h1 {
    font-size: 1.2rem;
  }

  p {
    font-size: 0.9rem;
  }

}