:root {
  --housing: #2a2e36;
  --housing-edge: #1a1d24;
  --housing-shine: #3a404c;
  --metal: #2e333c;
  --metal-light: #4a5160;
  --metal-dark: #16191f;
  --road: #16181e;
  --road-glow: #1e2430;
  --red-off: #3a1518;
  --red-on: #ff2a2a;
  --red-glow: rgba(255, 42, 42, 0.55);
  --amber-off: #3a2a12;
  --amber-on: #ffb020;
  --amber-glow: rgba(255, 176, 32, 0.5);
  --green-off: #123a22;
  --green-on: #28e070;
  --green-glow: rgba(40, 224, 112, 0.5);
}

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

html,
body {
  height: 100%;
  overflow: hidden;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

body {
  min-height: 100%;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(ellipse 80% 60% at 50% 35%, var(--road-glow), transparent 70%),
    linear-gradient(180deg, #1c2028 0%, var(--road) 55%, #12141a 100%);
  cursor: pointer;
  font-family: "Segoe UI", system-ui, sans-serif;
}

.scene {
  width: min(40vw, 200px);
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: translateY(-4vh);
}

@media (orientation: landscape) and (max-height: 500px) {
  .scene {
    width: min(26vh, 140px);
    transform: none;
  }
}

.housing {
  width: 100%;
  padding: 9% 15% 11%;
  border-radius: 22px;
  background:
    linear-gradient(160deg, var(--housing-shine) 0%, var(--housing) 40%, var(--housing-edge) 100%);
  box-shadow:
    0 2px 0 rgba(255, 255, 255, 0.08) inset,
    0 -8px 14px rgba(0, 0, 0, 0.35) inset,
    0 18px 40px rgba(0, 0, 0, 0.55),
    0 4px 10px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  gap: 8%;
  aspect-ratio: 1 / 2.4;
  position: relative;
  z-index: 2;
}

.housing::before {
  content: "";
  position: absolute;
  inset: 3.5% 7%;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.045);
  pointer-events: none;
}

/* Bracket that sits under the housing and grips the pole */
.mount {
  width: 42%;
  height: 14px;
  margin-top: -2px;
  border-radius: 0 0 6px 6px;
  background:
    linear-gradient(180deg, var(--metal-light) 0%, var(--metal) 55%, var(--metal-dark) 100%);
  box-shadow:
    0 2px 0 rgba(255, 255, 255, 0.1) inset,
    0 4px 8px rgba(0, 0, 0, 0.45);
  position: relative;
  z-index: 1;
}

.mount::before,
.mount::after {
  content: "";
  position: absolute;
  top: 3px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #6a7280, #1a1d22 70%);
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.5);
}

.mount::before {
  left: 18%;
}

.mount::after {
  right: 18%;
}

.pole {
  width: 16%;
  height: min(22vh, 160px);
  margin-top: -1px;
  background:
    linear-gradient(
      90deg,
      var(--metal-dark) 0%,
      #3a414c 28%,
      #525a68 48%,
      #3a414c 72%,
      var(--metal-dark) 100%
    );
  box-shadow:
    0 12px 24px rgba(0, 0, 0, 0.4),
    2px 0 4px rgba(0, 0, 0, 0.25) inset,
    -2px 0 4px rgba(255, 255, 255, 0.04) inset;
  border-radius: 0 0 3px 3px;
  position: relative;
}

.pole::after {
  content: "";
  position: absolute;
  left: -35%;
  right: -35%;
  bottom: 0;
  height: 10px;
  border-radius: 3px;
  background:
    linear-gradient(180deg, var(--metal-light) 0%, var(--metal-dark) 100%);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
}

.light {
  flex: 1 1 0;
  min-height: 0;
  border-radius: 50%;
  position: relative;
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.08), transparent 45%),
    var(--off);
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.5) inset,
    0 0 0 3px rgba(0, 0, 0, 0.35);
  transition:
    background 180ms ease,
    box-shadow 180ms ease,
    filter 180ms ease;
  filter: brightness(0.85);
}

.light::after {
  content: "";
  position: absolute;
  inset: 12%;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.22), transparent 42%);
  opacity: 0.35;
  pointer-events: none;
}

.light.red {
  --off: var(--red-off);
  --on: var(--red-on);
  --glow: var(--red-glow);
}

.light.amber {
  --off: var(--amber-off);
  --on: var(--amber-on);
  --glow: var(--amber-glow);
}

.light.green {
  --off: var(--green-off);
  --on: var(--green-on);
  --glow: var(--green-glow);
}

.light.on {
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.55), transparent 40%),
    radial-gradient(circle at 50% 55%, var(--on) 0%, var(--on) 55%, #000 140%);
  box-shadow:
    0 0 18px var(--glow),
    0 0 42px var(--glow),
    0 2px 4px rgba(0, 0, 0, 0.25) inset,
    0 0 0 3px rgba(0, 0, 0, 0.25);
  filter: brightness(1.05);
}

.light.on::after {
  opacity: 0.85;
}

.hint {
  position: fixed;
  left: 0;
  right: 0;
  bottom: max(1.25rem, env(safe-area-inset-bottom, 0px));
  text-align: center;
  color: rgba(255, 255, 255, 0.38);
  font-size: clamp(0.85rem, 3.2vw, 1rem);
  letter-spacing: 0.02em;
  pointer-events: none;
  transition: opacity 400ms ease;
}

body.hint-hidden .hint {
  opacity: 0;
}

.flash {
  animation: pulse 220ms ease;
}

@keyframes pulse {
  0% {
    transform: scale(1);
  }
  45% {
    transform: scale(1.015);
  }
  100% {
    transform: scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .light {
    transition: none;
  }

  .flash {
    animation: none;
  }
}
