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

body {
    font-family: Arial, sans-serif;
    background-color: #f0f0f0;
    color: #333;
    line-height: 1.4;
    height: 100vh;
    overflow-x: auto;
    overflow-y: auto;
    margin: 0;
    padding: 0;
}

#game-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 5px;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    text-align: center;
    margin-bottom: 5px;
}

header h1 {
    font-size: 1.5em;
    margin: 3px 0;
}

#game-board {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    min-height: 0;
}

/* 中间区域样式 - 三列布局 */
#middle-section {
    display: flex;
    gap: 10px;
    height: 180px;
    flex-shrink: 0;
}

#log-container {
    flex: 1.8;
    background-color: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 8px;
    height: 100%;
    overflow-y: auto;
}

#log-container h3 {
    margin-bottom: 6px;
    font-size: 0.9em;
}

#control-section {
    flex: 1;
    background-color: #fff9e6;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 8px;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

#control-section h3 {
    margin-bottom: 6px;
    font-size: 0.9em;
    text-align: center;
}

#game-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
}

#game-info div {
    text-align: center;
    font-size: 0.85em;
    font-weight: bold;
    padding: 4px;
    background-color: #f5f5f5;
    border-radius: 4px;
    border: 1px solid #ddd;
}

#environment-section {
    flex: 1.8;
    background-color: #e6f7ff;
    padding: 8px;
    border-radius: 6px;
    height: 100%;
    display: flex;
    flex-direction: column;
}

#environment-section h3 {
    margin-bottom: 6px;
    font-size: 0.9em;
    text-align: center;
}

.player-section {
    padding: 8px;
    border-radius: 6px;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.player-section h2 {
    margin-bottom: 6px;
    font-size: 1em;
}

#player-section {
    background-color: #e6ffe6;
}

#ai-section {
    background-color: #ffe6e6;
    flex: 0 0 auto;
    height: 250px;
    min-height: 250px;
    max-height: 250px;
}

/* 玩家区域容器 */
#player-areas {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    min-height: 0;
}

#player-species-section {
    background-color: #e6ffe6;
    flex: 0 0 auto;
    height: 250px;
    min-height: 250px;
    max-height: 250px;
}

#player-hand-section {
    background-color: #f0f8ff;
    flex: 1;
    min-height: 100px;
    display: flex;
    flex-direction: column;
}

.hand-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.hand-header h2 {
    margin: 0;
}

.action-points-display {
    background-color: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.85em;
    font-weight: bold;
    color: #856404;
}

.species-container {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 8px;
    flex: 1;
    align-content: center;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    padding: 15px;
    min-height: 0;
    /* 当内容不足以填满容器时，确保垂直居中 */
    min-height: 100%;
}

