/* Pacman - Styles */

:root {
  --bg-primary: #0f0f1a;
  --bg-secondary: #1a1a2e;
  --bg-card: #16213e;
  --accent: #e94560;
  --accent-hover: #ff6b81;
  --text-primary: #eee;
  --text-secondary: #a0a0b8;
  --border: #2a2a4a;
  --success: #4ecca3;
}

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

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.game-header {
  width: 100%;
  background: var(--bg-secondary);
  border-bottom: 2px solid var(--accent);
  padding: 16px 20px;
}

.game-header .container {
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.game-header h1 {
  font-size: 1.4rem;
  color: #eee;
}

.game-header .back-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.2s;
}

.game-header .back-link:hover {
  color: var(--accent);
}

.game-wrapper {
  max-width: 640px;
  width: 100%;
  padding: 16px 20px;
  margin: 10px auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* HUD */
.hud {
  display: flex;
  justify-content: space-between;
  width: 560px;
  margin-bottom: 10px;
  padding: 8px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.hud-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hud-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-secondary);
  font-weight: 700;
}

.hud-value {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-primary);
  font-family: 'Courier New', monospace;
}

/* High score HUD highlight — when the current run is in the lead */
.hud-value.leading {
  color: #ffe100;
  text-shadow: 0 0 6px rgba(255, 225, 0, 0.5);
  animation: highscore-pulse 1.4s ease-in-out infinite;
}

@keyframes highscore-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

#lives-display {
  font-size: 1rem;
  letter-spacing: 2px;
}

/* Canvas */
.canvas-container {
  position: relative;
  border: 2px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: #000;
}

#gameCanvas {
  display: block;
  width: 560px;
  height: 620px;
}

/* Overlays */
.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: opacity 0.3s;
}

.overlay.hidden {
  display: none;
}

.overlay-content {
  text-align: center;
}

.title-logo {
  font-size: 2.8rem;
  font-weight: 900;
  color: #ffe100;
  text-shadow: 0 0 20px rgba(255, 225, 0, 0.5);
  margin-bottom: 16px;
  letter-spacing: 4px;
}

