* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
}

/* 背景动态效果 */
body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 20% 50%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
                radial-gradient(circle at 80% 20%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
                radial-gradient(circle at 40% 80%, rgba(255, 255, 255, 0.1) 0%, transparent 50%);
    animation: floatBackground 20s ease-in-out infinite;
    z-index: -1;
    /* 使用GPU加速 */
    transform: translateZ(0);
    will-change: transform;
}

@keyframes floatBackground {
    0%, 100% {
        transform: translate(0, 0) scale(1);
    }
    33% {
        transform: translate(30px, -30px) scale(1.1);
    }
    66% {
        transform: translate(-30px, 30px) scale(0.9);
    }
}

/* 移动端优化：禁用或简化动画 */
@media (prefers-reduced-motion: reduce), (max-width: 768px) {
    body::before {
        animation: none;
        /* 简化背景，移除复杂渐变 */
        background: radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.05) 0%, transparent 50%);
    }
}

.header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.back-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 0.9em;
    font-weight: bold;
    cursor: pointer;
    /* 精确指定过渡属性，避免不必要的性能开销 */
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    text-decoration: none;
    display: inline-block;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    /* 使用GPU加速 */
    transform: translateZ(0);
}

/* 移动端优化：简化渐变背景 */
@media (max-width: 768px) {
    body {
        /* 简化主背景渐变，使用单一颜色或简单渐变 */
        background: #667eea;
    }
    
    .back-btn {
        /* 简化按钮渐变 */
        background: #667eea;
        box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
    }
}

.back-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.game-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    padding: 20px;
    width: 90%;
    max-width: 800px;
    text-align: center;
    /* 使用GPU加速 */
    transform: translateZ(0);
}

/* 移动端优化：简化阴影效果 */
@media (max-width: 768px) {
    .game-container {
        box-shadow: 0 8px 16px rgba(0, 0, 0, 0.08);
        padding: 15px;
        width: 95%;
    }
    
    .back-btn:hover {
        box-shadow: 0 4px 12px rgba(102, 126, 234, 0.5);
    }
    
    /* 优化游戏统计信息布局 */
    .game-stats {
        flex-wrap: wrap;
        gap: 10px;
        justify-content: center;
    }
    
    .stat {
        margin: 0 5px;
    }
    
    /* 优化攻击按钮布局 */
    .attack-buttons {
        flex-direction: column;
        gap: 10px;
    }
    
    .attack-btn {
        padding: 12px 20px;
        font-size: 0.9em;
    }
    
    /* 优化字体大小 */
    h1 {
        font-size: 1.8em;
    }
    
    h2 {
        font-size: 1.5em;
    }
    
    /* 优化怪兽区域 */
    .monster-area {
        margin-bottom: 20px;
    }
    
    .monster {
        margin: 0 auto;
        max-width: 250px;
    }
    
    /* 优化游戏消息区域 */
    .game-message {
        margin-top: 15px;
        padding: 10px;
    }
    
    /* 优化页脚 */
    .game-footer {
        font-size: 0.85em;
        padding: 10px;
    }
    
    /* 优化图形预览器 */
    .controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .control-group {
        min-width: auto;
    }
    
    .preview-area {
        min-height: 300px;
        padding: 10px;
    }
    
    .preview-container {
        margin-bottom: 20px;
    }
}

.game-header {
    margin-bottom: 20px;
}

