/* Word Search: one-screen play area, themed to match rtwl.fun (body.fx). */
html:has(body.ws-page), body.ws-page {
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  color-scheme: dark;
}
body.ws-page { min-height: 0; touch-action: manipulation; }
body.ws-page, body.ws-page * { box-sizing: border-box; }
body.ws-page .game-wrap {
  width: min(1180px, calc(100% - 16px));
  height: 100dvh;
  max-height: 100dvh;
  margin: 0 auto;
  padding: max(6px, env(safe-area-inset-top)) 0 max(8px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
  box-sizing: border-box;
}

.ws-top { display: flex; align-items: center; gap: 10px 14px; flex-shrink: 0; min-height: 0; }
.ws-top .back { margin: 0; flex-shrink: 0; color: var(--fx-neon, #3dff8a); font-size: 0.92rem; }
body.ws-page .ws-top .gg-head { flex: 1 1 auto; min-width: 0; align-items: center; }
body.ws-page .ws-top h1 {
  margin: 0;
  font-size: clamp(1.15rem, 2.2vw + 0.4rem, 1.75rem);
  line-height: 1.1;
  filter: drop-shadow(0 0 12px rgba(25, 193, 85, 0.4));
}
body.ws-page .gg-links a,
body.ws-page .ws-words-btn,
body.ws-page .ws-boards-btn,
body.ws-page .ws-words-close,
body.ws-page .ws-boards-close {
  font-weight: 600;
  color: var(--fx-text, #e6fff0);
  text-decoration: none;
  padding: 4px 12px;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--fx-edge, rgba(61, 255, 138, 0.24));
  border-radius: 999px;
  background: rgba(25, 193, 85, 0.08);
  cursor: pointer;
  font: inherit;
  font-weight: 600;
}
body.ws-page .gg-links a:hover,
body.ws-page .gg-links a:focus-visible,
body.ws-page .ws-words-btn:hover,
body.ws-page .ws-boards-btn:hover,
body.ws-page .ws-words-close:hover,
body.ws-page .ws-boards-close:hover {
  background: rgba(25, 193, 85, 0.16);
  border-color: var(--fx-neon, #3dff8a);
  outline: none;
}
body.ws-page .ws-words-btn,
body.ws-page .ws-boards-btn,
body.ws-page .ws-words-close,
body.ws-page .ws-boards-close { display: none; }
body.ws-page .ws-words-close,
body.ws-page .ws-boards-close { font-size: 0.9rem; }
.ws-words-mask, .ws-boards-mask { display: none; }
.ws-check {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
  border: 0; padding: 0; margin: -1px;
}

body.ws-page .setup { flex-shrink: 0; margin: 0; padding: 8px 12px; }
body.ws-page .setup .row { flex-wrap: nowrap; gap: 8px 10px; align-items: flex-end; }
body.ws-page .setup .row > * { flex: 1 1 0; min-width: 0; }
body.ws-page .setup .row > .btn { flex: 0 0 auto; }
body.ws-page .setup .field { margin-bottom: 0; color: var(--fx-neon, #3dff8a); font-size: 0.72rem; letter-spacing: 0.1em; }
body.ws-page input[type=text],
body.ws-page select {
  margin-top: 3px; padding: 6px 10px; color: var(--fx-text, #e6fff0);
  background: rgba(3, 15, 9, 0.72); border: 1px solid rgba(61, 255, 138, 0.3); border-radius: 12px;
}
body.ws-page input::placeholder { color: #7fae96; }
body.ws-page input:focus,
body.ws-page select:focus { outline: 2px solid var(--fx-neon, #3dff8a); outline-offset: 1px; border-color: var(--fx-neon, #3dff8a); }
body.ws-page .btn {
  font: inherit; font-weight: 600; cursor: pointer; border: 0; padding: 8px 16px; border-radius: 999px;
  background: linear-gradient(180deg, #3dff8a, #19c155); color: #03140b; box-shadow: 0 0 18px rgba(25, 193, 85, 0.45);
}
body.ws-page .btn:active { transform: translateY(1px); box-shadow: 0 0 10px rgba(25, 193, 85, 0.35); }
body.ws-page .btn:disabled { opacity: .5; cursor: default; }

.ws-layout {
  flex: 1 1 auto; min-height: 0; display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 280px);
  gap: 10px; align-items: stretch;
}
.ws-play { display: flex; flex-direction: column; min-height: 0; overflow: hidden; padding: 8px 12px 10px; }
.ws-side { min-height: 0; overflow: hidden; display: flex; flex-direction: column; gap: 10px; }
.ws-words-dock, .ws-scores-dock { min-height: 0; display: flex; flex-direction: column; }
.ws-words-dock { flex: 1 1 45%; }
.ws-scores-dock { flex: 1 1 55%; }
.ws-side .panel {
  flex: 1 1 auto; min-height: 0; overflow: auto; padding: 12px 14px;
  overscroll-behavior: contain; display: flex; flex-direction: column;
}
.ws-side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
body.ws-page .ws-side h3 { color: #fff; text-shadow: 0 0 14px rgba(25, 193, 85, 0.35); margin: 0 0 8px; font-size: 1.15rem; }
.ws-board-table { font-size: 0.9rem; overflow: auto; min-height: 0; flex: 0 1 auto; }
body.ws-page .ws-rules { font-size: 0.8rem; line-height: 1.35; margin: 10px 0 0; color: var(--fx-dim, #a6d8bb); }
body.ws-page .tab { background: rgba(3, 15, 9, 0.55); color: var(--fx-dim, #a6d8bb); border-color: var(--fx-edge, rgba(61, 255, 138, 0.24)); padding: 4px 10px; }
body.ws-page .tab.on { background: rgba(25, 193, 85, 0.16); color: #7dffb0; border-color: var(--fx-neon, #3dff8a); }
body.ws-page .muted { color: var(--fx-dim, #a6d8bb); }
body.ws-page .msg { color: #7dffb0; margin: 6px 0 0; min-height: 1.15em; font-size: 0.95rem; text-align: center; flex-shrink: 0; }
body.ws-page .msg.bad { color: #ffb4ab; }

.hud { display: flex; justify-content: space-around; text-align: center; margin-bottom: 6px; flex-shrink: 0; padding: 0; }
.hud .k { display: block; font-size: 0.68rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--fx-neon, #3dff8a); font-weight: 600; }
.hud .v { font-family: Chango, Georgia, serif; font-size: clamp(1.05rem, 2.2vh, 1.5rem); font-variant-numeric: tabular-nums; color: #fff; }
.hud .v.low { color: #ff8a80; }

.ws-grid-wrap {
  flex: 1 1 auto; min-height: 0; width: 100%;
  display: grid; place-items: center; container-type: size;
}
.grid {
  display: grid; gap: 2px;
  width: 100%;
  max-width: 560px;
  max-height: 100%;
  aspect-ratio: 1;
  height: auto;
  margin: 0; touch-action: none; user-select: none; -webkit-user-select: none;
}
@supports not (container-type: size) {
  .grid { width: min(100%, 70vw, calc(100dvh - 16rem)); height: auto; }
}
.cell {
  aspect-ratio: auto; min-width: 0; min-height: 0;
  display: grid; place-items: center;
  font-weight: 600;
  font-size: clamp(0.65rem, 4.6cqi, 1.35rem);
  background: rgba(3, 15, 9, 0.72);
  color: var(--fx-text, #e6fff0);
  border-radius: 6px;
  cursor: pointer;
  transition: background .08s, color .08s;
}
.cell.sel { background: var(--fx-neon, #3dff8a); color: #03140b; }
.cell.hit { background: rgba(25, 193, 85, 0.28); color: #7dffb0; }
.cell.hit.sel { background: var(--fx-neon, #3dff8a); color: #03140b; }
.grid.over .cell { cursor: default; }
.words { list-style: none; margin: 0 0 8px; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; overflow: auto; min-height: 0; }
.words li { font-weight: 600; letter-spacing: 0.06em; color: var(--fx-text, #e6fff0); }
.words li.done { text-decoration: line-through; color: var(--fx-neon, #3dff8a); opacity: .7; }
.words li.missed { color: #ffb4ab; }

@media (min-width: 800px) { body.ws-page .ggc-fab { right: 20px; } }
@media (max-width: 799px), (orientation: portrait) and (max-width: 899px) {
  .ws-layout { grid-template-columns: 1fr; }
  body.ws-page .ws-words-btn, body.ws-page .ws-boards-btn { display: inline-flex; }
  body.ws-page .ws-side { display: contents; }
  body.ws-page .ws-words-dock,
  body.ws-page .ws-scores-dock {
    display: none; position: fixed;
    inset: max(10px, env(safe-area-inset-top)) 12px max(10px, env(safe-area-inset-bottom));
    z-index: 90; max-width: 420px; margin: 0 auto; overflow: hidden;
  }
  body.ws-page .ws-words-dock > .panel,
  body.ws-page .ws-scores-dock > .panel {
    background: linear-gradient(160deg, rgba(10, 46, 28, 0.98), rgba(3, 15, 9, 0.98) 55%);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.7), 0 0 30px rgba(25, 193, 85, 0.25);
  }
  #ws-show-words:checked ~ .ws-words-mask,
  #ws-show-boards:checked ~ .ws-boards-mask {
    display: block; position: fixed; inset: 0; z-index: 85; background: rgba(0, 0, 0, 0.62); cursor: pointer;
  }
  body.ws-page .ws-words-close, body.ws-page .ws-boards-close { display: inline-flex; }
  #ws-show-words:checked ~ .ws-layout .ws-words-dock,
  #ws-show-boards:checked ~ .ws-layout .ws-scores-dock { display: flex; }
  #ws-show-words:checked ~ .ws-top .ws-words-btn,
  #ws-show-boards:checked ~ .ws-top .ws-boards-btn { border-color: var(--fx-neon, #3dff8a); background: rgba(25, 193, 85, 0.2); }
}
@media (max-width: 640px) {
  .back-full { display: none; }
  body.ws-page .setup .row { flex-wrap: wrap; }
  body.ws-page .setup .row > * { flex: 1 1 calc(50% - 10px); }
  body.ws-page .setup .row > .btn { flex: 1 1 100%; }
  body.ws-page .ws-top { flex-wrap: wrap; gap: 4px 8px; }
  body.ws-page .ws-top .gg-head { display: contents; }
  body.ws-page .ws-top h1 { font-size: 1.12rem; flex: 1 1 auto; min-width: 0; }
  body.ws-page .ws-top .gg-links { width: 100%; justify-content: center; flex-wrap: nowrap; gap: 6px; }
  body.ws-page .gg-links a, body.ws-page .ws-words-btn, body.ws-page .ws-boards-btn { min-height: 30px; padding: 3px 10px; font-size: 0.88rem; }
  body.ws-page .game-wrap { width: calc(100% - 12px); gap: 6px; }
  body.ws-page .msg { padding-right: 7.5rem; }
}
@media (max-height: 520px) {
  body.ws-page .game-wrap { padding-top: 4px; padding-bottom: 4px; gap: 4px; }
  body.ws-page .setup { padding: 4px 10px; }
  body.ws-page .setup .field { font-size: 0; letter-spacing: 0; }
  body.ws-page .setup input, body.ws-page .setup select { padding: 4px 8px; font-size: 0.88rem; letter-spacing: 0; text-transform: none; }
  .hud { margin-bottom: 2px; }
  .hud .v { font-size: 1rem; }
  .ws-rules { display: none; }
  body.ws-page .ws-top h1 { font-size: 1.05rem; }
  body.ws-page .ws-play { padding: 4px 8px 6px; }
  body.ws-page .btn { padding: 6px 12px; }
}
@media (orientation: landscape) and (max-height: 500px) {
  body.ws-page .setup .row { flex-wrap: nowrap; }
  body.ws-page .setup .row > * { flex: 1 1 0; }
  body.ws-page .setup .row > .btn { flex: 0 0 auto; }
  .ws-layout { grid-template-columns: minmax(0, 1fr) minmax(180px, 230px); }
  body.ws-page .ws-side { display: flex; }
  body.ws-page .ws-words-dock,
  body.ws-page .ws-scores-dock { display: flex; position: static; inset: auto; max-width: none; margin: 0; }
  body.ws-page .ws-words-btn, body.ws-page .ws-boards-btn,
  body.ws-page .ws-words-close, body.ws-page .ws-boards-close { display: none; }
}
@media (prefers-reduced-motion: reduce) { body.ws-page .btn:active { transform: none; } }