/* Letterpile: "Tile Table, Night Edition".
   The stage (header, home hero, footer) is navy in both themes; the page follows the system
   colour scheme until the header toggle is used (localStorage "theme", applied before paint).
   Existing custom-property names are kept (--bg --surface --text --muted --line --accent --link
   --tile --tile-edge --tile-ink); --ink is the same colour as --text. System fonts only. */
:root {
  /* page, light theme */
  --bg: #F3F5FF;
  --surface: #FFFFFF;
  --surface-2: #E8ECFF;
  --text: #0A1030;
  --ink: var(--text);
  --muted: #4A557F;
  --line: #CBD3F5;
  --field: #6A76A8;
  --link: #1F4FD8;
  --outline: #1F4FD8;
  --focus: #1D3FD1;
  --error: #B3261E;
  --good: #1E7A45;
  /* the stage: navy in BOTH themes */
  --stage: #0A1030;
  --stage-2: #131B45;
  --stage-ink: #FFFFFF;
  --stage-muted: #D3DBFF;
  --stage-line: #2D3E86;
  --stage-grid: rgb(77 141 255 / .10);
  --focus-stage: #FFDD55;
  /* accents, same in both themes; navy text on them */
  --blue: #4D8DFF;
  --violet: #9A7BFF;
  --accent: var(--blue);
  --accent-ink: #0A1030;
  /* letter tiles, same in both themes; always navy ink */
  --coral: #FF7A5C;
  --sun: #FFCC33;
  --mint: #35DCA2;
  --tile-blue: #5C9DFF;
  --tile-violet: #A98BFF;
  --wood: #FFE9B8;
  --tile: var(--wood);
  --tile-edge: #D9B867;
  --tile-ink: #0A1030;
  /* kept for the older helpers */
  --nav: var(--stage);
  --nav-ink: var(--stage-ink);
  --radius: 18px;
  --shadow: 0 1px 0 rgb(10 16 48 / .06), 0 10px 24px -12px rgb(10 16 48 / .3);
  --font-display: ui-rounded, "SF Pro Rounded", "Hiragino Maru Gothic ProN", "Arial Rounded MT Bold", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  /* Reserved ad-slot heights (label included). Fixed from first paint: no layout shift. */
  --ad-h: 280px;
  --results-min: 160px;
  color-scheme: light;
}
@media (min-width: 768px) { :root { --ad-h: 110px; } }
:root:not([data-theme="light"]) {
  --bg: #0E1735; --surface: #161F4A; --surface-2: #1D2960; --text: #F2F5FF; --muted: #AEBBE6; --line: #2D3E86;
  --field: #7F92E6; --link: #7FB0FF; --outline: #4D8DFF; --focus: #FFDD55; --error: #FF9A8A; --good: #5EE0A0;
  --shadow: 0 1px 0 rgb(0 0 0 / .3), 0 12px 28px -14px rgb(0 0 0 / .7);
  color-scheme: dark;
}
:root[data-theme="dark"] {
  --bg: #0E1735; --surface: #161F4A; --surface-2: #1D2960; --text: #F2F5FF; --muted: #AEBBE6; --line: #2D3E86;
  --field: #7F92E6; --link: #7FB0FF; --outline: #4D8DFF; --focus: #FFDD55; --error: #FF9A8A; --good: #5EE0A0;
  --shadow: 0 1px 0 rgb(0 0 0 / .3), 0 12px 28px -14px rgb(0 0 0 / .7);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* component display rules must never reveal hidden elements (e.g. the CMP footer link) */
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 16px; }
body { margin: 0; background: var(--bg); color: var(--text); font: 1.0625rem/1.6 var(--font-body); }
a { color: var(--link); }
h1, h2, h3 { font-family: var(--font-display); font-weight: 800; line-height: 1.15; letter-spacing: -.01em; }
code { font-family: var(--mono); font-size: .9em; }
kbd { font: 700 .85em var(--font-display); background: var(--surface-2); color: var(--text); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; padding: 0 6px; }
svg { max-width: 100%; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 640px) { .wrap { padding: 0 24px; } }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 8px; top: -80px; z-index: 100; background: var(--blue); color: var(--accent-ink); padding: 10px 16px; border-radius: 10px; font-weight: 800; text-decoration: none; }
.skip:focus { top: 8px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 6px; }
.masthead :focus-visible, .hero :focus-visible, .footer :focus-visible { outline-color: var(--focus-stage); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }

/* ---------- letter tiles ---------- */
.tile {
  --ts: 48px; --c: var(--wood);
  display: inline-grid; place-items: center; position: relative; flex: none; width: var(--ts); height: var(--ts);
  border-radius: calc(var(--ts) * .2); background: var(--c); color: var(--tile-ink);
  font: 800 calc(var(--ts) * .5)/1 var(--font-display); text-transform: uppercase;
  box-shadow: inset 0 calc(var(--ts) * -.07) 0 rgb(0 0 0 / .16), inset 0 2px 0 rgb(255 255 255 / .5), 0 3px 0 rgb(0 0 0 / .22);
}
.tile sup { position: absolute; right: calc(var(--ts) * .1); bottom: calc(var(--ts) * .09); font-size: max(10px, calc(var(--ts) * .24)); font-weight: 700; line-height: 1; }
.tile.sm { --ts: 36px; } .tile.md { --ts: 44px; } .tile.lg { --ts: 64px; }
.tile.blank { background: var(--wood); box-shadow: inset 0 0 0 3px var(--tile-ink), 0 3px 0 rgb(0 0 0 / .22); }
.tile.ghost { background: transparent; box-shadow: inset 0 0 0 2px var(--line); }
.c-coral { --c: var(--coral); } .c-sun { --c: var(--sun); } .c-blue { --c: var(--tile-blue); }
.c-mint { --c: var(--mint); } .c-violet { --c: var(--tile-violet); } .c-wood { --c: var(--wood); }

