/* 已限制在 #tool / .game-wrapper 作用域，避免污染 v2 yst-shell 布局 */
#tool * { -webkit-tap-highlight-color: transparent;
} #tool { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; display: flex; justify-content: center; align-items: flex-start; padding: 16px 10px; touch-action: pan-y; user-select: none; -webkit-user-select: none;
} .game-wrapper { background: #faf8ef; padding: 30px; border-radius: 16px; box-shadow: 0 10px 40px rgba(0,0,0,0.12); max-width: 580px; width: 100%;
} header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px;
} h1 { font-size: 56px; color: #776e65; font-weight: bold;
} .score-panel { display: flex; gap: 12px;
} .score-box { background: #bbada0; padding: 10px 24px; border-radius: 8px; text-align: center; min-width: 90px;
} .score-box .label { display: block; font-size: 13px; color: #eee4da; text-transform: uppercase;
} .score-box span:last-child { display: block; font-size: 26px; font-weight: bold; color: white;
} .controls { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; gap: 12px;
} .controls p { color: #776e65; flex: 1; font-size: 16px;
} .controls button { padding: 12px 22px; font-size: 15px; font-weight: bold; border: none; border-radius: 8px; cursor: pointer; transition: transform 0.1s, background 0.2s;
} #new-game { background: #8f7a66; color: white;
} #new-game:hover { background: #9f8b77;
} #sound-toggle { background: #cdc1b4; padding: 12px 14px; display: flex; align-items: center; justify-content: center;
} #sound-toggle svg { width: 22px; height: 22px; fill: #776e65;
} .controls button:active { transform: scale(0.95);
} #game-board { background: #bbada0; border-radius: 10px; padding: 14px; display: grid; grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(4, 1fr); gap: 14px; aspect-ratio: 1; position: relative; touch-action: none;
} .cell { background: rgba(238, 228, 218, 0.35); border-radius: 8px; display: flex; justify-content: center; align-items: center; font-size: 48px; font-weight: bold; color: #776e65; transition: all 0.12s ease; aspect-ratio: 1; min-width: 0; min-height: 0;
} /* 方块颜色 */
.cell[data-value="2"] { background: #eee4da; }
.cell[data-value="4"] { background: #ede0c8; }
.cell[data-value="8"] { background: #f2b179; color: white; }
.cell[data-value="16"] { background: #f59563; color: white; }
.cell[data-value="32"] { background: #f67c5f; color: white; }
.cell[data-value="64"] { background: #f65e3b; color: white; }
.cell[data-value="128"] { background: #edcf72; color: white; font-size: 38px; }
.cell[data-value="256"] { background: #edcc61; color: white; font-size: 38px; }
.cell[data-value="512"] { background: #edc850; color: white; font-size: 38px; }
.cell[data-value="1024"] { background: #edc53f; color: white; font-size: 32px; }
.cell[data-value="2048"] { background: #edc22e; color: white; font-size: 32px; }
.cell.super { background: #3c3a32; color: white; font-size: 28px; } /* 动画 */
.cell.new { animation: appear 0.2s ease;
} .cell.merged { animation: pop 0.2s ease;
} @keyframes appear { 0% { transform: scale(0); opacity: 0; } 100% { transform: scale(1); opacity: 1; }
} @keyframes pop { 0% { transform: scale(1); } 50% { transform: scale(1.15); } 100% { transform: scale(1); }
} /* 遮罩层 */
.overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); display: flex; justify-content: center; align-items: center; z-index: 100;
} .overlay.hidden { display: none;
} .message { background: white; padding: 40px 50px; border-radius: 16px; text-align: center; margin: 20px;
} .message h2 { color: #776e65; margin-bottom: 15px; font-size: 32px;
} .message p { color: #776e65; margin-bottom: 20px; font-size: 20px;
} .message button { padding: 14px 28px; font-size: 17px; font-weight: bold; border: none; border-radius: 8px; cursor: pointer; margin: 5px; background: #8f7a66; color: white;
} .message button:hover { background: #9f8b77;
} .message button:active { transform: scale(0.95);
} /* 移动端方向按钮 */
.mobile-controls { display: none; margin-top: 20px;
} .dpad { display: grid; grid-template-columns: repeat(3, 60px); grid-template-rows: repeat(3, 60px); gap: 8px; justify-content: center;
} .dpad button { background: #bbada0; border: none; border-radius: 10px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.1s;
} .dpad button:active { background: #8f7a66; transform: scale(0.95);
} .dpad button svg { width: 28px; height: 28px; fill: white;
} .dpad .empty { background: transparent;
} footer { margin-top: 20px; text-align: center; color: #776e65; font-size: 14px;
} footer p { margin-bottom: 10px;
} .links { font-size: 12px; color: #9a8b7c; padding-top: 12px; border-top: 1px solid #e0d6c8;
} .links a { color: #8f7a66; text-decoration: none; margin: 0 8px; transition: color 0.2s;
} .links a:hover { color: #f65e3b; text-decoration: underline;
} /* 移动端适配 */
@media (max-width: 600px) { body { padding: 5px; align-items: flex-start; padding-top: 10px; } .game-wrapper { padding: 15px; border-radius: 12px; } header { margin-bottom: 12px; } h1 { font-size: 42px; } .score-panel { gap: 8px; } .score-box { padding: 6px 14px; min-width: 70px; } .score-box .label { font-size: 11px; } .score-box span:last-child { font-size: 20px; } .controls { margin-bottom: 12px; gap: 8px; } .controls p { font-size: 14px; } .controls button { padding: 10px 16px; font-size: 14px; } #sound-toggle { padding: 10px 12px; } #game-board { padding: 10px; gap: 10px; border-radius: 8px; } .cell { font-size: 32px; border-radius: 6px; } .cell[data-value="128"], .cell[data-value="256"], .cell[data-value="512"] { font-size: 26px; } .cell[data-value="1024"], .cell[data-value="2048"] { font-size: 22px; } .cell.super { font-size: 18px; } .mobile-controls { display: block; } footer { margin-top: 15px; } footer p { font-size: 13px; } .links { font-size: 11px; } .links a { margin: 0 5px; }
} /* 超小屏幕 */
@media (max-width: 380px) { h1 { font-size: 36px; } .score-box { padding: 5px 10px; min-width: 60px; } .score-box span:last-child { font-size: 18px; } .controls p { font-size: 12px; } .cell { font-size: 26px; } .cell[data-value="128"], .cell[data-value="256"], .cell[data-value="512"] { font-size: 22px; } .cell[data-value="1024"], .cell[data-value="2048"] { font-size: 18px; } .cell.super { font-size: 14px; } .dpad { grid-template-columns: repeat(3, 50px); grid-template-rows: repeat(3, 50px); gap: 6px; } .dpad button svg { width: 24px; height: 24px; }
} /* 横屏模式 */
@media (max-height: 500px) and (orientation: landscape) { body { align-items: center; padding: 5px; } .game-wrapper { padding: 10px 20px; display: flex; flex-wrap: wrap; gap: 15px; max-width: 800px; } header, .controls, footer { width: 100%; } #game-board { width: 280px; height: 280px; } .mobile-controls { display: flex; align-items: center; margin-top: 0; } footer { display: none; }
}
