/* ================================================================
   Cazapalabras — tablero de letras prolijo, cápsula redondeada que
   se dibuja sobre las letras arrastradas y palabras cazadas que
   aterrizan en la lista.
   Se carga DESPUÉS de style.css.
   ================================================================ */

.cp-screen { gap: 9px; }

/* ---- marcador ---- */

.cp-screen .vs-bar { font-size: 1rem; }

.cp-points-row {
  padding: 0 2px;
  font-size: 0.9rem;
}

.cp-points-row .player-you,
.cp-points-row .player-opp {
  padding: 4px 12px;
  border-radius: 999px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.cp-points-row .player-you {
  background: linear-gradient(180deg, rgba(251, 191, 36, 0.24), rgba(251, 191, 36, 0.09));
  box-shadow: inset 0 0 0 1px rgba(251, 191, 36, 0.45);
}

.cp-points-row .player-opp {
  background: linear-gradient(180deg, rgba(56, 189, 248, 0.24), rgba(56, 189, 248, 0.09));
  box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.45);
}

.cp-clock {
  font-size: 1.15rem;
  font-weight: 900;
  letter-spacing: 0.03em;
  text-shadow: 0 0 14px rgba(251, 191, 36, 0.35);
}

.cp-timer {
  height: 9px;
  background: rgba(0, 0, 0, 0.4);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.45);
}

.cp-timer-fill {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0) 60%), #fbbf24;
  box-shadow: 0 0 10px rgba(251, 191, 36, 0.45);
}

.cp-timer-fill.low {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0) 60%), #ef4444;
  box-shadow: 0 0 14px rgba(239, 68, 68, 0.7);
  animation: cp-alarm 0.85s ease-in-out infinite;
}

@keyframes cp-alarm {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.55; }
}

/* ---- palabra en curso ---- */

.cp-word {
  min-height: 38px;
  font-size: clamp(1.15rem, 5.5vw, 1.45rem);
  letter-spacing: 0.12em;
  text-shadow: 0 0 18px rgba(251, 191, 36, 0.4);
  will-change: transform;
}

.cp-word.good {
  color: #86efac;
  text-shadow: 0 0 22px rgba(74, 222, 128, 0.7);
  animation: cp-hit 0.45s cubic-bezier(0.2, 0.9, 0.3, 1);
}

@keyframes cp-hit {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.22); }
  100% { transform: scale(1); }
}

.cp-word.dup { color: #7dd3fc; text-shadow: 0 0 18px rgba(56, 189, 248, 0.45); }
.cp-word.bad { color: #fca5a5; text-shadow: 0 0 18px rgba(248, 113, 113, 0.4); }

/* ---- tablero ---- */

.cp-grid-wrap {
  /* min(100%) en vez de 88vw: respeta el padding de la pantalla y nunca
     se pasa de ancho en celulares de 360px */
  width: min(100%, 380px);
  padding: 8px;
  border-radius: 22px;
  background:
    radial-gradient(120% 100% at 50% 0%, rgba(134, 239, 172, 0.09), rgba(0, 0, 0, 0) 65%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.32), rgba(0, 0, 0, 0.20));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.09),
    inset 0 0 26px rgba(0, 0, 0, 0.30),
    0 8px 20px rgba(0, 0, 0, 0.28);
}

/* la cápsula va DEBAJO de las celdas: las celdas son translúcidas, así que
   el trazo se ve a través y además llena los huecos entre letras */
.cp-path {
  inset: 8px;
  width: auto;
  height: auto;
  z-index: 1;
  overflow: visible;
}

/* 13 de 20 unidades por celda: ancho de cápsula, pero sin desbordar tanto
   sobre las letras vecinas en los tramos diagonales */
.cp-path polyline {
  stroke: rgba(251, 191, 36, 0.68);
  stroke-width: 13;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 2px rgba(251, 191, 36, 0.5));
}

.cp-grid {
  inset: 8px;
  gap: 6px;
  z-index: 2;
}

.cp-cell {
  font-size: clamp(1.15rem, 6vw, 1.6rem);
  font-weight: 800;
  letter-spacing: 0.01em;
  border: none;
  border-radius: 13px;
  color: #f0fdf4;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.13), rgba(255, 255, 255, 0.035));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    inset 0 -3px 0 rgba(0, 0, 0, 0.28),
    0 2px 4px rgba(0, 0, 0, 0.28);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  transition: box-shadow 0.12s ease, background 0.12s ease, transform 0.12s ease;
  will-change: transform;
}

/* celda dentro del arrastre: se hunde un poco y deja pasar la cápsula */
.cp-cell.sel {
  background: linear-gradient(160deg, rgba(253, 224, 71, 0.30), rgba(217, 119, 6, 0.16));
  color: #fffbeb;
  box-shadow:
    inset 0 0 0 2px rgba(253, 224, 71, 0.9),
    inset 0 1px 0 rgba(255, 255, 255, 0.3),
    0 0 14px rgba(251, 191, 36, 0.4);
  transform: scale(1.06);
}

/* ---- palabras cazadas ---- */

.cp-found {
  max-height: 66px;
  gap: 6px;
  padding: 2px;
}

.cp-chip {
  padding: 4px 11px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  border: none;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.3);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
}

/* la palabra recién cazada "aterriza" desde el cartel de arriba */
.cp-found .cp-chip {
  color: #451a03;
  background: linear-gradient(180deg, #fde68a, #f59e0b);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55), 0 2px 6px rgba(0, 0, 0, 0.3);
  animation: cp-land 0.45s cubic-bezier(0.18, 0.9, 0.3, 1.1) both;
}

/* el desplazamiento es corto porque .cp-found recorta: se lee como que la
   ficha cae desde el cartel de la palabra, sin quedar cortada */
@keyframes cp-land {
  0%   { opacity: 0; transform: translateY(-22px) scale(1.35); }
  60%  { opacity: 1; }
  100% { opacity: 1; transform: none; }
}

/* ---- fin de ronda: cada lista con el color de su dueño ---- */

#cp-end-mine .cp-chip {
  color: #451a03;
  background: linear-gradient(180deg, #fde68a, #f59e0b);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

#cp-end-opp .cp-chip {
  color: #082f49;
  background: linear-gradient(180deg, #bae6fd, #38bdf8);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

/* las que se escaparon: tachadas, apagadas */
#cp-end-missed .cp-chip {
  color: #cbd5e1;
  background: rgba(0, 0, 0, 0.30);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
  text-decoration: line-through;
  text-decoration-color: rgba(248, 113, 113, 0.85);
  text-decoration-thickness: 2px;
}

/* "ninguna 😳" no es una palabra: se lleva la especificidad de las listas
   con ID para no salir dorada ni tachada */
#cp-end-mine .cp-chip.none,
#cp-end-opp .cp-chip.none,
#cp-end-missed .cp-chip.none {
  background: rgba(0, 0, 0, 0.22);
  color: #94a3b8;
  text-transform: none;
  text-decoration: none;
  letter-spacing: 0;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.cp-end h3 {
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.72rem;
}

#cp-end-mine-title { color: #fbbf24; }
#cp-end-opp-title { color: #7dd3fc; }

#cp-status { min-height: 20px; text-align: center; }

@media (prefers-reduced-motion: reduce) {
  .cp-word.good,
  .cp-found .cp-chip,
  .cp-timer-fill.low { animation: none; }
}
