/* Bu renkler SADECE parmak/mouse kaldirildiginda (sonuc belli olduktan
   sonra) kisa bir sure gosterilir; secim yaparken (surukleme sirasinda)
   kelime kontrolu yapilmaz, notr/mavi gorunum kullanilir. */
#current-word.state-valid { background: var(--good); color:#fff; }
#current-word.state-dup { background: var(--dup); color:#2a1a00; }
#current-word.state-invalid { background: var(--bad); color:#fff; }

#found-words {
  width: 100%;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  /* soft fade at the top edge hints that the list scrolls (newest words come last, at the bottom) */
  -webkit-mask-image: linear-gradient(to top, #000 calc(100% - 18px), transparent);
  mask-image: linear-gradient(to top, #000 calc(100% - 18px), transparent);
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  justify-content: center;
  gap: 6px 10px;
  padding: 6px 16px;
}
.found-chip {
  color: rgba(var(--fg-rgb),0.92);
  font-weight: 700;
  font-size: 14px;
  background: rgba(var(--fg-rgb),0.08);
  border-radius: 10px;
  padding: 3px 10px;
  animation: popin 0.35s ease-out;
  text-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.found-chip.special { background: rgba(255,179,0,0.25); color: #ffe3a3; }
@keyframes popin {
  0% { transform: scale(0); opacity: 0; }
  60% { transform: scale(1.25); opacity: 1; }
  100% { transform: scale(1); }
}

#board-wrap {
  width: 100%;
  display: flex; justify-content: center;
  padding: 8px 8px calc(6px + env(safe-area-inset-bottom)) 8px;
  flex-shrink: 0;
}
#board {
  position: relative;
  /* --board-size is set by fitBoard(): the largest board that fits the space left on screen */
  width: var(--board-size, min(92vw, 420px));
  aspect-ratio: 1 / 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 3%;
  padding: 3%;
  background: rgba(0,0,0,0.25);
  border-radius: 24px;
  box-shadow: inset 0 2px 10px rgba(0,0,0,0.4);
}
#line-canvas {
  position: absolute; top:0; left:0; right:0; bottom:0;
  pointer-events: none;
}
.tile {
  position: relative;
  background: linear-gradient(145deg, var(--tile-a), var(--tile-b));
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: calc(var(--board-size, min(92vw, 420px)) * 0.092);
  font-weight: 800;
  color: var(--tile-text);
  border: 1px solid var(--tile-border);
  box-shadow: var(--tile-shadow);
  transition: transform 0.12s, background 0.12s, box-shadow 0.12s, color 0.12s;
}

.tile.tile-combo {
  font-size: calc(var(--board-size, min(92vw, 420px)) * 0.092); /* same size as the other letters */
  background: linear-gradient(145deg, var(--combo-a), var(--combo-b));
  color: var(--combo-text);
}

.tile .pts {
  position: absolute; bottom: 4px; right: 7px;
  font-size: 10px; font-weight: 700; opacity: 0.45;
}
/* Secim sirasinda (parmak/mouse henuz kalkmadan) notr "isaretlendi" rengi:
   gecerlilik kontrolu burada YAPILMAZ, sadece hangi kutucuklarin secili
   oldugunu gostermek icin acik mavi kullanilir. */
.tile.active {
  background: linear-gradient(145deg, var(--active-a), var(--active-b));
  transform: scale(1.1);
  box-shadow: 0 2px 0 rgba(0,0,0,0.3), 0 0 16px var(--active-glow);
  color: var(--active-text);
}
/* Parmak/mouse kaldirildiginda (sonuc belli olunca) oynayan kisa renkli
   geri bildirim animasyonlari: yesil = ilk kez bulunan gecerli kelime,
   sari = daha once bulunmus (tekrar), kirmizi = sozlukte olmayan kelime. */
.tile.valid-pulse {
  animation: tilegood 0.5s ease-out;
}
@keyframes tilegood {
  0% { transform: scale(1.1); }
  40% { transform: scale(1.35) rotate(-4deg); background: linear-gradient(145deg, var(--flash-good-a), var(--flash-good-b)); }
  100% { transform: scale(1); background: linear-gradient(145deg, var(--tile-a), var(--tile-b)); }
}
.tile.tile-combo.valid-pulse { animation: tilegoodcombo 0.5s ease-out; }
@keyframes tilegoodcombo {
  0% { transform: scale(1.1); }
  40% { transform: scale(1.35) rotate(-4deg); background: linear-gradient(145deg, var(--flash-good-a), var(--flash-good-b)); }
  100% { transform: scale(1); background: linear-gradient(145deg, var(--combo-a), var(--combo-b)); }
}
.tile.dup-pulse {
  animation: tiledup 0.5s ease-out;
}
@keyframes tiledup {
  0% { transform: scale(1.1); }
  40% { transform: scale(1.22); background: linear-gradient(145deg, var(--flash-dup-a), var(--flash-dup-b)); }
  100% { transform: scale(1); background: linear-gradient(145deg, var(--tile-a), var(--tile-b)); }
}
.tile.invalid-shake { animation: tileshake 0.4s ease-out; }
@keyframes tileshake {
  0% { transform: translateX(0) scale(1.1); background: linear-gradient(145deg, var(--flash-bad-a), var(--flash-bad-b)); }
  25% { transform: translateX(-6px) scale(1.1); background: linear-gradient(145deg, var(--flash-bad-a), var(--flash-bad-b)); }
  75% { transform: translateX(6px) scale(1.1); background: linear-gradient(145deg, var(--flash-bad-a), var(--flash-bad-b)); }
  100% { transform: translateX(0) scale(1); background: linear-gradient(145deg, var(--tile-a), var(--tile-b)); }
}

.particle {
  position: fixed;
  width: 8px; height: 8px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 999;
  animation: burst 0.8s ease-out forwards;
}
@keyframes burst {
  0% { transform: translate(0,0) scale(1); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(0) rotate(var(--rot, 0deg)); opacity: 0; }
}

#toast {
  position: fixed;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.5);
  font-size: 44px;
  font-weight: 900;
  color: #ffd93d;
  text-shadow: 0 0 20px rgba(255,217,61,0.9), 0 4px 10px rgba(0,0,0,0.5);
  opacity: 0;
  pointer-events: none;
  z-index: 1000;
}
#toast.show {
  animation: toastpop 0.9s ease-out forwards;
}
@keyframes toastpop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.3) rotate(-8deg); }
  20% { opacity: 1; transform: translate(-50%, -50%) scale(1.3) rotate(4deg); }
  40% { transform: translate(-50%, -50%) scale(1) rotate(0deg); }
  80% { opacity: 1; transform: translate(-50%, -60%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -90%) scale(0.9); }
}
/* While the words fit, they start from the bottom row and grow upwards (js/freeplay-targets.js, scrollFoundToEnd) */
#found-words.from-bottom { align-content: flex-end; }
