/* 游戏组件样式 - 第二层A */

/* 分数组件 */
.scores-container {
  float: left; /* 移到左侧，与按钮在同一行 */
  text-align: left;
  margin-top: 0; /* 与按钮顶部对齐 */
  vertical-align: top; /* 顶部对齐，解决baseline问题 */
  /* 移除flex，让内部元素正常显示 */
}

.score-container, .best-container {
  position: relative;
  display: inline-block;
  background: var(--button-bg);
  padding: 20px 20px 0 20px; /* 顶部内边距20px，底部0，左右20px */
  font-size: 22px; /* 减小字体 */
  height: 28px; /* 调整高度，使总高度匹配按钮的48px：20+28=48 */
  line-height: 24px; /* 增加行高，让数字向下移动 */
  font-weight: bold;
  border-radius: 3px;
  color: var(--button-text, #f9f6f2);
  margin-top: 0;
  text-align: center;
  vertical-align: top; /* 顶部对齐 */
}

.score-container:after, .best-container:after {
  position: absolute;
  width: 100%;
  top: 8px; /* 向下移动，让标签和数字整体居中 */
  left: 0;
  text-transform: uppercase;
  font-size: 11px; /* 减小字体 */
  line-height: 11px;
  text-align: center;
  color: var(--text-color, #776e65);
}

.score-container .score-addition, .best-container .score-addition {
  position: absolute;
  right: 30px;
  font-size: 25px;
  line-height: 25px;
  font-weight: bold;
  color: var(--weak-text);
  z-index: 100;
}

.score-container:after {
  content: "Score";
}

.best-container:after {
  content: "Best";
}

/* 游戏消息组件 */
.game-container .game-message {
  display: none;
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: rgba(238, 228, 218, 0.73);
  z-index: 100;
  text-align: center;
  animation: fade-in 800ms ease 1200ms;
  animation-fill-mode: both;
}

.game-container .game-message p {
  font-size: 60px;
  font-weight: bold;
  height: 60px;
  line-height: 60px;
  margin-top: 120px;
  color: var(--bright-text);
}

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

.game-container .game-message a {
  display: inline-block;
  background: var(--button-bg, #8f7a66);
  border-radius: 3px;
  padding: 0 20px;
  text-decoration: none;
  color: var(--button-text, #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: var(--bright-text);
}

.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;
}

/* 游戏介绍和按钮组件 */
.game-intro {
  float: none; /* 不浮动 */
  line-height: 1.4; /* 减小行间距 */
  margin-bottom: 10px; /* 与下方积分按钮的间距 */
  color: var(--text-color, #776e65);
  display: block; /* 占满整行 */
}

.restart-button {
  display: inline-block;
  background: var(--button-bg, #8f7a66);
  border-radius: 3px;
  padding: 0 18px; /* 稍微减小内边距 */
  text-decoration: none;
  color: var(--button-text, #f9f6f2);
  height: 48px; /* 减小高度，匹配积分板：12+42=54 */
  line-height: 48px; /* 垂直居中 */
  text-align: center;
  float: right;
  margin-right: 15px;
  margin-left: 5px; /* 添加左边距，匹配计分板之间的HTML空白字符间距 */
  margin-top: 0; /* 与积分对齐 */
  vertical-align: top; /* 顶部对齐 */
  font-size: 16px; /* 增大字体，提升可读性 */
  font-weight: bold; /* 加粗字体，增强视觉层次 */
}

/* 声音开关按钮 */
.sound-toggle-btn {
  display: inline-block;
  background: var(--button-bg, #8f7a66);
  border: none;
  border-radius: 3px;
  padding: 0 10px; /* 减小内边距 */
  color: var(--button-text, #f9f6f2);
  height: 48px; /* 与重启按钮一致 */
  line-height: 48px; /* 垂直居中 */
  text-align: center;
  font-size: 14px; /* 减小字体 */
  cursor: pointer;
  float: right;
  transition: all 0.3s ease;
  margin-right: 0;
  margin-top: 0; /* 与积分对齐 */
  vertical-align: top; /* 顶部对齐 */
}

.sound-toggle-btn:hover {
  opacity: 0.8;
  transform: scale(1.05);
}

/* 移动端优化 */
@media screen and (max-width: 520px) {
  .game-intro {
    text-align: center; /* 游戏描述左右居中 */
    padding: 0 10px;
  }

  .restart-button {
    width: 100px; /* 限制新游戏按钮宽度 */
    margin-right: 10px; /* 减少与声音按钮的间距 */
  }

  .sound-toggle-btn {
    margin-right: 0;
    margin-left: 10px; /* 增加左侧间距 */
  }
}

.sound-toggle-btn.active {
  background: var(--button-bg);
}

/* 游戏标题 */
.title {
  color: var(--text-color, #776e65);
  text-align: center; /* 标题左右居中 */
}

/* Tile颜色组件 */
.tile.tile-2 .tile-inner { background: #eee4da; }
.tile.tile-4 .tile-inner { background: #ede0c8; }
.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; font-size: 45px; }
.tile.tile-256 .tile-inner { color: #f9f6f2; background: #edcc61; font-size: 45px; }
.tile.tile-512 .tile-inner { color: #f9f6f2; background: #edc850; font-size: 45px; }
.tile.tile-1024 .tile-inner { color: #f9f6f2; background: #edc53f; font-size: 35px; }
.tile.tile-2048 .tile-inner { color: #f9f6f2; background: #edc22e; font-size: 35px; }
.tile.tile-super .tile-inner { color: #f9f6f2; background: #3c3a32; font-size: 30px; }

/* 动画组件 */
@keyframes move-up {
  0% {
    top: 25px;
    opacity: 1;
  }

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

@-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 fade-in {
  0% {
    opacity: 0;
  }

  100% {
    opacity: 1;
  }
}

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

  100% {
    opacity: 1;
  }
}

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

  100% {
    opacity: 1;
  }
}

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

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

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

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

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

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

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

  50% {
    transform: scale(1.2);
  }

  100% {
    transform: scale(1);
  }
}

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

  50% {
    transform: scale(1.2);
  }

  100% {
    transform: scale(1);
  }
}

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

  50% {
    transform: scale(1.2);
  }

  100% {
    transform: scale(1);
  }
}

/* Tile动画状态 */
.tile-new .tile-inner {
  animation: appear 200ms ease 100ms;
  animation-fill-mode: backwards;
}

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

.score-addition {
  animation: move-up 600ms ease-in;
  animation-fill-mode: both;
}

/* 响应式调整 */
@media screen and (max-width: 520px) {
  .tile.tile-128 .tile-inner,
  .tile.tile-256 .tile-inner,
  .tile.tile-512 .tile-inner {
    font-size: 25px;
  }

  .tile.tile-1024 .tile-inner,
  .tile.tile-2048 .tile-inner {
    font-size: 15px;
  }

  .tile.tile-super .tile-inner {
    font-size: 10px;
  }

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

  .heading {
    margin-bottom: 10px;
  }

  .game-intro {
    width: 55%;
    line-height: 1.65;
  }

  .restart-button {
    width: 42%;
    margin-top: 2px;
  }
}