/* 马卡龙色彩方案 */
html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    position: fixed;
    touch-action: none;
}

body {
    display: flex;
    justify-content: center;
    background: #FFF8DC;
    /* 淡黄色 */
    font-family: 'Comic Sans MS', Arial, sans-serif;
    color: #5a4a5a;
    box-sizing: border-box;
}

.game-container {
    position: relative;
    width: 100%;
    max-width: 800px;
    height: 100vh;
    margin: 0 auto;
    background: #FFF8DC;
    padding: 10px;
    box-sizing: border-box;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
}

.grid-container {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(5, 1fr);
    gap: 8px;
    background: #F0E6C8;
    /* 深一点的淡黄色 */
    padding: 10px;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(160, 120, 160, 0.2);
    width: 100%;
    max-width: 500px;
    aspect-ratio: 1;
    margin: 1rem auto;
}

.cell {
    border-radius: 8px;
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
    font-size: clamp(14px, 4vw, 20px);
    font-weight: bold;
    color: #5a4a5a;
    transition: all 0.2s ease;
    background-size: cover;
    background-position: center;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.cell span {
    z-index: 2;
    text-shadow: 0px 0px 5px white, 0px 0px 5px white, 0px 0px 5px white;
    font-weight: bold;
    padding: 2px 4px;
    margin: 2px;
}

/* 动物背景的数字方案 */
.cell-2 {
    background-color: #fce8e8;
    /* 浅粉色 - 兔子背景 */
    background-image: url('image/bunny.jpeg');
    background-size: cover;
    background-position: center;
}

.cell-4 {
    background-color: #e8fcf8;
    /* 浅绿色 - 鸭子背景 */
    background-image: url('image/duck.jpeg');
    background-size: cover;
    background-position: center;
}

.cell-8 {
    background-color: #fcf8e8;
    /* 浅黄色 - 狗狗背景 */
    background-image: url('image/puppy.jpeg');
    background-size: cover;
    background-position: center;
    color: #5a4a3a;
}

.cell-16 {
    background-color: #f8e8fc;
    /* 淡紫色 - 猫咪背景 */
    background-image: url('image/cat.jpeg');
    background-size: cover;
    background-position: center;
    color: #4a3a5a;
}

.cell-32 {
    background-color: #e8f8fc;
    /* 浅蓝色 - 企鹅背景 */
    background-image: url('image/otter pup.jpeg');
    background-size: cover;
    background-position: center;
    color: #3a4a5a;
}

.cell-64 {
    background-color: #fcf0e8;
    /* 橙色 - 狐狸背景 */
    background-image: url('./image/fox.jpeg');
    background-size: cover;
    background-position: center;
    color: #5a3a2a;
}

.cell-128 {
    background-color: #e8ecfc;
    /* 淡蓝色 - 熊猫背景 */
    background-image: url('image/squirrel.jpeg');
    background-size: cover;
    background-position: center;
    color: #3a3a5a;
    font-size: 18px;
}

.cell-256 {
    background-color: #f0fce8;
    /* 淡绿色 - 青蛙背景 */
    background-image: url('image/deer.jpeg');
    background-size: cover;
    background-position: center;
    color: #3a5a2a;
}

.cell-512 {
    background-color: #fce8ec;
    /* 粉红色 - 猪背景 */
    background-image: url('image/hedgehog.jpeg');
    background-size: cover;
    background-position: center;
    color: #5a2a3a;
}

.cell-1024 {
    background-color: #c8e8f0;
    /* 蓝绿色 - 鱼背景 */
    background-image: url('image/alpaca.jpeg');
    background-size: cover;
    background-position: center;
    color: #2a3a5a;
    font-size: 16px;
}

.cell-2048 {
    background-color: #f8d8c8;
    /* 橙色 - 狮子背景 */
    background-image: url('image/lion.jpeg');
    background-size: cover;
    background-position: center;
    color: #5a2a1a;
}

.cell-4096 {
    background-color: #e8d8f8;
    /* 紫色 - 大象背景 */
    background-image: url('image/elephant.jpeg');
    background-size: cover;
    background-position: center;
    color: #3a1a5a;
}

.cell-8192 {
    background-color: #c8f8d8;
    /* 薄荷绿 - 变色龙背景 */
    background-image: url('image/lamb.jpeg');
    background-size: cover;
    background-position: center;
    color: #1a5a3a;
}

.cell-16384 {
    background-color: #f8f8d8;
    /* 淡黄色 - 长颈鹿背景 */
    background-image: url('image/bear.jpeg');
    background-size: cover;
    background-position: center;
    color: #5a5a1a;
    font-size: 14px;
}

.cell-32768 {
    background-color: #d8c8e0;
    /* 淡紫色 - 蝴蝶背景 */
    background-image: url('image/tiger.jpeg');
    background-size: cover;
    background-position: center;
    color: #3a1a5a;
    font-size: 14px;
}

.cell-65536 {
    background-color: #f0c8d8;
    /* 粉色 - 孔雀背景 */
    background-image: url('image/panda.jpeg');
    background-size: cover;
    background-position: center;
    color: #5a1a3a;
    font-size: 14px;
}

.score-panel {
    text-align: center;
    margin: 0.5rem 0;
    font-size: clamp(0.8rem, 3vw, 1.2rem);
    color: #ffb6c1;
    text-shadow: 1px 1px 2px rgba(255, 182, 193, 0.3);
    font-family: 'Comic Sans MS', cursive, Arial, sans-serif;
}

.scores {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 576px;
    margin: 0 auto;
    gap: 12px;
}

.score-box {
    background: linear-gradient(145deg, #F0E6C8, #FFF8DC);
    padding: clamp(8px, 2vw, 12px) clamp(12px, 3vw, 20px);
    border-radius: 12px;
    color: #5a4a5a;
    box-shadow: 0 4px 12px rgba(160, 120, 160, 0.2);
    flex: 1;
}

.score-title {
    font-size: clamp(12px, 3vw, 14px);
    text-transform: uppercase;
    font-weight: bold;
}

.score-value {
    font-size: clamp(18px, 5vw, 24px);
    font-weight: bold;
}

/* 功能按钮 */
.control-panel {
    margin: 0.8rem 0;
    display: flex;
    gap: 1rem;
    justify-content: center;
}

button {
    padding: 10px 20px;
    background: linear-gradient(145deg, #F0E6C8, #FFF8DC);
    border: none;
    border-radius: 12px;
    color: #5a4a5a;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: bold;
    font-size: 16px;
    box-shadow: 0 4px 12px rgba(160, 120, 160, 0.2);
}

button:hover {
    background: linear-gradient(145deg, #FFF8DC, #FFFFF0);
    /* 更亮的淡黄色渐变 */
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(160, 120, 160, 0.3);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.game-over {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 248, 220, 0.85);
    /* 半透明淡黄色 */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    animation: fadeIn 0.8s ease;
    border-radius: 12px;
    box-shadow: inset 0 0 30px rgba(160, 120, 160, 0.4);
}

.game-over h2 {
    font-size: 3rem;
    color: #5a4a5a;
    margin-bottom: 0;
    text-shadow: 2px 2px 8px rgba(160, 120, 160, 0.4);
}

.game-over p {
    font-size: 1.5rem;
    color: #5a4a5a;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* 添加动画效果 */
.tile-new {
    animation: appear 0.3s ease-in-out;
}

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

    60% {
        transform: scale(1.1);
    }

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

/* 优化得分特效 */
.score-animation {
    position: absolute;
    font-size: 28px;
    font-weight: bold;
    color: #ff69b4;
    text-shadow: 0px 0px 5px white, 0px 0px 10px rgba(255, 105, 180, 0.5);
    pointer-events: none;
    z-index: 100;
    animation: floatUp 1.5s ease-out forwards;
    transform-origin: center;
}

@keyframes floatUp {
    0% {
        transform: translateY(0) scale(0.8) rotate(-10deg);
        opacity: 0;
    }

    20% {
        transform: translateY(-20px) scale(1.2) rotate(0deg);
        opacity: 1;
    }

    40% {
        transform: translateY(-40px) scale(1.1) rotate(5deg);
        opacity: 1;
    }

    100% {
        transform: translateY(-80px) scale(1) rotate(0deg);
        opacity: 0;
    }
}

/* 添加合并特效 */
.merge-animation {
    animation: merge 0.3s ease-in-out;
    position: relative;
}

@keyframes merge {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 rgba(255, 105, 180, 0.5);
    }

    50% {
        transform: scale(1.2);
        box-shadow: 0 0 20px rgba(255, 105, 180, 0.8);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 0 rgba(255, 105, 180, 0.5);
    }
}

/* 添加连击特效 */
.combo-animation {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 36px;
    font-weight: bold;
    color: #ff69b4;
    text-shadow: 0px 0px 5px white, 0px 0px 10px rgba(255, 105, 180, 0.5);
    animation: combo 1s ease-out forwards;
    z-index: 100;
}

@keyframes combo {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 0;
    }

    50% {
        transform: translate(-50%, -50%) scale(1.2);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0;
    }
}

/* 添加得分闪光效果 */
.score-flash {
    animation: scoreFlash 0.5s ease-out;
}

@keyframes scoreFlash {
    0% {
        transform: scale(1);
        color: #5a4a5a;
    }

    50% {
        transform: scale(1.1);
        color: #ff69b4;
    }

    100% {
        transform: scale(1);
        color: #5a4a5a;
    }
}

/* 添加操作反馈提示 */
.move-notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(211, 184, 211, 0.9);
    color: #5a4a5a;
    padding: 10px 20px;
    border-radius: 12px;
    font-size: 16px;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s;
    box-shadow: 0 4px 12px rgba(160, 120, 160, 0.3);
}

.move-notification.show {
    opacity: 1;
}

/* 音乐控制 */
.music-control {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(255, 248, 220, 0.8);
    /* 半透明淡黄色 */
    padding: 10px;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(160, 120, 160, 0.3);
    z-index: 100;
    transition: all 0.3s;
}

.music-control:hover {
    transform: scale(1.1);
}

.music-icon {
    width: 24px;
    height: 24px;
}

/* 添加难度选择样式 */
.difficulty-selector {
    margin: 1rem 0;
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.difficulty-btn {
    padding: 8px 16px;
    background: linear-gradient(145deg, #c8a8c8, #e8c8e8);
    border: none;
    border-radius: 8px;
    color: #5a4a5a;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: bold;
}

.difficulty-btn.active {
    background: linear-gradient(145deg, #d8b8d8, #f8d8f8);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(160, 120, 160, 0.3);
}

/* 添加统计信息样式 */
.stats-panel {
    display: flex;
    justify-content: space-between;
    margin: 0.8rem 0;
    padding: 1rem;
    background: linear-gradient(145deg, #F0E6C8, #FFF8DC);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(160, 120, 160, 0.2);
}

.stat-item {
    text-align: center;
}

.stat-value {
    font-size: 24px;
    font-weight: bold;
    color: #5a4a5a;
}

.stat-label {
    font-size: 12px;
    color: #5a4a5a;
    text-transform: uppercase;
}

/* 添加提示样式 */
.hint-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    border-radius: 12px;
}

.hint-content {
    background: white;
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    max-width: 80%;
}

.hint-arrow {
    position: absolute;
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-bottom: 10px solid white;
}

/* 移动端优化 */
@media (max-width: 480px) {
    .game-container {
        margin-top: 0;
        padding: 5px;
    }

    .score-panel {
        margin: 0.4rem 0;
        font-size: clamp(0.9rem, 3vw, 1.1rem);
        color: #ffb6c1;
        text-shadow: 1px 1px 2px rgba(255, 182, 193, 0.3);
        font-family: 'Comic Sans MS', cursive, Arial, sans-serif;
        letter-spacing: 0.5px;
    }

    .scores {
        gap: 8px;
    }

    .score-box {
        padding: 6px 12px;
    }

    .score-title {
        font-size: clamp(10px, 2.5vw, 12px);
    }

    .score-value {
        font-size: clamp(16px, 4vw, 20px);
    }

    .control-panel {
        margin: 0.6rem 0;
    }

    button {
        padding: 8px 16px;
        font-size: 15px;
    }

    .stats-panel {
        margin: 0.6rem 0;
        padding: 0.8rem;
    }

    .stat-value {
        font-size: 20px;
    }

    .stat-label {
        font-size: 10px;
    }

    .grid-container {
        gap: 4px;
        padding: 5px;
        margin-top: 0.8rem;
        max-width: 95vw;
    }

    .music-control {
        width: 40px;
        height: 40px;
    }

    .music-icon {
        width: 24px;
        height: 24px;
    }
}