:root {
  --bg-0: #06010f;
  --bg-1: #170026;
  --bg-2: #330046;
  --ink: #f8f4ff;
  --neon-cyan: #25f3ff;
  --neon-pink: #ff2aa6;
  --neon-lime: #afff1a;
  --panel: #12021f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  font-family: "Arial Black", Impact, Haettenschweiler, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 700px at 18% 0%, #60007a 0%, transparent 42%),
    radial-gradient(900px 620px at 100% 100%, #001f5a 0%, transparent 40%),
    linear-gradient(180deg, var(--bg-0) 0%, var(--bg-1) 45%, var(--bg-2) 100%);
  overflow: hidden;
  padding:
    max(10px, env(safe-area-inset-top))
    max(10px, env(safe-area-inset-right))
    max(10px, env(safe-area-inset-bottom))
    max(10px, env(safe-area-inset-left));
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
}

body::before {
  background: repeating-linear-gradient(
    0deg,
    rgb(255 255 255 / 0.03) 0 1px,
    transparent 1px 3px
  );
  mix-blend-mode: screen;
  animation: scan 10s linear infinite;
}

body::after {
  background:
    radial-gradient(circle at 30% 10%, rgb(255 0 128 / 0.2), transparent 34%),
    radial-gradient(circle at 70% 75%, rgb(0 225 255 / 0.17), transparent 30%);
}

.app {
  width: min(94vw, 520px);
  position: relative;
  display: grid;
  gap: 10px;
  grid-template-rows: auto auto auto;
}

.app,
canvas,
.touch-controls,
.touch-btn {
  touch-action: none;
}

.hud {
  background: linear-gradient(135deg, rgb(19 0 34 / 0.88), rgb(41 0 61 / 0.86));
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
  border: 2px solid rgb(255 42 166 / 0.58);
  box-shadow:
    0 0 0 1px rgb(37 243 255 / 0.45) inset,
    0 0 16px rgb(255 42 166 / 0.45),
    0 0 26px rgb(37 243 255 / 0.35);
}

.hud h1 {
  margin: 0;
  font-size: 1.1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--neon-cyan);
  text-shadow: 0 0 8px rgb(37 243 255 / 0.8), 0 0 22px rgb(37 243 255 / 0.6);
}

.hud p {
  margin: 6px 0 10px;
  font-size: 0.78rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: rgb(248 244 255 / 0.88);
}

.stats {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.88rem;
  letter-spacing: 0.06em;
}

.stats span {
  text-shadow: 0 0 8px rgb(255 42 166 / 0.65);
}

canvas {
  width: 100%;
  height: auto;
  max-height: min(68dvh, 740px);
  border-radius: 14px;
  display: block;
  border: 3px solid rgb(37 243 255 / 0.7);
  box-shadow:
    0 0 0 2px rgb(255 42 166 / 0.5) inset,
    0 0 18px rgb(37 243 255 / 0.7),
    0 0 34px rgb(255 42 166 / 0.55),
    0 16px 36px rgb(0 0 0 / 0.55);
}

.touch-controls {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.touch-btn {
  border: 1px solid rgb(37 243 255 / 0.7);
  border-radius: 12px;
  padding: 12px 0;
  font-size: 1.3rem;
  font-weight: 900;
  color: #f8f4ff;
  background: linear-gradient(125deg, rgb(8 0 20 / 0.96), rgb(48 0 68 / 0.88));
  box-shadow: 0 0 14px rgb(37 243 255 / 0.4), 0 0 20px rgb(255 42 166 / 0.35);
  user-select: none;
  -webkit-user-select: none;
}

.touch-btn:active,
.touch-btn.is-active {
  transform: translateY(1px) scale(0.98);
  box-shadow: 0 0 18px rgb(37 243 255 / 0.7), 0 0 26px rgb(255 42 166 / 0.55);
}

.motion-controls {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
}

.motion-btn {
  border: 1px solid rgb(175 255 26 / 0.65);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #05080f;
  background: linear-gradient(110deg, #afff1a, #25f3ff);
  box-shadow: 0 0 14px rgb(175 255 26 / 0.45);
}

#motion-status {
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  color: rgb(248 244 255 / 0.9);
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.overlay[hidden] {
  display: none;
}

.overlay .card {
  pointer-events: auto;
  background: linear-gradient(140deg, rgb(13 0 28 / 0.92), rgb(45 0 65 / 0.88));
  border: 2px solid rgb(255 42 166 / 0.7);
  box-shadow: 0 0 24px rgb(255 42 166 / 0.55), 0 0 34px rgb(37 243 255 / 0.45);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  min-width: 240px;
}

.overlay h2 {
  margin: 0 0 8px;
  color: var(--neon-lime);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-shadow: 0 0 12px rgb(175 255 26 / 0.8);
}

.overlay p {
  margin: 8px 0;
  font-size: 0.92rem;
  letter-spacing: 0.04em;
}

.overlay button {
  margin-top: 8px;
  border: 1px solid rgb(37 243 255 / 0.7);
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 0.9rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #05080f;
  background: linear-gradient(110deg, #25f3ff, #afff1a);
  box-shadow: 0 0 16px rgb(37 243 255 / 0.65);
  cursor: pointer;
}

@keyframes scan {
  0% {
    transform: translateY(0);
  }
  100% {
    transform: translateY(12px);
  }
}

@media (hover: hover) and (pointer: fine) {
  .touch-controls {
    display: none;
  }

  .motion-controls {
    display: none;
  }
}

@media (max-width: 560px) {
  .hud {
    padding: 10px 11px;
  }

  .hud h1 {
    font-size: 1rem;
  }

  .hud p {
    font-size: 0.7rem;
  }

  .stats {
    font-size: 0.8rem;
  }

  canvas {
    max-height: 62dvh;
  }
}