.game-header h1 {
    color: #333;
    font-size: 2.5em;
    margin-bottom: 15px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.game-stats {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 20px;
}

.stat {
    background: #f0f0f0;
    padding: 10px 20px;
    border-radius: 25px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.stat .label {
    font-weight: bold;
    color: #666;
    margin-right: 5px;
}

.stat .value {
    font-size: 1.2em;
    font-weight: bold;
    color: #333;
    transition: all 0.5s ease;
    display: inline-block;
    position: relative;
}

.stat .value.changed {
    animation: statValueChange 0.6s ease-in-out;
}

.stat .value.score {
    color: #f39c12;
    text-shadow: 0 0 10px rgba(243, 156, 18, 0.5);
}

.stat .value.health {
    color: #e74c3c;
    text-shadow: 0 0 10px rgba(231, 76, 60, 0.5);
}

.stat .value.level {
    color: #9b59b6;
    text-shadow: 0 0 10px rgba(155, 89, 182, 0.5);
}

@keyframes statValueChange {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.3);
        opacity: 0.8;
        text-shadow: 0 0 20px currentColor;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* 数值增加时的特效 */
.stat .value.increased {
    animation: statValueIncrease 0.8s ease-in-out;
}

/* 数值减少时的特效 */
.stat .value.decreased {
    animation: statValueDecrease 0.8s ease-in-out;
}

@keyframes statValueIncrease {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.4) rotate(5deg);
        color: #2ecc71;
        text-shadow: 0 0 20px rgba(46, 204, 113, 0.8);
    }
}

@keyframes statValueDecrease {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.4) rotate(-5deg);
        color: #e74c3c;
        text-shadow: 0 0 20px rgba(231, 76, 60, 0.8);
    }
}

.game-main {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.monster-area {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 300px;
    position: relative;
}

.monster {
    text-align: center;
    transition: transform 0.3s ease;
}

.monster:hover {
    transform: scale(1.05);
}

.monster-name {
    font-size: 1.8em;
    font-weight: bold;
    color: #e74c3c;
    margin-bottom: 10px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
    animation: monsterNameAnimation 3s ease-in-out infinite;
    display: inline-block;
    position: relative;
}

@keyframes monsterNameAnimation {
    0%, 100% {
        transform: scale(1);
        color: #e74c3c;
        text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2), 0 0 10px rgba(231, 76, 60, 0.3);
    }
    25% {
        transform: scale(1.05);
        color: #ee5a24;
        text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2), 0 0 15px rgba(238, 90, 36, 0.5);
    }
    50% {
        transform: scale(1.1);
        color: #ff6b6b;
        text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2), 0 0 20px rgba(255, 107, 107, 0.7);
    }
    75% {
        transform: scale(1.05);
        color: #ee5a24;
        text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2), 0 0 15px rgba(238, 90, 36, 0.5);
    }
}

/* 怪兽愤怒时的名称特效 */
.monster.angry .monster-name {
    animation: monsterNameAngry 0.5s ease-in-out infinite;
    color: #c0392b;
    text-shadow: 0 0 25px rgba(192, 57, 43, 0.8);
}

@keyframes monsterNameAngry {
    0%, 100% {
        transform: scale(1.1) rotate(0deg);
    }
    25% {
        transform: scale(1.2) rotate(-2deg);
    }
    75% {
        transform: scale(1.2) rotate(2deg);
    }
}