/* ---------- header (stage) ---------- */
.masthead { background: var(--stage); color: var(--stage-ink); border-radius: 0 0 28px 28px; }
.masthead:has(+ main.home) { border-radius: 0; }
.masthead .wrap { display: flex; align-items: center; gap: 8px; min-height: 68px; }
.brand { display: flex; align-items: center; min-height: 44px; gap: 10px; text-decoration: none; color: var(--stage-ink); font: 800 1.5rem/1 var(--font-display); letter-spacing: -.02em; }
.brand-tiles { display: flex; gap: 3px; }
.brand-tiles .tile { --ts: 28px; }
.brand-tiles .tile:nth-child(1) { transform: rotate(-7deg); }
.brand-tiles .tile:nth-child(2) { transform: translateY(2px); }
.brand-tiles .tile:nth-child(3) { transform: rotate(6deg); }
.icon-btn { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; flex: none; cursor: pointer; background: transparent; border: 2px solid var(--blue); color: var(--stage-ink); }
.icon-btn:hover { background: rgb(77 141 255 / .2); }
.theme-toggle { margin-left: 4px; }
.menu-toggle { display: none; }

.navbar { margin-left: auto; min-width: 0; }
.navbar ul { list-style: none; margin: 0; padding: 0; }
.nav-main { display: flex; align-items: center; gap: 4px; }
.nav-main > li { position: relative; }
.nav-main a, .nav-main summary {
  display: block; padding: 10px 14px; min-height: 44px; line-height: 24px; border-radius: 999px; color: var(--stage-ink);
  text-decoration: none; font-weight: 700; font-size: .95rem; cursor: pointer; list-style: none;
}
.nav-main summary::-webkit-details-marker { display: none; }
.nav-main a:hover, .nav-main summary:hover { background: rgb(255 255 255 / .12); }
.nav-main a[aria-current="page"], .nav-main details.active > summary { background: var(--violet); color: var(--tile-ink); }
.nav-main a.nav-games { background: var(--mint); color: var(--tile-ink); box-shadow: inset 0 -3px 0 rgb(0 0 0 / .18); }
.nav-main a.nav-games:hover { background: #5FE6B6; }
.nav-main a.nav-games[aria-current="page"] { background: var(--violet); }
.caret { display: inline-block; margin-left: 6px; border: 5px solid transparent; border-top-color: currentColor; border-bottom: 0; vertical-align: 2px; }
.dropdown {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 250px; display: none;
  background: var(--stage-2); border: 2px solid var(--stage-line); border-radius: 16px; box-shadow: var(--shadow); padding: 8px;
}
.has-dropdown details[open] .dropdown { display: grid; gap: 2px; }
@media (min-width: 1000px) { .has-dropdown details[open] .dropdown { grid-template-columns: 1fr 1fr; min-width: 480px; } }
.dropdown a { border-radius: 10px; }
.dropdown a[aria-current="page"] { background: var(--violet); color: var(--tile-ink); }

/* ---------- buttons and forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 10px 26px;
  border: 0; border-radius: 16px; background: var(--blue); color: var(--accent-ink); cursor: pointer; text-decoration: none;
  font: 800 1.1rem/1 var(--font-display);
  box-shadow: inset 0 -4px 0 rgb(10 16 48 / .22), 0 4px 0 #2748B8; transition: transform .12s ease, box-shadow .12s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(3px); box-shadow: inset 0 -4px 0 rgb(10 16 48 / .22), 0 1px 0 #2748B8; }
.btn.secondary { background: transparent; color: var(--text); border: 2px solid var(--outline); box-shadow: none; min-height: 48px; font-size: 1rem; }
.btn.secondary:hover { background: var(--surface-2); }
.btn.small { min-height: 44px; padding: 8px 18px; font-size: .95rem; }
.btn:disabled { opacity: .55; cursor: default; transform: none; }
.tool-form { display: grid; gap: 14px; margin-top: 18px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.field { display: grid; gap: 6px; flex: 1 1 140px; min-width: 0; }
.field > span { font-size: .8rem; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
input[type="text"], input[type="number"], select, textarea {
  width: 100%; min-height: 48px; font: inherit; padding: 8px 14px; border-radius: 14px;
  border: 2px solid var(--field); background: var(--surface); color: var(--text);
}
textarea { resize: vertical; min-height: 110px; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--outline); }
.big-input { font: 800 1.5rem/1.2 var(--font-display) !important; letter-spacing: .14em; text-transform: uppercase; min-height: 60px !important; border-radius: 18px !important; padding: 8px 18px !important; }
.big-input::placeholder { letter-spacing: .02em; text-transform: none; font-weight: 600; font-size: 1.05rem; color: var(--muted); opacity: 1; }
.check { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; font-size: .95rem; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--link); }
details.advanced { border: 2px solid var(--line); border-radius: 18px; padding: 4px 16px; background: var(--surface-2); }
details.advanced summary { cursor: pointer; font-family: var(--font-display); font-weight: 800; min-height: 44px; display: flex; align-items: center; }
details.advanced[open] { padding-bottom: 12px; }
details.advanced[open] summary { margin-bottom: 6px; }
.hint { font-size: .9rem; color: var(--muted); margin: 0; }

/* tile rack preview (decorative, mirrors the input) */
.rack { display: flex; flex-wrap: wrap; gap: 6px; min-height: 48px; }
.rack .tile { --ts: 44px; }
.tool-form .rack .tile { --ts: clamp(34px, calc((100vw - 112px) / 7), 46px); }
.rack .tile.pop { animation: pop .28s ease-out both; }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 28px; padding: 24px 16px 56px; }
.content { min-width: 0; }
.panel { background: var(--surface); border: 2px solid var(--line); border-radius: 26px; box-shadow: var(--shadow); padding: 28px; }
.tool-card { border-top: 10px solid var(--blue); }
.page-title { margin: 0 0 8px; font-size: clamp(1.9rem, 5vw, 2.6rem); }
.lede { margin: 0 0 20px; color: var(--muted); font-size: 1.1rem; max-width: 40rem; }

