/* Main Styling for Pac-Man Arcade Classique */

:root {
  --arcade-bg: #0d0d16;
  --cabinet-wood: #1e1108;
  --cabinet-metal: #2d2f3b;
  --marquee-bg: #05050a;
  --classic-blue: #2121ff;
  --neon-glow-blue: 0 0 10px rgba(33, 33, 255, 0.8), 0 0 20px rgba(33, 33, 255, 0.4);
  --neon-glow-yellow: 0 0 10px rgba(255, 255, 0, 0.8), 0 0 20px rgba(255, 255, 0, 0.4);
  --neon-glow-red: 0 0 10px rgba(255, 0, 0, 0.8), 0 0 20px rgba(255, 0, 0, 0.4);
  --text-primary: #ffffff;
  --text-yellow: #ffff00;
  --text-red: #ff0000;
  --text-pink: #ffb8ff;
  --text-cyan: #00ffff;
  --text-orange: #ffb852;
  --screen-width: 448px;
  --screen-height: 496px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}

body {
  background-color: var(--arcade-bg);
  background-image: 
    radial-gradient(circle at 20% 30%, rgba(33, 33, 255, 0.1) 0%, transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(255, 255, 0, 0.05) 0%, transparent 40%),
    linear-gradient(rgba(18, 18, 30, 0.6) 1px, transparent 1px),
    linear-gradient(90deg, rgba(18, 18, 30, 0.6) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 40px 40px, 40px 40px;
  color: var(--text-primary);
  font-family: 'Press Start 2P', monospace;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  overflow-x: hidden;
}

/* Main Cabinet Container */
.arcade-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 540px;
  background-color: #1a1a24;
  border-left: 12px solid #ff3300;
  border-right: 12px solid #ff3300;
  border-top: 6px solid #2d2f3b;
  border-bottom: 8px solid #111;
  box-shadow: 
    0 20px 50px rgba(0, 0, 0, 0.8),
    inset 0 0 30px rgba(0, 0, 0, 0.6);
  border-radius: 8px;
  position: relative;
}

/* Marquee Header */
.arcade-marquee {
  width: 100%;
  height: 100px;
  background-color: var(--marquee-bg);
  border-bottom: 6px solid #ffb852;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 0 20px rgba(255, 255, 255, 0.05);
}

.arcade-marquee::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(transparent 50%, rgba(255, 255, 255, 0.05) 50%);
  background-size: 100% 6px;
  pointer-events: none;
}

.marquee-text {
  font-size: 2.2rem;
  letter-spacing: 4px;
  font-weight: 900;
  margin-bottom: 4px;
  animation: marquee-pulse 2s infinite alternate;
}

.marquee-subtitle {
  font-size: 0.65rem;
  color: var(--text-cyan);
  letter-spacing: 2px;
  text-shadow: 0 0 5px rgba(0, 255, 255, 0.5);
}

/* Glow Classes */
.glow-yellow {
  color: var(--text-yellow);
  text-shadow: var(--neon-glow-yellow);
}

/* Cabinet Bezel */
.cabinet-bezel {
  width: 100%;
  background-color: #22222d;
  padding: 20px 25px;
  display: flex;
  flex-direction: column;
  align-items: center;
  border-bottom: 6px solid var(--cabinet-metal);
  position: relative;
}

.cabinet-bezel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 10px;
  right: 10px;
  height: 100%;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.4) 0%, transparent 10%, transparent 90%, rgba(0, 0, 0, 0.4) 100%);
  pointer-events: none;
}

/* Cabinet Header (Stats) */
.cabinet-header {
  width: var(--screen-width);
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
  padding: 0 5px;
}

