@import url(fonts/clear-sans.css);

html,
body {
  margin: 0;
  padding: 0;
  background: #faf8ef;
  color: #776e65;
  font-family: "Clear Sans", "Helvetica Neue", Arial, sans-serif;
  font-size: 18px;
}

body {
  margin: 80px 0;
}

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

h1.title {
  font-size: 50px;
  font-weight: bold;
  margin: 0;
  display: block;
  float: left;
}

.heading {
  width: 500px;
  float: left;
  margin-bottom: 15px;
  position: relative;
}

@-webkit-keyframes move-up {
  0% {
    top: 25px;
    opacity: 1;
  }

  100% {
    top: -50px;
    opacity: 0;
  }
}

@-moz-keyframes move-up {
  0% {
    top: 25px;
    opacity: 1;
  }

  100% {
    top: -50px;
    opacity: 0;
  }
}

@keyframes move-up {
  0% {
    top: 25px;
    opacity: 1;
  }

  100% {
    top: -50px;
    opacity: 0;
  }
}

.scores-container {
  float: right;
  text-align: right;
}

.score-container,
.best-container {
  position: relative;
  display: inline-block;
  background: #bbada0;
  padding: 15px 25px;
  font-size: 25px;
  height: 25px;
  line-height: 47px;
  font-weight: bold;
  border-radius: 3px;
  color: white;
  margin-top: 8px;
  text-align: center;
}

.score-container:after,
.best-container:after {
  position: absolute;
  width: 100%;
  top: 10px;
  left: 0;
  text-transform: uppercase;
  font-size: 13px;
  line-height: 13px;
  text-align: center;
  color: #eee4da;
}

.score-container .score-addition,
.best-container .score-addition {
  position: absolute;
  right: 30px;
  color: red;
  font-size: 25px;
  line-height: 25px;
  font-weight: bold;
  color: rgba(119, 110, 101, 0.9);
  z-index: 100;
  -webkit-animation: move-up 600ms ease-in;
  -moz-animation: move-up 600ms ease-in;
  animation: move-up 600ms ease-in;
  -webkit-animation-fill-mode: both;
  -moz-animation-fill-mode: both;
  animation-fill-mode: both;
}

.score-container:after {
  content: "分数";
}

.best-container:after {
  content: "最佳";
}

/* New Timer Styles */
#timer {
  float: left;
  width: 185px;
  text-align: center;
  margin-left: 15px;
  margin-bottom: 5px;
  position: relative;
  display: inline-block;
  background: #bbada0;
  padding: 15px 25px;
  font-size: 25px;
  height: 25px;
  line-height: 47px;
  font-weight: bold;
  border-radius: 3px;
  color: white;
  margin-top: 8px;
}

#timer:after {
  content: "时间";
  position: absolute;
  width: 100%;
  top: 10px;
  left: 0;
  text-transform: uppercase;
  font-size: 13px;
  line-height: 13px;
  text-align: center;
  color: #eee4da;
}

#timerbox {
  float: right;
  width: 250px;
  text-align: center;
  margin-bottom: 45px;
}

#timerbox.timerbox-leaderboard-mode > :not(.timerbox-leaderboard-panel) {
  display: none !important;
}

.timerbox-leaderboard-panel {
  display: none;
  width: 250px;
  min-height: 520px;
}

#timerbox.timerbox-leaderboard-mode .timerbox-leaderboard-panel {
  display: block;
}

.timerbox-leaderboard-header {
  background: #bbada0;
  color: #f9f6f2;
  border-radius: 3px;
  margin-top: 8px;
  margin-left: 15px;
  width: 235px;
  padding: 10px 6px;
  box-sizing: border-box;
}

.timerbox-leaderboard-title {
  font-size: 32px;
  line-height: 1;
  font-weight: bold;
}

.timerbox-leaderboard-list {
  margin-top: 10px;
}

.timerbox-leaderboard-row {
  margin-left: 15px;
  width: 235px;
  display: flex;
  align-items: center;
  margin-bottom: 8px;
}

.timerbox-leaderboard-rank {
  width: 42px;
  height: 42px;
  line-height: 42px;
  border-radius: 3px;
  background: #000;
  color: #fff;
  font-weight: bold;
  font-size: 20px;
}

.timerbox-leaderboard-rank.timerbox-leaderboard-rank-top1 {
  background: #d9b300;
}

.timerbox-leaderboard-rank.timerbox-leaderboard-rank-top2 {
  background: #c9c4ac;
}

.timerbox-leaderboard-rank.timerbox-leaderboard-rank-top3 {
  background: #ba8a00;
}

