/* =============================================================
   NEON PAC — cabinet styling, CRT overlay, HUD
   ============================================================= */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --neon: #2f6bff;
  --amber: #ffd83d;
  --pink: #ff8fd6;
  --cyan: #3fe0ff;
  --bg0: #04040c;
  --bg1: #0a0a1c;
  /* cabinet width: as big as the viewport allows, board stays square */
  --cab: min(94vw, calc(100vh - 190px), 780px);
}

html, body {
  height: 100%;
  background:
    radial-gradient(1200px 700px at 50% -10%, #131a3a 0%, #06060f 55%, #030309 100%);
  color: #cfe0ff;
  font-family: "Courier New", "DejaVu Sans Mono", ui-monospace, monospace;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  touch-action: none;
}

#cab {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 10px 24px;
}

/* ---------------------------------------------------------- HUD */
#hud {
  width: var(--cab);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: 12px;
  padding: 2px 6px 6px;
  text-transform: uppercase;
  letter-spacing: 2px;
  flex: 0 0 auto;
}
.hud-col { display: flex; flex-direction: column; gap: 3px; }
.hud-col.right { align-items: flex-end; text-align: right; }
.hud-col.mid { align-items: center; }
.label { font-size: 11px; color: #6f86b8; letter-spacing: 4px; }
.score {
  font-size: 26px; font-weight: 700; color: #fff;
  text-shadow: 0 0 8px rgba(255, 216, 61, .9), 0 0 22px rgba(255, 150, 0, .55);
  transform-origin: left center;
}
.score.bump { animation: bump .18s ease-out; }
@keyframes bump { 0% { transform: scale(1.14); color: var(--amber); } 100% { transform: scale(1); } }
.sub { font-size: 10px; color: #587099; letter-spacing: 2px; }
.lvl {
  font-size: 20px; color: var(--cyan);
  text-shadow: 0 0 10px rgba(63, 224, 255, .8);
}
.fruits { display: flex; gap: 3px; min-height: 18px; align-items: center; }
.fruitIcon { width: 17px; height: 17px; filter: drop-shadow(0 0 5px rgba(255, 143, 214, .8)); }

.lives { display: flex; gap: 6px; align-items: center; min-height: 18px; }
.life {
  width: 17px; height: 17px; display: block;
  border-radius: 50%;
  background: conic-gradient(from -34deg, transparent 0 68deg, #ffd83d 68deg 360deg);
  transform: rotate(90deg);
  filter: drop-shadow(0 0 6px rgba(255, 200, 40, .85));
  animation: nom 1.1s ease-in-out infinite;
}
.life:nth-child(2) { animation-delay: .18s; }
.life:nth-child(3) { animation-delay: .36s; }
@keyframes nom { 0%, 100% { transform: rotate(90deg) scale(1); } 50% { transform: rotate(90deg) scale(.86); } }

/* ---------------------------------------------------------- stage */
#stage {
  position: relative;
  flex: 1 1 auto;
  width: var(--cab);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  --sz: min(100%, 100vh);
}

#game {
  width: var(--sz);
  height: var(--sz);
  border-radius: 14px;
  background: #03030c;
  display: block;
  box-shadow:
    0 0 0 1px rgba(90, 140, 255, .22),
    0 0 40px rgba(35, 90, 255, .28),
    0 0 120px rgba(120, 40, 255, .18),
    inset 0 0 60px rgba(0, 0, 0, .9);
}

/* CRT: scanlines, curvature shading, subtle flicker */
#crt {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: var(--sz);
  height: var(--sz);
  border-radius: 14px;
  pointer-events: none;
  background:
    repeating-linear-gradient(to bottom, rgba(0, 0, 0, .30) 0 1px, rgba(0, 0, 0, 0) 1px 3px),
    radial-gradient(120% 100% at 50% 50%, rgba(0, 0, 0, 0) 55%, rgba(0, 0, 0, .55) 100%);
  mix-blend-mode: multiply;
  animation: flick 5.5s steps(2, end) infinite;
  opacity: .95;
}
@keyframes flick { 0%, 96% { opacity: .95; } 97% { opacity: .82; } 100% { opacity: .95; } }

#glare {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: var(--sz);
  height: var(--sz);
  border-radius: 14px;
  pointer-events: none;
  background:
    radial-gradient(60% 40% at 22% 12%, rgba(180, 220, 255, .07), rgba(0, 0, 0, 0) 70%),
    linear-gradient(160deg, rgba(255, 255, 255, .045), rgba(255, 255, 255, 0) 40%);
  box-shadow: inset 0 0 90px rgba(6, 10, 30, .8);
}

#hint {
  position: absolute;
  bottom: -20px; left: 0; right: 0;
  text-align: center;
  font-size: 10px;
  letter-spacing: 2px;
  color: #5a7099;
  text-transform: uppercase;
  pointer-events: none;
  text-shadow: 0 0 12px rgba(60, 120, 255, .35);
}

/* virtual thumb stick (touch) */
#stick {
  position: fixed;
  width: 90px; height: 90px;
  margin: -45px 0 0 -45px;
  border-radius: 50%;
  border: 1px solid rgba(120, 180, 255, .35);
  background: radial-gradient(circle, rgba(30, 60, 140, .35), rgba(0, 0, 0, .1));
  opacity: 0;
  transition: opacity .18s;
  pointer-events: none;
  z-index: 30;
}
#stick i {
  position: absolute; left: 50%; top: 50%;
  width: 40px; height: 40px; margin: -20px 0 0 -20px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff8dc, #ffd83d 55%, #c47f00);
  box-shadow: 0 0 18px rgba(255, 200, 60, .8);
  display: block;
}

/* test harness error surface */
#dbg {
  display: none;
  position: absolute;
  left: 8px; right: 8px; bottom: 22px;
  padding: 6px 8px;
  font: 11px/1.3 monospace;
  color: #ffd6d6;
  background: rgba(120, 0, 20, .85);
  border: 1px solid #ff5566;
  border-radius: 6px;
  z-index: 40;
  white-space: pre-wrap;
}

@media (max-width: 560px) {
  #hud { font-size: 10px; letter-spacing: 1px; }
  .score { font-size: 20px; }
  #hint { display: none; }
}
