:root {
  --bg: #111;
  --panel: #1c1c1c;
  --fg: #eaeaea;
  --muted: #8a8a8a;
  --accent: #ff4500;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow: hidden;
  touch-action: none;
}
header, footer {
  flex: none;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 14px;
  background: var(--panel);
}
header h1 { margin: 0; font-size: 15px; font-weight: 600; }
header span { color: var(--muted); }
header a { margin-left: auto; color: var(--muted); text-decoration: none; }
header a:hover { color: var(--fg); }
#viewport {
  flex: 1;
  position: relative;
  overflow: hidden;
  cursor: crosshair;
  background: #0a0a0a;
}
#viewport.dragging { cursor: grabbing; }
#board { position: absolute; top: 0; left: 0; width: 100%; height: 100%; image-rendering: pixelated; }
#cursor {
  position: absolute;
  pointer-events: none;
  outline: 2px solid #fff;
  mix-blend-mode: difference;
  display: none;
}
footer { flex-direction: column; align-items: stretch; gap: 8px; }
#cooldown { color: var(--muted); text-align: center; min-height: 20px; }
#cooldown.ready { color: var(--fg); }
#cooldown.error { color: var(--accent); }
#palette { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; }
#palette button {
  width: 28px;
  height: 28px;
  border: 2px solid transparent;
  border-radius: 4px;
  padding: 0;
  cursor: pointer;
}
#palette button.selected { border-color: #fff; transform: scale(1.15); }
@media (max-width: 600px) {
  #palette button { width: 22px; height: 22px; }
  header { gap: 10px; font-size: 12px; }
}
