@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

:root {
  --bg-color: #000033;
  --neon-cyan: #00ffff;
  --neon-pink: #ff00bb;
  --neon-green: #39ff14;
  --text-shadow-cyan: 0 0 5px var(--neon-cyan), 0 0 15px var(--neon-cyan);
  --text-shadow-pink: 0 0 5px var(--neon-pink), 0 0 15px var(--neon-pink);
  --box-shadow-cyan: 0 0 10px var(--neon-cyan), inset 0 0 10px var(--neon-cyan);
  --box-shadow-pink: 0 0 10px var(--neon-pink), inset 0 0 10px var(--neon-pink);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-color);
  font-family: 'Courier New', Courier, monospace;
  color: #ffffff;
}

#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background: radial-gradient(circle, #000044 0%, #000011 100%);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  background-color: transparent;
}

/* CRT Scanline and Flicker Effects */
#crt-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
  background-size: 100% 4px, 6px 100%;
  pointer-events: none;
  z-index: 10;
  opacity: 0.85;
}

#crt-overlay::after {
  content: " ";
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  background: rgba(18, 16, 16, 0.1);
  opacity: 0;
  pointer-events: none;
  animation: flicker 0.15s infinite;
}

@keyframes flicker {
  0% { opacity: 0.18; }
  50% { opacity: 0.22; }
  100% { opacity: 0.18; }
}

/* UI Overlay Screens */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 5;
  background: rgba(0, 0, 51, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: opacity 0.5s ease, visibility 0.5s ease;
  opacity: 0;
  visibility: hidden;
  padding: 20px;
  text-align: center;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.screen.active {
  opacity: 1;
  visibility: visible;
}

/* Common UI Elements */
h1 {
  font-family: 'Press Start 2P', monospace;
  font-size: 2.5rem;
  color: var(--neon-cyan);
  text-shadow: var(--text-shadow-cyan);
  margin-bottom: 2rem;
  letter-spacing: 2px;
  animation: pulse-cyan 2s infinite ease-in-out;
}

h2 {
  font-family: 'Press Start 2P', monospace;
  font-size: 1.5rem;
  color: var(--neon-pink);
  text-shadow: var(--text-shadow-pink);
  margin-bottom: 1.5rem;
}

.narrative-text {
  font-size: 1rem;
  line-height: 1.6;
  max-width: 600px;
  margin-bottom: 2rem;
  color: #d1d1ff;
  border-left: 3px solid var(--neon-pink);
  padding-left: 15px;
}

.btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 1rem;
  color: #ffffff;
  background: transparent;
  border: 2px solid var(--neon-pink);
  padding: 12px 24px;
  cursor: pointer;
  outline: none;
  box-shadow: var(--box-shadow-pink);
  transition: all 0.2s ease;
  margin: 10px;
  text-shadow: var(--text-shadow-pink);
}

.btn:hover, .btn:focus {
  background-color: var(--neon-pink);
  color: #000000;
  box-shadow: 0 0 20px var(--neon-pink);
  text-shadow: none;
}

.btn-cyan {
  border-color: var(--neon-cyan);
  box-shadow: var(--box-shadow-cyan);
  text-shadow: var(--text-shadow-cyan);
}

.btn-cyan:hover, .btn-cyan:focus {
  background-color: var(--neon-cyan);
  color: #000000;
  box-shadow: 0 0 20px var(--neon-cyan);
  text-shadow: none;
}

/* Animations */
@keyframes pulse-cyan {
  0%, 100% { text-shadow: var(--text-shadow-cyan); }
  50% { text-shadow: 0 0 15px var(--neon-cyan), 0 0 30px var(--neon-cyan); }
}

@keyframes pulse-pink {
  0%, 100% { text-shadow: var(--text-shadow-pink); }
  50% { text-shadow: 0 0 15px var(--neon-pink), 0 0 30px var(--neon-pink); }
}

/* Game HUD Overlay (visible when playing) */
#hud-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 3;
  display: none;
  padding: 20px;
  flex-direction: column;
  justify-content: space-between;
}

#hud-overlay.active {
  display: flex;
}

.hud-row {
  display: flex;
  justify-content: space-between;
  width: 100%;
}

