:root {
  --ws-primary: #2563eb;
  --ws-primary-dark: #1d4ed8;
  --ws-toolbar: #e8e8e8;
  --ws-list-bg: #f0f0f0;
  --ws-found: #4caf50;
  --ws-select: #ffd54f;
  --ws-cell: #fff;
  --ws-text: #1a1a1a;
  --ws-font-sm: 0.72rem;
  --ws-font-md: 0.88rem;
  --ws-font-lg: 1.05rem;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body.ws-page {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ws-text);
  background: #fafafa;
  line-height: 1.5;
}

.ws-home-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #7c3aed;
  color: #fff;
  border: 0;
  border-radius: 999px;
  padding: 0.55rem 0.95rem;
  font-weight: 700;
  font-size: 0.9rem;
  text-decoration: none;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.12s ease;
}

.ws-home-btn:hover {
  filter: brightness(1.1);
  color: #fff;
}

.ws-timer-btn {
  border: 0;
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.12s ease;
}

.ws-timer-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.ws-timer-start {
  background: #16a34a;
  color: #fff;
}

.ws-timer-pause {
  background: #ea580c;
  color: #fff;
}

.ws-theme-pick-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.ws-theme-pick {
  border: 1px solid #475569;
  background: #1e293b;
  color: #e2e8f0;
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.ws-theme-pick.active,
.ws-theme-pick:hover {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

.ws-skip {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  padding: 0.5rem 1rem;
  background: #000;
  color: #fff;
}

.ws-skip:focus {
  left: 0;
}

/* Header */
.ws-header {
  background: linear-gradient(180deg, var(--ws-primary) 0%, var(--ws-primary-dark) 100%);
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.ws-header-main {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
  padding: 0.65rem 1rem 0.85rem;
  width: 100%;
}

.ws-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
}

.ws-brand-link {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  text-decoration: none;
}

.ws-site-logo {
  display: block;
  height: clamp(34px, 7vw, 50px);
  width: auto;
  max-width: min(200px, 42vw);
  object-fit: contain;
}

.ws-header-title {
  margin: 0;
  padding: 0;
  width: 100%;
  font-size: clamp(1.35rem, 4vw, 1.6rem);
  font-weight: 700;
  letter-spacing: 0.03em;
  text-align: center;
  color: #fff;
}

.ws-header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
}

/* Pill buttons — high contrast on blue header */
.ws-header-actions .ws-home-btn,
.ws-header-actions .word-category-btn,
.ws-header-actions .settings-btn,
.ws-header-actions .new-game-btn {
  border: 2px solid rgba(255, 255, 255, 0.45);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.25);
  font-size: 0.875rem;
  font-weight: 700;
  white-space: nowrap;
  line-height: 1.2;
}

.ws-header-actions .ws-home-btn {
  background: #7c3aed;
  color: #fff;
}

.ws-header-actions .ws-home-btn:hover {
  background: #6d28d9;
  color: #fff;
}

.ws-header-actions .word-category-btn {
  background: #16a34a;
  color: #fff;
}

.ws-header-actions .word-category-btn:hover {
  background: #15803d;
  filter: none;
}

.ws-header-actions .settings-btn {
  background: #e0f2fe;
  color: #0c4a6e;
  border-color: rgba(255, 255, 255, 0.65);
}

.ws-header-actions .settings-btn:hover {
  background: #fff;
  color: #075985;
  filter: none;
}

.ws-header-actions .new-game-btn {
  background: #ffffff;
  color: #1d4ed8;
  border-color: #fff;
}

.ws-header-actions .new-game-btn:hover {
  background: #eff6ff;
  color: #1e40af;
}

@media (max-width: 700px) {
  .ws-header-top {
    flex-wrap: wrap;
  }

  .ws-site-logo {
    max-width: 140px;
    height: 32px;
  }

  .ws-header-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .ws-header-actions .ws-home-btn,
  .ws-header-actions .word-category-btn,
  .ws-header-actions .settings-btn,
  .ws-header-actions .new-game-btn {
    font-size: 0.78rem;
    padding: 0.45rem 0.7rem;
  }
}

.ws-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.45rem 0.75rem;
  background: var(--ws-toolbar);
  color: var(--ws-text);
  border-top: 1px solid #d0d0d0;
}

.ws-toolbar-left,
.ws-toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.ws-progress {
  font-weight: 600;
  font-size: 0.95rem;
  min-width: 4.5rem;
}

.ws-timer {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.ws-timer svg {
  width: 1.1rem;
  height: 1.1rem;
  opacity: 0.75;
}

.ws-lang {
  padding: 0.25rem 0.5rem;
  border: 1px solid #bbb;
  border-radius: 4px;
  background: #fff;
  font-size: 0.85rem;
}

.ws-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  color: var(--ws-text);
}

.ws-icon-btn:hover {
  background: rgba(0, 0, 0, 0.08);
}

.ws-icon-btn svg {
  width: 1.25rem;
  height: 1.25rem;
}

.ws-font-btn {
  font-weight: 800;
  font-size: 1rem;
}

