/* ============================================================
   Palabra oculta — rejilla 6×5 centrada + teclado en pantalla.
   --tile lo calcula hiddenword.js (cabe entera en pantalla con el
   teclado debajo). Tres estados, sobrios y con texto blanco legible en
   los dos temas; además del color, cada estado lleva una marca propia
   (raya = en su sitio, punto = en otro sitio) para no depender solo
   del color.
   ============================================================ */
.hw {
  --tile: 56px;
  /* colores de estado: tokens del sistema, oscurecidos lo justo para
     que el texto blanco tenga buen contraste (AA) en claro y en oscuro */
  --hw-g: var(--success);
  --hw-y: color-mix(in srgb, var(--present) 78%, #000);
  --hw-b: color-mix(in srgb, var(--muted) 82%, #000);
  --hw-on: #fff;
  width: 100%;
  display: flex; flex-direction: column; align-items: center; gap: 18px;
}
:root[data-theme="dark"] .hw {
  --hw-g: color-mix(in srgb, var(--success) 62%, #000);
  --hw-y: color-mix(in srgb, var(--present) 68%, #000);
  --hw-b: var(--surface-3);
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] .hw {
    --hw-g: color-mix(in srgb, var(--success) 62%, #000);
    --hw-y: color-mix(in srgb, var(--present) 68%, #000);
    --hw-b: var(--surface-3);
  }
}

.hw-host { display: flex; justify-content: center; padding: 6px 0 8px; }

.hw-grid { display: grid; gap: 6px; }
.hw-row { display: grid; grid-template-columns: repeat(5, var(--tile)); gap: 6px; }

.hw-tile {
  position: relative;
  box-sizing: border-box;
  width: var(--tile); height: var(--tile);
  display: grid; place-items: center;
  border: 2px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  font-family: var(--font-ui); font-weight: 700;
  font-size: calc(var(--tile) * .5); line-height: 1;
  color: var(--ink);
  text-transform: uppercase;
  user-select: none; -webkit-user-select: none;
}
.hw-row.is-current .hw-tile { border-color: var(--line-2); }
.hw-tile[data-state="filled"] { border-color: var(--ink-2); }
.hw-tile.is-pop { animation: hw-pop .12s ease-out; }
@keyframes hw-pop { 50% { transform: scale(1.07); } }

.hw-tile[data-state="g"], .hw-tile[data-state="y"], .hw-tile[data-state="b"] { color: var(--hw-on); border-color: transparent; }
.hw-tile[data-state="g"] { background: var(--hw-g); }
.hw-tile[data-state="y"] { background: var(--hw-y); }
.hw-tile[data-state="b"] { background: var(--hw-b); }
/* marca de forma además del color */
.hw-tile[data-state="g"]::after {
  content: ""; position: absolute; left: 30%; right: 30%; bottom: 11%;
  height: 3px; border-radius: 2px; background: currentColor; opacity: .8;
}
.hw-tile[data-state="y"]::after {
  content: ""; position: absolute; top: 10%; right: 10%;
  width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9;
}

/* volteo discreto al revelar un intento */
.hw-tile.is-flip { animation: hw-flip .36s ease-in-out; }
@keyframes hw-flip { 0% { transform: rotateX(0); } 50% { transform: rotateX(90deg); } 100% { transform: rotateX(0); } }
/* sacudida si la palabra no vale */
.hw-row.is-shake { animation: hw-shake .4s ease-in-out; }
@keyframes hw-shake {
  15%, 55% { transform: translateX(-6px); }
  35%, 75% { transform: translateX(6px); }
  90% { transform: translateX(-2px); }
}
@media (prefers-reduced-motion: reduce) {
  .hw-tile.is-flip, .hw-row.is-shake, .hw-tile.is-pop { animation: none; }
}

.hw-answer {
  margin: -4px 0 0; display: flex; align-items: baseline; gap: 10px;
  font-size: var(--t-sm); color: var(--muted);
}
.hw-answer-w { font-family: var(--font-num); font-size: 1.15rem; letter-spacing: .18em; color: var(--ink); font-weight: 600; }

/* ---------- teclado ---------- */
.hw-kb {
  width: 100%; max-width: 520px;
  display: flex; flex-direction: column; gap: 7px;
  user-select: none; -webkit-user-select: none;
}
.hw-kb-row { display: flex; justify-content: center; gap: 5px; }
.hw-key {
  position: relative;
  flex: 1 1 0; min-width: 0; max-width: 46px; height: 54px; padding: 0;
  display: inline-grid; place-items: center;
  font: 600 1rem/1 var(--font-ui); color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  transition: background var(--dur), color var(--dur), border-color var(--dur), transform .08s;
}
.hw-key:hover { background: var(--surface-3); }
.hw-key:active { transform: translateY(1px); }
.hw-key:focus-visible { outline: 2px solid var(--sel); outline-offset: 1px; }
.hw-key svg { width: 22px; height: 22px; }
.hw-key-wide { flex: 1.55 1 0; max-width: 76px; font-size: .8rem; letter-spacing: .01em; }
.hw-key[data-state] { color: var(--hw-on); border-color: transparent; }
.hw-key[data-state="g"] { background: var(--hw-g); }
.hw-key[data-state="y"] { background: var(--hw-y); }
.hw-key[data-state="b"] { background: transparent; color: color-mix(in srgb, var(--muted) 70%, transparent); border-color: var(--line); }
.hw-key[data-state="g"]::after {
  content: ""; position: absolute; left: 32%; right: 32%; bottom: 7px;
  height: 2px; border-radius: 2px; background: currentColor; opacity: .8;
}
.hw-key[data-state="y"]::after {
  content: ""; position: absolute; top: 6px; right: 6px;
  width: 5px; height: 5px; border-radius: 50%; background: currentColor;
}

.hw.is-done .hw-kb { opacity: .55; pointer-events: none; }

/* ---------- cómo se juega ---------- */
.hw-help-demo { --tile: 40px; --hw-g: var(--success); --hw-y: color-mix(in srgb, var(--present) 78%, #000); --hw-b: color-mix(in srgb, var(--muted) 82%, #000); --hw-on: #fff;
  display: flex; gap: 5px; justify-content: center; margin: 10px 0 8px; }
.hw-help-note { margin: 0; font-size: var(--t-sm); color: var(--muted); line-height: 1.5; }

/* ---------- tarjeta final: el recorrido en miniatura ---------- */
.hw-win-grid { display: grid; gap: 4px; justify-content: center; margin: 2px 0 14px; }
.hw-mini-row { display: flex; gap: 4px; }
.hw-mini { width: 16px; height: 16px; border-radius: 4px; background: var(--surface-3); }
.hw-mini[data-state="g"] { background: var(--success); }
.hw-mini[data-state="y"] { background: var(--present); }

@media (max-width: 640px) {
  .hw { gap: 14px; }
  .hw-kb {
    position: sticky; bottom: 0; z-index: 5;
    max-width: none; width: auto; align-self: stretch;
    margin: 0 -12px; padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
    background: var(--bg);
  }
  .hw-kb-row { gap: 4px; }
  .hw-key { max-width: none; height: 56px; font-size: 1.05rem; }
  .hw-key-wide { flex: 1.5 1 0; font-size: .78rem; }
}

/* la barra de juego aquí solo lleva el estado y "Más": sin caja, para
   que la rejilla sea lo único que pesa */
.play-hiddenword .play-toolbar { background: transparent; border-color: transparent; padding: 0; min-height: 36px; }
.play-hiddenword .tool-more { margin-left: auto; }
.play-hiddenword .tool-status { text-align: center; }
@media (max-width: 640px) {
  .play-hiddenword .play-toolbar { flex-wrap: nowrap; margin: -6px 0 -4px; }
  .play-hiddenword .tool-status { order: 0; flex: 1 1 auto; flex-basis: auto; text-align: left; padding: 0 4px; white-space: nowrap; }
  .play-hiddenword .tool-status:empty { display: block; }
}
