body {
    font-family: sans-serif;
    display: flex;
    flex-direction: column; /* 让标题在游戏容器上方 */
    align-items: center;
    justify-content: center; /* 垂直居中 */
    min-height: 100vh; /* 确保body至少占满屏幕高度 */
    background-color: #000;
    color: #fff;
    margin: 0;
    overflow: hidden; /* 防止游戏元素溢出 */
}

h1 {
    color: #eee;
    margin-bottom: 10px;
}

#game-container {
    width: 800px; /* 游戏区域宽度 */
    height: 600px; /* 游戏区域高度 */
    border: 2px solid #555;
    position: relative; /* 重要：内部绝对定位的基准 */
    background-color: #0a0a1a; /* 深空背景色 */
    overflow: hidden; /* 隐藏超出边界的威胁 */
    box-shadow: 0 0 20px rgba(0, 150, 255, 0.5);
}

#solar-system-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center, #1a1a3a 0%, #000010 70%, #000 100%);
    /* 可以添加星星等效果 */
    z-index: 0;
}

#earth {
    width: 100px;
    height: 100px;
    background-color: #3498db; /* 简化地球颜色 */
    background-image: url('earth.png'); /* 可选：使用地球图片 */
    background-size: cover;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%); /* 精确居中 */
    z-index: 10;
    box-shadow: 0 0 15px rgba(52, 152, 219, 0.8);
    transition: box-shadow 0.3s ease; /* 受损效果 */
}

#earth.damaged {
    box-shadow: 0 0 25px rgba(255, 0, 0, 1); /* 受损时的红色辉光 */
}


#threat-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 20; /* 在地球之上 */
}

.threat {
    position: absolute;
    border-radius: 50%;
    /* 动画由JS控制或添加CSS动画类 */
    transition: transform 5s linear; /* 移动动画，时间根据需要调整 */
    z-index: 25;
}

.asteroid {
    width: 20px;
    height: 20px;
    background-color: #a0522d; /* 棕色 */
    background-image: radial-gradient(circle, #d2b48c 20%, #8b4513 80%);
    box-shadow: 0 0 5px #555;
}

.cosmic-ray {
    width: 30px; /* 射线宽度 */
    height: 5px;  /* 射线高度 */
    background: linear-gradient(90deg, rgba(255,255,0,0) 0%, rgba(255,255,0,1) 50%, rgba(255,255,0,0) 100%); /* 黄色渐变 */
    border-radius: 2px;
    opacity: 0.8;
    box-shadow: 0 0 8px yellow;
}


/* 保护罩效果 */
#shield-effect-layer {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 150px; /* 比地球稍大 */
    height: 150px;
    z-index: 15; /* 在地球之上，威胁之下 */
    pointer-events: none; /* 不阻挡点击 */
}

.shield-effect {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    opacity: 0; /* 默认隐藏 */
    transition: opacity 0.2s ease-out;
}

#magnetic-field-effect.active {
    border: 3px dashed rgba(0, 255, 255, 0.7); /* 青色虚线 */
    opacity: 1;
    animation: pulse 1s infinite ease-in-out;
}

#atmosphere-effect.active {
    border: 4px solid rgba(135, 206, 250, 0.6); /* 天蓝色实线 */
    background-color: rgba(135, 206, 250, 0.1);
    opacity: 1;
}

@keyframes pulse {
    0% { transform: scale(1); box-shadow: 0 0 5px rgba(0, 255, 255, 0.5); }
    50% { transform: scale(1.05); box-shadow: 0 0 15px rgba(0, 255, 255, 0.8); }
    100% { transform: scale(1); box-shadow: 0 0 5px rgba(0, 255, 255, 0.5); }
}


#info-panel {
    position: absolute;
    top: 10px;
    left: 10px;
    background-color: rgba(0, 0, 0, 0.5);
    padding: 10px;
    border-radius: 5px;
    z-index: 50;
    color: #fff;
}
#info-panel div {
    margin-bottom: 5px;
}


#shield-controls {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.6);
    padding: 10px;
    border-radius: 8px;
    display: flex;
    gap: 10px; /* 按钮间距 */
    z-index: 50;
}

#shield-controls button {
    padding: 8px 12px;
    font-size: 14px;
    cursor: pointer;
    border: 1px solid #ccc;
    border-radius: 5px;
    background-color: #444;
    color: #fff;
    transition: background-color 0.2s, border-color 0.2s;
    display: flex; /* 让图标和文字对齐 */
    align-items: center;
    gap: 5px; /* 图标和文字间距 */
}

#shield-controls button:hover {
    background-color: #666;
    border-color: #fff;
}

#shield-controls button:disabled {
    background-color: #333;
    color: #888;
    cursor: not-allowed;
    border-color: #555;
}

.icon {
    font-size: 1.2em; /* 图标稍大 */
}
.cost {
    font-size: 0.8em;
    opacity: 0.8;
}


#message-box {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.8);
    border: 1px solid #ddd;
    padding: 15px 25px;
    border-radius: 8px;
    text-align: center;
    z-index: 100;
    min-width: 300px; /* 最小宽度 */
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
    transition: opacity 0.3s ease, visibility 0.3s ease;
}
#message-box.hidden {
    opacity: 0;
    visibility: hidden;
}
#message-box.success {
    border-color: #2ecc71; /* 绿色 */
    color: #2ecc71;
}
#message-box.fail {
    border-color: #e74c3c; /* 红色 */
    color: #e74c3c;
}
#message-box.info {
    border-color: #3498db; /* 蓝色 */
    color: #3498db;
}

/* 游戏结束画面 */
#game-over-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    z-index: 150;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #fff;
}
#game-over-screen.hidden {
    display: none;
}
#game-over-screen h2 {
    color: #e74c3c;
    margin-bottom: 20px;
}
#game-over-screen p {
    margin: 10px 0;
    font-size: 1.2em;
}
#restart-button {
    margin-top: 20px;
    padding: 10px 20px;
    font-size: 1.1em;
    cursor: pointer;
    background-color: #3498db;
    border: none;
    color: white;
    border-radius: 5px;
    transition: background-color 0.2s;
}
#restart-button:hover {
    background-color: #2980b9;
}