/* Game layout */
.ws-game-wrap {
  display: flex;
  min-height: calc(100vh - 7rem);
  max-height: calc(100vh - 7rem);
}

.ws-word-list {
  flex: 0 0 min(220px, 32vw);
  background: var(--ws-list-bg);
  border-right: 1px solid #ddd;
  overflow-y: auto;
  padding: 0.5rem 0.75rem;
  list-style: none;
  margin: 0;
}

.ws-word-list li {
  padding: 0.2rem 0;
  font-weight: 600;
  letter-spacing: 0.04em;
  font-size: var(--ws-list-font, var(--ws-font-md));
  transition: color 0.2s, opacity 0.2s;
}

.ws-word-list li.found {
  color: var(--ws-found);
  text-decoration: line-through;
  opacity: 0.75;
}

.ws-grid-panel {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 0.75rem;
  background: #fff;
  touch-action: none;
  user-select: none;
}

.ws-grid {
  display: grid;
  gap: 2px;
  margin: 0 auto;
}

.ws-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--ws-cell-size, 1.65rem);
  height: var(--ws-cell-size, 1.65rem);
  font-size: var(--ws-grid-font, var(--ws-font-md));
  font-weight: 700;
  background: var(--ws-cell);
  border: 1px solid #e0e0e0;
  cursor: pointer;
  transition: background 0.15s;
}

.ws-cell.selecting {
  background: var(--ws-select);
}

.ws-cell.found {
  background: #c8e6c9;
  border-color: #81c784;
}

/* Win toast — hidden until puzzle complete (no red bar at bottom) */
.ws-win-banner {
  display: none;
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: #15803d;
  color: #fff;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.18);
  z-index: 50;
  max-width: min(92vw, 28rem);
  text-align: center;
}

.ws-win-banner.show {
  display: block;
  animation: ws-win-pop 0.35s ease;
}

@keyframes ws-win-pop {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(0.75rem);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* SEO */
.ws-seo {
  max-width: 52rem;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
}

.ws-seo h1 {
  font-size: 1.75rem;
  margin: 0 0 0.75rem;
}

.ws-seo h2 {
  font-size: 1.25rem;
  margin: 1.75rem 0 0.5rem;
}

.ws-seo-lead {
  font-size: 1.05rem;
  color: #333;
}

.ws-seo-subhead {
  font-size: 1.2rem;
  margin: 1.5rem 0 0.35rem;
}

.ws-seo-intro-boxes {
  margin: 0 0 1rem;
  color: #475569;
  font-size: 0.98rem;
}

.ws-feature-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem;
  margin: 0 0 1.5rem;
}

@media (min-width: 520px) {
  .ws-feature-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 900px) {
  .ws-feature-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.ws-feature-box {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 1rem 1.05rem;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
  border-top: 3px solid var(--ws-primary);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.ws-feature-box:hover {
  border-color: #cbd5e1;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.1);
}

.ws-feature-box h3 {
  margin: 0 0 0.4rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.3;
}

.ws-feature-box p {
  margin: 0;
  font-size: 0.88rem;
  color: #475569;
  line-height: 1.45;
}

.ws-seo-steps,
.ws-seo-tips,
.ws-seo-audience {
  padding-left: 1.25rem;
}

.ws-seo-audience li {
  margin-bottom: 0.45rem;
}

.ws-seo-faq-grid {
  display: grid;
  gap: 1rem;
}

@media (min-width: 640px) {
  .ws-seo-faq-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.ws-seo-faq-item {
  background: #f5f5f5;
  padding: 1rem;
  border-radius: 8px;
}

.ws-seo-faq-item h3 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
}

.ws-seo-faq-item a {
  color: var(--ws-primary);
}

.ws-seo-faq-item p {
  margin: 0;
  font-size: 0.95rem;
  color: #444;
}

.ws-internal-links {
  background: #f0f0f0;
  padding: 2rem 1.25rem;
  border-top: 1px solid #ddd;
}

.ws-internal-wrap {
  max-width: 52rem;
  margin: 0 auto;
}

.ws-internal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}

.ws-internal-card {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.75rem 1rem;
  background: #fff;
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  border: 1px solid #ddd;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.ws-internal-card:hover {
  border-color: var(--ws-primary);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.12);
}

.ws-internal-card span {
  font-size: 0.85rem;
  color: #666;
}

.ws-footer {
  text-align: center;
  padding: 1.25rem 1rem;
  font-size: 0.85rem;
  color: #64748b;
  background: #fff;
  border-top: 1px solid #e2e8f0;
}

.ws-footer a {
  color: var(--ws-primary);
  margin: 0 0.5rem;
  text-decoration: none;
}

.ws-footer a:hover {
  text-decoration: underline;
}

@media (max-width: 700px) {
  .ws-game-wrap {
    flex-direction: column;
    min-height: auto;
    max-height: none;
  }

  .ws-word-list {
    flex: none;
    max-height: 140px;
    border-right: none;
    border-bottom: 1px solid #ddd;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.75rem;
  }

  .ws-word-list li {
    display: inline-block;
  }
}