.timerbox-leaderboard-entry {
  margin-left: 6px;
  width: 187px;
  height: 42px;
  line-height: 42px;
  background: #ddd6cc;
  color: #635c56;
  border-radius: 3px;
  font-weight: bold;
  font-size: 16px;
  text-align: left;
  padding: 0 10px;
  box-sizing: border-box;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.timerbox-leaderboard-row.is-self .timerbox-leaderboard-entry {
  color: #ff00ff;
}

.timerbox-leaderboard-empty {
  margin-left: 15px;
  width: 235px;
  padding: 12px 8px;
  box-sizing: border-box;
  border-radius: 3px;
  background: #ddd6cc;
  color: #635c56;
  font-size: 14px;
  text-align: center;
}

.timertile {
  box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0), inset 0 0 0 1px rgba(255, 255, 255, 0);
  border-radius: 3px;
  text-align: center;
  font-weight: bold;
  z-index: 10;
  width: 42px;
  height: 42px;
  line-height: 42px;
  color: #776e65;
  background: #eee4da;
  font-family: 'Clear Sans';
  float: left;
  margin-left: 15px;
  margin-top: 9px;
  font-size: 17px;
  /* Default size */
}

.above-game {
  width: 500px;
  float: left;
}

.above-game:after {
  content: "";
  display: block;
  clear: both;
}

.game-intro {
  float: left;
  line-height: 42px;
  margin-bottom: 0;
}

#play-mode-intro {
  max-width: 380px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
  font-size: 16px;
}

.restart-button {
  display: inline-block;
  background: #8f7a66;
  border-radius: 3px;
  padding: 0 20px;
  text-decoration: none;
  color: #f9f6f2;
  height: 40px;
  line-height: 42px;
  display: block;
  text-align: center;
  float: right;
}

.timer-container:after {
  position: absolute;
  width: 100%;
  top: 10px;
  left: 0;
  text-transform: uppercase;
  font-size: 13px;
  line-height: 13px;
  text-align: center;
  color: #eee4da;
  content: "时间";
}

p {
  margin-top: 0;
  margin-bottom: 10px;
  line-height: 1.65;
}

a {
  color: #776e65;
  font-weight: bold;
  text-decoration: underline;
  cursor: pointer;
}

strong.important {
  text-transform: uppercase;
}

hr {
  border: none;
  border-bottom: 1px solid #d8d4d0;
  margin-top: 20px;
  margin-bottom: 30px;
}

.container {
  width: 750px;
  margin: 0 auto;
}

@-webkit-keyframes fade-in {
  0% {
    opacity: 0;
  }

  100% {
    opacity: 1;
  }
}

@-moz-keyframes fade-in {
  0% {
    opacity: 0;
  }

  100% {
    opacity: 1;
  }
}

@keyframes fade-in {
  0% {
    opacity: 0;
  }

  100% {
    opacity: 1;
  }
}

.game-container {
  float: left;
  /* Added float */
  margin-top: 10px;
  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;
  -ms-touch-action: none;
  touch-action: none;
  background: #bbada0;
  border-radius: 6px;
  width: 500px;
  height: 500px;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}

.game-container.game-container-replay {
  margin-left: 114px;
}

.game-container .game-message {
  display: none;
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: rgba(238, 228, 218, 0.5);
  z-index: 100;
  text-align: center;
  -webkit-animation: fade-in 800ms ease 1200ms;
  -moz-animation: fade-in 800ms ease 1200ms;
  animation: fade-in 800ms ease 1200ms;
  -webkit-animation-fill-mode: both;
  -moz-animation-fill-mode: both;
  animation-fill-mode: both;
}

.game-container .game-message p {
  font-size: 60px;
  font-weight: bold;
  height: 60px;
  line-height: 60px;
  margin-top: 222px;
}

.game-container .game-message .lower {
  display: block;
  margin-top: 59px;
}

.game-container .game-message a {
  display: inline-block;
  background: #8f7a66;
  border-radius: 3px;
  padding: 0 20px;
  text-decoration: none;
  color: #f9f6f2;
  height: 40px;
  line-height: 42px;
  margin-left: 9px;
}

.game-container .game-message a.keep-playing-button {
  display: none;
}

.game-container .game-message.game-won {
  background: rgba(237, 194, 46, 0.5);
  color: #f9f6f2;
}

.game-container .game-message.game-won a.keep-playing-button {
  display: inline-block;
}

.game-container .game-message.game-won,
.game-container .game-message.game-over {
  display: block;
}

.grid-container {
  position: absolute;
  z-index: 1;
}

.grid-row {
  margin-bottom: 15px;
}

.grid-row:last-child {
  margin-bottom: 0;
}

.grid-row:after {
  content: "";
  display: block;
  clear: both;
}

.grid-cell {
  width: 106.25px;
  height: 106.25px;
  margin-right: 15px;
  float: left;
  border-radius: 3px;
  background: rgba(238, 228, 218, 0.35);
}

.grid-cell.grid-cell-obstacle {
  background: rgba(70, 64, 58, 0.55);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.08);
}

.grid-cell:last-child {
  margin-right: 0;
}

.tile-container {
  position: absolute;
  z-index: 2;
}

.tile,
.tile .tile-inner {
  width: 107px;
  height: 107px;
  line-height: 116.25px;
}

.tile.tile-position-1-1 {
  -webkit-transform: translate(0px, 0px);
  -moz-transform: translate(0px, 0px);
  transform: translate(0px, 0px);
}

