/* ==========================================
   游戏整体样式与厚涂手绘风格
   ========================================== */

:root {
    --bg-sky: #1a1c2e;
    --bg-ground: #2d2438;
    --color-wood: #7c4a32;
    --color-wood-dark: #502d1e;
    --color-raccoon: #707070;
    --color-raccoon-dark: #4a4a4a;
    --color-apron: #a8dadc;
    --color-apron-strap: #457b9d;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
}

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background-color: var(--bg-sky);
    color: #fff;
}

/* 游戏容器 */
.game-container {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 480px;
    margin: 0 auto;
    background: linear-gradient(to bottom, #0f1123 0%, #1a1c2e 50%, #2d2438 100%);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
}

/* ==========================================
   背景元素：星空、月亮、小动物
   ========================================== */

/* 闪烁的星空 */
.stars {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 60%;
    background-image: 
        radial-gradient(circle, #fff 1px, transparent 1.5px),
        radial-gradient(circle, #fff 1.5px, transparent 2px),
        radial-gradient(circle, rgba(255,255,255,0.7) 1px, transparent 1px);
    background-size: 120px 120px, 200px 200px, 80px 80px;
    background-position: 0 0, 40px 60px, 10px 10px;
    opacity: 0.6;
    animation: twinkle 4s infinite alternate ease-in-out;
}

@keyframes twinkle {
    0% { opacity: 0.4; }
    100% { opacity: 0.8; }
}

/* 弯弯的月亮 */
.moon {
    position: absolute;
    top: 40px;
    right: 40px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    box-shadow: -10px 10px 0 0 #fdf6e2;
    transform: rotate(-15deg);
    filter: drop-shadow(0 0 8px rgba(253, 246, 226, 0.4));
}

/* 篝火晚会模式：背景小动物 */
.party-animals {
    position: absolute;
    bottom: 180px;
    width: 100%;
    display: flex;
    justify-content: space-around;
    padding: 0 20px;
    pointer-events: none;
    z-index: 1;
}

.animal {
    font-size: 36px;
    opacity: 0;
    transform: translateY(50px) scale(0.5);
    transition: all 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* 晚会模式激活时的动画 */
.party-active .animal {
    opacity: 0.85;
    transform: translateY(0) scale(1);
}

.party-active .rabbit {
    animation: animal-bounce-1 1.2s infinite alternate ease-in-out;
}
.party-active .squirrel {
    animation: animal-bounce-2 1s infinite alternate ease-in-out 0.2s;
}
.party-active .fox {
    animation: animal-bounce-1 1.4s infinite alternate ease-in-out 0.4s;
}

@keyframes animal-bounce-1 {
    0% { transform: translateY(0) rotate(-5deg); }
    100% { transform: translateY(-15px) rotate(5deg); }
}

@keyframes animal-bounce-2 {
    0% { transform: translateY(0) scaleX(1); }
    100% { transform: translateY(-20px) scaleX(-1); }
}

/* ==========================================
   顶部状态栏
   ========================================== */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    z-index: 10;
}

.stars-collected {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 16px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 5px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.star-icon {
    animation: pulse 1.5s infinite alternate;
}

@keyframes pulse {
    0% { transform: scale(1); }
    100% { transform: scale(1.2); }
}

.streak-badge {
    font-size: 12px;
    background: rgba(0, 0, 0, 0.4);
    padding: 6px 12px;
    border-radius: 15px;
    color: #ffd166;
    border: 1px solid rgba(255, 209, 102, 0.3);
    transition: all 0.5s ease;
}

.streak-badge.active {
    background: linear-gradient(135deg, #ff6b6b, #ffbe0b);
    color: #fff;
    box-shadow: 0 0 10px rgba(255, 107, 107, 0.6);
    animation: rainbow-border 3s infinite linear;
}

/* ==========================================
   游戏主场景与小浣熊
   ========================================== */
.scene {
    position: relative;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding-bottom: 20px;
}

/* 小浣熊容器 */
.raccoon-container {
    position: absolute;
    left: 20px;
    bottom: 120px;
    width: 120px;
    height: 150px;
    z-index: 5;
}

/* 浣熊对话气泡 */
.raccoon-bubble {
    position: absolute;
    top: -85px;
    left: -10px;
    width: 160px;
    background: white;
    color: #333;
    padding: 10px;
    border-radius: 12px;
    font-size: 12px;
    line-height: 1.4;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    pointer-events: none;
    opacity: 0.95;
    transform-origin: bottom left;
    animation: bubble-float 3s infinite ease-in-out;
}

.raccoon-bubble::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 40px;
    border-width: 8px 8px 0;
    border-style: solid;
    border-color: white transparent;
    display: block;
    width: 0;
}

@keyframes bubble-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

/* 浣熊 CSS 手绘厚涂效果 */
.raccoon {
    position: relative;
    width: 100px;
    height: 120px;
    margin: 30px auto 0;
    transition: transform 0.3s ease;
}

/* 浣熊耳朵 */
.raccoon-ears .ear {
    position: absolute;
    width: 28px;
    height: 28px;
    background: var(--color-raccoon);
    border-radius: 50% 50% 10% 10%;
    border: 3px solid var(--color-raccoon-dark);
}
.raccoon-ears .ear::after {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    background: #ffb5a7;
    border-radius: 50%;
    top: 4px;
    left: 4px;
}
.raccoon-ears .ear.left {
    left: 10px;
    transform: rotate(-15deg);
}
.raccoon-ears .ear.right {
    right: 10px;
    transform: rotate(15deg);
}

/* 浣熊头部 */
.raccoon-head {
    position: absolute;
    top: 15px;
    left: 10px;
    width: 80px;
    height: 65px;
    background: var(--color-raccoon);
    border-radius: 40px 40px 35px 35px;
    border: 3px solid var(--color-raccoon-dark);
    z-index: 2;
    box-shadow: inset -4px -4px 0 rgba(0,0,0,0.15);
}

/* 浣熊眼罩 */
.raccoon-mask {
    position: absolute;
    top: 22px;
    left: 5px;
    width: 70px;
    height: 24px;
    background: #333;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    padding: 0 10px;
    align-items: center;
}

.raccoon-mask .eye {
    width: 10px;
    height: 10px;
    background: #fff;
    border-radius: 50%;
    position: relative;
}

.raccoon-mask .eye::after {
    content: '';
    position: absolute;
    width: 4px;
    height: 4px;
    background: #000;
    border-radius: 50%;
    top: 3px;
    left: 3px;
}

/* 浣熊鼻子 */
.raccoon-nose {
    position: absolute;
    bottom: 8px;
    left: 33px;
    width: 14px;
    height: 10px;
    background: #111;
    border-radius: 50% 50% 40% 40%;
}

/* 浣熊身体 */
.raccoon-body {
    position: absolute;
    bottom: 0;
    left: 15px;
    width: 70px;
    height: 55px;
    background: var(--color-raccoon);
    border-radius: 30px 30px 10px 10px;
    border: 3px solid var(--color-raccoon-dark);
    z-index: 1;
    box-shadow: inset -4px -2px 0 rgba(0,0,0,0.15);
}

/* 围裙 */
.apron {
    position: absolute;
    bottom: 0;
    left: 10px;
    width: 44px;
    height: 35px;
    background: var(--color-apron);
    border-radius: 5px 5px 15px 15px;
    border: 2px solid var(--color-apron-strap);
}

.apron::before {
    content: '';
    position: absolute;
    top: -10px;
    left: 12px;
    width: 16px;
    height: 10px;
    border: 2px solid var(--color-apron-strap);
    border-bottom: none;
    border-radius: 5px 5px 0 0;
}

/* 浣熊手臂 */
.raccoon-body .arm {
    position: absolute;
    width: 16px;
    height: 30px;
    background: var(--color-raccoon);
    border: 3px solid var(--color-raccoon-dark);
    border-radius: 10px;
    top: 10px;
    transition: transform 0.2s ease;
}

.raccoon-body .arm.left {
    left: -8px;
    transform-origin: top right;
    transform: rotate(20deg);
}

.raccoon-body .arm.right {
    right: -8px;
    transform-origin: top left;
    transform: rotate(-20deg);
}

/* 浣熊动画状态 */
/* 1. 拍手跳舞 (完美) */
.raccoon-happy {
    animation: raccoon-jump 0.6s infinite alternate ease-in-out;
}

.raccoon-happy .arm.left {
    animation: clap-left 0.3s infinite alternate ease-in-out;
}

.raccoon-happy .arm.right {
    animation: clap-right 0.3s infinite alternate ease-in-out;
}

@keyframes raccoon-jump {
    0% { transform: translateY(0) scaleY(1); }
    100% { transform: translateY(-25px) scaleY(0.95); }
}

@keyframes clap-left {
    0% { transform: rotate(20deg); }
    100% { transform: rotate(80deg) translateX(5px); }
}

@keyframes clap-right {
    0% { transform: rotate(-20deg); }
    100% { transform: rotate(-80deg) translateX(-5px); }
}

/* 2. 捂鼻子 (烤焦) */
.raccoon-sad {
    animation: raccoon-shiver 0.1s infinite;
}

.raccoon-sad .arm.right {
    transform: rotate(-110deg) translateY(-10px) translateX(-5px);
    z-index: 3;
}

@keyframes raccoon-shiver {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(2px); }
}


/* ==========================================
   篝火与烤架区域
   ========================================== */
.campfire-area {
    position: relative;
    width: 100%;
    height: 280px;
    display: flex;
    justify-content: center;
    align-items: flex-end;
}

/* 烤棉花糖的树枝 */
.stick-container {
    position: absolute;
    bottom: 110px;
    left: 45%;
    width: 180px;
    height: 120px;
    transform-origin: bottom left;
    transform: rotate(-25deg);
    z-index: 4;
    pointer-events: none; /* 允许穿透滑动棉花糖 */
}

.stick {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 6px;
    background: #5c3d2e;
    border-radius: 3px;
    box-shadow: inset 0 2px 0 rgba(255,255,255,0.1);
}

/* 树枝分叉，增加手绘感 */
.stick::before {
    content: '';
    position: absolute;
    top: -15px;
    right: 40px;
    width: 30px;
    height: 4px;
    background: #5c3d2e;
    transform: rotate(30deg);
    border-radius: 2px;
}

/* 棉花糖容器 */
.marshmallow-wrapper {
    position: absolute;
    right: -25px;
    top: -25px;
    width: 70px;
    height: 60px;
    pointer-events: auto; /* 重新开启鼠标/触摸事件 */
    cursor: grab;
}

.marshmallow-wrapper:active {
    cursor: grabbing;
}

/* 棉花糖本体 */
.marshmallow {
    position: relative;
    width: 100%;
    height: 100%;
    background-color: #ffffff;
    border-radius: 18px;
    border: 3px solid #e0dcd3;
    box-shadow: 
        inset -6px -6px 0 rgba(0, 0, 0, 0.05),
        0 4px 10px rgba(0, 0, 0, 0.15);
    display: flex;
    justify-content: center;
    align-items: center;
    transform-style: preserve-3d;
    transition: background-color 0.5s ease, border-color 0.5s ease, transform 0.1s ease-out;
    overflow: hidden;
}

/* 焦斑颗粒感纹理 */
.marshmallow .texture {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: radial-gradient(rgba(0,0,0,0.15) 1px, transparent 1px);
    background-size: 8px 8px;
    opacity: 0;
    transition: opacity 0.5s ease;
    pointer-events: none;
}

/* 棉花糖的小表情 */
.marshmallow-face {
    position: relative;
    width: 40px;
    height: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 5px;
    z-index: 2;
    transition: opacity 0.3s ease;
}

.m-eye {
    width: 6px;
    height: 6px;
    background: #4a3c31;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.m-mouth {
    position: absolute;
    bottom: 2px;
    left: 17px;
    width: 6px;
    height: 4px;
    border: 2px solid #4a3c31;
    border-top: none;
    border-radius: 0 0 4px 4px;
    transition: all 0.3s ease;
}

/* 表情变化：开心 */
.face-happy .m-eye {
    height: 3px;
    border-radius: 3px 3px 0 0;
    background: transparent;
    border: 2px solid #4a3c31;
    border-bottom: none;
}
.face-happy .m-mouth {
    width: 8px;
    height: 6px;
    left: 16px;
    border-radius: 50%;
    background: #ff85a1;
    border: none;
}

/* 表情变化：晕乎乎/烤焦 */
.face-burnt .m-eye {
    width: 8px;
    height: 8px;
    background: transparent;
    border: none;
    position: relative;
}
.face-burnt .m-eye::before, .face-burnt .m-eye::after {
    content: '';
    position: absolute;
    width: 8px;
    height: 2px;
    background: #332211;
    top: 3px;
}
.face-burnt .m-eye::before { transform: rotate(45deg); }
.face-burnt .m-eye::after { transform: rotate(-45deg); }
.face-burnt .m-mouth {
    width: 10px;
    height: 2px;
    background: #332211;
    border: none;
    border-radius: 0;
    left: 15px;
}

/* 冒烟动画 */
.smoke-container {
    position: absolute;
    top: -40px;
    left: 15px;
    width: 40px;
    height: 40px;
    pointer-events: none;
    display: none;
}

.smoke {
    position: absolute;
    width: 12px;
    height: 12px;
    background: rgba(180, 180, 180, 0.6);
    border-radius: 50%;
    opacity: 0;
}

.smoke:nth-child(1) { left: 5px; animation: rise-smoke 1.5s infinite ease-out; }
.smoke:nth-child(2) { left: 15px; animation: rise-smoke 1.5s infinite ease-out 0.4s; }
.smoke:nth-child(3) { left: 25px; animation: rise-smoke 1.5s infinite ease-out 0.8s; }

@keyframes rise-smoke {
    0% {
        transform: translateY(20px) scale(0.5);
        opacity: 0;
    }
    50% {
        opacity: 0.8;
        background: rgba(120, 120, 120, 0.4);
    }
    100% {
        transform: translateY(-40px) scale(2);
        opacity: 0;
    }
}


/* ==========================================
   篝火与火焰
   ========================================== */
.campfire {
    position: relative;
    width: 120px;
    height: 120px;
    margin-bottom: 10px;
}

/* 木柴 */
.wood {
    position: absolute;
    bottom: 10px;
    width: 90px;
    height: 18px;
    background: #5c3826;
    border-radius: 9px;
    border: 3px solid #3d2214;
    box-shadow: inset 0 3px 0 rgba(255,255,255,0.1);
}

.wood-1 {
    left: 5px;
    transform: rotate(12deg);
    z-index: 2;
}

.wood-2 {
    right: 5px;
    transform: rotate(-12deg);
    z-index: 1;
}

/* 火光环境晕染 */
.fire-glow {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 140px;
    height: 140px;
    background: radial-gradient(circle, rgba(255, 120, 0, 0.4) 0%, rgba(255, 60, 0, 0.1) 60%, transparent 100%);
    border-radius: 50%;
    z-index: 0;
    pointer-events: none;
    animation: glow-pulse 2s infinite alternate ease-in-out;
}

@keyframes glow-pulse {
    0% { transform: translateX(-50%) scale(0.9); opacity: 0.8; }
    100% { transform: translateX(-50%) scale(1.1); opacity: 1; }
}

/* 火焰本体 */
.flames {
    position: absolute;
    bottom: 25px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 80px;
    z-index: 3;
}

.flame {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    height: 100%;
    border-radius: 50% 50% 20% 20% / 60% 60% 40% 40%;
    transform-origin: bottom center;
}

.flame-back {
    width: 60px;
    height: 85px;
    background: #e63946;
    animation: sway 1.5s infinite alternate ease-in-out;
    opacity: 0.8;
}

.flame-mid {
    width: 45px;
    height: 70px;
    background: #f77f00;
    animation: sway 1.2s infinite alternate ease-in-out 0.2s;
}

.flame-front {
    width: 30px;
    height: 50px;
    background: #fcbf49;
    animation: sway 0.9s infinite alternate ease-in-out 0.4s;
}

@keyframes sway {
    0% {
        transform: translateX(-50%) scaleX(0.9) rotate(-3deg);
    }
    100% {
        transform: translateX(-50%) scaleX(1.1) rotate(3deg) scaleY(1.1);
    }
}

/* 火星子 */
.sparks .spark {
    position: absolute;
    width: 6px;
    height: 6px;
    background: #fcbf49;
    border-radius: 50%;
    opacity: 0;
}

.sparks .spark:nth-child(1) { left: 30px; bottom: 40px; animation: fly-spark 2s infinite ease-out; }
.sparks .spark:nth-child(2) { left: 60px; bottom: 50px; animation: fly-spark 1.8s infinite ease-out 0.5s; }
.sparks .spark:nth-child(3) { left: 90px; bottom: 35px; animation: fly-spark 2.2s infinite ease-out 1s; }

@keyframes fly-spark {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translateY(-100px) translateX(calc(-20px + 40px * random)) scale(0.2);
        opacity: 0;
    }
}


/* ==========================================
   底部控制区与火候条
   ========================================== */
.controls {
    background: rgba(26, 28, 46, 0.9);
    border-top: 3px solid #2d2438;
    padding: 20px;
    z-index: 10;
}

.indicator-container {
    width: 100%;
    margin-bottom: 15px;
}

.indicator-labels {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #a0aec0;
    margin-bottom: 6px;
    font-weight: bold;
}

.progress-track {
    position: relative;
    width: 100%;
    height: 16px;
    background: #2d3748;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid #4a5568;
}

/* 完美火候区间高亮 */
.perfect-zone {
    position: absolute;
    left: 55%; /* 对应 6-8 次翻转的区间 */
    width: 25%;
    height: 100%;
    background: rgba(72, 187, 120, 0.3);
    border-left: 2px dashed #48bb78;
    border-right: 2px dashed #48bb78;
    z-index: 1;
}

.progress-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(to right, #fff, #fbd38d, #ed8936, #744210, #1a202c);
    transition: width 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.1);
    z-index: 2;
    position: relative;
}

.status-text {
    text-align: center;
    font-size: 14px;
    margin-top: 8px;
    color: #ffd166;
    font-weight: bold;
}

/* 交互提示与重试按钮 */
.action-area {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 50px;
}

.swipe-hint {
    font-size: 14px;
    color: #a0aec0;
    animation: pulse 1.5s infinite alternate;
}

.btn-retry {
    background: linear-gradient(135deg, #ff9f1c, #ffbf69);
    border: none;
    color: #fff;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: bold;
    border-radius: 25px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(255, 159, 28, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
    animation: bounce 2s infinite;
}

.btn-retry:active {
    transform: scale(0.95);
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    60% { transform: translateY(-5px); }
}
