/* Shared by the word tools (Hangman Solver, Anagram Solver, Word Unscrambler
   and Word Finder): the page, the fields of letter tiles, the on-screen
   keyboard and the result panels, in the look of our games. Each tool adds
   its own pieces in its page. */
*, *::before, *::after { box-sizing: border-box; }
:root {
  color-scheme: dark;
  --cream: #f3f1eb;
  --ink: #2a2742;
  --orange: #f6ad55;
  --gold: #ffe6a3;
  --amber-soft: #f9e2b4;
  --key-bg: #4a5378;
  --key-bg-hover: #566089;
}
html { background: #3e3355; }
body { margin: 0; min-height: 100dvh; display: flex; flex-direction: column; background: linear-gradient(170deg, #212940, #2c2e48 50%, #3e3355); color: rgba(255,255,255,.92); font-family: 'DM Sans', sans-serif; }
button, input { font: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid #7ed5f0; outline-offset: 3px; }
[hidden] { display: none !important; }
main { flex: 1; width: 100%; }
h1, h2, h3, .chip, .tile, .key, .field-label, .tally, .count { font-family: 'Nunito', sans-serif; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

/* ── THE PAGE: the title, the fields and keyboard, then the results ── */
.solver { max-width: 640px; margin: 0 auto; padding: 30px 16px 0; }
.tool-head { margin-bottom: 18px; text-align: center; }
.tool-head h1 { margin: 0 0 8px; font-size: clamp(1.6rem, 5vw, 2.05rem); font-weight: 900; line-height: 1.2; }
.tool-intro { max-width: 820px; margin: 0 auto; color: #ffffffb5; line-height: 1.55; }
.game { display: flex; flex-direction: column; gap: 10px; }

/* ── FIELDS: tap one, then type on the keyboard ── */
.field { position: relative; padding: 10px 12px 14px; border-radius: 18px; background: #ffffff0a; box-shadow: inset 0 0 0 1.5px #ffffff10; cursor: pointer; container-type: inline-size; touch-action: manipulation; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; transition: background .18s, box-shadow .18s; }
.field.active { background: #ffffff0f; box-shadow: inset 0 0 0 2px #f6ad55b3, 0 0 0 4px #f6ad551f; }
.field:has(input:focus-visible) { outline: 3px solid #7ed5f0; outline-offset: 3px; }
.field-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 28px; margin-bottom: 8px; }
.field-label { color: #ffffff94; font-size: .74rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; cursor: pointer; }
.field.active .field-label { color: var(--amber-soft); }
.field-tools { display: flex; align-items: center; gap: 6px; }
.field-empty { color: #ffffff73; font-size: 1rem; text-align: center; }
.field-hint { margin: 10px 0 0; color: #ffffff80; font-size: .82rem; text-align: center; }
.tally { display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 11px; border: 0; border-radius: 999px; background: #ffffff17; color: #ffffffe0; font-size: .8rem; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tally.none { background: #f5656533; color: #fbb6b6; }
.tally.found { background: var(--gold); color: var(--ink); }
.clear-input { display: grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 50%; background: #ffffff14; color: #ffffffb3; font-size: 1.15rem; line-height: 1; }

/* ── LETTER TILES: cream for a letter, a dashed ? for a blank ── */
/* A row of tiles, sized so --len of them fit on a line. */
.tile-row {
  --gap: 6px;
  --len: 5;
  --tile: min(48px, calc((100vw - 76px - (var(--len) - 1) * var(--gap)) / var(--len)));
  --tile: min(48px, calc((100cqi - (var(--len) - 1) * var(--gap)) / var(--len)));
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center;
  gap: 10px var(--gap);
  min-height: calc(var(--tile) * 1.16);
}
.tile-row.long { --gap: 4px; }
.tile-row.ghost .tile { opacity: .3; }
.tile { position: relative; flex: none; display: grid; place-items: center; width: var(--tile); height: calc(var(--tile) * 1.16); padding: 0; border: 0; border-radius: calc(var(--tile) * .2); color: var(--ink); font-size: calc(var(--tile) * .58); font-weight: 900; line-height: 1; transition: background .2s, box-shadow .2s, transform .15s; }
.tile.shown { background: var(--cream); box-shadow: 0 2px 6px #0000002e, inset 0 -3px 0 #2a27421f, inset 0 1px 0 #ffffffb3; }
.tile.blank { --edge: 2px; background: #ffffff08; border: 2px dashed #ffffff47; color: #ffffff6b; font-size: calc(var(--tile) * .5); font-weight: 800; }
.tile.selected { transform: translateY(-3px); box-shadow: 0 0 0 3px var(--orange), 0 6px 14px #00000052; }
.tile.blank.selected { border-color: transparent; background: #f6ad5529; color: var(--amber-soft); }
.tile.caret-before::before, .tile.caret-after::after, .caret-slot { content: ''; position: absolute; top: 14%; bottom: 14%; width: 3px; border-radius: 2px; background: var(--orange); animation: caret 1.1s steps(1) infinite; }
.tile.caret-before::before { left: calc(var(--gap) / -2 - 1.5px - var(--edge, 0px)); }
.tile.caret-after::after { right: calc(var(--gap) / -2 - 1.5px - var(--edge, 0px)); }
.caret-slot { position: relative; top: auto; bottom: auto; height: calc(var(--tile) * .8); }
@keyframes caret { 50% { opacity: 0; } }
.tile.pop { animation: tilePop .42s cubic-bezier(.34, 1.6, .64, 1) backwards; }
@keyframes tilePop { 0% { transform: scale(.5); } 60% { transform: scale(1.14); } 100% { transform: scale(1); } }

/* ── THE KEYBOARD ── */
.keyboard { display: flex; flex-direction: column; gap: 7px; width: 100%; max-width: 540px; margin: 4px auto 0; user-select: none; -webkit-user-select: none; }
.key-row { display: flex; justify-content: center; gap: 6px; }
.key { position: relative; flex: 1; max-width: 46px; height: 50px; padding: 0; border: 0; border-radius: 9px; overflow: hidden; display: grid; place-items: center; background: var(--key-bg); color: #ffffffeb; font-size: 1.02rem; font-weight: 800; box-shadow: 0 2px 6px #00000040; transition: background-color .15s, color .15s, transform .1s, opacity .2s; touch-action: manipulation; }
.key > span { position: relative; display: grid; place-items: center; }
.key:active:not(:disabled) { transform: scale(.92); }
.key:disabled { cursor: default; }
.key.wide { flex: 1.5; max-width: 69px; }
/* The ? key looks like the blank it types. */
.key.blank-key { background: #ffffff0d; border: 2px dashed #ffffff5c; box-shadow: none; color: #ffffffbf; font-size: 1.25rem; }
.key.space { flex: 0 1 260px; max-width: 260px; height: 42px; color: #ffffffb3; font-size: .8rem; letter-spacing: .06em; }
.key.action { flex: 0 1 260px; max-width: 260px; height: 42px; background: linear-gradient(135deg, #48bb78, #2f855a); color: #fff; font-size: .9rem; letter-spacing: .04em; box-shadow: 0 4px 14px #2f855a59; }
.key.action:disabled { opacity: .45; box-shadow: none; }
.key.hit { background: #353c58; color: var(--cream); box-shadow: inset 0 0 0 1.5px #f3f1eb59; }
.key.miss { background: #4a3550; color: #fbb6b6; box-shadow: inset 0 0 0 1.5px #f5656580; }
.key.best { background: #38a169; color: #fff; box-shadow: 0 0 0 2px #c6f6d5, 0 0 16px 2px #48bb788c; animation: bestGlow 2.2s ease-in-out infinite; }
@keyframes bestGlow { 50% { box-shadow: 0 0 0 2px #c6f6d5, 0 0 24px 6px #48bb78b3; } }
.key.nope { animation: nope .32s ease; }
@keyframes nope { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

/* ── RESULTS ── */
.results { padding: 18px 0 60px; display: flex; flex-direction: column; gap: 14px; scroll-margin-top: 12px; }
.panel { padding: 22px; border-radius: 20px; background: #ffffff0b; }
.panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 15px; }
.panel-heading h2 { margin: 0; font-size: 1.08rem; font-weight: 800; overflow-wrap: anywhere; }
.pattern { margin-left: 6px; color: #ffffff8c; font-weight: 800; letter-spacing: .18em; white-space: nowrap; }
.count { flex-shrink: 0; padding: 3px 10px; border-radius: 20px; background: #ffffff12; font-size: .85rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; margin: 0; padding: 0; list-style: none; }
.chips li { display: flex; }
/* Common words look like cream tiles; rarer valid words stay quiet.
   Letters a blank stands for are orange. */
.chip { padding: 6px 10px; border: 0; border-radius: 8px; background: #ffffff10; color: #ffffffb8; font-size: .92rem; font-weight: 800; letter-spacing: .04em; }
.chip.common { background: var(--cream); color: var(--ink); box-shadow: 0 2px 0 #c9c5bf; }
.chip .blank { color: var(--orange); }
.chip.common .blank { color: #c05621; }
button.chip { cursor: pointer; }
.empty, .status, .note { margin: 0; color: #ffffffa8; line-height: 1.6; }
.status, .note { text-align: center; }
.note { color: #fac7ae; font-size: .88rem; }
.legend { margin: 2px 4px 0; color: #ffffff8c; font-size: .82rem; line-height: 1.6; text-align: center; }
.more-button { margin-top: 14px; padding: 8px 18px; border: 1px solid #ffffff24; border-radius: 100px; background: #ffffff12; color: #ffffffe6; font-size: .86rem; font-weight: 700; }
/* The best letters to guess: a tile, a bar for the odds and the odds
   themselves. Every row shares the same columns, so the bars line up. */
.odds-list { display: grid; gap: 9px; margin: 0; padding: 0; list-style: none; }
.odds-list li { display: grid; grid-template-columns: 52px 1fr 68px; align-items: center; gap: 12px; }
.odds-letter { justify-self: center; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 9px; background: #ffffff14; color: #ffffffd9; font-family: 'Nunito', sans-serif; font-size: 1.1rem; font-weight: 900; }
.odds-bar { height: 10px; border-radius: 6px; background: #ffffff12; overflow: hidden; }
.odds-bar span { display: block; width: var(--p); height: 100%; border-radius: 6px; background: #38a16999; }
.odds-value { color: #ffffffcc; font: 800 .92rem 'Nunito', sans-serif; font-variant-numeric: tabular-nums; text-align: right; }
/* The best letter sits on a green card with a bigger tile, bar and odds. */
.odds-list li.best { margin: 0 -12px 6px; padding: 12px; border-radius: 16px; background: linear-gradient(90deg, #38a16938, #38a1690d 75%); box-shadow: inset 0 0 0 1.5px #48bb7859; }
.odds-list li.best .odds-letter { width: 52px; height: 58px; border-radius: 13px; background: #38a169; color: #fff; font-size: 1.75rem; box-shadow: 0 3px 0 #276749, 0 8px 18px #38a1695c; }
.odds-list li.best .odds-bar { height: 14px; border-radius: 8px; background: #ffffff17; }
.odds-list li.best .odds-bar span { border-radius: 8px; background: linear-gradient(90deg, #38a169, #68d391); }
.odds-list li.best .odds-value { color: #c6f6d5; font-size: 1.4rem; }
.odds-note { margin: 14px 0 0; color: #ffffff8c; font-size: .84rem; }

@media (hover: hover) and (pointer: fine) {
  .more-button:hover, .clear-input:hover, .tally:hover, button.chip:hover { filter: brightness(1.15); }
  .key:not(:disabled):not(.hit):not(.miss):not(.best):not(.blank-key):not(.action):hover { background-color: var(--key-bg-hover); }
  .key.blank-key:hover { background: #ffffff1c; border-color: #ffffff8c; }
  .key.action:not(:disabled):hover { filter: brightness(1.08); }
  .field:not(.active):hover { background: #ffffff0f; }
}

/* ── ABOUT AND FOOTER ── */
.about-section { background: #00000038; border-top: 1px solid #ffffff0f; padding: 64px 24px 80px; }
.about-content { max-width: 720px; margin: auto; line-height: 1.7; color: #ffffffbf; }
.about-content h2 { font-size: 1.6rem; color: #fffffff0; margin: 0 0 18px; }
.about-content h3 { font-size: 1.15rem; color: #ffffffe6; margin: 34px 0 10px; }
.about-content h4 { font-family: 'Nunito', sans-serif; font-size: .98rem; color: #ffffffe6; margin: 0; }
.about-content p { margin: 0 0 14px; }
.about-content ul { margin: 0 0 14px; padding-left: 20px; }
.about-content li { margin-bottom: 8px; }
.about-content a { color: #4cf; text-underline-offset: 3px; }
.about-content strong { color: #f6ad55; }
/* A word written in the text as small tiles, like the board: cream for a
   letter, a dashed ? for a blank. */
.mini-tiles { display: inline-flex; gap: 3px; margin: 0 2px; vertical-align: middle; }
.mini-tiles span { display: grid; place-items: center; width: 22px; height: 25.5px; border-radius: 4.4px; background: var(--cream); box-shadow: 0 2px 6px #0000002e, inset 0 -3px 0 #2a27421f, inset 0 1px 0 #ffffffb3; color: var(--ink); font-family: 'Nunito', sans-serif; font-size: 12.8px; font-weight: 900; line-height: 1; }
.mini-tiles .blank { background: #ffffff08; border: 1.5px dashed #ffffff73; box-shadow: none; color: #ffffffb3; font-size: 12px; font-weight: 800; }
/* A ? (or *) to type, drawn like the blank tile it stands for. */
.qmark { display: inline-grid; place-items: center; min-width: 1.5em; height: 1.45em; padding: 0 .2em; border: 1.5px dashed #ffffff8c; border-radius: .35em; background: #ffffff12; color: #fff; font-family: 'Nunito', sans-serif; font-size: .9em; font-weight: 900; line-height: 1; vertical-align: .08em; }
.faq-item { margin-bottom: 10px; background: #0000002e; border: 1px solid #ffffff14; border-radius: 12px; }
.faq-item summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 16px; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: '+'; flex: none; font: 800 1.15rem/1 'Nunito', sans-serif; color: #ffffff8c; transition: transform .18s ease; }
.faq-item[open] summary::after { transform: rotate(45deg); }
.faq-item p { padding: 0 16px 14px; margin: 0; }
.site-footer { width: 100%; padding: 28px 24px 34px; background: #00000052; border-top: 1px solid #ffffff0f; text-align: center; font-family: 'Nunito', sans-serif; color: #ffffff8c; font-size: .84rem; letter-spacing: .04em; }
.site-footer a { color: #ffffffb3; text-decoration: none; }
.site-footer a:hover { color: #fffffff2; }
.site-footer-sep { margin: 0 12px; opacity: .42; }

/* ── SCREEN SIZES ── */
@media (max-width: 600px) {
  .solver { padding: 20px 10px 0; }
  .tool-head { margin-bottom: 14px; }
  .tool-intro { font-size: .94rem; }
  .key-row { gap: 5px; }
  .key { height: 48px; font-size: .98rem; }
  .key.space, .key.action { height: 40px; }
  .results { padding: 16px 0 48px; }
  .panel { padding: 18px; }
  .odds-list li { grid-template-columns: 46px 1fr 62px; gap: 10px; }
  .odds-list li.best { margin: 0 -10px 6px; padding: 10px; }
  .odds-list li.best .odds-letter { width: 46px; height: 52px; font-size: 1.55rem; }
  .odds-list li.best .odds-value { font-size: 1.2rem; }
}
/* Two columns on desktop: the fields and keyboard stay in view on the left
   while the results scroll on the right. */
@media (min-width: 1024px) {
  .solver { max-width: 966px; padding: 34px 24px 48px; display: grid; grid-template-columns: minmax(0, 480px) minmax(0, 1fr); column-gap: 32px; align-items: start; }
  .tool-head { grid-column: 1 / -1; margin-bottom: 24px; }
  .game { position: sticky; top: 16px; }
  .results { padding: 0; }
  .results:empty::before { content: attr(data-empty); display: block; padding: 40px 24px; border: 2px dashed #ffffff1a; border-radius: 20px; color: #ffffff73; line-height: 1.6; text-align: center; }
  .tally > span { display: none; }
}
@media (max-width: 370px) {
  .key-row { gap: 4px; }
  .key { height: 46px; border-radius: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
  .key.best, .tile.caret-before::before, .tile.caret-after::after, .caret-slot { animation: none; }
}
