/* ===== 全局重置 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: url('ig_000d48212332d9dd016a3b45371fec819baffec8c3d5247122.png') center/cover no-repeat;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

/* V3.2: 收集目标栏（横向，在棋盘上方） */
#goals-bar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: auto;
    max-width: 80%;
    margin: -8px auto 0;
    padding: 2px 8px;
    background: linear-gradient(145deg, rgba(255, 248, 230, 0.95), rgba(255, 240, 200, 0.9));
    border-radius: 8px;
    border: 2px solid rgba(200, 170, 100, 0.4);
    box-shadow:
        0 4px 12px rgba(0, 0, 0, 0.1),
        0 1px 4px rgba(0, 0, 0, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.6),
        inset 0 -1px 0 rgba(0, 0, 0, 0.03);
    flex-shrink: 0;
    position: relative;
    z-index: 10;
}

.goals-bar-title {
    font-size: 12px;
    font-weight: 700;
    color: #8b6914;
    letter-spacing: 1px;
    white-space: nowrap;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}

.goals-bar-list {
    display: flex;
    gap: 6px;
    align-items: center;
}

.goals-bar-item {
    display: flex;
    align-items: center;
    gap: 4px;
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.8), rgba(255, 252, 245, 0.75));
    border: 1.5px solid rgba(200, 170, 100, 0.3);
    border-radius: 6px;
    padding: 2px 6px;
    box-shadow:
        0 2px 6px rgba(0, 0, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);
    transition: transform 0.15s ease;
}

.goals-bar-item:hover {
    transform: scale(1.05);
}

.goals-bar-icon {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(255, 248, 230, 0.8), rgba(255, 240, 200, 0.7));
    border-radius: 10px;
    border: 1px solid rgba(200, 170, 100, 0.25);
    overflow: hidden;
}

.goals-bar-icon .goal-icon-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    pointer-events: none;
    transform: scale(1.15);
}

.goals-bar-count {
    font-size: 15px;
    font-weight: 800;
    color: #5d4a1a;
    min-width: 18px;
    text-align: center;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}

.goals-bar-count.completed {
    color: #2e7d32;
    text-decoration: line-through;
}

.goals-bar-meta {
    margin-left: 6px;
    padding-left: 10px;
    border-left: 2px solid rgba(200, 170, 100, 0.3);
}

/* V3 新增：设置按钮（V3.2 继续放大） */
.hud-btn {
    background: linear-gradient(145deg, rgba(255, 248, 230, 0.95), rgba(255, 240, 200, 0.9));
    border: 3px solid rgba(200, 170, 100, 0.5);
    border-radius: 50%;
    width: 60px;
    height: 60px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        0 6px 16px rgba(0, 0, 0, 0.18),
        0 2px 6px rgba(0, 0, 0, 0.12),
        inset 0 2px 0 rgba(255, 255, 255, 0.6),
        inset 0 -2px 0 rgba(0, 0, 0, 0.05);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.hud-btn:hover {
    transform: translateY(-3px);
    box-shadow:
        0 8px 20px rgba(0, 0, 0, 0.22),
        0 3px 8px rgba(0, 0, 0, 0.15),
        inset 0 2px 0 rgba(255, 255, 255, 0.6),
        inset 0 -2px 0 rgba(0, 0, 0, 0.05);
}

.hud-btn:active {
    transform: translateY(0);
    box-shadow:
        0 4px 12px rgba(0, 0, 0, 0.15),
        0 1px 4px rgba(0, 0, 0, 0.1),
        inset 0 2px 0 rgba(255, 255, 255, 0.6),
        inset 0 -2px 0 rgba(0, 0, 0, 0.05);
}

.hud-btn-icon {
    width: 54px;
    height: 54px;
    object-fit: contain;
    pointer-events: none;
    padding: 1px;
    margin-left: -2px;
}

/* V3 新增：设置弹窗 */
#settings-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

#settings-overlay.modal-hidden {
    display: none;
}

#settings-box {
    background: linear-gradient(135deg, #fffaf0, #fff5e0);
    border-radius: 20px;
    padding: 24px 20px;
    max-width: 300px;
    width: 85%;
    border: 2px solid rgba(200, 170, 100, 0.4);
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.25),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.settings-title {
    font-size: 20px;
    font-weight: 800;
    color: #8b6914;
    text-align: center;
    margin-bottom: 20px;
}

.settings-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 20px;
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.settings-label {
    font-size: 14px;
    font-weight: 600;
    color: #5d4a1a;
}

.settings-toggle {
    background: linear-gradient(135deg, #e0e0e0, #ccc);
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-radius: 20px;
    padding: 6px 16px;
    font-size: 13px;
    font-weight: 600;
    color: #666;
    cursor: pointer;
    transition: all 0.2s ease;
}

.settings-toggle.active {
    background: linear-gradient(135deg, #69f0ae, #4caf50);
    border-color: rgba(76, 175, 80, 0.5);
    color: #fff;
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
}

.settings-slider {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(200, 170, 100, 0.3);
    border-radius: 3px;
    outline: none;
}

.settings-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: linear-gradient(135deg, #ffd54f, #ffb300);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.settings-close-btn {
    width: 100%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    border: none;
    border-radius: 12px;
    padding: 12px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    transition: transform 0.1s, box-shadow 0.2s;
}

.settings-close-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

.settings-close-btn:active {
    transform: translateY(0);
}

/* 暗角叠加层：边缘变暗，突出中央内容 */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(
        ellipse at center,
        transparent 40%,
        rgba(0, 0, 0, 0.15) 70%,
        rgba(0, 0, 0, 0.35) 100%
    );
    pointer-events: none;
    z-index: 0;
}

/* ===== 游戏容器 ===== */
#game-container {
    width: 100%;
    max-width: 640px;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 10px;
    gap: 8px;
    overflow: visible;
    position: relative;
    z-index: 1;
}

/* ===== 生命栏（V3.3 新增） ===== */
#life-panel {
    position: absolute;
    top: 14px;
    left: 90px;
    width: 58px;
    height: 58px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.life-icon {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.life-count {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 22px;
    font-weight: 900;
    color: #fff;
    text-shadow:
        0 1px 2px rgba(0, 0, 0, 0.5),
        0 0 4px rgba(0, 0, 0, 0.3);
    pointer-events: none;
    line-height: 1;
}

/* ===== 顶部 HUD ===== */
#hud {
    width: 100%;
    max-width: 640px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    padding: 4px 0;
    position: relative;
}

