/* =====================
   GLOBAL STYLES
   ===================== */
html, body {
  margin: 0;
  background: #0056ff;
  color: #fff;
  font-family: "Jersey 10", serif;
  image-rendering: pixelated;
  min-height: 100vh;
}

body {
  background-size: cover;
  background-repeat: no-repeat;
  background-attachment: fixed;
  background-position: center center;
}

/* =====================
   INSTRUCTIONS SCREEN - RESPONSIVE
   ===================== */
.instructions-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.95);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  padding: 20px;
}

.instructions-content-new {
  max-width: 1200px;
  width: 100%;
  background: #0056ff;
  border: 8px solid #ffd700;
  border-radius: 24px;
  padding: 40px;
  box-shadow: 0 0 40px rgba(255, 215, 0, 0.6);
}

/* Logo and Button Header */
.instructions-header {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  align-items: center;
  margin-bottom: 20px;
  gap: 20px;
}

.instructions-logo {
  grid-column: 1;
  text-align: left;
}

.instructions-logo img {
  max-width: 250px;
  height: auto;
}

/* Start Game Button - Centered in middle column */
.start-game-btn-new {
  grid-column: 2;
  justify-self: center;
  padding: 12px 40px;
  font-family: "Jersey 10", serif;
  font-size: 48px;
  background: #ffd700;
  color: #000;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 0 #cc9900;
  text-transform: capitalize;
  font-weight: bold;
  white-space: nowrap;
}

.start-game-btn-new:hover {
  background: #ffed4e;
  transform: translateY(-2px);
  box-shadow: 0 6px 0 #cc9900;
}

.start-game-btn-new:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #cc9900;
}

/* Dividers */
.instructions-divider {
  height: 4px;
  background: #ffd700;
  margin: 20px 0;
}

/* Box Styling */
.instructions-box {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 12px;
  padding: 20px;
}

.instructions-box h2 {
  font-size: 40px;
  color: #ffd700;
  text-align: center;
  margin: 0 0 10px 0;
  text-transform: capitalize;
  font-weight: bold;
}

/* Top Row Layout */
.instructions-top-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
  margin-bottom: 0;
}

/* Controls Section */
.controls-arrows {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
}

.arrow-row {
  display: flex;
  gap: 8px;
}

.arrow-key {
  width: 45px;
  height: 45px;
  background: rgba(255, 255, 255, 0.2);
  border: 3px solid #fff;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: #fff;
  font-weight: bold;
}

/* Mobile D-pad preview */
.dpad-preview {
  display: none;
  justify-content: center;
  margin: 15px 0;
}

.dpad-mini {
  display: grid;
  grid-template-areas:
    ". up ."
    "left center right"
    ". down .";
  gap: 5px;
  width: 150px;
}

.dpad-mini-btn {
  background: rgba(255, 255, 255, 0.2);
  border: 3px solid #fff;
  border-radius: 8px;
  padding: 15px;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: bold;
}

.dpad-mini-btn.up { grid-area: up; }
.dpad-mini-btn.down { grid-area: down; }
.dpad-mini-btn.left { grid-area: left; }
.dpad-mini-btn.right { grid-area: right; }
.dpad-mini-btn.center { 
  grid-area: center; 
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.2);
}

/* Desktop/Mobile Toggle */
.desktop-only {
  display: flex;
}

.mobile-only {
  display: none;
}

/* Whack Man States */
.states-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  padding: 20px;
}

.state-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.state-item span {
  font-size: 28px;
  color: #fff;
  font-weight: bold;
}

/* Middle Row Layout */
.instructions-middle-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
  margin-bottom: 0;
}

/* Collectibles */
.collectibles-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  padding: 20px;
}

.collectible-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.collectible-label {
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.collectible-name {
  font-size: 22px;
  color: #fff;
  font-weight: bold;
  line-height: 1.2;
}

.collectible-points {
  font-size: 18px;
  color: #fff;
  line-height: 1.2;
}

/* Power Ups */
.powerups-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  padding: 20px;
}

.powerup-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.powerup-label {
  text-align: center;
}

.powerup-name {
  font-size: 22px;
  color: #fff;
  font-weight: bold;
  line-height: 1.2;
}

/* Bottom Row Layout */
.instructions-bottom-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
}

/* Goobs Boxes */
.goobs-box h2 {
  font-size: 36px;
  margin-bottom: 5px;
}

.goobs-subtitle {
  text-align: center;
  color: #fff;
  font-size: 20px;
  margin: 0 0 15px 0;
}

.goobs-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 15px;
  margin-bottom: 20px;
}