.title-sub {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.title-controls {
  font-size: 0.8rem;
  color: #666;
}

.title-sub kbd, .pause-sub kbd {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 0.9rem;
  color: var(--accent);
}

.gameover-title {
  font-size: 2.5rem;
  font-weight: 900;
  color: var(--accent);
  text-shadow: 0 0 20px rgba(233, 69, 96, 0.5);
  margin-bottom: 12px;
}

.gameover-score {
  font-size: 1.3rem;
  color: var(--text-primary);
  margin-bottom: 20px;
}

/* "NEW HIGH SCORE!" banner — shown only when the run beat the stored best */
.new-highscore-banner {
  font-size: 1.4rem;
  font-weight: 900;
  color: #ffe100;
  text-shadow: 0 0 14px rgba(255, 225, 0, 0.7);
  margin: 0 0 20px;
  letter-spacing: 2px;
  padding: 8px 18px;
  border: 2px solid #ffe100;
  border-radius: 8px;
  background: rgba(255, 225, 0, 0.08);
  display: none;
  animation: banner-glow 1.2s ease-in-out infinite alternate;
}

.new-highscore-banner.visible {
  display: block;
}

@keyframes banner-glow {
  0%   { box-shadow: 0 0 8px rgba(255, 225, 0, 0.4); transform: scale(1); }
  100% { box-shadow: 0 0 22px rgba(255, 225, 0, 0.9); transform: scale(1.04); }
}

/* Top-5 leaderboard shown on the Game Over screen */
.leaderboard {
  margin: 18px auto 22px;
  padding: 12px 16px;
  max-width: 320px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-align: left;
}
.lb-title {
  font-size: 0.8rem;
  letter-spacing: 2px;
  font-weight: 800;
  color: #ffe100;
  text-align: center;
  margin-bottom: 8px;
}
.lb-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.lb-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 4px 0;
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
  color: var(--text-primary);
  border-bottom: 1px dashed rgba(255, 255, 255, 0.08);
}
.lb-list li:last-child {
  border-bottom: none;
}
.lb-list li:nth-child(1) .lb-score { color: #ffe100; font-weight: 800; }
.lb-list li:nth-child(2) .lb-score { color: #cfd8dc; }
.lb-list li:nth-child(3) .lb-score { color: #d49a6a; }
.lb-score { font-weight: 700; }
.lb-meta { color: var(--text-secondary); font-size: 0.75rem; }
.lb-empty {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.85rem;
  padding: 4px 0;
}

.level-title {
  font-size: 2rem;
  font-weight: 800;
  color: #ffe100;
  margin-bottom: 10px;
}

.level-ready {
  font-size: 1.2rem;
  color: var(--success);
  font-weight: 700;
  animation: blink 1s ease-in-out infinite;
}

.pause-title {
  font-size: 2rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 10px;
}

.pause-sub {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.game-footer {
  text-align: center;
  padding: 20px;
  color: #555;
  font-size: 0.8rem;
}

/* Mute button — floating over the canvas */
.mute-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 20;
  width: 40px;
  height: 40px;
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: 50%;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  -webkit-user-select: none;
  user-select: none;
  line-height: 1;
}
.mute-btn:hover {
  background: rgba(255,255,255,0.2);
  border-color: rgba(255,255,255,0.6);
}
.mute-btn.muted {
  opacity: 0.5;
  border-color: var(--accent);
}

/* Touch controls — always visible, clickable with mouse too */
.touch-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-top: 16px;
  padding: 12px 0;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

.dpad-row {
  display: flex;
  gap: 4px;
  justify-content: center;
}

.dpad-btn {
  width: 56px;
  height: 56px;
  border: none;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 1.4rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.dpad-btn:active {
  background: rgba(233, 69, 96, 0.6);
}

.dpad-blank {
  background: transparent;
  pointer-events: none;
}

/* Trophy button in HUD */
.trophies-btn {
  background: rgba(255, 215, 0, 0.15);
  color: #ffe100;
  border: 1px solid rgba(255, 215, 0, 0.4);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  font-family: 'Courier New', monospace;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
  letter-spacing: 0.5px;
}
.trophies-btn:hover {
  background: rgba(255, 215, 0, 0.3);
  border-color: #ffe100;
  transform: translateY(-1px);
}
.trophies-btn.all-done {
  background: rgba(255, 215, 0, 0.35);
  border-color: #ffe100;
  text-shadow: 0 0 6px rgba(255, 225, 0, 0.6);
}

/* Trophy modal */
.trophy-modal {
  max-width: 460px;
  max-height: 80vh;
  background: var(--bg-secondary);
  border: 2px solid #ffe100;
  border-radius: 14px;
  padding: 22px 24px;
  overflow-y: auto;
  box-shadow: 0 0 40px rgba(255, 215, 0, 0.25);
}
.trophy-title {
  font-size: 1.5rem;
  font-weight: 900;
  color: #ffe100;
  letter-spacing: 3px;
  text-align: center;
  margin-bottom: 14px;
  text-shadow: 0 0 12px rgba(255, 225, 0, 0.5);
}
.trophy-progress-wrap {
  margin-bottom: 16px;
}
.trophy-progress-bar {
  width: 100%;
  height: 12px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(255, 215, 0, 0.3);
}
.trophy-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #e94560, #ffe100, #4ecca3);
  background-size: 200% 100%;
  border-radius: 6px;
  transition: width 0.5s ease;
  animation: trophy-shimmer 3s linear infinite;
}
@keyframes trophy-shimmer {
  0%   { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}
.trophy-progress-text {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 6px;
  letter-spacing: 1px;
  font-family: 'Courier New', monospace;
}
.trophy-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 10px 0 16px;
  max-height: 50vh;
  overflow-y: auto;
  padding: 4px;
}
.trophy-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 10px 6px;
  text-align: center;
  position: relative;
  transition: all 0.25s;
}
.trophy-card.unlocked {
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.12), rgba(255, 215, 0, 0.04));
  border-color: rgba(255, 215, 0, 0.5);
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.18);
}
.trophy-card.unlocked .trophy-icon {
  animation: trophy-pulse 2.4s ease-in-out infinite;
}
@keyframes trophy-pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.08); }
}
.trophy-card.locked .trophy-icon {
  filter: grayscale(1) brightness(0.4);
  opacity: 0.45;
}
.trophy-card.locked .trophy-name,
.trophy-card.locked .trophy-desc {
  color: var(--text-secondary);
  opacity: 0.55;
}
.trophy-icon {
  font-size: 1.8rem;
  display: block;
  margin-bottom: 4px;
  line-height: 1;
}
.trophy-name {
  font-size: 0.75rem;
  font-weight: 800;
  color: #ffe100;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
  text-transform: uppercase;
}
.trophy-desc {
  font-size: 0.65rem;
  color: var(--text-secondary);
  line-height: 1.25;
  margin-bottom: 4px;
  min-height: 28px;
}
.trophy-date {
  font-size: 0.6rem;
  color: #4ecca3;
  font-family: 'Courier New', monospace;
  margin-top: 2px;
}
.trophy-locked-tag {
  font-size: 0.65rem;
  color: #666;
  margin-top: 2px;
}
.trophy-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 8px;
}
.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.18);
  transform: translateY(-1px);
}

