/* Word Search */

.ws-page {
  padding-bottom: max(24px, env(safe-area-inset-bottom));
  touch-action: manipulation;
}

.ws-app {
  width: min(720px, 100%);
  margin: 0 auto;
  padding: 16px 12px 28px;
}

.ws-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.ws-title {
  margin: 0 0 4px;
  font-size: clamp(1.45rem, 5.5vw, 1.9rem);
  letter-spacing: -0.02em;
}

.ws-hint {
  margin: 0;
  color: #94a3b8;
  font-size: 0.9rem;
  line-height: 1.4;
  max-width: 34ch;
}

.ws-scores {
  display: flex;
  gap: 8px;
}

.ws-stat {
  min-width: 58px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.22);
  text-align: center;
}

.ws-stat-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #94a3b8;
}

.ws-stat-value {
  display: block;
  margin-top: 2px;
  font-size: 1.05rem;
  font-weight: 800;
  color: #f8fafc;
  font-variant-numeric: tabular-nums;
}

.ws-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.ws-diff {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #cbd5e1;
  font-size: 0.88rem;
  font-weight: 600;
}

.ws-diff select {
  min-height: 40px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: #1e293b;
  color: #f1f5f9;
  font-weight: 700;
}

.ws-btn {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: #1e293b;
  color: #f1f5f9;
  font-weight: 700;
  cursor: pointer;
}

.ws-btn:hover {
  border-color: rgba(96, 165, 250, 0.55);
}

.ws-btn.primary {
  background: linear-gradient(180deg, #38bdf8, #0284c7);
  border-color: transparent;
  color: #0b1220;
}

.ws-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(120px, 160px);
  gap: 14px;
  align-items: start;
  margin-bottom: 12px;
}

@media (max-width: 560px) {
  .ws-layout {
    grid-template-columns: 1fr;
  }
}

.ws-board-wrap {
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  overflow: hidden;
  border-radius: 14px;
  background: #0f172a;
  border: 1px solid rgba(148, 163, 184, 0.22);
  padding: 8px;
}

.ws-board {
  display: grid;
  gap: 2px;
  width: 100%;
  aspect-ratio: 1;
}

.ws-cell {
  display: grid;
  place-items: center;
  border-radius: 4px;
  font-weight: 800;
  font-size: clamp(0.72rem, 2.8vw, 1.05rem);
  color: #e2e8f0;
  background: #1e293b;
  cursor: pointer;
  transition: background 0.08s ease, color 0.08s ease;
}

.ws-cell.is-selecting {
  background: #38bdf8;
  color: #0b1220;
}

.ws-cell.is-found {
  color: #0b1220;
  font-weight: 900;
}

.ws-cell.is-found[data-tone="0"] { background: #67e8f9; }
.ws-cell.is-found[data-tone="1"] { background: #fbbf24; }
.ws-cell.is-found[data-tone="2"] { background: #a78bfa; }
.ws-cell.is-found[data-tone="3"] { background: #fb7185; }
.ws-cell.is-found[data-tone="4"] { background: #34d399; }
.ws-cell.is-found[data-tone="5"] { background: #60a5fa; }
.ws-cell.is-found[data-tone="6"] { background: #f472b6; }
.ws-cell.is-found[data-tone="7"] { background: #fcd34d; }
.ws-cell.is-found[data-tone="8"] { background: #2dd4bf; }
.ws-cell.is-found[data-tone="9"] { background: #c084fc; }

.ws-words {
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.22);
  padding: 12px;
}

.ws-words-title {
  margin: 0 0 8px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #94a3b8;
}

.ws-word-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

@media (max-width: 560px) {
  .ws-word-list {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
  }
}

.ws-word-item {
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #e2e8f0;
  padding: 4px 0;
}

@media (max-width: 560px) {
  .ws-word-item {
    padding: 4px 8px;
    border-radius: 8px;
    background: #1e293b;
  }
}

.ws-word-item.is-found {
  color: #64748b;
  text-decoration: line-through;
  text-decoration-thickness: 2px;
}

.ws-status {
  margin: 0 0 18px;
  color: #94a3b8;
  font-size: 0.9rem;
  min-height: 1.4em;
}

.ws-leaderboard {
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(148, 163, 184, 0.2);
  padding: 14px;
}

.ws-leaderboard-title {
  margin: 0 0 4px;
  font-size: 1.05rem;
}

.ws-leaderboard-lead {
  margin: 0 0 12px;
  color: #94a3b8;
  font-size: 0.85rem;
  line-height: 1.45;
}

.ws-leaderboard-lead a {
  color: #7dd3fc;
}

.ws-leaderboard-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ws-leaderboard-row {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 10px;
  background: #1e293b;
  font-size: 0.9rem;
}

.ws-leaderboard-row.is-you {
  outline: 1px solid rgba(56, 189, 248, 0.55);
}

.ws-leaderboard-rank {
  font-weight: 800;
  color: #94a3b8;
}

.ws-leaderboard-name {
  font-weight: 700;
  color: #f1f5f9;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ws-leaderboard-score {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: #7dd3fc;
}

.ws-leaderboard-empty {
  margin: 0;
  color: #94a3b8;
  font-size: 0.9rem;
}

.ws-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(4px);
}

.ws-overlay[hidden] {
  display: none;
}

.ws-overlay-card {
  width: min(360px, 100%);
  padding: 22px 18px;
  border-radius: 16px;
  background: #0f172a;
  border: 1px solid rgba(148, 163, 184, 0.28);
  text-align: center;
}

.ws-overlay-card h2 {
  margin: 0 0 8px;
  font-size: 1.35rem;
}

.ws-overlay-card p {
  margin: 0 0 16px;
  color: #94a3b8;
  line-height: 1.45;
}
