:root {
  --bg: #0d0d10;
  --panel: rgba(20, 20, 26, 0.92);
  --border: #2a2a33;
  --text: #e8e8ea;
  --muted: #9a9aa6;
  --accent: #7aa2ff;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
  overscroll-behavior: none;
}

#stage {
  position: fixed;
  inset: 0;
  touch-action: none;
  cursor: crosshair;
}

#view {
  position: absolute;
  top: 0;
  left: 0;
  image-rendering: pixelated;
}

/* HUD */
#hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  gap: 12px;
  pointer-events: none;
  z-index: 5;
}

#hud button { pointer-events: auto; }

/* Each HUD cluster is a self-contained dark pill so the text stays readable
   over any canvas colour, including large flat white areas when zoomed in. */
.hud-left, .hud-right {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 10px;
  backdrop-filter: blur(6px);
}

#coords {
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

#online { color: var(--muted); }

#avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
}

#who { color: var(--text); }

#logout {
  background: #1b1b22;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 3px 8px;
  cursor: pointer;
}

/* Dock */
#dock {
  position: fixed;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  z-index: 5;
  max-width: calc(100vw - 20px);
}

#palette {
  display: grid;
  grid-template-columns: repeat(16, 1fr);
  gap: 4px;
}

@media (max-width: 560px) {
  #palette { grid-template-columns: repeat(8, 1fr); }
}

.swatch {
  width: 26px;
  height: 26px;
  border-radius: 5px;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
}

.swatch.selected {
  border-color: var(--text);
  transform: scale(1.12);
}

#status {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

#inspectBtn {
  background: #1b1b22;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 10px;
  cursor: pointer;
}

#inspectBtn.active {
  color: var(--text);
  border-color: var(--accent);
}

#cooldown {
  position: relative;
  flex: 1;
  height: 26px;
  border-radius: 6px;
  background: #1b1b22;
  border: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

#cooldownBar {
  position: absolute;
  inset: 0 100% 0 0;
  background: rgba(122, 162, 255, 0.25);
  transition: right 0.2s linear;
}

#cooldownText {
  position: relative;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

#cooldown.ready #cooldownText { color: #7ee081; }

/* Sign-in button (shown in the HUD to logged-out viewers) */
#signin {
  background: #5865f2;
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  border-radius: 6px;
  padding: 5px 12px;
  white-space: nowrap;
}

/* Inspect panel */
#inspectPanel {
  position: fixed;
  right: 12px;
  top: 52px;
  width: 240px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  z-index: 8;
}

#inspectClose {
  position: absolute;
  top: 6px;
  right: 8px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
}

#inspectBody { font-size: 13px; line-height: 1.6; }
#inspectBody .sw {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  vertical-align: -1px;
  margin-right: 5px;
}

/* Toast */
#toast {
  position: fixed;
  left: 50%;
  bottom: 120px;
  transform: translateX(-50%);
  background: #33232a;
  border: 1px solid #6a3a48;
  color: #ffd9e2;
  padding: 8px 14px;
  border-radius: 8px;
  z-index: 30;
  font-size: 13px;
}
