:root {
  --chroma: #00FF00;
  --bg: #00FF00;
  --ink: #111;
  --tool-bg: rgba(20, 20, 20, 0.78);
  --tool-fg: #fff;
  --tool-size: 52px;
  --gap: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
}

#stage {
  display: block;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  background: var(--bg);
}

/* Toolbar */
.toolbar {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--gap);
  padding: 10px;
  background: var(--tool-bg);
  border-radius: 16px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 10;
  transition: transform 0.2s ease, opacity 0.2s ease;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}
.toolbar.side-right { right: 16px; }
.toolbar.side-left  { left: 16px; }
.toolbar.hidden {
  opacity: 0;
  pointer-events: none;
}
.toolbar.hidden.side-right { transform: translate(120%, -50%); }
.toolbar.hidden.side-left  { transform: translate(-120%, -50%); }

.tool {
  width: var(--tool-size);
  height: var(--tool-size);
  border-radius: 12px;
  border: 1.5px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  color: var(--tool-fg);
  font-size: 22px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease;
}
.tool:active { transform: scale(0.94); background: rgba(255,255,255,0.16); }
.tool.active { border-color: var(--chroma); background: rgba(0, 255, 0, 0.15); }

.tool.color {
  position: relative;
  border-radius: 50%;
}
.tool.color.black { background: #000; border-color: rgba(255,255,255,0.35); }
.tool.color.white { background: #fff; border-color: rgba(0,0,0,0.25); }
.tool.color.eraser {
  background: var(--chroma);
  border-color: rgba(255,255,255,0.45);
  overflow: hidden;
}
.tool.color.eraser::after {
  content: '';
  position: absolute;
  inset: 14%;
  border-radius: 50%;
  background: linear-gradient(45deg, transparent calc(50% - 1.5px), #fff calc(50% - 1.5px), #fff calc(50% + 1.5px), transparent calc(50% + 1.5px));
  pointer-events: none;
}
.tool.color.active { box-shadow: 0 0 0 3px var(--chroma); border-color: transparent; }
.tool.color.eraser.active { box-shadow: 0 0 0 3px #fff; border-color: transparent; }

.tool.brush {
  display: flex;
  align-items: center;
  justify-content: center;
}

.tool.bg-cycle {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
}
.bg-swatch {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid rgba(255,255,255,0.25);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.15);
}
.brush-dot {
  display: block;
  background: #fff;
  border-radius: 50%;
}
.brush-dot-small { width: 5px; height: 5px; }
.brush-dot-medium { width: 11px; height: 11px; }
.brush-dot-large { width: 20px; height: 20px; }

.tool.hide-btn { font-size: 18px; opacity: 0.7; }

.divider {
  width: 60%;
  height: 1px;
  background: rgba(255,255,255,0.12);
  margin: 2px 0;
}

/* Edge controls when toolbar hidden */
.edge-controls {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 10;
}
.edge-controls.side-right { right: 4px; }
.edge-controls.side-left  { left: 4px; }
.edge-controls[hidden] { display: none; }

.reveal-tab, .edge-btn {
  width: 28px;
  height: 56px;
  background: rgba(20,20,20,0.45);
  color: rgba(255,255,255,0.6);
  border: none;
  border-radius: 10px;
  font-size: 18px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s ease, color 0.15s ease;
}
.edge-btn.armed,
.tool.armed {
  background: rgba(220, 50, 50, 0.9);
  color: #fff;
  border-color: #ff6b6b;
}

/* HUD */
.hud {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 12px;
  background: var(--tool-bg);
  color: #fff;
  border-radius: 999px;
  font-size: 13px;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  z-index: 9;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.hud.visible { opacity: 0.9; }
