/* WordSearch in animesh.net's Index look (D12): wide Archivo caps, flat, no sticker shapes.
   Ground / text / name per palette (+ Ultra) are the home page's own (assets/theme/index-look.css).
   ok / bad are CurioWords' hand-picked, contrast-gated roles for the same 12 combinations
   (games/curiowords/js/core/site_theme.js); -fg is whichever text colour reads best on them.
   Checked by tools/w3/test.mjs over all 12 combinations. */
html                         { --ground:#e4ff3a; --fg:#111111; --name:#111111; --u-ground:#111111; --u-fg:#e4ff3a; --u-name:#e4ff3a; }
html[data-palette="violet"]  { --ground:#f2f2f2; --fg:#000000; --name:#000000; --u-ground:#4801ff; --u-fg:#ffffff; --u-name:#ffffff; }
html[data-palette="signal"]  { --ground:#f2f2f2; --fg:#111111; --name:#e04300; --u-ground:#ff4d00; --u-fg:#111111; --u-name:#111111; }
html[data-palette="mint"]    { --ground:#bff0d8; --fg:#13172e; --name:#13172e; --u-ground:#d6246e; --u-fg:#ffffff; --u-name:#ffffff; }
html[data-palette="cobalt"]  { --ground:#ffffff; --fg:#0b1a66; --name:#1f3fff; --u-ground:#1f3fff; --u-fg:#ffffff; --u-name:#ffffff; }
html[data-palette="night"]   { --ground:#121214; --fg:#ededed; --name:#d4ff3a; --u-ground:#ff3d7f; --u-fg:#121214; --u-name:#121214; }
/* WordSearch's canonical theme (D67), from the 2024 artwork (settings.py): ground BG_COLOUR (184,201,230),
   name END_TEXT_COLOUR (70,88,120), selection SELECTED_COLOUR (247,110,72), found FOUND_COLOUR (109,171,65),
   flying text BG_SCROLLING_TEXT_COLOUR (150,184,242) at its own alpha 100/255. Text is the end-text navy
   darkened to pass 4.5:1. "Ultra" = its dark side: a navy ground from the same hue. */
html[data-palette="wordsearch"] { --ground:#b8c9e6; --fg:#1f2a3d; --name:#465878; --u-ground:#1b2333; --u-fg:#dfe7f5; --u-name:#96b8f2; }
html                   { --g:var(--ground);   --f:var(--fg);   --n:var(--name);   --dot:var(--u-ground); }
html[data-ultra="on"]  { --g:var(--u-ground); --f:var(--u-fg); --n:var(--u-name); --dot:var(--ground); }
/* selection and flying text: inverted text and the name colour, faint, unless a theme says otherwise */
html { --sel:var(--f); --sel-fg:var(--g); --fly:var(--n); --fly-alpha:0.14; }

/* game roles: found (ok) and wrong (bad), with their text colour */
html                                       { --ok:#0b6b3a; --ok-fg:#ffffff; --bad:#c2122b; --bad-fg:#ffffff; }
html[data-ultra="on"]                      { --ok:#3dd6a0; --ok-fg:#111111; --bad:#ff6b6b; --bad-fg:#111111; }
html[data-palette="violet"]                { --ok:#0f766e; --ok-fg:#ffffff; --bad:#c81e1e; --bad-fg:#ffffff; }
html[data-palette="violet"][data-ultra="on"] { --ok:#7cf0c0; --ok-fg:#111111; --bad:#ff9ab0; --bad-fg:#111111; }
html[data-palette="signal"]                { --ok:#0f766e; --ok-fg:#ffffff; --bad:#a8123e; --bad-fg:#ffffff; }
html[data-palette="signal"][data-ultra="on"] { --ok:#0b5c54; --ok-fg:#ffffff; --bad:#7a0a1c; --bad-fg:#ffffff; }
html[data-palette="mint"]                  { --ok:#0f766e; --ok-fg:#ffffff; --bad:#b42318; --bad-fg:#ffffff; }
html[data-palette="mint"][data-ultra="on"] { --ok:#bff0d8; --ok-fg:#111111; --bad:#2a0614; --bad-fg:#ffffff; }
html[data-palette="cobalt"]                { --ok:#0f766e; --ok-fg:#ffffff; --bad:#b3123a; --bad-fg:#ffffff; }
html[data-palette="cobalt"][data-ultra="on"] { --ok:#7cf0c0; --ok-fg:#111111; --bad:#ffb3c4; --bad-fg:#111111; }
html[data-palette="night"]                 { --ok:#3dd6c8; --ok-fg:#111111; --bad:#ff6b7a; --bad-fg:#111111; }
html[data-palette="night"][data-ultra="on"] { --ok:#0b5c54; --ok-fg:#ffffff; --bad:#7a0a1c; --bad-fg:#ffffff; }
html[data-palette="wordsearch"]            { --ok:#6dab41; --ok-fg:#111111; --bad:#b3261e; --bad-fg:#ffffff; --sel:#f76e48; --sel-fg:#111111; --fly:#96b8f2; --fly-alpha:0.39; }
html[data-palette="wordsearch"][data-ultra="on"] { --ok:#6dab41; --ok-fg:#111111; --bad:#ff6b6b; --bad-fg:#111111; --sel:#f76e48; --sel-fg:#111111; --fly:#96b8f2; --fly-alpha:0.14; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; overflow-x: hidden; }
body {
	background: var(--g); color: var(--f);
	font-family: 'Instrument Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
	font-size: 15px; line-height: 1.5;
	transition: background-color .5s, color .5s;
	-webkit-font-smoothing: antialiased;
}
.wide { font-family: 'Archivo', 'Arial Black', sans-serif; font-stretch: 125%; font-variation-settings: 'wdth' 125; text-transform: uppercase; }
button { font: inherit; color: inherit; }
svg.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: square; stroke-linejoin: miter; }

/* flying text: a fixed canvas behind everything (D47) */
#fly { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
.page { position: relative; z-index: 1; max-width: 1040px; margin: 0 auto; padding: 12px 16px 32px; }

/* ---- top bar (as the home page's .top) ---- */
.top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.logo { margin: 0; font-weight: 700; font-size: clamp(22px, 6.4vw, 40px); line-height: .9; letter-spacing: -.01em; min-height: 44px; display: inline-flex; align-items: center; color: var(--n); }
.controls { position: relative; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pill {
	font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
	min-height: 44px; min-width: 44px; padding: 0 14px; border-radius: 999px; border: 1.5px solid var(--f);
	background: var(--g); color: var(--f); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.pill.icon-only { padding: 0; width: 44px; }
.pill:hover, .pill[aria-expanded="true"], .pill[aria-pressed="true"], .pill[aria-current="true"] { background: var(--f); color: var(--g); }
.pill:focus-visible, .swatch:focus-visible { outline: 2px solid var(--f); outline-offset: 2px; }
.pill .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--dot); border: 1.5px solid currentColor; }
.menu {
	position: absolute; top: calc(100% + 8px); right: 0; z-index: 5;
	width: min(280px, calc(100vw - 32px)); padding: 8px; border-radius: 16px;
	background: var(--g); border: 1.5px solid var(--f); display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
}
.menu[hidden] { display: none; }
.swatch {
	font-size: 14px; font-weight: 600; min-height: 44px; padding: 0 10px; border-radius: 10px;
	border: 1.5px solid transparent; background: transparent; color: var(--f); cursor: pointer;
	display: flex; align-items: center; gap: 10px; text-align: left;
}
.swatch:hover { border-color: var(--f); }
.swatch[aria-pressed="true"] { background: var(--f); color: var(--g); }
.swatch i { flex: none; width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid currentColor; }
.swatch i.site { background: conic-gradient(#e4ff3a 0 33%, #4801ff 0 66%, #ff3d7f 0); }
.menu .fbkitem {
	grid-column: 1 / -1; font: inherit; font-size: 14px; font-weight: 600; min-height: 44px; border-radius: 10px;
	border: 1.5px solid var(--f); background: transparent; color: var(--f); cursor: pointer;
}
.menu .fbkitem[hidden] { display: none; }
.menu .fbkitem:hover { background: var(--f); color: var(--g); }
.menu .swatch:first-child { grid-column: 1 / -1; }

/* ---- mode bar: always visible (D55) ---- */
.modes { display: flex; gap: 8px; margin: 14px 0 12px; flex-wrap: wrap; align-items: center; }
.modes .pill { font-family: 'Archivo', 'Arial Black', sans-serif; font-stretch: 125%; font-variation-settings: 'wdth' 125; font-size: 13px; font-weight: 700; }
.modes .sep { flex: 1; }

/* ---- board + list ---- */
main { display: flex; flex-wrap: wrap; gap: 16px 28px; align-items: flex-start; }
.stage { position: relative; width: min(100%, 560px); flex: 0 0 auto; user-select: none; -webkit-user-select: none; }
#board {
	--n: 10;
	display: grid; grid-template-columns: repeat(var(--n), 1fr);
	width: 100%; aspect-ratio: 1;
	background: var(--g); border: 1.5px solid var(--f);
	touch-action: pinch-zoom; user-select: none; /* one finger selects, two fingers zoom (D67) */ -webkit-user-select: none; cursor: pointer;
}
#board div {
	display: flex; align-items: center; justify-content: center;
	font-family: 'Archivo', 'Arial Black', sans-serif; font-weight: 600;
	font-size: calc(min(100vw - 35px, 557px) / var(--n) * .52); line-height: 1;
	color: var(--f);
}
#board[data-mode="hard"] div { font-weight: 700; font-size: calc(min(100vw - 35px, 557px) / var(--n) * .6); }
#board div.found { background: var(--ok); color: var(--ok-fg); }
#board div.sel { background: var(--sel); color: var(--sel-fg); }
#board div.bad { background: var(--bad); color: var(--bad-fg); }

/* the brief "not a word" flash (D55): visible with sound off */
.flash {
	position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
	padding: 10px 18px; border-radius: 999px; background: var(--bad); color: var(--bad-fg);
	font-weight: 700; font-size: clamp(14px, 4vw, 20px); letter-spacing: .02em; white-space: nowrap;
	pointer-events: none; opacity: 0; transition: opacity .12s;
}
.flash.on { opacity: 1; }

/* end state (L-14 in the look): covers the board, Restart and modes stay in reach */
.end {
	position: absolute; inset: 0; background: var(--g); border: 1.5px solid var(--f);
	display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 16px; text-align: center;
}
.end[hidden] { display: none; }
.end h2 { margin: 0; font-weight: 800; font-size: clamp(34px, 11vw, 72px); line-height: .9; color: var(--n); }
.end p { margin: 0; font-size: 16px; }
.end .row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

/* Hard on a phone held upright: suggest pinch-zoom (D67, D69); rules unchanged */
.turn { display: none; margin: 8px 0 0; font-size: 13px; }
@media (orientation: portrait) and (max-width: 600px) {
	body[data-mode="hard"] .turn { display: block; }
}
section.list { flex: 1 1 220px; min-width: 0; }
#listhead { margin: 0 0 10px; font-size: 13px; font-weight: 700; letter-spacing: .06em; }
#words { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
#words li {
	font-size: 14px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
	padding: 4px 12px; border-radius: 999px; border: 1.5px solid var(--f); background: var(--g);
}
#words li.found { background: var(--ok); color: var(--ok-fg); border-color: var(--ok); text-decoration: line-through; text-decoration-thickness: 2px; }
#status { min-height: 1.5em; margin: 12px 0 0; font-weight: 700; }
.foot { margin-top: 28px; font-size: 13px; }
.foot a { color: inherit; }

@media (min-width: 900px) {
	#board div { font-size: calc(557px / var(--n) * .52); }
	#board[data-mode="hard"] div { font-size: calc(557px / var(--n) * .6); }
}
/* A phone held sideways (D69): the board fits the screen height, so a drag never needs the page
   to scroll; title, controls and list sit in a column beside it. */
@media (orientation: landscape) and (max-height: 560px) {
	.page { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 20px; align-items: start; padding-top: 8px; padding-bottom: 8px; }
	main { display: contents; }
	.stage { grid-column: 1; grid-row: 1 / span 3; width: calc(100vh - 16px); width: calc(100dvh - 16px); }
	.top, .modes, section.list { grid-column: 2; }
	.modes { margin: 8px 0; }
	#board div { font-size: calc((100vh - 19px) / var(--n) * .52); }
	#board[data-mode="hard"] div { font-size: calc((100vh - 19px) / var(--n) * .6); }
}
@media (prefers-reduced-motion: reduce) {
	body, .flash { transition: none; }
}
