/* H5移动端优化样式 */

/* 基础重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
    touch-action: none;
}

/* 游戏画布容器 */
#gameContainer {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #000000;
}

/* 游戏画布响应式缩放 */
canvas {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    image-rendering: crisp-edges;
    image-rendering: pixelated;
}

/* 移动端虚拟控制按钮 */
.mobile-controls {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: none;
    z-index: 100;
}

.mobile-controls.active {
    display: flex;
    gap: 10px;
}

.mobile-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.4);
    color: white;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
}

.mobile-btn:active {
    background: rgba(255, 255, 255, 0.4);
    transform: scale(0.95);
}

/* 加载屏幕样式 */
#loadingScreen {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
}

#loadingBar {
    background: linear-gradient(90deg, #00ff00, #00cc00);
    box-shadow: 0 0 10px rgba(0, 255, 0, 0.5);
}

/* 全屏按钮 */
#fullscreenBtn {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.4);
    color: white;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 100;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

#fullscreenBtn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

#fullscreenBtn:active {
    transform: scale(0.95);
}

/* 移动端横屏提示 */
#landscapeWarning {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    color: white;
    text-align: center;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
}

#landscapeWarning.active {
    display: flex;
}

#landscapeWarning h2 {
    font-size: 24px;
    margin-bottom: 20px;
}

#landscapeWarning p {
    font-size: 16px;
    opacity: 0.8;
}

/* 方向控制按钮 */
.d-pad {
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 150px;
    height: 150px;
    display: none;
    z-index: 100;
}

.d-pad.active {
    display: block;
}

.d-pad-btn {
    position: absolute;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.4);
    color: white;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
}

.d-pad-btn:active {
    background: rgba(255, 255, 255, 0.4);
    transform: scale(0.95);
}

.d-pad-btn.up { top: 0; left: 50px; }
.d-pad-btn.down { bottom: 0; left: 50px; }
.d-pad-btn.left { left: 0; top: 50px; }
.d-pad-btn.right { right: 0; top: 50px; }
.d-pad-btn.center { top: 50px; left: 50px; }

/* 动作按钮 */
.action-buttons {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: none;
    z-index: 100;
}

.action-buttons.active {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.action-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(255, 100, 100, 0.3);
    border: 2px solid rgba(255, 100, 100, 0.5);
    color: white;
    font-size: 16px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
}

.action-btn:active {
    background: rgba(255, 100, 100, 0.5);
    transform: scale(0.95);
}

/* 响应式断点 */
@media (max-width: 768px) {
    .mobile-controls.active {
        bottom: 10px;
    }

    .mobile-btn {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }

    #fullscreenBtn {
        width: 40px;
        height: 40px;
        font-size: 16px;
        top: 10px;
        right: 10px;
    }

    .d-pad {
        width: 120px;
        height: 120px;
        bottom: 10px;
        left: 10px;
    }

    .d-pad-btn {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }

    .d-pad-btn.up { top: 0; left: 40px; }
    .d-pad-btn.down { bottom: 0; left: 40px; }
    .d-pad-btn.left { left: 0; top: 40px; }
    .d-pad-btn.right { right: 0; top: 40px; }
    .d-pad-btn.center { top: 40px; left: 40px; }

    .action-buttons {
        bottom: 10px;
        right: 10px;
    }

    .action-btn {
        width: 50px;
        height: 50px;
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .mobile-btn {
        width: 45px;
        height: 45px;
        font-size: 18px;
    }

    .d-pad {
        width: 100px;
        height: 100px;
    }

    .d-pad-btn {
        width: 35px;
        height: 35px;
        font-size: 14px;
    }

    .d-pad-btn.up { top: 0; left: 32.5px; }
    .d-pad-btn.down { bottom: 0; left: 32.5px; }
    .d-pad-btn.left { left: 0; top: 32.5px; }
    .d-pad-btn.right { right: 0; top: 32.5px; }
    .d-pad-btn.center { top: 32.5px; left: 32.5px; }

    .action-btn {
        width: 45px;
        height: 45px;
        font-size: 12px;
    }
}

/* 横屏模式优化 */
@media (orientation: landscape) and (max-height: 600px) {
    .d-pad {
        bottom: 10px;
        left: 10px;
    }

    .action-buttons {
        bottom: 10px;
        right: 10px;
    }

    .mobile-controls {
        bottom: 10px;
    }
}

/* 深色模式支持 */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #000000;
    }

    #loadingScreen {
        background-color: #000000;
    }
}

/* 高对比度模式支持 */
@media (prefers-contrast: high) {
    .mobile-btn,
    .d-pad-btn,
    .action-btn,
    #fullscreenBtn {
        border-width: 3px;
        background: rgba(255, 255, 255, 0.3);
    }
}

/* 减少动画模式支持 */
@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation: none !important;
    }
}

/* 打印样式 */
@media print {
    body {
        display: none;
    }
}