* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* 支持iOS全屏 */
:root {
    --vh: 1vh;
}

html {
    height: 100%;
    overflow: hidden;
    /* 支持iOS Safari全屏 */
    position: fixed;
    width: 100%;
}

/* SVG滤镜容器 */
.svg-filters {
    position: absolute;
    width: 0;
    height: 0;
    pointer-events: none;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    background: #000;
    color: #776e65;
    font-size: 18px;
    line-height: 1.42857143;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    height: calc(var(--vh, 1vh) * 100); /* 使用自定义视口高度 */
    overflow: hidden;
    /* 使用flex布局实现垂直居中 */
    display: flex;
    align-items: center;
    justify-content: center;
    /* 使用safe-area-inset确保内容不被系统UI遮挡 */
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

/* 背景壁纸 - 默认浅色模式 */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url('asset/wallpaper/bg1.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: -1;
    transition: background-image 0.5s ease-in-out;
}

/* 暗黑模式背景 */
@media (prefers-color-scheme: dark) {
    body::before {
        background-image: url('asset/wallpaper/bg1.jpg');
    }
}

/* 浅色模式下的UI元素颜色 */
@media (prefers-color-scheme: light) {
    h1 {
        color: rgba(0, 0, 0, 0.85);
        text-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    }
    
    .score-label {
        color: rgba(0, 0, 0, 0.6);
    }
    
    .score, .best-score {
        color: rgba(0, 0, 0, 0.85);
        text-shadow: 0 1px 2px rgba(0,0,0,0.1);
    }
    
    .score-box .liquidGlass-tint {
        background: rgba(0, 0, 0, 0.06);
    }
    
    .btn-new .liquidGlass-tint,
    .btn-undo .liquidGlass-tint {
        background: rgba(0, 0, 0, 0.06);
    }
    
    .btn-new .liquidGlass-content,
    .btn-undo .liquidGlass-content {
        color: rgba(0, 0, 0, 0.85);
        text-shadow: 0 1px 2px rgba(0,0,0,0.1);
    }
    
    .btn-new:hover .liquidGlass-tint,
    .btn-undo:hover .liquidGlass-tint {
        background: rgba(0, 0, 0, 0.1);
    }
    
    .btn-undo.disabled .liquidGlass-tint {
        background: rgba(0, 0, 0, 0.03);
    }
    
    .btn-undo.disabled:hover .liquidGlass-tint {
        background: rgba(0, 0, 0, 0.03);
    }
    
    .game-container::before {
        background: rgba(0, 0, 0, 0.08);
    }
    
    .game-container::after {
        box-shadow: 
            inset 2px 2px 4px rgba(255, 255, 255, 0.5),
            inset -2px -2px 4px rgba(0, 0, 0, 0.05);
    }
    
    .instructions {
        color: rgba(0, 0, 0, 0.6);
        background: rgba(0, 0, 0, 0.04);
        border: 1px solid rgba(0, 0, 0, 0.08);
    }
    
    .liquidGlass-shine {
        box-shadow: 
            inset 0 1px 1px rgba(255, 255, 255, 0.8),
            inset 1px 0 1px rgba(255, 255, 255, 0.8),
            inset -0.5px -0.5px 1px rgba(255, 255, 255, 0.3);
    }
}

.container {
    width: 100%;
    max-width: 100vw;
    height: 100%;
    padding: 20px;
    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.main-content {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative; /* 用于game-message定位 */
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    flex-shrink: 0;
    padding: 0 10px; /* 为header添加一些内边距 */
}

.header .score-container {
    flex-grow: 1;
    display: flex;
    justify-content: flex-end; /* 将分数框推到右边 */
    gap: 15px;
}

.footer {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 15px;
    flex-shrink: 0; /* 防止footer被压缩 */
}

.footer .controls {
    display: flex;
    justify-content: center;
    gap: 20px;
    width: 100%;
}

.footer .btn-new, 
.footer .btn-undo {
    margin-right: 0; /* 移除旧的右边距 */
}

h1 {
    color: rgba(255, 255, 255, 0.9);
    font-size: 60px;
    font-weight: bold;
    margin: 0;
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    flex-shrink: 0;
}

.header .btn-new {
    flex-shrink: 0;
}

.score-container {
    display: flex;
    gap: 15px;
    align-items: flex-start;
}

.score-box {
    display: block;
    position: relative;
    margin-left: 0;
    --ui-border-radius: 10px;
    border-radius: var(--ui-border-radius);
    overflow: hidden;
    /* 设置固定宽度确保两个分数框大小一致 */
    width: 120px;
    /* 移除旧样式 */
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: none;
    padding: 0;
    box-shadow: none;
}

/* 分数框的液态玻璃层样式 */
.score-box .liquidGlass-effect {
    border-radius: var(--ui-border-radius);
}

.score-box .liquidGlass-tint {
    background: rgba(255, 255, 255, 0.08);
    border-radius: var(--ui-border-radius);
}

.score-box .liquidGlass-shine {
    border-radius: var(--ui-border-radius);
}

.score-box .liquidGlass-content {
    position: relative;
    z-index: 3;
    padding: 10px 20px;
    text-align: center;
}

.score-label {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.8);
    text-transform: uppercase;
}

.score, .best-score {
    font-size: 25px;
    font-weight: bold;
    color: white;
    margin-top: 5px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

.controls {
    display: none; /* 隐藏旧的controls容器 */
}

.btn-new, .btn-undo {
    position: relative;
    display: inline-block;
    margin-right: 10px;
    --ui-border-radius: 10px;
    border-radius: var(--ui-border-radius);
    overflow: hidden;
    cursor: pointer;
    /* 设置最小宽度确保两个按钮大小一致 */
    min-width: 120px;
    /* 移除旧样式 */
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: none;
    padding: 0;
    box-shadow: none;
    transition: all 0.3s;
}

/* 修复：按钮使用inline-flex而不是flex，以保持水平排列 */
.btn-new.liquidGlass-wrapper, 
.btn-undo.liquidGlass-wrapper {
    display: inline-flex;
}

/* 按钮的液态玻璃层样式 */
.btn-new .liquidGlass-effect,
.btn-undo .liquidGlass-effect {
    border-radius: var(--ui-border-radius);
}

.btn-new .liquidGlass-tint,
.btn-undo .liquidGlass-tint {
    background: rgba(255, 255, 255, 0.08);
    border-radius: var(--ui-border-radius);
    transition: background 0.3s;
}

.btn-new .liquidGlass-shine,
.btn-undo .liquidGlass-shine {
    border-radius: var(--ui-border-radius);
}

.btn-new .liquidGlass-content,
.btn-undo .liquidGlass-content {
    position: relative;
    z-index: 3;
    padding: 10px 20px;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 600;
    font-size: 16px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

.btn-new:hover .liquidGlass-tint,
.btn-undo:hover .liquidGlass-tint {
    background: rgba(255, 255, 255, 0.12);
}

.btn-new:hover,
.btn-undo:hover {
    transform: translateY(-1px);
}

.btn-undo.disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.btn-undo.disabled .liquidGlass-tint {
    background: rgba(255, 255, 255, 0.03);
}

.btn-undo.disabled:hover {
    transform: none;
}

.btn-undo.disabled:hover .liquidGlass-tint {
    background: rgba(255, 255, 255, 0.03);
}

/* 游戏容器 - 液态玻璃效果 */
.game-container {
    position: relative;
    background: transparent;
    border-radius: 20px;
    width: 100%;
    /* 高度和宽度都与可用空间的较小值相关，确保是正方形并尽可能大 */
    max-width: min(450px, 90vw, 80vh);
    margin: 0 auto;
    padding: 10px;
    overflow: visible;
    flex: 0 0 auto;
    aspect-ratio: 1; /* 保持1:1的宽高比 */
}

/* 移除旧的液态玻璃效果层 */
.liquid-glass-effect {
    display: none;
}

/* 游戏容器的玻璃外框 */
.game-container::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 1;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    pointer-events: none;
}

/* 游戏容器的光泽效果 */
.game-container::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 2;
    border-radius: 20px;
    box-shadow: 
        inset 2px 2px 4px rgba(255, 255, 255, 0.2),
        inset -2px -2px 4px rgba(0, 0, 0, 0.1);
    pointer-events: none;
}

/* 游戏网格容器 */
.grid-container {
    position: relative;
    background: transparent;
    border-radius: 10px;
    width: 100%;
    aspect-ratio: 1;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 10px;
    padding: 10px;
    z-index: 3;  /* 在液态效果层之上 */
}

.grid-row {
    display: contents;
}

/* 游戏格子背景 */
.grid-cell {
    display: none;
}

/* 方块容器 */
.tile-container {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    bottom: 10px;
    z-index: 4;  /* 在网格之上 */
}

/* 统一的液态玻璃容器样式 */
.liquidGlass-wrapper {
    position: relative;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    cursor: pointer;
    background: transparent;
    border: none;
    padding: 0;
    box-shadow: none;
    transition: all 0.3s;
}

/* 统一的内部图层样式 */
.liquidGlass-wrapper > .liquidGlass-effect,
.liquidGlass-wrapper > .liquidGlass-tint,
.liquidGlass-wrapper > .liquidGlass-shine,
.liquidGlass-wrapper > .liquidGlass-content {
    position: absolute;
    inset: 0;
    border-radius: var(--ui-border-radius, 10px);
}

.liquidGlass-wrapper > .liquidGlass-effect {
    z-index: 0;
    backdrop-filter: blur(5px) saturate(120%);
    -webkit-backdrop-filter: blur(5px) saturate(120%);
    filter: url(#glass-distortion);
}

.liquidGlass-wrapper > .liquidGlass-tint {
    z-index: 1;
    background: rgba(255, 255, 255, 0.08);
    transition: background 0.3s;
}

.liquidGlass-wrapper > .liquidGlass-shine {
    z-index: 2;
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.6), inset 1px 0 1px rgba(255, 255, 255, 0.6), inset -0.5px -0.5px 1px rgba(255, 255, 255, 0.15);
}

.liquidGlass-wrapper > .liquidGlass-content {
    position: relative;
    z-index: 3;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 10px 20px;
}

/* 移除旧的、分散的样式 */
.score-box, .btn-new, .btn-undo {
    /* 样式已由 .liquidGlass-wrapper 统一处理 */
}
.score-box .liquidGlass-effect, .score-box .liquidGlass-tint, .score-box .liquidGlass-shine, .score-box .liquidGlass-content,
.btn-new .liquidGlass-effect, .btn-new .liquidGlass-tint, .btn-new .liquidGlass-shine, .btn-new .liquidGlass-content,
.btn-undo .liquidGlass-effect, .btn-undo .liquidGlass-tint, .btn-undo .liquidGlass-shine, .btn-undo .liquidGlass-content {
    /* 不再需要单独定义 */
}

/* 数字方块样式 - 严格按照示例结构 */
.tile {
    position: absolute;
    width: calc((100% - 30px) / 4);
    height: calc((100% - 30px) / 4);
    /* 分离不同属性的过渡效果 */
    transition: 
        top 0.12s cubic-bezier(0.25, 0.46, 0.45, 0.94),
        left 0.12s cubic-bezier(0.25, 0.46, 0.45, 0.94),
        transform 0.08s ease-out,
        border-radius 0.4s cubic-bezier(0.175, 0.885, 0.32, 2.2);
    
    /* 定义并使用CSS变量来统一控制圆角 */
    --tile-border-radius: 18px;
    border-radius: var(--tile-border-radius);
    
    /* 继承自 liquidGlass-wrapper 的样式 */
    display: flex;
    font-weight: 600;
    overflow: hidden;
    cursor: pointer;
    /* 移除外部阴影，更贴近iOS设计 */
    /* box-shadow: 0 6px 6px rgba(0, 0, 0, 0.2), 0 0 20px rgba(0, 0, 0, 0.1); */

    /* 移除旧样式 */
    background: transparent;
    border: none;
    line-height: 1; /* 确保flex生效 */
    
    /* 启用硬件加速 */
    will-change: transform;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

/* 拖动时的特殊样式 */
.tile.dragging {
    transition: transform 0.05s linear !important;
    will-change: transform;
}

/* 移动时的特殊样式 - 使用与键盘操作相同的时间 */
.tile.moving {
    transition: 
        top 0.12s cubic-bezier(0.25, 0.46, 0.45, 0.94),
        left 0.12s cubic-bezier(0.25, 0.46, 0.45, 0.94),
        transform 0.12s cubic-bezier(0.25, 0.46, 0.45, 0.94) !important;
}

/* 拖动状态下的容器效果 */
.tile-container.dragging-active {
    transition: opacity 0.2s ease;
}

/* 移动设备上的性能优化 */
@media (max-width: 520px) {
    /* 在移动设备上简化动画 */
    .tile.dragging {
        transition: none !important;
    }
    
    /* 移除拖动时的阴影效果 */
    .tile.dragging .liquidGlass-effect {
        filter: url(#glass-distortion);
    }
}

/* 移除拖动时的透明效果 - 保持所有砖块外观一致 */
/* .tile-container.dragging-active .tile:not(.dragging) {
    opacity: 0.7;
} */

/* 为拖动的砖块添加阴影效果 */
.tile.dragging {
    z-index: 100;
}

.tile.dragging .liquidGlass-effect {
    filter: url(#glass-distortion) drop-shadow(0 8px 20px rgba(0, 0, 0, 0.3));
}

.tile.dragging .liquidGlass-shine {
    box-shadow: 
        inset 0 1px 2px rgba(255, 255, 255, 0.8),
        inset 1px 0 2px rgba(255, 255, 255, 0.8),
        inset -0.5px -0.5px 1px rgba(255, 255, 255, 0.3);
}

/* 游戏方块的内部图层样式 */
.tile .liquidGlass-effect {
  position: absolute;
  z-index: 0;
  inset: 0;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  filter: url(#glass-distortion);
  overflow: hidden;
  isolation: isolate;
  display: block !important;
  border-radius: var(--tile-border-radius);
  transition: border-radius 0.4s cubic-bezier(0.175, 0.885, 0.32, 2.2);
}

.tile .liquidGlass-tint {
  z-index: 1;
  position: absolute;
  inset: 0;
  border-radius: var(--tile-border-radius);
  transition: border-radius 0.4s cubic-bezier(0.175, 0.885, 0.32, 2.2);
}

.tile .liquidGlass-shine {
  position: absolute;
  inset: 0; /* Changed back to 0 to ensure full coverage */
  z-index: 2;
  overflow: hidden;
  /* Asymmetrical highlight mimicking a top-left light source */
  box-shadow: 
    /* Separate highlights for top and left edges for better corner rendering */
    inset 0 1px 1px rgba(255, 255, 255, 0.6), /* Top edge highlight */
    inset 1px 0 1px rgba(255, 255, 255, 0.6), /* Left edge highlight */
    /* Faint highlight from bottom-right */
    inset -0.5px -0.5px 1px rgba(255, 255, 255, 0.15);
  border-radius: var(--tile-border-radius);
  transition: border-radius 0.4s cubic-bezier(0.175, 0.885, 0.32, 2.2);
}

/* This gradient conflicts with the new asymmetrical lighting, so it's removed. */
.tile .liquidGlass-shine::before {
  display: none;
}

.tile .liquidGlass-text {
  z-index: 3;
  font-size: 55px;
  font-weight: bold;
  color: white;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-shadow: 0 1px 3px rgba(0,0,0,0.4);
  border-radius: var(--tile-border-radius);
  transition: border-radius 0.4s cubic-bezier(0.175, 0.885, 0.32, 2.2);
}

/* 移除悬停效果 */
/*
.tile:hover {
    transform: scale(1.05);
    --tile-border-radius: 24px;
}
*/

/* 移除所有旧的方块样式 */
.tile::before,
.tile::after {
    display: none;
}

/* 不同数字的颜色 - 只应用到 tint 层 */
.tile-2 .liquidGlass-tint { background: rgba(238, 228, 218, 0.25); }
.tile-4 .liquidGlass-tint { background: rgba(237, 224, 200, 0.25); }
.tile-8 .liquidGlass-tint { background: rgba(242, 177, 121, 0.35); }
.tile-16 .liquidGlass-tint { background: rgba(245, 149, 99, 0.45); }
.tile-32 .liquidGlass-tint { background: rgba(246, 124, 95, 0.55); }
.tile-64 .liquidGlass-tint { background: rgba(246, 94, 59, 0.65); }
.tile-128 .liquidGlass-tint { background: rgba(237, 207, 114, 0.45); }
.tile-256 .liquidGlass-tint { background: rgba(237, 204, 97, 0.55); }
.tile-512 .liquidGlass-tint { background: rgba(237, 200, 80, 0.65); }
.tile-1024 .liquidGlass-tint { background: rgba(237, 197, 63, 0.75); }
.tile-2048 .liquidGlass-tint { background: rgba(237, 194, 46, 0.85); }

/* 为高数值方块设置浅色文字 */
.tile-8 .liquidGlass-text,
.tile-16 .liquidGlass-text,
.tile-32 .liquidGlass-text,
.tile-64 .liquidGlass-text,
.tile-128 .liquidGlass-text,
.tile-256 .liquidGlass-text,
.tile-512 .liquidGlass-text,
.tile-1024 .liquidGlass-text,
.tile-2048 .liquidGlass-text {
    color: #f9f6f2;
}

/* 调整字体大小 */
.tile-128 .liquidGlass-text,
.tile-256 .liquidGlass-text,
.tile-512 .liquidGlass-text {
    font-size: 45px;
}
.tile-1024 .liquidGlass-text,
.tile-2048 .liquidGlass-text {
    font-size: 35px;
}

/* 移除旧的颜色定义 */
.tile-2, .tile-4, .tile-8, .tile-16, .tile-32, .tile-64,
.tile-128, .tile-256, .tile-512, .tile-1024, .tile-2048 {
    background: none;
    color: transparent; /* 文字颜色由 .liquidGlass-text 控制 */
    text-shadow: none;
}

/* 新增方块动画 */
.tile-new {
    animation: appear 0.2s ease-in-out;
}

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

/* 合并方块动画 */
.tile-merged {
    animation: pop 0.2s ease-in-out;
}

@keyframes pop {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.15);
    }
    100% {
        transform: scale(1);
    }
}

/* Undo动画 - 方块消失 */
.tile-disappear {
    animation: disappear 0.15s ease-in-out;
}

@keyframes disappear {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: scale(0.5);
    }
}

/* Undo动画 - 方块重新出现（分裂效果） */
.tile-reappear {
    animation: reappear 0.2s ease-in-out;
}

@keyframes reappear {
    0% {
        opacity: 0;
        transform: scale(1.2) rotate(180deg);
    }
    50% {
        opacity: 0.8;
        transform: scale(0.9) rotate(90deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
}

/* 游戏结束/通关画面 */
.game-message {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 100;
    text-align: center;
    border-radius: 20px;
    max-width: none; /* 移除最大宽度限制 */
    max-height: none; /* 移除最大高度限制 */
}

.game-message p {
    font-size: 60px;
    font-weight: bold;
    height: 60px;
    line-height: 60px;
    margin-top: 200px;
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.game-message.game-won {
    background: rgba(237, 194, 46, 0.1); /* 更淡的金色 */
    backdrop-filter: blur(25px) saturate(160%);
    -webkit-backdrop-filter: blur(25px) saturate(160%);
    color: #ffd400;
}

.game-message.game-over,
.game-message.game-stuck {
    background: rgba(30, 40, 60, 0.15); /* 更淡的深色背景 */
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    color: rgba(255, 255, 255, 0.9);
}

.game-message.game-stuck .restart-button {
    display: inline-block; /* 确保按钮可见 */
}

.message-buttons {
    display: flex;
    gap: 15px; /* 按钮之间的间距 */
    margin-top: 20px;
}

.restart-button {
    display: inline-block;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    padding: 10px 30px;
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    font-weight: 600;
    margin-top: 30px;
    cursor: pointer;
    font-size: 18px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    transition: all 0.3s;
}

.restart-button:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 6px 30px rgba(0, 0, 0, 0.4);
}

.instructions {
    margin-top: 20px;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.7);
    font-size: 16px;
    text-align: center;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 15px;
    flex-shrink: 0; /* 不要收缩 */
}

/* 响应式设计 */
@media screen and (max-width: 520px) {
    .container {
        padding: 10px;
        padding-left: max(10px, env(safe-area-inset-left));
        padding-right: max(10px, env(safe-area-inset-right));
    }
    
    .header {
        flex-wrap: wrap;
        justify-content: center;
        gap: 15px;
    }
    
    h1 {
        font-size: 35px; /* 进一步减小标题字体 */
    }
    
    .score-container {
        gap: 8px; /* 减小分数框之间的间距 */
    }
    
    .score-box {
        margin-left: 0;
        --ui-border-radius: 8px;
        width: 85px; /* 减小分数框宽度 */
    }
    
    .score-box .liquidGlass-content {
        padding: 6px 10px; /* 减小内边距 */
    }
    
    .score-label {
        font-size: 10px; /* 减小标签字体 */
    }
    
    .score, .best-score {
        font-size: 18px; /* 减小分数字体 */
    }
    
    .controls {
        margin-bottom: 15px; /* 减小底部间距 */
    }
    
    .btn-new, .btn-undo {
        margin-right: 5px;
        --ui-border-radius: 8px;
        min-width: 100px;
    }
    
    .btn-new .liquidGlass-content,
    .btn-undo .liquidGlass-content {
        padding: 8px 15px;
        font-size: 14px;
    }
    
    .game-container {
        padding: 8px;
    }
    
    .grid-container {
        gap: 8px;
    }
    
    .tile {
        width: calc((100% - 24px) / 4);
        height: calc((100% - 24px) / 4);
        /* 在移动端使用较小的圆角 */
        --tile-border-radius: 12px;
    }
    
    .liquidGlass-text {
        font-size: 35px;
    }
    
    .tile-128 .liquidGlass-text,
    .tile-256 .liquidGlass-text,
    .tile-512 .liquidGlass-text {
        font-size: 30px;
    }
    
    .tile-1024 .liquidGlass-text,
    .tile-2048 .liquidGlass-text {
        font-size: 25px;
    }
    
    .game-message p {
        font-size: 40px;
        margin-top: 150px;
    }
    
    .instructions {
        font-size: 13px;
        padding: 10px;
        margin-top: 15px;
    }
    
    /* 在更小的屏幕上隐藏游戏说明 */
    @media screen and (max-height: 700px) {
        .instructions {
            display: none;
        }
    }
}

/* 针对iPhone等更小屏幕的特殊优化 */
@media screen and (max-width: 400px) {
    h1 {
        font-size: 32px;
    }
    
    .score-box {
        width: 80px;
    }
    
    .score-box .liquidGlass-content {
        padding: 5px 8px;
    }
    
    .score-label {
        font-size: 9px;
    }
    
    .score, .best-score {
        font-size: 16px;
    }
}

/* 触摸设备优化 */
@media (hover: none) {
    .btn-new:hover .liquidGlass-tint,
    .btn-undo:hover .liquidGlass-tint {
        background: rgba(255, 255, 255, 0.08);
    }
    
    .btn-new:hover,
    .btn-undo:hover {
        transform: none;
    }
}

/* 不支持backdrop-filter的浏览器降级方案 */
@supports not (backdrop-filter: blur(1px)) {
    .tile {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        background: rgba(255, 255, 255, 0.15) !important;
    }
    
    .score-box .liquidGlass-tint,
    .btn-new .liquidGlass-tint,
    .btn-undo .liquidGlass-tint {
        background: rgba(30, 30, 30, 0.9) !important;
    }
    
    .game-container,
    .instructions {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        background: rgba(30, 30, 30, 0.9) !important;
    }
}

/* 减少动画模式 */
@media (prefers-reduced-motion: reduce) {
    .tile {
        animation-play-state: paused !important;
        transition: none !important;
    }
}

/* 防止文本选择 */
.game-container {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

/* 分数增加动画 */
.score-addition {
    position: absolute;
    right: 20px;
    color: #776e65;
    font-size: 20px;
    font-weight: bold;
    animation: score-addition 0.8s ease-in-out;
    z-index: 20;
}

@keyframes score-addition {
    0% {
        opacity: 1;
        transform: translateY(0);
    }
    100% {
        opacity: 0;
        transform: translateY(-50px);
    }
}

/* Undo奖励动画 */
.undo-reward {
    position: absolute;
    right: 20px;
    top: 80px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.9);
    padding: 8px 16px;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    animation: undo-reward 1s ease-in-out;
    z-index: 30;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

@keyframes undo-reward {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    20% {
        opacity: 1;
        transform: translateY(0);
    }
    80% {
        opacity: 1;
        transform: translateY(0);
    }
    100% {
        opacity: 0;
        transform: translateY(-20px);
    }
}

/* 合并动画 - 不再使用液化效果 */
@keyframes liquidMerge {
    0% {
        transform: scale(1) rotate(0deg);
    }
    50% {
        transform: scale(1.3) rotate(180deg);
    }
    100% {
        transform: scale(1) rotate(360deg);
    }
}

/* LIQUID GLASS STYLES - 为UI元素创建独立的wrapper */
.ui-liquid-wrapper {
    position: relative;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    cursor: pointer;
    background: transparent;
    border: none;
    padding: 0;
    box-shadow: none;
    transition: all 0.3s;
}

.ui-liquid-wrapper > .liquidGlass-effect,
.ui-liquid-wrapper > .liquidGlass-tint,
.ui-liquid-wrapper > .liquidGlass-shine,
.ui-liquid-wrapper > .liquidGlass-content {
    position: absolute;
    inset: 0;
    border-radius: var(--ui-border-radius, 10px);
}

.ui-liquid-wrapper > .liquidGlass-effect {
    z-index: 0;
    backdrop-filter: blur(5px) saturate(120%);
    -webkit-backdrop-filter: blur(5px) saturate(120%);
    filter: url(#glass-distortion);
}

.ui-liquid-wrapper > .liquidGlass-tint {
    z-index: 1;
    background: rgba(255, 255, 255, 0.08);
    transition: background 0.3s;
}

.ui-liquid-wrapper > .liquidGlass-shine {
    z-index: 2;
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.6), inset 1px 0 1px rgba(255, 255, 255, 0.6), inset -0.5px -0.5px 1px rgba(255, 255, 255, 0.15);
}

.ui-liquid-wrapper > .liquidGlass-content {
    position: relative;
    z-index: 3;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 10px 20px;
}

/* 恢复游戏方块的原始样式 */
.tile.liquidGlass-wrapper {
    /* 保持原来的样式 */
} 