/* ---------- home: hero on the stage ---------- */
.hero {
  background-color: var(--stage);
  background-image: linear-gradient(var(--stage-grid) 1px, transparent 1px), linear-gradient(90deg, var(--stage-grid) 1px, transparent 1px);
  background-size: 56px 56px; color: var(--stage-ink); border-radius: 0 0 36px 36px; padding: 36px 0 44px; position: relative; overflow: hidden;
}
.hero-grid { display: grid; gap: 28px; align-items: center; }
.hero-copy { min-width: 0; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; margin: 0 0 14px; padding: 6px 14px; border-radius: 999px; background: rgb(154 123 255 / .26); border: 1px solid rgb(154 123 255 / .6); font-weight: 700; font-size: .9rem; }
.eyebrow i { width: 10px; height: 10px; border-radius: 3px; background: var(--mint); display: inline-block; }
.hero .page-title { font-size: clamp(2.4rem, 7.5vw, 4.25rem); letter-spacing: -.025em; margin-bottom: 12px; }
.hero .lede { color: var(--stage-muted); font-size: clamp(1.05rem, 2.4vw, 1.25rem); max-width: 34rem; margin-bottom: 4px; }
.hero kbd { background: var(--stage-2); border-color: var(--blue); color: var(--stage-ink); }
.hero .tool-form { max-width: 36rem; }
.hero input[type="text"], .hero select { background: var(--stage-2); color: var(--stage-ink); border-color: var(--blue); }
.hero .big-input { box-shadow: 0 0 0 4px rgb(77 141 255 / .28); }
.hero input[type="text"]::placeholder { color: var(--stage-muted); }
.hero input:focus, .hero select:focus { border-color: #FFFFFF; }
.hero .field > span, .hero .hint, .hero .show-all { color: var(--stage-muted); }
.hero details.advanced { background: var(--stage-2); border-color: var(--stage-line); }
.hero .check input { accent-color: var(--blue); }
.hero .rack .tile.ghost { box-shadow: inset 0 0 0 2px rgb(255 255 255 / .55); }
.facts { list-style: none; margin: 26px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 22px; font-size: .95rem; }
.facts li { display: flex; align-items: center; gap: 8px; }
.facts li::before { content: ""; width: 12px; height: 12px; border-radius: 4px; background: var(--mint); flex: none; }
.facts li:nth-child(2)::before { background: var(--sun); }
.facts li:nth-child(3)::before { background: var(--coral); }
/* pile of tiles (decorative) */
.pile { position: relative; display: flex; flex-wrap: nowrap; gap: 6px; order: -1; }
.pile .tile { --ts: 46px; transform: rotate(var(--r, 0deg)); animation: drop .55s cubic-bezier(.2, .8, .3, 1.2) both; }
.pile .tile:nth-child(1) { --r: -8deg; } .pile .tile:nth-child(2) { --r: 5deg; animation-delay: .06s; }
.pile .tile:nth-child(3) { --r: -4deg; animation-delay: .12s; } .pile .tile:nth-child(4) { --r: 7deg; animation-delay: .18s; }
.pile .tile:nth-child(5) { --r: -6deg; animation-delay: .24s; } .pile .tile:nth-child(6) { --r: 4deg; animation-delay: .3s; }
.pile .tile:nth-child(n+7) { display: none; }
@media (min-width: 900px) {
  .hero { padding: 56px 0 64px; }
  .hero-grid { grid-template-columns: minmax(0, 1.25fr) minmax(0, .75fr); gap: 40px; }
  .pile { order: 0; display: grid; grid-template-columns: repeat(3, auto); gap: 14px; justify-content: center; transform: rotate(-4deg); }
  .pile .tile { --ts: 92px; }
  .pile .tile:nth-child(even) { margin-top: 22px; }
  .pile .tile:nth-child(n+7) { display: grid; }
  .pile .tile:nth-child(7) { --r: -5deg; animation-delay: .36s; } .pile .tile:nth-child(8) { --r: 6deg; animation-delay: .42s; } .pile .tile:nth-child(9) { --r: -3deg; animation-delay: .48s; }
  .pile::before { content: ""; position: absolute; inset: -12% -8%; background: radial-gradient(closest-side, rgb(77 141 255 / .38), transparent); z-index: -1; }
}
@keyframes drop { from { opacity: 0; transform: translateY(-28px) rotate(calc(var(--r, 0deg) - 10deg)); } to { opacity: 1; transform: translateY(0) rotate(var(--r, 0deg)); } }
@keyframes pop { from { opacity: 0; transform: scale(.7); } to { opacity: 1; transform: scale(1); } }
/* Chips move in but never fade: text keeps full contrast from the first frame. */
@keyframes lift { from { transform: translateY(6px); } to { transform: none; } }

/* ---------- home: body sections ---------- */
.home-body { padding-top: 28px; }
.results-panel .results { margin-top: 0; }
.section { padding: 48px 0 8px; }
@media (min-width: 768px) { .section { padding: 64px 0 12px; } }
.section h2 { font-size: clamp(1.6rem, 3.6vw, 2.25rem); margin: 0 0 8px; }
.section-lede { color: var(--muted); max-width: 40rem; margin: 0 0 24px; }
.cats { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 600px) { .cats { grid-template-columns: repeat(2, 1fr); } .cats > li:last-child { grid-column: 1 / -1; } }
@media (min-width: 960px) { .cats { grid-template-columns: repeat(6, 1fr); } .cats > li { grid-column: span 2; } .cats > li:nth-child(n+4), .cats > li:last-child { grid-column: span 3; } }
.cat { position: relative; display: flex; flex-direction: column; gap: 10px; padding: 20px; border-radius: 24px; background: var(--c); color: var(--tile-ink); border: 2px solid transparent; box-shadow: var(--shadow); transition: transform .15s ease; }
.cat:hover { transform: translateY(-3px); }
.cat .top { display: flex; align-items: center; gap: 14px; }
.cat h3 { font-size: 1.5rem; margin: 0; }
.cat h3 a { color: inherit; text-decoration: none; }
.cat h3 a::after { content: ""; position: absolute; inset: 0; border-radius: 24px; }
.cat h3 a:focus-visible { outline: none; }
.cat:has(h3 a:focus-visible) { outline: 3px solid var(--focus); outline-offset: 3px; }
.cat p { margin: 0; font-size: 1rem; }
.mini { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.mini li { background: rgb(255 255 255 / .72); color: var(--tile-ink); border-radius: 999px; padding: 3px 12px; font-size: .88rem; font-weight: 700; }
.go { margin-top: auto; font: 800 .95rem var(--font-display); }
:root:not([data-theme="light"]) .cat { background: var(--surface); color: var(--text); border-color: var(--c); box-shadow: 0 0 0 1px var(--c), 0 12px 28px -12px var(--c); }
:root[data-theme="dark"] .cat { background: var(--surface); color: var(--text); border-color: var(--c); box-shadow: 0 0 0 1px var(--c), 0 12px 28px -12px var(--c); }
.tools { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr)); }
.tool { display: flex; gap: 12px; align-items: flex-start; height: 100%; padding: 14px; border-radius: 18px; background: var(--surface); border: 2px solid var(--line); text-decoration: none; color: var(--text); transition: transform .15s ease, border-color .15s ease; }
.tool:hover { transform: translateY(-2px); border-color: var(--outline); }
.tool strong { display: block; font: 800 1.02rem/1.25 var(--font-display); }
.tool small { display: block; color: var(--muted); font-size: .86rem; line-height: 1.35; margin-top: 2px; }
.az { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); }
.az a { display: grid; justify-items: center; gap: 2px; padding: 8px 0 6px; min-height: 44px; border-radius: 14px; background: var(--surface); border: 2px solid var(--line); color: var(--text); text-decoration: none; font: 800 1.5rem/1 var(--font-display); text-transform: uppercase; transition: transform .15s ease, background .15s ease; }
.az a small { font: 700 .75rem/1.2 var(--font-body); color: var(--muted); }
.az a:hover { background: var(--blue); color: var(--accent-ink); border-color: var(--blue); transform: translateY(-2px); }
.az a:hover small { color: var(--accent-ink); }
.az.popular { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.az.popular a { font: 800 1rem/1.2 var(--font-display); text-transform: none; padding: 10px 8px 8px; text-align: center; }
.prose .pairs { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 4px 16px; }
.prose .lead { font-size: 1.05rem; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
@media (min-width: 768px) { .steps { grid-template-columns: repeat(3, 1fr); } }
.steps li { display: flex; gap: 14px; align-items: flex-start; background: var(--surface-2); border-radius: 20px; padding: 18px; }
.steps h3 { font-size: 1.15rem; margin: 0 0 4px; }
.steps p { margin: 0; font-size: .98rem; color: var(--muted); }
.guide-cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
@media (min-width: 768px) { .guide-cards { grid-template-columns: repeat(3, 1fr); } }
.guide-cards li { position: relative; background: var(--surface); border: 2px solid var(--line); border-top: 8px solid var(--tile-violet); border-radius: 20px; padding: 18px; }
.guide-cards li:nth-child(2) { border-top-color: var(--tile-blue); }
.guide-cards li:nth-child(3) { border-top-color: var(--mint); }
.guide-cards li:hover { border-color: var(--outline); }
.guide-cards h3 { font-size: 1.15rem; margin: 0 0 6px; }
.guide-cards h3 a { color: var(--text); text-decoration: none; }
.guide-cards h3 a::after { content: ""; position: absolute; inset: 0; }
.guide-cards p { margin: 0; color: var(--muted); font-size: .96rem; }
.more-link { display: inline-flex; align-items: center; min-height: 44px; margin-top: 10px; font-weight: 800; }
.home-copy { display: grid; gap: 28px; padding: 24px 0 8px; }
@media (min-width: 1000px) { .home-copy { grid-template-columns: minmax(0, 1fr) 300px; align-items: start; } }
.home-copy .prose { max-width: 760px; }
.home-aside .panel { padding: 18px 20px; border-radius: 22px; }
.home-aside h2 { font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 10px; font-family: var(--font-body); }

/* ---------- results ---------- */
.results { margin-top: 22px; min-height: var(--results-min); }
.results--short { min-height: 80px; }
/* Shared result links run a search on load; reserve most of the screen so the results don't
   push visible content down when they arrive (layout shift). */
html.has-query .results { min-height: 70vh; }
.results .summary { margin: 0 0 14px; font-weight: 700; }
.results .summary small { color: var(--muted); font-weight: 500; }
.prose p.summary { font-size: 1.06rem; }
.group { --g: var(--wood); margin-bottom: 22px; content-visibility: auto; contain-intrinsic-size: auto 240px; } /* skip layout of off-screen result groups */
.group[data-len="3"] { --g: var(--tile-violet); }
.group[data-len="4"] { --g: var(--tile-blue); }
.group[data-len="5"] { --g: var(--mint); }
.group[data-len="6"] { --g: var(--sun); }
.group[data-len="7"], .group[data-len="8"], .group[data-len="9"], .group[data-len="10"], .group[data-len="11"],
.group[data-len="12"], .group[data-len="13"], .group[data-len="14"], .group[data-len="15"] { --g: var(--coral); }
.group h3 { margin: 0 0 10px; font-size: 1.05rem; display: flex; align-items: center; gap: 10px; }
.count { font: 800 .8rem var(--font-body); background: var(--surface-2); color: var(--muted); border-radius: 999px; padding: 2px 10px; }
.words { display: flex; flex-wrap: wrap; gap: 8px; }
.word {

  /* inline-block, not flex: the letters and the blank-tile <span>s must stay one word */
  display: inline-block; min-height: 44px; padding: 0 14px; cursor: pointer; white-space: nowrap;
  font: 800 1.02rem/38px var(--font-display); letter-spacing: .05em; text-transform: uppercase;
  background: var(--surface); color: var(--text); border: 2px solid var(--line); border-bottom: 4px solid var(--g, var(--wood)); border-radius: 14px;
  transition: transform .12s ease; animation: lift .25s ease-out both;
}
.word:hover { transform: translateY(-2px); border-color: var(--outline); border-bottom-color: var(--g, var(--wood)); }
.word .pts { display: inline-grid; place-items: center; vertical-align: middle; min-width: 26px; height: 26px; padding: 0 6px; margin: -3px -8px 0 8px; border-radius: 9px; background: var(--g, var(--wood)); color: var(--tile-ink); font: 800 .8rem/1 var(--font-body); letter-spacing: 0; }
.word .blank { color: var(--link); text-decoration: underline dotted 2px; text-underline-offset: 3px; }
.word.bingo { background: var(--coral); border-color: var(--coral); color: var(--tile-ink); border-bottom-color: rgb(10 16 48 / .35); }
.word.bingo .pts { background: #FFFFFF; }
.word.bingo .blank { color: inherit; }
.word.plain { background: var(--surface-2); border: 2px solid var(--line); }
.word.static { cursor: default; animation: none; }
.word.static:hover { transform: none; }
.empty, .error { padding: 18px; border-radius: 16px; background: var(--surface-2); color: var(--muted); margin: 0; }
.error { color: var(--error); }
.more { margin-top: 8px; }
.loading { color: var(--muted); display: flex; align-items: center; gap: 10px; }
.loading::before { content: ""; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--link); animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.toolbar label { font-size: .9rem; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.toolbar select { width: auto; padding: 6px 10px; }

/* Tile rack display (Text Twist wheel, jumbles) */
.tiles { display: flex; flex-wrap: wrap; gap: 6px; }
.tiles span {
  width: 44px; height: 48px; display: grid; place-items: center; position: relative; font: 800 22px/1 var(--font-display); text-transform: uppercase;
  background: var(--tile); color: var(--tile-ink); border-radius: 9px; box-shadow: inset 0 -3px 0 var(--tile-edge), 0 3px 0 rgb(0 0 0 / .18);
}
.tiles span sub { position: absolute; right: 4px; bottom: 5px; font-size: 10px; }
.tiles span.revealed { outline: 3px solid var(--mint); }
.tiles--wheel { margin-top: 16px; min-height: 48px; }
.tiles--puzzle { min-height: 48px; }

/* ---------- small layout helpers (replace the old inline styles) ---------- */
.grow { flex: 1 1 260px; }
.grow2 { flex: 2 1 240px; }
.narrow { flex: 0 1 130px; }
.row.end { align-items: end; }
.row.center { align-items: center; }
.spaced { margin-bottom: 14px; }
.mt { margin-top: 10px; }
.push { margin-left: auto; }
.toolbar.flat { margin: 0; }
.under-toolbar { margin: -6px 0 14px; }
.good { color: var(--good); }
/* Color names in the Wordle hint, drawn like the tiles (white on dark enough colors for AA in both themes). */
.c-grey, .c-warn, .c-good { color: #fff; padding: 0 6px; border-radius: 4px; background: #5A5F78; }
.c-warn { background: #8a6a00; }
.c-good { background: #2e6b3a; }
.jumble-field { flex: 1 1 150px; }
.show-all { font-size: .9rem; color: var(--muted); }
.scrambled { background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; padding: 14px 16px; font-size: 18px; font-family: var(--mono); white-space: pre-wrap; }
.challenge { border-top: 2px solid var(--line); margin-top: 28px; padding-top: 20px; }
.challenge h2 { margin: 0 0 4px; font-size: 1.4rem; }
.challenge > .hint { margin-bottom: 14px; }
.feedback { margin-top: 10px; min-height: 1.6em; }

/* ---------- Wordle tiles ---------- */
.wgrid { display: grid; gap: 8px; margin: 6px 0 14px; }
.wrow { display: flex; gap: 6px; align-items: center; }
.wtile { position: relative; width: 52px; height: 52px; border-radius: 10px; border: 0; cursor: pointer; font: 800 24px var(--font-display); text-transform: uppercase; color: #fff; background: #5A5F78; box-shadow: inset 0 -3px 0 rgb(0 0 0 / .2); }
.wtile[data-m="y"] { background: #8a6a00; }
.wtile[data-m="g"] { background: #2e6b3a; }
/* A shape as well as a color: nothing for gray, a dot for yellow, a check for green. */
.wmark { position: absolute; right: 4px; top: 2px; font-size: 12px; line-height: 1; }
.wtile[data-m="y"] .wmark::after { content: "•"; }
.wtile[data-m="g"] .wmark::after { content: "✓"; }
.wrow .del { margin-left: 6px; border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 20px; min-width: 44px; min-height: 44px; }
@media (max-width: 420px) { .wtile { width: 44px; height: 44px; font-size: 20px; } }

/* ---------- breadcrumbs, documents ---------- */
.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 14px; padding: 0; font-size: .9rem; color: var(--muted); }
.crumbs li + li::before { content: "›"; margin-right: 4px; }
.crumbs a { color: var(--muted); }
.prose.doc { margin-top: 0; max-width: 760px; }
.prose.doc > h2:first-of-type { margin-top: 24px; }
.updated { color: var(--muted); font-size: .9rem; margin-top: 0; }
.contact-email { font-size: 1.25rem; font-weight: 800; }

/* ---------- ad slots (containers only; no ad code) ---------- */
.ad-slot { display: block; min-height: var(--ad-h); margin: 28px 0; padding-top: 4px; contain: layout style; text-align: center; }
.ad-label { display: block; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.ad-slot--dev .ad-slot__inner { min-height: calc(var(--ad-h) - 24px); border: 2px dashed var(--line); border-radius: 14px; }
html.has-query .ad-slot { display: none; }

/* ---------- prose ---------- */
.prose { margin-top: 32px; }
.prose h2 { font-size: 1.5rem; margin: 28px 0 10px; }
.prose h3 { font-size: 1.15rem; margin: 20px 0 6px; }
.prose p, .prose li { color: var(--text); }
.prose ul, .prose ol { padding-left: 22px; }
.prose li { margin: 6px 0; }
.prose code { font: 700 .92em var(--font-display); background: var(--surface-2); padding: 1px 6px; border-radius: 6px; }
.prose table { border-collapse: collapse; width: 100%; font-size: .94rem; }
.prose th, .prose td { text-align: left; border-bottom: 1px solid var(--line); padding: 7px 10px; }
.prose th { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

/* ---------- sidebar ---------- */
.sidebar { display: grid; gap: 18px; align-content: start; }
.sidebar .panel { padding: 18px 20px; border-radius: 22px; }
.sidebar h2 { font-size: .85rem; margin: 0 0 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-family: var(--font-body); }
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar li a { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 4px 0; color: var(--text); text-decoration: none; font-weight: 700; border-bottom: 1px solid var(--line); }
.sidebar li:last-child a { border-bottom: 0; }
.sidebar li a:hover, .sidebar li a[aria-current="page"] { color: var(--link); }
.sidebar .ico {
  width: 30px; height: 30px; border-radius: 7px; display: grid; place-items: center; flex: none;
  font: 800 15px var(--font-display); background: var(--c, var(--wood)); color: var(--tile-ink); box-shadow: inset 0 -3px 0 rgb(0 0 0 / .16), 0 2px 0 rgb(0 0 0 / .2);
}
.tip p { margin: 0; font-size: .98rem; }
.values { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 6px; }
.values span { display: flex; justify-content: center; align-items: baseline; gap: 2px; background: var(--surface-2); border-radius: 10px; padding: 4px 0; font: 800 .95rem var(--font-display); text-transform: uppercase; }
.values b { font: 700 .75rem var(--font-body); color: var(--muted); }

/* ---------- footer (stage) ---------- */
.footer { background: var(--stage); color: var(--stage-muted); margin-top: 56px; padding: 40px 0 44px; border-radius: 36px 36px 0 0; font-size: .95rem; }
.footer a { color: #FFFFFF; }
.footer .brand { display: inline-flex; margin-bottom: 10px; }
.footer .cols { display: flex; flex-wrap: wrap; gap: 4px 22px; margin: 0 0 14px; }
.footer .cols a { display: inline-flex; align-items: center; min-height: 44px; text-decoration: none; }
.footer .cols a:hover { text-decoration: underline; }
.footer .cols.legal { padding-top: 10px; border-top: 1px solid var(--stage-line); }
.footer .fine { font-size: .85rem; color: #B9C4F2; }
.footer .mail { font-weight: 800; }

/* ---------- definition dialog ---------- */
dialog.define {
  width: min(520px, calc(100vw - 32px)); max-height: min(80vh, 640px); border: 0; border-radius: 26px; padding: 0;
  background: var(--surface); color: var(--text); box-shadow: 0 24px 70px rgb(0 0 0 / .4);
}
dialog.define::backdrop { background: rgb(5 8 28 / .7); }
.define header { display: flex; align-items: center; gap: 12px; padding: 18px 20px 12px; border-top: 10px solid var(--blue); border-bottom: 2px solid var(--line); }
.define header h2 { margin: 0; font: 800 1.6rem var(--font-display); text-transform: uppercase; letter-spacing: .08em; }
.define header .pts { color: var(--muted); font-size: .85rem; font-weight: 700; }
.define header button { margin-left: auto; display: grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 14px; border: 2px solid var(--field); background: var(--surface); color: var(--text); cursor: pointer; font-size: 1.2rem; }
.define header button:hover { border-color: var(--outline); }
.define .body { padding: 14px 20px 20px; overflow-y: auto; max-height: calc(min(80vh, 640px) - 80px); }
.define .pos { font-style: italic; color: var(--muted); margin: 12px 0 4px; font-weight: 600; }
.define ol { margin: 0; padding-left: 20px; }
.define li { margin: 4px 0; }
.define .links { margin-top: 14px; font-size: .9rem; display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.define .body > .hint { margin-bottom: 10px; }
.define [hidden] { display: none; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 12px; font-weight: 700; font-size: .9rem; z-index: 50; }

/* ---------- FAQ, related, word lists ---------- */
.faq { margin-top: 36px; }
.faq-item { border-bottom: 2px solid var(--line); }
.faq-item summary { cursor: pointer; font: 800 1.05rem var(--font-display); min-height: 48px; display: flex; align-items: center; padding: 6px 0; }
.faq-item[open] summary { color: var(--link); }
.faq-a { padding-bottom: 12px; }
.faq-a p:first-child { margin-top: 0; }
.related { margin-top: 32px; }
.related ul, .related-list { padding-left: 22px; }
.related li, .related-list li { margin: 4px 0; }
.prose.doc.wide { max-width: none; }
.wordlist { font-family: var(--mono); font-size: 15px; line-height: 1.9; word-spacing: .35em; overflow-wrap: anywhere; }
.prose h3 .count, .link-cols .count { font-size: .75rem; }
.link-cols { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px 16px; }
.link-cols li { display: flex; align-items: center; gap: 6px; min-height: 32px; }
.toc { background: var(--surface-2); border-radius: 16px; padding: 12px 18px; }
.prose .table-wrap { overflow-x: auto; }
.guide-list { list-style: none; padding: 0; }
.guide-list li { margin: 0 0 14px; }
/* Tables fit phone screens: cells may wrap anywhere, tighter padding below 480px. */
.prose td, .prose th { overflow-wrap: anywhere; }
@media (max-width: 480px) { .prose table { font-size: 13px; } .prose th, .prose td { padding: 5px 6px; } }

/* ---------- responsive ---------- */
@media (max-width: 999px) {
  .layout { grid-template-columns: 1fr; }
}
@media (max-width: 859px) {
  .masthead .wrap { flex-wrap: wrap; }
  .menu-toggle { display: grid; margin-left: auto; }
  .theme-toggle { margin-left: 0; }
  .navbar { display: none; order: 5; flex-basis: 100%; margin: 0 0 12px; }
  .navbar.open { display: block; }
  .nav-main { flex-direction: column; align-items: stretch; background: var(--stage-2); border: 2px solid var(--stage-line); border-radius: 18px; padding: 8px; }
  .dropdown { position: static; box-shadow: none; border: 0; padding: 0 0 0 12px; min-width: 0; background: none; }
  .panel { padding: 20px; }
  .layout { padding-top: 18px; }
}
@media (max-width: 420px) {
  .row > .btn { flex: 1 1 100%; }
}
.lp-example { border-collapse: separate; border-spacing: 4px; margin: 8px 0 14px; }
.lp-example td { width: 40px; height: 40px; text-align: center; font: 800 1.2rem var(--font-display); background: var(--wood); color: var(--tile-ink); border-radius: 8px; border: 0; }

/* ---------- Phase 4 word tools (wt-) ---------- */
.wt-grid { --n: 4; display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: 6px; max-width: calc(var(--n) * 70px); margin: 4px 0 12px; }
.wt-cell { aspect-ratio: 1; min-height: 0 !important; padding: 0 !important; text-align: center; font: 800 1.4rem var(--font-display) !important; border-radius: 12px !important; background: var(--wood) !important; color: var(--tile-ink) !important; }
.wt-cell.on { background: var(--sun) !important; box-shadow: inset 0 0 0 3px var(--tile-ink); }
.wt-path { min-height: 1.5em; font-weight: 700; }
.word.on { outline: 3px solid var(--focus); }
.wt-pairs, .wt-ladder, .wt-bars, .wt-cands, .wt-syl { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.wt-pair { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.wt-ladder { counter-reset: s; }
.wt-ladder .word { letter-spacing: .12em; text-transform: uppercase; }
.wt-ladder b { color: var(--link); text-decoration: underline 3px; text-underline-offset: 4px; }
.wt-bars li { display: grid; grid-template-columns: 2em 1fr; gap: 2px 10px; align-items: center; }
.wt-bars .bar { --w: 0%; height: 14px; width: var(--w); border-radius: 7px; background: var(--g, var(--mint)); }
.wt-bars small { grid-column: 2; color: var(--muted); }
.wt-boards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); margin-top: 14px; }
.wt-board { border: 2px solid var(--line); border-radius: 16px; padding: 12px; }
.wt-board h3 { margin: 0 0 8px; font-size: 1rem; display: flex; gap: 8px; align-items: center; }
.wt-board .wtile { width: 36px; height: 36px; font-size: 17px; }
.wt-board .words { gap: 6px; }
.wt-keys { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 6px; margin: 8px 0 12px; }
.wt-key { display: grid; justify-items: center; gap: 2px; font-weight: 800; }
.wt-key[data-n="0"] { opacity: .5; }
.wt-key input { width: 44px; min-height: 44px !important; padding: 0 !important; text-align: center; font: 800 1.1rem var(--font-display) !important; text-transform: uppercase; }
.wt-key input.clash { border-color: var(--coral) !important; }
.wt-plain { font: 700 1.15rem/1.6 var(--font-display); letter-spacing: .08em; white-space: pre-wrap; overflow-wrap: anywhere; min-height: 1.6em; }
.wt-cands > li { border-top: 1px solid var(--line); padding-top: 8px; }
.wt-sub { margin: 18px 0 10px; }
.wt-syl li { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.wt-sw sup { color: var(--link); font-weight: 800; margin-left: 1px; }
.wt-total { font: 800 1.2rem var(--font-display); }
.wt-hive { display: flex; gap: 6px; flex-wrap: wrap; }
.scan-row { margin-top: 8px; }
dialog.scan { max-width: 460px; width: calc(100% - 32px); border: 2px solid var(--line); border-radius: 22px; background: var(--surface); color: var(--text); padding: 20px; }
dialog.scan::backdrop { background: rgb(10 16 48 / .6); }
dialog.scan h2 { margin: 0 0 10px; }
.scan-img { width: 100%; max-height: 180px; object-fit: contain; border-radius: 12px; background: #fff; }
.hooks { margin: 8px 0; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; } .hooks .word { padding: 4px 10px; font-size: .9rem; } .hooks b { color: var(--link); }
.bs-wrap { margin: 10px 0; }
.bs-board { display: grid; grid-template-columns: repeat(15, 1fr); gap: 2px; max-width: 560px; padding: 4px; border-radius: 12px; background: var(--line); }
.bs-cell { aspect-ratio: 1; min-height: 0 !important; width: 100%; padding: 0 !important; border: 0 !important; border-radius: 4px !important; text-align: center; font: 800 clamp(11px, 2.6vw, 17px) var(--font-display) !important; background: var(--surface-2) !important; color: var(--text) !important; text-transform: uppercase; }
.bs-cell::placeholder { font-size: .6em; font-weight: 800; opacity: 1; color: #0b1a33; }
.bs-cell[data-b="d"] { background: #bfe3f7 !important; color: #0b1a33 !important; } .bs-cell[data-b="t"] { background: #1f5fa8 !important; color: #fff !important; }
.bs-cell[data-b="D"] { background: #f7c6cf !important; color: #0b1a33 !important; } .bs-cell[data-b="T"] { background: #b8322c !important; color: #fff !important; }
.bs-cell[data-b="t"]::placeholder, .bs-cell[data-b="T"]::placeholder { color: #fff; }
.bs-cell:not(:placeholder-shown) { background: var(--wood) !important; color: var(--tile-ink) !important; }
.bs-cell.blank { color: var(--link) !important; text-decoration: underline dotted; }
.bs-cell.new { background: var(--sun) !important; box-shadow: inset 0 0 0 2px var(--tile-ink); }
.bs-board.editing .bs-cell { cursor: pointer; }
.bs-plays { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.bs-play { width: 100%; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; text-align: left; padding: 10px 12px; border: 2px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text); cursor: pointer; font: inherit; }
.bs-play strong { margin-left: auto; font: 800 1.2rem var(--font-display); }
.bs-play small { flex-basis: 100%; color: var(--muted); }
.bs-play[aria-pressed="true"] { border-color: var(--focus); }
.bs-bonus { margin: 10px 0; }
.train-tabs { margin-bottom: 12px; } .train-tabs [aria-selected="true"] { background: var(--violet); color: var(--tile-ink); }
.train-q { font-size: 1.2rem; } .train-word { font: 800 2rem var(--font-display); letter-spacing: .12em; }
.train-rack { font: 800 1.8rem var(--font-display); letter-spacing: .1em; }
.train-feedback { min-height: 1.6em; font-weight: 700; } .train-card { border: 2px solid var(--line); border-radius: 16px; padding: 16px; text-align: center; }
.pz-grid { border-collapse: collapse; margin: 10px auto; font: 700 clamp(9px, 2.6vw, 15px)/1 var(--font-mono, monospace); text-transform: uppercase; }
.pz-grid td { width: 1.6em; height: 1.6em; text-align: center; border: 1px solid var(--line); padding: 0; }
.pz-10 { font-size: clamp(14px, 4vw, 20px); } .pz-20 { font-size: clamp(8px, 2.3vw, 14px); }
.pz-sudoku { font-size: clamp(16px, 5vw, 24px); } .pz-sudoku td:nth-child(3n) { border-right: 2px solid var(--text); } .pz-sudoku tr:nth-child(3n) td { border-bottom: 2px solid var(--text); }
.pz-ready { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 16px; } .pz-preview { overflow-x: auto; }
.install-bar { position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 40; max-width: 520px; margin: 0 auto; display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 14px; background: var(--stage-2); color: var(--stage-ink); border: 2px solid var(--stage-line); box-shadow: var(--shadow); font-size: .95rem; }
.install-bar span { flex: 1; } .install-x { border: 0; background: none; color: inherit; font-size: 22px; min-width: 44px; min-height: 44px; cursor: pointer; }
