:root {
  --gold: #FFD700;
  --blue: #00bfff;
  --purple: #8A2BE2;
  --bg: #05010f;
}

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

html, body {
  background: radial-gradient(ellipse at 50% 30%, #16072e 0%, #05010f 70%);
  color: #e6e1ff;
  font-family: 'IBM Plex Mono', monospace;
  min-height: 100%;
  overflow-x: hidden;
  touch-action: manipulation;
}

/* Starfield */
#stars { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
#stars span {
  position: absolute;
  background: #fff;
  border-radius: 50%;
  opacity: 0.5;
  animation: twinkle 4s infinite ease-in-out;
}
@keyframes twinkle { 0%,100% { opacity: 0.15; } 50% { opacity: 0.9; } }

/* Title screen */
#title-screen {
  position: fixed; inset: 0; z-index: 100;
  background: radial-gradient(ellipse at center, rgba(30,10,60,0.96), rgba(5,1,15,0.99));
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 28px; text-align: center; padding: 20px;
}
.genesis {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(14px, 4vw, 30px);
  line-height: 1.8;
  color: var(--gold);
  text-shadow: 0 0 20px rgba(255,215,0,0.6);
  animation: floaty 3s ease-in-out infinite;
}
@keyframes floaty { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
#beginBtn {
  font-family: 'Press Start 2P', monospace;
  font-size: 14px;
  padding: 18px 26px;
  background: transparent;
  color: var(--blue);
  border: 3px solid var(--blue);
  border-radius: 8px;
  cursor: pointer;
  text-shadow: 0 0 10px var(--blue);
  box-shadow: 0 0 24px rgba(0,191,255,0.4);
  transition: transform .15s, box-shadow .15s;
}
#beginBtn:hover { transform: scale(1.06); box-shadow: 0 0 40px rgba(0,191,255,0.7); }
.subtle { color: #8a84b0; font-size: 12px; }

/* HUD */
#hud {
  position: relative; z-index: 2;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 18px; max-width: 720px; margin: 0 auto;
}
.hud-title {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(16px, 5vw, 26px);
  color: var(--gold);
  text-shadow: 0 0 16px rgba(255,215,0,0.7);
  letter-spacing: 1px;
}
.hud-stats { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; }
.stat { display: flex; flex-direction: column; align-items: flex-start; }
.stat .label { font-size: 9px; letter-spacing: 1px; color: #8a84b0; }
.stat span:not(.label) { font-family: 'Press Start 2P', monospace; font-size: 15px; color: #fff; }
.stat.omni { cursor: help; }
.omni-bar { width: 90px; height: 10px; margin-top: 4px; border: 1px solid var(--purple); border-radius: 6px; overflow: hidden; }
.omni-fill { width: 100%; height: 100%; background: linear-gradient(90deg, var(--purple), var(--gold)); animation: pulseFill 1.4s infinite; }
@keyframes pulseFill { 0%,100% { opacity: 0.7; } 50% { opacity: 1; } }

/* Game */
#game-wrap {
  position: relative; z-index: 2;
  display: flex; justify-content: center;
  max-width: 720px; margin: 0 auto; padding: 4px;
}
#canvas {
  border-radius: 10px;
  box-shadow: 0 0 50px rgba(0,191,255,0.25), inset 0 0 30px rgba(0,0,0,0.6);
  max-width: 100%;
}

/* Controls */
#controls {
  position: relative; z-index: 2;
  display: flex; flex-wrap: wrap; gap: 10px; justify-content: center;
  padding: 16px; max-width: 720px; margin: 0 auto;
}
.pow {
  font-family: 'IBM Plex Mono', monospace; font-weight: 600;
  font-size: 13px; padding: 10px 14px;
  background: rgba(20,8,40,0.8); color: #fff;
  border: 2px solid var(--purple); border-radius: 8px;
  cursor: pointer;
  transition: transform .12s, box-shadow .12s, background .12s;
}
.pow kbd {
  font-size: 9px; background: #000; padding: 2px 5px; border-radius: 3px;
  border: 1px solid #444; margin-left: 4px;
}
.pow:hover { transform: translateY(-2px); box-shadow: 0 0 18px rgba(138,43,226,0.7); background: rgba(40,16,70,0.9); }
.pow:active { transform: scale(0.95); }

/* D-pad (mobile) */
#dpad {
  position: fixed; bottom: 14px; right: 14px; z-index: 5;
  display: none; flex-direction: column; align-items: center; gap: 4px;
}
.dpad-row { display: flex; gap: 4px; }
#dpad button {
  width: 52px; height: 52px; font-size: 20px;
  background: rgba(0,191,255,0.15); color: var(--blue);
  border: 2px solid var(--blue); border-radius: 10px;
  cursor: pointer; touch-action: none;
}
#dpad button:active { background: rgba(0,191,255,0.4); }

/* Leaderboard */
#leaderboard {
  position: relative; z-index: 2;
  max-width: 460px; margin: 20px auto;
  background: rgba(15,6,32,0.7);
  border: 1px solid rgba(138,43,226,0.4);
  border-radius: 12px; padding: 20px;
}
#leaderboard h2 {
  font-family: 'Press Start 2P', monospace;
  font-size: 13px; color: var(--purple);
  text-align: center; margin-bottom: 14px;
  text-shadow: 0 0 12px rgba(138,43,226,0.6);
}
#lb-list { list-style: none; }
#lb-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 6px; border-bottom: 1px solid rgba(255,255,255,0.06);
  font-size: 14px;
}
#lb-list li.empty { color: #6a6488; justify-content: center; }
.rank { width: 28px; text-align: center; }
.lbn { flex: 1; color: #d8d2ff; }
.lbs { font-family: 'Press Start 2P', monospace; font-size: 12px; color: var(--gold); }
#auth-status { text-align: center; margin-top: 14px; font-size: 12px; color: #8a84b0; }
#auth-status a { color: var(--blue); }

/* Footer */
footer {
  position: relative; z-index: 2;
  text-align: center; padding: 24px 16px 40px;
}
.tagline { font-style: italic; color: #7a7499; margin-bottom: 10px; font-size: 13px; }
footer a { color: var(--gold); text-decoration: none; border-bottom: 1px dashed var(--gold); }
footer a:hover { text-shadow: 0 0 10px var(--gold); }

/* Show d-pad on touch / small screens */
@media (max-width: 760px), (pointer: coarse) {
  #dpad { display: flex; }
  .pow kbd { display: none; }
}