/* 动物大战僵尸 - 样式表 */

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

body {
    font-family: 'Inter', sans-serif;
    background: linear-gradient(135deg, #87CEEB 0%, #98FB98 50%, #90EE90 100%);
    min-height: 100vh;
    overflow-x: hidden;
    user-select: none;
}

/* 游戏头部 */
.game-header {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.game-header h1 {
    font-size: 2.5rem;
    color: #2c5530;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.game-info {
    display: flex;
    align-items: center;
    gap: 30px;
}

.resource-counter {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #ff6b35;
    color: white;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 1.2rem;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(255, 107, 53, 0.3);
}

.level-info {
    background: #4a90e2;
    color: white;
    padding: 10px 20px;
    border-radius: 20px;
    font-weight: 500;
}

.grid-info {
    background: #28a745;
    color: white;
    padding: 10px 20px;
    border-radius: 20px;
    font-weight: 500;
    font-size: 0.9rem;
}

.game-controls {
    display: flex;
    gap: 10px;
}

.control-btn {
    background: #28a745;
    border: none;
    color: white;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 3px 10px rgba(40, 167, 69, 0.3);
}

.control-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(40, 167, 69, 0.4);
}

/* 动物选择栏 */
.animal-selector {
    display: flex;
    justify-content: center;
    padding: 15px;
    gap: 10px;
    background: rgba(255, 255, 255, 0.8);
    margin: 10px auto;
    max-width: 1200px;
    width: 95%;
    border-radius: 15px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    flex-wrap: wrap; /* 允许换行以适应更多动物 */
}

.animal-card {
    background: linear-gradient(145deg, #ffffff, #f0f0f0);
    border-radius: 12px;
    padding: 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 3px solid transparent;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    min-width: 105px; /* 稍微缩小以适应更多卡片 */
    flex: 0 0 auto;
}

.animal-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    border-color: #4a90e2;
}

.animal-card.selected {
    border-color: #28a745;
    background: linear-gradient(145deg, #e8f5e8, #d4f4d4);
    transform: translateY(-3px);
}

.animal-card.insufficient {
    opacity: 0.5;
    cursor: not-allowed;
}

.animal-card.locked {
    opacity: 0.3;
    cursor: not-allowed;
    filter: grayscale(1);
    position: relative;
}

.animal-card.locked::after {
    content: '🔒';
    position: absolute;
    top: 5px;
    right: 5px;
    font-size: 1rem;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 2px 4px;
    border-radius: 3px;
}

/* 新动物特殊样式 */
.animal-card[data-animal="wolf"] {
    background: linear-gradient(145deg, #E6E6FA, #D8BFD8);
    border-color: #4169E1;
}

.animal-card[data-animal="wolf"]:hover {
    border-color: #1E90FF;
    box-shadow: 0 8px 25px rgba(65, 105, 225, 0.3);
}

.animal-card[data-animal="tiger"] {
    background: linear-gradient(145deg, #FFE4B5, #FFDEAD);
    border-color: #FF4500;
}

.animal-card[data-animal="tiger"]:hover {
    border-color: #FF6347;
    box-shadow: 0 8px 25px rgba(255, 69, 0, 0.3);
}

/* 狼王和猛虎的特殊动画 */
.animal[data-type="wolf"] {
    animation: wolfGlow 2s ease-in-out infinite;
}

.animal[data-type="tiger"] {
    animation: tigerGlow 1.5s ease-in-out infinite;
}

@keyframes wolfGlow {
    0%, 100% {
        filter: brightness(1);
        text-shadow: 0 0 5px rgba(65, 105, 225, 0.5);
    }
    50% {
        filter: brightness(1.2);
        text-shadow: 0 0 10px rgba(65, 105, 225, 0.8);
    }
}

@keyframes tigerGlow {
    0%, 100% {
        filter: brightness(1);
        text-shadow: 0 0 5px rgba(255, 69, 0, 0.5);
    }
    50% {
        filter: brightness(1.2);
        text-shadow: 0 0 10px rgba(255, 69, 0, 0.8);
    }
}

.animal-icon {
    font-size: 3rem;
    margin-bottom: 8px;
    display: block;
}

.animal-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: #333;
    margin-bottom: 5px;
}

.animal-cost {
    color: #ff6b35;
    font-weight: 600;
    font-size: 0.85rem;
}

/* 游戏主区域 */
.game-main {
    position: relative;
    margin: 10px auto;
    max-width: 1200px; /* 设置最大宽度 */
    width: 95%; /* 使用屏幕的95%宽度 */
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="60" height="60" viewBox="0 0 60 60"><rect width="60" height="60" fill="%2398FB98"/><circle cx="15" cy="15" r="2" fill="%2390EE90"/><circle cx="45" cy="45" r="1.5" fill="%2387CEEB"/></svg>');
    border-radius: 15px;
    box-shadow: inset 0 4px 20px rgba(0, 0, 0, 0.1);
    padding: 20px;
    min-height: 500px; /* 确保有足够的高度 */
    display: flex;
    align-items: center;
    gap: 20px;
}
    gap: 20px;
}

/* 房子区域 */
.house-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 120px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    border: 3px solid #8B4513;
}

.house {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 10px;
    filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.3));
}

