@import url("https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@1,800&display=swap");
*, *::before, *::after {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}

body {
  font-family: Arial, sans-serif;
  background-color: #fffaeb;
  color: #fff;
  min-height: 100vh;
  display: flex;
  justify-content: top;
  align-items: center;
  flex-direction: column;
}

.game {
  position: relative;
  width: 960px;
  height: 340px;
  overflow: hidden;
  background-image: linear-gradient(#5CADEC, #2783CA);
  box-shadow: 0 0 1em #fff1;
}

.score {
  position: absolute;
  top: 0.5em;
  left: 0.5em;
}

.msg {
  position: absolute;
  top: 2em;
  left: 50%;
  font-size: 1.2em;
  transform: translateX(-50%);
  text-align: center;
  transition: opacity 0.25s;
}
.msg.off {
  opacity: 0;
}

.player {
  position: absolute;
  top: var(--player-y, 320px);
  left: var(--player-x, 480px);
  transform: translate(-100%, -100%);
  width: 48px;
  height: 48px;
  background-size: contain;
}
.player.idle {
  background-image: url("https://assets.codepen.io/1948355/player-idle.gif");
}
.player.run {
  background-image: url("https://assets.codepen.io/1948355/player-run.gif");
}
.player.jump {
  background-image: url("https://assets.codepen.io/1948355/player-jump.gif");
}
.player.dead {
  background-image: url("https://assets.codepen.io/1948355/player-dead.gif");
}

.building {
  position: absolute;
  bottom: 20px;
  left: var(--building-x, 960px);
  border: solid #0007;
  border-width: 0 1px;
}
.building_fragment {
  position: absolute;
  width: 25%;
  height: 33.334%;
  background-image: url("https://lh6.googleusercontent.com/LugR-6tc25GHcKzd-kn8bqA46eRBeGgSoTet6t_zN0I52wn4uhDn7_vyiIL1eXsKNH4=w2400");
  background-size: 1600% 300%;
  filter: hue-rotate(var(--hue));
}
.building_fragment:nth-child(4n+1) {
  left: 0%;
  background-position-x: calc(var(--buildingImageX, 0%) + 0%);
}
.building_fragment:nth-child(4n+2) {
  left: 25%;
  background-position-x: calc(var(--buildingImageX, 0%) + 6.25%);
}
.building_fragment:nth-child(4n+3) {
  left: 50%;
  background-position-x: calc(var(--buildingImageX, 0%) + 12.5%);
}
.building_fragment:nth-child(4n+4) {
  left: 75%;
  background-position-x: calc(var(--buildingImageX, 0%) + 18.75%);
}
.building_fragment:nth-child(n+1):nth-child(-n+4) {
  top: 0%;
  background-position-y: 0%;
}
.building_fragment:nth-child(n+5):nth-child(-n+8) {
  top: 33.334%;
  background-position-y: 50%;
}
.building_fragment:nth-child(n+9):nth-child(-n+12) {
  top: 66.668%;
  background-position-y: 100%;
}
.building.destroy .building_fragment {
  z-index: 100;
  animation: destroy 1s ease-out forwards;
}
@keyframes destroy {
  to {
    transform: translateX(var(--tx)) translateY(var(--ty)) rotateX(var(--rx)) rotateY(var(--ry)) rotateZ(var(--rz));
    opacity: 0;
  }
}
.building.destroy::before {
  content: "";
  position: absolute;
  top: calc(50% - 5px);
  right: 90%;
  width: 320px;
  height: 10px;
  border-radius: 5px;
  background-image: linear-gradient(#D10A00, #D10A00, #D10A00);
  animation: laserOff 0.5s ease-out forwards;
}
@keyframes laserOff {
  to {
    opacity: 0;
  }
}

.road {
  position: absolute;
  bottom: 0;
  width: calc(100% + 10px);
  height: 20px;
  background-image: linear-gradient(#555, #333);
}
.road::after {
  content: "";
  position: absolute;
  top: calc(50% - 1px);
  left: 0;
  width: 100%;
  height: 2px;
  background-image: repeating-linear-gradient(90deg, #aaa 0px 5px, #aaa0 5px 10px);
}