.tile.tile-position-1-2 {
  -webkit-transform: translate(0px, 121px);
  -moz-transform: translate(0px, 121px);
  transform: translate(0px, 121px);
}

.tile.tile-position-1-3 {
  -webkit-transform: translate(0px, 242px);
  -moz-transform: translate(0px, 242px);
  transform: translate(0px, 242px);
}

.tile.tile-position-1-4 {
  -webkit-transform: translate(0px, 363px);
  -moz-transform: translate(0px, 363px);
  transform: translate(0px, 363px);
}

.tile.tile-position-2-1 {
  -webkit-transform: translate(121px, 0px);
  -moz-transform: translate(121px, 0px);
  transform: translate(121px, 0px);
}

.tile.tile-position-2-2 {
  -webkit-transform: translate(121px, 121px);
  -moz-transform: translate(121px, 121px);
  transform: translate(121px, 121px);
}

.tile.tile-position-2-3 {
  -webkit-transform: translate(121px, 242px);
  -moz-transform: translate(121px, 242px);
  transform: translate(121px, 242px);
}

.tile.tile-position-2-4 {
  -webkit-transform: translate(121px, 363px);
  -moz-transform: translate(121px, 363px);
  transform: translate(121px, 363px);
}

.tile.tile-position-3-1 {
  -webkit-transform: translate(242px, 0px);
  -moz-transform: translate(242px, 0px);
  transform: translate(242px, 0px);
}

.tile.tile-position-3-2 {
  -webkit-transform: translate(242px, 121px);
  -moz-transform: translate(242px, 121px);
  transform: translate(242px, 121px);
}

.tile.tile-position-3-3 {
  -webkit-transform: translate(242px, 242px);
  -moz-transform: translate(242px, 242px);
  transform: translate(242px, 242px);
}

.tile.tile-position-3-4 {
  -webkit-transform: translate(242px, 363px);
  -moz-transform: translate(242px, 363px);
  transform: translate(242px, 363px);
}

.tile.tile-position-4-1 {
  -webkit-transform: translate(363px, 0px);
  -moz-transform: translate(363px, 0px);
  transform: translate(363px, 0px);
}

.tile.tile-position-4-2 {
  -webkit-transform: translate(363px, 121px);
  -moz-transform: translate(363px, 121px);
  transform: translate(363px, 121px);
}

.tile.tile-position-4-3 {
  -webkit-transform: translate(363px, 242px);
  -moz-transform: translate(363px, 242px);
  transform: translate(363px, 242px);
}

.tile.tile-position-4-4 {
  -webkit-transform: translate(363px, 363px);
  -moz-transform: translate(363px, 363px);
  transform: translate(363px, 363px);
}

.tile {
  position: absolute;
  -webkit-transition: 100ms ease-in-out;
  -moz-transition: 100ms ease-in-out;
  transition: 100ms ease-in-out;
  -webkit-transition-property: -webkit-transform;
  -moz-transition-property: -moz-transform;
  transition-property: transform;
}

.tile .tile-inner {
  border-radius: 3px;
  background: #eee4da;
  text-align: center;
  font-weight: bold;
  z-index: 10;
  font-size: 55px;
}

.tile.tile-2 .tile-inner {
  background: #eee4da;
  box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0), inset 0 0 0 1px rgba(255, 255, 255, 0);
}

.tile.tile-4 .tile-inner {
  background: #ede0c8;
  box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0), inset 0 0 0 1px rgba(255, 255, 255, 0);
}

.tile.tile-8 .tile-inner {
  color: #f9f6f2;
  background: #f2b179;
}

.tile.tile-16 .tile-inner {
  color: #f9f6f2;
  background: #f59563;
}

.tile.tile-32 .tile-inner {
  color: #f9f6f2;
  background: #f67c5f;
}

.tile.tile-64 .tile-inner {
  color: #f9f6f2;
  background: #f65e3b;
}

.tile.tile-128 .tile-inner {
  color: #f9f6f2;
  background: #edcf72;
  box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.2381), inset 0 0 0 1px rgba(255, 255, 255, 0.14286);
  font-size: 45px;
}

@media screen and (max-width: 520px) {
  .tile.tile-128 .tile-inner {
    font-size: 25px;
  }
}

.tile.tile-256 .tile-inner {
  color: #f9f6f2;
  background: #edcc61;
  box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.31746), inset 0 0 0 1px rgba(255, 255, 255, 0.19048);
  font-size: 45px;
}

@media screen and (max-width: 520px) {
  .tile.tile-256 .tile-inner {
    font-size: 25px;
  }
}

.tile.tile-512 .tile-inner {
  color: #f9f6f2;
  background: #edc850;
  box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.39683), inset 0 0 0 1px rgba(255, 255, 255, 0.2381);
  font-size: 45px;
}

@media screen and (max-width: 520px) {
  .tile.tile-512 .tile-inner {
    font-size: 25px;
  }
}

