@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0
}

:root {
  --yellow: #FFD700;
  --blue: #1a1aff;
  --dark: #000010;
  --cyan: #00FFFF
}

body {
  background: var(--dark);
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  font-family: 'Press Start 2P', monospace;
  color: #fff;
  overflow-x: hidden;
  padding: 10px 0
}

#game-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 520px;
  padding: 0 8px
}

#title-bar {
  display: flex;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 6px;
  font-size: clamp(7px, 1.8vw, 11px);
  letter-spacing: 1px
}

#score-display,
#hiscore-display {
  flex: 1;
  text-align: center
}

#main-title {
  font-size: clamp(18px, 5vw, 32px);
  color: var(--yellow);
  text-shadow: 0 0 20px var(--yellow), 0 0 40px #ffaa00;
  letter-spacing: 4px;
  margin-bottom: 4px;
  text-align: center;
  animation: titlePulse 2s ease-in-out infinite alternate
}

@keyframes titlePulse {
  from {
    text-shadow: 0 0 15px var(--yellow), 0 0 30px #ffaa00
  }

  to {
    text-shadow: 0 0 30px var(--yellow), 0 0 60px #ff8800, 0 0 80px #ff4400
  }
}

#canvas-container {
  position: relative;
  width: 100%;
  border: 3px solid var(--blue);
  box-shadow: 0 0 30px var(--blue), inset 0 0 30px rgba(0, 0, 40, .8);
  background: #000;
  border-radius: 4px;
  overflow: hidden
}

#gameCanvas {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: pixelated
}

#overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 10, .88);
  z-index: 10;
  gap: 14px;
  padding: 20px;
  text-align: center
}

#overlay.hidden {
  display: none
}

#overlay h2 {
  font-size: clamp(14px, 4vw, 24px);
  color: var(--yellow);
  text-shadow: 0 0 20px var(--yellow);
  line-height: 1.6
}

#overlay p {
  font-size: clamp(7px, 2vw, 10px);
  color: #ccc;
  line-height: 2;
  max-width: 280px
}

.btn {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(9px, 2.5vw, 13px);
  color: var(--dark);
  background: var(--yellow);
  border: none;
  padding: 10px 24px;
  cursor: pointer;
  border-radius: 2px;
  box-shadow: 0 4px 0 #a07800, 0 0 20px var(--yellow);
  transition: transform .08s, box-shadow .08s;
  letter-spacing: 1px
}

.btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #a07800
}

.btn:hover {
  background: #ffe44d
}

#status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin-top: 6px;
  font-size: clamp(7px, 1.8vw, 10px);
  padding: 0 4px
}

#lives-display {
  display: flex;
  gap: 6px;
  align-items: center
}

#level-display {
  color: var(--cyan)
}

#level-label {
  color: #aaa
}

#mute-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(6px, 1.6vw, 9px);
  background: transparent;
  border: 1px solid #555;
  color: #aaa;
  padding: 4px 8px;
  cursor: pointer;
  border-radius: 2px;
  transition: border-color .1s, color .1s;
  white-space: nowrap
}

#mute-btn:hover {
  border-color: var(--yellow);
  color: var(--yellow)
}

#mute-btn.muted {
  color: #ff5555;
  border-color: #ff5555
}

#dpad {
  display: none;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 4px;
  width: 150px;
  height: 150px;
  margin-top: 14px
}

.dpad-btn {
  font-family: monospace;
  font-size: 20px;
  background: rgba(255, 215, 0, .15);
  border: 2px solid rgba(255, 215, 0, .4);
  color: var(--yellow);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  transition: background .1s
}

.dpad-btn:active {
  background: rgba(255, 215, 0, .4)
}

.dpad-center {
  background: transparent;
  border-color: transparent;
  pointer-events: none
}

@media(pointer:coarse) {
  #dpad {
    display: grid
  }
}

@media(max-width:400px) {
  #dpad {
    width: 130px;
    height: 130px
  }
}

#ghost-legend {
  display: flex;
  gap: 10px;
  margin-top: 10px;
  font-size: clamp(5px, 1.5vw, 8px);
  flex-wrap: wrap;
  justify-content: center
}

.ghost-info {
  display: flex;
  align-items: center;
  gap: 4px;
  color: #aaa
}

.ghost-dot {
  width: 10px;
  height: 10px;
  border-radius: 50% 50% 0 0
}