/* =========================================================
   PAC MAZE DELUXE - Premium Arcade Stylesheet
   ========================================================= */

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

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

:root {
  --neon-blue:   #00c8ff;
  --neon-purple: #bb00ff;
  --neon-yellow: #ffe800;
  --neon-pink:   #ff4fc8;
  --neon-green:  #00ff88;
  --dark-bg:     #05060f;
  --hud-bg:      #0a0b1a;
}

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--dark-bg);
  font-family: 'Press Start 2P', 'Courier New', monospace;
  color: #fff;
  touch-action: none;
}

/* ---- SCREENS ---- */
.screen { position: fixed; inset: 0; display: flex; flex-direction: column;
          align-items: center; justify-content: center; opacity: 0;
          pointer-events: none; transition: opacity 0.4s; }
.screen.active { opacity: 1; pointer-events: all; }

/* ---- START SCREEN ---- */
#start-screen { background: var(--dark-bg); overflow: hidden; }
#bg-canvas { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0.35; }

.start-content {
  position: relative; z-index: 2;
  display: flex; flex-direction: column; align-items: center; gap: 18px;
}

.title-sub {
  font-size: 0.5rem; letter-spacing: 0.25em;
  color: var(--neon-purple); text-shadow: 0 0 12px var(--neon-purple);
}

