:root {
  --bg: #0e1620;
  --panel: #15202b;
  --cell: 18px;
  --gap: 1px;
  --given: #e8eef5;
  --empty: #1f2a36;
  --sel: #2f6fa3;
  --bad: #a33;
  --text: #e8eef5;
  --muted: #8aa0b8;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; background: var(--bg); color: var(--text); font-family: system-ui, -apple-system, sans-serif; }
#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.topbar { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: var(--panel); flex-wrap: wrap; }
.title { font-weight: 700; font-size: 16px; }
.title small { font-weight: 400; font-size: 11px; color: var(--muted); margin-left: 4px; }
#tiers { display: flex; gap: 4px; }
.btn { border: 1px solid #2a3a4a; background: #1c2a38; color: var(--text); padding: 6px 10px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.btn.tier { padding: 4px 8px; }
.btn.primary { background: #2f6fa3; border-color: #2f6fa3; }
.spacer { flex: 1; }
.hud { display: flex; gap: 8px; font-size: 13px; align-items: center; }
.hud .opt { color: var(--muted); font-size: 11px; }
#board { flex: 1; display: flex; align-items: center; justify-content: center; padding: 8px; min-height: 0; overflow: hidden; }
#grid {
  display: grid;
  grid-template-columns: repeat(var(--cols, 21), var(--cell));
  grid-template-rows: repeat(var(--rows, 21), var(--cell));
  gap: var(--gap);
  background: #0a1018;
}
.cell { width: var(--cell); height: var(--cell); display: flex; align-items: center; justify-content: center; font-size: calc(var(--cell) * 0.55); user-select: none; }
.cell.gap { background: transparent; }
.cell.given { background: #2a3a4a; color: var(--given); font-weight: 700; }
.cell.empty { background: var(--empty); color: var(--text); cursor: pointer; }
.cell.empty.selected { background: var(--sel); }
.cell.empty.bad { background: var(--bad); }
#pad { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 10px; background: var(--panel); justify-content: center; }
#pad .btn { min-width: 36px; }
#statusbar { display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: var(--panel); flex-wrap: wrap; }
#status { flex: 1; font-size: 12px; color: var(--muted); min-width: 120px; }
#status[data-mode="win"] { color: #6fcf6f; }
#status[data-mode="sel"] { color: var(--text); }
.actions { display: flex; gap: 4px; flex-wrap: wrap; }
#win { position: fixed; inset: 0; background: rgba(0,0,0,0.7); display: flex; align-items: center; justify-content: center; z-index: 10; }
#win.hidden { display: none; }
.win-card { background: var(--panel); padding: 24px; border-radius: 12px; text-align: center; }
.win-label { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.win-body { color: var(--muted); margin-bottom: 12px; }
#modal-root .modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.7); display: flex; align-items: center; justify-content: center; z-index: 20; }
#modal-root .modal { background: var(--panel); padding: 20px; border-radius: 12px; max-width: 90vw; max-height: 80vh; overflow: auto; }
@media (max-width: 600px) {
  .topbar { padding: 6px 8px; }
  .hud { font-size: 11px; }
}
