:root {
  --bg: #08090b;
  --panel: #0d0f12;
  --text: #eef1f4;
  --muted: #9aa3ad;
  --faint: #5b636d;
  --line: rgba(255, 255, 255, 0.1);
  --accent: #46c5e6;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; letter-spacing: -0.02em; font-size: 18px; }
.brand .dot { color: var(--accent); }
.brand .dim { color: var(--faint); font-weight: 400; }

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: ui-monospace, "JetBrains Mono", monospace;
  font-size: 12px;
  color: var(--muted);
}
.s-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--faint); }
.status[data-state="live"] .s-dot { background: #46e6a5; box-shadow: 0 0 10px rgba(70, 230, 165, 0.6); }
.status[data-state="down"] .s-dot { background: #ff6b6b; }
.peers { color: var(--faint); }
.peers[hidden] { display: none; }

.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 28px 20px 40px;
  gap: 20px;
}
.tagline {
  max-width: 46ch;
  text-align: center;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
  margin: 0;
}

.canvas-wrap {
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  touch-action: none;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
canvas[data-canvas] {
  display: block;
  width: min(78vw, 70vh, 560px);
  height: min(78vw, 70vh, 560px);
  image-rendering: pixelated;
  cursor: crosshair;
}

.controls { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.palette {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
  padding: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.swatch {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
}
.swatch[aria-pressed="true"] { border-color: var(--text); transform: scale(1.08); }
.swatch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.cooldown { display: flex; align-items: center; gap: 10px; font-family: ui-monospace, monospace; font-size: 12px; color: var(--muted); }
.cooldown[hidden] { display: none; }
.cd-bar { width: 120px; height: 6px; border-radius: 100px; background: rgba(255,255,255,0.08); overflow: hidden; }
.cd-fill { display: block; height: 100%; width: 100%; background: var(--accent); transform-origin: left; }

.hint { color: var(--faint); font-size: 12px; margin: 0; font-family: ui-monospace, monospace; }
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1a0f0f;
  border: 1px solid rgba(255, 107, 107, 0.5);
  color: #ffb3b3;
  padding: 10px 18px;
  border-radius: 100px;
  font-size: 13px;
  font-family: ui-monospace, monospace;
}
.toast[hidden] { display: none; }

.foot {
  display: flex;
  gap: 24px;
  justify-content: center;
  padding: 18px;
  border-top: 1px solid var(--line);
  font-size: 13px;
}
.foot a { color: var(--muted); text-decoration: none; }
.foot a:hover { color: var(--accent); }

@media (prefers-reduced-motion: reduce) {
  .cd-fill { transition: none !important; }
}
