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

:root {
  --neon-yellow: #ffe14d;
  --neon-blue: #00d4ff;
  --neon-pink: #ff2d95;
  --neon-green: #39ff14;
  --neon-orange: #ff6b2b;
  --neon-red: #ff1744;
  --bg-dark: #0a0a1a;
  --bg-surface: #0f0f2a;
}

body {
  background: var(--bg-dark);
  color: #fff;
  font-family: 'Press Start 2P', monospace;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  display: flex;
  justify-content: center;
  align-items: center;
}

#game-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 600px;
  height: 100vh;
  max-height: 100vh;
  padding: 8px;
  gap: 6px;
}

/* ─── HUD ─── */
#hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 4px 12px;
  background: rgba(15, 15, 42, 0.85);
  border: 1px solid rgba(0, 212, 255, 0.25);
  border-radius: 8px;
  backdrop-filter: blur(8px);
  position: relative;
}

.hud-left, .hud-right {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.hud-label {
  font-size: 7px;
  color: rgba(0, 212, 255, 0.6);
  letter-spacing: 2px;
}

.hud-value {
  font-size: 16px;
  color: var(--neon-yellow);
  text-shadow: 0 0 10px rgba(255, 225, 77, 0.7), 0 0 20px rgba(255, 225, 77, 0.3);
}

.hud-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

#title-text {
  font-family: 'Orbitron', sans-serif;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 3px;
  background: linear-gradient(90deg, var(--neon-yellow), var(--neon-orange), var(--neon-pink));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hud-level {
  font-size: 9px;
  color: var(--neon-green);
  text-shadow: 0 0 8px rgba(57,255,20,0.6);
}

.hud-level-name {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  color: rgba(0,212,255,0.6);
  letter-spacing: 2px;
}

/* ─── CANVAS ─── */
#game {
  display: block;
  width: 100%;
  flex: 1;
  border-radius: 10px;
  border: 1px solid rgba(0, 212, 255, 0.15);
  box-shadow:
    0 0 30px rgba(0, 212, 255, 0.08),
    inset 0 0 60px rgba(10, 10, 26, 0.5);
  background: var(--bg-dark);
  image-rendering: pixelated;
}

/* ─── OVERLAY ─── */
#overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 26, 0.92);
  backdrop-filter: blur(12px);
  z-index: 100;
  transition: opacity 0.3s ease;
}

#overlay.hide {
  opacity: 0;
  pointer-events: none;
}

#overlay-content {
  text-align: center;
  padding: 20px;
}

#overlay-title {
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(24px, 6vw, 48px);
  font-weight: 900;
  margin-bottom: 20px;
  line-height: 1.3;
}

.title-main {
  background: linear-gradient(135deg, var(--neon-yellow), var(--neon-orange), var(--neon-pink));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  display: block;
  animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% { filter: drop-shadow(0 0 20px rgba(255, 225, 77, 0.4)); }
  50% { filter: drop-shadow(0 0 40px rgba(255, 225, 77, 0.7)); }
}

.overlay-big {
  font-family: 'Orbitron', sans-serif;
  font-size: clamp(20px, 5vw, 40px);
  font-weight: 900;
  display: block;
}

.overlay-score {
  font-size: clamp(14px, 4vw, 24px);
  color: var(--neon-yellow);
  margin: 8px 0;
  text-shadow: 0 0 12px rgba(255, 225, 77, 0.6);
}

.overlay-hint {
  font-size: clamp(8px, 2vw, 11px);
  color: rgba(0, 212, 255, 0.7);
}

.overlay-hint kbd {
  display: inline-block;
  padding: 2px 8px;
  background: rgba(0, 212, 255, 0.15);
  border: 1px solid rgba(0, 212, 255, 0.4);
  border-radius: 4px;
  font-family: inherit;
  color: var(--neon-blue);
}

#lives-display {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
}

.life-icon {
  width: 28px;
  height: 28px;
  background: var(--neon-yellow);
  border-radius: 50%;
  clip-path: polygon(100% 50%, 50% 50%, 75% 0%, 100% 0%, 100% 25%);
  filter: drop-shadow(0 0 6px rgba(255, 225, 77, 0.7));
  transform: rotate(225deg);
}

/* ─── NAME FORM ─── */
.name-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.name-form p {
  color: var(--neon-blue);
  font-size: 9px;
}

#name-input {
  background: rgba(0,212,255,0.1);
  border: 2px solid #00d4ff;
  border-radius: 8px;
  color: #ffe14d;
  font-family: 'Press Start 2P', monospace;
  font-size: 14px;
  padding: 10px 16px;
  text-align: center;
  outline: none;
  width: 220px;
  max-width: 80vw;
}

#name-input:focus {
  border-color: #ffe14d;
  box-shadow: 0 0 15px rgba(255,225,77,0.3);
}

#name-submit, .play-again-btn {
  margin-top: 4px;
  background: linear-gradient(135deg, #00d4ff, #3d5afe);
  border: none;
  border-radius: 8px;
  color: #fff;
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
  padding: 10px 24px;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
}

#name-submit:hover, .play-again-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 0 20px rgba(0,212,255,0.4);
}

/* ─── LEADERBOARD ─── */
.lb-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin: 10px 0;
}

.lb-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 8px;
  width: 260px;
  max-width: 85vw;
}

.lb-row.is-new {
  background: rgba(255,225,77,0.12);
  color: var(--neon-yellow) !important;
}

.lb-medal { margin-right: 6px; }
.lb-name { flex: 1; text-align: left; }
.lb-score { text-align: right; margin-left: 8px; }
.lb-level { color: #555; font-size: 7px; }

/* ─── MOBILE CONTROLS ─── */
#mobile-controls {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding-bottom: 8px;
}

.ctrl-row { display: flex; gap: 4px; }

.ctrl-btn {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  border: 1px solid rgba(0, 212, 255, 0.3);
  background: rgba(15, 15, 42, 0.8);
  color: var(--neon-blue);
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background 0.1s;
}

.ctrl-btn:active {
  background: rgba(0, 212, 255, 0.25);
  border-color: var(--neon-blue);
}

@media (hover: none) and (pointer: coarse) {
  #mobile-controls { display: flex; }
  #game-wrapper { max-height: calc(100vh - 140px); }
}