.hud-left {
    position: absolute;
    left: 8px;
}

.hud-center {
    display: flex;
    justify-content: center;
    gap: 10px;
    align-items: center;
}

.hud-right {
    position: absolute;
    right: 8px;
}

.hud-item {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    background: linear-gradient(135deg, rgba(255, 248, 230, 0.95), rgba(255, 240, 200, 0.9));
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 2px solid rgba(200, 170, 100, 0.4);
    border-radius: 18px;
    padding: 10px 24px;
    min-width: 95px;
    box-shadow:
        0 6px 20px rgba(0, 0, 0, 0.15),
        0 2px 6px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.6),
        inset 0 -1px 0 rgba(0, 0, 0, 0.05);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.hud-item:hover {
    transform: translateY(-2px);
    box-shadow:
        0 8px 24px rgba(0, 0, 0, 0.18),
        0 3px 8px rgba(0, 0, 0, 0.12),
        inset 0 1px 0 rgba(255, 255, 255, 0.6),
        inset 0 -1px 0 rgba(0, 0, 0, 0.05);
}

.hud-label {
    font-size: 11px;
    color: #8b6914;
    letter-spacing: 1px;
    text-transform: uppercase;
    font-weight: 600;
}

.hud-value {
    font-size: 24px;
    font-weight: 800;
    color: #5d4a1a;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    line-height: 1.2;
}

#hud-moves .hud-value {
    color: #e65100;
    font-weight: 900;
}

/* V3.2: 星级评分栏（微调版） */
#star-rating-bar {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: linear-gradient(145deg, rgba(255, 248, 230, 0.98), rgba(255, 240, 200, 0.95));
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 2px solid rgba(200, 170, 100, 0.5);
    border-radius: 14px;
    padding: 8px 14px;
    box-shadow:
        0 6px 16px rgba(0, 0, 0, 0.15),
        0 2px 6px rgba(0, 0, 0, 0.1),
        inset 0 2px 0 rgba(255, 255, 255, 0.7),
        inset 0 -2px 0 rgba(0, 0, 0, 0.05);
    flex-shrink: 0;
}

.star-container {
    display: flex;
    gap: 6px;
    align-items: center;
}

.star {
    font-size: 22px;
    color: #a89878;
    text-shadow:
        0 1px 2px rgba(0, 0, 0, 0.2),
        0 0 1px rgba(0, 0, 0, 0.1);
    transition: color 0.3s ease, transform 0.3s ease, text-shadow 0.3s ease;
    line-height: 1;
    -webkit-text-stroke: 0.5px rgba(0, 0, 0, 0.1);
}

.star.active {
    color: #ff9800;
    text-shadow:
        0 0 12px rgba(255, 152, 0, 0.7),
        0 0 24px rgba(255, 152, 0, 0.4),
        0 2px 4px rgba(0, 0, 0, 0.25),
        0 0 2px rgba(255, 255, 255, 0.5);
    transform: scale(1.15);
    -webkit-text-stroke: 1px rgba(200, 120, 0, 0.3);
    filter: drop-shadow(0 2px 6px rgba(255, 152, 0, 0.5));
}

.star-progress-bg {
    width: 75px;
    height: 6px;
    background: linear-gradient(180deg, rgba(180, 160, 120, 0.2), rgba(180, 160, 120, 0.3));
    border-radius: 4px;
    overflow: hidden;
    border: 1.5px solid rgba(180, 160, 120, 0.4);
    box-shadow:
        inset 0 2px 3px rgba(0, 0, 0, 0.12),
        0 1px 0 rgba(255, 255, 255, 0.3);
}

.star-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(180deg, #81c784, #4caf50, #388e3c);
    border-radius: 4px;
    transition: width 0.5s ease;
    box-shadow:
        0 0 10px rgba(76, 175, 80, 0.6),
        inset 0 1px 0 rgba(255, 255, 255, 0.5),
        inset 0 -1px 0 rgba(0, 0, 0, 0.1);
}

/* ===== 关卡目标面板（V3 右侧任务栏） ===== */
.goal-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.8), rgba(255, 252, 245, 0.75));
    border: 2px solid rgba(200, 170, 100, 0.35);
    border-radius: 12px;
    padding: 10px 12px;
    box-shadow:
        0 4px 10px rgba(0, 0, 0, 0.1),
        0 1px 4px rgba(0, 0, 0, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.7),
        inset 0 -1px 0 rgba(0, 0, 0, 0.03);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.goal-item:hover {
    transform: scale(1.03);
    box-shadow:
        0 6px 14px rgba(0, 0, 0, 0.12),
        0 2px 6px rgba(0, 0, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.7),
        inset 0 -1px 0 rgba(0, 0, 0, 0.03);
}

.goal-icon {
    font-size: 22px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    background: linear-gradient(135deg, rgba(255, 248, 230, 0.8), rgba(255, 240, 200, 0.7));
    border-radius: 8px;
    border: 1px solid rgba(200, 170, 100, 0.3);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
}

/* 目标图标图片样式 */
.goal-icon-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    pointer-events: none;
}

.goal-count {
    font-size: 18px;
    font-weight: 800;
    color: #5d4a1a;
    min-width: 24px;
    text-align: center;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}

.goal-count.completed {
    color: #2e7d32;
    text-decoration: line-through;
    text-shadow: 0 1px 0 rgba(46, 125, 50, 0.3);
}

.meta-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #5d4a1a;
    justify-content: center;
    width: 100%;
    padding: 6px 0;
}

.meta-icon {
    font-size: 16px;
}

.meta-value {
    font-weight: 700;
    color: #5d4a1a;
}

/* ===== 棋盘区域 ===== */
#board-wrapper {
    flex: 1;
    width: 100%;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
    overflow: visible;
    padding: 2px;
}

