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

:root {
  --neon-yellow: #FFE000;
  --neon-blue: #2121DE;
  --neon-cyan: #00FFFF;
  --ghost-red: #FF0000;
  --ghost-pink: #FFB8FF;
  --ghost-cyan: #00FFFF;
  --ghost-orange: #FFB852;
  --bg-dark: #000000;
  --bg-screen: #000510;
  --maze-blue: #1a1aff;
  --text-white: #ffffff;
  --glow-yellow: 0 0 8px #FFE000, 0 0 20px #FFE000, 0 0 40px #FFE000;
  --glow-blue: 0 0 8px #2121DE, 0 0 20px #4444ff, 0 0 40px #2121DE;
  --glow-cyan: 0 0 8px #00FFFF, 0 0 20px #00FFFF;
}

html, body {
  width: 100%;
  min-height: 100vh;
  background: #0a0005;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Press Start 2P', monospace;
  overflow: hidden;
}

body {
  background:
    radial-gradient(ellipse at 50% 0%, #1a0030 0%, transparent 60%),
    radial-gradient(ellipse at 50% 100%, #000820 0%, transparent 60%),
    #050005;
}

/* ── ARCADE WRAPPER ── */
.arcade-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

/* ── CRT SCREEN ── */
.crt-screen {
  position: relative;
  background: var(--bg-screen);
  border: 3px solid #333;
  border-radius: 12px 12px 4px 4px;
  padding: 16px 20px 12px;
  box-shadow:
    0 0 0 1px #111,
    0 0 30px rgba(33, 33, 222, 0.4),
    0 0 80px rgba(33, 33, 222, 0.2),
    inset 0 0 60px rgba(0, 0, 0, 0.8);
  overflow: hidden;
}

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

/* CRT screen glare */
.screen-glare {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 40%;
  background: linear-gradient(
    180deg,
    rgba(255,255,255,0.03) 0%,
    transparent 100%
  );
  pointer-events: none;
  z-index: 11;
  border-radius: inherit;
}

/* ── HEADER ── */
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
  padding: 0 4px;
}

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

.label {
  font-size: 8px;
  color: #ffffff;
  letter-spacing: 1px;
}

.value {
  font-size: 14px;
  color: #ffffff;
  letter-spacing: 2px;
  min-width: 60px;
  text-align: center;
}

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

.pac-title {
  font-size: 18px;
  color: var(--neon-yellow);
  text-shadow: var(--glow-yellow);
  letter-spacing: 4px;
  animation: titlePulse 2s ease-in-out infinite;
}

@keyframes titlePulse {
  0%, 100% { text-shadow: var(--glow-yellow); }
  50% { text-shadow: 0 0 4px #FFE000, 0 0 10px #FFE000; }
}

/* ── CANVAS CONTAINER ── */
.canvas-container {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

#gameCanvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* ── OVERLAY ── */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  transition: opacity 0.3s ease;
}

.overlay.hidden {
  display: none;
}

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

.overlay-title {
  font-size: 28px;
  color: var(--neon-yellow);
  text-shadow: var(--glow-yellow);
  letter-spacing: 6px;
  animation: titlePulse 1.5s ease-in-out infinite;
}

.overlay-sub {
  font-size: 9px;
  color: #ffffff;
  letter-spacing: 1px;
  animation: blink 1s step-end infinite;
}

.overlay-hint {
  font-size: 7px;
  color: #888;
  letter-spacing: 1px;
}

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

/* ── FOOTER ── */
.game-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  padding: 0 4px;
}

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

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

.life-icon {
  width: 14px;
  height: 14px;
  background: var(--neon-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(--neon-yellow);
}

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

#level-display {
  font-size: 14px;
  color: var(--neon-yellow);
  text-shadow: 0 0 8px var(--neon-yellow);
}

/* ── CABINET BOTTOM ── */
.cabinet-bottom {
  background: linear-gradient(180deg, #1a1a1a 0%, #111 100%);
  border: 3px solid #333;
  border-top: none;
  border-radius: 0 0 8px 8px;
  padding: 8px 20px;
  width: 100%;
}

.controls-hint {
  display: flex;
  justify-content: center;
  gap: 24px;
  font-size: 6px;
  color: #555;
  letter-spacing: 0.5px;
}

/* ── GHOST COLORS (used by canvas, referenced here for reference) ── */
/* Blinky: #FF0000, Pinky: #FFB8FF, Inky: #00FFFF, Clyde: #FFB852 */

/* ── RESPONSIVE ── */
@media (max-width: 600px) {
  .pac-title { font-size: 12px; letter-spacing: 2px; }
  .overlay-title { font-size: 18px; }
  .value { font-size: 10px; }
  .controls-hint { gap: 12px; font-size: 5px; }
}