:root {
  --bg: #111;
  --panel: rgba(255, 255, 255, 0.08);
  --text: #fff;
  --muted: rgba(255, 255, 255, 0.72);
  --button: rgba(255, 255, 255, 0.14);
  --button-hover: rgba(255, 255, 255, 0.22);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  touch-action: none;
}

.home-link {
  position: fixed;
  top: 12px;
  left: 12px;

  z-index: 1000;

  color: white;
  text-decoration: none;

  font-size: 24px;
  font-weight: 700;

  opacity: 0.75;

  transition:
    opacity 120ms ease,
    transform 120ms ease;
}

.home-link:hover {
  opacity: 1;
  transform: scale(1.08);
}

button,
input {
  font: inherit;
}

.app {
  width: 100vw;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.toolbar {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: max(0.8rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) 0.8rem max(1rem, env(safe-area-inset-left));
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.72), rgba(0, 0, 0, 0.28));
  backdrop-filter: blur(12px);
}

h1 {
  margin: 0;
  font-size: clamp(1.1rem, 4vw, 1.8rem);
  letter-spacing: -0.04em;
}

p {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: clamp(0.78rem, 2.4vw, 0.95rem);
}

.controls {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.brush-control {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 0.7rem;
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-size: 0.9rem;
  user-select: none;
}

.brush-control input {
  width: min(22vw, 150px);
  accent-color: white;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 0.62rem 0.85rem;
  color: white;
  background: var(--button);
  cursor: pointer;
  user-select: none;
}

button:hover {
  background: var(--button-hover);
}

.canvas-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  cursor: crosshair;
}

canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.toast {
  position: absolute;
  left: 50%;
  bottom: max(1rem, env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(1rem);
  opacity: 0;
  padding: 0.65rem 0.9rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.controls button.active {
  background: white;
  color: #111;
}

#actorCanvas {
  pointer-events: auto;
}

@media (max-width: 700px) {
  .toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .controls {
    width: 100%;
    justify-content: flex-start;
  }

  .brush-control {
    flex: 1 1 100%;
  }

  .brush-control input {
    flex: 1;
    width: auto;
  }
}