#board {
    width: min(100%, calc((100vh - 240px) * 9 / 7));
    width: min(100%, calc((100dvh - 240px) * 9 / 7));
    max-height: calc(100vh - 240px);
    max-height: calc(100dvh - 240px);
    aspect-ratio: 9 / 7;
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    grid-template-rows: repeat(7, 1fr);
    gap: 3px;

    /* 奶油色嵌入式面板背景 */
    background:
        linear-gradient(145deg,
            rgba(255, 248, 230, 0.95) 0%,
            rgba(255, 240, 200, 0.9) 30%,
            rgba(255, 235, 180, 0.85) 70%,
            rgba(255, 245, 210, 0.9) 100%
        );

    /* 厚实奶油色边框 */
    border: 5px solid rgba(200, 170, 100, 0.5);
    border-radius: 24px;
    padding: 6px;

    /* 多层阴影：外阴影 + 内凹深度阴影 */
    box-shadow:
        /* 外阴影：立体悬浮 */
        0 16px 48px rgba(0, 0, 0, 0.25),
        0 6px 16px rgba(0, 0, 0, 0.15),
        /* 内阴影：收纳盒凹陷感 */
        inset 0 6px 12px rgba(0, 0, 0, 0.15),
        inset 0 -3px 6px rgba(255, 255, 255, 0.3),
        /* 内边框高光 */
        inset 0 0 0 3px rgba(255, 248, 230, 0.6);

    /* 嵌入场景感 */
    position: relative;
}

/* 收纳盒顶部高光条 */
#board::before {
    content: '';
    position: absolute;
    top: 0;
    left: 10%;
    right: 10%;
    height: 4px;
    background: linear-gradient(90deg,
        transparent,
        rgba(255, 248, 230, 0.8),
        rgba(255, 255, 255, 0.9),
        rgba(255, 248, 230, 0.8),
        transparent
    );
    border-radius: 0 0 6px 6px;
    z-index: 1;
}

/* ===== 单元格 ===== */
.cell {
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(16px, 3.5vw, 28px);
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    position: relative;
    overflow: hidden;
    transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.15s ease;

    /* 浅奶油色格子背景 */
    background: linear-gradient(145deg,
        rgba(255, 252, 245, 0.9) 0%,
        rgba(255, 248, 235, 0.85) 50%,
        rgba(255, 250, 240, 0.9) 100%
    );

    /* 内凹阴影 */
    box-shadow:
        inset 0 2px 4px rgba(0, 0, 0, 0.08),
        inset 0 -1px 2px rgba(255, 255, 255, 0.9),
        0 1px 3px rgba(0, 0, 0, 0.06);

    border: 1px solid rgba(200, 180, 140, 0.35);
}

.cell:hover {
    transform: scale(1.05);
    box-shadow:
        inset 0 2px 4px rgba(0, 0, 0, 0.08),
        inset 0 -1px 2px rgba(255, 255, 255, 0.8),
        0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 2;
}

.cell:active {
    transform: scale(0.92);
    box-shadow:
        inset 0 3px 6px rgba(0, 0, 0, 0.15),
        inset 0 -1px 2px rgba(255, 255, 255, 0.6),
        0 1px 2px rgba(0, 0, 0, 0.05);
}

.cell.selected {
    outline: 3px solid #ffd54f;
    outline-offset: -2px;
    animation: pulse 0.8s ease-in-out infinite;
    z-index: 3;
    box-shadow:
        inset 0 2px 4px rgba(0, 0, 0, 0.08),
        inset 0 -1px 2px rgba(255, 255, 255, 0.8),
        0 0 16px rgba(255, 213, 79, 0.4);
}

.cell.hint {
    outline: 3px dashed #ffd54f;
    outline-offset: -3px;
    animation: hint-pulse 0.5s ease-in-out infinite;
    box-shadow:
        inset 0 2px 4px rgba(0, 0, 0, 0.08),
        inset 0 -1px 2px rgba(255, 255, 255, 0.8),
        0 0 16px rgba(255, 213, 79, 0.6),
        0 0 32px rgba(255, 213, 79, 0.3);
    z-index: 5;
}

/* ===== 消除动画 ===== */
@keyframes match-clear {
    0%   { transform: scale(1); opacity: 1; }
    50%  { transform: scale(1.3); opacity: 0.6; }
    100% { transform: scale(0); opacity: 0; }
}

.cell.clearing {
    animation: match-clear 0.3s ease-out forwards;
    pointer-events: none;
}

/* ===== 下落动画 ===== */
.cell.falling {
    transition: transform 0.25s ease-in;
}

/* ===== 脉冲动画 ===== */
@keyframes pulse {
    0%, 100% { outline-color: #ffd54f; }
    50%      { outline-color: #ffab40; }
}

@keyframes hint-pulse {
    0%, 100% {
        outline-color: #ffd54f;
        box-shadow:
            inset 0 2px 4px rgba(0, 0, 0, 0.08),
            0 0 16px rgba(255, 213, 79, 0.6),
            0 0 32px rgba(255, 213, 79, 0.3);
    }
    50% {
        outline-color: #ffab40;
        box-shadow:
            inset 0 2px 4px rgba(0, 0, 0, 0.08),
            0 0 24px rgba(255, 171, 64, 0.8),
            0 0 48px rgba(255, 171, 64, 0.4);
    }
}

/* ===== 交换动画 ===== */
.cell.swapping {
    transition: transform 0.2s ease-in-out;
    z-index: 10;
}

/* ===== 方块统一风格 ===== */

/* CSS变量：图标缩放控制 */
:root {
    --tile-icon-scale: 1.35;
    --tool-icon-scale: 1.35;
}

/* 方块容器基础样式 */
.cell-content {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 85%;
    height: 85%;
    border-radius: 12px;
    position: relative;
    transition: transform 0.15s ease;
    overflow: hidden;
}

/* 方块图标统一大小（emoji后备） */
.cell-emoji {
    font-size: clamp(18px, 3.8vw, 30px);
    line-height: 1;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.15));
    z-index: 2;
    position: relative;
}

/* 方块图片图标（新增） */
.cell-icon {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    transform: scale(var(--tile-icon-scale));
    z-index: 2;
    position: relative;
    pointer-events: none;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.15));
}

