/* ============================================================
   PUCMAN — svg edition
   palette pulled from the traced artwork in this folder
   ============================================================ */
:root {
  --ink:        #05060f;
  --maze-blue:  #343091;
  --maze-deep:  #100e2d;
  --pellet:     #f5741e;
  --pac:        #fec013;
  --blinky:     #ed4321;
  --pinky:      #ff9ee0;
  --inky:       #f7a23b;
  --clyde:      #52d16b;
  --fright:     #2b5cff;
  --fright-alt: #f2f6ff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 50% 0%, #14183c 0%, #05060f 60%, #02030a 100%);
  color: #e8eaf6;
  font-family: "Segoe UI", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

#sprite-book { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ---------------- HUD ---------------- */
.hud {
  display: flex;
  flex-wrap: wrap;
  gap: 1.2rem 2rem;
  justify-content: center;
  align-items: center;
  padding: .7rem 1rem .3rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.hud-item { display: flex; align-items: center; gap: .5rem; }
.hud .label { font-size: .7rem; color: #7f88b8; }
.hud b { font-size: 1.1rem; color: var(--pac); min-width: 3.2ch; }
.life-book { width: 96px; height: 32px; }
.life-book g { transition: opacity .25s; }
.life-book g.lost { opacity: 0; }

/* ---------------- stage ---------------- */
.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .8rem;
  padding: .4rem .8rem 2rem;
}
.board-wrap {
  position: relative;
  width: min(96vw, 640px, 78vh);
}
#board {
  display: block;
  width: 100%;
  height: auto;
  background: #060814;
  border-radius: 10px;
  box-shadow: 0 0 0 2px #1b1e46, 0 18px 45px rgba(0,0,0,.6);
}
.board-bg { fill: #060814; }

/* maze walls (inline fills come from walls.svg, CSS can override) */
.wall-outline { fill: var(--maze-deep); }
.wall-core      { fill: var(--maze-blue); }
#board.level-flash .wall-core    { fill: #cdd6ff; }
#board.level-flash .wall-outline { fill: #ffffff; }

/* pellets + power pills */
.pellet { fill: var(--pellet); }
#pills use { animation: pill-pulse .55s ease-in-out infinite alternate; }
@keyframes pill-pulse { from { opacity: 1 } to { opacity: .35 } }

#fruit { opacity: 0; transition: opacity .3s; }
#fruit.show { opacity: 1; animation: fruit-pop .5s ease-out; }
@keyframes fruit-pop { from { transform: scale(.4) } to { transform: scale(1) } }

/* pucman */
#pac-mask { transition: none; }
#pucman.dying use:nth-of-type(1) { display: none; }
#pucman.spawn { animation: spawn .5s ease-out; }
@keyframes spawn { from { opacity: 0 } to { opacity: 1 } }

/* ghosts: the artwork of ghost-red.svg is cloned per ghost and
   recoloured here, so each ghost gets its own colour */
.ghost .g-body { fill: var(--blinky); }
.ghost.pinky .g-body { fill: var(--pinky); }
.ghost.inky  .g-body { fill: var(--inky); }
.ghost.clyde .g-body { fill: var(--clyde); }
.ghost .g-eye  { fill: #ffffff; }
.ghost .g-pupil { fill: #151515; }
.ghost .g-brow  { fill: #1a1a1a; }

.ghost.fright .g-body { fill: var(--fright); }
.ghost.fright .g-brow { display: none; }
.ghost.fright.blink .g-body { fill: var(--fright-alt); }
.ghost.fright.blink .g-pupil { fill: #d00; }
.ghost.eaten .g-body, .ghost.eaten .g-brow { display: none; }
.bob.pen-bob { animation: bob .5s ease-in-out infinite alternate; }
@keyframes bob { to { transform: translateY(-2px) } }

/* score popups */
.popups text {
  fill: #9fe8ff;
  font: 700 12px/1 "Segoe UI", system-ui, sans-serif;
  letter-spacing: .05em;
}

/* ---------------- overlay ---------------- */
.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(3,4,12,.82);
  border-radius: 10px;
  transition: opacity .25s;
}
.overlay.hidden { opacity: 0; pointer-events: none; }
.overlay-inner { text-align: center; padding: 1rem; }
.title {
  margin: 0 0 .4rem;
  font-size: clamp(2rem, 7vw, 3.4rem);
  letter-spacing: .12em;
  color: var(--pac);
  text-shadow: 0 0 18px rgba(254,192,19,.45);
}
.subtitle { margin: 0 0 1.2rem; color: #a9b2d8; font-size: .85rem; line-height: 1.5; }

.btn {
  background: #14183c;
  border: 1px solid #3a3f7a;
  border-radius: 999px;
  color: #e8eaf6;
  cursor: pointer;
  font: inherit;
  letter-spacing: .08em;
  padding: .5rem 1.1rem;
  text-transform: uppercase;
  font-size: .75rem;
}
.btn:hover { background: #1d2352; border-color: var(--pellet); color: #fff; }
#start-btn { font-size: .9rem; padding: .7rem 1.6rem; }

/* ---------------- controls ---------------- */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  align-items: center;
  justify-content: center;
}
.hint { width: 100%; margin: 0; text-align: center; color: #666e96; font-size: .72rem; }
.dpad {
  display: grid;
  grid-template-columns: repeat(3, 44px);
  grid-template-rows: repeat(2, 44px);
  gap: 4px;
}
.dpad-btn {
  background: #10142f; color: #cfd6f5; border: 1px solid #2b3160;
  border-radius: 8px; cursor: pointer; font-size: 1rem;
}
.dpad-btn:active { background: var(--pellet); color: #111; }
.dpad .up    { grid-column: 2; grid-row: 1; }
.dpad .left  { grid-column: 1; grid-row: 2; }
.dpad .down  { grid-column: 2; grid-row: 2; }
.dpad .right { grid-column: 3; grid-row: 2; }
@media (min-width: 820px) and (hover: hover) { .dpad { display: none; } }

@media (prefers-reduced-motion: reduce) {
  #pills use, .bob.pen-bob { animation: none; }
}
