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

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

body {
  margin: 80px 0;
}

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

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

@-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: "Score";
}

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

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: 980px;
  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-layout-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 20px;
  margin: 20px 0;
  align-items: stretch;
  touch-action: none;
}

/* 调整游戏容器样式以适应新布局 */
.game-container {
  margin: 0;
  width: 500px;
  flex-grow: 0;
  flex-shrink: 0;
  height: 500px;
  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;
  box-sizing: border-box;
  overscroll-behavior: none;
}

.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:last-child {
  margin-right: 0;
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

.tile.tile-position-4-4 {
  -webkit-transform: translate(363px, 363px);
  -moz-transform: translate(363px, 363px);
  -ms-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;
  box-sizing: border-box;
}

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

.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);
    -ms-transform: scale(0);
    transform: scale(0);
  }

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

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

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

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

  100% {
    opacity: 1;
    -webkit-transform: scale(1);
    -moz-transform: scale(1);
    -ms-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);
    -ms-transform: scale(0);
    transform: scale(0);
  }

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

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

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

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

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

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

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

  100% {
    -webkit-transform: scale(1);
    -moz-transform: scale(1);
    -ms-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;
}

.above-game {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.above-game:after {
  content: none;
}

.game-intro {
  flex: 0 1 auto;
  margin-right: 10px;
  line-height: 1.65;
  margin-bottom: 0;
  white-space: nowrap;
}

.btn-group {
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-end;
}

.restart-button,
.undo-button,
.save-button,
.load-button,
.ai-play-button,
.ai-step-button,
.ai-simulate-button,
.show-score-button {
  display: inline-block;
  background: #8f7a66;
  border-radius: 3px;
  padding: 0 8px;
  text-decoration: none;
  color: #f9f6f2;
  height: 40px;
  line-height: 42px;
  text-align: center;
  margin-left: 4px;
  margin-bottom: 5px;
  min-width: 50px;
  max-width: 80px;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.show-score-button.active {
  background: #65b27a;
  /* 使用绿色背景表示激活状态 */
}

/* 按钮悬停效果 */
.restart-button:hover,
.undo-button:hover,
.save-button:hover,
.load-button:hover,
.ai-play-button:hover,
.ai-step-button:hover,
.ai-simulate-button:hover,
.show-score-button:hover {
  background-color: #9f8b77;
}

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

.language-selector {
  margin: 10px 0;
  text-align: right;
}

.language-selector .lang-button {
  display: inline-block;
  background: #8f7a66;
  border-radius: 3px;
  padding: 0 10px;
  text-decoration: none;
  color: #f9f6f2;
  height: 30px;
  line-height: 30px;
  margin-left: 5px;
  cursor: pointer;
  min-width: 80px;
  text-align: center;
}

.language-selector .lang-button.active {
  background: #776e65;
}

@media screen and (max-width: 850px) {
  .container {
    width: 100%;
    padding: 0 10px;
    box-sizing: border-box;
  }
}

/* AI控制按钮容器 */
.ai-controls {
  margin-top: 10px;
  text-align: center;
}

/* 游戏对话框样式 */
.game-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
}

.game-dialog {
  background: #faf8ef;
  border-radius: 6px;
  padding: 20px;
  width: 80%;
  max-width: 500px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.4);
}

.game-dialog h3 {
  margin-top: 0;
  color: #776e65;
  text-align: center;
}

.game-dialog h4 {
  color: #776e65;
  margin: 15px 0 5px;
}

.input-group {
  margin: 15px 0;
}

.input-group label {
  display: block;
  margin-bottom: 5px;
  color: #776e65;
}

.save-input {
  width: 100%;
  padding: 8px;
  border: 1px solid #bbada0;
  border-radius: 3px;
  font-size: 16px;
  box-sizing: border-box;
}

.dialog-buttons {
  display: flex;
  justify-content: flex-end;
  margin-top: 15px;
}

.dialog-button {
  background: #8f7a66;
  border: none;
  border-radius: 3px;
  color: #f9f6f2;
  cursor: pointer;
  font-size: 14px;
  font-weight: bold;
  padding: 8px 15px;
  margin-left: 10px;
}

.dialog-button:hover {
  background: #9f8b77;
}

/* 存档列表样式 */
.save-list {
  max-height: 300px;
  overflow-y: auto;
  margin: 10px 0;
  border: 1px solid #bbada0;
  border-radius: 3px;
  padding: 5px;
}

.save-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px;
  border-bottom: 1px solid #cdc1b4;
}

.save-item:last-child {
  border-bottom: none;
}