.monster-health-bar {
    width: 200px;
    height: 20px;
    background: #ddd;
    border-radius: 10px;
    margin: 0 auto 20px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.monster-health {
    height: 100%;
    background: linear-gradient(90deg, #ff6b6b, #ee5a24);
    width: 100%;
    transition: width 0.5s ease;
    border-radius: 10px;
}

.monster-sprite {
    width: 200px;
    height: 200px;
    margin: 0 auto;
    position: relative;
}

.monster-body {
    width: 150px;
    height: 150px;
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 10px 20px rgba(231, 76, 60, 0.3), 0 0 30px rgba(255, 255, 255, 0.2);
    animation: breathe 2s ease-in-out infinite;
}

/* 眼睛 */
.monster-body::before {
    content: '';
    position: absolute;
    width: 50px;
    height: 50px;
    background: #fff;
    border-radius: 50%;
    top: 35px;
    left: 30px;
    box-shadow: 55px 0 0 #fff, 
                inset 0 0 10px rgba(0, 0, 0, 0.1);
}

/* 瞳孔 */
.monster-body::after {
    content: '';
    position: absolute;
    width: 25px;
    height: 25px;
    background: #333;
    border-radius: 50%;
    top: 45px;
    left: 42px;
    box-shadow: 55px 0 0 #333;
    animation: blink 3s ease-in-out infinite;
}

/* 高光 */
.monster-body {
    position: relative;
}

.monster-body .eye-highlight {
    content: '';
    position: absolute;
    width: 10px;
    height: 10px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    top: 50px;
    left: 45px;
    box-shadow: 55px 0 0 rgba(255, 255, 255, 0.8);
    z-index: 1;
}

/* 腮红 */
.monster-body .blush {
    content: '';
    position: absolute;
    width: 25px;
    height: 15px;
    background: rgba(255, 182, 193, 0.6);
    border-radius: 50%;
    top: 80px;
    left: 15px;
    box-shadow: 95px 0 0 rgba(255, 182, 193, 0.6);
    animation: blushPulse 3s ease-in-out infinite;
}

/* 嘴巴 - 正常表情 */
.monster-body .mouth {
    content: '';
    position: absolute;
    width: 40px;
    height: 20px;
    background: #333;
    border-radius: 0 0 40px 40px;
    top: 90px;
    left: 55px;
    transition: all 0.3s ease;
}

/* 嘴巴 - 受击表情 */
.monster.hit .monster-body .mouth {
    width: 50px;
    height: 30px;
    border-radius: 50%;
    top: 85px;
    left: 50px;
}

/* 嘴巴 - 愤怒表情 */
.monster.angry .monster-body .mouth {
    width: 40px;
    height: 5px;
    background: #e74c3c;
    border-radius: 5px;
    top: 100px;
    left: 55px;
    box-shadow: 0 0 10px rgba(231, 76, 60, 0.8);
}

/* 嘴巴 - 开心表情 */
.monster.happy .monster-body .mouth {
    width: 40px;
    height: 25px;
    background: #333;
    border-radius: 40px 40px 0 0;
    top: 85px;
    left: 55px;
}

/* 嘴巴 - 惊讶表情 */
.monster.surprised .monster-body .mouth {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    top: 90px;
    left: 60px;
}

/* 发怒表情 */
.monster.angry {
    animation: angryShake 0.5s ease-in-out infinite;
}

.monster.angry .monster-body::before {
    /* 发怒时的眼睛形状 */
    width: 55px;
    height: 45px;
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    transform: rotate(5deg);
    box-shadow: 55px 0 0 #fff, 
                inset 0 0 10px rgba(0, 0, 0, 0.1);
}

.monster.angry .monster-body::after {
    /* 发怒时的瞳孔 */
    width: 30px;
    height: 30px;
    top: 48px;
    left: 38px;
    box-shadow: 58px 0 0 #333;
    animation: angryBlink 0.5s ease-in-out infinite;
}

.monster.angry .monster-body .eye-highlight {
    /* 发怒时的高光 */
    opacity: 0.5;
    transform: scale(0.8);
}

.monster.angry .monster-body .blush {
    /* 发怒时的腮红 */
    background: rgba(255, 100, 100, 0.8);
    animation: angryBlush 0.3s ease-in-out infinite;
}

/* 悲伤表情 */
.monster.sad .monster-body::before {
    /* 悲伤时的眼睛形状 */
    width: 55px;
    height: 55px;
    border-radius: 50% 50% 50% 50% / 40% 40% 60% 60%;
    box-shadow: 55px 0 0 #fff, 
                inset 0 0 10px rgba(0, 0, 0, 0.1);
}

.monster.sad .monster-body::after {
    /* 悲伤时的瞳孔 */
    width: 20px;
    height: 20px;
    top: 55px;
    left: 45px;
    box-shadow: 55px 0 0 #333;
}

.monster.sad .monster-body .mouth {
    /* 悲伤时的嘴巴 */
    width: 40px;
    height: 5px;
    background: #333;
    border-radius: 5px;
    top: 95px;
    left: 55px;
    transform: rotate(180deg);
}

.monster.sad .monster-body .blush {
    /* 悲伤时的腮红 */
    background: rgba(200, 150, 255, 0.6);
    animation: sadBlush 2s ease-in-out infinite;
}

/* 发怒时的眨眼动画 */
@keyframes angryBlink {
    0%, 100% {
        height: 30px;
    }
    50% {
        height: 5px;
    }
}

/* 发怒时的抖动动画 */
@keyframes angryShake {
    0%, 100% {
        transform: scale(1);
    }
    25% {
        transform: scale(1.02) rotate(-1deg);
    }
    75% {
        transform: scale(1.02) rotate(1deg);
    }
}

/* 发怒时的腮红动画 */
@keyframes angryBlush {
    0%, 100% {
        opacity: 0.8;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.2);
    }
}

/* 悲伤时的腮红动画 */
@keyframes sadBlush {
    0%, 100% {
        opacity: 0.4;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(1.1);
    }
}

@keyframes breathe {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.05);
    }
}

