/* ============================================================
   NEON NIGHTS — 80s Arcade
   Nostalgia layer: neon glow, CRT scanlines, pixel aesthetic
   ============================================================ */

:root {
  --neon-pink:   #ff2d95;
  --neon-cyan:   #23e6ff;
  --neon-purple: #b026ff;
  --neon-yellow: #ffe14d;
  --neon-green:  #39ff88;
  --neon-orange: #ff7a3c;
  --bg-deep:     #05020f;
  --bg-panel:    #0c0618;
  --glass:       rgba(10, 6, 24, 0.72);
  --font-pixel:  'Press Start 2P', 'Courier New', monospace;
  --font-crt:    'VT323', 'Courier New', monospace;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-deep);
  color: #e8e6ff;
  font-family: var(--font-crt);
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

/* ---------- Canvas ---------- */
#scene {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  z-index: 0;
  touch-action: none;
}

/* ---------- Shared overlay ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none; /* overrides to auto for interactive bits */
}
.overlay > * { pointer-events: auto; }

/* ---------- Loading CRT ---------- */
#loading {
  background: var(--bg-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  z-index: 100;
  transition: opacity 0.6s ease;
}
#loading.hide { opacity: 0; pointer-events: none; }

.crt-wrap { width: min(560px, 86vw); }

.crt {
  position: relative;
  background: #000;
  border: 3px solid #1a2333;
  border-radius: 14px;
  box-shadow:
    0 0 0 2px #000,
    0 0 22px rgba(35, 230, 255, .35),
    0 0 60px rgba(255, 45, 149, .22),
    inset 0 0 30px rgba(0,0,0,.8);
  padding: 42px 34px;
  overflow: hidden;
}
.crt-scanlines {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255,255,255,0.04) 0px,
    rgba(255,255,255,0.04) 1px,
    rgba(0,0,0,0.15) 2px,
    rgba(0,0,0,0.15) 3px
  );
  pointer-events: none;
  mix-blend-mode: overlay;
}
.crt-text {
  font-family: var(--font-pixel);
  font-size: 13px;
  line-height: 2.2;
  color: var(--neon-green);
  text-shadow: 0 0 6px rgba(57,255,136,.8);
  position: relative;
}
.boot-line { color: var(--neon-cyan); text-shadow: 0 0 6px rgba(35,230,255,.8); }
.boot-flicker { color: var(--neon-yellow); text-shadow: 0 0 8px rgba(255,225,77,.9); animation: flicker 1.6s infinite; }
.boot-dots { color: var(--neon-purple); text-shadow: 0 0 6px rgba(176,38,255,.8); margin-top: 18px; font-size: 11px; }
.dotdot { animation: blink 1s steps(2) infinite; }
@keyframes flicker { 0%, 100% {opacity:1;} 8%{opacity:.4;} 12%{opacity:1;} 48%{opacity:1;} 52%{opacity:.3;} 56%{opacity:1;} }
@keyframes blink { 0%,49%{opacity:1;} 50%,100%{opacity:0;} }

/* ---------- HUD ---------- */
.hud { z-index: 20; }
.hud-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  background: linear-gradient(to bottom, rgba(5,2,15,.85), transparent);
  pointer-events: none;
}
.arcade-sign {
  font-family: var(--font-pixel);
  font-size: clamp(20px, 4.4vw, 40px);
  letter-spacing: 3px;
  color: #fff;
  background: linear-gradient(90deg, var(--neon-pink), var(--neon-purple), var(--neon-cyan));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 10px rgba(255,45,149,.7)) drop-shadow(0 0 26px rgba(35,230,255,.4));
  animation: signPulse 3.2s ease-in-out infinite;
}
@keyframes signPulse {
  0%,100% { filter: drop-shadow(0 0 10px rgba(255,45,149,.6)) drop-shadow(0 0 24px rgba(35,230,255,.35)); }
  50%     { filter: drop-shadow(0 0 14px rgba(255,45,149,.95)) drop-shadow(0 0 34px rgba(35,230,255,.55)); }
}
.hud-sub {
  margin-top: 8px;
  font-family: var(--font-pixel);
  font-size: clamp(8px, 1.2vw, 11px);
  color: var(--neon-yellow);
  text-shadow: 0 0 6px rgba(255,225,77,.6);
  letter-spacing: 2px;
}