.title-main {
  font-size: clamp(1.6rem, 5vw, 2.8rem);
  line-height: 1.15;
  text-align: center;
  filter: drop-shadow(0 0 18px var(--neon-blue));
}
.title-main span { display: inline-block; animation: letterPop 0.6s ease both; }
.title-main .t1  { color: #ff4444; animation-delay: 0.05s; }
.title-main .t2  { color: #ff8800; animation-delay: 0.10s; }
.title-main .t3  { color: var(--neon-yellow); animation-delay: 0.15s; }
.title-main .t4  { color: var(--neon-green);  animation-delay: 0.20s; }
.title-main .t5  { color: var(--neon-blue);   animation-delay: 0.25s; }
.title-main .t6  { color: var(--neon-purple); animation-delay: 0.30s; }
.title-main .t7  { color: var(--neon-pink);   animation-delay: 0.35s; }
.title-main .t8  { color: #ff4444; animation-delay: 0.40s; }
.title-main .t9  { color: #ff8800; animation-delay: 0.45s; }
.title-main .t10 { color: var(--neon-yellow); animation-delay: 0.50s; }
.title-main .t11 { color: var(--neon-green);  animation-delay: 0.55s; }
.title-main .t12 { color: var(--neon-blue);   animation-delay: 0.60s; }
.title-main .t13 { color: var(--neon-purple); animation-delay: 0.65s; }
.space { color: transparent !important; }

@keyframes letterPop {
  0%   { transform: translateY(-40px) scale(0.5); opacity: 0; }
  70%  { transform: translateY(6px)   scale(1.1); }
  100% { transform: translateY(0)     scale(1);   opacity: 1; }
}

.title-tagline {
  font-size: 0.45rem; letter-spacing: 0.2em;
  color: var(--neon-blue); text-shadow: 0 0 10px var(--neon-blue);
}

.start-preview {
  border: 2px solid var(--neon-purple);
  border-radius: 12px;
  box-shadow: 0 0 24px var(--neon-purple), inset 0 0 20px rgba(187,0,255,0.15);
  overflow: hidden;
  width: 160px; height: 160px;
}
#preview-canvas { width: 160px; height: 160px; display: block; }

.high-score-display {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.hs-label { font-size: 0.4rem; color: var(--neon-pink); letter-spacing: 0.15em; }
.hs-value { font-size: 1.1rem; color: var(--neon-yellow);
            text-shadow: 0 0 16px var(--neon-yellow); }

.insert-coin {
  font-size: 0.65rem; color: var(--neon-yellow);
  text-shadow: 0 0 18px var(--neon-yellow);
  animation: blink 0.9s step-end infinite;
  letter-spacing: 0.1em;
}

.start-hint { font-size: 0.38rem; color: #888; }

.controls-hint {
  display: flex; gap: 20px; font-size: 0.3rem; color: #555;
}

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

/* ---- GAME SCREEN ---- */
#game-screen { flex-direction: column; background: var(--dark-bg); }

#hud {
  width: 100%; max-width: 700px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 14px;
  background: var(--hud-bg);
  border-bottom: 1px solid rgba(0,200,255,0.2);
}
.hud-label { font-size: 0.3rem; color: #666; letter-spacing: 0.1em; }
.hud-value { font-size: 0.75rem; color: var(--neon-yellow);
             text-shadow: 0 0 10px var(--neon-yellow); }
.hud-left  { text-align: left; }
.hud-right { text-align: right; }
.hud-center { text-align: center; }

.level-badge {
  font-size: 0.55rem; color: var(--neon-blue);
  border: 1px solid var(--neon-blue); border-radius: 4px;
  padding: 3px 8px;
  text-shadow: 0 0 10px var(--neon-blue);
  box-shadow: 0 0 8px rgba(0,200,255,0.3);
}

#canvas-wrap {
  position: relative; flex: 1;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
#game-canvas { display: block; image-rendering: pixelated; }

/* ---- OVERLAYS ---- */
.game-overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 14px;
  background: rgba(5,6,15,0.82);
  backdrop-filter: blur(2px);
  z-index: 10;
}
.game-overlay.hidden { display: none; }

.overlay-title {
  font-size: clamp(1.2rem, 4vw, 2rem);
  color: var(--neon-yellow);
  text-shadow: 0 0 30px var(--neon-yellow);
  animation: titleGlow 1.5s ease-in-out infinite alternate;
}
.overlay-sub {
  font-size: clamp(0.4rem, 1.5vw, 0.65rem);
  color: var(--neon-blue);
  letter-spacing: 0.08em;
}
.overlay-sub.blink { animation: blink 1s step-end infinite; }
.red-text { color: #ff3333 !important; text-shadow: 0 0 30px #ff3333 !important; }
.gold-text { color: var(--neon-yellow) !important; }

.overlay-score-wrap {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: rgba(0,0,0,0.5); border: 1px solid rgba(255,232,0,0.3);
  border-radius: 8px; padding: 16px 32px;
}
.overlay-label { font-size: 0.3rem; color: #888; }
.overlay-big-score { font-size: 1.2rem; color: var(--neon-green);
                     text-shadow: 0 0 16px var(--neon-green); }

@keyframes titleGlow {
  from { text-shadow: 0 0 20px currentColor; }
  to   { text-shadow: 0 0 50px currentColor, 0 0 100px currentColor; }
}

/* ---- COMBO DISPLAY ---- */
#combo-display {
  position: absolute; left: 50%; top: 20%;
  transform: translateX(-50%);
  font-size: clamp(0.8rem, 2.5vw, 1.2rem);
  color: var(--neon-green);
  text-shadow: 0 0 20px var(--neon-green);
  pointer-events: none;
  animation: comboAnim 0.4s ease;
  z-index: 20;
}
#combo-display.hidden { display: none; }
@keyframes comboAnim {
  0%   { transform: translateX(-50%) scale(0.5); opacity: 0; }
  50%  { transform: translateX(-50%) scale(1.2); }
  100% { transform: translateX(-50%) scale(1); opacity: 1; }
}

/* ---- SCORE POPUPS ---- */
#score-popups {
  position: absolute; inset: 0; pointer-events: none; z-index: 15;
}
.score-popup {
  position: absolute;
  font-size: 0.55rem; color: var(--neon-yellow);
  text-shadow: 0 0 10px var(--neon-yellow);
  animation: popupFly 1.2s ease forwards;
  pointer-events: none;
  white-space: nowrap;
}
@keyframes popupFly {
  0%   { opacity: 1; transform: translate(-50%, 0)   scale(1); }
  100% { opacity: 0; transform: translate(-50%, -60px) scale(1.5); }
}

/* ---- LIVES BAR ---- */
#lives-bar {
  width: 100%; max-width: 700px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 12px;
  background: var(--hud-bg);
  border-top: 1px solid rgba(0,200,255,0.2);
}
#lives-canvas { display: block; }
#sound-toggle {
  font-size: 1.1rem; cursor: pointer;
  user-select: none;
  transition: transform 0.15s;
  filter: drop-shadow(0 0 6px var(--neon-blue));
}
#sound-toggle:hover { transform: scale(1.2); }

/* ---- MOBILE DPAD ---- */
#dpad {
  display: grid;
  grid-template-rows: repeat(3, auto);
  gap: 0;
  padding: 10px;
  user-select: none;
}
#dpad.hidden { display: none; }
.dpad-row {
  display: flex; align-items: center; justify-content: center; gap: 0;
}
.dpad-btn {
  width: 52px; height: 52px;
  background: rgba(0,200,255,0.12);
  border: 1px solid rgba(0,200,255,0.4);
  border-radius: 8px;
  color: var(--neon-blue);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.1s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.dpad-btn:active { background: rgba(0,200,255,0.35); transform: scale(0.9); }
.dpad-center { width: 52px; height: 52px; }

/* ---- SCREEN FLASH ---- */
#screen-flash {
  position: fixed; inset: 0; pointer-events: none; z-index: 999;
  background: rgba(255,232,0,0.55);
  opacity: 0;
  transition: opacity 0.05s;
}

/* ---- RESPONSIVE ---- */
@media (max-width: 600px) {
  .title-main { font-size: 1.2rem; }
  .insert-coin { font-size: 0.5rem; }
}
@media (hover: none) and (pointer: coarse) {
  #dpad { display: grid !important; }
}
