:root {
  --bg: #ffffff;
  --outer: #ffffff;
  --text: #1d2226;
  --muted: #5e6670;
  --surface: #f3f2ef;
  --pill: #e6e4df;
  --pill-text: #4a5058;
  --line: #cfccc5;
  --frame: #b9b6af;
  --cell: #eceae5;
  --grid: rgba(0, 0, 0, .08);
  --blocked: #8a8a8a;
  --letter: #1d2226;
  --on-pill: #14181c;
  --ok: #1a9a78;
  --accent: #0a66c2;
  --accent-text: #fff;
  --results-bg: #1d2226;
  --results-text: #fff;
  --c0: #00b4d8; --c1: #f58a00; --c2: #a259e6; --c3: #4fbf1a; --c4: #f43f6e; --c5: #6b6bf2;
}
@media (prefers-color-scheme: dark) {
  :root {
    --outer: #000; --bg: #1b1f23; --text: #f1f3f5; --muted: #9aa4af; --surface: #23282d; --pill: #34383d; --pill-text: #8d949c;
    --line: #3a4046; --frame: #e8e8e8; --cell: #20252a; --grid: rgba(255, 255, 255, .08); --blocked: #6b6b6b;
    --letter: #f1f3f5; --ok: #38d9a9; --accent: #70b5f9; --accent-text: #0b1f33;
    --results-bg: #c4c5c7; --results-text: #14181c;
  }
}
/* Region tint behind each word: its colour mixed into the page background. */
:root { --t0: color-mix(in srgb, var(--c0) 30%, var(--bg)); --t1: color-mix(in srgb, var(--c1) 30%, var(--bg));
        --t2: color-mix(in srgb, var(--c2) 30%, var(--bg)); --t3: color-mix(in srgb, var(--c3) 30%, var(--bg));
        --t4: color-mix(in srgb, var(--c4) 30%, var(--bg)); --t5: color-mix(in srgb, var(--c5) 30%, var(--bg)); }

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--outer); color: var(--text); }
body { font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }

.app { max-width: 480px; min-height: 100vh; margin: 0 auto; padding: 0 16px 24px; padding-bottom: calc(24px + env(safe-area-inset-bottom)); background: var(--bg); border-radius: 16px 16px 0 0; }

.top { position: relative; display: flex; align-items: center; justify-content: space-between; height: 46px; margin-bottom: 13px; }
.top .left, .top .right { display: flex; align-items: center; gap: 4px; }
.top .right { justify-self: end; gap: 0; }
h1 { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); margin: 0; font-size: 28px; font-weight: 800; letter-spacing: -0.01em; }
.timer-wrap { display: flex; align-items: center; gap: 6px; margin-left: 2px; color: var(--text); }
.timer { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.icon-btn { width: 40px; height: 40px; border: 0; background: transparent; color: var(--text); cursor: pointer; display: grid; place-items: center; border-radius: 50%; padding: 0; }
.icon-btn.muted { color: var(--pill-text); }
.icon-btn:disabled { opacity: .6; cursor: default; }

.frame { position: relative; padding: 3px; background: var(--frame); border-radius: 12px; touch-action: none; margin-top: 0; }
.board { display: block; width: 100%; height: auto; border-radius: 9px; overflow: hidden; user-select: none; -webkit-user-select: none; background: var(--frame); }
.board > *:not(.tile), .board text, .board g { pointer-events: none; }
.board .tile { stroke: var(--grid); stroke-width: 1; }
.board .tile.blocked { stroke: none; }
.board .tile.blocked { stroke: none; }
.board .pill-path { fill: none; stroke-width: 64; stroke-linecap: round; stroke-linejoin: round; }
.board .pill-dot { stroke: none; }
.board .ring { fill: none; stroke-width: 3; }
.board .chev { fill: none; stroke: var(--on-pill); stroke-opacity: .55; stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.board .letter { font: 800 46px system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; text-anchor: middle; dominant-baseline: central; fill: var(--letter); }
.board .letter.on { fill: var(--on-pill); }
.board .badge-bg { fill: var(--bg); stroke-width: 5; }
.board .badge-check { fill: none; stroke: var(--ok); stroke-width: 6; stroke-linecap: round; stroke-linejoin: round; }
.board .hint-ring { fill: none; stroke: var(--accent); stroke-width: 6; stroke-dasharray: 14 10; }
.board .trace { opacity: .9; }
.board .shake { animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
@media (prefers-reduced-motion: reduce) { .board .shake { animation: none; } }

.toast {
  position: absolute; left: 50%; top: calc(100% + 8px); transform: translateX(-50%); z-index: 2; padding: 6px 14px;
  background: var(--text); color: var(--bg); border-radius: 999px; font-size: 14px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity .15s; white-space: nowrap;
}
.toast.show { opacity: 1; }

.current { height: 30px; margin: 22px 0 0; text-align: center; font-size: 18px; font-weight: 800; letter-spacing: .14em; }

.slots { display: flex; flex-direction: column; gap: 2px; align-items: flex-start; min-height: 40px; }
.slot { display: flex; align-items: center; gap: 2px; padding: 0; border: 0; background: none; font: inherit; color: inherit; cursor: default; }
.slot .cell { width: 22px; height: 22px; border-radius: 5px; background: var(--pill); display: grid; place-items: center; font-weight: 800; font-size: 14px; line-height: 1; color: var(--on-pill); }
.slot.filled { cursor: pointer; }
.slot .check { width: 16px; height: 16px; margin-left: 8px; color: var(--ok); }

.actions { display: flex; gap: 8px; margin-top: 16px; }
.pill { flex: 1; height: 32px; border-radius: 999px; border: 0; background: var(--pill); color: var(--pill-text); font: inherit; font-weight: 700; font-size: 15px; cursor: pointer; padding: 0; }
.pill:hover:not(:disabled) { color: var(--text); }
.pill:disabled { cursor: default; }

.how { margin-top: 16px; border: 1px solid var(--line); border-radius: 6px; padding: 0 16px; }
.how summary { min-height: 46px; display: flex; align-items: center; justify-content: space-between; font-weight: 700; font-size: 16px; cursor: pointer; list-style: none; }
.how summary::-webkit-details-marker { display: none; }
.how summary::after { content: ""; width: 10px; height: 10px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); margin-right: 4px; transition: transform .15s; }
.how[open] summary::after { transform: rotate(-135deg); }
.how ul { margin: 0 0 14px; padding-left: 20px; color: var(--muted); font-size: 15px; }

.results { display: block; width: 100%; margin-top: 8px; height: 47px; border: 0; border-radius: 999px; background: var(--results-bg); color: var(--results-text); font: inherit; font-weight: 800; font-size: 19px; cursor: pointer; padding: 0; }
.results:disabled { opacity: .55; cursor: default; }
.foot { color: var(--muted); font-size: 12px; text-align: center; margin-top: 18px; }

button:focus-visible, summary:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

dialog { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--text); max-width: min(92vw, 420px); padding: 20px; }
dialog::backdrop { background: rgba(0, 0, 0, .6); }
dialog h2 { margin-top: 0; }
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.modes button, .dlg-actions button { min-height: 44px; padding: 8px 14px; border-radius: 999px; border: 0; background: var(--pill); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; width: 100%; }
.modes button.active, button.primary { background: var(--accent); color: var(--accent-text); }
.dlg-actions { display: flex; gap: 8px; }
.dlg-actions form { flex: 1; display: flex; }
.share { background: var(--bg); padding: 12px; border-radius: 10px; white-space: pre-wrap; font: 14px/1.5 ui-monospace, monospace; }
