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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: 'Courier New', monospace;
  color: #eee;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

#app {
  position: relative;
  width: 100%;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px;
}

/* ═══════ SCREENS ═══════ */
.screen { display: none; }
.screen.active {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

/* ═══════ MENU ═══════ */
.title {
  font-size: 3.2rem;
  color: #FFD700;
  text-shadow: 0 0 10px #FFD700, 0 0 30px #FFD700, 0 0 60px #FFA500;
  margin-top: 1.5rem;
  letter-spacing: 8px;
  text-align: center;
}

.pac-art {
  margin: 1rem 0;
  animation: float 2s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.mouth-anim {
  animation: chomp 0.3s ease-in-out infinite alternate;
  transform-origin: 60px 60px;
}

@keyframes chomp {
  0%   { transform: rotate(0deg); }
  100% { transform: rotate(15deg); }
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 260px;
  margin: 0.5rem 0;
}

.menu-buttons button,
.overlay-box button {
  padding: 12px 20px;
  font-size: 1.05rem;
  font-family: inherit;
  font-weight: bold;
  letter-spacing: 2px;
  text-transform: uppercase;
  background: #111;
  color: #0ff;
  border: 2px solid #0ff;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.1s;
}

.menu-buttons button:hover,
.overlay-box button:hover {
  background: #0ff;
  color: #000;
}

.menu-buttons button:active,
.overlay-box button:active {
  transform: scale(0.96);
}

.menu-footer {
  margin-top: 1rem;
  font-size: 0.75rem;
  color: #666;
  text-align: center;
}

/* ═══════ HUD ═══════ */
.hud {
  display: flex;
  justify-content: space-between;
  width: 100%;
  padding: 4px 4px 0;
}

.hud-item { text-align: center; flex: 1; }
.hud-center { flex: 0.6; }

.hud-label {
  display: block;
  font-size: 0.65rem;
  color: #888;
  letter-spacing: 1px;
}

.hud-val {
  display: block;
  font-size: 1.1rem;
  color: #FFD700;
  text-shadow: 0 0 6px #FFD700;
}

.hud-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 4px 4px;
}

.lives-row {
  display: flex;
  gap: 4px;
}

/* ═══════ CANVAS ═══════ */
.canvas-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
}

#gameCanvas {
  display: block;
  background: #000;
  border-radius: 4px;
  max-width: 100%;
  height: auto;
}

/* ═══════ PAUSE BUTTON ═══════ */
.pause-btn {
  position: fixed;
  top: 10px;
  right: 10px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border: 1px solid #555;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 0.9rem;
  cursor: pointer;
  z-index: 100;
  line-height: 1;
}

.pause-btn:hover { border-color: #0ff; }

/* ═══════ OVERLAYS ═══════ */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 200;
}

.overlay-box {
  background: #0a0a0a;
  border: 2px solid #0ff;
  border-radius: 10px;
  padding: 2rem 1.5rem;
  text-align: center;
  max-width: 340px;
  width: 90%;
  box-shadow: 0 0 30px rgba(0, 255, 255, 0.15);
}

.overlay-box h2 {
  font-size: 1.8rem;
  color: #FFD700;
  text-shadow: 0 0 12px #FFD700;
  margin-bottom: 0.8rem;
}

.overlay-box p {
  margin: 0.35rem 0;
  color: #ccc;
  font-size: 0.95rem;
}

.overlay-box p span { color: #FFD700; }

.overlay-box button {
  display: block;
  width: 100%;
  margin-top: 10px;
}

.overlay-tall { max-width: 380px; }

.instructions {
  text-align: left;
  margin: 0.6rem 0 0.8rem;
}

.instructions p {
  margin: 0.3rem 0;
  color: #aaa;
  font-size: 0.85rem;
  line-height: 1.4;
}

.instructions hr {
  border: none;
  border-top: 1px solid #333;
  margin: 0.5rem 0;
}

.key {
  color: #0ff;
  font-weight: bold;
}

/* ═══════ MOBILE CONTROLS ═══════ */
.mobile-controls {
  display: grid;
  grid-template-columns: 56px 56px 56px;
  grid-template-rows: 56px 56px;
  gap: 4px;
  margin-top: 10px;
}

.dpad-btn {
  width: 56px;
  height: 56px;
  font-size: 1.4rem;
  background: rgba(0, 255, 255, 0.06);
  color: #0ff;
  border: 2px solid rgba(0, 255, 255, 0.35);
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s;
}

.dpad-btn:active {
  background: rgba(0, 255, 255, 0.25);
}

.dpad-up    { grid-column: 2; grid-row: 1; }
.dpad-left  { grid-column: 1; grid-row: 2; }
.dpad-right { grid-column: 3; grid-row: 2; }
.dpad-down  { grid-column: 2; grid-row: 2; }

/* ═══════ UTIL ═══════ */
.hidden { display: none !important; }

/* ═══════ RESPONSIVE ═══════ */
@media (max-width: 500px) {
  .title { font-size: 2.2rem; letter-spacing: 4px; }
  .menu-buttons { width: 220px; }
  .menu-buttons button { font-size: 0.9rem; padding: 10px 16px; }
  .hud-val { font-size: 0.95rem; }
  .hud-label { font-size: 0.55rem; }
}

@media (max-height: 700px) {
  .title { font-size: 2rem; margin-top: 0.5rem; }
  .pac-art { margin: 0.4rem 0; }
  .pac-art svg { width: 60px; height: 60px; }
}