/* 方块背景色（柔和色板） */
.cell-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 12px;
    z-index: 1;

    /* 极轻微的高光，几乎透明 */
    background: linear-gradient(135deg,
        rgba(255, 255, 255, 0.15) 0%,
        transparent 50%,
        rgba(0, 0, 0, 0.02) 100%
    );

    /* 极轻微阴影，去掉气泡感 */
    box-shadow: none;
}

/* 各物品专属背景色 - 大幅透明化 */
.cell.item-socks .cell-bg { background-color: rgba(248, 187, 208, 0.15); }
.cell.item-books .cell-bg { background-color: rgba(144, 202, 249, 0.15); }
.cell.item-teddy .cell-bg { background-color: rgba(255, 204, 128, 0.15); }
.cell.item-pencil .cell-bg { background-color: rgba(165, 214, 167, 0.15); }
.cell.item-lotion .cell-bg { background-color: rgba(206, 147, 216, 0.15); }
.cell.item-ribbon .cell-bg { background-color: rgba(239, 154, 154, 0.15); }
.cell.item-key .cell-bg { background-color: rgba(255, 245, 157, 0.15); }

/* 方块统一光源高光 - 已移除气泡效果 */

/* 方块底部投影 - 已移除气泡效果 */

/* 方块hover效果 */
.cell:hover .cell-content {
    transform: scale(1.05);
}

.cell:hover .cell-bg {
    box-shadow:
        0 5px 10px rgba(0, 0, 0, 0.15),
        0 2px 4px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

/* 方块选中状态增强 */
.cell.selected .cell-bg {
    box-shadow:
        0 0 0 3px #ffd54f,
        0 5px 15px rgba(255, 213, 79, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

/* ===== 道具样式 ===== */
.cell.has-powerup {
    box-shadow:
        inset 0 2px 4px rgba(0, 0, 0, 0.08),
        inset 0 -1px 2px rgba(255, 255, 255, 0.8),
        0 0 12px rgba(255, 215, 0, 0.6);
    animation: powerup-glow 1.5s ease-in-out infinite;
}

.cell.broom-h {
    border: 3px solid #ef5350;
    background: linear-gradient(145deg,
        rgba(239, 83, 80, 0.3),
        rgba(255, 255, 255, 0.75),
        rgba(239, 83, 80, 0.2)
    );
}

.cell.broom-v {
    border: 3px solid #42a5f5;
    background: linear-gradient(145deg,
        rgba(66, 165, 245, 0.3),
        rgba(255, 255, 255, 0.75),
        rgba(66, 165, 245, 0.2)
    );
}

.powerup-badge {
    position: absolute;
    right: 1px;
    bottom: 1px;
    font-size: 11px;
    line-height: 1;
    pointer-events: none;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3));
}

@keyframes powerup-glow {
    0%, 100% { box-shadow: 0 0 8px rgba(255, 215, 0, 0.7); }
    50% { box-shadow: 0 0 16px rgba(255, 215, 0, 1); }
}

/* ===== 障碍物样式 ===== */
.cell.obstacle-wall {
    background: linear-gradient(145deg,
        rgba(120, 100, 80, 0.9) 0%,
        rgba(100, 80, 60, 0.95) 50%,
        rgba(80, 65, 45, 0.9) 100%
    );
    cursor: not-allowed;
    box-shadow:
        inset 0 3px 6px rgba(0, 0, 0, 0.3),
        inset 0 -1px 2px rgba(255, 255, 255, 0.1),
        0 1px 3px rgba(0, 0, 0, 0.15);
    border: 2px solid rgba(60, 45, 30, 0.5);
    border-radius: 6px;
}

.cell.obstacle-wall:hover {
    transform: none;
    box-shadow:
        inset 0 3px 6px rgba(0, 0, 0, 0.3),
        inset 0 -1px 2px rgba(255, 255, 255, 0.1),
        0 1px 3px rgba(0, 0, 0, 0.15);
}

/* ===== 底部道具栏 ===== */
#toolbar {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    padding: 2px 0 4px;
    margin-top: 2px;
    background: transparent;
    border: none;
    box-shadow: none;
}

.tool-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 8px 12px;
    border-radius: 14px;
    cursor: pointer;
    transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.2s, box-shadow 0.2s;
    position: relative;
    min-width: 60px;
    background: linear-gradient(145deg, rgba(255, 248, 230, 0.95), rgba(255, 240, 200, 0.9));
    border: 2px solid rgba(200, 170, 100, 0.4);
    box-shadow:
        0 4px 12px rgba(0, 0, 0, 0.12),
        0 2px 4px rgba(0, 0, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.6),
        inset 0 -1px 0 rgba(0, 0, 0, 0.05);
}

.tool-item:hover {
    background: linear-gradient(145deg, rgba(255, 252, 245, 0.98), rgba(255, 248, 230, 0.95));
    transform: translateY(-3px);
    box-shadow:
        0 6px 16px rgba(0, 0, 0, 0.15),
        0 3px 6px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.6),
        inset 0 -1px 0 rgba(0, 0, 0, 0.05);
}

.tool-item:active {
    transform: translateY(0) scale(0.95);
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.1),
        0 1px 3px rgba(0, 0, 0, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.6),
        inset 0 -1px 0 rgba(0, 0, 0, 0.05);
}

.tool-item.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
    filter: grayscale(0.3);
    background: linear-gradient(145deg, rgba(240, 235, 225, 0.9), rgba(235, 230, 220, 0.85));
}

.tool-item.active-tool {
    background: linear-gradient(145deg, rgba(255, 248, 230, 0.98), rgba(255, 240, 200, 0.95));
    border: 3px solid rgba(255, 213, 79, 0.7);
    box-shadow:
        0 0 16px rgba(255, 213, 79, 0.3),
        0 4px 12px rgba(0, 0, 0, 0.12),
        inset 0 2px 0 rgba(255, 255, 255, 0.6),
        inset 0 -2px 0 rgba(0, 0, 0, 0.05);
    animation: tool-glow 1.5s ease-in-out infinite;
}

@keyframes tool-glow {
    0%, 100% { box-shadow: 0 0 12px rgba(255, 213, 79, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.3); }
    50% { box-shadow: 0 0 20px rgba(255, 213, 79, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.3); }
}

.tool-icon {
    font-size: 32px;
    line-height: 1;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.15));
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: linear-gradient(145deg, rgba(255, 252, 245, 0.8), rgba(255, 248, 235, 0.7));
    border-radius: 14px;
    border: 1px solid rgba(200, 170, 100, 0.3);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
}