.species-card {
    width: 140px;
    min-height: 160px;
    border: 2px solid #333;
    border-radius: 8px;
    padding: 8px;
    background-color: #fff;
    position: relative;
    font-size: 0.8em;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.species-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.species-card h4 {
    text-align: left;
    margin-bottom: 6px;
    padding-bottom: 2px;
    border-bottom: 1px solid #ccc;
    font-size: 0.9em;
}

.trait-slot {
    margin: 4px 0;
    padding: 4px;
    border: 1px dashed #999;
    border-radius: 4px;
    min-height: 22px;
    position: relative;
    font-size: 0.75em;
    background-color: #fafafa;
    transition: background-color 0.2s ease;
}

.trait-slot:hover {
    background-color: #f0f0f0;
}

.special-trait-slot {
    background-color: #fff9e6;
    border: 1px dashed #f39c12;
}

.special-trait-slot:hover {
    background-color: #fef5e7;
}

/* 特殊性状容器和圆圈样式 */
.special-traits-container {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 4px;
}

.special-trait-circle {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 1px dashed #999;
    position: relative;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.special-trait-circle.empty {
    background-color: transparent;
}

.special-trait-circle.filled {
    border-color: #222;
}

.special-trait-circle.selectable-slot {
    cursor: pointer;
    border-color: #007bff;
    border-width: 2px;
}

.special-trait-circle.selectable-slot:hover {
    transform: scale(1.1);
    box-shadow: 0 0 8px rgba(0, 123, 255, 0.5);
}

.special-trait-circle:hover {
    transform: scale(1.05);
}

.special-trait-circle.special-trait-blocked {
    cursor: not-allowed;
    position: relative;
}

.special-trait-circle.special-trait-blocked:hover {
    transform: scale(1.1);
    box-shadow: 0 0 8px rgba(255, 0, 0, 0.5);
}

.special-trait-circle.special-trait-blocked::after {
    content: '×';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-weight: bold;
    font-size: 10px;
    text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.8);
    pointer-events: none;
}

/* 适应性显示样式 */
.adaptability-display {
    margin-top: 6px;
    padding: 4px;
    background-color: #f8f9fa;
    border-radius: 4px;
    text-align: center;
    font-size: 0.75em;
    font-weight: bold;
    border: 1px solid #e9ecef;
}

.adaptability-hot {
    color: #dc3545;
    background-color: #fff5f5;
    padding: 2px 4px;
    border-radius: 3px;
    border: 1px solid #f5c6cb;
}

.adaptability-cold {
    color: #007bff;
    background-color: #f0f8ff;
    padding: 2px 4px;
    border-radius: 3px;
    border: 1px solid #b3d9ff;
}

.trait-card {
    width: 85px;
    min-height: 35px;
    border: 1px solid #333;
    border-radius: 4px;
    padding: 4px;
    margin: 2px;
    background-color: #fff;
    cursor: pointer;
    transition: transform 0.2s;
    position: relative;
    font-size: 0.75em;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.trait-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.trait-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    margin-top: 4px;
    flex: 1;
    align-content: flex-start;
    overflow-y: auto;
    padding: 5px;
    justify-content: center;
}

.card {
    background-color: white;
    border-radius: 4px;
    padding: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-bottom: 4px;
    font-size: 0.8em;
}

.hot {
    background-color: #ffcccc;
}

.cold {
    background-color: #ccf2ff;
}

/* 气候卡片样式 */
.climate-display {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 8px;
    flex: 1;
}

.climate-card {
    background-color: white;
    border-radius: 4px;
    padding: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid #ddd;
    text-align: center;
    min-height: 45px;
}

.climate-card .card-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 100%;
}

.climate-card .card-label {
    font-size: 0.65em;
    color: #666;
    margin: 0 0 2px 0;
    font-weight: bold;
}

.climate-card .card-value {
    font-size: 0.8em;
    font-weight: bold;
    margin: 0;
}

/* 气候状态卡片背景色 */
.climate-card.ice-age {
    background: linear-gradient(135deg, #e6f3ff, #b3d9ff);
    border-color: #4da6ff;
}

.climate-card.ice-house {
    background: linear-gradient(135deg, #f0f8ff, #cce7ff);
    border-color: #66b3ff;
}

.climate-card.moderate {
    background: linear-gradient(135deg, #f5f5f5, #e0e0e0);
    border-color: #999;
}

.climate-card.greenhouse {
    background: linear-gradient(135deg, #fff5e6, #ffcc99);
    border-color: #ff9933;
}

.climate-card.super-greenhouse {
    background: linear-gradient(135deg, #ffe6e6, #ffb3b3);
    border-color: #ff6666;
}

/* 温度变化卡片背景色 */
.climate-card.warming {
    background: linear-gradient(135deg, #fff0e6, #ffd9b3);
    border-color: #ff8c1a;
}

.climate-card.cooling {
    background: linear-gradient(135deg, #e6f7ff, #b3e6ff);
    border-color: #1a8cff;
}

.environment-display {
    flex: 1;
    display: flex;
    flex-direction: column;
}



#dice-result {
    font-size: 16px;
    font-weight: bold;
    margin: 3px 0;
}

.btn {
    background-color: #4CAF50;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.8em;
    margin: 1px;
}

.btn:hover {
    background-color: #45a049;
}

#control-panel {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 8px;
}

#control-panel .btn {
    width: 100%;
    padding: 6px 8px;
    font-size: 0.8em;
}

#game-log {
    font-family: monospace;
    font-size: 10px;
}

#game-log p {
    margin: 2px 0;
}

.hidden {
    display: none;
}

#species-action-panel,
#confirm-trait-panel,
#duplication-confirm-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #fff;
    padding: 20px;
    border: 2px solid #333;
    border-radius: 10px;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.3);
    z-index: 10;
    min-width: 300px;
    text-align: center;
}

