* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Helvetica Neue", Arial, sans-serif;
  font-weight: bold;
  background: #faf8ef;
  color: #776e65;
  font-size: 18px;
  margin: 0;
  padding: 0;
}

.container {
  width: 500px;
  margin: 0 auto;
  padding: 10px;
}

h1 {
  font-size: 36px;
  font-weight: 900;
  color: #13141c;
  text-align: center;
  margin: 0 0 15px 0;
}

.score-container {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 5px;
}

.score-box {
  display: inline-block;
  position: relative;
  background: #a78d74;
  padding: 10px 20px;
  border-radius: 3px;
  color: white;
  text-align: center;
  min-width: 80px;
  margin-right: 10px;
}

.score-box:last-of-type {
  margin-right: 0;
}

.score-label {
  font-size: 13px;
  line-height: 13px;
  text-transform: uppercase;
  margin-bottom: 5px;
}

.score {
  font-size: 25px;
  font-weight: bold;
  line-height: 25px;
}

.restart-button,
.keep-playing-button,
.retry-button {
  margin-bottom: 0;
  display: inline-block;
  background: #a78d74;
  border-radius: 3px;
  padding: 10px 20px;
  color: white;
  font-weight: bold;
  text-decoration: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  min-width: 80px;
  height: 56px;
  box-sizing: border-box;
  transition: all 0.3s ease-in-out;
}

.restart-button:hover,
.keep-playing-button:hover,
.retry-button:hover {
  background: #9f8a76;
}

.game-container {
  position: relative;
  padding: 15px;
  cursor: default;
  -webkit-touch-callout: none;
  -ms-touch-callout: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
  background: #bbada0;
  border-radius: 10px;
  width: 500px;
  height: 500px;
  margin: 0 auto;
  touch-action: none;
  -webkit-overflow-scrolling: touch;
}

.grid-container {
  position: absolute;
  z-index: 1;
}

.grid-row {
  margin-bottom: 15px;
}

.grid-row:last-child {
  margin-bottom: 0;
}

.grid-cell {
  width: 106.25px;
  height: 106.25px;
  background: rgba(238, 228, 218, 0.35);
  border-radius: 3px;
  margin-right: 15px;
  margin-bottom: 15px;
  float: left;
}

.grid-cell:last-child {
  margin-right: 0;
}

.grid-row:last-child .grid-cell {
  margin-bottom: 0;
}

.tile-container {
  position: absolute;
  z-index: 2;
}

.tile {
  width: 106.25px;
  height: 106.25px;
  border-radius: 3px;
  background: #eee4da;
  position: absolute;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 55px;
  font-weight: bold;
  z-index: 10;
  line-height: 1;
  transition: all 0.15s ease-in-out;
}

.tile-position-0-0 {
  left: 0px;
  top: 0px;
}

.tile-position-0-1 {
  left: 121.25px;
  top: 0px;
}

.tile-position-0-2 {
  left: 242.5px;
  top: 0px;
}

.tile-position-0-3 {
  left: 363.75px;
  top: 0px;
}

.tile-position-1-0 {
  left: 0px;
  top: 121.25px;
}

.tile-position-1-1 {
  left: 121.25px;
  top: 121.25px;
}

.tile-position-1-2 {
  left: 242.5px;
  top: 121.25px;
}

.tile-position-1-3 {
  left: 363.75px;
  top: 121.25px;
}

.tile-position-2-0 {
  left: 0px;
  top: 242.5px;
}

.tile-position-2-1 {
  left: 121.25px;
  top: 242.5px;
}

.tile-position-2-2 {
  left: 242.5px;
  top: 242.5px;
}

.tile-position-2-3 {
  left: 363.75px;
  top: 242.5px;
}

.tile-position-3-0 {
  left: 0px;
  top: 363.75px;
}

.tile-position-3-1 {
  left: 121.25px;
  top: 363.75px;
}

.tile-position-3-2 {
  left: 242.5px;
  top: 363.75px;
}

.tile-position-3-3 {
  left: 363.75px;
  top: 363.75px;
}

.tile-2 {
  background: #eee4da;
  color: #776e65;
}

.tile-4 {
  background: #ede0c8;
  color: #776e65;
}

.tile-8 {
  background: #f2b179;
  color: #f9f6f2;
}

.tile-16 {
  background: #f59563;
  color: #f9f6f2;
}

