:root {
  --ink: #20102f;
  --gold: #ff9f1c;
  --ghost: #fff1d6;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0d0a24;
  touch-action: none;
  font-family: ui-rounded, "Arial Rounded MT Bold", system-ui, sans-serif;
}

#cam,
#view {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}

#cam {
  object-fit: cover;
  filter: brightness(.9) saturate(.88);
}

#haunt-overlay {
  position: fixed;
  z-index: 1;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 100%, rgba(111, 48, 125, .2), transparent 60%),
    radial-gradient(ellipse at 0% 0%, rgba(255, 111, 0, .14), transparent 42%),
    radial-gradient(ellipse at 100% 0%, rgba(92, 49, 130, .18), transparent 42%),
    radial-gradient(ellipse at center, transparent 48%, rgba(17, 8, 29, .38) 100%);
}

#haunt-overlay::before {
  position: absolute;
  inset: 35% -20% -10%;
  background:
    radial-gradient(ellipse at 20% 80%, rgba(178, 116, 198, .2), transparent 45%),
    radial-gradient(ellipse at 75% 70%, rgba(255, 133, 45, .14), transparent 48%);
  content: "";
  filter: blur(24px);
  animation: haunted-mist 9s ease-in-out infinite alternate;
}

#haunt-overlay::after {
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(255, 159, 28, .2);
  border-radius: 18px;
  box-shadow: inset 0 0 35px rgba(27, 10, 41, .18);
  content: "";
}

@keyframes haunted-mist {
  from { opacity: .55; transform: translateX(-3%); }
  to { opacity: 1; transform: translateX(3%); }
}

#hud {
  position: fixed;
  inset: 0 0 auto;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: max(12px, env(safe-area-inset-top)) 8px 0;
  pointer-events: none;
}

.pill {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(32, 16, 47, .94);
  box-shadow: 0 2px 14px rgba(255, 112, 20, .18);
  color: #fff;
  font-size: clamp(16px, 3vw, 28px);
  white-space: nowrap;
}

#score {
  color: var(--gold);
}

#tool-picker {
  position: fixed;
  bottom: max(16px, env(safe-area-inset-bottom));
  left: 50%;
  display: flex;
  gap: clamp(10px, 4vw, 24px);
  align-items: center;
  transform: translateX(-50%);
  pointer-events: auto;
}

.tool-option {
  display: grid;
  width: clamp(72px, 18vw, 104px);
  height: clamp(72px, 18vw, 104px);
  place-items: center;
  padding: 8px;
  border: 3px solid rgba(255, 255, 255, .45);
  border-radius: 22px;
  background: rgba(32, 16, 47, .9);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .35);
  transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease;
}

.tool-option img {
  width: 100%;
  height: 100%;
}

.tool-option[aria-pressed="true"] {
  border-color: #fff;
  box-shadow: 0 0 0 3px var(--tool-color), 0 0 22px var(--tool-color);
  transform: translateY(-6px) scale(1.06);
}

.tool-option:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 4px;
}

#feedback {
  position: fixed;
  bottom: calc(116px + env(safe-area-inset-bottom));
  left: 50%;
  max-width: calc(100vw - 24px);
  padding: 12px 20px;
  border-radius: 999px;
  background: rgba(32, 16, 47, .96);
  color: #fff;
  font-size: 20px;
  text-align: center;
  transform: translateX(-50%);
}

#start {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 24px;
  background:
    radial-gradient(ellipse at 50% 25%, rgba(114, 49, 120, .32), transparent 45%),
    radial-gradient(ellipse at 50% 100%, rgba(255, 111, 0, .13), transparent 55%),
    #10091d;
  color: #fff;
  text-align: center;
}

#start h1 {
  margin: 0;
  color: var(--ghost);
  font-size: clamp(40px, 8vw, 80px);
  text-shadow: 0 0 18px rgba(255, 132, 31, .45);
}

.intro-copy {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 30ch;
}

#start p {
  max-width: 30ch;
  margin: 0;
  font-size: clamp(18px, 2.6vw, 26px);
  line-height: 1.4;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 16px 40px;
  background: linear-gradient(135deg, #ffbd45, #ff8617);
  color: var(--ink);
  font: inherit;
  font-size: clamp(22px, 3.4vw, 34px);
  cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
  #haunt-overlay::before {
    animation: none;
  }
}

button:focus-visible {
  outline: 4px solid #fff;
  outline-offset: 4px;
}

#msg {
  min-height: 1.4em;
  color: #ffb4a2;
  font-size: 18px;
}

[hidden] {
  display: none !important;
}
