:root {
    --primary-color: #FFB6C1;
    --secondary-color: #98D8C8;
    --accent-color: #F7DC6F;
    --background-color: #FFF5F5;
    --card-bg: #FFFFFF;
    --text-color: #5D4E60;
    --text-light: #8E7B8E;
    --border-color: #E8D5E8;
    --shadow-color: rgba(147, 112, 219, 0.15);
    --success-color: #7DCEA0;
    --danger-color: #F1948A;
    
    --animal-bear: #D4A574;
    --animal-fox: #E67E22;
    --animal-frog: #58D68D;
    --animal-bunny: #F5B7B1;
    --animal-cat: #BB8FCE;
    --animal-owl: #85C1E9;
    --animal-penguin: #5DADE2;
    --animal-lion: #F4D03F;
    --animal-turtle: #45B39D;
    --animal-monkey: #BA9A6D;
    --animal-elephant: #AEB6BF;
    --animal-dragon: #E74C3C;
    
    --cell-size: 40px;
    --grid-gap: 2px;
    --border-radius: 12px;
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
}

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

body {
    font-family: 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: linear-gradient(135deg, var(--background-color) 0%, #FFF0F5 50%, #F0FFF0 100%);
    color: var(--text-color);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
}

#app {
    max-width: 480px;
    margin: 0 auto;
    padding: 10px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: 0 4px 15px var(--shadow-color);
    margin-bottom: 10px;
}

.stat-box {
    display: flex;
    align-items: center;
    gap: 6px;
}

.stat-icon {
    font-size: 1.2em;
}

.stat-value {
    font-weight: 600;
    font-size: 1.1em;
    color: var(--text-color);
}

.btn-next {
    background: linear-gradient(135deg, var(--primary-color), #FF9AA2);
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 20px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
    box-shadow: 0 2px 8px rgba(255, 182, 193, 0.4);
}

.btn-next:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 182, 193, 0.6);
}

.btn-next:active {
    transform: translateY(0);
}

#tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.tab {
    flex: 1;
    padding: 12px;
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
    color: var(--text-light);
}

.tab.active {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-color: transparent;
    color: white;
}

.tab:hover:not(.active) {
    border-color: var(--primary-color);
    color: var(--text-color);
}

#game-container {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.panel {
    display: none;
    flex-direction: column;
    flex: 1;
}

.panel.active {
    display: flex;
}

#level-info {
    text-align: center;
    padding: 8px;
    background: var(--card-bg);
    border-radius: var(--border-radius);
    margin-bottom: 10px;
    font-weight: 500;
}

#game-canvas {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: 0 4px 20px var(--shadow-color);
    touch-action: none;
    margin: 0 auto;
}

#block-tray {
    display: flex;
    justify-content: center;
    gap: 12px;
    padding: 16px;
    background: var(--card-bg);
    border-radius: var(--border-radius);
    margin-top: 10px;
    box-shadow: 0 -4px 20px var(--shadow-color);
}

.tray-slot {
    width: 100px;
    height: 100px;
    background: linear-gradient(135deg, #F8F9FA, #F0F3F4);
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    transition: var(--transition-fast);
    border: 2px dashed var(--border-color);
}

.tray-slot:hover {
    border-color: var(--primary-color);
    background: linear-gradient(135deg, #FFF5F5, #FFF0F0);
}

.tray-slot.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.tray-slot.empty {
    background: transparent;
    border-style: dashed;
}

#zoo-header {
    display: flex;
    justify-content: space-around;
    padding: 16px;
    background: var(--card-bg);
    border-radius: var(--border-radius);
    margin-bottom: 10px;
    box-shadow: 0 4px 15px var(--shadow-color);
}

.zoo-stat {
    text-align: center;
}

.zoo-stat-label {
    display: block;
    font-size: 0.85em;
    color: var(--text-light);
    margin-bottom: 4px;
}

.zoo-stat-value {
    font-size: 1.4em;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-color), #F39C12);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#animal-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    overflow-y: auto;
    padding-bottom: 20px;
}

.animal-card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 16px;
    box-shadow: 0 4px 15px var(--shadow-color);
    transition: var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.animal-card.locked {
    opacity: 0.6;
    filter: grayscale(0.5);
}

.animal-card.unlocked {
    border: 2px solid var(--secondary-color);
}

.animal-icon {
    width: 60px;
    height: 60px;
    margin: 0 auto 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5em;
}