.house-roof {
    font-size: 3rem;
    margin-bottom: -10px;
    z-index: 2;
    animation: houseGlow 3s ease-in-out infinite alternate;
}

.house-body {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 1.5rem;
    background: rgba(139, 69, 19, 0.1);
    padding: 5px 10px;
    border-radius: 5px;
}

.house-door {
    font-size: 2rem;
}

.house-window {
    font-size: 1.5rem;
}

.house-text {
    font-size: 0.9rem;
    font-weight: 600;
    color: #8B4513;
    text-align: center;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.8);
}

@keyframes houseGlow {
    0% {
        filter: brightness(1) drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.3));
    }
    100% {
        filter: brightness(1.2) drop-shadow(2px 2px 8px rgba(255, 215, 0, 0.5));
    }
}

/* 房子被攻击时的震动效果 */
.house-area.under-attack {
    animation: houseShake 0.5s ease-in-out;
}

@keyframes houseShake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-2px); }
    20%, 40%, 60%, 80% { transform: translateX(2px); }
}

/* 房子警告状态 */
.house-area.warning {
    border-color: #FFA500;
    background: rgba(255, 165, 0, 0.15);
    animation: houseWarning 1s ease-in-out infinite;
}

.house-area.danger {
    border-color: #ff0000;
    background: rgba(255, 0, 0, 0.2);
    animation: houseDanger 0.5s ease-in-out infinite;
}

@keyframes houseWarning {
    0%, 100% { 
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); 
        border-width: 2px;
    }
    50% { 
        box-shadow: 0 4px 15px rgba(255, 165, 0, 0.4);
        border-width: 3px;
    }
}

@keyframes houseDanger {
    0%, 100% { 
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); 
        border-width: 2px;
    }
    50% { 
        box-shadow: 0 6px 20px rgba(255, 0, 0, 0.6);
        border-width: 4px;
    }
}
}

.house-area.danger .house-text {
    color: #ff0000;
    animation: dangerBlink 1s infinite;
}

@keyframes dangerBlink {
    0%, 50% { opacity: 1; }
    25%, 75% { opacity: 0.5; }
}

/* 游戏网格 */
.game-grid {
    display: grid;
    grid-template-columns: repeat(12, 70px); /* 12列，每列70px */
    grid-template-rows: repeat(6, 70px);     /* 6行，每行70px */
    gap: 4px; /* 稍微减小间隙 */
    background: rgba(255, 255, 255, 0.3);
    padding: 15px;
    border-radius: 12px;
    border: 3px solid #228B22;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    justify-content: center; /* 居中对齐网格 */
    flex: 1; /* 占据剩余空间 */
}

.grid-cell {
    background: rgba(144, 238, 144, 0.4);
    border: 1px dashed rgba(34, 139, 34, 0.3);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    min-height: 60px; /* 确保最小高度 */
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.grid-cell:hover {
    background: rgba(144, 238, 144, 0.7);
    border-color: #228B22;
    transform: scale(1.03); /* 稍微减小缩放以适应更密集的网格 */
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1), 0 2px 8px rgba(34, 139, 34, 0.3);
}

.grid-cell.occupied {
    cursor: default;
    background: rgba(255, 255, 255, 0.8);
    border: 2px solid #28a745;
}

.grid-cell.can-place {
    background: rgba(40, 167, 69, 0.2);
    border-color: #28a745;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% { opacity: 0.7; }
    50% { opacity: 1; }
    100% { opacity: 0.7; }
}

/* 动物样式 */
.animal {
    font-size: 2.5rem;
    animation: animalSpawn 0.5s ease;
    cursor: pointer;
    position: relative;
    z-index: 2;
}

