body {
  background: #000;
  color: #fff;
  font-family: 'Arial', sans-serif;
  user-select: none;
  touch-action: manipulation;
  overflow: hidden;
}

.game-title {
  font-size: 3.5rem;
  text-shadow: 0 0 20px #ffff00, 0 0 30px #ff00ff;
  animation: pulse 2s infinite;
  font-family: "Press Start 2P", monospace;
  color: #fdd835;
}

.select-player {
  font-size: 1rem;
  text-shadow: 0 0 20px #ffff00, 0 0 30px #ff00ff;
  animation: pulse 2s infinite;
  font-family: "Press Start 2P", monospace;
  color: #fdd835;
}


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

.hud-item {
  font-size: 1.2rem;
  padding: 8px 16px;
  background: rgba(255,255,255,0.1);
  border-radius: 8px;
  backdrop-filter: blur(10px);
}

/* APPEARANCE SELECTOR */
.appearance-selector {
  max-width: 600px;
  margin: 0 auto;
  padding: 15px;
  background: rgba(255,255,255,0.05);
  border-radius: 8px;
  backdrop-filter: blur(10px);
}

.appearance-selector h5 {
  color: #ffd700;
  text-shadow: 0 0 10px #ffd700;
}

.appearance-option {
  position: relative;
}

.appearance-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.appearance-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: rgba(59, 130, 246, 0.2);
  border: 2px solid #3b82f6;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;
}

.appearance-label:hover, .preview-pacman-css:hover {

  background: rgba(59, 130, 246, 0.3);
  transform: scale(1.05);
}

.appearance-option input[type="radio"]:checked + .appearance-label {
  background: rgba(59, 130, 246, 0.5);
  border-color: #ffd700;
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
}

.appearance-label span {
  font-weight: bold;
  font-size: 0.9rem;
}

/* Preview Pac-Man styles */
.preview-pacman-css {
  width: 40px;
  height: 40px;
  border-radius: 50%;

}


/* Preview Pac-Man styles */
.preview-pacman-png,
.preview-pacman-gif {
  width: 46px;
  height: 46px;
  border-radius: 50%;
}


.preview-pacman-css {
  background: #ffd700;
  position: relative;
  margin: 3px 0;
}

.preview-pacman-css::before {
  content: "";
  position: absolute;
  top: 52%;
  left: 0;
  transform: translate(-50%, -50%);
  width: 0;
  height: 0;
  border-width: 10px 20px 10px 62px;
  border-style: solid;
  border-color: transparent #0c1a31 transparent transparent;
}

@keyframes chomp-preview {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.preview-pacman-png {
  background: url('pacman.png') center/100% no-repeat;
  background-color: transparent;
}

.preview-pacman-gif {
  background: url('pacman.gif') center/100% no-repeat;
  background-color: transparent;
}

/* Grille responsive */
#game {
  display: grid;
  grid-template-columns: repeat(17, min(28px, 4.5vw));
  grid-template-rows: repeat(20, min(28px, 4.5vw));
  gap: 0;
  margin: 0 auto;
  border: 4px solid #1e40af;
  background: #000;
  border-radius: 8px;
  box-shadow: 0 0 30px rgba(30, 64, 175, 0.5);
  position: relative;
}

.cell {
  width: 100%;
  height: 100%;
  position: relative;
}

.wall {
  background: linear-gradient(135deg, #5c3c6b  0%, #3a2b72  100%);
  border: 0.5px solid rgba(0, 0, 0, 0.3);
  border-radius: 2px;
}

.dot {
  position: relative;
}

.dot::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20%;
  height: 20%;
  background: #ffd700;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  box-shadow: 0 0 5px #ffd700;
}

.power-pellet {
  position: relative;
}

.power-pellet::after {
  content: "💰";
  position: absolute;
  top: -15%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 160%;
}

@keyframes power-pulse {
  0% { transform: translate(-50%, -50%) scale(1); }
  100% { transform: translate(-50%, -50%) scale(1.3); }
}

