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

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

:root {
  --black: #000000;
  --deep: #0a0a0a;
  --yellow: #FFD700;
  --yellow-glow: #FFE44D;
  --blue-wall: #1a1aff;
  --blue-wall-glow: #4444ff;
  --ghost-red: #FF0000;
  --ghost-pink: #FFB8FF;
  --ghost-cyan: #00FFFF;
  --ghost-orange: #FFB852;
  --ghost-scared: #2121DE;
  --dot-color: #FFB8AE;
  --text-white: #ffffff;
  --neon-green: #39FF14;
  --font: 'Press Start 2P', monospace;
}

html, body {
  width: 100%;
  height: 100%;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

body {
  background: radial-gradient(ellipse at center, #0d0d1a 0%, #000000 70%);
  min-height: 100vh;
}

.arcade-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding: 16px 20px 20px;
  background: #050508;
  border: 2px solid #1a1aff;
  border-radius: 4px;
  box-shadow:
    0 0 20px rgba(26, 26, 255, 0.4),
    0 0 60px rgba(26, 26, 255, 0.15),
    inset 0 0 30px rgba(0, 0, 0, 0.8);
  user-select: none;
}

/* CRT scanlines effect */
.scanlines {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.08) 2px,
    rgba(0, 0, 0, 0.08) 4px
  );
  pointer-events: none;
  z-index: 10;
  border-radius: 4px;
}

.crt-overlay {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 60%, rgba(0,0,0,0.5) 100%);
  pointer-events: none;
  z-index: 11;
  border-radius: 4px;
}

/* Header */
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  width: 560px;
  padding: 0 4px 12px;
  font-family: var(--font);
}

.score-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 100px;
}

.score-block .label {
  font-family: var(--font);
  font-size: 9px;
  color: #fff;
  letter-spacing: 1px;
}

.score-block .value {
  font-family: var(--font);
  font-size: 14px;
  color: var(--yellow);
  text-shadow: 0 0 8px var(--yellow), 0 0 16px rgba(255, 215, 0, 0.4);
  min-width: 60px;
  text-align: center;
}

.title-block {
  display: flex;
  align-items: center;
}

.pac-title {
  font-family: var(--font);
  font-size: 18px;
  color: var(--yellow);
  text-shadow:
    0 0 10px var(--yellow),
    0 0 20px rgba(255, 215, 0, 0.6),
    0 0 40px rgba(255, 215, 0, 0.2);
  letter-spacing: 3px;
}

/* Canvas container */
.game-container {
  position: relative;
  width: 560px;
  height: 620px;
}

#gameCanvas {
  display: block;
  background: #000;
  image-rendering: pixelated;
}

/* Overlays */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  font-family: var(--font);
}

.overlay.hidden {
  display: none;
}

.overlay-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  text-align: center;
}

.blink-text {
  font-family: var(--font);
  font-size: 14px;
  color: var(--yellow);
  text-shadow: 0 0 10px var(--yellow);
  animation: blink 1s step-end infinite;
}

.sub-text {
  font-family: var(--font);
  font-size: 8px;
  color: #aaa;
  letter-spacing: 1px;
}

.pause-text {
  font-family: var(--font);
  font-size: 28px;
  color: var(--yellow);
  text-shadow: 0 0 15px var(--yellow), 0 0 30px rgba(255,215,0,0.4);
}

.gameover-text {
  font-family: var(--font);
  font-size: 24px;
  color: var(--ghost-red);
  text-shadow: 0 0 15px var(--ghost-red), 0 0 30px rgba(255,0,0,0.4);
  animation: flicker 0.15s infinite alternate;
}

.win-text {
  font-family: var(--font);
  font-size: 28px;
  color: var(--neon-green);
  text-shadow: 0 0 15px var(--neon-green), 0 0 30px rgba(57,255,20,0.4);
}

.final-score {
  font-family: var(--font);
  font-size: 11px;
  color: #fff;
  letter-spacing: 2px;
}

.controls-hint {
  font-family: var(--font);
  font-size: 8px;
  color: #666;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 1px solid #333;
  padding: 12px 20px;
  line-height: 1.8;
}

/* Footer */
.game-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 560px;
  padding: 12px 4px 0;
  font-family: var(--font);
}

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

.lives-display .label,
.level-display .label {
  font-family: var(--font);
  font-size: 8px;
  color: #fff;
}

.lives-icons {
  display: flex;
  gap: 6px;
  align-items: center;
}

.life-icon {
  width: 16px;
  height: 16px;
  background: var(--yellow);
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  clip-path: polygon(50% 50%, 100% 20%, 100% 0%, 0% 0%, 0% 100%, 100% 100%, 100% 80%);
  box-shadow: 0 0 6px var(--yellow);
}

.level-display {
  display: flex;
  align-items: center;
  gap: 8px;
}

.level-display .value {
  font-family: var(--font);
  font-size: 12px;
  color: var(--yellow);
  text-shadow: 0 0 8px var(--yellow);
}

/* Animations */
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

@keyframes flicker {
  0% { opacity: 1; }
  100% { opacity: 0.85; }
}

/* Mobile touch controls */
.touch-controls {
  display: none;
  grid-template-columns: repeat(3, 48px);
  grid-template-rows: repeat(3, 48px);
  gap: 4px;
  margin-top: 12px;
}

.touch-btn {
  background: rgba(26, 26, 255, 0.2);
  border: 1px solid rgba(26, 26, 255, 0.5);
  border-radius: 4px;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.touch-btn:active {
  background: rgba(26, 26, 255, 0.5);
}

.touch-btn.up    { grid-column: 2; grid-row: 1; }
.touch-btn.left  { grid-column: 1; grid-row: 2; }
.touch-btn.right { grid-column: 3; grid-row: 2; }
.touch-btn.down  { grid-column: 2; grid-row: 3; }

@media (max-width: 620px) {
  .arcade-wrapper {
    padding: 10px 8px 12px;
    border: none;
    box-shadow: none;
  }

  .game-header,
  .game-container,
  .game-footer {
    width: 100vw;
    max-width: 400px;
  }

  #gameCanvas {
    width: 100%;
    height: auto;
  }

  .game-container {
    height: auto;
  }

  .pac-title {
    font-size: 13px;
  }

  .touch-controls {
    display: grid;
  }
}