body {
  overflow: hidden;
  touch-action: pan-y;
  user-select: none;
}

#container {
  position: relative;
  width: 100vw;
  height: 100vh;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  transition: background-image 0.5s ease;
}

#mobileControls {
  display: none;
  position: fixed;
  bottom: 20px;
  left: 0;
  right: 0;
  z-index: 1000;
}

#toggleControls {
  position: fixed;
  top: 10px;
  right: 10px;
  padding: 10px 15px;
  background: rgba(255, 255, 255, 0.3);
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-radius: 10px;
  color: white;
  cursor: pointer;
  z-index: 1001;
  font-size: 16px;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

#toggleControls:hover {
  background: rgba(255, 255, 255, 0.4);
}

#touchPad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 5px;
  width: 180px;
  height: 180px;
  margin: 0 auto;
}

.controlButton {
  background: rgba(255, 255, 255, 0.3);
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-radius: 10px;
  color: white;
  text-align: center;
  font-size: 24px;
  line-height: 50px;
  user-select: none;
  touch-action: none;
}

#leftButton {
  grid-column: 1;
  grid-row: 2;
}

#rightButton {
  grid-column: 3;
  grid-row: 2;
}

#upButton {
  grid-column: 2;
  grid-row: 1;
}

#downButton {
  grid-column: 2;
  grid-row: 3;
}

#actionButton {
  width: 100px;
  height: 50px;
  margin: 20px auto 0;
  line-height: 50px;
}

.bart {
  position: absolute;
  width: 50px;
  height: auto;
  cursor: pointer;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.bart img {
  width: 100%;
  height: auto;
  display: block;
}

.destroyed {
  opacity: 0;
  transform: scale(0.2);
}

.explosion {
  position: absolute;
  width: 60px;
  height: 60px;
  background-image: url('/explode.gif');
  background-size: cover;
  pointer-events: none;
  z-index: 1000;
}

.spike-container {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 300px;
  height: 150px;
  display: flex;
  justify-content: space-between;
  transition: left 0.3s ease;
}

.spike {
  position: relative;
  bottom: 0;
  width: 100px;
  height: 150px;
  background-image: url('/costume2 (8).png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: bottom;
  transition: transform 0.3s ease;
}

#levelInfo {
  position: fixed;
  top: 10px;
  left: 10px;
  font-size: 24px;
  color: white;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
  z-index: 1000;
}

#levelName {
  position: fixed;
  top: 40px;
  left: 10px;
  font-size: 24px;
  color: white;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
  z-index: 1000;
}

#winMessage {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 32px;
  color: white;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
  display: none;
  z-index: 1000;
  background: rgba(0,0,0,0.7);
  padding: 20px;
  border-radius: 10px;
}

.thwomp {
  position: absolute;
  width: 100px;
  height: 100px;
  left: 50%;
  transform: translateX(-50%);
  top: 50px;
  transition: top 0.2s ease;
  display: none;
}

.thwomp img {
  width: 100%;
  height: 100%;
  display: block;
}

#level3Container {
  position: relative;
  width: 100%;
  height: 100%;
  display: none;
}

#level3Bart {
  position: absolute;
  left: 50%;
  bottom: 50px;
  transform: translateX(-50%);
  width: 50px;
  height: auto;
  display: inline-block;
  transform-origin: center bottom;
}

#level3Bart img {
  width: 100%;
  height: auto;
  display: block;
}

#level4Container {
  position: relative;
  width: 100%;
  height: 100%;
  display: none;
}

#tank {
  position: absolute;
  bottom: 50px;
  left: 50%;
  transform: translateX(-50%);
  width: 100px;
  height: 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#tankBody {
  width: 100px;
  height: 100px;
  background-image: url('/tank.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

#tankBarrel {
  display: none;
}

.bullet {
  position: absolute;
  width: 20px;
  height: 20px;
  background-image: url('/5441aa1580a8925 (1).png');
  background-size: contain;
  background-repeat: no-repeat;
  pointer-events: none;
  transition: bottom 1s linear;
}

#level4Bart {
  position: absolute;
  left: 50%;
  top: 50px;
  transform: translateX(-50%);
  width: 50px;
  height: auto;
}

#level4Bart img {
  width: 100%;
  height: auto;
  display: block;
}

#level5Container {
  position: relative;
  width: 100%;
  height: 100%;
  display: none;
}

