body {
  margin: 0;
  background: #000000;
  color: white;
  font-family: sans-serif;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  overflow: hidden;
  width: 100vw;
  position: relative;
}

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

#slots {
  display: flex;
  justify-content: center;
  gap: 4px;
  position: absolute;
  height: 230px;
  z-index: 3000;
}

.slot {
  display: inline-block;
  margin: 0 3px;
  vertical-align: top;
  text-align: center;
  position: relative;
  width: 42px;
  margin-top: 40px;
}
.slot.upgrade-space {
  height: 60px; /* Reserve space for upgrade buttons */
}
.slot .die {
  width: 42px;
  height: 42px;
  perspective: 400px;
  margin-bottom: 5px;
  cursor: pointer;
  /* Face placement */
}
.slot .die.disabled {
  pointer-events: none;
  opacity: 0.3;
}
.slot .die .cube-wrapper {
  width: 42px;
  height: 42px;
  perspective: none;
  transform-style: preserve-3d;
}
.slot .die .face {
  position: absolute;
  width: 42px;
  height: 42px;
  line-height: 42px;
  background: #fff;
  color: #000;
  border: 1px solid #999;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  padding: 0;
  margin: 0;
}
.slot .die .cube {
  width: 42px;
  height: 42px;
  transform-style: preserve-3d;
  transform: rotateX(0deg) rotateY(0deg) translateZ(-30px);
  transition: transform 1s;
}
.slot .die .cube-wrapper.rolling {
  animation: popRoll 0.5s ease;
}
@keyframes popRoll {
  0% {
    transform: scale(1) translateZ(0);
  }
  30% {
    transform: scale(1.2) translateZ(-10px);
  }
  100% {
    transform: scale(1) translateZ(0);
  }
}
.slot .die .front {
  transform: rotateY(0deg) translateZ(21px);
}
.slot .die .back {
  transform: rotateY(180deg) translateZ(21px);
}
.slot .die .right {
  transform: rotateY(90deg) translateZ(21px);
}
.slot .die .left {
  transform: rotateY(-90deg) translateZ(21px);
}
.slot .die .top {
  transform: rotateX(90deg) translateZ(21px);
}
.slot .die .bottom {
  transform: rotateX(-90deg) translateZ(21px);
}
.slot .die.bounce {
  animation: bounceDie 0.25s ease;
}
@keyframes bounceDie {
  0% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-8px);
  }
  100% {
    transform: translateY(0);
  }
}
.slot .cooldown {
  width: 100%;
  height: 6px;
  background: #444;
  border-radius: 3px;
  overflow: hidden;
}
.slot .cooldown .cooldown-fill {
  height: 100%;
  background: limegreen;
  width: 0%;
  transition: width 0.1s linear;
}

.plus-slot {
  position: absolute;
  top: 0;
  right: -80px;
  width: 60px;
}

#enemy-zone {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  background-image: url("images/grass.png");
  background-repeat: repeat;
  background-size: 60%;
  background-position: top left;
}
@media (max-width: 1200px) {
  #enemy-zone {
    background-size: 50%;
  }
}
@media (max-width: 600px) {
  #enemy-zone {
    background-size: 70%;
  }
}
@media (max-width: 500px) {
  #enemy-zone {
    background-size: 80%;
  }
}
@media (max-width: 400px) {
  #enemy-zone {
    background-size: 90%;
  }
}

.castle {
  position: fixed;
  bottom: 0;
  width: 100vw;
  max-width: 500px;
  height: 280px;
  min-height: 180px;
  background-image: url("images/castle.png");
  background-repeat: repeat;
  background-size: 50%;
  background-position: top left;
  z-index: 1000;
  display: flex;
  justify-content: center;
}
@media (max-width: 1200px) {
  .castle {
    background-size: 10%;
  }
}
@media (max-width: 600px) {
  .castle {
    background-size: 20%;
  }
}
@media (max-width: 500px) {
  .castle {
    background-size: 30%;
  }
}
@media (max-width: 400px) {
  .castle {
    background-size: 50%;
  }
}

.projectile {
  position: absolute;
  width: 8px;
  height: 8px;
  background: #0ff;
  border-radius: 50%;
  pointer-events: none;
}

#message {
  position: absolute;
  top: 20%;
  width: 100%;
  max-width: 300px;
  text-align: center;
  font-size: 2rem;
  color: black;
  display: none;
  border: 2px solid black;
  width: auto;
  padding: 50px 50px;
  background-color: #d0d0d0;
  font-size: 20px;
  z-index: 3000;
}
@media (max-width: 500px) {
  #message {
    padding: 20px 40px;
  }
}

.projectile {
  position: absolute;
  width: 8px;
  height: 8px;
  background: cyan;
  border-radius: 50%;
  pointer-events: none;
  z-index: 1000;
}

.add-die {
  display: inline-block;
  margin: 10px auto;
  padding: 6px 12px;
  font-size: 1rem;
  background: #28a745;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.add-die:hover {
  background: #218838;
}