.animal-name {
    text-align: center;
    font-weight: 600;
    margin-bottom: 4px;
}

.animal-level {
    text-align: center;
    font-size: 0.85em;
    color: var(--text-light);
    margin-bottom: 8px;
}

.animal-dps {
    text-align: center;
    font-size: 0.9em;
    color: var(--accent-color);
    font-weight: 600;
    margin-bottom: 8px;
}

.animal-upgrade {
    width: 100%;
    padding: 10px;
    background: linear-gradient(135deg, var(--secondary-color), #7DCEA0);
    border: none;
    border-radius: 8px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
}

.animal-upgrade:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(125, 206, 160, 0.4);
}

.animal-upgrade:disabled {
    background: var(--border-color);
    cursor: not-allowed;
}

.upgrade-cost {
    font-size: 0.85em;
    display: block;
    margin-top: 4px;
}

.floating-diamond {
    position: absolute;
    font-size: 0.9em;
    color: var(--accent-color);
    font-weight: 700;
    pointer-events: none;
    animation: floatUp 1s ease-out forwards;
    z-index: 10;
}

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

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--card-bg);
    padding: 32px;
    border-radius: var(--border-radius);
    text-align: center;
    max-width: 320px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-content h2 {
    margin-bottom: 16px;
    color: var(--text-color);
}

.modal-content p {
    margin-bottom: 12px;
    color: var(--text-light);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), #FF9AA2);
    color: white;
    border: none;
    padding: 14px 32px;
    border-radius: 25px;
    font-weight: 600;
    font-size: 1.1em;
    cursor: pointer;
    transition: var(--transition-fast);
    margin-top: 16px;
    box-shadow: 0 4px 15px rgba(255, 182, 193, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 182, 193, 0.6);
}

.block-preview {
    display: grid;
    gap: 1px;
    background: var(--border-color);
    border-radius: 6px;
    padding: 2px;
}

.block-preview-cell {
    width: 20px;
    height: 20px;
    border-radius: 3px;
}

.block-preview-cell.filled {
    background: var(--primary-color);
}

.block-preview-cell.empty {
    background: transparent;
}

.clear-animation {
    animation: clearPulse 0.3s ease;
}

@keyframes clearPulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
    100% {
        transform: scale(0);
        opacity: 0;
    }
}

.drop-animation {
    animation: dropDown 0.3s ease;
}

@keyframes dropDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.place-animation {
    animation: placeBounce 0.2s ease;
}

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

.score-popup {
    position: absolute;
    font-weight: 700;
    font-size: 1.2em;
    color: var(--accent-color);
    pointer-events: none;
    animation: scoreFloat 1s ease-out forwards;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

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

.combo-text {
    position: absolute;
    font-weight: 800;
    font-size: 1.5em;
    color: var(--danger-color);
    pointer-events: none;
    animation: comboFlash 0.8s ease-out forwards;
    text-shadow: 0 2px 8px rgba(241, 148, 138, 0.5);
}

@keyframes comboFlash {
    0% {
        opacity: 1;
        transform: scale(0.5);
    }
    50% {
        opacity: 1;
        transform: scale(1.3);
    }
    100% {
        opacity: 0;
        transform: scale(1) translateY(-30px);
    }
}

@media (max-width: 400px) {
    :root {
        --cell-size: 35px;
    }
    
    #app {
        padding: 8px;
    }
    
    header {
        padding: 10px 12px;
    }
    
    .stat-value {
        font-size: 1em;
    }
    
    .tray-slot {
        width: 85px;
        height: 85px;
    }
    
    #animal-grid {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 768px) {
    :root {
        --cell-size: 45px;
    }
    
    #app {
        padding: 20px;
    }
    
    .tray-slot {
        width: 120px;
        height: 120px;
    }
}

.drag-ghost {
    position: fixed;
    pointer-events: none;
    z-index: 1000;
    opacity: 0.9;
    transform: translate(-50%, -50%);
}

.grid-highlight {
    position: absolute;
    background: rgba(255, 182, 193, 0.3);
    border-radius: 4px;
    pointer-events: none;
}

.grid-invalid {
    background: rgba(241, 148, 138, 0.3);
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 8px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--secondary-color), var(--primary-color));
    transition: width 0.3s ease;
}

.lock-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--border-radius);
}

.lock-icon {
    font-size: 2em;
}

.unlock-level {
    font-size: 0.85em;
    color: var(--text-light);
    margin-top: 4px;
}