.tile.tile-1024 .tile-inner {
  color: #f9f6f2;
  background: #edc53f;
  box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.47619), inset 0 0 0 1px rgba(255, 255, 255, 0.28571);
  font-size: 35px;
}

@media screen and (max-width: 520px) {
  .tile.tile-1024 .tile-inner {
    font-size: 15px;
  }
}

.tile.tile-2048 .tile-inner {
  color: #f9f6f2;
  background: #edc22e;
  box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.55556), inset 0 0 0 1px rgba(255, 255, 255, 0.33333);
  font-size: 35px;
}

@media screen and (max-width: 520px) {
  .tile.tile-2048 .tile-inner {
    font-size: 15px;
  }
}

.tile.tile-super .tile-inner {
  color: #f9f6f2;
  background: #3c3a32;
  font-size: 30px;
}

@media screen and (max-width: 520px) {
  .tile.tile-super .tile-inner {
    font-size: 10px;
  }
}

@-webkit-keyframes appear {
  0% {
    opacity: 0;
    -webkit-transform: scale(0);
    -moz-transform: scale(0);
    transform: scale(0);
  }

  100% {
    opacity: 1;
    -webkit-transform: scale(1);
    -moz-transform: scale(1);
    transform: scale(1);
  }
}

@-moz-keyframes appear {
  0% {
    opacity: 0;
    -webkit-transform: scale(0);
    -moz-transform: scale(0);
    transform: scale(0);
  }

  100% {
    opacity: 1;
    -webkit-transform: scale(1);
    -moz-transform: scale(1);
    transform: scale(1);
  }
}

@keyframes appear {
  0% {
    opacity: 0;
    -webkit-transform: scale(0);
    -moz-transform: scale(0);
    transform: scale(0);
  }

  100% {
    opacity: 1;
    -webkit-transform: scale(1);
    -moz-transform: scale(1);
    transform: scale(1);
  }
}

.tile-new .tile-inner {
  -webkit-animation: appear 200ms ease 100ms;
  -moz-animation: appear 200ms ease 100ms;
  animation: appear 200ms ease 100ms;
  -webkit-animation-fill-mode: backwards;
  -moz-animation-fill-mode: backwards;
  animation-fill-mode: backwards;
}

@-webkit-keyframes pop {
  0% {
    -webkit-transform: scale(0);
    -moz-transform: scale(0);
    transform: scale(0);
  }

  50% {
    -webkit-transform: scale(1.2);
    -moz-transform: scale(1.2);
    transform: scale(1.2);
  }

  100% {
    -webkit-transform: scale(1);
    -moz-transform: scale(1);
    transform: scale(1);
  }
}

@-moz-keyframes pop {
  0% {
    -webkit-transform: scale(0);
    -moz-transform: scale(0);
    transform: scale(0);
  }

  50% {
    -webkit-transform: scale(1.2);
    -moz-transform: scale(1.2);
    transform: scale(1.2);
  }

  100% {
    -webkit-transform: scale(1);
    -moz-transform: scale(1);
    transform: scale(1);
  }
}

@keyframes pop {
  0% {
    -webkit-transform: scale(0);
    -moz-transform: scale(0);
    transform: scale(0);
  }

  50% {
    -webkit-transform: scale(1.2);
    -moz-transform: scale(1.2);
    transform: scale(1.2);
  }

  100% {
    -webkit-transform: scale(1);
    -moz-transform: scale(1);
    transform: scale(1);
  }
}

.tile-merged .tile-inner {
  z-index: 20;
  -webkit-animation: pop 200ms ease 100ms;
  -moz-animation: pop 200ms ease 100ms;
  animation: pop 200ms ease 100ms;
  -webkit-animation-fill-mode: backwards;
  -moz-animation-fill-mode: backwards;
  animation-fill-mode: backwards;
}

.game-intro {
  margin-bottom: 0;
}

.game-explanation {
  margin-top: 50px;
}

