/* Layout: one narrow column, header → board → keyboard; result card slides in under the board. */
:root {
  --bg: #F2F3F8;
  --surface: #FFFFFF;
  --fg: #171A2E;
  --muted: #5D6178;
  --line: #D5D8E5;
  --key: #DFE2EE;
  --key-fg: #171A2E;
  --miss: #7C8098;
  --tile-empty: #FFFFFF;
  --hit: #4A4FD6;
  --near: #E09A2D;
  --flame: #F06A2A;
  --font-display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", sans-serif;
  --font-body: "Figtree", "Segoe UI", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11131F; --surface: #1A1D2D; --fg: #ECEEF7; --muted: #A0A4BC; --line: #33374D;
    --key: #3A3E57; --key-fg: #ECEEF7; --miss: #44485F; --tile-empty: #161927; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #11131F; --surface: #1A1D2D; --fg: #ECEEF7; --muted: #A0A4BC; --line: #33374D;
  --key: #3A3E57; --key-fg: #ECEEF7; --miss: #44485F; --tile-empty: #161927; color-scheme: dark;
}
:root[data-palette="ocean"] { --hit: #0F7C8C; --near: #D9A632; }
:root[data-palette="ember"] { --hit: #C8432B; --near: #3F7FBF; }
:root[data-palette="forest"] { --hit: #2E7D4F; --near: #C79A1E; }
:root[data-palette="gold"] { --hit: #A97A08; --near: #7A5AC8; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { background: var(--bg); color: var(--fg); font-family: var(--font-body); font-size: 16px; line-height: 1.5; }
.ws-app { max-width: 500px; margin: 0 auto; padding-inline: 16px; padding-block: 8px 24px; display: flex; flex-direction: column; gap: 14px; }

.ws-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-block: 6px; border-bottom: 1px solid var(--line); }
.ws-brand { display: flex; flex-direction: column; min-width: 0; }
.ws-logo { font-family: var(--font-display); font-weight: 800; font-size: 1.6rem; letter-spacing: -0.02em; line-height: 1.1; margin: 0; }
.ws-logo span { color: var(--flame); }
.ws-meta { font-size: 0.8rem; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; font-variant-numeric: tabular-nums; }
.ws-actions { display: flex; gap: 6px; }
.ws-icon-btn { font: inherit; border: 1px solid var(--line); background: var(--surface); color: var(--fg); border-radius: 999px; min-width: 40px; height: 40px; padding-inline: 12px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 4px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ws-icon-btn:hover { border-color: var(--muted); }
.ws-streak-pill .flame { color: var(--flame); }

.ws-board { display: grid; grid-template-rows: repeat(6, 1fr); gap: 6px; width: min(100%, 310px); margin: 0 auto; }
.ws-row { display: grid; grid-template-columns: repeat(var(--cols, 5), 1fr); gap: 6px; }
.ws-row.shake { animation: shake 0.4s; }
.ws-tile { aspect-ratio: 1; max-width: 100%; display: flex; align-items: center; justify-content: center; font-family: var(--font-display); font-weight: 800; font-size: 1.9rem; text-transform: uppercase; border: 2px solid var(--line); background: var(--tile-empty); color: var(--fg); border-radius: 6px; user-select: none; }
.ws-tile.filled { border-color: var(--muted); animation: pop 0.1s; }
.ws-tile.hit, .ws-tile.near, .ws-tile.miss { color: #fff; border-color: transparent; }
.ws-tile.hit { background: var(--hit); }
.ws-tile.near { background: var(--near); }
.ws-tile.miss { background: var(--miss); }
.ws-tile.flip { animation: flip 0.5s ease both; }

.ws-keyboard { display: flex; flex-direction: column; gap: 7px; user-select: none; }
.ws-krow { display: flex; gap: 5px; justify-content: center; }
.ws-key { font-family: var(--font-body); font-weight: 700; font-size: 0.95rem; flex: 1 1 0; min-width: 0; max-width: 44px; height: 54px; border: none; border-radius: 6px; background: var(--key); color: var(--key-fg); cursor: pointer; text-transform: uppercase; touch-action: manipulation; }
.ws-key.wide { max-width: 68px; flex: 1.5 1 0; font-size: 0.75rem; }
.ws-key.hit, .ws-key.near, .ws-key.miss { color: #fff; }
.ws-key.hit { background: var(--hit); }
.ws-key.near { background: var(--near); }
.ws-key.miss { background: var(--miss); }
.ws-key:focus-visible, .ws-icon-btn:focus-visible, .ws-btn:focus-visible { outline: 3px solid var(--flame); outline-offset: 2px; }

.ws-result { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.ws-result h2 { font-family: var(--font-display); font-size: 1.35rem; margin: 0; text-wrap: balance; }
.ws-word { font-family: var(--font-display); font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: var(--hit); }
.ws-def { margin: 0; color: var(--fg); }
.ws-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 700; }
.ws-row-btns { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ws-btn { font: inherit; font-weight: 700; border: none; border-radius: 999px; padding: 10px 18px; cursor: pointer; background: var(--hit); color: #fff; }
.ws-btn.ghost { background: transparent; color: var(--fg); border: 1px solid var(--line); }
.ws-countdown { font-variant-numeric: tabular-nums; font-family: var(--font-display); font-weight: 700; font-size: 1.2rem; }
.ws-yesterday { border-top: 1px dashed var(--line); padding-top: 10px; font-size: 0.92rem; color: var(--muted); }
.ws-yesterday strong { color: var(--fg); text-transform: uppercase; letter-spacing: 0.08em; }

.ws-ad { border: 1px dashed var(--line); border-radius: 8px; min-height: 90px; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; }

.ws-toast { position: fixed; left: 50%; top: calc(env(safe-area-inset-top, 0px) + 10px); transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 8px; font-weight: 700; z-index: 50; }

.ws-overlay { position: fixed; inset: 0; background: rgba(10, 12, 24, 0.55); display: flex; align-items: flex-start; justify-content: center; z-index: 40; padding-inline: 16px; padding-block: calc(env(safe-area-inset-top, 0px) + 40px) 24px; overflow-y: auto; }
.ws-modal { background: var(--surface); color: var(--fg); border-radius: 14px; width: 100%; max-width: 440px; padding: 20px; display: flex; flex-direction: column; gap: 14px; position: relative; }
.ws-modal h2 { font-family: var(--font-display); margin: 0; font-size: 1.4rem; }
.ws-modal h3 { margin: 0; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.ws-close { position: absolute; top: 12px; right: 12px; }
.ws-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; }
.ws-stat b { display: block; font-family: var(--font-display); font-size: 1.7rem; font-variant-numeric: tabular-nums; line-height: 1.1; }
.ws-stat span { font-size: 0.72rem; color: var(--muted); }
.ws-dist { display: flex; flex-direction: column; gap: 4px; font-variant-numeric: tabular-nums; font-size: 0.85rem; }
.ws-dist-row { display: grid; grid-template-columns: 14px 1fr; gap: 8px; align-items: center; }
.ws-bar { background: var(--miss); color: #fff; text-align: right; padding-inline: 6px; border-radius: 3px; min-width: 22px; font-weight: 700; }
.ws-bar.today { background: var(--hit); }
.ws-badges { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ws-badge { border: 1px solid var(--line); border-radius: 10px; padding: 10px 6px; text-align: center; font-size: 0.78rem; display: flex; flex-direction: column; gap: 2px; }
.ws-badge b { font-family: var(--font-display); font-size: 1.15rem; }
.ws-badge.locked { opacity: 0.45; }
.ws-badge.earned { border-color: var(--flame); }
.ws-palettes { display: flex; flex-wrap: wrap; gap: 8px; }
.ws-swatch { font: inherit; font-size: 0.8rem; font-weight: 700; border: 2px solid var(--line); background: var(--bg); color: var(--fg); border-radius: 999px; padding: 6px 12px 6px 6px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.ws-swatch i { width: 18px; height: 18px; border-radius: 50%; display: inline-block; }
.ws-swatch[aria-pressed="true"] { border-color: var(--fg); }
.ws-swatch:disabled { opacity: 0.45; cursor: not-allowed; }
.ws-ex { display: flex; gap: 4px; }
.ws-ex .ws-tile { width: 38px; font-size: 1.2rem; }
.ws-modal p, .ws-modal ul { margin: 0; }
.ws-fallback { width: 100%; min-height: 110px; font: inherit; font-size: 0.85rem; background: var(--bg); color: var(--fg); border: 1px solid var(--line); border-radius: 8px; padding: 8px; }

@keyframes flip { 0% { transform: rotateX(0); } 50% { transform: rotateX(90deg); } 100% { transform: rotateX(0); } }
@keyframes pop { 50% { transform: scale(1.08); } }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
@media (prefers-reduced-motion: reduce) { .ws-tile.flip, .ws-tile.filled, .ws-row.shake { animation: none; } }
@media (max-width: 380px) { .ws-key { height: 48px; font-size: 0.85rem; } .ws-tile { font-size: 1.5rem; } }

.tf-cluecard { display: flex; flex-direction: column; gap: 8px; align-items: center; text-align: center; padding-block: 4px 2px; }
.tf-clue { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: 1.3rem; line-height: 1.25; text-wrap: balance; }
.tf-slots { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; }
.tf-slot { display: flex; gap: 3px; padding: 4px; border-radius: 8px; border: 2px solid transparent; }
.tf-slot.active { border-color: var(--hit); }
.tf-slot span { width: 26px; height: 30px; border-bottom: 3px solid var(--line); display: flex; align-items: center; justify-content: center; font-family: var(--font-display); font-weight: 800; text-transform: uppercase; font-size: 1rem; }
.tf-slot.active span { border-bottom-color: var(--hit); }
.tf-slot.solved span { border-bottom-color: var(--hit); color: var(--hit); }
.tf-slot.revealed span { border-bottom-color: var(--miss); color: var(--muted); }
.tf-plus { font-family: var(--font-display); font-size: 1.3rem; color: var(--flame); }
.tf-stage { font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; }
.ws-board[style*="--cols: 6"] .ws-tile, .ws-board[style*="--cols:6"] .ws-tile { font-size: 1.6rem; }
@media (max-width: 380px) { .tf-slot span { width: 22px; height: 26px; font-size: 0.9rem; } }

.ws-footer { max-width: 500px; margin: 0 auto; padding-inline: 16px; padding-block: 8px 32px; display: flex; flex-wrap: wrap; gap: 6px 16px; justify-content: center; font-size: 0.85rem; color: var(--muted); }
.ws-footer a { color: var(--muted); }
.ws-footer a:hover { color: var(--fg); }
.ws-page { max-width: 680px; margin: 0 auto; padding-inline: 16px; padding-block: 8px 24px; display: flex; flex-direction: column; gap: 18px; }
.ws-page .ws-header a { color: inherit; text-decoration: none; }
.ws-page article { display: flex; flex-direction: column; gap: 14px; max-width: 65ch; }
.ws-page h1.page-title { font-family: var(--font-display); font-size: 2rem; margin: 0; letter-spacing: -0.02em; text-wrap: balance; }
.ws-page h2 { font-family: var(--font-display); font-size: 1.2rem; margin: 8px 0 0; }
.ws-page p, .ws-page ul { margin: 0; }
.ws-page a { color: var(--hit); }
.ws-play { align-self: flex-start; text-decoration: none; }
.ws-arch { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 0; }
.ws-arch li { display: grid; grid-template-columns: 4.5rem 9rem 1fr; gap: 12px; padding-block: 12px; border-bottom: 1px solid var(--line); align-items: baseline; }
.ws-arch .n { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 0.85rem; }
.ws-arch .w { font-family: var(--font-display); font-weight: 800; text-transform: uppercase; letter-spacing: 0.1em; color: var(--hit); }
.ws-arch .d { min-width: 0; }
@media (max-width: 480px) { .ws-arch li { grid-template-columns: 1fr; gap: 2px; } }
