body {
  margin: 0;
  background: #000;
  font-family: 'Luna', sans-serif;
  overflow: hidden;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.18em;
}

#game-root {
  position: relative;
  width: 100vw;
  height: 100vh;
  background: #000;
}

/* Fallback animated background when video fails */
#game-root.no-video::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 20%, rgba(168,85,247,0.25), transparent 55%),
    radial-gradient(circle at 80% 80%, rgba(34,197,94,0.25), transparent 55%),
    radial-gradient(circle at 10% 90%, rgba(168,85,247,0.15), transparent 55%);
  animation: pulse-bg 6s ease-in-out infinite alternate;
  z-index: 0;
}

video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
  position: relative;
  z-index: 0;
}

/* Base cue */
#base-instruction {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 14px);
  left: 50%;
  transform: translateX(-50%);
  max-width: 92vw;
  text-align: center;
  font-family: 'Bebas Neue', sans-serif;
  font-size: clamp(22px, 4.8vw, 52px);
  line-height: 1.05;
  color: #a855f7;
  text-shadow: 0 0 8px rgba(168,85,247,0.8);
  padding: 4px 12px 10px;
  box-sizing: border-box;
  z-index: 2;
  display: inline-block;
  animation: base-pulse 1.5s ease-in-out infinite;
}

#base-instruction::after {
  content: "";
  display: block;
  margin: 4px auto 0;
  width: 120px;
  height: 2px;
  background: linear-gradient(90deg, transparent, #a855f7, transparent);
  box-shadow: 0 0 10px rgba(168,85,247,0.8);
}

/* Popup layer with vignette */
#popup {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle, transparent 55%, rgba(0,0,0,0.7) 100%);
  z-index: 3;
}

#popup-text {
  padding: 18px 24px;
  border: 2px solid #22c55e;
  color: #22c55e;
  font-size: 18px;
  text-align: center;
  background: rgba(0,0,0,0.8);
  box-shadow:
    0 0 12px rgba(34,197,94,0.8),
    0 0 30px rgba(0,0,0,0.9);
  max-width: 80vw;
  animation: popup-in 0.2s ease-out forwards;
}

/* Popup exit animation helper */
#popup.closing #popup-text {
  animation: popup-out 0.2s ease-in forwards;
}

.hidden {
  display: none !important;
}

/* Controls HUD */
#controls {
  position: absolute;
  bottom: 160px;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 0 16px;
  box-sizing: border-box;
  z-index: 4;
}

button {
  background: transparent;
  border: 1px solid #22c55e;
  color: #22c55e;
  padding: 10px 18px;
  min-width: 90px;
  border-radius: 999px;
  font-family: 'Luna', sans-serif;
  font-size: 12px;
  letter-spacing: 0.16em;
  cursor: pointer;
  outline: none;
  position: relative;
  overflow: hidden;
}

button::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(circle at 0% 0%, rgba(34,197,94,0.2), transparent 55%);
  opacity: 0;
  transition: opacity 0.2s ease-out;
}

button:active::before,
button:hover::before {
  opacity: 1;
}

button:disabled {
  opacity: 0.4;
  cursor: default;
}

/* Countdown overlay */
#countdown {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(56px, 15vw, 96px);
  color: #22c55e;
  text-shadow:
    0 0 10px rgba(34,197,94,0.9),
    0 0 25px rgba(0,0,0,1);
  background: rgba(0,0,0,0.55);
  z-index: 5;
}

#countdown.go {
  animation: go-flash 0.6s ease-out;
}

/* Animations */
@keyframes popup-in {
  from {
    transform: scale(0.85);
    opacity: 0;
    box-shadow:
      0 0 3px rgba(34,197,94,0.5),
      0 0 0 rgba(0,0,0,1);
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes popup-out {
  from {
    transform: scale(1);
    opacity: 1;
  }
  to {
    transform: scale(0.9);
    opacity: 0;
  }
}

@keyframes go-flash {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  40% {
    transform: scale(1.08);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 0;
  }
}

@keyframes base-pulse {
  0% {
    transform: translateX(-50%) scale(1);
  }
  50% {
    transform: translateX(-50%) scale(1.08);
  }
  100% {
    transform: translateX(-50%) scale(1);
  }
}

@keyframes pulse-bg {
  from {
    opacity: 0.6;
    transform: scale(1);
  }
  to {
    opacity: 1;
    transform: scale(1.04);
  }
}

@media (min-width: 768px) {
  #base-instruction {
    font-size: 18px;
  }

  #popup-text {
    font-size: 22px;
    max-width: 420px;
  }

  button {
    font-size: 13px;
    padding: 10px 22px;
    min-width: 110px;
  }
}