@media screen and (max-width: 520px) {

  html,
  body {
    font-size: 15px;
  }

  body {
    margin: 20px 0;
    padding: 0 20px;
  }

  h1.title {
    font-size: 27px;
    margin-top: 15px;
  }

  .container {
    width: 280px;
    margin: 0 auto;
  }

  .score-container,
  .best-container,
  .timer-container {
    margin-top: 0;
    padding: 15px 10px;
    min-width: 40px;
  }

  .stats-left {
    float: left;
    font-weight: bold;
    color: #776e65;
    margin-top: 10px;
  }

  .stats-right {
    float: right;
    font-weight: bold;
    color: #776e65;
    margin-top: 10px;
  }

  .heading {
    margin-bottom: 10px;
  }

  .game-container {
    margin-top: 40px;
    position: relative;
    padding: 10px;
    cursor: default;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    background: #bbada0;
    border-radius: 6px;
    width: 280px;
    height: 280px;
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
  }

  .game-container .game-message {
    display: none;
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: rgba(238, 228, 218, 0.5);
    z-index: 100;
    text-align: center;
    -webkit-animation: fade-in 800ms ease 1200ms;
    -moz-animation: fade-in 800ms ease 1200ms;
    animation: fade-in 800ms ease 1200ms;
    -webkit-animation-fill-mode: both;
    -moz-animation-fill-mode: both;
    animation-fill-mode: both;
  }

  .game-container .game-message p {
    font-size: 60px;
    font-weight: bold;
    height: 60px;
    line-height: 60px;
    margin-top: 222px;
  }

  .game-container .game-message .lower {
    display: block;
    margin-top: 59px;
  }

  .game-container .game-message a {
    display: inline-block;
    background: #8f7a66;
    border-radius: 3px;
    padding: 0 20px;
    text-decoration: none;
    color: #f9f6f2;
    height: 40px;
    line-height: 42px;
    margin-left: 9px;
  }

  .game-container .game-message a.keep-playing-button {
    display: none;
  }

  .game-container .game-message.game-won {
    background: rgba(237, 194, 46, 0.5);
    color: #f9f6f2;
  }

  .game-container .game-message.game-won a.keep-playing-button {
    display: inline-block;
  }

  .game-container .game-message.game-won,
  .game-container .game-message.game-over {
    display: block;
  }

  .grid-container {
    position: absolute;
    z-index: 1;
  }

  .grid-row {
    margin-bottom: 10px;
  }

  .grid-row:last-child {
    margin-bottom: 0;
  }

  .grid-row:after {
    content: "";
    display: block;
    clear: both;
  }

  .grid-cell {
    width: 57.5px;
    height: 57.5px;
    margin-right: 10px;
    float: left;
    border-radius: 3px;
    background: rgba(238, 228, 218, 0.35);
  }

  .grid-cell:last-child {
    margin-right: 0;
  }

  .tile-container {
    position: absolute;
    z-index: 2;
  }

  .tile,
  .tile .tile-inner {
    width: 58px;
    height: 58px;
    line-height: 67.5px;
  }

  .tile.tile-position-1-1 {
    -webkit-transform: translate(0px, 0px);
    -moz-transform: translate(0px, 0px);
    transform: translate(0px, 0px);
  }

  .tile.tile-position-1-2 {
    -webkit-transform: translate(0px, 67px);
    -moz-transform: translate(0px, 67px);
    transform: translate(0px, 67px);
  }

  .tile.tile-position-1-3 {
    -webkit-transform: translate(0px, 135px);
    -moz-transform: translate(0px, 135px);
    transform: translate(0px, 135px);
  }

  .tile.tile-position-1-4 {
    -webkit-transform: translate(0px, 202px);
    -moz-transform: translate(0px, 202px);
    transform: translate(0px, 202px);
  }

  .tile.tile-position-2-1 {
    -webkit-transform: translate(67px, 0px);
    -moz-transform: translate(67px, 0px);
    transform: translate(67px, 0px);
  }

  .tile.tile-position-2-2 {
    -webkit-transform: translate(67px, 67px);
    -moz-transform: translate(67px, 67px);
    transform: translate(67px, 67px);
  }

  .tile.tile-position-2-3 {
    -webkit-transform: translate(67px, 135px);
    -moz-transform: translate(67px, 135px);
    transform: translate(67px, 135px);
  }

  .tile.tile-position-2-4 {
    -webkit-transform: translate(67px, 202px);
    -moz-transform: translate(67px, 202px);
    transform: translate(67px, 202px);
  }

  .tile.tile-position-3-1 {
    -webkit-transform: translate(135px, 0px);
    -moz-transform: translate(135px, 0px);
    transform: translate(135px, 0px);
  }

  .tile.tile-position-3-2 {
    -webkit-transform: translate(135px, 67px);
    -moz-transform: translate(135px, 67px);
    transform: translate(135px, 67px);
  }

  .tile.tile-position-3-3 {
    -webkit-transform: translate(135px, 135px);
    -moz-transform: translate(135px, 135px);
    transform: translate(135px, 135px);
  }

  .tile.tile-position-3-4 {
    -webkit-transform: translate(135px, 202px);
    -moz-transform: translate(135px, 202px);
    transform: translate(135px, 202px);
  }

  .tile.tile-position-4-1 {
    -webkit-transform: translate(202px, 0px);
    -moz-transform: translate(202px, 0px);
    transform: translate(202px, 0px);
  }

  .tile.tile-position-4-2 {
    -webkit-transform: translate(202px, 67px);
    -moz-transform: translate(202px, 67px);
    transform: translate(202px, 67px);
  }

  .tile.tile-position-4-3 {
    -webkit-transform: translate(202px, 135px);
    -moz-transform: translate(202px, 135px);
    transform: translate(202px, 135px);
  }

  .tile.tile-position-4-4 {
    -webkit-transform: translate(202px, 202px);
    -moz-transform: translate(202px, 202px);
    transform: translate(202px, 202px);
  }

  .game-intro {
    width: 55%;
    display: block;
    box-sizing: border-box;
    line-height: 1.65;
  }

  #play-mode-intro {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: clip;
    line-height: 1.65;
    font-size: 13px;
  }

  .restart-button {
    width: 42%;
    padding: 0;
    display: block;
    box-sizing: border-box;
    margin-top: 2px;
  }

  .game-container {
    margin-top: 17px;
  }

  .tile .tile-inner {
    font-size: 35px;
  }

  .game-message p {
    font-size: 30px !important;
    height: 30px !important;
    line-height: 30px !important;
    margin-top: 90px !important;
  }

  .game-message .lower {
    margin-top: 30px !important;
  }

  /* Mobile Optimization for Milestones */
  #milestones-container {
    display: none;
    margin-top: 10px;
    background: #faf8ef;
    padding: 10px;
    border-radius: 6px;
  }

  #milestones-container.expanded {
    display: block;
    -webkit-animation: fade-in 400ms ease;
    -moz-animation: fade-in 400ms ease;
    animation: fade-in 400ms ease;
  }
}

