:root {
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --size: calc(min(100vw, 70vh) - clamp(32px, 15vmin, 48px));
}

html,
body {
  margin: 0;
  padding: 0;
  background: #eee4da;
  color: #776e65;
  font-family: "Clear Sans", "Helvetica Neue", Arial, sans-serif;
  font-size: 18px;
  -webkit-touch-callout: none;
  /* iOS 长按菜单 */
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  /* 移除点击高亮 */
  touch-action: manipulation;
  /* 减少双击缩放/拖动 */
}

.container {
  width: var(--size);
  margin: 0 auto;
  box-sizing: border-box;
}

.heading {
  margin: clamp(2px, 1vw, 16px) auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.heading:after {
  content: "";
  display: block;
  clear: both;
}

.title h1 {
  font-size: clamp(36px, 12vw, 72px);
  font-weight: bold;
  margin: 0;
  display: block;
  float: left;
}

@keyframes score-burst {
  0% {
    transform: scale(1.8) translateY(0);
    opacity: 1;
  }

  40% {
    transform: scale(1.3) translateY(-12px);
    opacity: 0.9;
  }

  70% {
    transform: scale(1.0) translateY(-24px);
    opacity: 0.6;
  }

  100% {
    transform: scale(0.8) translateY(-36px);
    opacity: 0;
  }
}

/* 兼容前缀（可选，如果要兼容旧浏览器） */
@-webkit-keyframes score-burst {
  0% {
    transform: scale(1.8) translateY(0);
    opacity: 1;
  }

  40% {
    transform: scale(1.3) translateY(-2px);
    opacity: 0.9;
  }

  70% {
    transform: scale(1.0) translateY(-4px);
    opacity: 0.6;
  }

  100% {
    transform: scale(0.8) translateY(-6px);
    opacity: 0;
  }
}


.scores-container {
  background: #bbada0;
  border-radius: clamp(12px, 3vmin, 16px);
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1);
  min-width: clamp(120px, 40%, 480px);
  width: clamp(240px, 60%, 480px);
}

.level-container,
.score-container {
  position: relative;
  display: inline-block;
  font-weight: bold;
  color: #bbada0;
  text-align: center;
  padding: clamp(10px, 2vmin, 14px) clamp(10px, 2.4vmin, 14px);
  font-size: clamp(22px, 5.5vmin, 32px);
  height: clamp(28px, 6.2vmin, 44px);
  line-height: clamp(48px, 10vmin, 72px);
  width: 50%;
}

.level-container {
  background: #faf8ef;
  border-radius: clamp(12px, 3vmin, 16px);
  color: #bbada0;
}

.score-container {
  color: white;
}

.score-container:after,
.level-container:after {
  position: absolute;
  width: 100%;
  left: 0;
  text-transform: uppercase;
  text-align: center;
  top: clamp(5px, 1.2vmin, 8px);
  font-size: clamp(13px, 3vmin, 16px);
  line-height: clamp(13px, 3vmin, 16px);
}

.score-container .score-addition,
.level-container .score-addition {
  position: absolute;
  right:clamp(25px, 6vmin, 40px);
  /* 更贴近数值 */
  top: 55px;
  /* 放在数字右上角 */
  font-size: clamp(25px, 6vmin, 40px);
  line-height: clamp(25px, 6vmin, 40px);
  color: red;
  font-weight: bold;
  color: rgba(119, 110, 101, 0.9);
  z-index: 100;
  animation: score-burst 600ms ease-out forwards;
  /* 可选前缀 */
  -webkit-animation: score-burst 600ms ease-out forwards;
}

.score-container::after {
  content: attr(data-label);
}

.score-container:not([data-label])::after {
  content: "Score";
}

.level-container::after {
  content: attr(data-label);
}

.level-container:not([data-label])::after {
  content: "Level";
}

/* level-container 提升时的醒目动画 */
@keyframes level-bump {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.0);
  }

  35% {
    transform: scale(1.08);
    box-shadow: 0 0 0 10px rgba(255, 255, 255, 0.35);
  }

  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.0);
  }
}

@keyframes level-glow {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.75);
    opacity: 1;
  }

  100% {
    box-shadow: 0 0 0 28px rgba(255, 255, 255, 0);
    opacity: 0;
  }
}

@keyframes level-value-zoom {
  0% {
    transform: scale(2.25) translateY(-5px);
  }

  100% {
    transform: scale(1.0);
  }
}

.level-container .level-value {
  display: inline-block;
  transform-origin: center;
  will-change: transform;
}

