/* wordsearch.css — Word Search. Immersive: site chrome hidden; only the grid,
   a slim HUD, the word list and the start/solved overlay show. */

.wg-main.wg-main-game { max-width: none; width: 100%; margin: 0; padding: 0; }

.wg-ws {
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center;
  gap: 8px; padding: 8px 10px 12px; background: #0b1016;
}

/* ── HUD ── */
.wg-ws-hud { width: 100%; max-width: 520px; display: flex; align-items: center; gap: 10px; color: #eaf0f5; }
.wg-ws-exit {
  flex: 0 0 auto; width: 38px; height: 38px; display: grid; place-items: center;
  font-size: 1.5rem; line-height: 1; color: #cdd6de; text-decoration: none;
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12); border-radius: 10px;
}
.wg-ws-exit:hover { background: rgba(255,255,255,0.12); color: #fff; }
.wg-ws-score { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; line-height: 1.05; }
.wg-ws-num { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.01em; }
.wg-ws-mini { font-size: 0.7rem; color: #8a99a8; font-weight: 600; }
.wg-ws-hud-btns { flex: 0 0 auto; display: flex; gap: 6px; }
.wg-ws-hbtn {
  font: inherit; font-size: 0.82rem; font-weight: 700; padding: 8px 12px; min-width: 40px;
  color: #eaf0f5; background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.14); border-radius: 10px; cursor: pointer;
}
.wg-ws-hbtn:hover { background: rgba(255,255,255,0.16); }
.wg-ws-hbtn:disabled { opacity: 0.4; cursor: default; }

/* ── Grid ── */
.wg-ws-boardwrap { position: relative; flex: 1 1 auto; display: flex; align-items: center; justify-content: center; width: 100%; }
.wg-ws-grid {
  position: relative;
  display: grid; grid-template-columns: repeat(var(--n, 8), 1fr);
  width: min(94vw, calc(100vh - 250px), 520px);
  width: min(94vw, calc(100dvh - 250px), 520px);
  aspect-ratio: 1 / 1;
  padding: 6px; gap: 1px;
  background: #0f1720; border: 1px solid rgba(255,255,255,0.10); border-radius: 14px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.45);
  touch-action: none;            /* drag selects letters; never scrolls the page */
  user-select: none; -webkit-user-select: none;
}
.wg-ws-cell {
  display: grid; place-items: center;
  color: #cfd8e0; font-weight: 700; line-height: 1;
  border-radius: 6px; cursor: pointer;
  transition: background-color 0.08s ease, color 0.08s ease;
}
.wg-ws-cell.is-sel { background: rgba(14,175,76,0.55); color: #fff; }
.wg-ws-cell.is-found { background: #0eaf4c; color: #04120a; }
@media (prefers-reduced-motion: reduce) { .wg-ws-cell { transition: none; } }

/* ── Word list ── */
.wg-ws-words {
  width: 100%; max-width: 520px;
  display: flex; flex-wrap: wrap; gap: 5px; justify-content: center;
}
.wg-ws-word {
  font-size: 0.74rem; font-weight: 700; color: #cfd8e0;
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12);
  padding: 3px 9px; border-radius: 999px;
}
.wg-ws-word.is-found { color: #7ee0a2; border-color: rgba(126,224,162,0.45); text-decoration: line-through; opacity: 0.7; }

/* ── Overlay ── */
.wg-ws-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(9,14,20,0.92); border-radius: 14px; padding: 14px; }
.wg-ws-overlay[hidden] { display: none; }
.wg-ws-overlay-card {
  color: #fff; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 9px;
  width: 100%; max-width: 320px; max-height: 100%; overflow: hidden;
}
.wg-ws-overlay-card h2 { margin: 0; font-size: 1.45rem; }
.wg-ws-overlay-card p { margin: 0; display: flex; flex-direction: column; gap: 5px; font-size: 0.9rem; }
.wg-ws-overlay-card .wg-btn { min-width: 160px; }
.wg-ws-final { font-size: 1.2rem; font-weight: 800; }
.wg-ws-best-tag { color: #ffd54a; font-weight: 700; }
.wg-ws-time { color: #7ee0a2; font-weight: 700; font-size: 0.86rem; }
.wg-ws-hint { font-size: 0.82rem; opacity: 0.82; }
.wg-ws-controls { flex: 0 0 auto; margin: 0; font-size: 0.72rem; line-height: 1.45; color: #9fb0be; max-width: 300px; }
.wg-ws-overlay-exit { color: #9fb0be; font-size: 0.85rem; text-decoration: underline; }
.wg-ws-overlay-exit:hover { color: #fff; }

/* Word-pack picker */
.wg-ws-packs { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.wg-ws-pack {
  font: inherit; font-size: 0.8rem; font-weight: 700; padding: 7px 14px;
  color: #cfd8e0; background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.16); border-radius: 999px; cursor: pointer;
}
.wg-ws-pack[aria-pressed="true"] { background: var(--wg-color, #0eaf4c); border-color: var(--wg-color, #0eaf4c); color: #fff; }

/* Themes: a one-line scroll strip — there are ~11 of them and the overlay card
   also has to fit the leaderboard, so they must not wrap into a tall block. */
.wg-ws-themes {
  display: flex; gap: 6px; width: 100%; overflow-x: auto; padding: 1px 2px 3px;
  scrollbar-width: none; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain;
}
.wg-ws-themes::-webkit-scrollbar { display: none; }
.wg-ws-theme {
  flex: 0 0 auto; font: inherit; font-size: 0.72rem; font-weight: 600; padding: 5px 11px;
  color: #9fb0bf; background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.12); border-radius: 999px; cursor: pointer;
  white-space: nowrap; transition: background .18s var(--wg-ease-out, ease), color .18s var(--wg-ease-out, ease);
}
.wg-ws-theme[aria-pressed="true"] { background: rgba(14,175,76,0.22); border-color: var(--wg-color, #0eaf4c); color: #cdf3da; }

/* ── Leaderboard (its list is the only scroll region) ── */
.wg-ws-lb { flex: 1 1 auto; min-height: 0; width: 100%; display: flex; flex-direction: column; text-align: left; margin-top: 2px; }
.wg-ws-lb-head { display: flex; align-items: baseline; gap: 8px; justify-content: center; margin-bottom: 6px; }
.wg-ws-lb-head h3 { margin: 0; font-size: 1rem; color: #eaf0f5; }
.wg-ws-lb-total { font-size: 0.78rem; color: #8a99a8; }
.wg-ws-lb-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.wg-ws-lb-row { display: flex; align-items: center; gap: 10px; padding: 7px 10px; font-size: 0.88rem; background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.08); border-radius: 8px; }
.wg-ws-lb-row.is-me { border-color: var(--wg-color); background: rgba(14,175,76,0.18); }
.wg-ws-lb-rank { flex: 0 0 auto; width: 22px; font-weight: 800; color: #8a99a8; text-align: center; }
.wg-ws-lb-row:nth-child(1) .wg-ws-lb-rank { color: #f5b301; }
.wg-ws-lb-row:nth-child(2) .wg-ws-lb-rank { color: #c4ced6; }
.wg-ws-lb-row:nth-child(3) .wg-ws-lb-rank { color: #cd7f32; }
.wg-ws-lb-name { flex: 1 1 auto; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wg-ws-lb-name em { color: #7ee0a2; font-style: normal; font-weight: 700; font-size: 0.85em; }
.wg-ws-lb-score { flex: 0 0 auto; font-weight: 800; }
.wg-ws-lb-empty { color: #8a99a8; font-size: 0.86rem; text-align: center; padding: 6px 2px; }
.wg-ws-lb-me { margin: 6px 0 0; font-size: 0.84rem; color: #7ee0a2; font-weight: 600; text-align: center; }