@keyframes blink {
    0%, 90%, 100% {
        height: 25px;
    }
    95% {
        height: 2px;
    }
}

/* 腮红动画 */
@keyframes blushPulse {
    0%, 100% {
        opacity: 0.6;
        transform: scale(1);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.1);
    }
}

/* 更可爱的呼吸动画 */
@keyframes breathe {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.05);
        box-shadow: 0 15px 25px rgba(231, 76, 60, 0.4), 0 0 40px rgba(255, 255, 255, 0.3);
    }
}

/* 受击时的表情变化动画 */
@keyframes hitFace {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
    }
    25% {
        transform: translate(-55%, -50%) scale(1.05) rotate(-5deg);
    }
    75% {
        transform: translate(-45%, -50%) scale(1.05) rotate(5deg);
    }
}

.monster.hit .monster-body {
    animation: hitFace 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% {
        transform: translate(-50%, -50%) rotate(0deg);
    }
    25% {
        transform: translate(-55%, -50%) rotate(-5deg);
    }
    75% {
        transform: translate(-45%, -50%) rotate(5deg);
    }
}

.monster.hit .monster-body {
    animation: shake 0.5s ease-in-out;
}

.attack-area {
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
}

.attack-buttons {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

.attack-btn {
    padding: 15px 30px;
    font-size: 1.1em;
    font-weight: bold;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    min-width: 120px;
    position: relative;
    overflow: hidden;
}

.attack-btn span {
    position: relative;
    z-index: 1;
    transition: all 0.3s ease;
    display: inline-block;
}

.attack-btn:hover span {
    transform: scale(1.1);
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
    animation: buttonTextFloat 0.6s ease-in-out;
}

.attack-btn:active span {
    transform: scale(0.95);
    animation: buttonTextPress 0.2s ease-in-out;
}

@keyframes buttonTextFloat {
    0%, 100% {
        transform: scale(1.1);
    }
    50% {
        transform: scale(1.15);
    }
}

@keyframes buttonTextPress {
    0% {
        transform: scale(1.1);
    }
    50% {
        transform: scale(0.9);
    }
    100% {
        transform: scale(0.95);
    }
}

.attack-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.attack-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3), 0 0 20px rgba(255, 255, 255, 0.3);
    animation: pulse 1s infinite;
}

.attack-btn:active {
    transform: translateY(0);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}

.attack-btn:active::before {
    width: 300px;
    height: 300px;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3), 0 0 20px rgba(255, 255, 255, 0.3);
    }
    50% {
        box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3), 0 0 30px rgba(255, 255, 255, 0.5);
    }
}

.attack-btn:nth-child(1) {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
}

