:root {
  --bg: #f6f5f1;
  --panel: #ffffff;
  --ink: #1c1c1e;
  --muted: #6b6b70;
  --line: #2b2b2e;
  --block: #1f1f22;
  --word: #cfe3ff;
  --cur: #ffe27a;
  --accent: #2f5bea;
  --cell: 40px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17171a; --panel: #222226; --ink: #ecebe6; --muted: #9a9aa2;
    --line: #8a8a92; --block: #0b0b0d; --word: #2b3f66; --cur: #8a6d00; --accent: #7fa0ff;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.4 system-ui, -apple-system, Segoe UI, Roboto, sans-serif; }

header {
  display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: flex-end;
  padding: 12px 16px; background: var(--panel); border-bottom: 1px solid rgba(128,128,128,.25);
}
header h1 { margin: 0 8px 0 0; font-size: 20px; align-self: center; }
.field { display: flex; flex-direction: column; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.field select, .field input { margin-top: 3px; font: inherit; font-size: 15px; text-transform: none; letter-spacing: 0; color: var(--ink); background: var(--bg); border: 1px solid rgba(128,128,128,.4); border-radius: 6px; padding: 6px 8px; min-width: 160px; }
.status { margin-left: auto; display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); align-self: center; }
.status i { width: 9px; height: 9px; border-radius: 50%; background: #3cb44b; display: inline-block; }
.status.offline i { background: #e6194b; }

.banner { margin: 12px 16px 0; padding: 10px 14px; border-radius: 8px; background: #fff3cd; color: #5c4400; }
.banner.ok { background: #d6f5dc; color: #11521f; font-weight: 600; }
.banner.err { background: #fde2e2; color: #7a1010; }

main { display: flex; flex-wrap: wrap; gap: 20px; padding: 16px; align-items: flex-start; }
.left { flex: 1 1 360px; min-width: 0; }
.right { flex: 1 1 320px; min-width: 260px; }

.clue-bar { background: var(--panel); border-left: 5px solid var(--accent); border-radius: 6px; padding: 10px 14px; margin-bottom: 14px; min-height: 44px; font-size: 16px; }
.clue-bar b { margin-right: 6px; }

.grid-wrap { padding: 22px 6px 6px 6px; overflow-x: auto; }
.grid { display: grid; grid-template-columns: repeat(var(--cols), var(--cell)); grid-auto-rows: var(--cell); width: max-content; border: 2px solid var(--line); background: var(--line); gap: 1px; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.cell { position: relative; background: var(--panel); cursor: pointer; }
.cell.block { background: var(--block); cursor: default; }
.cell.word { background: var(--word); }
.cell.cur { background: var(--cur); }
.cell .num { position: absolute; top: 1px; left: 3px; font-size: calc(var(--cell) * .24); line-height: 1; color: var(--muted); pointer-events: none; }
.cell .val { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding-top: calc(var(--cell) * .12); font-size: calc(var(--cell) * .56); font-weight: 600; pointer-events: none; }
.cell.wrong .val { color: #e6194b; text-decoration: line-through; }
.cell.remote { box-shadow: inset 0 0 0 3px var(--rc); z-index: 1; }
.cell.remote.word-remote:not(.cur):not(.word) { background: color-mix(in srgb, var(--rc) 18%, var(--panel)); }
.cell .tag { position: absolute; bottom: 100%; left: -1px; padding: 1px 5px; font-size: 11px; line-height: 1.3; color: #fff; border-radius: 4px 4px 4px 0; white-space: nowrap; pointer-events: none; z-index: 5; }

.actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 12px; }
button { font: inherit; padding: 7px 14px; border-radius: 6px; border: 1px solid rgba(128,128,128,.5); background: var(--panel); color: var(--ink); cursor: pointer; }
button:hover { border-color: var(--accent); }
.users { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; background: var(--panel); border: 1px solid rgba(128,128,128,.3); font-size: 13px; }
.chip i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

.clues { display: flex; gap: 20px; }
.clue-col { flex: 1 1 0; min-width: 0; }
.clue-col h2 { margin: 0 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.clue-col ol { list-style: none; margin: 0; padding: 0; max-height: 70vh; overflow-y: auto; }
.clue-col li { display: flex; gap: 8px; padding: 5px 8px; border-radius: 6px; cursor: pointer; }
.clue-col li:hover { background: rgba(128,128,128,.12); }
.clue-col li.active { background: var(--word); }
.clue-col li.cur { background: var(--cur); }
.clue-col li .n { font-weight: 700; min-width: 1.6em; text-align: right; }
.clue-col li .dots { margin-left: auto; display: flex; gap: 3px; align-items: center; }
.clue-col li .dots i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

.kbd { position: fixed; left: -1000px; top: 0; width: 1px; height: 1px; opacity: 0; }

@media (max-width: 720px) {
  .clues { flex-direction: column; }
  .clue-col ol { max-height: 30vh; }
}