.tile-32 {
  background: #f67c5f;
  color: #f9f6f2;
}

.tile-64 {
  background: #f65e3b;
  color: #f9f6f2;
}

.tile-128 {
  background: #edcf72;
  color: #f9f6f2;
  font-size: 45px;
}

.tile-256 {
  background: #edcc61;
  color: #f9f6f2;
  font-size: 45px;
}

.tile-512 {
  background: #edc850;
  color: #f9f6f2;
  font-size: 45px;
}

.tile-1024 {
  background: #edc53f;
  color: #f9f6f2;
  font-size: 35px;
}

.tile-2048 {
  background: #edc22e;
  color: #f9f6f2;
  font-size: 35px;
}

.tile-super {
  background: #3c3a32;
  color: #f9f6f2;
  font-size: 30px;
}

.tile-new {
  animation: appear 200ms ease-in-out;
}

.tile-merged {
  animation: pop 200ms ease-in-out;
}

@keyframes appear {
  0% {
    opacity: 0;
    transform: scale(0);
  }

  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes pop {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.2);
  }

  100% {
    transform: scale(1);
  }
}

.game-message {
  display: none;
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: rgba(238, 228, 218, 0.73);
  color: #776e65;
  text-align: center;
  z-index: 100;
  border-radius: 10px;
}

.game-message p {
  font-size: 60px;
  font-weight: bold;
  height: 60px;
  line-height: 60px;
  margin-top: 150px;
}

.game-message .lower {
  display: block;
  margin-top: 30px;
}

.game-won {
  background: rgba(237, 194, 46, 0.5);
  color: #f9f6f2;
}

.game-won p {
  color: #f9f6f2;
}

.game-over {
  background: rgba(238, 228, 218, 0.73);
}

.game-over p {
  color: #776e65;
}

/* 响应式设计 */
@media screen and (max-width: 520px) {
  .container {
    width: 280px;
    margin: 0 auto;
    padding: 20px 0;
  }

  h1 {
    font-size: 40px;
    margin-bottom: 10px;
  }

  .score-box {
    min-width: 60px;
    padding: 8px 12px;
    margin-right: 8px;
  }

  .restart-button,
  .keep-playing-button,
  .retry-button {
    min-width: 60px;
    padding: 8px 12px;
    font-size: 14px;
  }

  .game-container {
    width: 280px;
    height: 280px;
    padding: 10px;
  }

  .grid-cell {
    width: 57.5px;
    height: 57.5px;
    margin-right: 10px;
    margin-bottom: 10px;
  }

  .grid-row:last-child .grid-cell {
    margin-bottom: 0;
  }

  .tile {
    width: 57.5px;
    height: 57.5px;
    font-size: 30px;
  }

  .tile-position-0-0 {
    left: 0px;
    top: 0px;
  }

  .tile-position-0-1 {
    left: 67.5px;
    top: 0px;
  }

  .tile-position-0-2 {
    left: 135px;
    top: 0px;
  }

  .tile-position-0-3 {
    left: 202.5px;
    top: 0px;
  }

  .tile-position-1-0 {
    left: 0px;
    top: 67.5px;
  }

  .tile-position-1-1 {
    left: 67.5px;
    top: 67.5px;
  }

  .tile-position-1-2 {
    left: 135px;
    top: 67.5px;
  }

  .tile-position-1-3 {
    left: 202.5px;
    top: 67.5px;
  }

  .tile-position-2-0 {
    left: 0px;
    top: 135px;
  }

  .tile-position-2-1 {
    left: 67.5px;
    top: 135px;
  }

  .tile-position-2-2 {
    left: 135px;
    top: 135px;
  }

  .tile-position-2-3 {
    left: 202.5px;
    top: 135px;
  }

  .tile-position-3-0 {
    left: 0px;
    top: 202.5px;
  }

  .tile-position-3-1 {
    left: 67.5px;
    top: 202.5px;
  }

  .tile-position-3-2 {
    left: 135px;
    top: 202.5px;
  }

  .tile-position-3-3 {
    left: 202.5px;
    top: 202.5px;
  }

  .tile-128,
  .tile-256,
  .tile-512 {
    font-size: 25px;
  }

  .tile-1024,
  .tile-2048 {
    font-size: 20px;
  }

  .tile-super {
    font-size: 18px;
  }

  .game-message p {
    font-size: 30px;
    margin-top: 80px;
  }
}