/* Controls hint */
.hud-controls {
  position: absolute;
  top: 88px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
}
.control-hint {
  background: var(--glass);
  border: 1px solid rgba(35,230,255,.25);
  border-radius: 999px;
  padding: 7px 16px;
  font-family: var(--font-crt);
  font-size: 15px;
  color: #cfd8ff;
  backdrop-filter: blur(4px);
  box-shadow: 0 0 18px rgba(35,230,255,.15);
  pointer-events: none;
}
.control-hint .key {
  display: inline-block;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 13px;
  color: var(--neon-cyan);
}

/* Bottom: leaderboard + location */
.hud-bottom {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 16px 20px;
  gap: 20px;
  background: linear-gradient(to top, rgba(5,2,15,.85), transparent);
  pointer-events: none;
}
.credits-block { min-width: min(400px, 40vw); }
.leaderboard-title {
  font-family: var(--font-pixel);
  font-size: 9px;
  color: var(--neon-pink);
  letter-spacing: 2px;
  margin-bottom: 8px;
  text-shadow: 0 0 6px rgba(255,45,149,.6);
}
.leaderboard {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.lb-chip {
  background: var(--glass);
  border: 1px solid rgba(255,255,255,.12);
  border-left: 3px solid var(--chip-neon, var(--neon-cyan));
  border-radius: 6px;
  padding: 4px 10px;
  font-family: var(--font-crt);
  font-size: 15px;
  color: #e8e6ff;
  backdrop-filter: blur(3px);
  box-shadow: 0 0 12px color-mix(in srgb, var(--chip-neon, var(--neon-cyan)) 30%, transparent);
  pointer-events: none;
}
.lb-chip b { color: var(--chip-neon, var(--neon-cyan)); }
.location-chip {
  background: var(--glass);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 8px;
  padding: 4px 12px;
  font-family: var(--font-crt);
  font-size: 15px;
  color: #fff;
  text-align: right;
  pointer-events: none;
}
.location-chip .chip-label {
  display: block;
  font-family: var(--font-pixel);
  font-size: 7px;
  color: var(--neon-cyan);
  letter-spacing: 2px;
  margin-bottom: 2px;
}

/* ---------- Prompt (interact) ---------- */
.prompt {
  position: fixed;
  bottom: 120px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-panel);
  border: 2px solid var(--neon-cyan);
  border-radius: 8px;
  padding: 12px 20px;
  font-family: var(--font-pixel);
  font-size: 11px;
  color: var(--neon-cyan);
  box-shadow: 0 0 24px rgba(35,230,255,.5), inset 0 0 14px rgba(35,230,255,.15);
  text-align: center;
  z-index: 40;
  animation: promptPulse 1.4s ease-in-out infinite;
  pointer-events: none;
  max-width: 80vw;
}
.prompt .prompt-game { color: var(--neon-pink); display: block; font-size: 13px; margin-bottom: 4px; text-shadow: 0 0 8px rgba(255,45,149,.6); }
@keyframes promptPulse { 0%,100%{ box-shadow:0 0 20px rgba(35,230,255,.4);} 50%{ box-shadow:0 0 34px rgba(35,230,255,.75);} }