/* PAC-MAN STYLES */

/* CSS APPEARANCE (Type A) */
.pacman.appearance-css {
  width: 100%;
  height: 100%;
  background: #ffd700;
  border-radius: 50%;
  position: relative;
  z-index: 10;
}

.pacman.appearance-css::before {
  content: "";
  position: absolute;
  width: 0;
  height: 0;
  border-style: solid;
  /* animation: chomp-anim 0.3s infinite; */ /* Animation désactivée */
}

/* LEFT */
.pacman.appearance-css.right::before {
  top: 50%;
  left: 80%;
  transform: translate(-50%, -50%);
  border-width: 8px 13px 8px 0;
  border-color: transparent #111 transparent transparent;
}

/* RIGHT */
.pacman.appearance-css.left::before {
  top: 50%;
  right: 80%;
  transform: translate(50%, -50%);
  border-width: 8px 0 8px 12px;
  border-color: transparent transparent transparent #111;
}

/* UP */
.pacman.appearance-css.up::before {
  bottom: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  border-width: 12px 8px 0 8px;
  border-color: #111 transparent transparent transparent;
}

/* DOWN */
.pacman.appearance-css.down::before {
  top: 40%;
  left: 50%;
  transform: translate(-50%, 50%);
  border-width: 0 8px 12px 8px;
  border-color: transparent transparent #111 transparent;
}

@keyframes chomp-anim {
  0%, 49%   { opacity: 1; }
  50%, 100% { opacity: 0; }
}

/* PNG APPEARANCE (Type B) */
.pacman.appearance-png {
  width: 100%;
  height: 100%;
  background: url('pacman.png') center/contain no-repeat;
  background-color: transparent;
  position: relative;
  z-index: 10;
  transform: none;
}

.pacman.appearance-png.left {
  transform: scaleX(-1) !important;
}

.pacman.appearance-png.right {
  transform: scaleX(1) !important;
}

.pacman.appearance-png.up {
  transform: rotate(-90deg) !important;
}

.pacman.appearance-png.down {
  transform: rotate(90deg) !important;
}

/* GIF APPEARANCE (Type C) */
.pacman.appearance-gif {
  width: 100%;
  height: 100%;
  background: url('pacman.gif') center/contain no-repeat;
  background-color: transparent;
  position: relative;
  z-index: 10;
  transform: none;
}

.pacman.appearance-gif.left {
  transform: scaleX(-1) !important;
}

.pacman.appearance-gif.right {
  transform: scaleX(1) !important;
}

.pacman.appearance-gif.up {
  transform: rotate(-90deg) !important;
}

.pacman.appearance-gif.down {
  transform: rotate(90deg) !important;
}

/* Animation de mort */
.pacman.dying {
  animation: death 1s forwards;
}

@keyframes death {
  0% { 
    transform: rotate(0deg) scale(1);
    opacity: 1;
  }
  50% { 
    transform: rotate(180deg) scale(1.5);
  }
  100% { 
    transform: rotate(360deg) scale(0);
    opacity: 0;
  }
}

/* FANTÔMES */
.ghost {
  width: 100%;
  height: 100%;
  border-radius: 50% 50% 0 0;
  position: relative;
  z-index: 5;
  animation: ghost-float 0.5s infinite alternate;
}

@keyframes ghost-float {
  0% { transform: translateY(0); }
  100% { transform: translateY(-2px); }
}

.ghost::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 25%;
  background: repeating-linear-gradient(
    90deg,
    transparent 0 3px,
    currentColor 3px 6px
  );
}

/* Yeux des fantômes */
.ghost::before {
  content: "👀";
  position: absolute;
  top: 15%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 100%;
}

/* Couleurs des fantômes */
.ghost-red {
  background: #ff0000;
  color: #ff0000;
  box-shadow: 0 0 15px rgba(255, 0, 0, 0.8);
}