.level-container.bump .level-value {
  animation: level-value-zoom 300ms ease-in-out;
}

.level-container.bump {
  animation: level-bump 600ms ease-in-out;
  will-change: transform;
  position: relative;
}

.level-container.bump::after {
  content: attr(data-label);
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  pointer-events: none;
  animation: level-glow 600ms ease-out;
}

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;
}

@-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;
  }
}

@-webkit-keyframes slide-up {
  0% {
    margin-top: 32%;
  }

  100% {
    margin-top: 20%;
  }
}

@-moz-keyframes slide-up {
  0% {
    margin-top: 32%;
  }

  100% {
    margin-top: 20%;
  }
}

@keyframes slide-up {
  0% {
    margin-top: 32%;
  }

  100% {
    margin-top: 20%;
  }
}

/* game-container：保持正方形，变量驱动内部计算 */
.game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: clamp(12px, 2vmin, 16px) auto;
  position: relative;
  --pad: clamp(10px, 3vmin, 15px);
  --gap: clamp(10px, 3vmin, 15px);
  padding: var(--pad);
  background: rgba(187, 173, 160, 0.85);
  border-radius: clamp(12px, 3vmin, 24px);

  /* 容器“目标宽度”变量 --size，最小 320 最大 800 */
  /* --size: clamp(320px, 90vmin, 800px); */
  width: var(--size);
  aspect-ratio: 1 / 1;
  box-sizing: border-box;

  /* 内部可用区与格子计算（4x4 固定） */
  --inner: calc(var(--size) - (var(--pad) * 2));
  --cell: calc((var(--inner) - (var(--gap) * 3)) / 4);
  --step: calc(var(--cell) + var(--gap));

  /* 核心磨砂效果，轻微边框更像玻璃，内阴影提升质感 */
  -webkit-backdrop-filter: blur(10px) saturate(115%);
  -moz-backdrop-filter: blur(10px) saturate(115%);
  backdrop-filter: blur(10px) saturate(115%);
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);

  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1);
  transition: box-shadow 180ms ease, transform 120ms ease, filter 120ms ease;
  will-change: box-shadow, transform;
}

@supports (height: 100dvh) {
  .game-container {
    --size: calc(min(100dvw, 70dvh) - clamp(32px, 15vmin, 48px));
  }

  .container {
    max-height: 100dvh;
  }
}

.game-message {
  display: none;
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  color: #ede0c8;
  background: rgba(187, 173, 160, 0.6);
  z-index: 100;
  text-align: center;
  -webkit-animation: fade-in 800ms ease 400ms;
  -moz-animation: fade-in 800ms ease 400ms;
  animation: fade-in 800ms ease 400ms;
  -webkit-animation-fill-mode: both;
  -moz-animation-fill-mode: both;
  animation-fill-mode: both;
  -webkit-backdrop-filter: blur(3px) saturate(115%);
  -moz-backdrop-filter: blur(3px) saturate(115%);
  backdrop-filter: blur(3px) saturate(115%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 1s;
}

.game-message .lower {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  gap: clamp(20px, 5vmin, 30px);
  margin-top: 10vh;
  flex-wrap: nowrap;
  /* 禁止换行 */
  white-space: nowrap;
  /* 进一步防止换行 */
}

.game-message .keep-playing-button {
  display: none;
}

.game-message .game-message-text {
  font-size: clamp(24px, 7vmin, 48px);
  font-weight: bold;
  line-height: normal;
}

.game-message .result-number {
  color: #ff6600;
  font-size: clamp(48px, 10vmin, 80px);
  text-shadow: rgba(255, 255, 255, 0.2) 0 1px 8px;
  vertical-align: middle;
  margin-left: 10px;
  transform-origin: center;
  will-change: transform;
  animation: result-number-pulse 400ms ease-out 3;
}

@keyframes result-number-pulse {

  0%,
  100% {
    transform: scale(1);
  }

  40% {
    transform: scale(1.3);
  }

  60% {
    transform: scale(1.1);
  }
}

.game-message .result-nexttips {
  font-size: clamp(16px, 5vmin, 24px);
  color: #edcf72;
  margin-top: 30px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.game-message .result-nextnum {
  display: inline;
  color: #faef8d;
  font-size: clamp(20px, 6vmin, 36px);
}

.game-message .result_gameOver {
  display: none;
  color: #795548;
  font-weight: bold;
  font-size: clamp(48px, 8vmin, 72px);
  text-shadow: rgba(0, 0, 0, 0.2) 0 2px 6px;
  text-align: center;
}

.game-message.game-won .keep-playing-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ff6600;
  animation: level-bump 1.2s ease-in-out infinite;
  /* 缩放弹跳 */
  will-change: transform;
}

.game-message.game-won .keep-playing-button::after {
  content: attr(data-label);
  position: absolute;
  inset: -2px;
  /* 轻微外扩 */
  border-radius: inherit;
  pointer-events: none;
  animation: level-glow 1.2s ease-out infinite;
  /* 同步辉光 */
}

.game-message.game-won,
.game-message.game-over {
  display: flex;
  /* 替换原来的 display: block */
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 3vmin, 18px);
  opacity: 1;
  pointer-events: auto;
}