.game-container .game-message a.export-replay-button,
.game-container .game-message a.import-replay-button,
.game-container .game-message a.undo-button {
  display: inline-block;
  background: #8f7a66;
  border-radius: 3px;
  padding: 0 20px;
  text-decoration: none;
  color: #f9f6f2;
  height: 40px;
  line-height: 42px;
  margin-left: 9px;
  cursor: pointer;
}

/* Replay Modal */
.replay-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  /* Hidden by default via inline style, but this is the display type */
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

/* Replay Controls Panel */
.replay-controls-panel {
  border: 1px solid #d8d4d0;
}

.replay-control-btn {
  background: #8f7a66;
  border-radius: 3px;
  padding: 0 10px;
  color: #f9f6f2;
  height: 30px;
  line-height: 30px;
  cursor: pointer;
  border: none;
  font-weight: bold;
}

.replay-control-btn:hover {
  background: #7f6a56;
}

input[type=range] {
  -webkit-appearance: none;
  background: transparent;
}

input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  height: 20px;
  width: 20px;
  border-radius: 10px;
  background: #edc22e;
  cursor: pointer;
  margin-top: -8px;
}

input[type=range]::-webkit-slider-runnable-track {
  width: 100%;
  height: 4px;
  cursor: pointer;
  background: #d8d4d0;
  border-radius: 2px;
}

.replay-modal-content {
  background: #faf8ef;
  padding: 20px;
  border-radius: 6px;
  width: 90%;
  max-width: 500px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  text-align: center;
}

.replay-modal-content h3 {
  color: #776e65;
  margin-top: 0;
}

.replay-textarea {
  width: 100%;
  height: 100px;
  margin: 15px 0;
  padding: 10px;
  border: 1px solid #d8d4d0;
  border-radius: 3px;
  font-family: monospace;
  resize: vertical;
}

.replay-modal-actions .replay-button {
  display: inline-block;
  background: #8f7a66;
  border-radius: 3px;
  padding: 0 20px;
  text-decoration: none;
  color: #f9f6f2;
  height: 40px;
  line-height: 42px;
  margin: 0 5px;
  cursor: pointer;
  border: none;
  font-size: 16px;
  font-weight: bold;
}

.replay-button {
  display: inline-block;
  background: #8f7a66;
  border-radius: 3px;
  padding: 0 20px;
  text-decoration: none;
  color: #f9f6f2;
  height: 40px;
  line-height: 40px;
  cursor: pointer;
  border: none;
  font-size: 14px;
  font-weight: bold;
}

/* Home top action buttons */
.top-action-buttons {
  position: absolute;
  top: -56px;
  right: -250px;
  display: flex;
  gap: 8px;
  z-index: 20;
}

.top-action-btn {
  display: inline-block;
  background: #8f7a66;
  border-radius: 3px;
  padding: 0 14px;
  text-decoration: none;
  color: #f9f6f2;
  height: 34px;
  line-height: 34px;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
}

.top-action-btn:hover {
  background: #7f6a56;
}

.floating-settings-btn {
  position: fixed;
  top: 8px;
  right: 8px;
  z-index: 1001;
}

.stats-panel-toggle {
  border: none;
}

.stats-panel-toggle.is-floating {
  position: fixed;
  top: 8px;
  right: 86px;
  z-index: 1001;
}

.stats-panel-toggle:hover {
  background: #7f6a56;
}

.stats-panel-content {
  max-width: 360px;
}

.stats-panel-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid #e1dbd3;
  color: #776e65;
  font-weight: bold;
}

.stats-panel-row:last-of-type {
  border-bottom: none;
}

/* Settings modal */
.settings-modal-content {
  max-width: 540px;
  text-align: left;
}

.settings-row {
  margin: 14px 0;
}

.settings-row label {
  display: block;
  margin-bottom: 8px;
  font-weight: bold;
  color: #776e65;
}

.settings-switch-row {
  display: flex !important;
  align-items: center;
  gap: 8px;
  font-weight: normal !important;
  margin-bottom: 4px;
}

.settings-switch-row input[type=checkbox] {
  width: 18px;
  height: 18px;
}