/* Trophy toast notifications — slide in from top-right */
.trophy-toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.trophy-toast {
  background: linear-gradient(135deg, #2a2200, #4a3a00);
  border: 2px solid #ffe100;
  border-radius: 10px;
  padding: 10px 14px;
  min-width: 240px;
  max-width: 320px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 4px 24px rgba(255, 215, 0, 0.4);
  animation: trophy-toast-slide 0.5s ease-out, trophy-toast-fade 0.6s ease-in 3.2s forwards;
  pointer-events: auto;
}
.trophy-toast .trophy-toast-icon {
  font-size: 1.8rem;
  animation: trophy-toast-pulse 1.4s ease-in-out infinite;
}
.trophy-toast .trophy-toast-body {
  flex: 1;
  min-width: 0;
}
.trophy-toast .trophy-toast-label {
  font-size: 0.65rem;
  color: #ffe100;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 2px;
}
.trophy-toast .trophy-toast-name {
  font-size: 0.95rem;
  color: #fff;
  font-weight: 800;
  margin-bottom: 2px;
}
.trophy-toast .trophy-toast-desc {
  font-size: 0.7rem;
  color: var(--text-secondary);
  line-height: 1.2;
}
@keyframes trophy-toast-slide {
  0%   { transform: translateX(120%); opacity: 0; }
  100% { transform: translateX(0);    opacity: 1; }
}
@keyframes trophy-toast-fade {
  0%   { opacity: 1; transform: translateX(0); }
  100% { opacity: 0; transform: translateX(40px); }
}
@keyframes trophy-toast-pulse {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50%      { transform: scale(1.18) rotate(-8deg); }
}

/* Mobile: 2-column grid for trophies */
@media (max-width: 600px) {
  .trophy-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .trophy-toast-container {
    top: 8px;
    right: 8px;
    left: 8px;
  }
  .trophy-toast {
    min-width: 0;
    max-width: none;
  }
}

/* ==================== SPEED-RUN TIMER ==================== */
/* Compact timer block in the HUD — shows level time + per-level PB badge */
.hud-timer {
  position: relative;
  padding-right: 4px;
}

#timer-display {
  letter-spacing: 0.5px;
  min-width: 76px;
  text-align: right;
  display: inline-block;
  font-variant-numeric: tabular-nums;
}

/* When the current run is beating the PB, glow the timer gold */
#timer-display.ahead-pb {
  color: #ffe100;
  text-shadow: 0 0 8px rgba(255, 225, 0, 0.7);
  animation: timer-ahead-pulse 0.9s ease-in-out infinite;
}

