/* WordSearch player styles — light theme, Merriweather (mid-day.com look).
   All scoped under .ws so the widget is safe to embed anywhere. */

.ws {
  /* theme tokens — retune per host if needed */
  --ws-font: "Merriweather", Georgia, "Times New Roman", serif;
  --ws-bg: #ffffff;
  --ws-ink: #1a1a1a;
  --ws-muted: #6b6b6b;
  --ws-line: #2b2b2b;
  --ws-cell-bg: #ffffff;
  --ws-sel: #f5b301;         /* in-progress selection */
  --ws-found: #cfe8cf;       /* solved word cells */
  --ws-found-ink: #1c5e20;
  --ws-anchor: #fde7b0;      /* first tap of a tap-tap selection */
  --ws-accent: #c8102e;      /* mid-day red */
  --ws-panel: #faf7f2;
  --ws-border: #e3ded5;

  font-family: var(--ws-font);
  color: var(--ws-ink);
  background: var(--ws-bg);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  /*max-width: 960px;*/
  margin: 0 auto;
  /*padding: 14px;*/
  box-sizing: border-box;
}
.ws *, .ws *::before, .ws *::after { box-sizing: border-box; }

/* header */
.ws-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 2px solid var(--ws-line);
  padding-bottom: 10px;
  margin-bottom: 14px;
}
.ws-theme { margin: 0; font-size: 1.4rem; font-weight: 700; }
.ws-sub { color: var(--ws-muted); font-size: .8rem; font-style: italic; margin-top: 2px; }
.ws-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.ws-progress {
  font-size: .82rem;
  font-weight: 700;
  color: var(--ws-accent);
  white-space: nowrap;
}
.ws-timer {
  font-variant-numeric: tabular-nums;
  font-size: 1.1rem;
  font-weight: 700;
  background: var(--ws-panel);
  border: 1px solid var(--ws-border);
  border-radius: 8px;
  padding: 4px 10px;
  white-space: nowrap;
}

/* layout */
.ws-body { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.ws-left { flex: 1 1 420px; min-width: 280px; }
.ws-words { flex: 1 1 220px; min-width: 200px; }

/* grid */
.ws-grid {
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  grid-template-rows: repeat(var(--rows), 1fr);
  gap: 0;
  width: 100%;
  max-width: 560px;
  aspect-ratio: 1 / 1;
  border: 2px solid var(--ws-line);
  background: var(--ws-line);
  outline: none;
  touch-action: none;          /* let the grid own drag gestures */
  user-select: none;
}
.ws-cell {
  position: relative;
  background: var(--ws-cell-bg);
  border: .5px solid var(--ws-border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: 700;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  line-height: 1;
}
.ws-letter {
  font-size: clamp(11px, 3.2vw, 22px);
  text-transform: uppercase;
  pointer-events: none;
}
.ws-cell.ws-found { background: var(--ws-found); }
.ws-cell.ws-found .ws-letter { color: var(--ws-found-ink); }
.ws-cell.ws-anchor { background: var(--ws-anchor); }
.ws-cell.ws-sel { background: var(--ws-sel); }
/* selection wins over found while dragging over already-found cells */
.ws-cell.ws-found.ws-sel { background: var(--ws-sel); }

.ws-cell.ws-pop { animation: ws-pop .38s ease; }
@keyframes ws-pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.28); }
  100% { transform: scale(1); }
}

/* word list */
.ws-words-head {
  margin: 0 0 8px;
  font-size: 1rem;
  border-bottom: 1px solid var(--ws-border);
  padding-bottom: 4px;
}
.ws-wordlist {
  list-style: none;
  margin: 0;
  padding: 0;
  columns: 2;
  column-gap: 18px;
}
.ws-word {
  font-size: .9rem;
  padding: 3px 6px;
  margin: 0 -4px;
  border-radius: 5px;
  cursor: pointer;
  break-inside: avoid;
  transition: color .2s ease, opacity .2s ease, background .15s ease;
}
.ws-word:hover { background: var(--ws-panel); }
.ws-word-selected,
.ws-word-selected:hover {
  background: var(--ws-anchor);
  outline: 1px solid var(--ws-accent);
}
.ws-word-found {
  text-decoration: line-through;
  text-decoration-color: var(--ws-accent);
  color: var(--ws-muted);
  opacity: .65;
  cursor: default;
}
.ws-word-found:hover { background: none; }
.ws-word-revealed { font-style: italic; }

/* toolbar */
.ws-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--ws-border);
}
.ws-btn {
  font-family: inherit;
  font-size: .82rem;
  padding: 6px 12px;
  border: 1px solid var(--ws-line);
  border-radius: 6px;
  background: #fff;
  color: var(--ws-ink);
  cursor: pointer;
}
.ws-btn:hover { background: var(--ws-panel); }
.ws-btn:active { transform: translateY(1px); }
.ws-btn:disabled { opacity: .45; cursor: default; }
.ws-btn:disabled:hover { background: #fff; }
.ws-btn-danger { border-color: var(--ws-accent); color: var(--ws-accent); }
.ws-toolbar-hint { font-size: .78rem; color: var(--ws-muted); margin-right: auto; }

/* completion overlay + confetti */
.ws-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.ws-overlay.ws-hidden { display: none; }
.ws-confetti {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.ws-overlay-card {
  position: relative;
  background: #fff;
  border-radius: 14px;
  padding: 28px 34px;
  text-align: center;
  max-width: 320px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
  animation: ws-cardin .45s cubic-bezier(.2, .9, .3, 1.2);
}
@keyframes ws-cardin {
  0% { transform: scale(.7); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
.ws-overlay-card h3 { margin: 6px 0; font-size: 1.5rem; }
.ws-overlay-emoji { font-size: 2.6rem; }
.ws-overlay-time { color: var(--ws-muted); margin: 4px 0 16px; }

.ws-hidden { display: none; }

/* error box */
.ws-error {
  border: 1px solid var(--ws-accent);
  background: #fff4f4;
  color: #7a1c1c;
  padding: 14px 16px;
  border-radius: 8px;
}
.ws-error strong { display: block; margin-bottom: 4px; }

/* small screens: word list stacks below the grid */
@media (max-width: 640px) {
  .ws { padding: 10px; }
  .ws-body { flex-direction: column; }
  .ws-left, .ws-words { flex: 1 1 auto; width: 100%; }
  .ws-grid { max-width: 100%; }
  .ws-wordlist { columns: 3; }
}

@media (prefers-reduced-motion: reduce) {
  .ws-cell.ws-pop { animation: none; }
  .ws-overlay-card { animation: none; }
}