.goob-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.goob-item span {
  font-size: 20px;
  color: #fff;
  font-weight: bold;
}

/* Scared Goobs / Goob Warp */
.scared-goobs,
.goob-warp {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 15px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
}

.scared-goobs p,
.goob-warp p {
  font-size: 18px;
  color: #fff;
  margin: 0;
  line-height: 1.4;
}

/* Device Info */
.device-info {
  text-align: center;
  margin-top: 20px;
  font-size: 20px;
  color: #ffd700;
  font-weight: bold;
}

/* Sprite Boxes - No border, no background, fixed sizing */
.sprite-box {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-repeat: no-repeat;
  background-position: 0 0;
  image-rendering: pixelated;
  overflow: hidden;
}

/* Animated Sprite Images */
@keyframes pacmanAnim {
  0%, 50% { background-position: 0 0; }
  50.1%, 100% { background-position: -64px 0; }
}

@keyframes ghostAnim {
  0%, 50% { background-position: 0 0; }
  50.1%, 100% { background-position: -64px 0; }
}

/* Pac-Man sprites */
#pacman-normal { 
  background-image: url('../images/whack-man/whackman.png'); 
  background-size: 128px 256px;
  width: 64px;
  height: 64px;
  animation: pacmanAnim 0.6s steps(1) infinite;
}
#pacman-power { 
  background-image: url('../images/whack-man/whackman-power.png'); 
  background-size: 128px 256px;
  width: 64px;
  height: 64px;
  animation: pacmanAnim 0.6s steps(1) infinite;
}
#collectible { 
  background-image: url('../images/whack-man/collectible.png'); 
  background-size: 48px 48px;
  width: 48px;
  height: 48px;
}
#powerblock { 
  background-image: url('../images/whack-man/powerblock.png'); 
  background-size: 58px 58px;
  width: 58px;
  height: 58px;
}
#chest { 
  background-image: url('../images/whack-man/treasure-chest.png'); 
  background-size: 64px 64px;
  width: 64px;
  height: 64px;
}
#powerup-life { 
  background-image: url('../images/whack-man/powerup-life.png'); 
  background-size: 64px 64px;
  width: 64px;
  height: 64px;
}
#powerup-speed { 
  background-image: url('../images/whack-man/powerup-speed.png'); 
  background-size: 64px 64px;
  width: 64px;
  height: 64px;
}
#powerup-score { 
  background-image: url('../images/whack-man/powerup-score.png'); 
  background-size: 64px 64px;
  width: 64px;
  height: 64px;
}

/* Ghost sprites */
#ghost-red { 
  background-image: url('../images/whack-man/ghost-red.png'); 
  background-size: 128px 256px;
  animation: ghostAnim 0.6s steps(1) infinite;
}
#ghost-pink { 
  background-image: url('../images/whack-man/ghost-pink.png'); 
  background-size: 128px 256px;
  animation: ghostAnim 0.6s steps(1) infinite;
}
#ghost-blue { 
  background-image: url('../images/whack-man/ghost-blue.png'); 
  background-size: 128px 256px;
  animation: ghostAnim 0.6s steps(1) infinite;
}
#ghost-yellow { 
  background-image: url('../images/whack-man/ghost-yellow.png'); 
  background-size: 128px 256px;
  animation: ghostAnim 0.6s steps(1) infinite;
}
#ghost-invincible { 
  background-image: url('../images/whack-man/ghost-invincible.png'); 
  background-size: 128px 256px;
  animation: ghostAnim 0.6s steps(1) infinite;
}
#ghost-invincible2 { 
  background-image: url('../images/whack-man/ghost-invincible2.png'); 
  background-size: 128px 256px;
  animation: ghostAnim 0.6s steps(1) infinite;
}
#ghost-demon1 { 
  background-image: url('../images/whack-man/ghost-demon1.png'); 
  background-size: 128px 256px;
  animation: ghostAnim 0.6s steps(1) infinite;
}
#ghost-demon2 { 
  background-image: url('../images/whack-man/ghost-demon2.png'); 
  background-size: 128px 256px;
  animation: ghostAnim 0.6s steps(1) infinite;
}
#ghost-frightened { 
  background-image: url('../images/whack-man/ghost-red-fright.png'); 
  background-size: 128px 256px;
  animation: ghostAnim 0.6s steps(1) infinite;
}

/* Ghost house */
#goob-warp {
  background-image: url('../images/whack-man/ghosthouse.png');
  background-size: 64px 256px;
  background-position: 0 0;
  width: 64px;
  height: 64px;
}

