#pacman-root {
  --bg: #000;
  --text: #fff;
  --yellow: #ffe600;
  --blue: #2121de;
  --font: "Press Start 2P", ui-monospace, monospace;
  /* Barre commune (css/games.css) façon borne d'arcade */
  --mg-jeu-largeur: 504px;
  --mgb-fond: linear-gradient(120deg, #000, #0d0d3a);
  --mgb-accent: var(--yellow);
  --mgb-titre: linear-gradient(100deg, var(--yellow), #ffb347);
  --mgb-police-titre: var(--font);
  --mgb-ombre: 0 0 0 2px var(--blue), 0 8px 24px rgba(0, 0, 0, 0.35);
  --mg-fs-fond: #000;
  --mg-bulle-fond: #0d0d3a;
}

#pacman-root .mg-barre-titre {
  font-size: 1.05em;
}

/* Plein écran : le labyrinthe occupe la hauteur sous la barre */
#pacman-root.mg-fs .stage {
  max-width: none;
  margin: auto;
  box-shadow: none;
}

#pacman-root.mg-fs .screen {
  width: min(92vw, calc((100vh - 130px) * 448 / 576));
}

#pacman-root * {
  box-sizing: border-box;
}

.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 0 auto 20px auto;
  padding: 16px;
  max-width: 480px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.screen {
  position: relative;
  width: min(92vw, 420px);
  /* le canvas garde les proportions 448 × 576 */
  aspect-ratio: 448 / 576;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
}

/* ---------- Écran titre ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 16px;
  background: rgba(0, 0, 0, 0.88);
  text-align: center;
}

.overlay[hidden] {
  display: none;
}

.overlay h1 {
  margin: 0 0 8px;
  font-size: clamp(22px, 6vh, 42px);
  color: var(--yellow);
  text-shadow: 0 0 12px rgba(255, 230, 0, 0.6);
  letter-spacing: 0.08em;
}

.cast p {
  margin: 8px 0;
  font-size: clamp(8px, 1.6vh, 12px);
  text-align: left;
}
.cast .g {
  font-size: 1.4em;
  margin-right: 8px;
}
.blinky,
.blinky + b {
  color: #ff0000;
}
.pinky {
  color: #ffb8ff;
}
.inky {
  color: #00ffff;
}
.clyde {
  color: #ffb852;
}
.cast p:nth-child(1) b {
  color: #ff0000;
}
.cast p:nth-child(2) b {
  color: #ffb8ff;
}
.cast p:nth-child(3) b {
  color: #00ffff;
}
.cast p:nth-child(4) b {
  color: #ffb852;
}

.points {
  font-size: clamp(8px, 1.5vh, 11px);
  color: #ffb8ae;
}
.points .dot,
.points .pow {
  display: inline-block;
  vertical-align: middle;
  border-radius: 50%;
  background: #ffb8ae;
}
.points .dot {
  width: 4px;
  height: 4px;
}
.points .pow {
  width: 10px;
  height: 10px;
}

.start {
  margin-top: 6px;
  padding: 14px 26px;
  font: inherit;
  font-size: clamp(12px, 2.2vh, 16px);
  color: #000;
  background: var(--yellow);
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  animation: pulse 1.2s infinite;
}

.keys {
  font-size: clamp(7px, 1.3vh, 10px);
  color: #999;
  line-height: 1.8;
}

@keyframes pulse {
  50% {
    transform: scale(1.06);
  }
}

/* ---------- Commandes ---------- */

.pad button {
  font: inherit;
  color: var(--text);
  background: #111;
  border: 2px solid var(--blue);
  border-radius: 8px;
  cursor: pointer;
}

/* croix directionnelle : seulement sur écran tactile */
.pad {
  display: none;
  grid-template-columns: repeat(3, 56px);
  grid-template-rows: repeat(2, 48px);
  gap: 6px;
}

.pad button {
  font-size: 18px;
}
.pad [data-dir="up"] {
  grid-column: 2;
  grid-row: 1;
}
.pad [data-dir="left"] {
  grid-column: 1;
  grid-row: 2;
}
.pad [data-dir="down"] {
  grid-column: 2;
  grid-row: 2;
}
.pad [data-dir="right"] {
  grid-column: 3;
  grid-row: 2;
}
.pad button:active {
  background: var(--blue);
}

@media (hover: none) and (pointer: coarse) {
  .pad {
    display: grid;
  }
  .keys {
    display: none;
  }
}