.game-message.game-over .result-nexttips {
  display: none;
}

.grid-container {
  position: absolute;
  z-index: 1;
}

/* 背景格和 tile 层铺满内容区（扣除 padding） */
.grid-container,
.tile-container,
.game-message {
  position: absolute;
  left: var(--pad);
  top: var(--pad);
  width: var(--inner);
  height: var(--inner);
  box-sizing: border-box;
}

/* 背景格 */
.grid-row {
  margin-bottom: var(--gap);
}

.grid-row:last-child {
  margin-bottom: 0;
}

.grid-row:after {
  content: "";
  display: block;
  clear: both;
}

.grid-cell {
  width: var(--cell);
  height: var(--cell);
  margin-right: var(--gap);
  float: left;
  border-radius: clamp(8px, 2vmin, 12px);
  background: rgba(238, 228, 218, 0.35);
}

.grid-cell:last-child {
  margin-right: 0;
}

/* tile 层 */
.tile-container {
  z-index: 2;
  transform: none;
}

.tile {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--cell);
  height: var(--cell);
  transform-origin: top left;
  transition: transform 120ms ease-in-out;
  will-change: transform;
  box-sizing: border-box;
}

.tile .tile-inner {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: normal;
  border-radius: clamp(8px, 2vmin, 12px);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1), 0 3px 6px rgba(0, 0, 0, 0.1);
  font-weight: bold;
  font-size: clamp(18px, 6vmin, 55px);
  z-index: 10;
}

/* 用 --step 计算位移，替换原固定 px 值 */
.tile.tile-position-1-1 {
  transform: translate3d(0, 0, 0);
}

.tile.tile-position-1-2 {
  transform: translate3d(0, var(--step), 0);
}

.tile.tile-position-1-3 {
  transform: translate3d(0, calc(var(--step) * 2), 0);
}

.tile.tile-position-1-4 {
  transform: translate3d(0, calc(var(--step) * 3), 0);
}

.tile.tile-position-2-1 {
  transform: translate3d(var(--step), 0, 0);
}

.tile.tile-position-2-2 {
  transform: translate3d(var(--step), var(--step), 0);
}

.tile.tile-position-2-3 {
  transform: translate3d(var(--step), calc(var(--step) * 2), 0);
}

.tile.tile-position-2-4 {
  transform: translate3d(var(--step), calc(var(--step) * 3), 0);
}

.tile.tile-position-3-1 {
  transform: translate3d(calc(var(--step) * 2), 0, 0);
}

.tile.tile-position-3-2 {
  transform: translate3d(calc(var(--step) * 2), var(--step), 0);
}

.tile.tile-position-3-3 {
  transform: translate3d(calc(var(--step) * 2), calc(var(--step) * 2), 0);
}

.tile.tile-position-3-4 {
  transform: translate3d(calc(var(--step) * 2), calc(var(--step) * 3), 0);
}

.tile.tile-position-4-1 {
  transform: translate3d(calc(var(--step) * 3), 0, 0);
}

.tile.tile-position-4-2 {
  transform: translate3d(calc(var(--step) * 3), var(--step), 0);
}

.tile.tile-position-4-3 {
  transform: translate3d(calc(var(--step) * 3), calc(var(--step) * 2), 0);
}

.tile.tile-position-4-4 {
  transform: translate3d(calc(var(--step) * 3), calc(var(--step) * 3), 0);
}

.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;
}

.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;
}

.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;
}

.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;
}

.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;
}

/* level-container 动态皮肤，随最大合成数字变化 */
.level-container.tile-2 {
  background: #eee4da;
  color: #776e65;
}

.level-container.tile-4 {
  background: #ede0c8;
  color: #776e65;
}

