/* Word Search — own styles, theme variables only. Root class: .ws */

.ws {
  width: 100%;
  max-width: 640px;
}

/* ---------------------------------------------------------------- stats bar */

.ws-bar {
  display: flex;
  align-items: stretch;
  gap: 10px;
  margin-bottom: 12px;
}

.ws-stat {
  min-width: 84px;
  padding: 8px 14px 6px;
  text-align: center;
  border-radius: 10px;
  background: var(--gm-surface, #1b2740);
  border: 1px solid var(--gm-line, rgba(255, 255, 255, 0.09));
}

.ws-stat-theme {
  flex: 1;
  min-width: 0;
  text-align: left;
}

.ws-stat b {
  display: block;
  font: 500 1.25rem/1.2 var(--gm-display, "Fraunces", Georgia, serif);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ws-lab {
  display: block;
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gm-muted, rgba(242, 238, 230, 0.66));
}

/* ---------------------------------------------------------------- grid */

.ws-grid {
  --n: 10;
  container-type: inline-size;
  display: grid;
  grid-template-columns: repeat(var(--n), 1fr);
  gap: 3px;
  width: 100%;
  padding: 8px;
  box-sizing: border-box;
  background: var(--gm-surface, #1b2740);
  border: 1px solid var(--gm-line, rgba(255, 255, 255, 0.09));
  border-radius: var(--gm-radius, 12px);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.ws-cell {
  appearance: none;
  -webkit-appearance: none;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 18%;
  cursor: pointer;
  touch-action: none;
  font: 600 calc(100cqw / var(--n) * 0.48)/1 var(--gm-body, "DM Sans", system-ui, sans-serif);
  text-transform: uppercase;
  color: var(--gm-text, #f2eee6);
  background: var(--gm-bg-2, #131c2b);
  transition: background 0.12s ease, color 0.12s ease;
}

.ws-cell:hover {
  background: var(--gm-surface-2, #22304a);
}

.ws-cell:focus-visible {
  outline: 3px solid var(--gm-accent-bright, #e0584a);
  outline-offset: -2px;
  position: relative;
  z-index: 2;
}

.ws-cell.is-found {
  background: var(--gm-accent-soft, rgba(192, 57, 43, 0.3));
  box-shadow: inset 0 0 0 1px var(--gm-accent-line, rgba(192, 57, 43, 0.42));
}

.ws-cell.is-start {
  box-shadow: inset 0 0 0 3px var(--gm-accent-bright, #e0584a);
}

.ws-cell.is-sel,
.ws-cell.is-sel.is-found {
  background: var(--gm-accent, #c0392b);
  color: #fff;
}

.ws-cell.is-miss {
  animation: ws-miss 0.4s ease;
}

@keyframes ws-miss {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6%); }
  75% { transform: translateX(6%); }
}

#gm-word-search .gm-status { margin-top: 12px; }

/* ---------------------------------------------------------------- word list */

.ws-words {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ws-words li {
  padding: 7px 10px;
  border-radius: 8px;
  background: var(--gm-bg-2, #131c2b);
  font-size: 0.84rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.2s ease, color 0.2s ease;
}

.ws-words li.is-found {
  text-decoration: line-through;
  color: var(--gm-muted, rgba(242, 238, 230, 0.66));
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--gm-line, rgba(255, 255, 255, 0.09));
}

.gm-seg button,
.gm-actions .gm-btn { min-height: 44px; }

@media (max-width: 480px) {
  .ws-bar { gap: 6px; }
  .ws-stat { min-width: 64px; padding: 8px 8px 6px; }
  .ws-stat b { font-size: 1.1rem; }
  .ws-grid { padding: 5px; gap: 2px; }
  .ws-cell { border-radius: 14%; }
}

@media (prefers-reduced-motion: reduce) {
  .ws-cell, .ws-words li { transition: none; }
  .ws-cell.is-miss { animation: none; }
}
