.wsleuth {
    --bg: #ffffff;
    --surface: #ffffff;
    --surface-2: #ecebe7;
    --text: #1c1c1e;
    --muted: #6b6963;
    --border: #d8d5cc;
    --tile-border: #d3d0c7;
    --tile-border-strong: #85837c;
    --key: #dedbd2;
    --key-text: #1c1c1e;
    --key-edge: #b3afa3;
    --key-text-shadow: rgba(255, 255, 255, .45);
    --absent: #787c7e;
    --absent-edge: #545759;
    --present: #c9b458;
    --present-edge: #9a883a;
    --correct: #6aaa64;
    --correct-edge: #4a8245;
    --on-tile: #ffffff;
    --focus: #2f6fd6;
    --display: 'Libre Franklin', 'Helvetica Neue', Arial, sans-serif;
    --body: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --mono: 'IBM Plex Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;

    box-sizing: border-box;
    container-type: inline-size;
    background: var(--bg);
    color: var(--text);
    font-family: var(--body);
    font-size: 15px;
    line-height: 1.45;
    text-align: center;
    padding: 22px 16px 36px;
    border-radius: 10px;
    -webkit-font-smoothing: antialiased;
  }
  .wsleuth[data-theme="dark"], :root[data-theme="dark"] .wsleuth[data-theme="auto"] {
    --bg: #121213; --surface: #1b1b1d; --surface-2: #27272a; --text: #ecebe6; --muted: #9b9a94;
    --border: #3a3a3c; --tile-border: #3a3a3c; --tile-border-strong: #7c7c80;
    --key: #818384; --key-text: #ecebe6; --key-edge: #545657; --key-text-shadow: rgba(0, 0, 0, .3);
    --absent: #3a3a3c; --absent-edge: #1f1f21; --present: #b59f3b; --present-edge: #7f6f27;
    --correct: #538d4e; --correct-edge: #355e32; --focus: #7aa7f0;
  }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .wsleuth[data-theme="auto"] {
      --bg: #121213; --surface: #1b1b1d; --surface-2: #27272a; --text: #ecebe6; --muted: #9b9a94;
      --border: #3a3a3c; --tile-border: #3a3a3c; --tile-border-strong: #7c7c80;
      --key: #818384; --key-text: #ecebe6; --key-edge: #545657; --key-text-shadow: rgba(0, 0, 0, .3);
      --absent: #3a3a3c; --absent-edge: #1f1f21; --present: #b59f3b; --present-edge: #7f6f27;
      --correct: #538d4e; --correct-edge: #355e32; --focus: #7aa7f0;
    }
  }

  /* Neutralise theme styling inside the widget. */
  .wsleuth *, .wsleuth *::before, .wsleuth *::after { box-sizing: border-box; }
  .wsleuth button {
    all: unset; box-sizing: border-box; cursor: pointer; font-family: inherit; text-align: center;
    -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  }
  .wsleuth button:focus-visible, .wsleuth input:focus-visible, .wsleuth summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
  .wsleuth .ws-title, .wsleuth .ws-h2, .wsleuth p, .wsleuth ul, .wsleuth li { margin: 0; padding: 0; border: 0; text-decoration: none; }
  .wsleuth ul, .wsleuth li { list-style: none; }
  .wsleuth li::before, .wsleuth li::after { content: none; }
  .wsleuth strong, .wsleuth b { color: var(--text); font-weight: 600; }

  .wsleuth .ws-wrap { max-width: 1040px; margin: 0 auto; }

  .wsleuth .ws-header {
    display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center;
    padding-bottom: 16px; margin-bottom: 22px; border-bottom: 1px solid var(--border);
  }
  .wsleuth .ws-title { font-family: var(--display); font-weight: 800; font-size: 1.8rem; letter-spacing: -0.01em; margin: 0 0 4px; line-height: 1.1; color: var(--text); text-decoration: none; text-transform: none; }
  .wsleuth .ws-tag { color: var(--muted); margin: 0 auto; max-width: 52ch; text-wrap: pretty; font-size: 15px; }
  .wsleuth .ws-controls { display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap; }
  .wsleuth .ws-lens-label { font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
  .wsleuth .ws-btn {
    display: inline-block; border: 1px solid var(--border); background: var(--surface); color: var(--text);
    padding: 7px 12px; border-radius: 6px; font-size: .85rem; font-weight: 500; line-height: 1.3;
  }
  .wsleuth .ws-btn:hover { background: var(--surface-2); }

  .wsleuth .ws-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 340px); gap: 40px; align-items: start; }
  @media (max-width: 820px) { .wsleuth .ws-layout { grid-template-columns: 1fr; gap: 28px; } }
  @container (max-width: 760px) { .wsleuth .ws-layout { grid-template-columns: 1fr; gap: 28px; } }

  /* Board: tiles scale to the word length and the column width. */
  .wsleuth .ws-board-col { container-type: inline-size; min-width: 0; }
  .wsleuth .ws-board {
    --cols: 5; --gap: 6px;
    --tile: clamp(24px, calc((100vw - 56px - (var(--cols) - 1) * var(--gap)) / var(--cols)), 66px);
    display: grid; gap: var(--gap); width: fit-content; max-width: 100%; margin: 0 auto; border-radius: 4px;
  }
  @supports (width: 1cqw) { .wsleuth .ws-board { --tile: clamp(24px, calc((100cqw - (var(--cols) - 1) * var(--gap)) / var(--cols)), 66px); } }
  .wsleuth .ws-board:focus { outline: none; }
  @media (hover: hover) and (pointer: fine) {
    .wsleuth.nofocus .ws-board { outline: 2px dashed var(--tile-border-strong); outline-offset: 8px; cursor: text; }
  }
  .wsleuth .ws-row { display: grid; grid-template-columns: repeat(var(--cols), var(--tile)); gap: var(--gap); }
  .wsleuth .ws-tile {
    width: var(--tile); height: var(--tile); padding: 0;
    border: 2px solid var(--tile-border); border-radius: 2px; background: transparent;
    font-family: var(--display); font-weight: 800; font-size: calc(var(--tile) * .5); line-height: 1;
    text-transform: uppercase; color: var(--text);
    display: grid; place-items: center; cursor: default; user-select: none;
  }
  .wsleuth .ws-tile.u { border-color: var(--tile-border-strong); }
  .wsleuth .ws-row.full .ws-tile { cursor: pointer; }
  .wsleuth .ws-tile.a { background: var(--absent); border-color: var(--absent); color: var(--on-tile); }
  .wsleuth .ws-tile.p { background: var(--present); border-color: var(--present); color: var(--on-tile); }
  .wsleuth .ws-tile.c { background: var(--correct); border-color: var(--correct); color: var(--on-tile); }
  .wsleuth .ws-tile.pop { animation: ws-pop 110ms ease-out; }
  @keyframes ws-pop { from { transform: scale(1.12); } to { transform: scale(1); } }
  .wsleuth .ws-row.shake { animation: ws-shake 500ms ease-in-out; }
  @keyframes ws-shake {
    10%, 90% { transform: translateX(-2px); } 20%, 80% { transform: translateX(4px); }
    30%, 50%, 70% { transform: translateX(-6px); } 40%, 60% { transform: translateX(6px); }
  }
  .wsleuth .ws-hint { text-align: center; color: var(--muted); font-size: .88rem; margin: 14px auto 0; min-height: 2.6em; max-width: 34ch; text-wrap: balance; }

  /* Keyboard: keycaps with a lit face, a darker edge below, and a press that sinks onto it. */
  .wsleuth .ws-kb { margin-top: 18px; display: grid; gap: 9px; padding-bottom: 5px; }
  .wsleuth .ws-kb-row { display: flex; justify-content: center; gap: 6px; }
  .wsleuth .ws-key {
    --cap: var(--key); --edge: var(--key-edge); --cap-text: var(--key-text); --cap-text-shadow: var(--key-text-shadow);
    display: flex; align-items: center; justify-content: center;
    height: 54px; flex: 1 0 0; max-width: 46px; min-width: 0; padding: 0; border: 0; border-radius: 6px;
    background-color: var(--cap);
    background-image: linear-gradient(180deg, rgba(255, 255, 255, .24), rgba(255, 255, 255, 0) 55%, rgba(0, 0, 0, .07));
    color: var(--cap-text); text-shadow: 0 1px 0 var(--cap-text-shadow);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .4), inset 0 -1px 0 rgba(0, 0, 0, .1),
                0 3px 0 var(--edge), 0 5px 5px rgba(0, 0, 0, .22);
    transform: translateY(0);
    transition: transform 70ms ease, box-shadow 70ms ease;
    font-family: var(--display); font-weight: 600; font-size: .95rem; line-height: 1; text-transform: uppercase; cursor: pointer;
  }
  .wsleuth .ws-key:hover { background-image: linear-gradient(180deg, rgba(255, 255, 255, .32), rgba(255, 255, 255, .06) 55%, rgba(0, 0, 0, .05)); }
  .wsleuth .ws-key:active, .wsleuth .ws-key.down {
    transform: translateY(3px);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), inset 0 -1px 0 rgba(0, 0, 0, .1),
                0 0 0 var(--edge), 0 1px 1px rgba(0, 0, 0, .25);
  }
  .wsleuth .ws-key.wide { flex: 1.55 0 0; max-width: 72px; font-size: .72rem; letter-spacing: .04em; }
  .wsleuth .ws-key.a, .wsleuth .ws-key.p, .wsleuth .ws-key.c { --cap-text: var(--on-tile); --cap-text-shadow: rgba(0, 0, 0, .25); }
  .wsleuth .ws-key.a { --cap: var(--absent); --edge: var(--absent-edge); }
  .wsleuth .ws-key.p { --cap: var(--present); --edge: var(--present-edge); }
  .wsleuth .ws-key.c { --cap: var(--correct); --edge: var(--correct-edge); }
  .wsleuth .ws-legend { display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; margin-top: 14px; color: var(--muted); font-size: .8rem; }
  .wsleuth .ws-legend span { display: inline-flex; align-items: center; gap: 6px; }
  .wsleuth .ws-legend i { width: 12px; height: 12px; border-radius: 2px; display: inline-block; }

  /* Panel */
  .wsleuth .ws-panel-col { min-width: 0; }
  .wsleuth .ws-status { display: flex; align-items: baseline; justify-content: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; min-height: 2.4rem; }
  .wsleuth .ws-num { font-family: var(--display); font-weight: 800; font-size: 2.1rem; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; color: var(--text); }
  .wsleuth .ws-lbl { color: var(--muted); font-size: .95rem; }
  .wsleuth .ws-solved { display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap; }
  .wsleuth .ws-mini { display: inline-flex; flex-wrap: wrap; justify-content: center; gap: 4px; }
  .wsleuth .ws-mini span {
    width: 30px; height: 30px; display: grid; place-items: center; background: var(--correct); color: var(--on-tile);
    font-family: var(--display); font-weight: 800; font-size: 1rem; text-transform: uppercase; border-radius: 2px;
  }

  .wsleuth .ws-section + .ws-section { margin-top: 20px; }
  .wsleuth .ws-sec-head { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 8px; }
  .wsleuth .ws-h2 { font-family: var(--body); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); margin: 0; line-height: 1.3; }
  .wsleuth .ws-seg { display: inline-flex; flex-wrap: wrap; justify-content: center; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; background: var(--surface); }
  .wsleuth .ws-seg button { display: inline-block; border: 0; background: transparent; padding: 5px 10px; font-size: .8rem; font-weight: 500; line-height: 1.3; color: var(--muted); }
  .wsleuth .ws-seg button + button { border-left: 1px solid var(--border); }
  .wsleuth .ws-seg button[aria-pressed="true"] { background: var(--text); color: var(--bg); }
  .wsleuth .ws-lens button { padding: 6px 10px; font-family: var(--display); font-weight: 700; font-size: .9rem; min-width: 34px; }

  .wsleuth .ws-sugg { list-style: none; margin: 0 auto; padding: 0; display: grid; gap: 1px; max-width: 360px; }
  .wsleuth .ws-sugg button {
    display: grid; grid-template-columns: 1.1rem 9px auto minmax(20px, 1fr) auto; align-items: center; gap: 8px;
    width: 100%; padding: 4px 8px; border: 0; border-radius: 6px; background: transparent; color: var(--text);
    text-align: center; font-size: inherit; line-height: 1.3;
  }
  .wsleuth .ws-sugg button:hover { background: var(--surface-2); }
  .wsleuth .ws-rank { font-family: var(--mono); font-size: .78rem; color: var(--muted); }
  .wsleuth .ws-poss { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--muted); opacity: .55; justify-self: center; }
  .wsleuth .ws-poss.yes { background: var(--correct); border-color: var(--correct); opacity: 1; }
  .wsleuth .ws-word { font-family: var(--display); font-weight: 700; font-size: .95rem; letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; }
  .wsleuth .ws-bar { height: 5px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
  .wsleuth .ws-bar i { display: block; height: 100%; background: var(--correct); border-radius: 4px; }
  .wsleuth .ws-meta { font-family: var(--mono); font-size: .74rem; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
  .wsleuth .ws-note { color: var(--muted); font-size: .8rem; margin: 10px auto 0; max-width: 60ch; text-align: center; text-wrap: balance; }
  .wsleuth .ws-note .ws-poss { display: inline-block; vertical-align: middle; margin-right: 4px; }
  .wsleuth .ws-empty { color: var(--muted); font-size: .9rem; padding: 8px 0; text-align: center; }

  .wsleuth .ws-find {
    display: block; width: 100%; max-width: 200px; margin: 0 auto; padding: 6px 10px; box-sizing: border-box; min-height: 0; height: auto;
    border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); box-shadow: none;
    font: inherit; font-size: .85rem; line-height: 1.3; text-align: center; -webkit-appearance: none; appearance: none;
  }
  .wsleuth .ws-find::placeholder { color: var(--muted); }
  .wsleuth .ws-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; max-height: 170px; overflow: auto; padding: 2px; }
  .wsleuth .ws-chip {
    display: inline-block; font-family: var(--display); font-weight: 600; font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; line-height: 1.3;
    padding: 4px 8px; border-radius: 4px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  }
  .wsleuth .ws-chip:hover { border-color: var(--tile-border-strong); }

  .wsleuth .ws-details { margin-top: 26px; border-top: 1px solid var(--border); padding-top: 12px; text-align: center; }
  .wsleuth .ws-details summary { cursor: pointer; font-size: .85rem; font-weight: 500; color: var(--muted); list-style-position: inside; }
  .wsleuth .ws-opts { display: grid; gap: 10px; margin-top: 12px; font-size: .9rem; justify-items: center; }
  .wsleuth .ws-opts label { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; text-align: center; max-width: 44ch; margin: 0; color: var(--text); font-weight: 400; }
  .wsleuth .ws-opts input { margin: 3px 0 0; accent-color: var(--correct); flex: none; width: auto; }
  .wsleuth .ws-opts small { display: block; color: var(--muted); font-size: .85em; }
  .wsleuth .ws-footer { margin-top: 36px; color: var(--muted); font-size: .8rem; border-top: 1px solid var(--border); padding-top: 12px; text-align: center; }
  .wsleuth .ws-credit { margin: 28px auto 0; color: var(--muted); font-size: .75rem; text-align: center; max-width: 64ch; text-wrap: balance; }

  /* Before the first word is entered, the widget is just the grid, the hint and the keyboard. */
  .wsleuth.pre .ws-legend, .wsleuth.pre .ws-panel-col, .wsleuth.pre .ws-footer { display: none; }
  .wsleuth.pre .ws-layout { grid-template-columns: minmax(0, 1fr); }

  @media (prefers-reduced-motion: reduce) { .wsleuth .ws-tile.pop, .wsleuth .ws-row.shake { animation: none; } .wsleuth .ws-key { transition: none; } }