.save-info {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.save-actions {
  display: flex;
  gap: 5px;
}

.save-actions button {
  background: #8f7a66;
  border: none;
  border-radius: 3px;
  color: #f9f6f2;
  cursor: pointer;
  padding: 4px 8px;
  font-size: 12px;
}

.save-actions .load-button {
  background: #65b27a;
}

.save-actions .delete-button {
  background: #e74c3c;
}

.save-actions button:hover {
  opacity: 0.9;
}

/* AI 决策分析样式 */
.ai-decision-container {
  margin: 20px auto;
  max-width: 980px;
  background: rgba(238, 228, 218, 0.35);
  padding: 15px;
  border-radius: 6px;
  color: #776e65;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  animation: ai-panel-fade-in 0.5s ease;
}

/* 分析面板的淡入动画 */
@keyframes ai-panel-fade-in {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ai-decision-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.ai-decision-header h3 {
  margin: 0;
  font-size: 18px;
}

.ai-decision-close-button {
  background: #8f7a66;
  color: white;
  border: none;
  border-radius: 3px;
  padding: 5px 10px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.ai-decision-close-button:hover {
  background: #9f8b77;
}

.ai-best-move {
  font-size: 16px;
  text-align: center;
  margin-bottom: 15px;
  padding: 5px;
  background: rgba(238, 228, 218, 0.5);
  border-radius: 3px;
}

.ai-brackets-explanation {
  font-size: 14px;
  font-style: italic;
  text-align: center;
  margin: 10px 0;
  color: #9e948a;
}

.ai-score-explanation {
  font-size: 14px;
  margin: 10px 0;
  padding: 5px;
  background: rgba(238, 228, 218, 0.5);
  border-radius: 3px;
  line-height: 1.4;
}

.ai-factors,
.ai-weights {
  margin-bottom: 10px;
}

.ai-factors ul,
.ai-weights ul {
  margin: 5px 0;
  padding-left: 25px;
}

/* 棋盘状态显示样式 */
.ai-boards {
  margin: 15px 0;
}

.ai-board {
  margin: 10px auto;
  max-width: 250px;
}

.board-grid {
  background: #bbada0;
  border-radius: 6px;
  padding: 10px;
}

.board-row {
  display: flex;
  margin-bottom: 10px;
}

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

.board-cell {
  width: 40px;
  height: 40px;
  margin-right: 5px;
  background: rgba(238, 228, 218, 0.35);
  border-radius: 3px;
  text-align: center;
  line-height: 40px;
  font-weight: bold;
  font-size: 16px;
}

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

/* 为不同数值的方块设置不同背景色 */
.board-cell.tile-2 {
  background: #eee4da;
}

.board-cell.tile-4 {
  background: #ede0c8;
}

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

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

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

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

.board-cell.tile-128 {
  background: #edcf72;
  color: #f9f6f2;
  font-size: 18px;
}

.board-cell.tile-256 {
  background: #edcc61;
  color: #f9f6f2;
  font-size: 18px;
}

.board-cell.tile-512 {
  background: #edc850;
  color: #f9f6f2;
  font-size: 18px;
}

.board-cell.tile-1024 {
  background: #edc53f;
  color: #f9f6f2;
  font-size: 16px;
}

.board-cell.tile-2048 {
  background: #edc22e;
  color: #f9f6f2;
  font-size: 16px;
}

.board-after-move-row {
  background: rgba(238, 228, 218, 0.2);
}

.board-after-move-cell {
  padding: 10px !important;
}

.board-after-move-title {
  text-align: center;
  font-weight: bold;
  margin-bottom: 5px;
}

.ai-comparison {
  margin-top: 15px;
}

.ai-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  font-size: 12px;
}

.ai-table th,
.ai-table td {
  border: 1px solid #bbada0;
  padding: 4px;
  text-align: center;
}

.ai-table th {
  background-color: #bbada0;
  color: white;
}

.ai-table tr:nth-child(even):not(.board-after-move-row) {
  background-color: rgba(238, 228, 218, 0.5);
}

.ai-table tr.best-move {
  background-color: rgba(237, 194, 46, 0.3);
  font-weight: bold;
}

@media screen and (max-width: 520px) {
  .ai-decision-container {
    font-size: 12px;
    padding: 10px;
    max-width: 95%;
  }

  .ai-table th,
  .ai-table td {
    padding: 2px;
    font-size: 10px;
  }

  .ai-score-explanation {
    font-size: 12px;
  }

  .board-cell {
    width: 30px;
    height: 30px;
    line-height: 30px;
    font-size: 14px;
    margin-right: 3px;
  }

  .board-cell.tile-128,
  .board-cell.tile-256,
  .board-cell.tile-512 {
    font-size: 12px;
  }

  .board-cell.tile-1024,
  .board-cell.tile-2048 {
    font-size: 10px;
  }
}

/* 在游戏区域小于表格宽度时添加水平滚动 */
@media screen and (max-width: 520px) {
  .ai-comparison {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* 实时评分分析样式 */
.realtime-score-container {
  min-width: 210px;
  width: auto;
  max-width: 350px;
  flex-shrink: 0;
  flex-grow: 1;
  margin: 0;
  background: rgba(238, 228, 218, 0.35);
  padding: 15px;
  border-radius: 6px;
  color: #776e65;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  animation: ai-panel-fade-in 0.5s ease;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  height: 100%;
}

.realtime-score-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.realtime-score-container h3 {
  margin: 0;
  font-size: 18px;
}

.realtime-score-close-button {
  background: #8f7a66;
  color: white;
  border: none;
  border-radius: 3px;
  padding: 5px 10px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.realtime-score-close-button:hover {
  background: #9f8b77;
}

.realtime-score-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  font-size: 12px;
}

.realtime-score-table th,
.realtime-score-table td {
  border: 1px solid #bbada0;
  padding: 4px;
  text-align: center;
}

.realtime-score-table th {
  background-color: #bbada0;
  color: white;
}

.realtime-score-table tr:nth-child(even) {
  background-color: rgba(238, 228, 218, 0.5);
}

.realtime-score-table .total-row {
  font-weight: bold;
  background-color: rgba(237, 194, 46, 0.2);
}

.realtime-score-table .positive-change {
  color: #65b27a;
  font-weight: bold;
}

.realtime-score-table .negative-change {
  color: #e74c3c;
  font-weight: bold;
}

/* 移动设备适配 */
@media screen and (max-width: 520px) {
  .realtime-score-container,
  .previous-board-container {
    font-size: 12px;
    padding: 10px;
    width: 95%;
    max-width: none;
  }

  .realtime-score-table th,
  .realtime-score-table td {
    padding: 2px;
    font-size: 10px;
  }

  .realtime-score-container h3,
  .previous-board-container h3 {
    font-size: 16px;
  }

  .board-cell {
    width: 30px;
    height: 30px;
    line-height: 30px;
    font-size: 14px;
    margin-right: 3px;
  }

  .board-cell.tile-128,
  .board-cell.tile-256,
  .board-cell.tile-512 {
    font-size: 12px;
  }

  .board-cell.tile-1024,
  .board-cell.tile-2048 {
    font-size: 10px;
  }
}

/* 游戏布局容器 */
.game-layout-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 20px;
  margin: 20px 0;
  align-items: stretch;
}

/* 历史棋盘容器 */
.previous-board-container {
  min-width: 210px;
  width: auto;
  max-width: 300px;
  flex-shrink: 0;
  flex-grow: 1;
  background: rgba(238, 228, 218, 0.35);
  padding: 15px;
  border-radius: 6px;
  color: #776e65;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  animation: ai-panel-fade-in 0.5s ease;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  height: 100%;
}

.previous-board-container h3 {
  margin: 0 0 10px 0;
  font-size: 18px;
  text-align: center;
}

/* 移动设备响应式布局 */
@media screen and (max-width: 1050px) {
  .container {
    width: 100%;
    padding: 0 10px;
    box-sizing: border-box;
  }

  .game-layout-container {
    flex-direction: column;
    align-items: center;
  }

  .previous-board-container,
  .realtime-score-container {
    width: 90%;
    max-width: 500px;
    margin: 10px auto;
  }

  .game-container {
    width: 90%;
    max-width: 500px;
    margin: 10px auto;
  }
}

@media screen and (max-width: 520px) {
  html,
  body {
    font-size: 15px;
  }

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

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

  .container {
    width: 100%;
    padding: 0;
  }

  .game-layout-container {
    gap: 10px;
  }

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

  .heading {
    margin-bottom: 10px;
  }

  .above-game {
    flex-direction: column;
    align-items: center;
  }

  .game-intro {
    width: 100%;
    margin-right: 0;
    margin-bottom: 10px;
    text-align: center;
    font-size: 13px;
    white-space: normal;
  }

  .btn-group {
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
  }

  .restart-button,
  .undo-button,
  .save-button,
  .load-button,
  .ai-play-button,
  .ai-step-button,
  .ai-simulate-button,
  .show-score-button {
    margin: 3px 1px;
    min-width: 40px;
    max-width: 65px;
    padding: 0 2px;
    font-size: 11px;
    height: 35px;
    line-height: 37px;
  }

  .language-selector {
    text-align: center;
    margin: 10px 0;
  }

  .language-selector .lang-button {
    min-width: 100px;
  }

  .game-container {
    margin-top: 10px;
    width: 280px;
    height: 280px;
    padding: 10px;
  }

  .previous-board-container,
  .realtime-score-container {
    width: 280px;
    padding: 10px;
  }

  .ai-decision-container {
    max-width: 95%;
    padding: 10px;
  }
}