/* Custom Theme Settings Layout */
.theme-settings-row {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  margin: 14px 0;
}

.theme-selection-col {
  flex: 0 0 200px;
  /* Fixed width for selector */
}

.theme-preview-col {
  flex: 1;
  /* Takes remaining space */
}

/* Custom Select Dropdown */
.custom-select-wrapper {
  position: relative;
  user-select: none;
  width: 100%;
}

.custom-select {
  position: relative;
  display: flex;
  flex-direction: column;
}

.custom-select-trigger {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  font-size: 14px;
  color: #776e65;
  height: 36px;
  line-height: 36px;
  background: #fffdfa;
  border: 1px solid #d8d4d0;
  border-radius: 4px;
  cursor: pointer;
}

.custom-select-options {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fffdfa;
  border: 1px solid #d8d4d0;
  border-top: none;
  border-radius: 0 0 4px 4px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-10px);
  transition: all 0.2s ease;
  max-height: 300px;
  overflow-y: auto;
}

.custom-select.open .custom-select-options {
  opacity: 1;
  visibility: visible;
  pointer-events: all;
  transform: translateY(0);
}

.custom-option {
  padding: 0 10px;
  line-height: 36px;
  cursor: pointer;
  transition: background 0.1s;
}

.custom-option:hover {
  background: #eee4da;
}

.custom-option.selected {
  background: #edc22e;
  color: #fff;
}

.custom-arrow {
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 5px solid #776e65;
  transition: transform 0.2s;
}

.custom-select.open .custom-arrow {
  transform: rotate(180deg);
}

/* Adjusted Preview Grid for Side-by-Side */
.theme-preview-grid {
  display: grid;
  grid-template-columns: repeat(4, 40px);
  /* Slightly smaller to fit */
  grid-template-rows: repeat(4, 40px);
  gap: 6px;
  background: #bbada0;
  border-radius: 6px;
  padding: 6px;
  width: fit-content;
}

.settings-note {
  margin-top: 8px;
  font-size: 13px;
  color: #8a8178;
}

color: #8a8178;
}

@media screen and (max-width: 520px) {
  .top-action-buttons {
    position: static;
    right: auto;
    top: auto;
    flex-wrap: wrap;
    justify-content: flex-end;
    margin-bottom: 10px;
  }

  .top-action-btn {
    height: 30px;
    line-height: 30px;
    padding: 0 10px;
    font-size: 13px;
  }

  .floating-settings-btn {
    right: 6px;
    top: 6px;
  }

  .stats-panel-toggle.is-floating {
    right: 76px;
    top: 6px;
  }
}

/* Timer Tiles (Legend Colors & Glows) */
.timer-legend-16 {
  background: #f59563;
  box-shadow: 0 0 5px 0 rgba(245, 149, 99, 0.5);
}

.timer-legend-32 {
  background: #f67c5f;
  box-shadow: 0 0 5px 0 rgba(246, 124, 95, 0.5);
}

.timer-legend-64 {
  background: #f65e3b;
  box-shadow: 0 0 5px 0 rgba(246, 94, 59, 0.5);
}

.timer-legend-128 {
  background: #edcf72;
  box-shadow: 0 0 10px 1px rgba(243, 215, 116, 0.4), inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}

.timer-legend-256 {
  background: #edcc61;
  box-shadow: 0 0 10px 1px rgba(243, 215, 116, 0.45), inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}

.timer-legend-512 {
  background: #edc850;
  box-shadow: 0 0 10px 2px rgba(243, 215, 116, 0.5), inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}

.timer-legend-1024 {
  background: #edc53f;
  box-shadow: 0 0 10px 2px rgba(243, 215, 116, 0.55), inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}

.timer-legend-2048 {
  background: #edc22e;
  box-shadow: 0 0 15px 3px rgba(243, 215, 116, 0.6), inset 0 0 0 1px rgba(255, 255, 255, 0.3);
}

.timer-legend-4096 {
  background: #aa44cc;
  box-shadow: 0 0 15px 3px rgba(170, 68, 204, 0.6), inset 0 0 0 1px rgba(255, 255, 255, 0.15);
}

.timer-legend-8192 {
  background: #662288;
  box-shadow: 0 0 15px 3px rgba(102, 34, 136, 0.6), inset 0 0 0 1px rgba(255, 255, 255, 0.15);
}

.timer-legend-16384 {
  background: #331155;
  box-shadow: 0 0 15px 3px rgba(51, 17, 85, 0.6), inset 0 0 0 1px rgba(255, 255, 255, 0.15);
}

.timer-legend-32768 {
  background: #000000;
  box-shadow: 0 0 15px 3px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(100, 100, 100, 0.2);
}

/* Custom Tile Colors 4096+ to match Timer Legend */
.tile.tile-4096 .tile-inner {
  color: #f9f6f2;
  background: #aa44cc;
  box-shadow: 0 0 30px 10px rgba(170, 68, 204, 0.47), inset 0 0 0 1px rgba(255, 255, 255, 0.28);
}