.score-container {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.score-container .label {
  font-size: 0.65rem;
  color: var(--text-red);
  margin-bottom: 6px;
  letter-spacing: 1px;
}

.score-container .value {
  font-size: 0.85rem;
  color: #fff;
  letter-spacing: 1px;
}

/* CRT Screen Wrapper */
.crt-screen {
  width: var(--screen-width);
  height: var(--screen-height);
  background-color: #000;
  position: relative;
  overflow: hidden;
  border-radius: 20px;
  box-shadow: 
    inset 0 0 30px rgba(0, 0, 0, 1),
    0 0 0 8px #18181f,
    0 0 15px rgba(33, 33, 255, 0.4);
  border: 4px solid #333344;
}

/* Game Canvas */
#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

/* CRT Scanlines Overlay */
.scanlines {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    rgba(18, 16, 16, 0) 50%, 
    rgba(0, 0, 0, 0.35) 50%
  );
  background-size: 100% 4px;
  z-index: 10;
  pointer-events: none;
}

/* CRT Screen Flicker */
.screen-flicker {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(18, 16, 16, 0.05);
  opacity: 0;
  z-index: 11;
  pointer-events: none;
  animation: flicker 0.15s infinite;
}

/* Game Overlays */
.overlay-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.85);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 5;
  text-align: center;
  padding: 20px;
  transition: opacity 0.3s ease;
}

.overlay-screen.hidden {
  display: none !important;
  opacity: 0;
  pointer-events: none;
}

/* Overlay Typographies */
.flash-text {
  font-size: 1.5rem;
  color: var(--text-yellow);
  text-shadow: var(--neon-glow-yellow);
  margin-bottom: 25px;
  animation: text-flash 0.8s infinite steps(2);
}

.ready-text {
  font-size: 1.6rem;
  color: var(--text-yellow);
  text-shadow: var(--neon-glow-yellow);
  letter-spacing: 2px;
  animation: scale-pulse 0.4s infinite alternate ease-in-out;
}

.paused-text {
  font-size: 1.6rem;
  color: var(--text-cyan);
  text-shadow: 0 0 10px rgba(0, 255, 255, 0.8);
  letter-spacing: 3px;
}

.game-over-text {
  font-size: 1.8rem;
  color: var(--text-red);
  text-shadow: var(--neon-glow-red);
  margin-bottom: 25px;
  letter-spacing: 2px;
  animation: text-shake 0.5s infinite;
}

.cta-text {
  font-size: 0.55rem;
  line-height: 1.8;
  color: #8888aa;
  letter-spacing: 1.5px;
  margin-bottom: 30px;
}

/* Character Preview on Start Screen */
.character-preview {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  background-color: rgba(10, 10, 20, 0.8);
  padding: 15px 20px;
  border: 2px solid var(--classic-blue);
  box-shadow: inset 0 0 10px rgba(33, 33, 255, 0.3);
  border-radius: 4px;
}

.preview-row {
  font-size: 0.55rem;
  letter-spacing: 1px;
  color: #bbb;
  display: flex;
  align-items: center;
}

.ghost-char {
  font-size: 0.9rem;
  margin-right: 12px;
  display: inline-block;
  animation: bounce 0.6s infinite alternate;
}

/* Specific ghost colors */
.red-text { color: var(--text-red); text-shadow: 0 0 5px rgba(255, 0, 0, 0.5); }
.pink-text { color: var(--text-pink); text-shadow: 0 0 5px rgba(255, 184, 255, 0.5); }
.cyan-text { color: var(--text-cyan); text-shadow: 0 0 5px rgba(0, 255, 255, 0.5); }
.orange-text { color: var(--text-orange); text-shadow: 0 0 5px rgba(255, 184, 82, 0.5); }

/* Cabinet Footer (Lives & Stage) */
.cabinet-footer {
  width: var(--screen-width);
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 15px;
  padding: 0 5px;
}

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

.lives-container .label, .level-container .label {
  font-size: 0.55rem;
  color: #666688;
}

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

.lives-icons svg {
  width: 14px;
  height: 14px;
  fill: var(--text-yellow);
}

.level-container .value {
  font-size: 0.65rem;
  color: var(--text-yellow);
}