@keyframes timer-ahead-pulse {
  0%, 100% { transform: scale(1); text-shadow: 0 0 8px rgba(255, 225, 0, 0.6); }
  50%      { transform: scale(1.06); text-shadow: 0 0 14px rgba(255, 225, 0, 0.95); }
}

/* Tiny PB badge — sits underneath the timer value */
.hud-pb-tag {
  display: inline-block;
  margin-left: 6px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #ffe100;
  background: rgba(255, 215, 0, 0.12);
  border: 1px solid rgba(255, 215, 0, 0.35);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  vertical-align: middle;
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
}
.hud-pb-tag.no-pb {
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.12);
}

/* Final run time on the Game Over screen */
.gameover-time {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 14px;
  font-family: 'Courier New', monospace;
  letter-spacing: 1px;
}
.gameover-time #final-time {
  color: #ffe100;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* PB summary block — appears on Game Over when new records were set */
.pb-summary {
  margin: 14px auto 18px;
  padding: 12px 16px;
  max-width: 320px;
  background: rgba(255, 215, 0, 0.06);
  border: 1px solid rgba(255, 215, 0, 0.4);
  border-radius: 8px;
  text-align: left;
}
.pb-summary.hidden { display: none; }
.pb-summary-title {
  font-size: 0.78rem;
  letter-spacing: 2px;
  font-weight: 800;
  color: #ffe100;
  text-align: center;
  margin-bottom: 8px;
}
.pb-summary-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.pb-summary-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 4px 0;
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
  color: var(--text-primary);
  border-bottom: 1px dashed rgba(255, 215, 0, 0.18);
}
.pb-summary-list li:last-child { border-bottom: none; }
.pb-summary-level { color: #ffe100; font-weight: 700; }
.pb-summary-time  { color: var(--text-primary); font-variant-numeric: tabular-nums; }

/* ==================== PB TOAST (top-left) ==================== */
.pb-toast-container {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.pb-toast {
  background: linear-gradient(135deg, #1a1300, #3a2a00);
  border: 2px solid #ffe100;
  border-radius: 10px;
  padding: 10px 14px;
  min-width: 220px;
  max-width: 320px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 4px 24px rgba(255, 215, 0, 0.45);
  animation: pb-toast-slide 0.5s ease-out, pb-toast-fade 0.6s ease-in 3.7s forwards;
  pointer-events: auto;
}
.pb-toast-icon {
  font-size: 1.9rem;
  animation: pb-toast-spin 1.6s ease-in-out infinite;
  filter: drop-shadow(0 0 6px rgba(255, 215, 0, 0.7));
}
.pb-toast-body { flex: 1; min-width: 0; }
.pb-toast-label {
  font-size: 0.65rem;
  color: #ffe100;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 2px;
}
.pb-toast-level {
  font-size: 0.8rem;
  color: #fff;
  font-weight: 700;
  margin-bottom: 2px;
}
.pb-toast-time {
  font-size: 1.1rem;
  color: #ffe100;
  font-weight: 800;
  font-family: 'Courier New', monospace;
  font-variant-numeric: tabular-nums;
  letter-spacing: 1px;
}
.pb-toast-delta {
  font-size: 0.7rem;
  color: #4ecca3;
  margin-top: 2px;
  font-weight: 700;
  font-family: 'Courier New', monospace;
  font-variant-numeric: tabular-nums;
}
@keyframes pb-toast-slide {
  0%   { transform: translateX(-120%); opacity: 0; }
  100% { transform: translateX(0);    opacity: 1; }
}
@keyframes pb-toast-fade {
  0%   { opacity: 1; transform: translateX(0); }
  100% { opacity: 0; transform: translateX(-40px); }
}
@keyframes pb-toast-spin {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50%      { transform: scale(1.18) rotate(15deg); }
}

@media (max-width: 600px) {
  .game-wrapper {
    padding: 8px 8px;
  }
  #gameCanvas, .hud {
    width: 100%;
    max-width: 560px;
  }
  #gameCanvas {
    height: auto;
    aspect-ratio: 560/620;
  }
  .hud {
    padding: 6px 10px;
  }
  .game-header { padding: 10px 12px; }
  .game-header h1 { font-size: 1.1rem; }
  .game-header .back-link { font-size: 0.8rem; }
  .title-logo { font-size: 2rem; }
  .title-sub, .title-controls { font-size: 0.85rem; }
  .dpad-btn {
    width: 48px;
    height: 48px;
    font-size: 1.1rem;
  }
  .pb-toast-container {
    top: 8px;
    left: 8px;
    right: 8px;
  }
  .pb-toast {
    min-width: 0;
    max-width: none;
  }
  .powerup-hud {
    font-size: 0.7rem;
    padding: 3px 6px;
    gap: 5px;
  }
  .powerup-icon {
    font-size: 0.95rem;
  }
  .powerup-bar {
    width: 36px;
  }
}

/* ==================== POWER-UP SYSTEM ==================== */
/* Active power-up HUD chip — appears next to the trophy button when a power-up is running. */
.powerup-hud {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.18);
  font-family: 'Courier New', monospace;
  font-weight: 800;
  font-size: 0.78rem;
  letter-spacing: 1px;
  color: #fff;
  position: relative;
  overflow: hidden;
  transition: opacity 0.25s, transform 0.25s;
}
.powerup-hud.hidden { display: none; }
.powerup-hud.entering { animation: powerup-hud-pop 0.4s ease-out; }
.powerup-hud.fading { opacity: 0; transform: scale(0.85); }

