:root {
  --bg: #f4f2ec;
  --panel: #ffffff;
  --ink: #1a1b1f;
  --muted: #676a72;
  --line: #d9d6cd;
  --block: #1a1b1f;
  --square: #ffffff;
  --mine: #fff2b8;
  --word: #dbe7ff;
  --waiting: #ffe0bf;
  --solved: #c9f0d6;
  --solved-ink: #13693a;
  --accent: #2f5bea;
  --warn: #a35a00;
  --ok: #1d7a46;
  --bad: #b3261e;
  --flash: #ffd166;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111215;
    --panel: #1a1b1f;
    --ink: #eeede8;
    --muted: #9b9ea6;
    --line: #2d2f35;
    --block: #050506;
    --square: #3b3e47;
    --mine: #6b5d1e;
    --word: #2f4a80;
    --waiting: #6e4618;
    --solved: #1f5a37;
    --solved-ink: #7fdca2;
    --accent: #7b96ff;
    --warn: #e2a54d;
    --ok: #5cc98a;
    --bad: #f08a80;
    --flash: #8a6a12;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

.top, .game, .foot { max-width: 1080px; margin: 0 auto; padding: 0 16px; }

.top {
  display: flex; align-items: center; gap: 12px;
  padding-top: 18px; padding-bottom: 14px;
}
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; }
.mark {
  width: 18px; height: 18px; border-radius: 3px;
  background:
    linear-gradient(var(--ink), var(--ink)) 0 0 / 50% 50% no-repeat,
    linear-gradient(var(--ink), var(--ink)) 100% 100% / 50% 50% no-repeat,
    var(--square);
  border: 1.5px solid var(--ink);
}
.word { font-weight: 700; letter-spacing: -0.01em; font-size: 18px; }
.puzzle { color: var(--muted); font-size: 14px; }
.score { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.score strong { color: var(--ink); }

.conn {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 13px; color: var(--muted);
  padding: 3px 10px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--panel); white-space: nowrap;
}
.conn .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }
.conn[data-state="live"] .dot { background: var(--ok); }
.conn[data-state="down"] .dot { background: var(--bad); }

.game {
  display: grid;
  grid-template-columns: minmax(0, 560px) minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

.current {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px;
  min-height: 52px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px; margin-bottom: 12px;
}
.current-label { font-weight: 600; }
.current-hold { font-size: 13px; color: var(--muted); }
.current-hold[data-hold="waiting"], .current-hold[data-hold="asked"] { color: var(--warn); }
.current-hold[data-hold="held"] { color: var(--ok); }
.current-hold[data-hold="lost"] { color: var(--bad); }

.grid {
  display: grid;
  gap: 2px;
  background: var(--block);
  border: 2px solid var(--block);
  border-radius: 6px;
  width: 100%;
  user-select: none;
  touch-action: manipulation;
}
.sq {
  position: relative;
  aspect-ratio: 1;
  background: var(--block);
}
.sq.on {
  background: var(--square);
  cursor: pointer;
  display: grid; place-items: center;
  font-weight: 700;
  font-size: clamp(14px, 4.2vw, 26px);
  text-transform: uppercase;
  transition: background-color 160ms;
}
.sq.on.word-sel { background: var(--word); }
.sq.on.word-sel.waiting { background: var(--waiting); }
.sq.on.next { background: var(--mine); }
.sq.on.solved { background: var(--solved); color: var(--solved-ink); }
.sq.on.flash { animation: flash 900ms ease-out; }
@keyframes flash { from { background: var(--flash); } }
.num {
  position: absolute; top: 2px; left: 3px;
  font-size: clamp(8px, 1.6vw, 11px); font-weight: 500; color: var(--muted);
}

.board { position: relative; }
/* On screen but unseen, at 16px so that a phone does not zoom to it. */
.keys {
  position: absolute; top: 60px; left: 0; width: 1px; height: 1px;
  opacity: 0; font-size: 16px; border: 0; padding: 0;
  pointer-events: none;
}

.done {
  margin-top: 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--solved); color: var(--solved-ink);
  border-radius: 10px; padding: 12px 14px;
}
.done[hidden] { display: none; }
.done-text { margin: 0; font-weight: 700; }
#again {
  font: inherit; font-weight: 600; color: #fff; background: var(--accent);
  border: 0; border-radius: 8px; padding: 8px 14px; cursor: pointer;
}

.clues { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.clues h2 {
  font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); margin: 4px 0 8px;
}
.clues ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.clue {
  display: grid; grid-template-columns: 26px 1fr; gap: 6px;
  padding: 6px 8px; border-radius: 8px; cursor: pointer;
  font-size: 15px;
}
.clue:hover { background: var(--panel); }
.clue.sel { background: var(--word); }
.clue.sel.waiting { background: var(--waiting); }
.clue .n { font-weight: 700; text-align: right; }
.clue.solved { color: var(--muted); }
.clue.solved .t { text-decoration: line-through; }

.foot { padding-top: 28px; padding-bottom: 40px; }
.foot p { color: var(--muted); font-size: 13px; max-width: 72ch; margin: 0; }

@media (max-width: 760px) {
  .game { grid-template-columns: 1fr; }
  .score, .puzzle { display: none; }
}
@media (max-width: 420px) {
  .clues { grid-template-columns: 1fr; }
}
