/* Word search, in the side panel and in its own tab: big bold letters on a card, the words below
   (or beside it in a wide tab), soft color bands over the found ones. Uses the colors of the page
   it sits in (popup.css, page.css). */
.ws { --ws-card: #161616; --ws-shadow: 0 10px 30px rgba(0,0,0,.45); position: relative; display: flex; flex-direction: column; gap: 10px; }
@media (prefers-color-scheme: light) { :root[data-theme="auto"] .ws { --ws-card: #fff; --ws-shadow: 0 8px 26px rgba(0,0,0,.09); } }
:root[data-theme="light"] .ws { --ws-card: #fff; --ws-shadow: 0 8px 26px rgba(0,0,0,.09); }
:where(.ws) svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:where(.ws) button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
:where(.ws) button:focus-visible { outline: 1.5px solid var(--stroke); outline-offset: 2px; }

/* The strip: language | level and time | hint, stats, sound | Stop, New game */
.ws-bar { position: relative; display: flex; align-items: center; gap: 1px; height: 44px; padding: 0 5px; border-radius: 22px; background: var(--row);
  border: 1px solid var(--divider); }
.ws-bar [hidden] { display: none !important; }
.ws-sep { flex: none; width: 1px; height: 18px; margin: 0 4px; background: var(--divider); }
.ws-grow { flex: 1; }
.ws-lang { flex: none; height: 32px; padding: 0 10px 0 8px; display: inline-flex; align-items: center; gap: 7px; border-radius: 16px; font-weight: 600; }
.ws-lang span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-lang:hover { background: var(--hover); }
.ws-lang svg { width: 16px; height: 16px; color: var(--text2); }
.ws-clock { flex: none; display: flex; align-items: center; gap: 8px; padding-inline-start: 4px; white-space: nowrap; }
.ws-timer { min-width: 40px; font-variant-numeric: tabular-nums; font-weight: 600; font-size: 14px; color: var(--text2); }
.ws-timer.ws-done { color: var(--green); }
.ws-timer.ws-paused { opacity: .45; }
.ws-ib { flex: none; width: 32px; height: 32px; display: grid; place-items: center; border-radius: 9px; color: var(--text2); }
.ws-ib:hover { background: var(--hover); color: var(--text); }

.ws-level { color: var(--text2); font-weight: 600; font-size: 12.5px; }
.ws-stop, .ws-new { flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; transition: transform .15s, filter .2s; }
.ws-stop:hover, .ws-new:hover { filter: brightness(1.06); }
.ws-stop:active, .ws-new:active { transform: scale(.94); }
.ws-stop svg, .ws-new svg { width: 15px; height: 15px; stroke-width: 2.2; }
.ws-stop { background: #f6b4b4; color: #7a1f1f; }
.ws-stop svg { fill: currentColor; stroke: none; }
.ws-new { margin-inline-start: 4px; background: var(--text); color: var(--bg); }
/* Narrower: the language's code, then no level, closer buttons, no clock, a shortened name */
.ws-code { display: none; }
.ws-f1 .ws-code { display: inline; }
.ws-f1 .ws-code + .ws-name, .ws-f2 .ws-level, .ws-f4 .ws-clock, .ws-f4 .ws-lang + .ws-sep { display: none; }
.ws-f3 .ws-ib { width: 28px; }
.ws-f3 .ws-sep { margin: 0 2px; }
.ws-preview.ws-first .ws-f4 :is(.ws-stop, .ws-new, .ws-ib + .ws-sep) { display: none; } /* only the language counts the first time */
.ws-f5 .ws-lang { flex: 0 1 auto; min-width: 0; }

.ws-play { position: relative; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.ws-card { position: relative; padding: 10px; border-radius: 16px; background: var(--ws-card); box-shadow: var(--ws-shadow); }
.ws-grid { position: relative; touch-action: none; user-select: none; -webkit-user-select: none; }
.ws-marks { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; stroke-linecap: round; }
.ws-marks line { stroke-width: .8; }
.ws-marks line.ws-sel { stroke: color-mix(in srgb, var(--text) 14%, transparent); }
.ws-marks line.ws-miss { stroke: color-mix(in srgb, var(--red) 28%, transparent); opacity: 0; transition: opacity .35s .05s; }
.ws-marks line.ws-found { stroke: hsl(var(--h) 42% 32%); }
@media (prefers-color-scheme: light) { :root[data-theme="auto"] .ws-marks line.ws-found { stroke: hsl(var(--h) 85% 82%); } }
:root[data-theme="light"] .ws-marks line.ws-found { stroke: hsl(var(--h) 85% 82%); }
.ws-marks line.ws-pop { animation: ws-band .5s cubic-bezier(.3,1.5,.5,1); }
.ws-marks .ws-anchor { fill: color-mix(in srgb, var(--text) 14%, transparent); stroke: none; }
.ws-marks .ws-flash { fill: none; stroke: var(--yellow); stroke-width: .07; animation: ws-flash 1.8s ease-out forwards; transform-box: fill-box; transform-origin: center; }
@keyframes ws-band { from { stroke-width: .5; } 60% { stroke-width: .9; } to { stroke-width: .8; } }
@keyframes ws-flash { 0% { opacity: 0; transform: scale(1.8); } 18% { opacity: 1; transform: scale(1); } 75% { opacity: 1; } 100% { opacity: 0; } }

.ws-letters { position: absolute; inset: 0; display: grid; }
.ws-letters span { display: grid; place-items: center; font-weight: 700; font-size: calc(var(--cell) * .52); line-height: 1; color: var(--text); transition: transform .18s; }
.ws-letters span.ws-on { transform: scale(1.14); }
.ws-letters.ws-enter span { animation: ws-in .45s cubic-bezier(.2,.8,.3,1.2) backwards; animation-delay: calc(var(--d) * 20ms); }
.ws-letters.ws-wave span { animation: ws-wave .7s ease-in-out; animation-delay: calc(var(--d) * 28ms); }
@keyframes ws-in { from { opacity: 0; transform: scale(.4); } }
@keyframes ws-wave { 40% { transform: translateY(calc(var(--cell) * -.22)) scale(1.12); } }

.ws-words { display: flex; flex-wrap: wrap; justify-content: center; align-content: flex-start; gap: 6px 16px; max-width: 520px; min-height: 46px; padding: 0 4px; }
.ws-word { font-weight: 700; font-size: 16px; line-height: 1.25; letter-spacing: .02em; color: var(--text); transition: opacity .5s, color .3s; }
.ws-word.ws-got { opacity: .28; }
.ws-word.ws-hinted { color: var(--yellow); }
.ws-blank { display: inline-flex; align-items: center; gap: 7px; }
.ws-blank i { width: calc(var(--n) * .55em); height: 3px; margin-top: .55em; border-radius: 2px; opacity: .55;
  background: repeating-linear-gradient(90deg, currentColor 0 .4em, transparent .4em .55em); }
.ws-blank b { display: grid; place-items: center; min-width: 1.7em; height: 1.7em; padding: 0 .45em; border-radius: .85em; background: var(--field);
  color: var(--text2); font-size: .62em; font-variant-numeric: tabular-nums; }
.ws-blank.ws-hinted b { color: var(--yellow); }
.ws-credit { margin: 0; display: flex; align-items: center; gap: 6px; font-size: 10.5px; color: var(--text3); }
.ws-credit a { color: var(--text2); }
.ws .ws-credit svg.ws-gh { width: 13px; height: 13px; fill: currentColor; stroke: none; }
.ws:not(.ws-panel) .ws-credit { width: 100%; max-width: max(320px, var(--ws-span, 520px)); align-self: center; }

/* Its own tab: at the top, the same 500px card on every level, the list below it. */
.ws:not(.ws-panel) { height: 100%; }
.ws:not(.ws-panel) .ws-bar { width: 100%; max-width: max(320px, var(--ws-span, 520px)); align-self: center; }
.ws:not(.ws-panel) .ws-play { justify-content: center; }
.ws:not(.ws-panel) .ws-word { font-size: 19px; }
.ws:not(.ws-panel) .ws-words { width: min(var(--ws-span, 500px), 100%); max-width: none; min-height: 124px; gap: 8px 18px; }

/* Waiting for Start: the puzzle dimmed under the button */
.ws-start { position: absolute; top: 0; left: 0; right: 0; z-index: 2; display: grid; place-items: center; }
.ws-start .ws-btn { height: 50px; padding: 0 28px; border-radius: 25px; font-size: 16px; color: var(--text); background: color-mix(in srgb, var(--text) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--text) 24%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.ws-start[hidden] { display: none; }
.ws-waiting .ws-grid, .ws-waiting .ws-words { opacity: .1; filter: blur(2.5px); }
.ws-start svg { fill: currentColor; stroke: none; }

/* The language list, dropping from its button over the game */
.ws-menu { position: absolute; top: calc(100% + 6px); left: 0; z-index: 6; width: min(100%, 270px); max-height: 320px; display: flex; flex-direction: column;
  padding: 6px; border-radius: 14px; background: var(--ws-card); border: 1px solid var(--divider); box-shadow: 0 16px 44px rgba(0,0,0,.35);
  transform-origin: top left; animation: ws-drop .22s cubic-bezier(.2,.9,.3,1.15); }
.ws:not(.ws-panel) .ws-menu { width: 300px; max-height: min(460px, 70vh); }
@keyframes ws-drop { from { opacity: 0; transform: translateY(-6px) scale(.97); } }
.ws-search { flex: none; height: 34px; margin-bottom: 4px; padding: 0 10px; border: 0; border-radius: 9px; background: var(--field); color: var(--text);
  font: inherit; outline: none; }
.ws .ws-search:focus-visible { outline: none; box-shadow: inset 0 0 0 1.5px var(--stroke); }
.ws-search::placeholder { color: var(--text3); }
.ws-search::-webkit-search-cancel-button { display: none; }
.ws-options { position: relative; flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; }
.ws-options button { flex: none; display: flex; align-items: baseline; gap: 8px; padding: 7px 10px; border-radius: 8px; text-align: start; }
.ws-options button[hidden] { display: none; }
.ws-options button:hover, .ws-options button:focus-visible { background: var(--hover); outline: none; }
.ws-options span { font-weight: 600; }
.ws-options small { margin-inline-start: auto; color: var(--text3); font-size: 11px; white-space: nowrap; }
.ws-options button.ws-cur { box-shadow: inset 0 0 0 1.5px var(--green); }
.ws-none { margin: 0; padding: 10px; color: var(--text3); text-align: center; }

/* Before a language is picked: everything but the language button, dimmed and out of reach */
/* Without a puzzle: everything dimmed but the language button (and Start, after the first time) */
.ws-preview .ws-clock, .ws-preview .ws-stop, .ws-preview .ws-new, .ws-preview .ws-sep, .ws-preview .ws-card, .ws-preview .ws-words, .ws-preview .ws-credit, .ws-preview .ws-timer, .ws-preview .ws-ib { opacity: .1; user-select: none; -webkit-user-select: none; }
.ws-preview .ws-ib.ws-roombtn { opacity: 1; user-select: auto; -webkit-user-select: auto; } /* Play with others works without a puzzle */
.ws-first .ws-lang { color: var(--text); box-shadow: inset 0 0 0 1.5px var(--green); animation: ws-call 2.4s ease-in-out infinite; }
.ws-first .ws-lang svg { color: var(--green); }
@keyframes ws-call { 50% { box-shadow: inset 0 0 0 1.5px var(--green), 0 0 0 5px color-mix(in srgb, var(--green) 18%, transparent); } }

/* Cards over the game: stats, solved, messages */
.ws-overlay { position: absolute; inset: -6px; z-index: 5; display: grid; place-items: center; padding: 10px; border-radius: 16px;
  background: color-mix(in srgb, var(--bg) 60%, transparent); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); animation: ws-fade .25s; }
.ws:not(.ws-panel) .ws-overlay { position: fixed; inset: 0; border-radius: 0; }
@keyframes ws-fade { from { opacity: 0; } }
.ws-box { position: relative; width: min(100%, 380px); max-height: 100%; overflow-y: auto; background: var(--ws-card); border: 1px solid var(--divider); border-radius: 18px;
  padding: 22px 18px 18px; display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.35);
  animation: ws-rise .28s cubic-bezier(.2,.8,.2,1); }
.ws-panel .ws-box { max-height: 520px; }
/* A plain rise that ends exactly in place: no overshoot or scale, so the text doesn't settle after it shows. */
@keyframes ws-rise { from { transform: translateY(8px); opacity: 0; } }
.ws-box h2 { margin: 0; font-size: 16px; font-weight: 700; }
.ws-box p { margin: 0; color: var(--text2); }
.ws-x { position: absolute; top: 8px; right: 8px; }
.ws-levels { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.ws-levels button { display: flex; align-items: center; gap: 10px; height: 48px; padding: 0 16px; border-radius: 12px; background: var(--field); text-align: start;
  transition: background-color .2s, transform .15s; }
.ws-levels button:hover { background: var(--hover); }
.ws-levels button:active { transform: scale(.98); }
.ws-levels span { font-weight: 700; font-size: 15px; }
.ws-levels small { margin-inline-start: auto; color: var(--text3); font-size: 11.5px; }
.ws-levels svg { width: 15px; height: 15px; color: var(--text3); }
.ws-big { font-size: 38px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.ws-box .ws-best { color: var(--yellow); font-weight: 600; }
.ws-btn { height: 40px; padding: 0 20px; border-radius: 20px; background: var(--text); color: var(--bg); font-weight: 700;
  display: inline-flex; align-items: center; gap: 8px; transition: transform .15s; }
.ws-btn:hover { transform: scale(1.03); }
.ws-btn svg { stroke-width: 2.2; }
.ws-link { color: var(--text2); text-decoration: underline; text-underline-offset: 2px; }
.ws-stats { border-collapse: collapse; font-variant-numeric: tabular-nums; }
.ws-stats th, .ws-stats td { padding: 6px 10px; text-align: right; }
.ws-stats th { color: var(--text3); font-weight: 600; font-size: 10.5px; letter-spacing: .05em; text-transform: uppercase; }
.ws-stats td:first-child, .ws-stats th:first-child { text-align: left; }
.ws-stats tr + tr td { border-top: 1px solid var(--divider); }

@media (prefers-reduced-motion: reduce) {
  .ws-letters.ws-enter span, .ws-letters.ws-wave span, .ws-marks line.ws-pop, .ws-overlay, .ws-box, .ws-menu, .ws-first .ws-lang { animation: none; }
}
