/* ===== 全局重置与基础 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
    width: 100%; height: 100%;
    overflow: hidden;
    font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: #FFF5E6;
}
#game-container {
    width: 100%; height: 100%;
    max-width: 480px;
    margin: 0 auto;
    position: relative;
    background: linear-gradient(180deg, #FFF5E6 0%, #FFE4C4 100%);
    overflow: hidden;
}

/* ===== 场景管理 ===== */
.scene {
    position: absolute; top: 0; left: 0;
    width: 100%; height: 100%;
    display: none;
    flex-direction: column;
    overflow-y: auto;
}
.scene.active { display: flex; }
.scene.overlay {
    background: rgba(0,0,0,0.6);
    z-index: 1000;
    justify-content: center; align-items: center;
}

/* ===== 按钮基础 ===== */
button {
    border: none; outline: none; cursor: pointer;
    font-family: inherit; transition: transform 0.1s, box-shadow 0.1s;
}
button:active { transform: scale(0.95); }
.btn-big {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    padding: 16px 40px;
    border-radius: 50px;
    font-size: 20px; font-weight: bold;
    color: white;
    background: linear-gradient(180deg, #7CB342 0%, #558B2F 100%);
    box-shadow: 0 4px 0 #33691E, 0 6px 12px rgba(0,0,0,0.2);
}
.btn-small {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 12px 20px;
    border-radius: 16px;
    font-size: 14px;
    background: linear-gradient(180deg, #FFB74D 0%, #F57C00 100%);
    box-shadow: 0 3px 0 #E65100, 0 4px 8px rgba(0,0,0,0.2);
    color: white; font-weight: bold;
}
.btn-back {
    width: 44px; height: 44px;
    border-radius: 12px;
    background: linear-gradient(180deg, #81C784 0%, #43A047 100%);
    box-shadow: 0 3px 0 #2E7D32;
    font-size: 20px; color: white;
}
.btn-pause {
    width: 36px; height: 36px;
    border-radius: 10px;
    background: linear-gradient(180deg, #81C784 0%, #43A047 100%);
    box-shadow: 0 2px 0 #2E7D32;
    font-size: 16px; color: white;
}
.btn-modal {
    width: 200px; padding: 14px;
    margin: 8px 0;
    border-radius: 30px;
    font-size: 18px; font-weight: bold;
    background: linear-gradient(180deg, #AED581 0%, #7CB342 100%);
    box-shadow: 0 3px 0 #558B2F, 0 4px 8px rgba(0,0,0,0.15);
    color: white;
}
.btn-play .play-icon { font-size: 24px; }

/* ===== 主页场景 ===== */
#scene-home { background: #FFF5E6; }
.home-bg {
    width: 100%; height: 100%;
    position: relative;
    display: flex; flex-direction: column; align-items: center;
    padding: 20px 16px;
}
.home-header {
    width: 100%; display: flex; justify-content: center; margin-bottom: 10px;
}
.resource-bar {
    display: flex; gap: 12px;
    background: rgba(255,255,255,0.7);
    padding: 8px 16px;
    border-radius: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.res-item {
    display: flex; align-items: center; gap: 4px;
    font-size: 14px; font-weight: bold; color: #5D4037;
}
.res-icon { font-size: 18px; }

.home-shop-sign {
    margin: 10px 0;
    display: flex; justify-content: center;
}
.sign-board {
    background: linear-gradient(180deg, #D7CCC8 0%, #BCAAA4 100%);
    padding: 12px 40px;
    border-radius: 20px;
    box-shadow: 0 4px 0 #8D6E63, 0 6px 12px rgba(0,0,0,0.15);
    display: flex; align-items: center; gap: 10px;
    border: 3px solid #8D6E63;
}
.pig-icon { font-size: 32px; }
.shop-name { font-size: 22px; font-weight: bold; color: #4E342E; }

.home-pig-area {
    position: relative;
    width: 180px; height: 180px;
    display: flex; justify-content: center; align-items: center;
    margin: 10px 0;
}
.pig-character {
    font-size: 120px;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.2));
    animation: pigBounce 2s ease-in-out infinite;
}
@keyframes pigBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}
.pig-apron {
    position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
    width: 80px; height: 60px;
    background: #66BB6A;
    border-radius: 10px 10px 30px 30px;
    z-index: -1;
}

.home-counter {
    width: 100%; max-width: 320px;
    background: linear-gradient(180deg, #A1887F 0%, #8D6E63 100%);
    padding: 12px;
    border-radius: 16px;
    box-shadow: 0 4px 0 #6D4C41, inset 0 2px 4px rgba(255,255,255,0.2);
    margin: 10px 0;
    display: flex; justify-content: center;
}
.counter-items {
    display: flex; gap: 16px;
}
.counter-item {
    width: 44px; height: 44px;
    background: white;
    border-radius: 12px;
    display: flex; justify-content: center; align-items: center;
    font-size: 28px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.home-buttons {
    width: 100%; max-width: 320px;
    display: flex; flex-direction: column; align-items: center; gap: 16px;
    margin-top: auto; margin-bottom: 20px;
}
.home-btn-row {
    display: flex; gap: 20px;
    width: 100%; justify-content: center;
}
.btn-map { background: linear-gradient(180deg, #FFD54F 0%, #FFA000 100%); box-shadow: 0 3px 0 #F57C00; }
.btn-gear { background: linear-gradient(180deg, #90CAF9 0%, #42A5F5 100%); box-shadow: 0 3px 0 #1E88E5; }
.btn-icon { font-size: 28px; }

/* ===== 关卡选择场景 ===== */
#scene-levels {
    background: linear-gradient(180deg, #FFF8E1 0%, #FFE0B2 100%);
    padding: 20px 16px;
}
.levels-header {
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 20px;
}
.levels-title {
    flex: 1; text-align: center;
    font-size: 24px; font-weight: bold; color: #5D4037;
}
.levels-pig { font-size: 40px; }
.levels-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding: 0 8px;
}
.level-card {
    aspect-ratio: 1;
    background: linear-gradient(180deg, #FFF9C4 0%, #FFECB3 100%);
    border-radius: 16px;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    box-shadow: 0 3px 0 #FFB74D, 0 4px 8px rgba(0,0,0,0.1);
    border: 2px solid #FFB74D;
    position: relative;
    cursor: pointer;
    transition: transform 0.15s;
}
.level-card:active { transform: scale(0.95); }
.level-card.locked {
    background: linear-gradient(180deg, #E0E0E0 0%, #BDBDBD 100%);
    border-color: #9E9E9E;
    box-shadow: 0 3px 0 #757575;
    cursor: not-allowed;
}
.level-card.completed {
    border-color: #66BB6A;
    box-shadow: 0 3px 0 #43A047;
}
.level-num {
    font-size: 28px; font-weight: bold; color: #5D4037;
}
.level-card.locked .level-num { color: #9E9E9E; }
.level-stars {
    font-size: 12px; margin-top: 2px;
}
.level-card.locked .level-stars { display: none; }
.level-lock-icon {
    font-size: 24px; color: #9E9E9E;
}

/* ===== 关卡准备场景 ===== */
#scene-prep {
    background: linear-gradient(180deg, #FFF8E1 0%, #FFE0B2 100%);
    padding: 20px 16px;
    align-items: center;
}
.prep-header {
    width: 100%; display: flex; align-items: center; gap: 12px;
    margin-bottom: 16px;
}
.prep-pig { font-size: 50px; margin-left: auto; }
.prep-level-num {
    font-size: 36px; font-weight: bold; color: #5D4037;
    background: linear-gradient(180deg, #C8E6C9 0%, #A5D6A7 100%);
    padding: 8px 40px;
    border-radius: 20px;
    box-shadow: 0 3px 0 #66BB6A, 0 4px 8px rgba(0,0,0,0.1);
    margin-bottom: 16px;
}
.prep-targets {
    width: 100%; max-width: 360px;
    background: white;
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-bottom: 12px;
}
.target-title {
    font-size: 16px; font-weight: bold; color: #5D4037;
    margin-bottom: 10px; text-align: center;
}
.target-list {
    display: flex; flex-wrap: wrap; justify-content: center; gap: 12px;
}
.target-item {
    display: flex; align-items: center; gap: 6px;
    background: #FFF8E1;
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 14px; font-weight: bold; color: #5D4037;
}
.target-item .item-emoji { font-size: 24px; }
.prep-timer {
    font-size: 20px; font-weight: bold; color: #5D4037;
    margin-bottom: 12px;
}
.prep-powerups {
    width: 100%; max-width: 360px;
    background: white;
    border-radius: 16px;
    padding: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-bottom: 16px;
}
.pu-title {
    font-size: 14px; font-weight: bold; color: #5D4037;
    margin-bottom: 8px; text-align: center;
}
.pu-list {
    display: flex; justify-content: space-around; gap: 8px;
}
.pu-item {
    display: flex; flex-direction: column; align-items: center;
    padding: 8px;
    border-radius: 12px;
    background: #F5F5F5;
    font-size: 12px; color: #5D4037;
}
.pu-icon { font-size: 28px; }

/* ===== 游戏局内场景 ===== */
#scene-game {
    background: linear-gradient(180deg, #FFF8E1 0%, #FFE0B2 100%);
}
.game-header {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 12px;
    background: rgba(255,255,255,0.6);
    backdrop-filter: blur(4px);
}
.timer-display {
    display: flex; align-items: center; gap: 4px;
    background: white;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 16px; font-weight: bold; color: #5D4037;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.timer-icon { font-size: 18px; }
.timer-display.warning { color: #E53935; animation: timerPulse 0.5s infinite; }
@keyframes timerPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.1); } }
.target-display {
    flex: 1;
    display: flex; justify-content: center; gap: 6px;
    flex-wrap: wrap;
}
.target-chip {
    display: flex; align-items: center; gap: 4px;
    background: white;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 12px; font-weight: bold; color: #5D4037;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
.target-chip .tc-emoji { font-size: 18px; }
.target-chip.completed { background: #C8E6C9; }
.score-display {
    display: flex; align-items: center; gap: 4px;
    font-size: 16px; font-weight: bold; color: #F57C00;
}
.level-badge {
    background: linear-gradient(180deg, #A5D6A7 0%, #66BB6A 100%);
    color: white; font-weight: bold;
    padding: 4px 10px; border-radius: 12px;
    font-size: 14px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* 货柜游戏板 */
.game-board {
    flex: 1;
    display: flex; flex-wrap: wrap; justify-content: center; align-content: center;
    gap: 8px;
    padding: 12px 16px;
    overflow-y: auto;
}
.cabinet-cell {
    width: 90px; height: 90px;
    background: linear-gradient(180deg, #D7CCC8 0%, #BCAAA4 100%);
    border-radius: 12px;
    box-shadow: 0 3px 0 #8D6E63, 0 4px 8px rgba(0,0,0,0.1), inset 0 1px 2px rgba(255,255,255,0.3);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    position: relative;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s;
    border: 2px solid #A1887F;
}
.cabinet-cell:hover { transform: translateY(-2px); box-shadow: 0 5px 0 #8D6E63, 0 6px 12px rgba(0,0,0,0.15); }
.cabinet-cell:active { transform: translateY(1px); box-shadow: 0 1px 0 #8D6E63; }
.cabinet-cell.selected {
    border-color: #FFD54F;
    box-shadow: 0 0 0 3px rgba(255,213,79,0.5), 0 3px 0 #8D6E63;
}
.cell-item {
    font-size: 36px;
    filter: drop-shadow(0 2px 2px rgba(0,0,0,0.15));
    transition: transform 0.2s, opacity 0.2s;
}
.cell-item.moving { animation: itemMove 0.3s ease-out; }
@keyframes itemMove {
    0% { transform: scale(1.2); }
    100% { transform: scale(1); }
}
.cell-item.matched { animation: itemMatch 0.5s ease-out forwards; }
@keyframes itemMatch {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.4) rotate(10deg); opacity: 0.8; }
    100% { transform: scale(0); opacity: 0; }
}
.cell-stack-count {
    position: absolute; bottom: 2px; right: 4px;
    font-size: 10px; font-weight: bold;
    color: white; background: rgba(0,0,0,0.4);
    padding: 1px 5px; border-radius: 8px;
}

/* 小猪提示 */
.game-pig-hint {
    display: flex; align-items: flex-start; gap: 8px;
    padding: 8px 16px;
}
.pig-avatar { font-size: 40px; }
.hint-bubble {
    flex: 1;
    background: white;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px; color: #5D4037;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    position: relative;
}
.hint-bubble::before {
    content: ''; position: absolute; left: -6px; top: 14px;
    width: 0; height: 0;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-right: 8px solid white;
}

/* 操作区 */
.game-operating-area {
    background: rgba(139, 69, 19, 0.15);
    padding: 10px 16px;
    border-top: 2px solid rgba(139, 69, 19, 0.2);
}
.op-title {
    text-align: center;
    font-size: 12px; font-weight: bold; color: #5D4037;
    margin-bottom: 6px;
}
.op-slots {
    display: flex; justify-content: center; gap: 6px;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 4px 0;
}
.op-slot {
    width: 44px; height: 44px;
    background: linear-gradient(180deg, #EFEBE9 0%, #D7CCC8 100%);
    border-radius: 10px;
    box-shadow: 0 2px 0 #8D6E63, 0 3px 6px rgba(0,0,0,0.1), inset 0 1px 2px rgba(255,255,255,0.3);
    display: flex; justify-content: center; align-items: center;
    position: relative;
    border: 2px dashed #A1887F;
    transition: all 0.2s;
    flex-shrink: 0;
}
.op-slot.filled {
    border-style: solid;
    border-color: #8D6E63;
    background: linear-gradient(180deg, #FFF8E1 0%, #FFECB3 100%);
}
.op-slot .slot-item {
    font-size: 22px;
    filter: drop-shadow(0 2px 2px rgba(0,0,0,0.15));
}
.op-slot.temp-slot {
    border-color: #FFD54F;
    background: linear-gradient(180deg, #FFFDE7 0%, #FFF9C4 100%);
}

/* 道具栏 */
.game-powerups {
    display: flex; justify-content: space-around; gap: 8px;
    padding: 10px 12px 16px;
}
.pu-btn {
    display: flex; flex-direction: column; align-items: center;
    padding: 8px 6px;
    border-radius: 12px;
    background: linear-gradient(180deg, #FFF8E1 0%, #FFE0B2 100%);
    box-shadow: 0 2px 0 #D7CCC8, 0 3px 6px rgba(0,0,0,0.1);
    border: 2px solid #D7CCC8;
    min-width: 64px;
    position: relative;
}
.pu-btn:active { transform: translateY(1px); box-shadow: 0 1px 0 #D7CCC8; }
.pu-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(0.6);
}
.pu-btn.used {
    opacity: 0.4;
    cursor: not-allowed;
    filter: grayscale(1);
}
.pu-btn-icon { font-size: 24px; }
.pu-btn-label { font-size: 11px; font-weight: bold; color: #5D4037; margin-top: 2px; }
.pu-used {
    position: absolute; top: 2px; right: 2px;
    font-size: 10px; color: #E53935; font-weight: bold;
}

/* ===== 模态框 ===== */
.modal-box {
    background: white;
    border-radius: 24px;
    padding: 28px 24px;
    width: 90%; max-width: 340px;
    display: flex; flex-direction: column; align-items: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}
.modal-title {
    font-size: 24px; font-weight: bold; color: #5D4037;
    margin-bottom: 16px;
}
.result-box { text-align: center; }
.result-title { font-size: 26px; font-weight: bold; color: #5D4037; margin-bottom: 8px; }
.result-stars { font-size: 36px; margin-bottom: 8px; }
.result-score { font-size: 18px; color: #F57C00; font-weight: bold; margin-bottom: 8px; }
.result-detail { font-size: 14px; color: #8D6E63; margin-bottom: 16px; }

/* ===== 动画 ===== */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.3s ease-out; }

@keyframes pop { 0% { transform: scale(0.8); } 50% { transform: scale(1.1); } 100% { transform: scale(1); } }
.pop { animation: pop 0.3s ease-out; }

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-5px); }
    40% { transform: translateX(5px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(5px); }
}
.shake { animation: shake 0.4s ease-out; }

/* ===== 连击特效 ===== */
.combo-text {
    position: fixed;
    font-size: 28px; font-weight: bold;
    color: #FFD54F;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
    pointer-events: none;
    z-index: 9999;
    animation: comboFloat 1s ease-out forwards;
}
@keyframes comboFloat {
    0% { transform: translateY(0) scale(0.5); opacity: 0; }
    20% { transform: translateY(-20px) scale(1.2); opacity: 1; }
    100% { transform: translateY(-60px) scale(1); opacity: 0; }
}

/* ===== 粒子特效 ===== */
.particle {
    position: fixed;
    pointer-events: none;
    z-index: 9998;
    animation: particleFloat 1s ease-out forwards;
}
@keyframes particleFloat {
    0% { transform: translate(0, 0) scale(1); opacity: 1; }
    100% { transform: translate(var(--px), var(--py)) scale(0); opacity: 0; }
}

/* ===== 浮动分数 ===== */
.float-score {
    position: fixed;
    font-size: 20px; font-weight: bold;
    color: #7CB342;
    pointer-events: none;
    z-index: 9999;
    animation: scoreFloat 1s ease-out forwards;
}
@keyframes scoreFloat {
    0% { transform: translateY(0); opacity: 1; }
    100% { transform: translateY(-40px); opacity: 0; }
}
