*,
*:before,
*:after {
  box-sizing: border-box;
}

button:hover,
a:hover {
  cursor: pointer;
}

.clearfix::after {
  content: "";
  display: block;
  clear: both;
}

html {
  min-height: 100%;
  width: 100%;
  font-size: 16px;
  font-family: "Gabarito", sans-serif;
  line-height: 1.5em;
  color: #eeeeee;
  background: #222831;
}

.wrapper {
  max-width: 500px;
  margin: 0 auto;
  padding: 15px;
}

h2 {
  font-style: italic;
}

/* Introduction */
.intro {
  margin-bottom: 60px;
}
.intro_title {
  text-align: center;
  color: #fd7014;
  font-size: 3rem;
}

/* Guide instructions */
.guide {
  border-bottom: 1px solid #393e46;
}
.guide:first-of-type {
  margin-top: 4rem;
  border-top: 1px solid #393e46;
}
.guide_arrow {
  display: inline-block;
  margin: 15px;
  font-size: 3rem;
  color: #eeeeee;
}

.controls_game, .controls_score {
  display: inline-block;
  width: 50%;
  float: left;
}
@media all and (max-width: 767px) {
  .controls_game, .controls_score {
    width: 100%;
  }
}
.controls_game-btn {
  margin-bottom: 1rem;
  padding: 0.5em 0.75em;
  background: transparent;
  color: #fd7014;
  border: 2px solid #fd7014;
  appearance: none;
  border-radius: 5px;
  letter-spacing: 0.1em;
  font-weight: bold;
  text-transform: lowercase;
  transition: background-color 0.3s ease, color 0.3s ease;
}
.controls_game-btn:hover {
  background-color: #fd7014;
  color: #ffffff;
}
.controls_score {
  display: inline-block;
  min-width: 4em;
  margin-bottom: 4rem;
  padding: 0.5em 0.75em;
  background: #393e46;
  border-radius: 5px;
  text-align: center;
}
.controls_score-label, .controls_score-text {
  display: inline-block;
}
.controls_score-label {
  color: #eeeeee;
}
.controls_score-text {
  color: #fd7014;
  font-size: 2rem;
}

/* Gameboard */
.gameboard {
  position: relative;
  width: 100%;
  max-width: 500px;
  height: 100%;
  max-height: 500px;
  margin: auto;
  padding: 8px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 5px;
  box-shadow: 0 0 8px 0px #fd7014;
}
.gameboard::before {
  content: "";
  display: block;
  padding-bottom: 100%;
}

/* Grid and Tiles */
.grid_cell, .tile {
  display: inline-block;
  height: 25%;
  width: 25%;
  padding: 8px;
  float: left;
  background: rgba(238, 238, 238, 0.15);
  background-clip: content-box;
}

.tile-container {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  margin: auto;
  border-radius: 5px;
}

.tile {
  display: table;
  background-clip: content-box;
  position: absolute;
  z-index: 2;
  will-change: top, left;
  transition-property: top, left;
  transition-duration: 0.175s;
  transition-timing-function: ease-out;
}
.tile.initialize {
  animation-name: newTile;
  animation-duration: 0.175s;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}
@keyframes newTile {
  0% {
    opacity: 0;
  }
  50% {
    opacity: 0;
    transform: scale(0);
  }
  75% {
    opacity: 1;
    transform: scale(0.5);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}
.tile_number {
  display: table-cell;
  vertical-align: middle;
  text-align: center;
  font-size: 2rem;
  font-weight: bold;
  color: white;
}

.tile:nth-of-type(1) { z-index: 2; }
.tile:nth-of-type(2) { z-index: 3; }
.tile:nth-of-type(3) { z-index: 4; }
.tile:nth-of-type(4) { z-index: 5; }
.tile:nth-of-type(5) { z-index: 6; }
.tile:nth-of-type(6) { z-index: 7; }
.tile:nth-of-type(7) { z-index: 8; }
.tile:nth-of-type(8) { z-index: 9; }
.tile:nth-of-type(9) { z-index: 10; }
.tile:nth-of-type(10) { z-index: 11; }
.tile:nth-of-type(11) { z-index: 12; }
.tile:nth-of-type(12) { z-index: 13; }
.tile:nth-of-type(13) { z-index: 14; }
.tile:nth-of-type(14) { z-index: 15; }
.tile:nth-of-type(15) { z-index: 16; }
.tile:nth-of-type(16) { z-index: 17; }

.tile[data-x="0"][data-y="0"] { top: 0%; left: 0%; }
.tile[data-x="0"][data-y="25"] { top: 25%; left: 0%; }
.tile[data-x="0"][data-y="50"] { top: 50%; left: 0%; }
.tile[data-x="0"][data-y="75"] { top: 75%; left: 0%; }
.tile[data-x="25"][data-y="0"] { top: 0%; left: 25%; }
.tile[data-x="25"][data-y="25"] { top: 25%; left: 25%; }
.tile[data-x="25"][data-y="50"] { top: 50%; left: 25%; }
.tile[data-x="25"][data-y="75"] { top: 75%; left: 25%; }
.tile[data-x="50"][data-y="0"] { top: 0%; left: 50%; }
.tile[data-x="50"][data-y="25"] { top: 25%; left: 50%; }
.tile[data-x="50"][data-y="50"] { top: 50%; left: 50%; }
.tile[data-x="50"][data-y="75"] { top: 75%; left: 50%; }
.tile[data-x="75"][data-y="0"] { top: 0%; left: 75%; }
.tile[data-x="75"][data-y="25"] { top: 25%; left: 75%; }
.tile[data-x="75"][data-y="50"] { top: 50%; left: 75%; }
.tile[data-x="75"][data-y="75"] { top: 75%; left: 75%; }

.tile_number[data-value="2"] { background: #4a515c; color: #fff; box-shadow: 0 0 2px 2px #31353a; }
.tile_number[data-value="4"] { background: #5a626d; color: #fff; box-shadow: 0 0 2px 2px #41474e; }
.tile_number[data-value="8"] { background: #ff9650; color: #fff; box-shadow: 0 0 2px 2px #e67c2e; }
.tile_number[data-value="16"] { background: #fd7014; color: #fff; box-shadow: 0 0 2px 2px #c9590f; }
.tile_number[data-value="32"] { background: #4a515c; color: #fff; box-shadow: 0 0 2px 2px #31353a; }
.tile_number[data-value="64"] { background: #5a626d; color: #fff; box-shadow: 0 0 2px 2px #41474e; }
.tile_number[data-value="128"] { background: #ff9650; color: #fff; box-shadow: 0 0 2px 2px #e67c2e; }
.tile_number[data-value="256"] { background: #fd7014; color: #fff; box-shadow: 0 0 2px 2px #c9590f; }
.tile_number[data-value="512"] { background: #4a515c; color: #fff; box-shadow: 0 0 2px 2px #31353a; }
.tile_number[data-value="1024"] { background: #5a626d; color: #fff; box-shadow: 0 0 2px 2px #41474e; }
.tile_number[data-value="2048"] { background: #ff9650; color: #fff; box-shadow: 0 0 2px 2px #e67c2e; }
.tile_number[data-value="4096"] { background: #fd7014; color: #fff; box-shadow: 0 0 2px 2px #c9590f; }