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

:root {
    --primary-color: #4CAF50;
    --secondary-color: #2196F3;
    --warning-color: #ff9800;
    --danger-color: #f44336;
    --text-color: #2c3e50;
    --border-radius: 12px;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
}

body {
    font-family: 'Segoe UI', Arial, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #e4e8eb 100%);
    padding: 20px;
    min-height: 100vh;
}

.container {
    display: flex;
    gap: 24px;
    max-width: 1400px;
    margin: 0 auto;
    height: calc(100vh - 40px);
}

.simulation-area {
    flex: 1;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    position: relative;
}

#worldCanvas {
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom right, #e8f4f8 0%, #d4e9f7 100%);
}

.control-panel {
    width: 320px;
    background: white;
    padding: 24px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 20px;
    height: 100%;
    overflow-y: auto;
}

.control-panel h2 {
    color: var(--text-color);
    font-size: 24px;
    margin-bottom: 16px;
    text-align: center;
    font-weight: 600;
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.control-group {
    background: #f8f9fa;
    padding: 16px;
    border-radius: var(--border-radius);
    border: 1px solid #eee;
}

button {
    padding: 12px 20px;
    border: none;
    border-radius: var(--border-radius);
    background: var(--primary-color);
    color: white;
    cursor: pointer;
    transition: var(--transition);
    font-size: 16px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

button:active {
    transform: translateY(0);
}

#startBtn {
    background: var(--primary-color);
}

#pauseBtn {
    background: var(--warning-color);
}

#resetBtn {
    background: var(--danger-color);
}

#addFoodBtn {
    background: var(--secondary-color);
}

.environment-controls {
    padding: 20px 0;
    border-top: 2px solid #eee;
    border-bottom: 2px solid #eee;
}

.environment-controls h3, .stats h3 {
    color: var(--text-color);
    font-size: 18px;
    margin-bottom: 16px;
    font-weight: 600;
}

select {
    width: 100%;
    padding: 12px;
    margin-bottom: 16px;
    border: 2px solid #eee;
    border-radius: var(--border-radius);
    background: white;
    color: var(--text-color);
    font-size: 16px;
    cursor: pointer;
    transition: var(--transition);
}

select:hover {
    border-color: var(--primary-color);
}

select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.2);
}

.stats {
    padding-top: 20px;
}

.stats p {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 12px 0;
    padding: 12px;
    background: #f8f9fa;
    border-radius: var(--border-radius);
    color: var(--text-color);
    font-size: 16px;
}

.stats span {
    font-weight: 600;
    color: var(--primary-color);
}

/* 添加图标 */
#startBtn::before {
    content: "▶";
}

#pauseBtn::before {
    content: "⏸";
}

#resetBtn::before {
    content: "⟳";
}

#addFoodBtn::before {
    content: "🍎";
}

/* 响应式设计 */
@media (max-width: 1024px) {
    .container {
        flex-direction: column;
        height: auto;
    }

    .control-panel {
        width: 100%;
    }

    .simulation-area {
        height: 60vh;
    }
}

/* 添加动画效果 */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.stats span {
    animation: pulse 2s infinite;
    display: inline-block;
}

/* 按钮激活状态 */
button.active {
    background: var(--text-color);
    transform: scale(0.98);
}

/* 按钮点击动画 */
.pulse {
    animation: button-pulse 0.2s ease-in-out;
}

@keyframes button-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(0.95); }
    100% { transform: scale(1); }
}

/* 涟漪效果 */
.ripple {
    position: fixed;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    transform: scale(0);
    animation: ripple 1s ease-out;
    pointer-events: none;
    width: 100px;
    height: 100px;
    margin-left: -50px;
    margin-top: -50px;
}

@keyframes ripple {
    0% {
        transform: scale(0);
        opacity: 0.5;
    }
    100% {
        transform: scale(4);
        opacity: 0;
    }
}

/* 统计数值变化动画 */
.stats span {
    transition: color 0.3s ease;
}

.stats span[data-increased="true"] {
    color: var(--primary-color);
    animation: value-increase 0.5s ease-out;
}

.stats span[data-decreased="true"] {
    color: var(--danger-color);
    animation: value-decrease 0.5s ease-out;
}