.attack-btn.special {
    background: linear-gradient(135deg, #9b59b6, #8e44ad);
    color: white;
}

.attack-btn.heal {
    background: linear-gradient(135deg, #2ecc71, #27ae60);
    color: white;
}

.attack-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.game-message {
    background: #f8f9fa;
    padding: 15px 30px;
    border-radius: 25px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.5s ease;
    animation: messageSlideIn 0.5s ease forwards;
}

.game-message.show {
    opacity: 1;
    transform: translateY(0);
}

.game-message p {
    font-size: 1.1em;
    color: #333;
    font-weight: bold;
    animation: messagePulse 1s ease-in-out;
}

@keyframes messageSlideIn {
    0% {
        opacity: 0;
        transform: translateY(20px) scale(0.9);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes messagePulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

/* 不同类型消息的颜色效果 */
.game-message.attack p {
    color: #3498db;
    text-shadow: 0 0 10px rgba(52, 152, 219, 0.5);
}

.game-message.special p {
    color: #9b59b6;
    text-shadow: 0 0 15px rgba(155, 89, 182, 0.6);
}

.game-message.heal p {
    color: #2ecc71;
    text-shadow: 0 0 10px rgba(46, 204, 113, 0.5);
}

.game-message.victory p {
    color: #f39c12;
    text-shadow: 0 0 15px rgba(243, 156, 18, 0.6);
    animation: victoryPulse 1.5s ease-in-out infinite;
}

.game-message.levelup p {
    color: #e67e22;
    text-shadow: 0 0 20px rgba(230, 126, 34, 0.7);
    animation: levelUpText 1s ease-out;
}

.game-message.warning p {
    color: #e74c3c;
    text-shadow: 0 0 10px rgba(231, 76, 60, 0.5);
    animation: warningShake 0.5s ease-in-out;
}

@keyframes victoryPulse {
    0%, 100% {
        transform: scale(1);
        text-shadow: 0 0 15px rgba(243, 156, 18, 0.6);
    }
    50% {
        transform: scale(1.1);
        text-shadow: 0 0 25px rgba(243, 156, 18, 0.9);
    }
}

@keyframes levelUpText {
    0% {
        transform: scale(0.8) rotate(-5deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.2) rotate(5deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

@keyframes warningShake {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-5px);
    }
    75% {
        transform: translateX(5px);
    }
}

.game-footer {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #eee;
    color: #666;
    font-size: 0.9em;
}

.damage-text {
    position: absolute;
    font-size: 1.5em;
    font-weight: bold;
    color: #e74c3c;
    pointer-events: none;
    animation: floatUp 1s ease-out forwards;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

@keyframes floatUp {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-50px) scale(1.2);
    }
}

.level-up {
    animation: levelUp 1s ease-out;
}

@keyframes levelUp {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
        color: #f39c12;
    }
}

/* 技能释放特效 */
.skill-effect {
    position: absolute;
    pointer-events: none;
    border-radius: 50%;
    animation: skillExplosion 0.8s ease-out forwards;
}

/* 技能名称显示 */
.skill-name {
    position: absolute;
    font-size: 1.5em;
    font-weight: bold;
    pointer-events: none;
    z-index: 10;
    animation: skillNameAnimation 1s ease-out forwards;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.skill-name.normal {
    color: #3498db;
    text-shadow: 0 0 15px rgba(52, 152, 219, 0.8);
}

.skill-name.special {
    color: #9b59b6;
    text-shadow: 0 0 20px rgba(155, 89, 182, 0.9);
}

.skill-name.heal {
    color: #2ecc71;
    text-shadow: 0 0 15px rgba(46, 204, 113, 0.8);
}

@keyframes skillNameAnimation {
    0% {
        opacity: 0;
        transform: translateY(30px) scale(0.5) rotate(-10deg);
    }
    50% {
        opacity: 1;
        transform: translateY(-10px) scale(1.2) rotate(5deg);
    }
    100% {
        opacity: 0;
        transform: translateY(-50px) scale(0.8) rotate(0deg);
    }
}

/* 怪兽互动文字样式 */
.monster-line {
    position: absolute;
    font-size: 1.2em;
    font-weight: bold;
    pointer-events: none;
    z-index: 100;
    animation: monsterLineAnimation 2s ease-out forwards;
    max-width: 200px;
    text-align: center;
    padding: 10px 15px;
    border-radius: 20px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    /* 移除固定位置，改为动态生成 */
}

.monster-line::before {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 10px 10px 0;
    border-style: solid;
    border-color: rgba(0, 0, 0, 0.7) transparent transparent;
    /* 根据气泡位置调整三角指向 */
}

/* 不同位置的气泡三角指向 */
.monster-line.top::before {
    bottom: auto;
    top: -10px;
    border-width: 0 10px 10px;
    border-color: transparent transparent rgba(0, 0, 0, 0.7);
}

.monster-line.left::before {
    left: 20px;
    transform: none;
}

.monster-line.right::before {
    left: auto;
    right: 20px;
    transform: none;
}

/* 为不同类型气泡设置不同的动画 */
@keyframes monsterLineAnimation {
    0% {
        opacity: 0;
        transform: scale(0.8) rotate(random(10deg) - 5deg);
    }
    20% {
        opacity: 1;
        transform: scale(1.1) rotate(random(10deg) - 5deg);
    }
    80% {
        opacity: 1;
        transform: scale(1) rotate(random(10deg) - 5deg);
    }
    100% {
        opacity: 0;
        transform: scale(0.8) translateY(-30px) rotate(random(10deg) - 5deg);
    }
}

.monster-line.normal {
    background: rgba(52, 152, 219, 0.9);
}

.monster-line.normal::before {
    border-color: rgba(52, 152, 219, 0.9) transparent transparent;
}

.monster-line.special {
    background: rgba(155, 89, 182, 0.9);
    font-size: 1.3em;
    animation: monsterLineSpecial 2s ease-out forwards;
}

.monster-line.special::before {
    border-color: rgba(155, 89, 182, 0.9) transparent transparent;
}

.monster-line.low-health {
    background: rgba(231, 76, 60, 0.9);
    font-size: 1.3em;
    animation: monsterLineLowHealth 2s ease-out forwards;
}

.monster-line.low-health::before {
    border-color: rgba(231, 76, 60, 0.9) transparent transparent;
}

.monster-line.counterattack {
    background: rgba(243, 156, 18, 0.9);
}

.monster-line.counterattack::before {
    border-color: rgba(243, 156, 18, 0.9) transparent transparent;
}

.monster-line.defeated {
    background: rgba(128, 128, 128, 0.9);
    font-size: 1.4em;
    animation: monsterLineDefeated 2.5s ease-out forwards;
}

.monster-line.defeated::before {
    border-color: rgba(128, 128, 128, 0.9) transparent transparent;
}

@keyframes monsterLineAnimation {
    0% {
        opacity: 0;
        transform: translateY(20px) scale(0.8);
    }
    20% {
        opacity: 1;
        transform: translateY(0) scale(1.1);
    }
    80% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-30px) scale(0.8);
    }
}

@keyframes monsterLineSpecial {
    0% {
        opacity: 0;
        transform: translateY(20px) scale(0.8) rotate(-5deg);
    }
    30% {
        opacity: 1;
        transform: translateY(-10px) scale(1.3) rotate(5deg);
    }
    70% {
        opacity: 1;
        transform: translateY(-10px) scale(1.2) rotate(0deg);
    }
    100% {
        opacity: 0;
        transform: translateY(-40px) scale(0.9);
    }
}

@keyframes monsterLineLowHealth {
    0% {
        opacity: 0;
        transform: translateY(20px) scale(0.8);
    }
    20% {
        opacity: 1;
        transform: translateY(0) scale(1.2);
    }
    40% {
        transform: translateY(0) scale(1.3) rotate(-3deg);
    }
    60% {
        transform: translateY(0) scale(1.3) rotate(3deg);
    }
    80% {
        opacity: 1;
        transform: translateY(0) scale(1.2);
    }
    100% {
        opacity: 0;
        transform: translateY(-30px) scale(0.8);
    }
}

@keyframes monsterLineDefeated {
    0% {
        opacity: 0;
        transform: translateY(20px) scale(0.8);
    }
    20% {
        opacity: 1;
        transform: translateY(0) scale(1.2);
    }
    70% {
        opacity: 1;
        transform: translateY(0) scale(1.1);
    }
    100% {
        opacity: 0;
        transform: translateY(-50px) scale(0.7);
    }
}

.skill-effect.normal {
    background: radial-gradient(circle, rgba(52, 152, 219, 0.8), transparent);
    box-shadow: 0 0 30px rgba(52, 152, 219, 0.8);
}

.skill-effect.special {
    background: radial-gradient(circle, rgba(155, 89, 182, 0.8), transparent);
    box-shadow: 0 0 50px rgba(155, 89, 182, 0.8), 0 0 100px rgba(155, 89, 182, 0.5);
}

.skill-effect.heal {
    background: radial-gradient(circle, rgba(46, 204, 113, 0.8), transparent);
    box-shadow: 0 0 30px rgba(46, 204, 113, 0.8);
}

@keyframes skillExplosion {
    0% {
        width: 0;
        height: 0;
        opacity: 1;
    }
    100% {
        width: 300px;
        height: 300px;
        opacity: 0;
    }
}

/* 怪兽受击增强特效 */
.monster.hit {
    animation: monsterHit 0.5s ease-in-out;
}

@keyframes monsterHit {
    0%, 100% {
        transform: scale(1);
    }
    25% {
        transform: scale(0.9) rotate(-5deg);
        filter: brightness(0.8) saturate(1.5);
    }
    50% {
        transform: scale(1.1) rotate(5deg);
        filter: brightness(1.2) saturate(2);
    }
    75% {
        transform: scale(0.95) rotate(-3deg);
        filter: brightness(0.9) saturate(1.8);
    }
}

/* 怪兽死亡特效 */
.monster.dead {
    animation: monsterDeath 1.5s ease-out forwards;
}

@keyframes monsterDeath {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.2) rotate(10deg);
        opacity: 0.8;
        filter: brightness(0.5) saturate(0.5);
    }
    100% {
        transform: scale(0.5) rotate(-20deg);
        opacity: 0;
        filter: brightness(0) saturate(0);
    }
}

