body {
  background: #222;
  font-family: "Press Start 2P", monospace;
  font-smooth: never;
  height: 98vh;
  margin: 0;
}

/* UI */
.topUI {
  position: absolute;
  z-index: 1000; /* need this cause clip-path changes stack context */
  transform: translate(-50%, 25px);
  text-shadow: -2px 0 black, 0 2px black, 2px 0 black, 0 -2px black;
  letter-spacing: 2px;
  color: #fff;
  font-size: 17px;
}
.topUI::before {
  display: inline-block;
  height: 17px;
  padding: 1px 2px;
  line-height: 19px;
  font-size: 17px;
  background: #fff;
  text-shadow: none;
  font-weight: 900;
  letter-spacing: 0;
  border-radius: 6px;
  margin-right: 30px;
  border: 2px solid #7dd8c9;
}
#time {
  left: 13%;
  color: #f4f430;
}
#time::before {
  content: "TIME";
  color: #f57214;
}
#score {
  left: 45%;
}

#score::before {
  content: "SCORE";
  color: #a61a9d;
}
#lap {
  left: 88%;
  width: 45%;
}
#lap::before {
  content: "LAP";
  color: #0082df;
}

#tacho {
  position: absolute;
  text-align: right;
  width: 23%;
  bottom: 5%;
  z-index: 2000;
  color: #e62e13;
  text-shadow: -2px 0 black, 0 2px black, 2px 0 black, 0 -2px black;
  letter-spacing: 2px;
  font-size: 23px;
}
#tacho::after {
  content: "km/h";
  color: #fab453;
  font-size: 18px;
  margin-left: 5px;
}

@media screen and (max-width: 480px) {
  #score {
    left: 30%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
  }

  #lap {
    left: 80%;
  }

  #time {
    display: none;
  }

  #tacho {
    left: 10px;
  }
}

/*
road
*/
#game {
  position: relative;
  margin: 0 auto;
  overflow: hidden;
  background: #222;
  user-select: none;
  transition: opacity 10s;
}

@media screen and (max-width: 920px) {
  #game {
    width: 100vw !important;
    aspect-ratio: 12/7;
  }
}

#road {
  transition: opacity 1s;
  transition-timing-function: steps(1, end);
}

@media screen and (max-width: 920px) {
  #road {
    right: 20vw;
  }

  #cloud {
    left: 20vw;
  }
}

@media screen and (max-width: 768px) {
  #road {
    right: 35vw;
    top: 0;
  }

  #cloud {
    left: 35vw;
  }

  #controls,
  .controls-group {
    flex-wrap: wrap;
    row-gap: 1rem;
    column-gap: 1rem;
    margin-top: 1rem !important;
  }

  .controls-item {
    /* flex-direction: column; */
  }

  .controls-item-key {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    text-align: center;
    height: 30px;
    width: 30px;
  }

  .controls-item-text {
    display: none;
  }
}

@media screen and (max-width: 650px) {
  #road {
    right: 50vw;
  }

  #cloud {
    left: 50vw;
  }

  .controls-item {
  }

  .controls-item-key {
    height: 30px;
    width: 30px;
  }
}

@media screen and (max-width: 480px) {
  #road {
    right: 70vw;
  }

  #cloud {
    left: 70vw;
  }
}

@media screen and (max-width: 410px) {
  #road {
    right: 100vw;
  }

  #cloud {
    left: 100vw;
  }
}

#road * {
  position: absolute;
  image-rendering: pixelated;
}
#hero {
  background-repeat: no-repeat;
  background-position: -110px 0;
  z-index: 2000;
  transform: scale(1.4);
}
#cloud {
  background-size: auto 100%;
  width: 100%;
  height: 57%;
}

/*
home
*/
#road {
  position: absolute;
  width: 100%;
  height: 100%;
}

#home {
  position: absolute;
  color: #fff;
  width: 100%;
  height: 100%;
  z-index: 1000; /* need this cause clip-path changes stack context */
}

#highscore {
  position: absolute;
  width: 100%;
  height: 20%;
  bottom: 0;
  column-count: 3;
  column-fill: auto;
}

#highscore * {
  color: #9e95a8;
  margin: 0 0 6px 27px;
}

h1 {
  position: absolute;
  left: 50%;
  top: 25%;
  transform: translate(-50%, -50%);
  font-size: 3em;

  background: -webkit-linear-gradient(#25d8b1, #e2bbf0);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

@media screen and (max-width: 410px) {
  h1 {
    font-size: 2em;
  }
}

#text {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.2em;
  color: #d9bbf3;
  text-shadow: 0 0 black, 0 2px black, 2px 0 black, 0 0 black;
}

.blink {
  animation: blinker 2s steps(4, end) infinite;
}
@keyframes blinker {
  50% {
    opacity: 0;
  }
}

/*
Guide
*/
#controls {
  color: #868686;
  font-size: 13px;
  line-height: 13px;
  margin: 10px;
  text-align: center;
  display: flex;
  justify-content: center;
  align-items: center;
}

.controls-group {
  color: #868686;
  font-size: 13px;
  line-height: 13px;
  margin: 10px;
  text-align: center;
  display: flex;
  justify-content: center;
  align-items: center;
}

#controls > div > span {
  margin-left: 20px;
}
#controls > div > span > span {
  border: 2px solid #868686;
  border-radius: 5px;
  padding: 7px;
  margin-right: 10px;
  display: inline-block;
}
#controls > div > span:last-child > span:not([data-key="KeyM"]) {
  transform: rotate(90deg);
}

.controls-item {
  display: flex;
  align-items: center;
}

/* Cool hover and click effects for control keys */
.controls-item-key {
  transition: all 0.2s ease-in-out;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.controls-item-key::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.2),
    transparent
  );
  transition: left 0.5s ease-in-out;
}

.controls-item-key:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3), 0 0 0 2px #25d8b1,
    0 0 10px rgba(37, 216, 177, 0.5);
  border-color: #25d8b1;
  color: #25d8b1;
  text-shadow: 0 0 5px rgba(37, 216, 177, 0.8);
}

.controls-item-key:hover::before {
  left: 100%;
}

.controls-item-key:active {
  transform: translateY(0px) scale(0.95);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3), 0 0 0 1px #e2bbf0,
    0 0 5px rgba(226, 187, 240, 0.8);
  border-color: #e2bbf0;
  color: #e2bbf0;
  transition: all 0.1s ease-in-out;
}

.controls-item-key:active::before {
  left: 100%;
  transition: left 0.1s ease-in-out;
}

/* Keyboard press effect - same as active state */
.controls-item-key.key-pressed {
  transform: translateY(0px) scale(0.95);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3), 0 0 0 1px #e2bbf0,
    0 0 5px rgba(226, 187, 240, 0.8);
  border-color: #e2bbf0;
  color: #e2bbf0;
  transition: all 0.1s ease-in-out;
}

.controls-item-key.key-pressed::before {
  left: 100%;
  transition: left 0.1s ease-in-out;
}