/* Per-power-up color theming via [data-kind] */
.powerup-hud[data-kind="slow"]   { border-color: #4ec0ff; background: linear-gradient(135deg, rgba(0,40,80,0.7), rgba(0,80,140,0.6)); color: #4ec0ff; }
.powerup-hud[data-kind="fast"]   { border-color: #ffe100; background: linear-gradient(135deg, rgba(80,60,0,0.7), rgba(140,110,0,0.6)); color: #ffe100; }
.powerup-hud[data-kind="double"] { border-color: #4ecca3; background: linear-gradient(135deg, rgba(0,60,40,0.7), rgba(30,110,80,0.6)); color: #4ecca3; }
.powerup-hud[data-kind="scare"]  { border-color: #ff6b81; background: linear-gradient(135deg, rgba(80,0,30,0.7), rgba(140,30,60,0.6)); color: #ff6b81; }

.powerup-icon {
  font-size: 1.1rem;
  line-height: 1;
  filter: drop-shadow(0 0 4px currentColor);
  animation: powerup-icon-pulse 1s ease-in-out infinite;
}
.powerup-label {
  font-size: 0.72rem;
  letter-spacing: 1.5px;
  text-shadow: 0 0 6px rgba(0, 0, 0, 0.6);
}
.powerup-bar {
  width: 48px;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
}
.powerup-bar-fill {
  display: block;
  height: 100%;
  width: 100%;
  background: currentColor;
  border-radius: 3px;
  transform-origin: left center;
  transform: scaleX(1);
  transition: transform 0.15s linear;
  box-shadow: 0 0 6px currentColor;
}

@keyframes powerup-hud-pop {
  0%   { transform: scale(0.6); opacity: 0; }
  60%  { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes powerup-icon-pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.18); }
}

/* "POWER-UP!" toast — drops in from the top center when a magic pellet spawns */
.powerup-spawn-toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.85);
  color: #ffe100;
  border: 2px solid #ffe100;
  border-radius: 10px;
  padding: 8px 18px;
  font-family: 'Courier New', monospace;
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: 2px;
  box-shadow: 0 4px 24px rgba(255, 215, 0, 0.45);
  z-index: 9999;
  animation: powerup-spawn-slide 0.5s ease-out, powerup-spawn-fade 0.6s ease-in 2.3s forwards;
  pointer-events: none;
}
.powerup-spawn-toast[data-kind="slow"]   { color: #4ec0ff; border-color: #4ec0ff; box-shadow: 0 4px 24px rgba(78, 192, 255, 0.45); }
.powerup-spawn-toast[data-kind="fast"]   { color: #ffe100; border-color: #ffe100; box-shadow: 0 4px 24px rgba(255, 215, 0, 0.45); }
.powerup-spawn-toast[data-kind="double"] { color: #4ecca3; border-color: #4ecca3; box-shadow: 0 4px 24px rgba(78, 204, 163, 0.45); }
.powerup-spawn-toast[data-kind="scare"]  { color: #ff6b81; border-color: #ff6b81; box-shadow: 0 4px 24px rgba(255, 107, 129, 0.45); }

@keyframes powerup-spawn-slide {
  0%   { transform: translateX(-50%) translateY(-30px); opacity: 0; }
  100% { transform: translateX(-50%) translateY(0);     opacity: 1; }
}
@keyframes powerup-spawn-fade {
  0%   { opacity: 1; transform: translateX(-50%) translateY(0); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-20px); }
}

/* Soft screen-tint applied to the canvas container while a power-up is active. */
.powerup-tint {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  border-radius: 10px;
  transition: opacity 0.4s;
  opacity: 0;
}
.powerup-tint.active { opacity: 1; }
.powerup-tint[data-kind="slow"]   { box-shadow: inset 0 0 80px rgba(78, 192, 255, 0.32); }
.powerup-tint[data-kind="fast"]   { box-shadow: inset 0 0 80px rgba(255, 225, 0, 0.32); }
.powerup-tint[data-kind="double"] { box-shadow: inset 0 0 80px rgba(78, 204, 163, 0.32); }
.powerup-tint[data-kind="scare"]  { box-shadow: inset 0 0 80px rgba(255, 107, 129, 0.32); }

/* ============================================================
   LIVE MINIMAP / RADAR
   A small always-visible mini-map that mirrors the maze state.
   - Walls: pale blue grid
   - Dots: tiny pink squares
   - Power pellets: slightly bigger pulsing white squares
   - Pacman: yellow disc
   - Ghosts: colored discs (blue+white border when frightened, white when eaten)
   - Fruit: orange star
   - Power-up magic pellet: cyan diamond
   - Red pulsing border when a ghost is close (danger)
   ============================================================ */
.minimap-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #0f0f23;
  border: 1.5px solid #2121de;
  border-radius: 6px;
  padding: 2px;
  margin-left: 4px;
  box-shadow: 0 0 6px rgba(33, 33, 222, 0.4);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.minimap-wrap.minimap-danger {
  border-color: #ff3838;
  box-shadow: 0 0 10px rgba(255, 56, 56, 0.85);
  animation: minimapDangerPulse 0.9s ease-in-out infinite;
}
@keyframes minimapDangerPulse {
  0%, 100% { box-shadow: 0 0 6px rgba(255, 56, 56, 0.5); }
  50%      { box-shadow: 0 0 14px rgba(255, 56, 56, 1); }
}
.minimap-wrap.minimap-hidden { display: none; }
.minimap-canvas {
  display: block;
  image-rendering: pixelated;
  /* Don't capture clicks — pure display */
  pointer-events: none;
}
.minimap-toggle {
  background: transparent;
  border: 1.5px solid #2a2a4a;
  color: #eee;
  font-size: 1.1rem;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  margin-left: 2px;
  line-height: 1;
}
.minimap-toggle:hover { border-color: var(--accent); }
.minimap-toggle.off {
  opacity: 0.45;
  filter: grayscale(0.7);
}

/* On narrow screens, drop the minimap below the HUD so it doesn't crowd */
@media (max-width: 640px) {
  .hud {
    flex-wrap: wrap;
    row-gap: 8px;
  }
  .minimap-wrap, .minimap-toggle { order: 99; }
}

/* ============================================================ */

