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

:root {
  --bg: #050a0f;
  --rack: #1a2332;
  --rack-light: #2a3a4f;
  --cable: #00ff88;
  --player: #ffcc00;
  --enemy-1: #ff3366;
  --enemy-2: #00ccff;
  --enemy-3: #ff9900;
  --enemy-4: #cc66ff;
  --wall: #0d1b2a;
  --text: #e0f7fa;
  --accent: #00e5ff;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

html, body {
  width: 100%;
  height: 100%;
  background: var(--bg);
  font-family: 'Press Start 2P', cursive;
  color: var(--text);
  overflow: hidden;
  overscroll-behavior: none;
}

#game-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100vw;
  height: 100vh;
  padding: 4px;
}

header {
  text-align: center;
  margin-bottom: 6px;
}

header h1 {
  font-size: 24px;
  color: var(--accent);
  text-shadow: 0 0 8px var(--accent), 0 0 20px var(--accent);
  letter-spacing: 3px;
}

.subtitle {
  font-size: 9px;
  color: var(--cable);
  margin-top: 4px;
  text-shadow: 0 0 4px var(--cable);
}

#hud {
  display: flex;
  gap: 12px;
  margin-bottom: 6px;
  font-size: 10px;
  color: var(--text);
  flex-wrap: wrap;
  justify-content: center;
}

.hud-item {
  background: rgba(0, 229, 255, 0.08);
  border: 1px solid var(--accent);
  padding: 4px 10px;
  border-radius: 4px;
}

.hud-item span {
  color: var(--player);
}

#gameCanvas {
  border: 3px solid var(--accent);
  border-radius: 6px;
  box-shadow: 0 0 20px rgba(0, 229, 255, 0.15);
  background: var(--wall);
  image-rendering: pixelated;
  max-width: 100vw;
  max-height: 55vh;
  touch-action: none;
}

#overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(5, 10, 15, 0.92);
  z-index: 10;
}

#message {
  font-size: 18px;
  color: var(--accent);
  text-shadow: 0 0 10px var(--accent);
  animation: blink 1s step-end infinite;
  margin-bottom: 16px;
  text-align: center;
  line-height: 1.6;
  padding: 0 16px;
}

@keyframes blink {
  50% { opacity: 0; }
}

.start-button {
  font-family: 'Press Start 2P', cursive;
  font-size: 16px;
  color: var(--bg);
  background: var(--accent);
  border: 3px solid var(--accent);
  padding: 14px 32px;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 0 15px rgba(0, 229, 255, 0.4);
  transition: transform 0.1s, box-shadow 0.1s;
  margin-bottom: 20px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.start-button:active {
  transform: scale(0.95);
  box-shadow: 0 0 8px rgba(0, 229, 255, 0.3);
}

#high-scores {
  text-align: center;
}

#high-scores h2 {
  font-size: 12px;
  color: var(--cable);
  margin-bottom: 10px;
}

#highScoresList {
  list-style: none;
  font-size: 10px;
  line-height: 2;
  color: var(--text);
}

#highScoresList li:nth-child(1) { color: #ffd700; }
#highScoresList li:nth-child(2) { color: #c0c0c0; }
#highScoresList li:nth-child(3) { color: #cd7f32; }

#controls-hint {
  margin-top: 6px;
  display: flex;
  gap: 16px;
  font-size: 8px;
  color: #4a6572;
}

/* Mobile controls */
#mobile-controls {
  display: none;
  margin-top: 6px;
  z-index: 20;
}

.dpad {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.dpad-row {
  display: flex;
  gap: 4px;
  align-items: center;
  justify-content: center;
}

.dpad-btn {
  width: 56px;
  height: 56px;
  font-size: 22px;
  color: var(--accent);
  background: rgba(0, 229, 255, 0.12);
  border: 2px solid var(--accent);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  transition: background 0.1s, transform 0.05s;
}

.dpad-btn:active {
  background: rgba(0, 229, 255, 0.35);
  transform: scale(0.92);
}

.hidden {
  display: none !important;
}

/* Desktop specific */
.desktop-hint {
  display: inline;
}

/* Touch device / mobile overrides */
@media (pointer: coarse) {
  .desktop-hint {
    display: none;
  }
  #mobile-controls {
    display: flex;
    justify-content: center;
  }
  #controls-hint {
    font-size: 7px;
    gap: 10px;
  }
}

/* Small screens */
@media (max-width: 420px) {
  header h1 {
    font-size: 16px;
    letter-spacing: 2px;
  }
  .subtitle {
    font-size: 7px;
  }
  #hud {
    gap: 6px;
    font-size: 8px;
  }
  .hud-item {
    padding: 3px 6px;
  }
  #message {
    font-size: 14px;
  }
  .start-button {
    font-size: 13px;
    padding: 10px 22px;
  }
  #high-scores h2 {
    font-size: 10px;
  }
  #highScoresList {
    font-size: 8px;
  }
  .dpad-btn {
    width: 48px;
    height: 48px;
    font-size: 18px;
  }
}

/* Height-based scaling for canvas */
@media (max-height: 700px) {
  #gameCanvas {
    max-height: 48vh;
  }
}
@media (max-height: 600px) {
  #gameCanvas {
    max-height: 42vh;
  }
  #mobile-controls {
    margin-top: 4px;
  }
  .dpad-btn {
    width: 42px;
    height: 42px;
    font-size: 16px;
  }
}