#confirm-operation-text,
#duplication-confirm-text {
    margin-bottom: 15px;
    font-weight: bold;
}

.action-btn {
    display: block;
    width: 100%;
    margin: 5px 0;
    padding: 8px;
    border: none;
    border-radius: 5px;
    background-color: #4b6bfb;
    color: white;
    cursor: pointer;
}

.action-btn:hover {
    background-color: #3a59e0;
}

.confirm-btn {
    background-color: #e74c3c !important;
}

.confirm-btn:hover {
    background-color: #c0392b !important;
}

.cancel-btn {
    background-color: #27ae60 !important;
}

.cancel-btn:hover {
    background-color: #229954 !important;
}

/* 悬停提示样式 */
.trait-tooltip {
    position: fixed;
    background-color: #333;
    color: white;
    padding: 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: pre-line;
    z-index: 99999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    pointer-events: auto;
    min-width: 150px;
    max-width: 250px;
    text-align: left;
    line-height: 1.4;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border: 1px solid #555;
    --arrow-position: top;
}

/* 箭头样式 - 默认在上方（悬浮窗在下方） */
.trait-tooltip::before {
    content: '';
    position: absolute;
    border: 6px solid transparent;
}

/* 悬浮窗在下方时，箭头在上方 */
.trait-tooltip[style*="--arrow-position: top"]::before,
.trait-tooltip:not([style*="--arrow-position"])::before {
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    border-bottom-color: #333;
}

/* 悬浮窗在上方时，箭头在下方 */
.trait-tooltip[style*="--arrow-position: bottom"]::before {
    bottom: -12px;
    left: 50%;
    transform: translateX(-50%);
    border-top-color: #333;
}

/* 悬浮窗在右侧时，箭头在左侧 */
.trait-tooltip[style*="--arrow-position: left"]::before {
    left: -12px;
    top: 50%;
    transform: translateY(-50%);
    border-right-color: #333;
}

/* 悬浮窗在左侧时，箭头在右侧 */
.trait-tooltip[style*="--arrow-position: right"]::before {
    right: -12px;
    top: 50%;
    transform: translateY(-50%);
    border-left-color: #333;
}

.trait-name {
    font-weight: bold;
    text-align: center;
    font-size: 0.9em;
}

.extinct {
    opacity: 0.5;
    background-color: #888;
}

.selected {
    outline: 3px solid #ff9900;
    box-shadow: 0 0 15px rgba(255, 153, 0, 0.4);
    transform: scale(1.02);
}

.tooltip {
    position: relative;
    display: inline-block;
}

.tooltip .tooltiptext {
    visibility: hidden;
    width: 120px;
    background-color: black;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 5px;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    margin-left: -60px;
    opacity: 0;
    transition: opacity 0.3s;
}

.tooltip:hover .tooltiptext {
    visibility: visible;
    opacity: 1;
}

.modified {
    opacity: 0.7;
    background-color: #e0e0e0;
    position: relative;
}

.modified::after {
    content: "已修改";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-30deg);
    font-size: 24px;
    font-weight: bold;
    color: #ff0000;
    border: 2px solid #ff0000;
    padding: 5px 10px;
    border-radius: 5px;
    pointer-events: none;
}

.removable {
    cursor: pointer;
    transition: all 0.2s ease;
}

.selectable {
    cursor: pointer;
    transition: all 0.2s ease;
}

.selectable:hover {
    box-shadow: 0 0 10px rgba(75, 107, 251, 0.8);
    transform: scale(1.02);
}

.selectable-slot {
    cursor: pointer;
    transition: all 0.2s ease;
}

.selectable-slot:hover {
    background-color: #e6f7ff;
    border-color: #4b6bfb;
}

.selected-slot {
    border: 2px solid #4b6bfb;
    background-color: #e6f7ff;
}

.compatible {
    box-shadow: 0 0 8px rgba(76, 175, 80, 0.8);
}

.incompatible {
    opacity: 0.5;
}

