:root {
  --bg: #05080f;
  --phosphor: #5cffb0;
  --cyan: #45e7ff;
  --amber: #ffb347;
  --hot: #ff4d6d;
  --dim: rgba(92, 255, 176, 0.55);
  --font-arcade: "Press Start 2P", monospace;
  --font-mono: "Share Tech Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 700px at 50% -10%, #12203a 0%, transparent 55%),
    linear-gradient(180deg, #070b14 0%, var(--bg) 45%, #03050a 100%);
  color: var(--phosphor);
  font-family: var(--font-mono);
  overflow: hidden;
}

.stage {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem 1rem 5.5rem;
  gap: 0.75rem;
}

.bezel {
  position: relative;
  width: min(96vw, 960px);
  aspect-ratio: 960 / 640;
  border-radius: 1.1rem;
  padding: 0.55rem;
  background:
    linear-gradient(145deg, #1a2438, #0a101c 55%, #151c2c);
  box-shadow:
    0 0 0 1px rgba(69, 231, 255, 0.18),
    0 30px 80px rgba(0, 0, 0, 0.55),
    inset 0 0 40px rgba(69, 231, 255, 0.05);
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 0.55rem;
  background: #02040a;
  image-rendering: pixelated;
}

.crt {
  pointer-events: none;
  position: absolute;
  inset: 0.55rem;
  border-radius: 0.55rem;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(255, 255, 255, 0.03) 0px,
      rgba(255, 255, 255, 0.03) 1px,
      transparent 2px,
      transparent 3px
    ),
    radial-gradient(ellipse at center, transparent 50%, rgba(0, 0, 0, 0.45) 100%);
  mix-blend-mode: screen;
  opacity: 0.65;
  animation: flicker 4.5s infinite;
}

@keyframes flicker {
  0%, 100% { opacity: 0.62; }
  48% { opacity: 0.7; }
  50% { opacity: 0.55; }
  52% { opacity: 0.68; }
}

.hud-help {
  text-align: center;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  color: var(--dim);
  max-width: 52rem;
}
.hud-help .touch { display: none; }

.touch-ui {
  position: fixed;
  inset: auto 0 0 0;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(5, 8, 15, 0.92), transparent);
  z-index: 5;
}
.touch-ui .pad {
  display: flex;
  gap: 0.55rem;
  align-items: flex-end;
}
.touch-ui button {
  min-width: 3.4rem;
  min-height: 3.4rem;
  border: 1px solid rgba(69, 231, 255, 0.45);
  border-radius: 0.85rem;
  background: rgba(10, 20, 34, 0.85);
  color: var(--cyan);
  font-family: var(--font-arcade);
  font-size: 0.55rem;
  letter-spacing: 0.04em;
  touch-action: none;
  user-select: none;
}
.touch-ui button.fire {
  min-width: 5.2rem;
  min-height: 5.2rem;
  color: var(--amber);
  border-color: rgba(255, 179, 71, 0.55);
  background: rgba(40, 22, 8, 0.85);
}
.touch-ui button:active { transform: scale(0.96); filter: brightness(1.25); }

@media (max-width: 820px), (pointer: coarse) {
  .hud-help .desk { display: none; }
  .hud-help .touch { display: inline; }
  .touch-ui { display: flex; }
  .stage { padding-bottom: 7.5rem; }
}

@media (min-width: 821px) and (pointer: fine) {
  .touch-ui[hidden], .touch-ui { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  .crt { animation: none; }
}