.ghost-pink {
  background: #ffb8ff;
  color: #ffb8ff;
  box-shadow: 0 0 15px rgba(255, 184, 255, 0.8);
}

.ghost-cyan {
  background: #00ffff;
  color: #00ffff;
  box-shadow: 0 0 15px rgba(0, 255, 255, 0.8);
}

.ghost-orange {
  background: #ffb852;
  color: #ffb852;
  box-shadow: 0 0 15px rgba(255, 184, 82, 0.8);
}

/* Fantômes effrayés */
.ghost-scared {
  background: #fff !important;
  color: #2121de !important;
  animation: ghost-scared 0.3s infinite;
}

@keyframes ghost-scared {
  0%, 100% { background: #2121de; }
  50% { background: #ffffff; }
}

.ghost-scared::before {
  content: "😱";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  font-size: 120%;
}

















/* CONTRÔLES */
.controls button {
  margin: 0 5px;
  min-width: 140px;
  font-weight: bold;
  text-transform: uppercase;
  transition: all 0.3s;
}

.controls button:hover {
  transform: scale(1.05);
}

kbd {
  background: #333;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid #666;
  font-family: monospace;
}

.instructions {
  max-width: 600px;
  margin: 0 auto;
  padding: 15px;
  background: rgba(255,255,255,0.05);
  border-radius: 8px;
  backdrop-filter: blur(10px);
}

/* MOBILE CONTROLS */
.mobile-controls {
  display: none;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(3, 70px);
  grid-template-rows: repeat(3, 70px);
  gap: 10px;
  justify-content: center;
}

.btn-control {
  background: linear-gradient(135deg, #3b82f6 0%, #1e40af 100%);
  border: 2px solid #60a5fa;
  border-radius: 12px;
  font-size: 2rem;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 10px rgba(59, 130, 246, 0.3);
}

.btn-control:active {
  transform: scale(0.95);
  box-shadow: 0 2px 5px rgba(59, 130, 246, 0.5);
}

@media (max-width: 768px) {
  .mobile-controls {
    display: block;
  }
  
  .game-title {
    font-size: 1.8rem;
  }
  
  .hud-item {
    font-size: 1rem;
    padding: 6px 12px;
  }
  
  #game {
    grid-template-columns: repeat(17, 20px);
    grid-template-rows: repeat(20, 20px);
  }
  
  .appearance-selector {
    font-size: 0.9rem;
  }
  
  .preview-pacman-css,
  .preview-pacman-png,
  .preview-pacman-gif {
    width: 30px;
    height: 30px;
  }
}

/* MODAL GAME OVER */
.game-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.95);
  backdrop-filter: blur(10px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.game-modal.active {
  display: flex;
}

.modal-content {
  max-width: 70%;
  background: linear-gradient(135deg, #201f39  0%, #523579 100%);
  padding: 40px;
  border-radius: 20px;
  text-align: center;
  border: 4px solid #60a5fa;
  box-shadow: 0 0 50px rgba(59, 130, 246, 0.8);
  animation: modal-appear 0.5s;
}

@keyframes modal-appear {
  0% { 
    transform: scale(0.5);
    opacity: 0;
  }
  100% { 
    transform: scale(1);
    opacity: 1;
  }
}

.modal-content h2 {
  font-family: "Press Start 2P", monospace;
  font-size: 3rem;
  margin-bottom: 20px;
  text-shadow: 0 0 20px #fff;
}




.modal-content p {
  font-size: 1.5rem;
  margin-bottom: 30px;
}

#finalScore {
  color: #ffd700;
  font-size: 2rem;
  font-weight: bold;
  text-shadow: 0 0 10px #ffd700;
}

/* Effets sonores visuels */
@keyframes eat-dot {
  0% { opacity: 1; }
  50% { opacity: 1; }
  100% { opacity: 1; }
}

.eating {
  animation: eat-dot 0.1s;
}