/* CLAUDE CYBERNETICS // Neon Runner
   Retro CRT styling — neon yellow-green + glowing orange/red on black */

:root {
  --neon: #c4f000;        /* yellow-green wireframe */
  --neon-dim: #6e8a00;
  --hot: #ff5a1f;         /* orange-red data node */
  --hot-deep: #d62b00;
  --bg: #050300;
  --pixel: "Press Start 2P", "Courier New", monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: 100%;
  background: #000;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  font-family: "Courier New", monospace;
  display: flex;
  align-items: center;
  justify-content: center;
}

#screen {
  position: relative;
  /* As large as possible while fitting both viewport width and height. */
  width: min(96vw, 960px, calc(96dvh * 16 / 9));
  aspect-ratio: 16 / 9;
  border-radius: 14px;
  overflow: hidden;
  box-shadow:
    0 0 0 2px #1a1200,
    0 0 40px rgba(196, 240, 0, 0.15),
    0 0 90px rgba(255, 90, 31, 0.12);
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: var(--bg);
  image-rendering: pixelated;
}

/* CRT scanline + vignette overlay */
#scanlines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(0,0,0,0) 0px,
      rgba(0,0,0,0) 2px,
      rgba(0,0,0,0.22) 3px,
      rgba(0,0,0,0.22) 4px
    ),
    radial-gradient(ellipse at center,
      rgba(0,0,0,0) 55%,
      rgba(0,0,0,0.55) 100%);
  mix-blend-mode: multiply;
  animation: flicker 4s infinite steps(60);
}

@keyframes flicker {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.92; }
}

/* HUD */
#hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  flex-wrap: wrap;
  gap: clamp(8px, 2.4vw, 26px);
  padding: 12px 56px 12px 16px;   /* extra right pad clears the mute button */
  pointer-events: none;
  font-family: var(--pixel);
  letter-spacing: 0.5px;
  font-size: clamp(7px, 1.15vw, 11px);
  line-height: 1.4;
  color: var(--neon);
  text-shadow: 0 0 6px var(--neon), 0 0 14px rgba(196,240,0,0.5);
}
#hud span {
  color: var(--hot);
  text-shadow: 0 0 6px var(--hot), 0 0 14px rgba(255,90,31,0.6);
}

/* Overlay (title / messages) */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 14px;
  background: radial-gradient(ellipse at center, rgba(20,10,0,0.6), rgba(0,0,0,0.92));
  color: var(--neon);
  z-index: 5;
  padding: 20px;
}
.overlay.hidden { display: none; }

.title {
  font-family: var(--pixel);
  font-size: clamp(24px, 6vw, 56px);
  line-height: 1.25;
  letter-spacing: 1px;
  color: var(--neon);
  text-shadow:
    0 0 8px var(--neon),
    0 0 22px rgba(196,240,0,0.7),
    0 0 46px rgba(255,90,31,0.4);
}
.title .sub {
  font-size: 0.42em;
  color: var(--hot);
  letter-spacing: 2px;
  text-shadow: 0 0 10px var(--hot), 0 0 28px rgba(255,90,31,0.6);
}
.tag {
  font-family: var(--pixel);
  letter-spacing: 4px;
  font-size: clamp(9px, 1.7vw, 14px);
  color: #fff7c2;
  text-shadow: 0 0 10px var(--hot);
}
.prompt {
  letter-spacing: 1px;
  font-size: clamp(12px, 1.8vw, 17px);
  color: #e9ffb0;
  max-width: 80%;
}
.keys {
  font-size: clamp(10px, 1.5vw, 14px);
  letter-spacing: 1px;
  color: var(--neon-dim);
}
.keys b {
  color: var(--neon);
  text-shadow: 0 0 6px var(--neon);
}

#start-btn {
  margin-top: 10px;
  font-family: var(--pixel);
  letter-spacing: 2px;
  font-size: clamp(11px, 1.8vw, 16px);
  color: var(--bg);
  background: var(--neon);
  border: none;
  padding: 14px 30px;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: 0 0 14px var(--neon), 0 0 36px rgba(196,240,0,0.5);
  transition: transform 0.08s ease, box-shadow 0.2s ease;
  animation: pulse 1.6s ease-in-out infinite;
}
#start-btn:hover { transform: scale(1.05); }
#start-btn:active { transform: scale(0.97); }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 14px var(--neon), 0 0 36px rgba(196,240,0,0.45); }
  50% { box-shadow: 0 0 22px var(--hot), 0 0 52px rgba(255,90,31,0.6); }
}

/* ---- Mute toggle ---- */
#mute-btn {
  position: absolute;
  top: 10px;
  right: max(10px, env(safe-area-inset-right));
  z-index: 7;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  font-size: 18px;
  line-height: 1;
  color: var(--neon);
  background: rgba(8, 14, 0, 0.4);
  border: 2px solid var(--neon);
  box-shadow: 0 0 10px rgba(196, 240, 0, 0.4);
  text-shadow: 0 0 8px var(--neon);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.06s ease, box-shadow 0.15s ease, color 0.15s ease;
}
#mute-btn:hover { transform: scale(1.06); }
#mute-btn:active { transform: scale(0.94); }
#mute-btn.muted {
  color: var(--neon-dim);
  border-color: var(--neon-dim);
  box-shadow: none;
  text-shadow: none;
}

/* ---- Touch controls (mobile) ---- */
#touch-controls {
  display: none;                 /* shown only on touch devices while playing */
  position: fixed;
  left: 0; right: 0; bottom: 0;
  justify-content: space-between;
  align-items: flex-end;
  padding: 18px;
  /* keep clear of the home indicator / rounded corners */
  padding-left: max(18px, env(safe-area-inset-left));
  padding-right: max(18px, env(safe-area-inset-right));
  padding-bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 6;
  pointer-events: none;          /* container ignores taps; buttons opt back in */
}

/* Only show on touch devices, and only once the game is running. */
@media (hover: none) and (pointer: coarse) {
  body.playing #touch-controls { display: flex; }
}

.pad {
  display: flex;
  gap: 16px;
  pointer-events: none;
}

.tbtn {
  pointer-events: auto;
  width: 74px;
  height: 74px;
  border-radius: 50%;
  font-size: 30px;
  line-height: 1;
  color: var(--neon);
  background: rgba(8, 14, 0, 0.42);
  border: 2px solid var(--neon);
  box-shadow: 0 0 12px rgba(196, 240, 0, 0.45), inset 0 0 10px rgba(196, 240, 0, 0.2);
  text-shadow: 0 0 8px var(--neon);
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  backdrop-filter: blur(2px);
  transition: transform 0.05s ease, box-shadow 0.1s ease, background 0.1s ease;
}

.tbtn:active {
  transform: scale(0.92);
  background: rgba(196, 240, 0, 0.25);
  box-shadow: 0 0 22px var(--neon), inset 0 0 16px rgba(196, 240, 0, 0.4);
}

.tbtn-jump {
  width: 92px;
  height: 92px;
  font-size: 38px;
  color: var(--hot);
  border-color: var(--hot);
  box-shadow: 0 0 14px rgba(255, 90, 31, 0.5), inset 0 0 12px rgba(255, 90, 31, 0.25);
  text-shadow: 0 0 10px var(--hot);
}
.tbtn-jump:active {
  background: rgba(255, 90, 31, 0.28);
  box-shadow: 0 0 26px var(--hot), inset 0 0 18px rgba(255, 90, 31, 0.45);
}