.level-container.tile-8 {
  background: #f2b179;
  color: #f9f6f2;
}

.level-container.tile-16 {
  background: #f59563;
  color: #f9f6f2;
}

.level-container.tile-32 {
  background: #f67c5f;
  color: #f9f6f2;
}

.level-container.tile-64 {
  background: #f65e3b;
  color: #f9f6f2;
}

.level-container.tile-128 {
  background: #edcf72;
  color: #f9f6f2;
}

.level-container.tile-256 {
  background: #edcc61;
  color: #f9f6f2;
}

.level-container.tile-512 {
  background: #edc850;
  color: #f9f6f2;
}

.level-container.tile-1024 {
  background: #edc53f;
  color: #f9f6f2;
}

.level-container.tile-2048 {
  background: #edc22e;
  color: #f9f6f2;
}

/* 超过 2048 用深色 */
.level-container.tile-super {
  background: #3c3a32;
  color: #edc22e;
}

/* 大数字方块字体响应式 */
.tile.tile-128 .tile-inner,
.tile.tile-256 .tile-inner,
.tile.tile-512 .tile-inner,
.tile.tile-1024 .tile-inner,
.tile.tile-2048 .tile-inner {
  font-size: clamp(18px, 6vmin, 45px);
}

.tile.tile-super .tile-inner {
  color: #edc22e;
  background: #3c3a32;
  font-size: clamp(20px, 4.5vmin, 40px);
}

@-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;
}

.above-game {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: clamp(12px, 3vmin, 25px);
  padding-top: clamp(12px, 5vw, 50px);
  text-align: center;
  opacity: 0;
  animation: fade-in-above-game 1500ms forwards;
}

@keyframes fade-in-above-game {
  to {
    opacity: 1;
  }
}

.above-game .more-button,
.above-game .restart-button {
  float: none !important;
  margin: 0;
}

.game-button {
  width: clamp(80px, 25vmin, 150px);
  height: clamp(40px, 7vmin, 60px);
  font-size: clamp(14px, 4vmin, 22px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(143, 122, 102, 0.3);
  color: #f9f6f2;
  border-radius: clamp(20px, 5vmin, 30px);
  padding: 0 12px;
  text-decoration: none;
  cursor: pointer;
  margin: 0;
  text-align: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
  transition: box-shadow 180ms ease, transform 120ms ease, filter 120ms ease;
  will-change: box-shadow, transform;
  position: relative;
  overflow: hidden;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* 涟漪伪元素 */
.game-button::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.45);
  transform: translate(var(--ripple-x, 50%), var(--ripple-y, 50%)) scale(0);
  opacity: 0;
  pointer-events: none;
}

/* 统一触发涟漪动画的类（桌面/触控都用） */
.game-button.ripple::after {
  animation: button-ripple 450ms ease-out;
}

/* 涟漪动画 */
@keyframes button-ripple {
  0% {
    transform: translate(var(--ripple-x, 50%), var(--ripple-y, 50%)) scale(0);
    opacity: .7;
  }

  100% {
    transform: translate(var(--ripple-x, 50%), var(--ripple-y, 50%)) scale(18);
    opacity: 0;
  }
}

.game-button:hover,
.game-button:focus-visible {
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
  filter: brightness(1.03);
  outline: none;
}

.game-button:active {
  transform: translateY(1px) scale(0.99);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
  filter: brightness(0.98);
}

/* 移动端点击反馈（粗指针且无 hover） */
@media (hover: none) and (pointer: coarse) {
  .game-button {
    -webkit-tap-highlight-color: transparent;
    position: relative;
    overflow: hidden;
    /* 让涟漪不溢出 */
  }

  .game-button:active,
  .game-button.pressed {
    transform: none;
    filter: none;
    box-shadow:
      0 2px 6px rgba(0, 0, 0, 0.12),
      /* 保留原外阴影 */
      inset 0 2px 6px rgba(0, 0, 0, 0.22);
    /* 新增内阴影 */
  }

  .game-button.pressed::after {
    animation: button-ripple 450ms ease-out;
  }
}

.more-button {
  background: rgba(242, 177, 121, 0.8);
}
.more-button:hover,
.more-button:focus-visible {
  background: #f59563;
}

.restart-button:hover,
.restart-button:focus-visible {
  background: rgba(143, 122, 102, 0.8);
}

.game-explanation {
  font-size: clamp(12px, 2.4vmin, 24px);
  line-height: clamp(18px, 4vmin, 28px);
  color: #bbada0;
}

