/* Word Search — scoped to .g-ws */
.g-ws .ws-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; margin: 0; }
.g-ws .game-bar .group:first-child { gap: 8px; }
.g-ws .ws-seg { flex-wrap: wrap; border-radius: 24px; }
.g-ws .ws-seg button { min-height: 44px; }
.g-ws .ws-tip { text-align: center; color: var(--ink-soft); font-weight: 700; font-size: .98rem; margin: -4px 0 14px; }
.g-ws .ws-print-title { display: none; }

.g-ws .ws-layout { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.g-ws .ws-sheet.is-wide .ws-layout { flex-direction: row; align-items: flex-start; justify-content: center; gap: 28px; }

/* ---- grid ---- */
.g-ws .ws-gridbox {
  position: relative; max-width: 100%; flex-shrink: 0;
  background: #fff; border-radius: 18px; box-shadow: 0 0 0 3px var(--line), 0 8px 0 var(--berry-soft);
  padding: 0;
}
.g-ws .ws-grid {
  --cell: 36px; position: relative; z-index: 1; display: grid; grid-template-rows: repeat(var(--n), var(--cell));
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; cursor: pointer;
}
.g-ws .ws-row { display: grid; grid-template-columns: repeat(var(--n), var(--cell)); }
.g-ws .ws-cell {
  width: var(--cell); height: var(--cell); padding: 0; border: 0; background: transparent; border-radius: 50%;
  font-family: var(--head); font-weight: 600; font-size: calc(var(--cell) * .6); line-height: 1; color: var(--ink);
  display: grid; place-items: center; cursor: pointer; -webkit-tap-highlight-color: transparent; transition: color .2s, transform .2s;
}
.g-ws .ws-cell:focus-visible { outline: 3px solid var(--gold); outline-offset: -2px; border-radius: 10px; }
.g-ws .ws-cell.is-found { color: #2b1015; }
.g-ws .ws-cell.is-first { color: #fff; transform: scale(1.12); }
.g-ws .ws-marks { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; overflow: visible; }
.g-ws .ws-marks line { stroke-width: .78; stroke-linecap: round; fill: none; }
.g-ws .ws-marks .ws-found { opacity: .72; animation: wsDraw .45s cubic-bezier(.2, 1.4, .4, 1); }
.g-ws .ws-marks .ws-live { opacity: .9; stroke-width: .84; }
.g-ws .ws-marks .ws-live.is-miss { opacity: 0; transition: opacity .35s; }
@keyframes wsDraw { from { opacity: 0; stroke-width: .3; } }

/* ---- word list ---- */
.g-ws .ws-listbox { width: 100%; max-width: 560px; }
.g-ws .ws-sheet.is-wide .ws-listbox { width: 240px; flex-shrink: 0; }
.g-ws .ws-list-title { font-size: 1.25rem; margin: 0 0 10px; text-align: center; color: var(--berry); }
.g-ws .ws-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.g-ws .ws-sheet.is-wide .ws-list { flex-direction: column; flex-wrap: nowrap; }
.g-ws .ws-word {
  position: relative; display: flex; align-items: center; gap: 8px; padding: 5px 14px 5px 6px; min-height: 46px;
  background: var(--cream); border-radius: 999px; box-shadow: inset 0 0 0 2px var(--line);
  font-family: var(--head); font-weight: 600; font-size: 1.1rem; letter-spacing: 1.5px; transition: background .3s, box-shadow .3s;
}
.g-ws .ws-pic { width: 36px; height: 36px; flex-shrink: 0; border-radius: 50%; background: #fff; display: grid; place-items: center; overflow: hidden; box-shadow: 0 2px 0 var(--line); }
.g-ws .ws-pic-img { width: auto; height: 32px; object-fit: contain; }
.g-ws .ws-pic-emoji { font-size: 1.3rem; line-height: 1; }
.g-ws .ws-wtext { position: relative; }
.g-ws .ws-check { display: none; margin-left: auto; width: 24px; height: 24px; border-radius: 50%; background: #fff; color: var(--mint-dark); font-size: .95rem; place-items: center; }
.g-ws .ws-word.is-found { background: var(--c); box-shadow: none; color: #2b1015; animation: wsFound .55s cubic-bezier(.2, 1.5, .4, 1); }
.g-ws .ws-word.is-found .ws-wtext::after { content: ""; position: absolute; left: -3px; right: -3px; top: 52%; height: 3px; border-radius: 3px; background: currentColor; opacity: .75; }
.g-ws .ws-word.is-found .ws-check { display: grid; }
.g-ws .ws-word.is-found .ws-pic { animation: wsSpin .6s ease; }
@keyframes wsFound { 40% { transform: scale(1.12) rotate(-2deg); } }
@keyframes wsSpin { 50% { transform: scale(1.25) rotate(12deg); } }
.g-ws .ws-sheet.is-fresh .ws-gridbox { animation: wsIn .4s ease both; }
@keyframes wsIn { from { opacity: 0; transform: scale(.96); } }

@media (max-width: 620px) {
  .g-ws .game-bar { justify-content: center; }
  .g-ws .game-bar .group { justify-content: center; }
  .g-ws .ws-seg button { padding: 8px 11px; font-size: .92rem; }
  .g-ws .ws-seg:first-child { display: grid; grid-template-columns: 1fr 1fr; width: 100%; max-width: 360px; }
  .g-ws .ws-word { font-size: 1rem; padding-right: 12px; min-height: 44px; }
  .g-ws .ws-pic { width: 32px; height: 32px; }
  .g-ws .ws-pic-img { height: 28px; }
  .g-ws .ws-tip { font-size: .9rem; }
}

/* ---- print just the puzzle and the word list ---- */
@media print {
  @page { margin: 14mm; }
  body * { visibility: hidden !important; }
  .g-ws .ws-sheet, .g-ws .ws-sheet * { visibility: visible !important; }
  .g-ws.game-root { position: static !important; box-shadow: none !important; }
  main > :not(.g-ws):not(:has(.g-ws)) { display: none !important; }
  .g-ws > :not(.ws-sheet) { display: none !important; }
  .g-ws .ws-sheet { position: absolute; left: 0; top: 0; width: 100%; animation: none !important; }
  .g-ws .ws-print-title { display: block; text-align: center; margin-bottom: 8mm; font-family: var(--head); }
  .g-ws .ws-print-title strong { display: block; font-size: 26pt; color: #000; }
  .g-ws .ws-print-title span { font-size: 10pt; color: #555; }
  .g-ws .ws-layout { flex-direction: column !important; align-items: center !important; gap: 8mm !important; }
  .g-ws .ws-gridbox { width: auto !important; box-shadow: none; border: 2pt solid #000; border-radius: 4mm; padding: 2mm; animation: none !important; }
  .g-ws .ws-sheet .ws-grid { grid-template-rows: repeat(var(--n), calc(150mm / var(--n))); }
  .g-ws .ws-sheet .ws-row { grid-template-columns: repeat(var(--n), calc(150mm / var(--n))); }
  .g-ws .ws-sheet .ws-cell { width: calc(150mm / var(--n)); height: calc(150mm / var(--n)); font-size: calc(90mm / var(--n)); color: #000 !important; transform: none !important; }
  .g-ws .ws-marks { display: none !important; }
  .g-ws .ws-listbox { width: 100% !important; max-width: none; }
  .g-ws .ws-list { flex-direction: row !important; flex-wrap: wrap !important; justify-content: center; }
  .g-ws .ws-word, .g-ws .ws-word.is-found { background: #fff !important; box-shadow: inset 0 0 0 1pt #999 !important; color: #000 !important; animation: none !important; }
  .g-ws .ws-word .ws-wtext::after, .g-ws .ws-check { display: none !important; }
  .g-ws .ws-word::before { content: ""; width: 4mm; height: 4mm; border: 1pt solid #000; border-radius: 1mm; margin-left: 2mm; }
}