.hud-panel {
  background: rgba(0, 0, 51, 0.6);
  border: 1px solid var(--neon-cyan);
  box-shadow: 0 0 8px rgba(0, 255, 255, 0.3);
  padding: 10px 15px;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.8rem;
  color: var(--neon-cyan);
  text-shadow: 0 0 4px var(--neon-cyan);
}

.hud-shield {
  display: flex;
  align-items: center;
  gap: 10px;
}

.shield-bar-bg {
  width: 100px;
  height: 12px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--neon-pink);
}

.shield-bar-fill {
  width: 100%;
  height: 100%;
  background: var(--neon-pink);
  box-shadow: 0 0 5px var(--neon-pink);
  transition: width 0.15s ease-out;
}

/* Mobile Controls Styles */
#mobile-controls {
  display: none;
  position: absolute;
  bottom: 25px;
  left: 0;
  width: 100%;
  justify-content: flex-end;
  padding: 0 30px;
  z-index: 8;
  pointer-events: none;
}

.mobile-action-buttons {
  display: flex;
  align-items: flex-end;
  gap: 15px;
  pointer-events: auto;
}

.action-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: rgba(255, 0, 187, 0.15);
  border: 2px solid var(--neon-pink);
  box-shadow: var(--box-shadow-pink);
  color: var(--neon-pink);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.6rem;
  font-weight: bold;
  cursor: pointer;
}

.action-btn:active {
  background: var(--neon-pink);
  color: #000000;
}

.action-boost {
  margin-bottom: 25px;
}

/* Display mobile controls on touchscreen/mobile devices */
@media (max-width: 1024px) or (hover: none) and (pointer: coarse) {
  #mobile-controls {
    display: flex;
  }
  
  /* Make HUD smaller on mobile */
  .hud-panel {
    font-size: 0.65rem;
    padding: 6px 10px;
  }
  
  .shield-bar-bg {
    width: 60px;
  }

  /* Make screens fit cleanly on mobile screens and allow scroll */
  .screen {
    justify-content: flex-start;
    padding-top: 35px;
    padding-bottom: 35px;
  }
  
  h1 {
    font-size: 1.5rem;
    margin-bottom: 1.2rem;
  }
  
  h2 {
    font-size: 1rem;
    margin-bottom: 0.8rem;
  }
  
  .narrative-text {
    font-size: 0.8rem;
    line-height: 1.4;
    margin-bottom: 1.2rem;
    padding-left: 10px;
    max-width: 100%;
  }
  
  .btn {
    font-size: 0.8rem;
    padding: 10px 20px;
    margin: 5px;
  }
  
  #start-screen div[style*="margin-bottom: 2rem"] {
    margin-bottom: 1.2rem !important;
    font-size: 0.75rem !important;
  }
}

/* Leaderboard Overlay Styles (to match Agent B's expected styles) */
.leaderboard-container {
  width: 100%;
  max-width: 450px;
  margin: 15px 0;
  border: 2px solid var(--neon-cyan);
  box-shadow: var(--box-shadow-cyan);
  background: rgba(0, 0, 0, 0.6);
  padding: 15px;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  font-family: monospace;
  font-size: 1rem;
}

.leaderboard-table th {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.75rem;
  color: var(--neon-pink);
  text-shadow: var(--text-shadow-pink);
  border-bottom: 2px solid var(--neon-pink);
  padding: 8px;
  text-align: left;
}

.leaderboard-table td {
  padding: 8px;
  border-bottom: 1px solid rgba(0, 255, 255, 0.2);
  color: #ffffff;
}

.leaderboard-table tr:hover td {
  color: var(--neon-cyan);
  text-shadow: 0 0 5px var(--neon-cyan);
}

.leaderboard-highlight td {
  color: var(--neon-green) !important;
  font-weight: bold;
}

.leaderboard-input-box {
  margin-top: 15px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.leaderboard-input-box label {
  font-size: 0.9rem;
  color: #ffffff;
}

.leaderboard-input {
  font-family: 'Press Start 2P', monospace;
  font-size: 1rem;
  background: transparent;
  border: 2px solid var(--neon-cyan);
  color: var(--neon-cyan);
  padding: 8px;
  text-align: center;
  width: 120px;
  text-transform: uppercase;
  outline: none;
  box-shadow: var(--box-shadow-cyan);
}

.leaderboard-input:focus {
  border-color: var(--neon-pink);
  box-shadow: var(--box-shadow-pink);
  color: var(--neon-pink);
}