.sharing {
  margin-top: 20px;
  text-align: center;
}

.sharing>iframe,
.sharing>span,
.sharing>form {
  display: inline-block;
  vertical-align: middle;
}

#result_div {
  position: fixed;
  /* 固定定位，覆盖全屏 */
  inset: 0;
  /* 等价于 top/right/bottom/left: 0 */
  background: rgba(0, 0, 0, 0.9);
  z-index: 10000;
  display: block;
  align-items: center;
  justify-content: center;
  padding: clamp(12px, 3vmin, 16px);
  box-sizing: border-box;
  opacity: 0;
  pointer-events: none;
  transition: opacity 1000ms ease;
  will-change: opacity;
}

#result_div.visible {
  opacity: 1;
  pointer-events: auto;
}

#result_div .result-content {
  width: clamp(240px, 75vmin, 600px);
  background: rgba(0, 0, 0, 0.3);
  border: 1px rgba(255, 255, 255, 0.3) solid;
  border-radius: 6px;
  padding: clamp(20px, 5vmin, 48px) clamp(12px, 3vmin, 24px);
  margin: 15vh auto 0 auto;
  text-align: center;
  position: relative;
  box-sizing: border-box;
}

#result_div .result-content i {
  position: absolute;
  top: -25px;
  right: -15px;
  width: clamp(29px, 6vmin, 44px);
  height: clamp(29px, 6vmin, 44px);
  border-radius: clamp(14.5px, 3vmin, 22px);
  background: url(close.png);
  background-size: clamp(29px, 6vmin, 44px) clamp(29px, 6vmin, 44px);
  background-color: #000;
  cursor: pointer;
  transform: translateY(10px);
  opacity: 1;
  transition: transform 300ms ease, opacity 300ms ease;
  will-change: transform, opacity;
}

#result_div .shareIcon {
  width: clamp(160px, 50vmin, 300px);
  height: auto;
}

#result_div .result-content center {
  line-height: 25px;
  font-size: 20px;
  margin-top: 12px;
  /* 调整为更紧凑的上边距 */
  color: #eee;
  display: block;
  /* 避免 <center> 的怪异行为 */
  text-align: center;
  transform: translateY(0);
  opacity: 1;
}

.medal_tips {
  font-size: clamp(14px, 4.5vmin, 22px);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
}

.medal_num {
  font-size: clamp(36px, 10vw, 72px);
  color: #fce700;
}

.medal_next {
  padding-top: 10px;
  color: #04e5f9;
}

.result_share {
  width: 100%;
  text-align: right;
}

/* 横屏适配：game-intro左，game-main右，heading纵向排列 */
@media (orientation: landscape) and (min-width: 480px) {
  .game-container {
    --size: calc(min(100dvw, 90dvh) - clamp(32px, 15vmin, 48px));
  }

  .container {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    justify-content: center;
    gap: clamp(16px, 5vw, 80px);
    max-width: none;
    width: auto;
  }

  .game-intro {
    flex: 1 1 320px;
    max-width: 380px;
    min-width: clamp(120px, 40%, 240px);
    width: 100%;
    margin: 0;
    padding: clamp(12px, 3vmin, 16px);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    gap: clamp(16px, 3vw, 32px);
  }

  .game-intro .heading {
    width: 100%;
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: clamp(8px, 2vw, 24px);
  }

  .game-main {
    flex: 0 0 auto;
    margin: 0;
    padding-right: clamp(12px, 3vmin, 16px);
    align-self: flex-start;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: auto;
  }

  .title h1 {
    font-size: clamp(48px, 10vw, 100px);
  }

  .game-intro .scores-container {
    width: 100%;
    justify-content: flex-start;
    gap: clamp(8px, 2vw, 24px);
  }

  .game-intro .level-container {
    width: 50%;
  }

  .game-intro .game-explanation {
    width: 100%;
    text-align: left;
    margin: 0;
    margin-top: clamp(8px, 2vw, 20px);
    color: #bbada0;
    font-size: clamp(12px, 3.2vmin, 28px);
    line-height: clamp(14px, 5vmin, 32px);
  }

  .above-game {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: clamp(12px, 3vmin, 25px);
    padding-top: clamp(8px, 2.5vmin, 16px);
    text-align: center;
    width: 100%;
    margin: 0 auto;
  }

  #result_div .result-content {
    width: clamp(280px, 80vmin, 500px);
    margin: 10vh auto 0 auto;
  }
}