/* 全局样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "Microsoft Yahei", Arial, sans-serif;
}

body {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    background: linear-gradient(135deg, #1a2a6c, #b21f1f, #1a2a6c);
    padding: 20px 0;
}

/* 游戏包装器 - 核心居中逻辑 */
.game-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    /* 响应式最大宽度，防止大屏拉伸 */
    max-width: 480px;
    margin: 0 auto;
}

/* 游戏开始界面 */
#game-start {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 720px;
    background: rgba(0, 0, 0, 0.9);
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
    border-radius: 8px;
}

#game-start h1 {
    font-size: 48px;
    margin-bottom: 30px;
    color: #00ff9d;
    text-shadow: 0 0 10px #00ff9d;
}

#game-start p {
    font-size: 16px;
    margin-bottom: 40px;
    color: #ccc;
    text-align: center;
    line-height: 1.5;
}

#start-btn, #restart-btn {
    padding: 15px 40px;
    font-size: 20px;
    background: linear-gradient(to right, #00ff9d, #00cc88);
    border: none;
    border-radius: 50px;
    color: #000;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 255, 157, 0.4);
}

#start-btn:hover, #restart-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 255, 157, 0.6);
}

/* 游戏容器 - 固定比例 + 溢出隐藏 */
#game-container {
    position: relative;
    width: 100%;
    /* 核心：保持 4:6 的宽高比 */
    aspect-ratio: 4 / 6;
    max-height: 720px;
    background: #000 url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M11 18c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm48 25c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm-43-7c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm63 31c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM34 90c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm56-76c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM12 86c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm28-65c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm23-11c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-6 60c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm29 22c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zM32 63c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm57-13c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-9-21c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM60 91c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM35 41c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM12 60c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2z' fill='%23222' fill-opacity='0.4' fill-rule='evenodd'/%3E%3C/svg%3E");
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.8);
    display: none;
}

/* 玩家飞机样式 */
.player {
    position: absolute;
    width: 10%;
    height: 8%;
    left: 45%;
    bottom: 3%;
    z-index: 10;
    transition: all 0.05s ease;
}

