        :root {
            --bg-color: #2d2d2d;
            --container-bg: #3a3a3a;
            --cell-bg: #4a4a4a;
            --text-color: #f0f0f0;
            --border-color: #555;
            --button-bg: #ff6b6b;
            --button-hover: #ff5252;
            --title-color: #ff6b6b;
            --score-bg: #3a3a3a;
            --secondary-text: #aaa;
        }

        .light-theme {
            --bg-color: #f0f0f0;
            --container-bg: #e0e0e0;
            --cell-bg: #d0d0d0;
            --text-color: #333;
            --border-color: #bbb;
            --button-bg: #ff6b6b;
            --button-hover: #ff5252;
            --title-color: #ff6b6b;
            --score-bg: #e0e0e0;
            --secondary-text: #666;
        }

        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
            -webkit-tap-highlight-color: transparent;
        }

        body {
            font-family: 'Courier New', monospace;
            background-color: var(--bg-color);
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            color: var(--text-color);
            padding: 20px;
            transition: background-color 0.3s ease;
        }

        .container {
            max-width: 500px;
            width: 100%;
        }

        .header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
            flex-wrap: wrap;
        }

        h1 {
            font-size: 36px;
            color: var(--title-color);
            text-shadow: 2px 2px 0 #000;
            letter-spacing: 2px;
            margin-bottom: 10px;
        }

        .theme-switch {
            display: flex;
            align-items: center;
            margin-bottom: 10px;
        }

        .theme-label {
            margin-right: 10px;
            font-size: 14px;
            color: var(--secondary-text);
        }

        .switch {
            position: relative;
            display: inline-block;
            width: 50px;
            height: 24px;
        }

        .switch input {
            opacity: 0;
            width: 0;
            height: 0;
        }

        .slider {
            position: absolute;
            cursor: pointer;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background-color: #ccc;
            transition: .4s;
            border-radius: 24px;
        }

        .slider:before {
            position: absolute;
            content: "";
            height: 16px;
            width: 16px;
            left: 4px;
            bottom: 4px;
            background-color: white;
            transition: .4s;
            border-radius: 50%;
        }

        input:checked+.slider {
            background-color: var(--button-bg);
        }

        input:checked+.slider:before {
            transform: translateX(26px);
        }

        .scores {
            display: flex;
            gap: 15px;
            margin-bottom: 10px;
        }

        .score-container,
        .best-container {
            background: var(--score-bg);
            padding: 10px 15px;
            border-radius: 5px;
            text-align: center;
            border: 2px solid var(--border-color);
        }

        .score-title,
        .best-title {
            font-size: 14px;
            color: var(--secondary-text);
            margin-bottom: 5px;
        }

        .score-value,
        .best-value {
            font-size: 22px;
            font-weight: bold;
            color: var(--text-color);
        }

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

        .description {
            color: var(--secondary-text);
            font-size: 14px;
            line-height: 1.4;
            margin-bottom: 10px;
        }

        .restart-button {
            background: var(--button-bg);
            color: white;
            border: none;
            padding: 8px 15px;
            border-radius: 5px;
            font-family: 'Courier New', monospace;
            font-weight: bold;
            cursor: pointer;
            border: 2px solid #000;
            box-shadow: 2px 2px 0 #000;
        }

        .restart-button:hover {
            background: var(--button-hover);
        }

        .grid-container {
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            grid-gap: 10px;
            background-color: var(--container-bg);
            padding: 10px;
            border-radius: 5px;
            border: 4px solid var(--border-color);
            margin-bottom: 20px;
            position: relative;
            aspect-ratio: 1/1;
        }

        .cell {
            width: 100%;
            background: var(--cell-bg);
            border-radius: 3px;
            display: flex;
            justify-content: center;
            align-items: center;
            font-size: 24px;
            font-weight: bold;
            border: 2px solid var(--border-color);
            aspect-ratio: 1/1;
        }

        .tile {
            position: absolute;
            display: flex;
            justify-content: center;
            align-items: center;
            font-size: 24px;
            font-weight: bold;
            border-radius: 3px;
            transition: all 0.2s ease;
            border: 2px solid;
            z-index: 10;
            /* 确保像素块精确对齐 */
            transform: translate(0, 0);
        }

        /* 新增动画效果 */
        @keyframes appear {
            0% {
                transform: scale(0);
            }

            50% {
                transform: scale(1.1);
            }

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

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

            50% {
                transform: scale(1.2);
            }

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

        .tile-new {
            animation: appear 0.2s ease;
        }

        .tile-merged {
            animation: merge 0.3s ease;
            z-index: 20;
        }

        /* 不同数值的瓷砖样式 - 像素风配色 */
        .tile-2 {
            background: #6bcae2;
            color: #1a4a5a;
            border-color: #4a9db3;
        }

        .tile-4 {
            background: #a8e6cf;
            color: #3a6b59;
            border-color: #7dbb9e;
        }

        .tile-8 {
            background: #ffd93d;
            color: #6b5a1a;
            border-color: #ccab1f;
        }

        .tile-16 {
            background: #ff9a3d;
            color: #6b3a1a;
            border-color: #cc7a1f;
        }

        .tile-32 {
            background: #ff6b6b;
            color: #6b1a1a;
            border-color: #cc5252;
        }

        .tile-64 {
            background: #c44569;
            color: #fff;
            border-color: #9a3654;
        }

        .tile-128 {
            background: #786fa6;
            color: #fff;
            border-color: #5f5885;
            font-size: 22px;
        }

        .tile-256 {
            background: #574b90;
            color: #fff;
            border-color: #453a73;
            font-size: 22px;
        }

        .tile-512 {
            background: #f19066;
            color: #fff;
            border-color: #c47352;
            font-size: 22px;
        }

        .tile-1024 {
            background: #f5cd79;
            color: #6b5a1a;
            border-color: #c4a35f;
            font-size: 18px;
        }

        .tile-2048 {
            background: #ff7979;
            color: #fff;
            border-color: #cc6161;
            font-size: 18px;
        }

        .game-message {
            display: none;
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.8);
            border-radius: 5px;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            z-index: 100;
        }

        .game-message p {
            font-size: 32px;
            font-weight: bold;
            margin-bottom: 20px;
            color: #fff;
            text-shadow: 2px 2px 0 #000;
        }

        .game-message button {
            background: var(--button-bg);
            color: white;
            border: none;
            padding: 10px 20px;
            border-radius: 5px;
            font-family: 'Courier New', monospace;
            font-weight: bold;
            cursor: pointer;
            border: 2px solid #000;
            box-shadow: 2px 2px 0 #000;
        }

        .instructions {
            text-align: center;
            color: var(--secondary-text);
            font-size: 14px;
            line-height: 1.5;
        }

        .game-board {
            position: relative;
        }

        /* 移动设备优化 */
        .mobile-controls {
            display: none;
            grid-template-columns: repeat(3, 1fr);
            grid-template-rows: repeat(3, 1fr);
            gap: 5px;
            margin-top: 20px;
            aspect-ratio: 1/1;
            max-width: 150px;
            margin: 20px auto;
        }

        .control-btn {
            background: var(--container-bg);
            border: 2px solid var(--border-color);
            border-radius: 5px;
            display: flex;
            justify-content: center;
            align-items: center;
            font-size: 20px;
            color: var(--text-color);
            cursor: pointer;
            user-select: none;
        }

        .control-btn:active {
            background: var(--cell-bg);
        }

        .up-btn {
            grid-column: 2;
            grid-row: 1;
        }

        .down-btn {
            grid-column: 2;
            grid-row: 3;
        }

        .left-btn {
            grid-column: 1;
            grid-row: 2;
        }

        .right-btn {
            grid-column: 3;
            grid-row: 2;
        }

        @media (max-width: 768px) {
            .header {
                flex-direction: column;
                align-items: flex-start;
            }

            h1 {
                font-size: 28px;
            }

            .scores {
                width: 100%;
                justify-content: space-between;
            }

            .score-container,
            .best-container {
                flex: 1;
                min-width: 0;
            }

            .tile {
                font-size: 18px;
            }

            .tile-128,
            .tile-256,
            .tile-512 {
                font-size: 16px;
            }

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

            .mobile-controls {
                display: grid;
            }

            .game-info {
                flex-direction: column;
                align-items: flex-start;
            }

            .restart-button {
                margin-top: 10px;
            }
        }

        @media (max-width: 480px) {
            .container {
                padding: 10px;
            }

            h1 {
                font-size: 24px;
            }

            .score-value,
            .best-value {
                font-size: 18px;
            }

            .grid-container {
                grid-gap: 5px;
                padding: 5px;
            }

            .tile {
                font-size: 16px;
            }

            .tile-128,
            .tile-256,
            .tile-512 {
                font-size: 14px;
            }

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