/* ===== 小恐龍寵物（本體、動畫、彩蛋）===== */
/* Pet Styles */
.pet-area {
    position: fixed;
    bottom: 0; left: 0; width: 100%; height: 180px; 
    z-index: 999999; pointer-events: none;
}

.pet-container {
    position: absolute; bottom: 20px; left: 50%;
    transform: translateX(-50%);
    display: flex; flex-direction: column; align-items: center;
    transition: left 3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: auto !important;
}

.pet-speech-bubble {
    background: var(--bg-color);
    color: var(--text-color);
    padding: 8px 16px; border-radius: 12px;
    font-size: 0.8rem; font-weight: 700;
    margin-bottom: 12px; border: 2px solid var(--primary-color);
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    white-space: nowrap; position: relative; pointer-events: none;
}

.pet-speech-bubble::after {
    content: ''; position: absolute; bottom: -8px; left: 50%;
    transform: translateX(-50%);
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid var(--primary-color);
}

.pet-dino {
    width: 48.4px; height: 51.7px;
    background-image: url('../sprite.png');
    background-size: 1356.3px 74.8px; /* 原圖 1233x68 放大 1.1 倍，position 需同步 x1.1 */
    background-repeat: no-repeat; background-position: -44px -2.2px;
    transform: var(--flip, scaleX(1));
    transition: transform 0.3s; cursor: pointer !important;
    user-select: none; image-rendering: pixelated;
    filter: drop-shadow(0 0 2px #fff); margin-bottom: 12px;
    pointer-events: auto !important;
}

.pet-dino.walking { animation: dino-run 0.2s steps(1) infinite; }
@keyframes dino-run { 0% { background-position: -1029.6px -2.2px; } 50% { background-position: -1078px -2.2px; } }

/* 開心小跳：transform 帶上 --flip 保留恐龍面向 */
.pet-dino.jumping { animation: dino-jump 0.7s ease; }
@keyframes dino-jump {
    0%, 55%, 100% { transform: var(--flip, scaleX(1)) translateY(0); }
    25% { transform: var(--flip, scaleX(1)) translateY(-18px); }
    80% { transform: var(--flip, scaleX(1)) translateY(-10px); }
}

/* 蹲下 frame（原圖 x=1112 寬 59，乘 1.1）：拍拍/暴雨/午睡共用 */
.pet-dino.ducking, .pet-dino.scared, .pet-container.napping .pet-dino {
    width: 64.9px;
    background-position: -1223.2px -2.2px;
    animation: none;
}

/* 暴雨害怕發抖（偶發彩蛋，約 5 秒） */
.pet-dino.scared { animation: dino-shake 0.2s infinite; }
@keyframes dino-shake {
    0%, 100% { transform: var(--flip, scaleX(1)) translateX(0); }
    25% { transform: var(--flip, scaleX(1)) translateX(-2px); }
    75% { transform: var(--flip, scaleX(1)) translateX(2px); }
}

/* 午睡 Zzz 泡泡 */
.pet-container.napping::after {
    content: '💤';
    position: absolute;
    bottom: 100px; left: 58%;
    font-size: 1rem;
    pointer-events: none;
    animation: zzz-float 2.5s ease-out infinite;
}
@keyframes zzz-float {
    0% { opacity: 0; transform: translate(0, 0) scale(0.7); }
    30% { opacity: 1; }
    100% { opacity: 0; transform: translate(10px, -26px) scale(1.15); }
}

.pet-dino.happy { filter: drop-shadow(0 0 10px #ff0) brightness(1.2); }
.pet-dino.hungry { filter: grayscale(1) opacity(0.7); }
/* dead 放最後：優先權蓋過 ducking/scared，死掉時不再蹲下發抖 */
.pet-dino.dead { background-position: -1174.8px -2.2px; width: 48.4px; animation: none; }

/* 翼手龍彩蛋（原圖 x=134/180 寬 46 高 40，乘 1.1；面向左，由右往左飛） */
.ptero {
    position: fixed;
    right: 0;
    width: 50.6px; height: 44px;
    background-image: url('../sprite.png');
    background-size: 1356.3px 74.8px;
    background-repeat: no-repeat;
    background-position: -147.4px -2.2px;
    image-rendering: pixelated;
    filter: drop-shadow(0 0 2px #fff);
    z-index: 999998;
    pointer-events: none;
    animation: ptero-fly 8s linear forwards, ptero-flap 0.4s steps(1) infinite;
}
@keyframes ptero-fly {
    from { transform: translateX(60px); }
    to { transform: translateX(calc(-100vw - 60px)); }
}
@keyframes ptero-flap {
    0%, 100% { background-position: -147.4px -2.2px; }
    50% { background-position: -198px -2.2px; }
}

/* 仙人掌彩蛋：偶爾滑過地面，小恐龍跳過去（尺寸/座標由 JS 依大小款式設定） */
.easter-cactus {
    position: fixed;
    right: 0;
    background-image: url('../sprite.png');
    background-size: 1356.3px 74.8px;
    background-repeat: no-repeat;
    image-rendering: pixelated;
    filter: drop-shadow(0 0 2px #fff);
    z-index: 999998;
    pointer-events: none;
    animation: ptero-fly 5s linear forwards; /* 與翼手龍同 keyframes；等效遊戲起始速度，跳單顆剛好 */
}

/* 躍過仙人掌的單次跳躍：精確拋物線，與遊戲內物理同款
   （初速 -10.6、重力 0.6/frame → 高 ~100px、滯空 ~0.6s；
   cubic-bezier(1/3, 2/3, 2/3, 1) 是二次減速曲線的精確表示，下降段取鏡像） */
.pet-dino.hopping { animation: dino-hop 0.6s linear; }
@keyframes dino-hop {
    0% { transform: var(--flip, scaleX(1)) translateY(0); animation-timing-function: cubic-bezier(0.333, 0.667, 0.667, 1); }
    50% { transform: var(--flip, scaleX(1)) translateY(-100px); animation-timing-function: cubic-bezier(0.333, 0, 0.667, 0.333); }
    100% { transform: var(--flip, scaleX(1)) translateY(0); }
}