@keyframes value-increase {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); color: var(--primary-color); }
    100% { transform: scale(1); }
}

@keyframes value-decrease {
    0% { transform: scale(1); }
    50% { transform: scale(0.8); color: var(--danger-color); }
    100% { transform: scale(1); }
}

/* 环境切换过渡效果 */
#worldCanvas {
    transition: background 0.5s ease;
}

/* 控制面板组件悬停效果 */
.control-group {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.control-group:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
}

/* 状态指示器 */
#systemStatus {
    position: relative;
    padding-left: 20px;
}

#systemStatus::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--warning-color);
    animation: status-pulse 2s infinite;
}

#systemStatus[data-status="running"]::before {
    background: var(--primary-color);
}

#systemStatus[data-status="paused"]::before {
    background: var(--warning-color);
}

@keyframes status-pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* 食物数量警告 */
#foodCount[data-warning="true"] {
    color: var(--warning-color);
    animation: warning-pulse 1s infinite;
}

@keyframes warning-pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* 种群数量变化指示器 */
.population-stats p {
    position: relative;
    overflow: hidden;
}

.population-stats p::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
}

.population-stats p[data-changed="true"]::after {
    transform: translateX(100%);
}

/* 工具提示 */
[data-tooltip] {
    position: relative;
}

[data-tooltip]:hover::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 5px 10px;
    background: var(--text-color);
    color: white;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 1000;
    opacity: 0;
    animation: tooltip-fade-in 0.2s ease forwards;
}

@keyframes tooltip-fade-in {
    from { opacity: 0; transform: translate(-50%, 10px); }
    to { opacity: 1; transform: translate(-50%, -5px); }
}