.upgrade-buttons {
  position: absolute;
  top: 53px;
  left: 0px;
  width: 100%;
  overflow: hidden;
}
.upgrade-buttons button {
  display: block;
  margin: 4px auto;
  padding: 5px 0px;
  background: #007bff;
  color: white;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  font-size: 13px;
  width: 42px;
}
.upgrade-buttons button:hover {
  background: #0056b3;
}
.upgrade-buttons button.upgrade-element {
  background-color: white;
  padding: 2px;
}
.upgrade-buttons button.upgrade-element img {
  width: 20px;
  height: 20px;
}

.add-die {
  display: block;
  margin: 12px auto;
  padding: 6px 12px;
  font-size: 1rem;
  background: #28a745;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.add-die:hover {
  background: #218838;
}

.die-color-white.die .face {
  background-color: #ffffff;
}

.die-color-yellow.die .face {
  background-color: #ffff99;
}

.die-color-green.die .face {
  background-color: #c7db2a;
}

.die-color-blue.die .face {
  background-color: #57a5f4;
}

.die-color-red.die .face {
  background-color: #ff9999;
}

.die-color-brown.die .face {
  background-color: #d9560d;
}

.die-color-black.die .face {
  background-color: #333;
  color: white;
}

.enemy {
  position: absolute;
  width: 64px;
  height: 89px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow: visible;
  z-index: 2;
}
.enemy.boss .sprite-wrapper {
  box-shadow: 0 0 40px red, inset 0 0 24px red;
  border-radius: 50%;
}
.enemy .sprite-wrapper {
  width: 59px;
  height: 69px;
  overflow: hidden;
  position: relative;
}
.enemy .sprite-wrapper .burning-effect {
  position: absolute;
  top: 0;
  left: 78%;
  transform: translateX(-50%);
  width: 78px;
  height: 131px;
  background-size: 50% 50%;
  background-repeat: no-repeat;
  pointer-events: none;
  z-index: 5;
  transform-origin: bottom center;
}
.enemy .enemy-sprite {
  position: absolute;
  top: 0;
  left: 0;
  width: 114px;
  height: 136px;
  background-image: url("images/spritegrid_dd.png");
  background-repeat: no-repeat;
  image-rendering: pixelated;
  transform: scale(0.5);
  transform-origin: top left;
  top: -7px;
}
.enemy .enemy-sprite.burning {
  animation: burn 1s infinite;
}
@keyframes burn {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}
.enemy .enemy-hp {
  margin-top: 4px;
  font-size: 1rem;
  font-weight: bold;
  color: black;
}

.upgrade-placeholder {
  height: 28px;
}

.element-icon {
  position: relative;
  top: -86px;
  left: -1px;
  width: 24px;
  height: 24px;
  z-index: 10;
  pointer-events: none;
  background-color: white;
  border-radius: 50%;
  padding: 3px;
}

#splashscreen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: #00070a;
  color: white;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 2rem;
  z-index: 9999;
  flex-direction: column;
  text-align: center;
}
#splashscreen img {
  width: 70%;
  max-width: 300px;
}
#splashscreen #splashscreen-text {
  width: 100%;
}
#splashscreen #splashscreen-text .level-buttons {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 20px;
  flex-direction: column;
  align-items: center;
}
#splashscreen #splashscreen-text .level-buttons button {
  padding: 10px 20px;
  font-size: 1.1rem;
  font-weight: bold;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  color: white;
  text-shadow: 1px 1px 2px #000;
  transition: transform 0.1s ease;
  width: 60%;
  max-width: 300px;
}
#splashscreen #splashscreen-text .level-buttons button:hover {
  transform: scale(1.05);
}
#splashscreen #splashscreen-text .level-buttons button.dev {
  background-color: #1fa841;
}
#splashscreen #splashscreen-text .level-buttons button.easy {
  background-color: #ffffff;
}
#splashscreen #splashscreen-text .level-buttons button.normal {
  background-color: #ffff99;
}
#splashscreen #splashscreen-text .level-buttons button.hard {
  background-color: #ff9999;
}
#splashscreen #splashscreen-text .level-buttons button.insane {
  background-color: #000;
  border: 1px solid white;
}

#info {
  position: fixed;
  top: 0;
  left: 0;
  background-color: rgba(208, 208, 208, 0.5098039216);
  width: 192px;
  padding: 10px 10px;
  color: black;
  z-index: 200;
}
.restart-btn, #next-wave-button {
  display: block;
  margin: 4px auto;
  padding: 4px 20px;
  font-size: 25px;
  background: #007bff;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
}

.splash-circle {
  position: absolute;
  border-radius: 50%;
  background-color: rgba(0, 150, 255, 0.2);
  border: 2px solid rgba(0, 150, 255, 0.5);
  pointer-events: none;
  z-index: 1;
}

.earth-stone {
  position: absolute;
  width: 60px;
  height: 30px;
  background-size: contain;
  background-repeat: no-repeat;
  pointer-events: none;
  z-index: 1;
}
.earth-stone img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#next-wave-container {
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: none;
  z-index: 10;
}
#next-wave-container button {
  padding: 12px 24px;
  font-size: 18px;
  font-weight: bold;
  background-color: #ffd700;
  border: 2px solid #333;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}
#next-wave-container button:hover {
  background-color: #ffcc00;
}