/* =====================
   MOBILE RESPONSIVE
   ===================== */
@media (max-width: 1024px) {
  .instructions-overlay {
    padding: 0;
    align-items: flex-start;
  }

  .instructions-content-new {
    padding: 20px 15px;
    border-width: 4px;
    border-radius: 16px;
    margin-top: 0;
    min-height: 100vh;
  }

  /* Header - Stack vertically on mobile */
  .instructions-header {
    grid-template-columns: 1fr;
    text-align: center;
    gap: 15px;
    margin-bottom: 15px;
  }

  .instructions-logo {
    grid-column: 1;
    text-align: center;
  }

  .instructions-logo img {
    max-width: 180px;
  }

  .start-game-btn-new {
    grid-column: 1;
    font-size: 32px;
    padding: 12px 30px;
  }

  /* Single column layouts on mobile */
  .instructions-top-row,
  .instructions-middle-row,
  .instructions-bottom-row {
    grid-template-columns: 1fr;
    gap: 15px;
  }

  .instructions-box {
    padding: 15px;
  }

  .instructions-box h2 {
    font-size: 28px;
    margin-bottom: 15px;
  }

  .instructions-divider {
    margin: 15px 0;
  }

  /* Show mobile controls, hide desktop */
  .desktop-only {
    display: none !important;
  }

  .mobile-only {
    display: flex !important;
  }

  .dpad-preview {
    display: flex;
  }

  /* MOBILE: Horizontal layout - sprite left, text right */
  .states-grid {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 10px;
  }

  .state-item {
    flex-direction: row;
    justify-content: flex-start;
    gap: 15px;
  }

  .state-item span {
    font-size: 20px;
  }

  .collectibles-grid,
  .powerups-grid {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 10px;
  }

  .collectible-item,
  .powerup-item {
    flex-direction: row;
    justify-content: flex-start;
    min-height: auto;
    gap: 15px;
  }

  .collectible-label,
  .powerup-label {
    text-align: left;
    min-height: auto;
    justify-content: center;
  }

  .collectible-name,
  .powerup-name {
    font-size: 18px;
  }

  .collectible-points {
    font-size: 16px;
  }

  /* Goobs: Horizontal layout */
  .goobs-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .goob-item {
    flex-direction: row;
    justify-content: flex-start;
    gap: 15px;
  }

  .goob-item span {
    font-size: 18px;
  }

  .goobs-subtitle {
    font-size: 16px;
  }

  .scared-goobs p,
  .goob-warp p {
    font-size: 15px;
  }

  .device-info {
    font-size: 14px;
    padding: 10px;
  }

  /* SMALLER STATIC SPRITES for mobile */
  .sprite-box {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
  }

  /* Disable animations on mobile - static sprites */
  #pacman-normal,
  #pacman-power,
  #ghost-red,
  #ghost-pink,
  #ghost-blue,
  #ghost-yellow,
  #ghost-invincible,
  #ghost-invincible2,
  #ghost-demon1,
  #ghost-demon2,
  #ghost-frightened {
    animation: none !important;
  }

  #pacman-normal,
  #pacman-power {
    background-size: 80px 160px;
    width: 40px;
    height: 40px;
  }

  #collectible {
    background-size: 32px 32px;
    width: 32px;
    height: 32px;
  }

  #powerblock {
    background-size: 36px 36px;
    width: 36px;
    height: 36px;
  }

  #chest,
  #powerup-life,
  #powerup-speed,
  #powerup-score {
    background-size: 40px 40px;
    width: 40px;
    height: 40px;
  }

  #ghost-red,
  #ghost-pink,
  #ghost-blue,
  #ghost-yellow,
  #ghost-invincible,
  #ghost-invincible2,
  #ghost-demon1,
  #ghost-demon2,
  #ghost-frightened {
    background-size: 80px 160px;
    width: 40px;
    height: 40px;
  }

  #goob-warp {
    background-size: 40px 160px;
    width: 40px;
    height: 40px;
  }
}

/* Extra small screens (phones in portrait) */
@media (max-width: 480px) {
  .instructions-content-new {
    padding: 20px 15px;
  }

  .instructions-logo img {
    max-width: 150px;
  }

  .start-game-btn-new {
    font-size: 28px;
    padding: 12px 24px;
  }

  .instructions-box h2 {
    font-size: 28px;
  }

  .instructions-box {
    padding: 15px;
  }

  /* Stack collectibles and powerups in single column on very small screens */
  .collectibles-grid,
  .powerups-grid {
    grid-template-columns: 1fr;
  }
}