.creature-info {
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: 8px;
    padding: 15px;
    margin-top: 20px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.creature-info h3 {
    color: #2c3e50;
    margin: 0 0 15px 0;
    font-size: 1.2em;
    border-bottom: 2px solid #3498db;
    padding-bottom: 5px;
}

.creature-info h4 {
    color: #34495e;
    margin: 15px 0 8px 0;
    font-size: 1em;
}

.creature-info > div {
    margin-bottom: 15px;
    padding: 10px;
    background-color: rgba(236, 240, 241, 0.5);
    border-radius: 5px;
}

.creature-info p {
    margin: 5px 0;
    font-size: 0.9em;
    color: #444;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.creature-info span {
    font-weight: bold;
    color: #2980b9;
}

.population-stats span {
    color: #e74c3c;  /* 捕食者 */
}

.population-stats p:nth-child(2) span {
    color: #3498db;  /* 防御者 */
}

.population-stats p:nth-child(3) span {
    color: #27ae60;  /* 采集者 */
}

.gender-stats span {
    color: #8e44ad;
}

.gender-stats p:last-child span {
    color: #e84393;  /* 怀孕数量 */
}

.age-stats span {
    color: #f39c12;
}

.detailed-stats span {
    font-family: monospace;
    background-color: rgba(52, 152, 219, 0.1);
    padding: 2px 5px;
    border-radius: 3px;
    min-width: 40px;
    display: inline-block;
    text-align: right;
}

/* 环境信息面板样式 */
.environment-info {
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: 8px;
    padding: 15px;
    margin-top: 20px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.environment-info h3 {
    color: #2c3e50;
    margin: 0 0 15px 0;
    font-size: 1.2em;
    border-bottom: 2px solid #3498db;
    padding-bottom: 5px;
}

.environment-info h4 {
    color: #34495e;
    margin: 15px 0 8px 0;
    font-size: 1em;
}

.season-info {
    background-color: rgba(236, 240, 241, 0.5);
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 10px;
}

.season-info p {
    margin: 5px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.season-info span {
    font-weight: bold;
    color: #2980b9;
}

.disaster-info {
    background-color: rgba(241, 196, 15, 0.1);
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 10px;
}

.disaster-info p {
    margin: 5px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.disaster-info span {
    font-weight: bold;
    color: #c0392b;
}

.environment-effects {
    background-color: rgba(46, 204, 113, 0.1);
    padding: 10px;
    border-radius: 5px;
}

.environment-effects p {
    margin: 5px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.environment-effects span {
    font-weight: bold;
    color: #27ae60;
}

/* 季节特效 */
.season-spring #worldCanvas {
    background: linear-gradient(to bottom right, #e8f4f8 0%, #d4e9f7 100%);
}

.season-summer #worldCanvas {
    background: linear-gradient(to bottom right, #f8e8d4 0%, #f7d4b3 100%);
}

.season-autumn #worldCanvas {
    background: linear-gradient(to bottom right, #f8e3d4 0%, #f7c4b3 100%);
}

.season-winter #worldCanvas {
    background: linear-gradient(to bottom right, #f0f4f8 0%, #e4e9f7 100%);
}

/* 灾害效果动画 */
@keyframes disaster-warning {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

.disaster-active {
    animation: disaster-warning 2s infinite;
    color: #e74c3c !important;
}

/* 环境效果指示器 */
.effect-positive {
    color: #27ae60 !important;
}

.effect-negative {
    color: #c0392b !important;
}

.effect-neutral {
    color: #7f8c8d !important;
}

/* 生物详细信息弹窗 */
.creature-details-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    max-width: 400px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.creature-details-modal h2 {
    color: #2c3e50;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #3498db;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.creature-details-modal .close-btn {
    background: none;
    border: none;
    color: #7f8c8d;
    cursor: pointer;
    padding: 5px;
    font-size: 20px;
    width: auto;
}

.creature-details-modal .close-btn:hover {
    color: #e74c3c;
    transform: scale(1.1);
}

.creature-details-section {
    margin: 15px 0;
    padding: 10px;
    background: rgba(236, 240, 241, 0.5);
    border-radius: 8px;
}

.creature-details-section h3 {
    color: #34495e;
    margin-bottom: 10px;
    font-size: 1.1em;
}

.creature-details-section p {
    margin: 8px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #2c3e50;
}

.creature-details-section span {
    font-weight: bold;
    padding: 2px 8px;
    border-radius: 4px;
    background: rgba(52, 152, 219, 0.1);
}

.creature-details-section.genes span {
    font-family: monospace;
}

.creature-details-section.status span.high {
    color: #27ae60;
}

.creature-details-section.status span.medium {
    color: #f39c12;
}

.creature-details-section.status span.low {
    color: #e74c3c;
}

.creature-details-section.family-tree {
    max-height: 200px;
    overflow-y: auto;
}

.creature-details-modal .type-icon {
    font-size: 1.5em;
    margin-right: 10px;
}

.creature-details-modal .gender-icon {
    color: #3498db;
    margin-left: 10px;
}

.creature-details-modal .gender-icon.female {
    color: #e84393;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

/* 移动端响应式设计 */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .container {
        flex-direction: column;
        height: auto;
        gap: 12px;
    }

    .simulation-area {
        height: 60vh;
        min-height: 300px;
    }

    .control-panel {
        width: 100%;
        padding: 15px;
        max-height: none;
        gap: 12px;
    }

    .control-panel button {
        padding: 10px;
        font-size: 14px;
    }

    .stats p {
        padding: 8px;
        font-size: 14px;
    }

    .creature-info > div {
        padding: 8px;
    }

    .creature-info h3 {
        font-size: 1.1em;
    }

    .creature-info h4 {
        font-size: 0.9em;
    }

    .creature-info p {
        font-size: 0.85em;
    }

    /* 移动端弹窗样式优化 */
    .creature-details-modal {
        width: 95%;
        max-height: 90vh;
        padding: 15px;
        font-size: 14px;
    }

    .creature-details-modal h2 {
        font-size: 1.2em;
        margin-bottom: 10px;
    }

    .creature-details-section {
        margin: 10px 0;
        padding: 8px;
    }

    .creature-details-section h3 {
        font-size: 1em;
    }

    .creature-details-section p {
        font-size: 0.9em;
    }

    /* 移动端环境信息面板优化 */
    .environment-info {
        margin-top: 12px;
        padding: 12px;
    }

    .environment-info h3 {
        font-size: 1.1em;
    }

    .environment-info h4 {
        font-size: 0.9em;
    }

    .season-info,
    .disaster-info,
    .environment-effects {
        padding: 8px;
        margin-bottom: 8px;
    }

    .environment-info p {
        font-size: 0.85em;
    }

    /* 移动端统计面板布局优化 */
    .population-stats,
    .detailed-stats,
    .gender-stats,
    .age-stats {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    /* 移动端按钮组优化 */
    .controls {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    /* 移动端触摸优化 */
    button,
    select,
    .close-btn {
        min-height: 44px; /* 确保触摸目标足够大 */
    }

    /* 移动端滚动优化 */
    .control-panel {
        -webkit-overflow-scrolling: touch;
        overflow-y: auto;
    }

    /* 移动端文字大小调整 */
    .detailed-stats span {
        font-size: 0.9em;
        min-width: 35px;
    }

    /* 移动端间距优化 */
    .creature-info > div + div {
        margin-top: 10px;
    }

    /* 移动端动画优化 */
    @media (prefers-reduced-motion: reduce) {
        * {
            animation-duration: 0.01ms !important;
            animation-iteration-count: 1 !important;
            transition-duration: 0.01ms !important;
            scroll-behavior: auto !important;
        }
    }
}

/* 针对超小屏幕的优化 */
@media (max-width: 360px) {
    .population-stats,
    .detailed-stats,
    .gender-stats,
    .age-stats {
        grid-template-columns: 1fr;
    }

    .controls {
        grid-template-columns: 1fr;
    }

    .creature-details-modal {
        padding: 10px;
    }

    .stats p {
        font-size: 12px;
    }
}

/* 针对横屏模式的优化 */
@media (max-height: 500px) and (orientation: landscape) {
    .container {
        flex-direction: row;
        height: auto;
        min-height: calc(100vh - 20px);
    }

    .simulation-area {
        height: calc(100vh - 20px);
        flex: 2;
    }

    .control-panel {
        flex: 1;
        max-height: calc(100vh - 20px);
    }

    .creature-details-modal {
        width: 80%;
        height: 90vh;
    }
}

/* 针对高DPI屏幕的优化 */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .creature-details-modal,
    .control-panel,
    .simulation-area {
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    }
}

/* 游戏介绍弹窗样式 */
.intro-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    animation: fadeIn 0.3s ease-out forwards;
}

.intro-content {
    background: white;
    padding: 30px;
    border-radius: 15px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.2);
    transform: translateY(-20px);
    animation: slideIn 0.3s ease-out forwards;
}

.intro-content h2 {
    color: #2c3e50;
    text-align: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid #3498db;
    font-size: 1.8em;
}

.intro-section {
    margin: 20px 0;
    padding: 15px;
    background: rgba(236, 240, 241, 0.5);
    border-radius: 10px;
    transition: transform 0.2s;
}

.intro-section:hover {
    transform: translateX(5px);
}

.intro-section h3 {
    color: #2980b9;
    margin-bottom: 10px;
    font-size: 1.3em;
    display: flex;
    align-items: center;
    gap: 10px;
}

.intro-section p {
    color: #34495e;
    line-height: 1.6;
    margin: 10px 0;
}

.intro-section ul {
    list-style: none;
    padding: 0;
}

.intro-section li {
    margin: 10px 0;
    padding-left: 25px;
    position: relative;
    color: #34495e;
    line-height: 1.5;
}

.intro-section li::before {
    content: "•";
    color: #3498db;
    position: absolute;
    left: 10px;
    font-weight: bold;
}

.intro-buttons {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.dont-show-again {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #7f8c8d;
    font-size: 0.9em;
    cursor: pointer;
}

.dont-show-again input {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.start-button {
    padding: 12px 30px;
    background: #2ecc71;
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 1.1em;
    cursor: pointer;
    transition: all 0.3s;
}

.start-button:hover {
    background: #27ae60;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(46, 204, 113, 0.3);
}

.start-button:active {
    transform: translateY(0);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from { 
        opacity: 0;
        transform: translateY(-20px);
    }
    to { 
        opacity: 1;
        transform: translateY(0);
    }
}

/* 移动端适配 */
@media (max-width: 768px) {
    .intro-content {
        padding: 20px;
        width: 95%;
    }

    .intro-content h2 {
        font-size: 1.5em;
    }

    .intro-section h3 {
        font-size: 1.2em;
    }

    .intro-buttons {
        flex-direction: column;
        gap: 15px;
    }

    .dont-show-again {
        order: 2;
    }

    .start-button {
        width: 100%;
        order: 1;
    }
} 