.selected-for-discard {
    outline: 3px solid #ff5722;
    background-color: #fff0e6;
}

.removable:hover {
    background-color: #ffdddd;
    border-color: #ff0000;
}

.instruction-message {
    background-color: #4b6bfb;
    color: white;
    padding: 10px;
    margin: 10px 0;
    border-radius: 5px;
    text-align: center;
    font-weight: bold;
}

/* 游戏设置面板样式 */
#game-settings-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #fff;
    border-radius: 15px;
    padding: 40px;
    max-width: 450px;
    width: 90%;
    text-align: center;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    z-index: 1000;
}

#game-settings-panel h1 {
    margin-bottom: 10px;
    color: #2c3e50;
    font-size: 2em;
    font-weight: bold;
}

#game-settings-panel h2 {
    margin-bottom: 30px;
    color: #7f8c8d;
    font-size: 1.2em;
    font-style: italic;
    font-weight: normal;
}

.setting-group {
    margin-bottom: 25px;
    text-align: left;
}

.setting-group label {
    display: block;
    margin-bottom: 10px;
    font-weight: bold;
    color: #34495e;
    font-size: 1.1em;
}

.setting-group select {
    width: 100%;
    padding: 12px;
    border: 2px solid #bdc3c7;
    border-radius: 8px;
    font-size: 1em;
    background-color: #fff;
    transition: border-color 0.3s;
}

.setting-group select:focus {
    outline: none;
    border-color: #3498db;
}

#start-game {
    margin-top: 20px;
    padding: 15px 40px;
    font-size: 1.2em;
    background-color: #27ae60;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.2s;
    font-weight: bold;
}

#start-game:hover {
    background-color: #229954;
    transform: translateY(-2px);
}

/* 响应式设计 */
@media (max-height: 800px) {
    #middle-section {
        height: 160px;
    }
    
    .species-card {
        width: 130px;
        min-height: 140px;
        font-size: 0.75em;
    }
    
    .trait-card {
        width: 75px;
        min-height: 30px;
    }
    
    #ai-section,
    #player-species-section {
        height: 220px;
        min-height: 220px;
        max-height: 220px;
    }
}

@media (max-height: 700px) {
    #middle-section {
        height: 140px;
    }
    
    .species-card {
        width: 120px;
        min-height: 120px;
        font-size: 0.7em;
    }
    
    .trait-card {
        width: 70px;
        min-height: 28px;
    }
    
    .player-section {
        padding: 6px;
    }
    
    /* 在低高度屏幕上减少物种区域高度 */
    #ai-section,
    #player-species-section {
        height: 180px;
        min-height: 180px;
        max-height: 180px;
    }
}

@media (max-width: 1200px) {
    #game-container {
        max-width: 100%;
        padding: 3px;
    }
    
    .species-card {
        width: 130px;
    }
}

@media (max-width: 900px) {
    .species-card {
        width: 120px;
        min-height: 140px;
    }
    
    .trait-card {
        width: 75px;
        min-height: 30px;
    }
    
    /* 在小屏幕上进一步减少高度 */
    #ai-section,
    #player-species-section {
        height: 200px;
        min-height: 200px;
        max-height: 200px;
    }
    
    /* 小屏幕上调整中间区域布局 */
    #middle-section {
        height: 160px;
    }
    
    #control-section h3,
    #environment-section h3,
    #log-container h3 {
        font-size: 0.8em;
        margin-bottom: 4px;
    }
    
    #game-info div {
        font-size: 0.75em;
        padding: 3px;
    }
    
    #control-panel .btn {
        padding: 4px 6px;
        font-size: 0.75em;
    }
    
    .action-points-display {
        font-size: 0.75em;
        padding: 3px 6px;
    }
}

/* 灭绝物种样式 */
.extinct-species {
    opacity: 0.6;
    background-color: #888 !important;
    position: relative;
}

.extinct-species::after {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-15deg);
    font-size: 18px;
    font-weight: bold;
    color: #ff0000;
    background-color: rgba(255, 255, 255, 0.9);
    border: 2px solid #ff0000;
    padding: 4px 8px;
    border-radius: 4px;
    pointer-events: none;
    z-index: 10;
}