.player-body {
    position: absolute;
    top: 15%;
    left: 20%;
    width: 60%;
    height: 70%;
    background: linear-gradient(to bottom, #00ff9d, #00cc88);
    border-radius: 15px 15px 5px 5px;
}

.player-wing {
    position: absolute;
    top: 40%;
    width: 40%;
    height: 25%;
    background: linear-gradient(to bottom, #00ff9d, #00cc88);
    border-radius: 10px;
}

.player-wing.left {
    left: 0;
    transform: rotate(-15deg);
}

.player-wing.right {
    right: 0;
    transform: rotate(15deg);
}

/* 子弹样式 */
.bullet {
    position: absolute;
    background: linear-gradient(to top, #ff3366, #ff6688);
    border-radius: 2px;
    z-index: 5;
}

.bullet.normal {
    width: 1.2%;
    height: 3.5%;
}

.bullet.strong {
    width: 2%;
    height: 5%;
    background: linear-gradient(to top, #ffcc00, #ffff00);
    box-shadow: 0 0 10px #ffff00;
}

/* 敌机样式 */
.enemy {
    position: absolute;
    z-index: 8;
}

.enemy.normal {
    width: 9%;
    height: 5.5%;
    background: linear-gradient(to bottom, #ff6600, #ff3300);
    border-radius: 10px 10px 5px 5px;
}

.enemy.normal::before {
    content: "";
    position: absolute;
    top: 12%;
    left: 10%;
    width: 80%;
    height: 25%;
    background: #ff9900;
    border-radius: 5px;
}

.enemy.boss {
    width: 14%;
    height: 8%;
    background: linear-gradient(to bottom, #9900cc, #660099);
    border-radius: 15px 15px 10px 10px;
    box-shadow: 0 0 15px #9900cc;
}

.enemy.boss::before {
    content: "";
    position: absolute;
    top: 15%;
    left: 15%;
    width: 70%;
    height: 25%;
    background: #cc33ff;
    border-radius: 8px;
}

/* 敌机子弹 */
.enemy-bullet {
    position: absolute;
    width: 1.6%;
    height: 2.5%;
    background: linear-gradient(to bottom, #ff0066, #cc0055);
    border-radius: 4px;
    z-index: 7;
}

/* 陨石样式 */
.meteor {
    position: absolute;
    width: 10%;
    height: 10%;
    background: linear-gradient(45deg, #666666, #333333);
    border-radius: 50% 40% 60% 30%;
    transform: rotate(45deg);
    box-shadow: 0 0 10px #666666;
    z-index: 9;
}

/* 道具样式 */
.prop {
    position: absolute;
    width: 8%;
    height: 8%;
    border-radius: 50%;
    z-index: 15;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #fff;
    font-weight: bold;
    font-size: 16px;
}

.prop.clear {
    background: linear-gradient(45deg, #0099ff, #0066cc);
    box-shadow: 0 0 10px #0099ff;
}

.prop.strong {
    background: linear-gradient(45deg, #ffcc00, #ff9900);
    box-shadow: 0 0 10px #ffcc00;
}

.prop.speed {
    background: linear-gradient(45deg, #ff0066, #cc0055);
    box-shadow: 0 0 10px #ff0066;
}

.prop.multi {
    background: linear-gradient(45deg, #00ff66, #00cc55);
    box-shadow: 0 0 10px #00ff66;
}

/* 信息面板 */
.info-panel {
    position: absolute;
    top: 2%;
    left: 2%;
    right: 2%;
    display: flex;
    justify-content: space-between;
    color: #fff;
    font-size: 3vw;
    z-index: 20;
    text-shadow: 0 0 5px #000;
}

.info-panel .score, .info-panel .hp {
    background: rgba(0, 0, 0, 0.7);
    padding: 1% 2%;
    border-radius: 5px;
}

.props {
    display: flex;
    gap: 10px;
}

.prop-item {
    background: rgba(0, 0, 0, 0.7);
    padding: 1% 2%;
    border-radius: 5px;
}

/* 游戏结束界面 */
#game-over {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    color: #fff;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 50;
}

#game-over h2 {
    font-size: 10vw;
    margin-bottom: 20px;
    color: #ff3366;
    text-shadow: 0 0 10px #ff3366;
}

#game-over p {
    font-size: 5vw;
    margin-bottom: 30px;
}

/* 爆炸效果 */
.explosion {
    position: absolute;
    width: 16%;
    height: 16%;
    background: radial-gradient(circle, #ffcc00 0%, #ff6600 50%, #ff3300 100%);
    border-radius: 50%;
    animation: explosion 0.5s ease-out forwards;
    z-index: 30;
}

@keyframes explosion {
    0% { transform: scale(0.5); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.8; }
    100% { transform: scale(1.5); opacity: 0; }
}

/* ========== 新增：手机虚拟按键样式 ========== */
.touch-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 480px;
    padding: 0 10px;
    display: none;
}

/* 横屏时显示虚拟按键（手机端） */
@media (max-width: 768px) {
    .touch-controls {
        display: flex;
    }
}

/* 方向键区域 */
.direction-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
}

/* 虚拟按键通用样式 */
.dir-btn, .skill-btn {
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid #00ff9d;
    border-radius: 8px;
    color: #00ff9d;
    font-size: 20px;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    touch-action: manipulation;
    user-select: none;
    transition: all 0.1s ease;
}

/* 方向键特殊布局 */
.dir-btn[data-key="ArrowUp"] {
    grid-column: 2;
    grid-row: 1;
}
.dir-btn[data-key="ArrowLeft"] {
    grid-column: 1;
    grid-row: 2;
}
.dir-btn[data-key="ArrowDown"] {
    grid-column: 2;
    grid-row: 2;
}
.dir-btn[data-key="ArrowRight"] {
    grid-column: 3;
    grid-row: 2;
}

/* 大招按钮 */
.skill-btn {
    width: 100px;
    background: linear-gradient(to right, #ff3366, #ff6688);
    border-color: #ff3366;
    color: #fff;
}

/* 按键按压反馈 */
.dir-btn:active, .skill-btn:active {
    background: rgba(0, 255, 157, 0.5);
    transform: scale(0.95);
}
.skill-btn:active {
    background: linear-gradient(to right, #cc0055, #ff0066);
}
