/* Word search — game-specific styles (shared look lives in ../theme.css) */

/* ---------- Play area ---------- */
.play-area {
  display: flex;
  gap: 16px;
  align-items: stretch;
  flex: 1 1 auto;
  min-height: 0;
}

.grid-wrap {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.grid {
  display: grid;
  gap: 2px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  touch-action: none;
  transition: filter 0.25s ease;
  /* Square grid sized to fit both the column width and the viewport height,
     so the whole puzzle is visible without scrolling. */
  width: min(100%, calc(100dvh - 200px));
  align-self: flex-start;
}

.cell {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  font-weight: 700;
  font-size: inherit; /* set on .grid by fitGrid() to scale with cell size */
  border-radius: 6px;
  color: var(--ink);
  background: var(--bg);
  transition: background 0.1s ease;
}

.cell.selecting {
  background: var(--accent);
  color: #fff;
}

.cell.found-1 { background: var(--found-1); }
.cell.found-2 { background: var(--found-2); }
.cell.found-3 { background: var(--found-3); }
.cell.found-4 { background: var(--found-4); }
.cell.found-5 { background: var(--found-5); }
.cell.found-6 { background: var(--found-6); }
.cell.found-7 { background: var(--found-7); }
.cell.found-8 { background: var(--found-8); }

.cell.selecting.found-1, .cell.selecting.found-2, .cell.selecting.found-3,
.cell.selecting.found-4, .cell.selecting.found-5, .cell.selecting.found-6,
.cell.selecting.found-7, .cell.selecting.found-8 {
  background: var(--accent);
  color: #fff;
}

/* ---------- Word panel ---------- */
.word-panel {
  flex: 0 0 250px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  transition: filter 0.25s ease;
  align-self: flex-start;
  max-height: 100%;
  overflow-y: auto;
}

.word-panel.wide {
  flex: 0 0 360px;
}

.word-panel.extra-wide {
  flex: 0 0 480px;
}

.word-panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}

.word-panel-head h2 {
  font-size: 1.05rem;
}

.progress {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

/* The list's font-size is set by fitWords() so the words fill the panel:
   few words get large text, many words shrink just enough to fit. */
.word-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 1rem;
}

.word-list.two-col,
.word-list.three-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.word-list.three-col {
  grid-template-columns: 1fr 1fr 1fr;
  gap: 5px;
}

.word-list.two-col li,
.word-list.three-col li {
  letter-spacing: 0.02em;
  overflow-wrap: anywhere;
}

.word-list li {
  font-weight: 600;
  font-size: inherit;
  letter-spacing: 0.04em;
  padding: 0.3em 0.7em;
  border-radius: 9px;
  background: var(--bg);
  transition: opacity 0.2s ease;
  white-space: nowrap;
}

.word-list li.found {
  text-decoration: line-through;
  opacity: 0.45;
}

/* ---------- Large screens ---------- */
@media (min-width: 1280px) and (min-height: 900px) {
  .grid {
    width: min(100%, calc(100dvh - 230px));
    padding: 12px;
    gap: 3px;
  }

  .word-panel {
    flex: 0 0 300px;
    padding: 18px;
  }

  .word-panel.wide {
    flex: 0 0 400px;
  }

  .word-panel.extra-wide {
    flex: 0 0 520px;
  }
}

/* ---------- Narrow screens ---------- */
@media (max-width: 760px) {
  .play-area {
    flex-direction: column;
  }

  .word-panel {
    flex: 1 1 auto;
    width: 100%;
    max-height: none;
    align-self: stretch;
  }

  .word-list li {
    font-size: 0.9rem;
  }

  .grid {
    width: 100%;
  }
}