@keyframes animalSpawn {
    0% {
        transform: scale(0) rotate(180deg);
        opacity: 0;
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

.animal.attacking {
    animation: attack 0.3s ease;
}

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

/* 僵尸生成区域 */
.zombie-spawn {
    position: absolute;
    right: 0;
    top: 0;
    width: 50px;
    height: 100%;
    z-index: 1;
    pointer-events: none; /* 不干扰其他元素的交互 */
}

/* 僵尸样式 */
.zombie {
    position: absolute;
    font-size: 2.5rem;
    z-index: 1;
    animation: zombieSpawn 0.8s ease;
    transition: all 0.3s ease;
}

@keyframes zombieSpawn {
    0% {
        transform: translateX(100px) scale(0);
        opacity: 0;
    }
    100% {
        transform: translateX(0) scale(1);
        opacity: 1;
    }
}

.zombie.dying {
    animation: zombieDeath 0.6s ease forwards;
}

@keyframes zombieDeath {
    0% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: scale(0.3) rotate(180deg);
        opacity: 0;
    }
}

/* 生命值条 */
.health-bar {
    position: absolute;
    top: -8px;
    left: 0;
    width: 100%;
    height: 4px;
    background: rgba(255, 0, 0, 0.3);
    border-radius: 2px;
}

.health-fill {
    height: 100%;
    background: linear-gradient(90deg, #ff0000, #ff6b35);
    border-radius: 2px;
    transition: width 0.3s ease;
}

/* 状态面板 */
.status-panel {
    margin: 10px auto;
    max-width: 1200px;
    width: 95%;
    background: rgba(255, 255, 255, 0.9);
    padding: 15px;
    border-radius: 15px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    backdrop-filter: blur(10px);
}

.wave-info {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.wave-progress {
    width: 200px;
    height: 8px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #28a745, #20c997);
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

.game-stats {
    display: flex;
    gap: 30px;
}

.stat {
    text-align: center;
    font-weight: 500;
}

/* 投射物 */
.projectile {
    position: absolute;
    width: 15px;
    height: 15px;
    background: #8B4513;
    border-radius: 50%;
    z-index: 2;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

.projectile.bone {
    background: linear-gradient(45deg, #F5F5DC, #DDBF94);
    border: 2px solid #8B7355;
}

.projectile.bamboo {
    background: linear-gradient(45deg, #90EE90, #32CD32);
    border-radius: 2px;
    width: 20px;
    height: 4px;
}

/* 资源掉落物 */
.resource-drop {
    position: absolute;
    font-size: 2.2rem; /* 增大萝卜大小 */
    z-index: 3;
    animation: resourceDrop 0.5s ease;
    cursor: pointer;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3); /* 添加阴影使其更突出 */
    transition: all 0.2s ease;
}

.resource-drop::before {
    content: '';
    position: absolute;
    top: -10px;
    left: -10px;
    right: -10px;
    bottom: -10px;
    background: radial-gradient(circle, rgba(255, 165, 0, 0.2) 0%, rgba(255, 215, 0, 0.1) 50%, transparent 70%);
    border-radius: 50%;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: -1;
    animation: resourceGlow 2s ease-in-out infinite;
}

@keyframes resourceGlow {
    0%, 100% {
        opacity: 0.3;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(1.1);
    }
}

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

.resource-drop:hover {
    transform: scale(1.3); /* 悬停时更大 */
    animation: bounce 0.6s infinite;
    filter: brightness(1.2); /* 悬停时发光效果 */
}

.resource-drop:hover::before {
    opacity: 1;
}

@keyframes bounce {
    0%, 100% { 
        transform: scale(1.3) translateY(0); 
        filter: brightness(1.2);
    }
    50% { 
        transform: scale(1.4) translateY(-8px); 
        filter: brightness(1.4) drop-shadow(0 0 10px orange);
    }
}

@keyframes autoCollectAnimation {
    0% {
        transform: translate(-50%, -50%) scale(1.2);
        opacity: 1;
        filter: brightness(1.3) drop-shadow(0 0 15px gold);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.5);
        opacity: 0.8;
        filter: brightness(1.5) drop-shadow(0 0 20px gold);
    }
    100% {
        transform: translate(-50%, -50%) scale(0.3);
        opacity: 0;
        filter: brightness(2) drop-shadow(0 0 25px gold);
    }
}

/* 狼王嚎叫特效 */
@keyframes howlRipple {
    0% {
        transform: translate(-50%, -50%) scale(0.3);
        opacity: 1;
        border-width: 5px;
    }
    50% {
        transform: translate(-50%, -50%) scale(0.8);
        opacity: 0.7;
        border-width: 3px;
    }
    100% {
        transform: translate(-50%, -50%) scale(1.5);
        opacity: 0;
        border-width: 1px;
    }
}

/* 猛虎强击特效 */
@keyframes tigerStrike {
    0% {
        transform: translate(-50%, -50%) scale(0.5) rotate(0deg);
        opacity: 1;
    }
    30% {
        transform: translate(-50%, -50%) scale(1.2) rotate(90deg);
        opacity: 0.9;
    }
    100% {
        transform: translate(-50%, -50%) scale(2) rotate(180deg);
        opacity: 0;
    }
}

@keyframes clawSlash {
    0% {
        transform: scaleY(0) rotate(var(--rotation));
        opacity: 1;
    }
    50% {
        transform: scaleY(1) rotate(var(--rotation));
        opacity: 0.8;
    }
    100% {
        transform: scaleY(0.8) rotate(var(--rotation));
        opacity: 0;
    }
}

/* 模态框样式 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    max-width: 400px;
    width: 90%;
}

.modal-content h2 {
    margin-bottom: 20px;
    color: #2c5530;
    font-size: 2rem;
}

.modal-content p {
    margin-bottom: 30px;
    color: #666;
    font-size: 1.1rem;
}

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

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 120px;
}

.btn-primary {
    background: #28a745;
    color: white;
    box-shadow: 0 4px 15px rgba(40, 167, 69, 0.3);
}

.btn-primary:hover {
    background: #218838;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(40, 167, 69, 0.4);
}

.btn-secondary {
    background: #6c757d;
    color: white;
    box-shadow: 0 4px 15px rgba(108, 117, 125, 0.3);
}

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(108, 117, 125, 0.4);
}

/* 响应式设计 */
@media (max-width: 1400px) {
    .game-grid {
        grid-template-columns: repeat(12, 60px);
        grid-template-rows: repeat(6, 60px);
        gap: 3px;
    }
    
    .game-main {
        width: 98%;
    }
    
    .house-area {
        min-width: 100px;
    }
    
    .house-roof {
        font-size: 2.5rem;
    }
}

@media (max-width: 1024px) {
    .game-main {
        flex-direction: column;
        gap: 15px;
        margin: 10px;
        padding: 15px;
    }
    
    .house-area {
        min-width: auto;
        width: 100%;
        flex-direction: row;
        justify-content: center;
        padding: 15px;
    }
    
    .house {
        margin-right: 15px;
        margin-bottom: 0;
    }
    
    .game-grid {
        grid-template-columns: repeat(10, 55px); /* 减少到10列适应平板 */
        grid-template-rows: repeat(6, 55px);
        gap: 3px;
    }
    
    .animal-selector {
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .animal-card {
        min-width: 100px;
        padding: 10px;
    }
    
    .animal-icon {
        font-size: 2.5rem;
    }
}

@media (max-width: 768px) {
    .game-header {
        flex-direction: column;
        gap: 15px;
        padding: 15px;
    }
    
    .game-header h1 {
        font-size: 1.8rem;
    }
    
    .game-info {
        gap: 15px;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .house-area {
        padding: 10px;
    }
    
    .house-roof {
        font-size: 2rem;
    }
    
    .house-body {
        font-size: 1.2rem;
    }
    
    .house-text {
        font-size: 0.8rem;
    }
    
    .game-grid {
        grid-template-columns: repeat(8, 45px); /* 手机端8列 */
        grid-template-rows: repeat(6, 45px);
        gap: 2px;
        padding: 10px;
    }
    
    .animal, .zombie {
        font-size: 1.8rem;
    }
    
    .game-main {
        margin: 5px;
        padding: 10px;
    }
    
    .animal-selector {
        margin: 5px;
        padding: 15px;
    }
}

@media (max-width: 480px) {
    .game-grid {
        grid-template-columns: repeat(6, 40px); /* 小屏手机6列 */
        grid-template-rows: repeat(6, 40px);
        gap: 2px;
        padding: 8px;
    }
    
    .animal, .zombie {
        font-size: 1.5rem;
    }
    
    .resource-drop {
        font-size: 1.8rem;
    }
    
    .animal-selector {
        gap: 8px;
        padding: 10px;
    }
    
    .animal-card {
        min-width: 80px;
        padding: 8px;
    }
    
    .animal-icon {
        font-size: 2rem;
    }
}

/* 特效和动画增强 */
.sparkle {
    position: absolute;
    width: 8px;
    height: 8px;
    background: gold;
    border-radius: 50%;
    animation: sparkle 1s ease-out forwards;
}

@keyframes sparkle {
    0% {
        transform: scale(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: scale(1) rotate(360deg);
        opacity: 0;
    }
}

.explosion {
    position: absolute;
    width: 60px;
    height: 60px;
    background: radial-gradient(circle, #ff6b35 0%, #ff0000 50%, transparent 70%);
    border-radius: 50%;
    animation: explode 0.6s ease-out forwards;
}

@keyframes explode {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 0;
    }
}