/* Word games — Word Search and Daily Word. Reuses Fire A tokens. */

.word-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space);
  padding: var(--space);
  background: radial-gradient(120% 90% at 50% 28%, #2e4d78 0%, #1d2f4a 55%, #152238 100%);
  border-radius: var(--radius-lg);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), inset 0 0 60px rgba(0,0,0,0.35);
}
@media (max-width: 800px) {
  .word-body { grid-template-columns: 1fr; }
}

/* ---- Word Search ---- */
.ws-grid {
  display: grid;
  grid-template-columns: repeat(var(--ws-size, 12), 1fr);
  gap: 2px;
  width: min(100%, 680px);
  margin: 0 auto;
  aspect-ratio: 1 / 1;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
.ws-cell {
  background: rgba(255,255,255,0.08);
  border-radius: 6px;
  color: var(--fg);
  font-weight: 700;
  font-size: clamp(11px, 2.3vmin, 22px);
  display: flex; align-items: center; justify-content: center;
  padding: 0;
  cursor: pointer;
  min-height: 0;
  min-width: 0;
  transition: background 0.12s ease, color 0.12s ease, transform 0.12s ease;
}
.ws-cell:hover { background: rgba(255,255,255,0.14); }
.ws-cell.is-preview {
  background: rgba(87, 184, 76, 0.55);
  color: #fff;
}
.ws-cell.is-active {
  background: rgba(87, 184, 76, 0.9);
  color: #fff;
}
.ws-cell.is-cursor {
  box-shadow: 0 0 0 3px var(--focus);
  z-index: 2;
  position: relative;
}
.ws-cell.is-found {
  background: rgba(87, 184, 76, 0.32);
  color: #d6ffcf;
  box-shadow: inset 0 0 0 1px rgba(87, 184, 76, 0.55);
}
.ws-side {
  min-width: 160px;
  max-width: 260px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
@media (max-width: 800px) {
  .ws-side { max-width: none; min-width: 0; }
}
.ws-words-title {
  margin: 0 0 4px;
  font-size: 0.85em;
  color: var(--fg-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.ws-words {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.ws-word {
  padding: 4px 10px;
  background: rgba(255,255,255,0.08);
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.95em;
  letter-spacing: 0.5px;
  transition: opacity 0.2s ease;
}
.ws-word.is-found {
  background: rgba(87, 184, 76, 0.32);
  color: #d6ffcf;
  text-decoration: line-through;
  opacity: 0.7;
}

/* ---- Daily Word ---- */
.dw-body {
  display: flex;
  flex-direction: column;
  gap: var(--space);
  align-items: center;
  padding: var(--space);
}
.dw-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
  /* Height-fenced: the grid is 6 rows over 5 columns (height ~1.2 x
     width) and the keyboard below it needs ~150px. At a 688px tablet
     viewport the old fixed 340px width pushed the keyboard's second
     and third rows below the fold (visual sweep 2026-11-17). */
  width: min(100%, 340px, calc((var(--win-h, 100dvh) - 395px) * 0.8333));
}
.dw-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}
.dw-cell {
  aspect-ratio: 1 / 1;
  background: rgba(255,255,255,0.05);
  border-radius: 8px;
  border: 2px solid rgba(255,255,255,0.14);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
  font-size: clamp(18px, 4.5vmin, 30px);
  color: var(--fg);
  text-transform: uppercase;
  transition: background 0.2s ease, color 0.2s ease;
}
.dw-cell.is-typing { border-color: rgba(255,255,255,0.4); }
.dw-cell.is-cursor { border-color: var(--focus); box-shadow: 0 0 0 2px rgba(245,197,66,0.3); }
.dw-cell.is-gray { background: #434a55; color: #cfd6df; border-color: transparent; }
.dw-cell.is-yellow { background: #b79838; color: #fff; border-color: transparent; }
.dw-cell.is-green { background: #4c9d5c; color: #fff; border-color: transparent; }

.dw-keyboard {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  width: min(100%, 600px);
}
.dw-key-row {
  display: flex;
  gap: 4px;
  justify-content: center;
  width: 100%;
}
.dw-key {
  flex: 1 1 0;
  min-width: 0;
  min-height: 44px;
  padding: 6px 4px;
  background: rgba(255,255,255,0.12);
  border-radius: 6px;
  font-weight: 700;
  font-size: clamp(11px, 2vmin, 15px);
  color: var(--fg);
  transition: background 0.12s ease;
}
.dw-key:hover { background: rgba(255,255,255,0.18); }
.dw-key.dw-key-wide { flex: 1.5 1 0; font-size: 0.82em; }
.dw-key.is-gray { background: #363c46; color: #afb6c1; }
.dw-key.is-yellow { background: #b79838; color: #fff; }
.dw-key.is-green { background: #4c9d5c; color: #fff; }
.dw-stats { color: var(--fg-dim); font-size: 0.95em; }

@media (max-width: 480px) {
  .dw-cell { font-size: clamp(16px, 7vw, 24px); }
}

/* ---- Daily Crossword ---- */
.cw-chooser { display: flex; flex-direction: column; gap: var(--space); padding: var(--space); }
.cw-today-btn {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  min-height: 72px; padding: 14px 20px; text-align: left; width: min(100%, 560px);
}
.cw-today-title { font-size: 1.35em; font-weight: 800; }
.cw-today-line { font-size: 1em; opacity: 0.92; }
.cw-chooser-note { margin: 0; color: var(--fg-dim); }
.cw-puzzle-list {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
}
.cw-puzzle-btn {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  min-height: 64px; padding: 10px 14px; text-align: left;
}
.cw-puzzle-name { font-weight: 700; font-size: 1.1em; }
.cw-puzzle-size { color: var(--fg-dim); font-size: 0.95em; }
.cw-puzzle-note { font-size: 0.9em; color: var(--focus); font-weight: 700; }
.cw-puzzle-btn.is-done .cw-puzzle-note { color: #8fd18a; }

.cw-zoom-bar { display: flex; gap: 8px; justify-content: center; margin: 4px 0; }
.cw-zoom-btn { min-width: 96px; min-height: 48px; }
.cw-grid-wrap {
  display: flex; justify-content: center;
  padding: 6px;
  overflow: hidden;
}
.cw-grid-wrap.is-zoomed {
  /* Zoomed: scroll both ways (drag pans); start alignment keeps the
     left and top edges reachable. */
  justify-content: flex-start;
  align-items: flex-start;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.cw-grid {
  flex: none;
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--cw-n, 9), var(--cw-u, 40px));
  grid-auto-rows: var(--cw-u, 40px);
  gap: 0;
  background: #0b111b;
  border: 3px solid #0b111b;
  border-radius: 6px;
  user-select: none;
  -webkit-user-select: none;
}
.cw-cell {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  padding: 0; margin: 0;
  min-width: 0; min-height: 0;
  background: #f7f4ea;
  color: #111;
  border: 1px solid #0b111b;
  border-radius: 0;
  cursor: pointer;
}
.cw-cell.is-black { background: #0b111b; cursor: default; }
.cw-cell.is-word { background: #cfe3ff; }
.cw-cell.is-sel { background: #ffd95e; box-shadow: inset 0 0 0 3px #b07d00; }
.cw-cell .cw-letter {
  font-weight: 800;
  font-size: calc(var(--cw-u, 40px) * 0.6);
  line-height: 1;
  text-transform: uppercase;
}
.cw-cell .cw-num {
  position: absolute; top: 1px; left: 3px;
  font-size: max(10px, calc(var(--cw-u, 40px) * 0.27));
  font-weight: 700; line-height: 1;
  color: #333;
}
/* Check marks a wrong letter gently: a soft red slash, never a flash. */
.cw-cell.is-wrong .cw-letter { color: #b3261e; }
.cw-cell.is-wrong::after {
  content: ""; position: absolute; left: 12%; right: 12%; top: 50%;
  border-top: 2px solid rgba(179,38,30,0.55);
  transform: rotate(-35deg);
  pointer-events: none;
}
.cw-cell.is-revealed .cw-letter { color: #1f5fbf; }
.cw-cell.is-revealed::before {
  content: ""; position: absolute; right: 2px; top: 2px;
  width: 0; height: 0;
  border-left: 8px solid transparent;
  border-top: 8px solid #1f5fbf;
  pointer-events: none;
}

.cw-clue-bar {
  display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap;
  margin: 8px auto 6px; padding: 12px 16px;
  width: min(100%, 760px);
  background: rgba(255,255,255,0.1);
  border-radius: var(--radius-lg);
  font-size: 1.3em;
  min-height: 56px;
}
.cw-clue-num { font-weight: 800; color: var(--focus); white-space: nowrap; }
.cw-clue-text { font-weight: 600; }
.cw-row {
  display: flex; gap: 8px; justify-content: center; flex-wrap: wrap;
  margin: 6px auto; width: min(100%, 760px);
}
.cw-big-btn { min-height: 52px; min-width: 132px; flex: 1 1 0; font-size: 1.05em; }
.cw-status { text-align: center; min-height: 1.4em; margin: 4px auto; width: min(100%, 760px); font-size: 1.05em; }
.cw-keyboard {
  display: flex; flex-direction: column; gap: 6px; align-items: center;
  width: min(100%, 760px); margin: 8px auto;
}
.cw-key-row { display: flex; gap: 5px; justify-content: center; width: 100%; }
.cw-key {
  flex: 1 1 0; min-width: 0; min-height: 52px;
  padding: 6px 2px;
  background: rgba(255,255,255,0.14);
  border-radius: 8px;
  font-weight: 800; font-size: 1.2em;
  color: var(--fg);
}
.cw-key:hover { background: rgba(255,255,255,0.2); }
.cw-key.cw-key-wide { flex: 1 1 0; font-size: 1.05em; max-width: 280px; }
.cw-done-info { color: var(--fg-dim); font-size: 1em; }