/* 升级全屏特效 */
.level-up-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(243, 156, 18, 0.3), transparent);
    pointer-events: none;
    animation: levelUpFlash 1s ease-out forwards;
    z-index: 1000;
}

@keyframes levelUpFlash {
    0% {
        opacity: 0;
        transform: scale(0.5);
    }
    50% {
        opacity: 1;
        transform: scale(1.2);
    }
    100% {
        opacity: 0;
        transform: scale(2);
    }
}

/* 治疗特效 */
.heal-effect {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(46, 204, 113, 0.6), transparent);
    border-radius: 50%;
    animation: healPulse 1s ease-out forwards;
    pointer-events: none;
}

@keyframes healPulse {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }
    50% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.2);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(2);
    }
}

/* 得分弹出特效 */
.score-popup {
    position: absolute;
    font-size: 1.2em;
    font-weight: bold;
    color: #f39c12;
    pointer-events: none;
    animation: scoreFloat 1s ease-out forwards;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

@keyframes scoreFloat {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-30px) scale(1.5);
    }
}

@media (max-width: 600px) {
    .game-container {
        width: 95%;
        padding: 15px;
    }
    
    .game-header h1 {
        font-size: 2em;
    }
    
    .game-stats {
        gap: 15px;
        flex-wrap: wrap;
    }
    
    .stat {
        padding: 8px 15px;
    }
    
    .monster-sprite {
        width: 150px;
        height: 150px;
    }
    
    .monster-body {
        width: 120px;
        height: 120px;
    }
    
    .attack-buttons {
        flex-direction: column;
        gap: 10px;
    }
    
    .attack-btn {
        width: 200px;
    }
}