:root {
  --ink: #fff4d4;
  --panel: rgba(16, 10, 9, 0.68);
  font-family:
    ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  margin: 0;
  background: #120f0e;
  color: var(--ink);
  user-select: none;
  touch-action: none;
}

button {
  border: 0;
  cursor: pointer;
  font: inherit;
}

.wall {
  position: relative;
  width: 100dvw;
  height: 100dvh;
  min-height: 100vh;
  overflow: hidden;
  background:
    linear-gradient(rgba(15, 9, 8, 0.1), rgba(7, 6, 6, 0.52)),
    url("assets/background.png") center / cover no-repeat,
    #120f0e;
}

.wall::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 24%, rgba(255, 218, 154, 0.16), transparent 16rem),
    radial-gradient(circle at 48% 68%, rgba(231, 139, 126, 0.09), transparent 18rem),
    linear-gradient(90deg, rgba(255, 248, 220, 0.03), transparent 22%, rgba(0, 0, 0, 0.14) 76%);
  animation: roomBreath 6.5s ease-in-out infinite;
}

.wall::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  background-image:
    repeating-radial-gradient(circle at 12% 18%, rgba(255, 244, 211, 0.075) 0 1px, transparent 1px 4px),
    repeating-linear-gradient(0deg, rgba(255, 244, 211, 0.018) 0 1px, transparent 1px 5px),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.032) 0 1px, transparent 1px 7px);
  background-size:
    180px 180px,
    100% 5px,
    7px 100%;
  mix-blend-mode: overlay;
  opacity: 0.32;
  animation: analogFlicker 1.8s steps(2, end) infinite;
}

@keyframes roomBreath {
  0%,
  100% {
    opacity: 0.94;
  }
  50% {
    opacity: 1;
  }
}

@keyframes analogFlicker {
  0%,
  100% {
    transform: translate3d(0, 0, 0);
    opacity: 0.29;
  }
  50% {
    transform: translate3d(-1px, 1px, 0);
    opacity: 0.37;
  }
}

.graffiti-canvas {
  position: absolute;
  inset: 0;
  z-index: 3;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

.spray-tip {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 7;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  background:
    radial-gradient(circle, color-mix(in srgb, var(--spray, #f5d76e) 82%, white 8%) 0 22%, transparent 42%),
    radial-gradient(circle, rgba(255, 255, 255, 0.42) 0 1px, transparent 2px);
  filter: none;
  transform: translate3d(-100px, -100px, 0);
  transition: opacity 150ms ease;
}

.is-spraying .spray-tip {
  opacity: 0.86;
  animation: sprayPulse 520ms ease-in-out infinite alternate;
}

@keyframes sprayPulse {
  from {
    scale: 0.9;
  }
  to {
    scale: 1.03;
  }
}

.live-pulse {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 12px);
  right: calc(env(safe-area-inset-right) + 12px);
  z-index: 8;
  padding: 7px 10px;
  color: #fff4d4;
  background: rgba(16, 10, 9, 0.68);
  border: 1px solid rgba(245, 215, 110, 0.32);
  border-radius: 999px;
  box-shadow: 0 0 24px rgba(245, 215, 110, 0.16);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0;
}

.live-pulse::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 6px;
  background: #f5d76e;
  border-radius: 50%;
  box-shadow: 0 0 14px #f5d76e;
}

.status {
  position: fixed;
  left: 50%;
  top: calc(env(safe-area-inset-top) + 12px);
  z-index: 8;
  width: max-content;
  max-width: calc(100vw - 96px);
  padding: 10px 13px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid rgba(255, 236, 202, 0.15);
  border-radius: 999px;
  transform: translateX(-50%);
  backdrop-filter: blur(14px);
  box-shadow:
    0 12px 42px rgba(0, 0, 0, 0.28),
    0 0 24px rgba(245, 215, 110, 0.08);
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1.35;
  text-align: center;
  word-break: keep-all;
}

.spray-panel {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 16px);
  z-index: 8;
  display: grid;
  grid-template-columns: repeat(4, 46px);
  gap: 9px;
  padding: 9px;
  background: var(--panel);
  border: 1px solid rgba(255, 236, 202, 0.16);
  border-radius: 999px;
  transform: translateX(-50%);
  backdrop-filter: blur(14px);
  box-shadow:
    0 16px 48px rgba(0, 0, 0, 0.34),
    0 0 32px rgba(245, 215, 110, 0.06);
}

.color-button {
  position: relative;
  width: 46px;
  height: 46px;
  background: var(--swatch);
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  box-shadow:
    0 8px 20px rgba(0, 0, 0, 0.28),
    0 0 18px color-mix(in srgb, var(--swatch) 34%, transparent),
    inset 0 -8px 12px rgba(0, 0, 0, 0.2),
    inset 0 7px 12px rgba(255, 255, 255, 0.28);
}

.color-button::after {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  opacity: 0.55;
}

.color-button.active {
  border-color: rgba(255, 255, 255, 0.96);
  transform: translateY(-3px);
}

@media (min-width: 760px) {
  .status {
    top: calc(env(safe-area-inset-top) + 20px);
    font-size: 0.9rem;
  }

  .spray-panel {
    bottom: calc(env(safe-area-inset-bottom) + 22px);
  }
}

@media (max-width: 360px) {
  .spray-panel {
    grid-template-columns: repeat(4, 42px);
    gap: 8px;
  }

  .color-button {
    width: 42px;
    height: 42px;
  }
}