.level5-bart {
  position: absolute;
  width: 50px;
  height: auto;
  transform: translateY(-50%);
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.level5-bart img {
  width: 100%;
  height: auto;
  display: block;
}

.car {
  position: absolute;
  width: 60px;
  height: auto;
  transform: translateX(-50%);
  transition: top 0.2s ease;
}

.car img {
  width: 100%;
  height: auto;
  display: block;
  transform: rotate(-90deg);
}

.playable-bart {
  position: absolute;
  width: 50px;
  height: auto;
  z-index: 100;
}

.playable-bart img {
  width: 100%;
  height: auto;
  display: block;
}

.level8-thwomp {
  position: absolute;
  width: 100px;
  height: 100px;
  transition: top 0.2s ease;
  z-index: 90;
}

.level8-spike {
  width: 100px;
  height: 150px;
  background-image: url('/costume2 (8).png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: bottom;
  z-index: 80;
}

.evil-clown {
  width: 50px;
  height: auto;
  position: absolute;
  z-index: 100;
}

.evil-clown img {
  width: 100%;
  height: auto;
  display: block;
}

.ghost {
  position: absolute;
  width: 50px;
  height: 50px;
  z-index: 100;
}

.ghost img {
  width: 100%;
  height: 100%;
  display: block;
}

.helicopter {
  position: absolute;
  width: 80px;
  height: 80px;
  transform: translate(-50%, -50%);
  z-index: 1000;
  pointer-events: none;
}

.helicopter img {
  width: 100%;
  height: 100%;
  display: block;
}

.ghost-bullet {
  position: absolute;
  width: 20px;
  height: 20px;
  background-image: url('/ghost bullet.png');
  background-size: contain;
  background-repeat: no-repeat;
  pointer-events: none;
  z-index: 900;
}

.chest {
  position: absolute;
  width: 60px;
  height: 60px;
  transform: translate(-50%, -50%);
  z-index: 100;
}

.chest img {
  width: 100%;
  height: 100%;
  display: block;
}

.dog {
  position: absolute;
  width: 50px;
  height: 50px;
  transform: translate(-50%, -50%);
  z-index: 90;
}

.dog img {
  width: 100%;
  height: 100%;
  display: block;
}

.sports {
  position: absolute;
  width: 100px;
  height: 100px;
  transform: translate(0, -50%);
  z-index: 80;
}

.sports img {
  width: 100%;
  height: 100%;
  display: block;
}

.dk-player {
  position: absolute;
  width: 80px;
  height: 80px;
  transform: translate(-50%, -50%);
  z-index: 100;
}

.dk-player img {
  width: 100%;
  height: 100%;
  display: block;
}

.boulder {
  position: absolute;
  width: 100px;
  height: 100px;
  transform: translate(-50%, -50%);
  z-index: 100;
}

.boulder img {
  width: 100%;
  height: 100%;
  display: block;
}

.ground-bart {
  z-index: 90;
}

.robber {
  position: absolute;
  width: 50px;
  height: auto;
  z-index: 100;
}

.robber img {
  width: 100%;
  height: auto;
  display: block;
}

.money-bag {
  position: absolute;
  width: 40px;
  height: auto;
  z-index: 90;
}

.money-bag img {
  width: 100%;
  height: auto;
  display: block;
}

.snifit {
  position: absolute;
  width: 80px;
  height: 80px;
  transform: translateY(-50%);
  z-index: 100;
}

.snifit img {
  width: 100%;
  height: 100%;
  display: block;
}

.snifit-bullet {
  position: absolute;
  width: 20px;
  height: 20px;
  background-image: url('/snifit bullet.png');
  background-size: contain;
  background-repeat: no-repeat;
  pointer-events: none;
  z-index: 900;
}

.moving-bart {
  transition: none;
}

@media (hover: none) and (pointer: coarse) {
  #mobileControls {
    display: block;
  }
  
  #container {
    padding-bottom: 280px;
  }
  
  .bart {
    min-width: 60px;
    min-height: 60px;
  }
  
  .explosion {
    min-width: 80px;
    min-height: 80px;
  }
  
  #levelInfo, #levelName {
    font-size: 32px;
  }
  
  #winMessage {
    font-size: 40px;
  }
}

.mario {
  position: absolute;
  width: 50px;
  height: 50px;
  transform-origin: center;
  z-index: 100;
}

.mario img {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
}

#mainMenu {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #444444;
  z-index: 2000;
  overflow-y: auto;
  min-height: 480px;
}

.menuLogo {
  max-width: 80%;
  height: auto;
  margin-bottom: 40px;
  min-width: 300px;
}

.menuButtons {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.menuButtons button {
  padding: 15px 40px;
  font-size: 24px;
  background: #555555;
  color: white;
  border: 2px solid #777777;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.2s;
}

.menuButtons button:hover {
  background: #666666;
}

#settingsMenu {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #444444;
  z-index: 2000;
  color: white;
}

.settingsControl {
  margin: 20px 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.settingsControl input[type="range"] {
  width: 200px;
}

#backButton {
  margin-top: 30px;
  padding: 10px 25px;
  font-size: 18px;
  background: #555555;
  color: white;
  border: 2px solid #777777;
  border-radius: 5px;
  cursor: pointer;
}

#backButton:hover {
  background: #666666;
}

#levelSelectMenu {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  background: #444444;
  z-index: 2000;
  color: white;
  padding: 20px;
  overflow-y: auto;
}

.levelGrid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 15px;
  margin: 20px;
  max-width: 800px;
  width: 100%;
}

.levelButton {
  padding: 15px;
  background: #555555;
  color: white;
  border: 2px solid #777777;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.2s;
  text-align: center;
}

.levelButton:hover {
  background: #666666;
}

.levelButton.locked {
  background: #333333;
  cursor: not-allowed;
  opacity: 0.5;
}

.levelButton .levelNumber {
  font-size: 24px;
  font-weight: bold;
  margin-bottom: 5px;
}

.levelButton .levelName {
  font-size: 12px;
  height: 32px;
  overflow: hidden;
}

#levelSelectBackButton {
  margin-top: 20px;
  padding: 10px 25px;
  font-size: 18px;
  background: #555555;
  color: white;
  border: 2px solid #777777;
  border-radius: 5px;
  cursor: pointer;
}

#levelSelectBackButton:hover {
  background: #666666;
}