/* ---------- Game overlay ---------- */
.game-overlay {
  z-index: 60;
  background: rgba(2,0,8,.96);
  display: flex;
  flex-direction: column;
  padding: 12px;
  pointer-events: auto;
}
#gameCanvas {
  flex: 1;
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
  border: 1px solid #1a2333;
  border-radius: 8px;
  image-rendering: pixelated;
  min-height: 0;
}
.game-topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 4px;
}
.game-title {
  font-family: var(--font-pixel);
  font-size: 14px;
  color: var(--neon-pink);
  text-shadow: 0 0 8px rgba(255,45,149,.7);
}
.game-meta { flex: 1; font-family: var(--font-crt); font-size: 15px; color: #9aa; }
.game-exit {
  background: transparent;
  border: 2px solid var(--neon-pink);
  color: var(--neon-pink);
  border-radius: 6px;
  width: 36px;
  height: 36px;
  font-size: 18px;
  cursor: pointer;
  text-shadow: 0 0 6px rgba(255,45,149,.6);
  transition: all .15s;
  pointer-events: auto;
}
.game-exit:hover { background: rgba(255,45,149,.18); box-shadow: 0 0 16px rgba(255,45,149,.6); }
.game-help { font-family: var(--font-crt); font-size: 14px; color: #889; text-align: center; padding: 6px; }
.game-help b { color: var(--neon-cyan); }

/* EmulatorJS injected markup tweaks */
#gameCanvas .ejs_parent { position: absolute; inset: 0; }

/* ---------- Register / choose cabinet ---------- */
.register-overlay {
  z-index: 50;
  background: rgba(3,1,10,.8);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  backdrop-filter: blur(3px);
}
.register-card {
  position: relative;
  width: min(520px, 92vw);
  max-height: 82vh;
  overflow: auto;
  background: linear-gradient(160deg, #12082a, #0a0318);
  border: 1px solid rgba(35,230,255,.25);
  border-radius: 14px;
  padding: 28px;
  box-shadow: 0 0 40px rgba(176,38,255,.25), 0 0 80px rgba(255,45,149,.12);
}
.register-card h2 {
  font-family: var(--font-pixel);
  font-size: 16px;
  color: var(--neon-cyan);
  text-shadow: 0 0 8px rgba(35,230,255,.7);
  margin-bottom: 8px;
}
.register-sub { font-family: var(--font-crt); font-size: 16px; color: #9aa; margin-bottom: 18px; }
.rom-list { display: flex; flex-direction: column; gap: 10px; }
.rom-item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.1);
  border-left: 4px solid var(--neon-purple);
  border-radius: 8px;
  padding: 12px 14px;
  cursor: pointer;
  transition: all .15s;
}
.rom-item:hover {
  border-left-color: var(--neon-cyan);
  background: rgba(35,230,255,.08);
  box-shadow: 0 0 16px rgba(35,230,255,.25);
}
.rom-item .rom-art { width: 44px; height: 44px; flex: 0 0 44px; border-radius: 6px; display:flex; align-items:center; justify-content:center; font-size: 24px; background: rgba(255,255,255,.05); }
.rom-item .rom-name { font-family: var(--font-pixel); font-size: 11px; color: #fff; }
.rom-item .rom-desc { font-family: var(--font-crt); font-size: 14px; color: #99a; margin-top: 3px; }
.rom-item .rom-tag { margin-left:auto; font-family: var(--font-pixel); font-size: 7px; color: var(--neon-yellow); border:1px solid rgba(255,225,77,.4); border-radius:4px; padding:3px 5px; }
.register-footnote { margin-top: 16px; }
.file-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 2px dashed rgba(35,230,255,.35);
  border-radius: 8px;
  padding: 14px;
  font-family: var(--font-crt);
  font-size: 15px;
  color: var(--neon-cyan);
  cursor: pointer;
  transition: all .15s;
}
.file-label:hover { border-color: var(--neon-cyan); background: rgba(35,230,255,.06); }
.file-label input { display: none; }
.register-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: transparent;
  border: 2px solid var(--neon-pink);
  color: var(--neon-pink);
  width: 32px;
  height: 32px;
  border-radius: 6px;
  font-size: 15px;
  cursor: pointer;
}
.register-close:hover { background: rgba(255,45,149,.18); }

/* empty rom list */
.rom-empty { font-family: var(--font-crt); font-size: 15px; color: #778; padding: 14px; text-align:center; border:1px dashed rgba(255,255,255,.15); border-radius:8px; }

/* ---------- Motion / reduced ---------- */
@media (prefers-reduced-motion: reduce) {
  .arcade-sign, .boot-flicker, .prompt { animation: none !important; }
}

/* Hide scrollbars but keep scroll on register card */
.register-card::-webkit-scrollbar { width: 6px; }
.register-card::-webkit-scrollbar-thumb { background: rgba(35,230,255,.3); border-radius: 3px; }