/* 道具图片图标样式 */
.tool-icon-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    transform: scale(var(--tool-icon-scale));
    pointer-events: none;
}

.tool-count {
    position: absolute;
    top: -4px;
    right: -4px;
    background: linear-gradient(145deg, #ef5350, #d32f2f);
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    text-align: center;
    border-radius: 9px;
    padding: 0 4px;
    box-shadow:
        0 2px 6px rgba(239, 83, 80, 0.4),
        0 1px 3px rgba(0, 0, 0, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.6);
}

.tool-label {
    font-size: 11px;
    color: #5d4a1a;
    font-weight: 600;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}

/* ===== 音频控制栏 ===== */
#audio-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: linear-gradient(145deg, rgba(255, 248, 230, 0.95), rgba(255, 240, 200, 0.9));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 16px;
    border: 2px solid rgba(200, 170, 100, 0.5);
    box-shadow:
        0 4px 12px rgba(0, 0, 0, 0.15),
        0 2px 4px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.6),
        inset 0 -1px 0 rgba(0, 0, 0, 0.05);
    flex-shrink: 0;
}

.audio-btn {
    background: linear-gradient(145deg, rgba(255, 252, 245, 0.9), rgba(255, 248, 235, 0.85));
    border: 2px solid rgba(200, 170, 100, 0.35);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    font-size: 16px;
    cursor: pointer;
    box-shadow:
        0 3px 8px rgba(0, 0, 0, 0.1),
        0 1px 3px rgba(0, 0, 0, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);
    transition: transform 0.1s, background 0.2s, border-color 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.audio-btn:hover {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.95), rgba(255, 252, 245, 0.9));
    transform: translateY(-2px);
    box-shadow:
        0 4px 10px rgba(0, 0, 0, 0.12),
        0 2px 4px rgba(0, 0, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.audio-btn:active {
    transform: translateY(0);
    box-shadow:
        0 2px 6px rgba(0, 0, 0, 0.1),
        0 1px 2px rgba(0, 0, 0, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.audio-btn.active {
    border-color: #4caf50;
    background: linear-gradient(145deg, rgba(200, 230, 201, 0.9), rgba(165, 214, 167, 0.85));
    box-shadow:
        0 3px 8px rgba(76, 175, 80, 0.2),
        0 1px 3px rgba(76, 175, 80, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.audio-btn.muted {
    opacity: 0.5;
    border-color: #ef5350;
    background: linear-gradient(145deg, rgba(255, 205, 210, 0.9), rgba(255, 183, 178, 0.85));
    box-shadow:
        0 3px 8px rgba(239, 83, 80, 0.2),
        0 1px 3px rgba(239, 83, 80, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

#volume-container {
    display: flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(145deg, rgba(255, 252, 245, 0.8), rgba(255, 248, 235, 0.75));
    border-radius: 10px;
    padding: 4px 10px;
    border: 1px solid rgba(200, 170, 100, 0.3);
    box-shadow:
        inset 0 1px 2px rgba(0, 0, 0, 0.06),
        0 1px 0 rgba(255, 255, 255, 0.5);
    flex-shrink: 0;
}

.volume-label {
    font-size: 11px;
    color: #5d4a1a;
    white-space: nowrap;
    font-weight: 600;
    flex-shrink: 0;
}

.volume-slider {
    width: 60px;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: linear-gradient(145deg, rgba(200, 170, 100, 0.3), rgba(200, 170, 100, 0.2));
    border-radius: 3px;
    outline: none;
    border: 1px solid rgba(200, 170, 100, 0.2);
    flex-shrink: 0;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: linear-gradient(145deg, #69f0ae, #4caf50);
    border-radius: 50%;
    cursor: pointer;
    box-shadow:
        0 2px 6px rgba(105, 240, 174, 0.4),
        0 1px 3px rgba(0, 0, 0, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.6);
}

.volume-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: linear-gradient(145deg, #69f0ae, #4caf50);
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid rgba(255, 255, 255, 0.6);
    box-shadow:
        0 2px 6px rgba(105, 240, 174, 0.4),
        0 1px 3px rgba(0, 0, 0, 0.2);
}

/* ===== 弹窗模态 ===== */
#modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: modal-bg-in 0.3s ease;
}

#modal-overlay.modal-hidden {
    display: none;
}

@keyframes modal-bg-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

#modal-box {
    background: linear-gradient(145deg, rgba(255, 248, 230, 0.98), rgba(255, 240, 200, 0.95));
    border-radius: 24px;
    padding: 32px 28px;
    max-width: 340px;
    width: 88%;
    text-align: center;
    border: 3px solid rgba(200, 170, 100, 0.5);
    box-shadow:
        0 24px 64px rgba(0, 0, 0, 0.25),
        0 8px 24px rgba(0, 0, 0, 0.15),
        inset 0 2px 0 rgba(255, 255, 255, 0.7),
        inset 0 -2px 0 rgba(0, 0, 0, 0.05);
    animation: modal-box-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modal-box-in {
    from { opacity: 0; transform: scale(0.7) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

#modal-icon {
    font-size: 52px;
    margin-bottom: 12px;
    line-height: 1;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
}

#modal-title {
    font-size: 24px;
    font-weight: 900;
    color: #5d4a1a;
    margin-bottom: 12px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

#modal-body {
    font-size: 15px;
    color: #8b6914;
    margin-bottom: 16px;
    line-height: 1.6;
    font-weight: 500;
}

#modal-rewards {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
}

.reward-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(145deg, #ffd54f, #ffb300);
    color: #5d4a1a;
    font-size: 14px;
    font-weight: 700;
    padding: 8px 14px;
    border-radius: 20px;
    border: 2px solid rgba(255, 213, 79, 0.5);
    box-shadow:
        0 4px 10px rgba(255, 179, 0, 0.4),
        0 2px 4px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.5);
    animation: reward-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.reward-badge:nth-child(2) { animation-delay: 0.1s; }
.reward-badge:nth-child(3) { animation-delay: 0.2s; }

@keyframes reward-pop {
    from { opacity: 0; transform: scale(0); }
    to { opacity: 1; transform: scale(1); }
}

.modal-action-btn {
    background: linear-gradient(145deg, #667eea, #764ba2);
    color: #fff;
    border: 2px solid rgba(102, 126, 234, 0.3);
    border-radius: 16px;
    padding: 14px 40px;
    font-size: 17px;
    font-weight: 800;
    cursor: pointer;
    box-shadow:
        0 6px 18px rgba(102, 126, 234, 0.4),
        0 3px 6px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
    transition: transform 0.1s, box-shadow 0.2s;
    letter-spacing: 1px;
}

.modal-action-btn:hover {
    transform: translateY(-3px);
    box-shadow:
        0 8px 24px rgba(102, 126, 234, 0.5),
        0 4px 8px rgba(0, 0, 0, 0.12),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.modal-action-btn:active {
    transform: translateY(0);
    box-shadow:
        0 4px 12px rgba(102, 126, 234, 0.4),
        0 2px 4px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

/* ===== 响应式 ===== */
@media (max-height: 667px) {
    #game-container { padding: 4px 8px; gap: 4px; }
    #goals-bar { padding: 2px 6px; gap: 5px; margin-top: -6px; }
    .goals-bar-title { font-size: 9px; }
    .goals-bar-icon { width: 24px; height: 24px; }
    .goals-bar-count { font-size: 11px; }
    .hud-item { padding: 6px 14px; min-width: 70px; }
    .hud-value { font-size: 18px; }
    .hud-btn { width: 48px; height: 48px; }
    .hud-btn-icon { width: 40px; height: 40px; }
    .star { font-size: 16px; }
    .star-progress-bg { width: 60px; height: 5px; }
    #star-rating-bar { padding: 6px 10px; gap: 3px; }
    #toolbar { gap: 4px; padding: 1px 0 3px; }
    .tool-item { padding: 6px 8px; min-width: 50px; gap: 2px; }
    .tool-icon { width: 30px; height: 30px; font-size: 22px; }
    .tool-label { font-size: 9px; }
    .tool-count { font-size: 9px; min-width: 14px; height: 14px; line-height: 14px; }
    #modal-box { padding: 24px 20px; }
    #modal-icon { font-size: 40px; }
    #modal-title { font-size: 20px; }
}

@media (max-width: 400px) {
    #game-container { padding: 4px 6px; gap: 3px; }
    #goals-bar { padding: 2px 5px; gap: 4px; margin-top: -6px; }
    .goals-bar-title { font-size: 8px; }
    .goals-bar-item { padding: 2px 4px; gap: 2px; }
    .goals-bar-icon { width: 22px; height: 22px; }
    .goals-bar-count { font-size: 10px; }
    .hud-item { padding: 5px 10px; min-width: 60px; }
    .hud-value { font-size: 16px; }
    .hud-label { font-size: 9px; }
    .hud-btn { width: 42px; height: 42px; }
    .hud-btn-icon { width: 34px; height: 34px; }
    .star { font-size: 14px; }
    .star-progress-bg { width: 50px; height: 4px; }
    #star-rating-bar { padding: 5px 8px; gap: 3px; }
    #toolbar { gap: 3px; padding: 1px 0 2px; }
    .tool-item { padding: 5px 7px; min-width: 44px; border-radius: 12px; gap: 2px; }
    .tool-icon { width: 26px; height: 26px; font-size: 18px; border-radius: 8px; }
    .tool-label { font-size: 8px; }
    .tool-count { font-size: 8px; min-width: 12px; height: 12px; line-height: 12px; top: -2px; right: -2px; }
}

@media (max-width: 360px) {
    #goals-bar { padding: 1px 4px; gap: 3px; }
    .goals-bar-title { font-size: 7px; }
    .goals-bar-item { padding: 1px 3px; }
    .goals-bar-icon { width: 20px; height: 20px; }
    .goals-bar-count { font-size: 9px; }
    .hud-btn { width: 38px; height: 38px; }
    .hud-btn-icon { width: 30px; height: 30px; }
    #toolbar { gap: 3px; }
    .tool-item { padding: 4px 6px; min-width: 40px; }
    .tool-icon { width: 24px; height: 24px; font-size: 16px; }
    .tool-label { font-size: 8px; }
    .tool-count { font-size: 8px; min-width: 12px; height: 12px; line-height: 12px; }
}

/* ===== combo 消息（浮动文字 - 3D 立体效果） ===== */
.combo-float {
    position: fixed;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 42px;
    font-weight: 900;
    color: #ff6f00;
    text-shadow:
        0 1px 0 #ff8f00,
        0 2px 0 #ff6f00,
        0 3px 0 #e65100,
        0 4px 0 #bf360c,
        0 5px 10px rgba(0, 0, 0, 0.4),
        0 0 30px rgba(255, 111, 0, 0.6),
        0 0 60px rgba(255, 111, 0, 0.3);
    -webkit-text-stroke: 1px rgba(0, 0, 0, 0.2);
    z-index: 1500;
    pointer-events: none;
    animation: combo-float-anim 1.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    letter-spacing: 3px;
    font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

@keyframes combo-float-anim {
    0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.2) rotate(-10deg); }
    10%  { opacity: 1; transform: translate(-50%, -50%) scale(1.4) rotate(3deg); }
    25%  { transform: translate(-50%, -50%) scale(0.95) rotate(-1deg); }
    35%  { transform: translate(-50%, -50%) scale(1.05) rotate(0deg); }
    65%  { opacity: 1; }
    100% { opacity: 0; transform: translate(-50%, -120%) scale(0.7) translateY(-30px); }
}

/* ===== 消除粒子系统 ===== */
.particle-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
    overflow: visible;
}

.particle {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    pointer-events: none;
    animation: particle-fly 0.6s ease-out forwards;
}

/* 粒子颜色（与方块配色对应） */
.particle.pink { background: #f8bbd0; box-shadow: 0 0 6px #f48fb1; }
.particle.blue { background: #90caf9; box-shadow: 0 0 6px #64b5f6; }
.particle.orange { background: #ffcc80; box-shadow: 0 0 6px #ffb74d; }
.particle.green { background: #a5d6a7; box-shadow: 0 0 6px #81c784; }
.particle.purple { background: #ce93d8; box-shadow: 0 0 6px #ba68c8; }
.particle.red { background: #ef9a9a; box-shadow: 0 0 6px #e57373; }
.particle.yellow { background: #fff59d; box-shadow: 0 0 6px #fff176; }
.particle.gold { background: #ffd54f; box-shadow: 0 0 6px #ffc107; }

@keyframes particle-fly {
    0% {
        opacity: 1;
        transform: translate(0, 0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(var(--tx), var(--ty)) scale(0.3);
    }
}

/* ===== 行列清除特效 ===== */
.line-clear-effect {
    position: absolute;
    pointer-events: none;
    z-index: 90;
}

.line-clear-h {
    top: 50%;
    left: -10%;
    width: 120%;
    height: 4px;
    transform: translateY(-50%);
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(255, 215, 0, 0.8) 20%,
        rgba(255, 255, 255, 1) 50%,
        rgba(255, 215, 0, 0.8) 80%,
        transparent 100%
    );
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.6), 0 0 40px rgba(255, 215, 0, 0.3);
    animation: line-sweep-h 0.4s ease-out forwards;
}

.line-clear-v {
    top: -10%;
    left: 50%;
    width: 4px;
    height: 120%;
    transform: translateX(-50%);
    background: linear-gradient(180deg,
        transparent 0%,
        rgba(255, 215, 0, 0.8) 20%,
        rgba(255, 255, 255, 1) 50%,
        rgba(255, 215, 0, 0.8) 80%,
        transparent 100%
    );
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.6), 0 0 40px rgba(255, 215, 0, 0.3);
    animation: line-sweep-v 0.4s ease-out forwards;
}

@keyframes line-sweep-h {
    0% { opacity: 0; transform: translateY(-50%) scaleX(0); }
    30% { opacity: 1; transform: translateY(-50%) scaleX(1.2); }
    100% { opacity: 0; transform: translateY(-50%) scaleX(1.5); }
}

@keyframes line-sweep-v {
    0% { opacity: 0; transform: translateX(-50%) scaleY(0); }
    30% { opacity: 1; transform: translateX(-50%) scaleY(1.2); }
    100% { opacity: 0; transform: translateX(-50%) scaleY(1.5); }
}

/* ===== 爆炸特效（T/L形） ===== */
.explosion-effect {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 200%;
    height: 200%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: radial-gradient(
        circle,
        rgba(255, 255, 255, 0.9) 0%,
        rgba(255, 215, 0, 0.6) 30%,
        rgba(255, 150, 0, 0.3) 60%,
        transparent 100%
    );
    pointer-events: none;
    z-index: 95;
    animation: explosion-burst 0.5s ease-out forwards;
}

@keyframes explosion-burst {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.1); }
    20% { opacity: 1; transform: translate(-50%, -50%) scale(0.8); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(2); }
}

/* ===== 十字清除特效 ===== */
.cross-clear-effect {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 300%;
    height: 300%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 95;
    animation: cross-burst 0.5s ease-out forwards;
}

.cross-clear-effect::before,
.cross-clear-effect::after {
    content: '';
    position: absolute;
    background: linear-gradient(90deg,
        transparent,
        rgba(255, 215, 0, 0.9),
        rgba(255, 255, 255, 1),
        rgba(255, 215, 0, 0.9),
        transparent
    );
}

.cross-clear-effect::before {
    top: 50%;
    left: 0;
    width: 100%;
    height: 3px;
    transform: translateY(-50%);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
}

.cross-clear-effect::after {
    top: 0;
    left: 50%;
    width: 3px;
    height: 100%;
    transform: translateX(-50%);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
}

@keyframes cross-burst {
    0% { opacity: 0; transform: translate(-50%, -50%) rotate(0deg) scale(0.3); }
    30% { opacity: 1; transform: translate(-50%, -50%) rotate(45deg) scale(1.2); }
    100% { opacity: 0; transform: translate(-50%, -50%) rotate(90deg) scale(2); }
}

/* ===== UI反馈：涟漪效果 ===== */
.ripple-effect {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    transform: scale(0);
    animation: ripple 0.6s ease-out;
    pointer-events: none;
}

@keyframes ripple {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* ===== 道具使用闪光 ===== */
.tool-flash {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(
        circle,
        rgba(255, 255, 255, 0.8) 0%,
        rgba(255, 215, 0, 0.4) 50%,
        transparent 100%
    );
    border-radius: inherit;
    opacity: 0;
    pointer-events: none;
    animation: tool-flash-anim 0.3s ease-out;
}

@keyframes tool-flash-anim {
    0% { opacity: 0; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1.1); }
    100% { opacity: 0; transform: scale(1.2); }
}

/* ===== 得分飘字 ===== */
.score-float {
    position: absolute;
    font-size: 16px;
    font-weight: 700;
    color: #ffd54f;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
    pointer-events: none;
    z-index: 120;
    animation: score-fly 0.8s ease-out forwards;
}

@keyframes score-fly {
    0% {
        opacity: 1;
        transform: translateY(0) scale(0.8);
    }
    100% {
        opacity: 0;
        transform: translateY(-40px) scale(1.2);
    }
}

/* ===== 按钮按压增强 ===== */
.btn-press-effect {
    animation: btn-press 0.15s ease-out;
}

@keyframes btn-press {
    0% { transform: scale(1); }
    50% { transform: scale(0.92); }
    100% { transform: scale(1); }
}

/* ===== 方块交换轨迹 ===== */
.swap-trail {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 10px;
    background: linear-gradient(90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    pointer-events: none;
    z-index: 50;
    animation: trail-fade 0.3s ease-out forwards;
}

@keyframes trail-fade {
    0% { opacity: 0.6; transform: scaleX(1.5); }
    100% { opacity: 0; transform: scaleX(2); }
}

/* ================================
V4.1-M1 Mobile Portrait Layout Fix
Only affects <=768px portrait screens
Desktop layout locked
================================ */
@media (max-width: 768px) and (orientation: portrait) {
    html,
    body {
        width: 100%;
        overflow: hidden;
        overflow-x: hidden;
    }

    #game-container {
        width: 100%;
        max-width: none;
        padding: 6px 6px 4px;
        gap: 4px;
        overflow: hidden;
    }

    #hud {
        width: 100%;
        max-width: none;
        display: grid;
        grid-template-columns: minmax(0, 1fr) 70px;
        align-items: center;
        gap: 4px;
        min-height: 44px;
        padding: 2px 4px 0 90px;
    }

    .hud-left {
        position: absolute;
        left: 0;
        top: 2px;
    }

    .hud-right {
        position: static;
        justify-self: end;
        width: 70px;
    }

    .hud-center {
        width: 100%;
        min-width: 0;
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 4px;
    }

    #life-panel {
        top: 8px;
        left: 48px;
        width: 36px;
        height: 36px;
    }

    .life-count {
        font-size: 14px;
    }

    .hud-btn {
        width: 38px;
        height: 38px;
        border-radius: 13px;
    }

    .hud-btn-icon {
        width: 30px;
        height: 30px;
    }

    .hud-item {
        min-width: 0;
        width: 100%;
        padding: 5px 4px;
        border-radius: 12px;
    }

    .hud-label {
        font-size: 8px;
        letter-spacing: 0;
    }

    .hud-value {
        font-size: 16px;
        line-height: 1.05;
    }

    #star-rating-bar {
        width: 66px;
        padding: 5px 5px;
        gap: 3px;
        border-radius: 12px;
    }

    .star-container {
        gap: 2px;
    }

    .star {
        font-size: 13px;
    }

    .star.active {
        transform: scale(1.08);
    }

    .star-progress-bg {
        width: 50px;
        height: 4px;
        border-width: 1px;
    }

    #goals-bar {
        max-width: 94vw;
        margin-top: 0;
        padding: 2px 6px;
        gap: 4px;
    }

    .goals-bar-title {
        font-size: 8px;
        letter-spacing: 0;
    }

    .goals-bar-list {
        gap: 4px;
    }

    .goals-bar-item {
        padding: 2px 4px;
        gap: 2px;
    }

    .goals-bar-icon {
        width: 24px;
        height: 24px;
        border-radius: 7px;
    }

    .goals-bar-count {
        min-width: 12px;
        font-size: 10px;
    }

    .goals-bar-meta {
        margin-left: 2px;
        padding-left: 6px;
    }

    #board-wrapper {
        align-items: flex-start;
        padding: 2px 0 0;
    }

    #board {
        width: min(96vw, calc((100dvh - 180px) * 9 / 7));
        max-height: calc(100dvh - 180px);
        gap: 2px;
        border-width: 4px;
        border-radius: 18px;
        padding: 4px;
    }

    .cell {
        border-radius: 8px;
    }

    #toolbar {
        width: 100%;
        max-width: 96vw;
        gap: 4px;
        padding: 2px 0 4px;
        margin-top: 0;
        flex-wrap: nowrap;
    }

    .tool-item {
        flex: 1 1 0;
        min-width: 0;
        max-width: 64px;
        padding: 5px 4px;
        gap: 2px;
        border-radius: 11px;
    }

    .tool-icon {
        width: 26px;
        height: 26px;
        border-radius: 8px;
    }

    .tool-label {
        max-width: 100%;
        font-size: 8px;
        line-height: 1;
        white-space: nowrap;
    }

    .tool-count {
        min-width: 12px;
        height: 12px;
        line-height: 12px;
        font-size: 8px;
        top: -2px;
        right: -2px;
    }
}

/* ================================
V4.1-M2 Mobile Apple Portrait Fine Tune
Only affects <=768px portrait screens
Desktop layout locked
================================ */
@media (max-width: 768px) and (orientation: portrait) {
    #hud {
        grid-template-columns: minmax(0, 1fr) clamp(70px, 18vw, 76px);
        min-height: clamp(48px, 12.8vw, 52px);
        padding: 3px 4px 0 94px;
    }

    .hud-center {
        gap: clamp(4px, 1.2vw, 5px);
    }

    #life-panel {
        top: 8px;
        left: 50px;
        width: clamp(38px, 10.4vw, 42px);
        height: clamp(38px, 10.4vw, 42px);
    }

    .life-count {
        font-size: clamp(15px, 4.1vw, 17px);
    }

    .hud-btn {
        width: clamp(40px, 10.8vw, 44px);
        height: clamp(40px, 10.8vw, 44px);
    }

    .hud-btn-icon {
        width: clamp(32px, 8.7vw, 35px);
        height: clamp(32px, 8.7vw, 35px);
    }

    .hud-item {
        padding: 6px 4px;
        min-height: clamp(44px, 11.8vw, 48px);
    }

    .hud-label {
        font-size: clamp(9px, 2.35vw, 10px);
    }

    .hud-value {
        font-size: clamp(17px, 4.45vw, 19px);
    }

    #star-rating-bar {
        width: clamp(70px, 18vw, 76px);
        padding: 6px 5px;
    }

    .star {
        font-size: clamp(14px, 3.65vw, 15px);
    }

    .star-progress-bg {
        width: clamp(52px, 13.6vw, 56px);
        height: 5px;
    }

    #goals-bar {
        margin-top: 1px;
    }

    #board-wrapper {
        flex: 0 0 auto;
    }

    #toolbar {
        max-width: min(96vw, 420px);
        gap: clamp(4px, 1.2vw, 6px);
        padding: 3px 0 calc(5px + env(safe-area-inset-bottom, 0px));
        margin-top: clamp(7px, 1.8svh, 12px);
    }

    .tool-item {
        max-width: 70px;
        min-height: clamp(58px, 15.2vw, 64px);
        padding: 6px 5px;
        gap: 3px;
    }

    .tool-icon {
        width: clamp(30px, 7.9vw, 34px);
        height: clamp(30px, 7.9vw, 34px);
    }

    .tool-label {
        font-size: clamp(9px, 2.45vw, 10px);
        line-height: 1.05;
    }

    .tool-count {
        min-width: 14px;
        height: 14px;
        line-height: 14px;
        font-size: 9px;
    }
}

/* ================================
V4.1-M3 Mobile Main Area Vertical Shift
Only affects <=768px portrait screens
Desktop layout locked
================================ */
@media (max-width: 768px) and (orientation: portrait) {
    #board-wrapper,
    #toolbar {
        transform: translateY(clamp(18px, 2.4svh, 24px));
    }
}