.tile.tile-8192 .tile-inner {
  color: #f9f6f2;
  background: #662288;
  box-shadow: 0 0 30px 10px rgba(102, 34, 136, 0.55), inset 0 0 0 1px rgba(255, 255, 255, 0.33);
}

.tile.tile-16384 .tile-inner {
  color: #f9f6f2;
  background: #331155;
  box-shadow: 0 0 30px 10px rgba(51, 17, 85, 0.6), inset 0 0 0 1px rgba(255, 255, 255, 0.33);
}

.tile.tile-32768 .tile-inner {
  color: #f9f6f2;
  background: #000000;
  box-shadow: 0 0 30px 10px rgba(0, 0, 0, 0.6), inset 0 0 0 1px rgba(255, 255, 255, 0.33);
}

@media screen and (max-width: 520px) {

  .tile.tile-4096 .tile-inner,
  .tile.tile-8192 .tile-inner,
  .tile.tile-16384 .tile-inner,
  .tile.tile-32768 .tile-inner {
    font-size: 15px;
    /* Adjust font size for mobile */
  }
}

/* Account / Leaderboard / History pages */
.portal-container {
  width: 960px;
}

.portal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 12px;
}

.portal-header .title {
  float: none;
  margin: 0;
}

.portal-nav {
  display: flex;
  gap: 12px;
}

.portal-nav a {
  text-decoration: none;
}

.portal-card {
  background: #fffdf7;
  border: 1px solid #d8d4d0;
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 12px;
}

.portal-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.portal-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.portal-form input,
.portal-inline-input {
  height: 36px;
  border: 1px solid #d8d4d0;
  border-radius: 4px;
  padding: 0 10px;
  font-size: 14px;
  color: #776e65;
}

.portal-inline-input {
  width: 180px;
}

.portal-api-input {
  width: 320px;
  max-width: 100%;
}

.portal-actions-inline {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.portal-api-row label {
  min-width: 68px;
}

.portal-inline-select {
  width: auto;
  min-width: 130px;
}

.portal-status {
  margin-top: 8px;
  font-size: 14px;
}

.portal-muted {
  color: #8a8178;
  margin-top: 6px;
}

.portal-table-wrap {
  overflow-x: auto;
}

.portal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.portal-table th,
.portal-table td {
  border-bottom: 1px solid #e7e1d7;
  padding: 8px;
  text-align: left;
}

.portal-table th {
  color: #8a8178;
}

.portal-section-title {
  margin: 12px 0;
  font-size: 24px;
}

.history-item {
  background: #fffdf7;
  border: 1px solid #d8d4d0;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
}

.history-item-head {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
  font-size: 14px;
}

.final-board-grid {
  display: grid;
  grid-template-columns: repeat(4, 52px);
  grid-template-rows: repeat(4, 52px);
  gap: 6px;
  background: #bbada0;
  border-radius: 6px;
  padding: 8px;
  width: fit-content;
}

.final-board-cell {
  background: rgba(238, 228, 218, 0.35);
  border-radius: 3px;
  color: #776e65;
  font-weight: bold;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.final-board-cell-empty {
  background: rgba(238, 228, 218, 0.35);
  color: transparent;
}

.final-board-cell-v-2 {
  background: #eee4da;
  color: #776e65;
}

.final-board-cell-v-4 {
  background: #ede0c8;
  color: #776e65;
}

.final-board-cell-v-8 {
  background: #f2b179;
  color: #f9f6f2;
}

.final-board-cell-v-16 {
  background: #f59563;
  color: #f9f6f2;
}

.final-board-cell-v-32 {
  background: #f67c5f;
  color: #f9f6f2;
}

.final-board-cell-v-64 {
  background: #f65e3b;
  color: #f9f6f2;
}

.final-board-cell-v-128 {
  background: #edcf72;
  color: #f9f6f2;
  font-size: 14px;
}

.final-board-cell-v-256 {
  background: #edcc61;
  color: #f9f6f2;
  font-size: 14px;
}

.final-board-cell-v-512 {
  background: #edc850;
  color: #f9f6f2;
  font-size: 14px;
}

.final-board-cell-v-1024 {
  background: #edc53f;
  color: #f9f6f2;
  font-size: 12px;
}

.final-board-cell-v-2048 {
  background: #edc22e;
  color: #f9f6f2;
  font-size: 12px;
}

.final-board-cell-v-4096,
.final-board-cell-v-8192,
.final-board-cell-v-16384,
.final-board-cell-v-32768,
.final-board-cell-v-65536 {
  background: #3c3a32;
  color: #f9f6f2;
  font-size: 11px;
}

.final-board-cell-super {
  background: #3c3a32;
  color: #f9f6f2;
  font-size: 10px;
}

@media screen and (max-width: 980px) {
  .portal-container {
    width: 94%;
  }

  .portal-header {
    display: block;
  }

  .portal-nav {
    margin-top: 8px;
  }

  .portal-grid-2 {
    grid-template-columns: 1fr;
  }
}
