@import url("https://fonts.googleapis.com/css2?family=Titan+One&display=swap");
html {
  font-size: 3vh;
}
@media (orientation: portrait) {
  html {
    font-size: 2.9vw;
  }
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  margin: 0;
  color: #fff;
  background: radial-gradient(#419197, #419197 60%, #fff 300%);
  overflow: hidden;
  font-family: "Titan One", sans-serif;
  font-weight: 700;
  font-size: 1.5rem;
}

.game {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  width: 29.03rem;
  transition: transform 0.5s ease;
  border: 1px solid #419197;
  overflow: hidden;
  perspective: 20rem;
  transform-style: preserve-3d;
  transform-origin: center center 0;
  border-radius: 0.5rem;
  background-color: #78d6c6;
}
.game:before, .game:after {
  content: "";
  display: flex;
  position: absolute;
  z-index: -1;
  top: 0;
  width: var(--cell);
  height: 100%;
  background: red;
  transform-style: preserve-3d;
  transform-origin: center center 0;
  background-color: rgba(65, 145, 151, 0.5);
  outline: 1px solid #fff;
}
.game:before {
  left: 0;
  transform: translateZ(calc(-0.5 * var(--cell))) translateX(calc(-0.5 * var(--cell))) rotate3d(0, 1, 0, 90deg);
}
.game:after {
  right: 0;
  transform: translateZ(calc(-0.5 * var(--cell))) translateX(calc(0.5 * var(--cell))) rotate3d(0, 1, 0, 90deg);
}
.game__player {
  position: absolute;
  z-index: 999;
  width: calc(var(--cell) * 0.8);
  height: calc(var(--cell) * 0.8);
  top: calc((var(--positionTop) + 0.1) * var(--cell));
  left: calc((var(--positionLeft) + 0.1) * var(--cell));
  transition-property: top, left, transform;
  transition-duration: 0.2s;
  transition-timing-function: ease;
  transform: var(--rotation) translateZ(0);
}
.game__player-eye {
  transform-origin: 50% 20%;
  animation: blink;
  animation-duration: 2s;
  animation-iteration-count: infinite;
}
@keyframes blink {
  0%, 40%, 60%, 100% {
    transform: scaleY(1);
  }
  50% {
    transform: scaleY(0.2);
  }
}
@media (max-width: 767px) {
  .game__player {
    transition-duration: 0.1s;
  }
}
.game__cell {
  position: relative;
  z-index: -1;
  width: var(--cell);
  height: var(--cell);
  background: linear-gradient(135deg, #78d6c6, #fff 200%);
  outline: 1px solid #fff;
  transform: translateZ(calc(-1 * var(--cell)));
}
.game__cell--rock {
  position: relative;
  transform: translateZ(0);
  transform-style: preserve-3d;
  transform-origin: center center 0;
  background: none;
  outline: none;
}
.game__cell--rock-face {
  position: absolute;
  display: flex;
  background: linear-gradient(135deg, #919ea3, #fff 200%);
  border-radius: 0.1rem;
  outline: 1px solid #919ea3;
}
.game__cell--rock-lava .game__cell--rock-face {
  background: linear-gradient(45deg, orange, #ff7d66 200%);
  background-size: 100% 200%;
  animation: lava;
  animation-duration: 2s;
  animation-iteration-count: infinite;
  outline: 1px solid #ff7d66;
}
@keyframes lava {
  0%, 100% {
    background-position: 0 0;
  }
  50% {
    background-position: 0 100%;
  }
}
.game__cell--rock-front {
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}
.game__cell--rock-top, .game__cell--rock-bottom, .game__cell--rock-left, .game__cell--rock-right {
  width: 100%;
  height: var(--cell);
}
.game__cell--rock-top {
  top: 0;
  left: 0;
  transform: translateZ(calc(-0.5 * var(--cell))) translateY(calc(-0.5 * var(--cell))) rotate3d(1, 0, 0, 90deg);
}
.game__cell--rock-bottom {
  bottom: 0;
  left: 0;
  transform: translateZ(calc(-0.5 * var(--cell))) translateY(calc(0.5 * var(--cell))) rotate3d(1, 0, 0, 90deg);
}
.game__cell--rock-left {
  top: 0;
  left: 0;
  transform: translateZ(calc(-0.5 * var(--cell))) translateY(calc(-0.5 * var(--cell))) translateX(calc(var(--cell) / -2)) rotate3d(1, 0, 0, 90deg) rotate3d(0, 1, 0, 90deg) translateX(calc(var(--cell) / 2));
}
.game__cell--rock-right {
  top: 0;
  left: 0;
  transform: translateZ(calc(-0.5 * var(--cell))) translateY(calc(-0.5 * var(--cell))) translateX(calc(var(--cell) / -2)) rotate3d(1, 0, 0, 90deg) rotate3d(0, 1, 0, 90deg) translateX(calc(var(--cell) / 2)) translateZ(var(--cell));
}
.game__cell--horizontal {
  z-index: 0;
  transform: translateZ(calc(var(--cell) * -0.8));
  background: linear-gradient(135deg, #78d6c6, #eb80b1 200%);
}
.game__cell--horizontal:before, .game__cell--horizontal:after {
  content: "";
  position: absolute;
  width: 0;
  height: 0;
  border-top: calc(var(--cell) / 4) solid transparent;
  border-bottom: calc(var(--cell) / 4) solid transparent;
}
.game__cell--horizontal:before {
  bottom: calc(var(--cell) / 6);
  left: calc(var(--cell) / 6);
  border-left: calc(var(--cell) / 3) solid #fff;
}
.game__cell--horizontal:after {
  top: calc(var(--cell) / 6);
  right: calc(var(--cell) / 6);
  border-right: calc(var(--cell) / 3) solid #fff;
}
.game__cell--vertical {
  z-index: 0;
  transform: translateZ(calc(var(--cell) * -0.8));
  background: linear-gradient(135deg, #78d6c6, orange 200%);
}
.game__cell--vertical:before, .game__cell--vertical:after {
  content: "";
  position: absolute;
  width: 0;
  height: 0;
  border-left: calc(var(--cell) / 4) solid transparent;
  border-right: calc(var(--cell) / 4) solid transparent;
}
.game__cell--vertical:before {
  bottom: calc(var(--cell) / 6);
  left: calc(var(--cell) / 6);
  border-bottom: calc(var(--cell) / 3) solid #fff;
}
.game__cell--vertical:after {
  top: calc(var(--cell) / 6);
  right: calc(var(--cell) / 6);
  border-top: calc(var(--cell) / 3) solid #fff;
}
.game__cell--end {
  background-color: #fff;
  background-image: linear-gradient(45deg, #000038 25%, transparent 25%, transparent 74%, #000038 75%, #000038), linear-gradient(45deg, #000038 25%, transparent 25%, transparent 74%, #000038 75%, #000038);
  background-size: calc(var(--cell) / 2) calc(var(--cell) / 2);
  background-position: 0 0, calc(var(--cell) / 4) calc(var(--cell) / 4);
}
.game__wrapper {
  position: relative;
}
.game__water {
  position: absolute;
  transition-property: width, height;
  transition-duration: 0.2s;
  transition-timing-function: ease;
  transform-style: preserve-3d;
}
.game__water--0, .game__water--2 {
  width: 100%;
  height: calc(var(--depth) * var(--cell));
}
.game__water--1, .game__water--3 {
  height: 100%;
  width: calc(var(--depth) * var(--cell));
}
.game__water--0, .game__water--3 {
  bottom: 0;
  left: 0;
}
.game__water--1 {
  bottom: 0;
  right: 0;
}
.game__water--2 {
  top: 0;
  left: 0;
}
.game__water--front {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  background-color: rgba(65, 145, 151, 0.6);
  transform: translateZ(0);
}
.game__water--top, .game__water--left, .game__water--right, .game__water--bottom {
  position: absolute;
  display: flex;
  background: linear-gradient(45deg, rgba(65, 145, 151, 0.5), #fff 200%);
}
.game__water--top, .game__water--bottom {
  width: 100%;
  height: var(--cell);
  transform-origin: center 0 0;
}
.game__water--left, .game__water--right {
  width: var(--cell);
  height: 100%;
  transform-origin: center center 0;
}
.game__water--top {
  top: 0;
  left: 0;
  transform: translateZ(calc(-1 * var(--cell))) rotate3d(1, 0, 0, 90deg);
}
.game__water--left {
  top: 0;
  left: 0;
  transform: translateZ(calc(-0.5 * var(--cell))) translateX(calc(-0.5 * var(--cell))) rotate3d(0, 1, 0, 90deg);
}
.game__water--right {
  top: 0;
  right: 0;
  transform: translateZ(calc(-0.5 * var(--cell))) translateX(calc(0.5 * var(--cell))) rotate3d(0, 1, 0, 90deg);
}
.game__water--bottom {
  bottom: 0;
  left: 0;
  transform: translateZ(calc(-1 * var(--cell))) translateY(calc(var(--cell))) rotate3d(1, 0, 0, 90deg);
}

.title {
  position: absolute;
  top: 1rem;
  left: 1rem;
  color: #fff07f;
}

.level-text {
  position: absolute;
  top: 1rem;
  right: 1rem;
}
.level-text:before {
  content: "by PEDRO ONDIVIELA";
  position: absolute;
  right: 0;
  bottom: calc(4rem - 100vh);
  font-size: 0.5rem;
  text-align: right;
}

.water-level {
  position: absolute;
  top: calc(50vh - var(--height) * var(--cell) * 0.5);
  right: calc(50vw - var(--width) * var(--cell) * 0.5 - 0.15rem);
  display: flex;
  width: 0.3rem;
  height: calc(var(--height) * var(--cell));
  background: linear-gradient(#78d6c6 50%, transparent 50%);
  background-size: 100% 200%;
  background-position: 0 calc(100% + (var(--depth) / var(--height) * 100%));
  transition: all 0.2s ease;
}
.water-level:before, .water-level:after {
  content: "";
  position: absolute;
  left: -0.15rem;
  width: 5rem;
  color: #fff;
  font-size: 1rem;
}
.water-level:before {
  content: "min -";
  top: calc(100% - (var(--min-depth) / var(--height) * 100%) - 0.7rem);
  left: -2.35rem;
}
.water-level:after {
  content: "- max";
  top: calc(100% - (var(--max-depth) / var(--height) * 100%) - 0.7rem);
}
.water-level--hidden {
  display: none;
}

.over-text {
  position: absolute;
  top: 0;
  left: 0;
  display: none;
  justify-content: center;
  align-items: center;
  width: 100vw;
  height: 100vh;
  color: #fff;
  background-color: rgba(65, 145, 151, 0.5);
  text-align: center;
  text-transform: uppercase;
}
.over-text--display {
  display: flex;
}
.over-text--lose {
  color: #000038;
  background-color: rgba(255, 125, 102, 0.5);
}
.over-text--win {
  display: flex;
  flex-direction: column;
  font-size: 10vw;
  color: #12486b;
  background-color: rgba(245, 252, 205, 0.5);
}
.over-text--win .over-text__timer {
  font-size: 5vw;
}
.over-text--tutorial {
  color: #12486b;
  background: rgba(255, 255, 255, 0.3);
  top: unset;
  bottom: 0;
  height: 4rem;
  pointer-events: none;
}

.controls {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  flex-wrap: wrap;
  width: 100%;
  height: 100%;
}
.controls__arrow {
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.controls__arrow:after {
  content: "";
  width: 0;
  height: 0;
  margin: 1rem;
  opacity: 0.3;
}
.controls__arrow--top, .controls__arrow--bottom {
  width: 100%;
  height: 40vh;
}
.controls__arrow--left, .controls__arrow--right {
  flex-direction: column;
  width: 50%;
  height: 20vh;
}
.controls__arrow--top, .controls__arrow--left {
  align-items: flex-start;
}
.controls__arrow--bottom, .controls__arrow--right {
  align-items: flex-end;
}
.controls__arrow--top:after {
  border-left: 1rem solid transparent;
  border-right: 1rem solid transparent;
  border-bottom: 1rem solid #fff;
}
.controls__arrow--left:after {
  border-left: 1rem solid transparent;
  border-right: 1rem solid transparent;
  border-top: 1rem solid #fff;
  transform: rotate(45deg);
}
.controls__arrow--right:after {
  border-left: 1rem solid transparent;
  border-right: 1rem solid transparent;
  border-top: 1rem solid #fff;
  transform: rotate(-45deg);
}
.controls__arrow--bottom:after {
  border-left: 1rem solid transparent;
  border-right: 1rem solid transparent;
  border-top: 1rem solid #fff;
}

.intro {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  padding: 1rem;
  color: #fff07f;
  background-color: #419197;
  cursor: pointer;
}
.intro__title {
  font-size: 4rem;
}
.intro__subtitle {
  color: #f5fccd;
}
.intro__explanation {
  position: absolute;
  bottom: 3rem;
  left: 1rem;
  width: calc(100vw - 2rem);
  font-size: 1.5rem;
  text-align: right;
  color: #fff;
}
.intro__player {
  position: absolute;
  top: 10rem;
  right: 0;
  width: 40vw;
  height: 40vh;
  transform: rotate(10deg);
}
.intro__button {
  position: absolute;
  bottom: 30vh;
  left: 40vw;
  display: inline-flex;
  justify-content: center;
  width: 20vw;
  padding: 0.5rem 1rem;
  border-radius: 2rem;
  color: #12486b;
  background: #fff07f;
  outline: 2px solid #12486b;
  transition: transform 0.2s ease;
}
.intro__button:hover {
  transform: scale(1.2);
}
.intro__earth {
  position: absolute;
  top: 30vh;
  left: 15vw;
  width: 70vw;
  height: 70vw;
  border-radius: 50%;
  background-color: #12486b;
  transform: rotate(10deg);
  overflow: hidden;
}
@media (max-width: 767px) {
  .intro__earth {
    width: 120vw;
    height: 120vw;
    left: -10vw;
  }
}
.intro__earth:before {
  content: "";
  display: block;
  width: 100%;
  height: 100%;
  background: url("https://www.pedro-ondiviela.com/assets/map.svg");
  background-size: cover;
  transition: background-position 0.5s ease;
  animation: globeSpinning;
  animation-duration: 300s;
  animation-iteration-count: infinite;
  animation-timing-function: linear;
}
@keyframes globeSpinning {
  0% {
    background-position: 0 0;
  }
  100% {
    background-position: 288% 0;
  }
}
.intro--hidden {
  display: none;
}

.fullscreen {
  position: absolute;
  top: 1.2rem;
  right: 7rem;
  cursor: pointer;
}

.refresh {
  position: absolute;
  top: 1rem;
  right: 4rem;
  cursor: pointer;
}

.level-selector {
  position: absolute;
  top: 0;
  left: 0;
  width: 80vw;
  height: 100vh;
  padding: 0 10vw;
  color: #fff;
  background-color: rgba(65, 145, 151, 0.5);
  font-size: 2rem;
  display: none;
}
@media (min-height: 600px) {
  .level-selector {
    font-size: 1.5rem;
  }
}
.level-selector--active {
  display: flex;
  justify-content: center;
  align-items: center;
  align-content: center;
  flex-wrap: wrap;
}
.level-selector__button {
  padding: 1rem;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: background-color 0.2s ease;
}
.level-selector__button:hover {
  background-color: rgba(0, 0, 56, 0.2);
}
.level-selector__button--current {
  background-color: #12486b;
}
.level-selector__button--disabled {
  opacity: 0.5;
  cursor: default;
  pointer-events: none;
}