/* mobile gamepad CSS and JS copied from
https://github.com/chrismaltby/gb-studio/blob/v2beta/appData/js-emulator/index.html
(see LICENSE.gbstudio)
*/
body {
  position: absolute;
  display: flex;
  flex-direction: column;
  background-color: #eee;
  margin: 0;
  width: 100%;
  height: 100%;
  user-select: none;
  -webkit-user-select: none;
}

#game {
  display: flex;
  flex-direction: column;
  position: absolute;
  width: 100%;
  height: 100%;
  touch-action: none;
  text-align: center;
}

#load {
  position: absolute;
  top: 0;
  right: 0;
  color: white;
  opacity: 0.5;
}

canvas {
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  height: 100%;
}

#gp {
  display: none;
  position: fixed;
  bottom: 0px;
  height: 210px;
  width: 100%;
  touch-action: none;
  opacity: 0.8;
}

#gp_dpad {
  position: absolute;
  bottom: 20px;
  left: 0px;
  width: 184px;
  height: 184px;
}

#gp_dpad:before {
  content: "";
  display: block;
  width: 48px;
  height: 48px;
  background: #5c5c5c;
  background: radial-gradient(
    ellipse at center,
    #5c5c5c 0%,
    #555 59%,
    #5c5c5c 60%
  );
  position: absolute;
  left: 68px;
  top: 68px;
}

#gp_left {
  position: absolute;
  left: 20px;
  top: 68px;
  width: 48px;
  height: 48px;
  background: #666;
  background: radial-gradient(ellipse at center, #666 0%, #5c5c5c 80%);
  border-top-left-radius: 4px;
  border-bottom-left-radius: 4px;
}

#gp_right {
  position: absolute;
  left: 116px;
  top: 68px;
  width: 48px;
  height: 48px;
  background: #666;
  background: radial-gradient(ellipse at center, #666 0%, #5c5c5c 80%);
  border-top-right-radius: 4px;
  border-bottom-right-radius: 4px;
}

#gp_up {
  position: absolute;
  left: 68px;
  top: 20px;
  width: 48px;
  height: 48px;
  background: #666;
  background: radial-gradient(ellipse at center, #666 0%, #5c5c5c 80%);
  border-top-left-radius: 4px;
  border-top-right-radius: 4px;
}

#gp_down {
  position: absolute;
  left: 68px;
  top: 116px;
  width: 48px;
  height: 48px;
  background: #666;
  background: radial-gradient(ellipse at center, #666 0%, #5c5c5c 80%);
  border-bottom-left-radius: 4px;
  border-bottom-right-radius: 4px;
}

#gp_a {
  position: absolute;
  bottom: 110px;
  right: 20px;
}

#gp_b {
  position: absolute;
  bottom: 80px;
  right: 100px;
}

.roundBtn {
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: bold;
  font-size: 32px;
  color: #440f1f;
  line-height: 64px;
  width: 64px;
  height: 64px;
  border-radius: 64px;
  background: #870a4c;
  background: radial-gradient(ellipse at center, #ab1465 0%, #8b1e57 100%);
  box-shadow: 0px 4px 5px rgba(0, 0, 0, 0.2);
}

.capsuleBtn {
  font-weight: bold;
  font-size: 10px;
  color: #111;
  display: flex;
  justify-content: center;
  align-items: center;
  line-height: 40px;
  text-transform: uppercase;
  width: 64px;
  height: 32px;
  border-radius: 40px;
  background: #222;
  background: radial-gradient(ellipse at center, #666 0%, #555 100%);
  box-shadow: 0px 4px 5px rgba(0, 0, 0, 0.2);
}

#gp_start {
  position: absolute;
  bottom: 20px;
  right: 15px;
}

#gp_select {
  position: absolute;
  bottom: 20px;
  right: 100px;
}

.btnPressed {
  opacity: 0.5;
}

@media only screen and (max-width: 640px) {
  #game canvas {
    margin-top: 0px;
    width: 100%;
    max-width: 480px;
    border: 0px;
    border-radius: 0px;
  }
}

@media only screen and (max-device-width: 812px) and (orientation: portrait) {
  body {
    margin: 0;
  }

  #game {
    width: 100%;
    position: fixed;
    touch-action: none;
  }

  #game canvas {
    margin: 0;
    display: block;
    width: 100% !important;
    height: auto !important;
  }
}

@media only screen and (max-device-width: 320px) and (orientation: portrait) {
  #gp_dpad {
    left: -5px;
    bottom: -5px;
  }

  #gp_a {
    right: 5px;
    bottom: 95px;
  }

  #gp_b {
    right: 80px;
  }

  #gp_start {
    right: 5px;
  }

  #gp_select {
    right: 80px;
  }
}

@media only screen and (max-width: 500px) and (max-height: 400px) {
  #gp {
    display: none;
  }
}

/* Small devices in landscape */
@media only screen and (max-device-width: 300px) and (orientation: landscape) {
  html,
  body {
    height: 100%;
  }
  body {
    display: flex;
    justify-content: center;
    align-items: center;
  }

  #game:after {
    content: "PLEASE ROTATE ↻";
    font-size: 24px;
    font-weight: bold;
    color: #fff;
  }

  #game canvas {
    display: none;
    max-width: 480px;
  }

  #gp {
    display: none;
  }
}

/* Devices large enough for landscape */
@media only screen and (min-width: 300px) and (orientation: landscape) {
  #gp {
    bottom: 50%;
    transform: translateY(50%);
    opacity: 0.5;
  }
}