.controls-info {
  font-size: 0.45rem;
  color: #44445c;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

/* Arcade Control Panel Mockup */
.arcade-control-panel {
  width: 100%;
  height: 120px;
  background-color: #1a1a24;
  border-top: 6px solid #444455;
  border-bottom: 6px solid #111;
  display: flex;
  justify-content: space-around;
  align-items: center;
  position: relative;
  padding: 0 40px;
}

.arcade-control-panel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: 
    linear-gradient(rgba(255, 255, 255, 0.02) 50%, transparent 50%),
    linear-gradient(90deg, transparent 50px, rgba(33, 33, 255, 0.05) 50px, rgba(33, 33, 255, 0.05) 52px, transparent 52px);
  background-size: 100% 8px, 100px 100%;
  pointer-events: none;
}

/* Joystick Assembly */
.joystick-assembly {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.joystick-base {
  width: 60px;
  height: 60px;
  background: radial-gradient(circle, #222 30%, #000 70%);
  border: 4px solid #444;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
  position: relative;
}

.joystick-shaft {
  width: 12px;
  height: 35px;
  background: linear-gradient(90deg, #888, #ddd, #555);
  border-radius: 6px;
  position: absolute;
  bottom: 22px;
  transform-origin: bottom center;
  transition: transform 0.1s ease-out;
  display: flex;
  justify-content: center;
}

.joystick-ball {
  width: 28px;
  height: 28px;
  background: radial-gradient(circle at 35% 35%, #ff3b30 10%, #cc1100 60%, #660000 100%);
  border-radius: 50%;
  position: absolute;
  top: -20px;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.6);
}

.control-label {
  font-size: 0.45rem;
  color: #777799;
  letter-spacing: 1px;
}

/* Action Buttons */
.action-buttons {
  display: flex;
  gap: 25px;
}

.btn-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.btn-label {
  font-size: 0.45rem;
  color: #777799;
  letter-spacing: 1px;
}

/* 3D Arcade Push Buttons */
.arcade-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  position: relative;
  outline: none;
}

.btn-cap {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  transition: transform 0.05s ease;
}

/* Red Button (Audio) */
.btn-red {
  background: linear-gradient(#aa0000, #440000);
  box-shadow: 0 5px 0 #330000, 0 8px 10px rgba(0, 0, 0, 0.5);
}
.btn-red .btn-cap {
  background: radial-gradient(circle at 35% 35%, #ff4d4d, #cc0000);
  box-shadow: inset 0 2px 2px rgba(255, 255, 255, 0.4);
}
.btn-red:active {
  box-shadow: 0 1px 0 #330000, 0 2px 4px rgba(0, 0, 0, 0.5);
  transform: translateY(4px);
}
.btn-red:active .btn-cap {
  transform: scale(0.95);
}

/* Yellow Button (Pause) */
.btn-yellow {
  background: linear-gradient(#a3a300, #444400);
  box-shadow: 0 5px 0 #333300, 0 8px 10px rgba(0, 0, 0, 0.5);
}
.btn-yellow .btn-cap {
  background: radial-gradient(circle at 35% 35%, #ffff66, #cccc00);
  box-shadow: inset 0 2px 2px rgba(255, 255, 255, 0.4);
}
.btn-yellow:active {
  box-shadow: 0 1px 0 #333300, 0 2px 4px rgba(0, 0, 0, 0.5);
  transform: translateY(4px);
}
.btn-yellow:active .btn-cap {
  transform: scale(0.95);
}

/* Coin Door Mockup */
.coin-door {
  width: 100%;
  height: 110px;
  background-color: #121217;
  border-top: 8px solid #08080a;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-radius: 0 0 6px 6px;
}

.coin-slots {
  display: flex;
  justify-content: center;
  width: 100%;
}

.coin-slot {
  width: 90px;
  height: 60px;
  background-color: #2a0000;
  border: 4px solid #1d1f27;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 5px 0;
  cursor: pointer;
  position: relative;
  box-shadow: 
    inset 0 0 10px rgba(0, 0, 0, 0.8),
    0 2px 4px rgba(0, 0, 0, 0.6);
  transition: border-color 0.2s;
}

.coin-slot:hover {
  border-color: #3e4252;
}

.slot-text {
  font-size: 0.35rem;
  color: #ff3300;
  font-weight: bold;
}

.coin-insert-hole {
  width: 6px;
  height: 26px;
  background-color: #000;
  border-radius: 3px;
  box-shadow: inset 0 0 3px rgba(255, 255, 255, 0.1);
}

.coin-return-btn {
  font-size: 0.38rem;
  font-family: 'Press Start 2P', monospace;
  padding: 2px 5px;
  background-color: #ff3300;
  color: #fff;
  border-radius: 2px;
  text-shadow: 0 0 2px #000;
  box-shadow: 0 0 5px rgba(255, 51, 0, 0.8);
  transition: background-color 0.2s, box-shadow 0.2s;
}

/* Flashing insert coin lamp */
.coin-return-btn.lamp-flash {
  animation: coin-lamp-blink 1s infinite steps(2);
}

.coin-return-btn.lamp-active {
  background-color: #ff6633;
  box-shadow: 0 0 10px rgba(255, 102, 51, 1);
}

.door-brand {
  font-size: 0.38rem;
  color: #333344;
  letter-spacing: 2px;
}

/* Animations */
@keyframes marquee-pulse {
  from {
    text-shadow: 
      0 0 5px rgba(255, 255, 0, 0.6),
      0 0 10px rgba(255, 255, 0, 0.4),
      0 0 20px rgba(255, 184, 82, 0.2);
  }
  to {
    text-shadow: 
      0 0 10px rgba(255, 255, 0, 1),
      0 0 20px rgba(255, 255, 0, 0.8),
      0 0 30px rgba(255, 184, 82, 0.5),
      0 0 40px rgba(255, 51, 0, 0.3);
  }
}

@keyframes text-flash {
  0%, 100% {
    opacity: 1;
    text-shadow: var(--neon-glow-yellow);
  }
  50% {
    opacity: 0.2;
    text-shadow: none;
  }
}

@keyframes coin-lamp-blink {
  0%, 100% {
    background-color: #ff3300;
    box-shadow: 0 0 8px rgba(255, 51, 0, 0.9);
  }
  50% {
    background-color: #2a0000;
    box-shadow: none;
    color: #440000;
  }
}

@keyframes flicker {
  0% { opacity: 0.985; }
  50% { opacity: 0.97; }
  100% { opacity: 0.985; }
}

@keyframes scale-pulse {
  from { transform: scale(0.95); }
  to { transform: scale(1.05); }
}

@keyframes bounce {
  from { transform: translateY(0); }
  to { transform: translateY(-4px); }
}

@keyframes text-shake {
  0% { transform: translate(0, 0); }
  20% { transform: translate(-1px, 1px); }
  40% { transform: translate(1px, -1px); }
  60% { transform: translate(-1px, -1px); }
  80% { transform: translate(1px, 1px); }
  100% { transform: translate(0, 0); }
}

/* Responsiveness */
@media (max-width: 580px) {
  body {
    padding: 5px;
  }
  .arcade-container {
    width: 100%;
    max-width: 460px;
    border-left: 6px solid #ff3300;
    border-right: 6px solid #ff3300;
  }
  .arcade-marquee {
    height: 70px;
  }
  .marquee-text {
    font-size: 1.5rem;
  }
  .cabinet-bezel {
    padding: 10px;
  }
  .cabinet-header {
    width: 100%;
  }
  .crt-screen {
    width: 100%;
    height: calc((100vw - 40px) * (496 / 448));
    max-height: var(--screen-height);
  }
  .cabinet-footer {
    width: 100%;
  }
  .arcade-control-panel {
    padding: 0 15px;
    height: 90px;
  }
  .joystick-base {
    width: 44px;
    height: 44px;
  }
  .joystick-shaft {
    height: 25px;
    bottom: 15px;
  }
  .joystick-ball {
    width: 20px;
    height: 20px;
    top: -12px;
  }
  .arcade-btn {
    width: 32px;
    height: 32px;
  }
  .btn-cap {
    width: 26px;
    height: 26px;
  }
}
