/**
 * Game Container Styles
 */

#game-container {
    width: 100%;
    min-height: calc(100vh - 70px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    /* 移动端触摸优化 */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

/* 移动端减少padding以最大化游戏空间 */
@media (max-width: 768px) {
    #game-container {
        padding: 5px;
        min-height: calc(100vh - 60px);
    }
}

.game-wrapper {
    position: relative;
    max-width: 100%;
    margin: 0 auto;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(138, 43, 226, 0.3);
}

#game-canvas {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    /* 移动端游戏交互优化 */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    /* 防止双击缩放 */
    touch-action: manipulation;
}

/* Game Loading */
.game-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 60px;
    color: white;
}

.game-loading .spinner {
    width: 60px;
    height: 60px;
    border-width: 6px;
}

.game-loading-text {
    font-size: 18px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.8);
}

/* Game Error */
.game-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 60px;
    color: white;
    text-align: center;
}

.game-error-icon {
    font-size: 60px;
    color: #ff4444;
}

.game-error-title {
    font-size: 24px;
    font-weight: 600;
}

.game-error-message {
    font-size: 16px;
    color: rgba(255, 255, 255, 0.7);
    max-width: 400px;
}

/* Game Controls */
.game-controls {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 12px;
    z-index: 10;
}

.game-control-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.game-control-btn:hover {
    background: rgba(138, 43, 226, 0.8);
    border-color: var(--primary-color);
    transform: scale(1.1);
}

/* Fullscreen */
.game-wrapper.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    border-radius: 0;
    z-index: 9999;
}

/* Mobile Game Container Improvements */
.game-wrapper.mobile-optimized {
    width: 100%;
    max-width: 100vw;
    height: auto;
    min-height: calc(100vh - 90px);
}

.game-wrapper.mobile-optimized #game-canvas {
    width: 100%;
    min-height: calc(100vh - 90px);
}

/* 移动端竖屏自适应模式 */
.mobile-portrait-adaptive {
    width: 100% !important;
    max-width: 100vw !important;
    height: calc(100vh - 80px) !important;
    margin: 0 !important;
    border-radius: 0 !important;
    border-left: none !important;
    border-right: none !important;
    /* 支持安全区域（iPhone刘海屏等） */
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

/* 移动端横屏全屏模式 */
.mobile-landscape-fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    margin: 0 !important;
    border-radius: 0 !important;
    border: none !important;
    z-index: 9999 !important;
    /* 支持安全区域 */
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

/* Portrait Mode Optimization */
@media screen and (orientation: portrait) and (max-width: 768px) {
    #game-container {
        padding: 0;
        align-items: flex-start;
        min-height: calc(100vh - 60px);
    }

    .game-wrapper {
        width: 100%;
        max-width: 100vw;
        margin: 0;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .game-wrapper:not(.fullscreen) {
        height: calc(100vh - 80px);
        max-height: calc(100vh - 80px);
    }
}

/* Landscape Mode Optimization */
@media screen and (orientation: landscape) and (max-height: 500px) {
    #game-container {
        padding: 0;
        min-height: 100vh;
    }

    .game-wrapper {
        width: 100vw;
        height: 100vh;
        border-radius: 0;
        border: none;
    }

    .game-controls {
        top: 5px;
        right: 5px;
    }
}

/* 横屏模式下的全屏优化 */
@media screen and (orientation: landscape) and (max-width: 1024px) {
    #game-container {
        padding: 0;
    }
    
    .mobile-landscape-fullscreen #game-canvas {
        width: 100%;
        height: 100%;
    }
}

/* Responsive */
@media (max-width: 768px) {
    #game-container {
        padding: 15px 10px;
        min-height: calc(100vh - 60px);
    }

    .game-wrapper {
        border-radius: 12px;
        width: 100%;
        max-width: 100%;
    }

    .game-controls {
        top: 10px;
        right: 10px;
        gap: 8px;
    }

    .game-control-btn {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }

    .game-loading {
        padding: 40px 20px;
    }

    .game-error {
        padding: 40px 20px;
    }
}

@media (max-width: 480px) {
    #game-container {
        padding: 10px 5px;
        min-height: calc(100vh - 60px);
    }

    .game-wrapper {
        border-radius: 8px;
        border: 1px solid rgba(138, 43, 226, 0.3);
    }

    .game-controls {
        top: 8px;
        right: 8px;
        gap: 6px;
    }

    .game-control-btn {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }

    .game-loading {
        padding: 30px 15px;
    }

    .game-loading .spinner {
        width: 40px;
        height: 40px;
        border-width: 4px;
    }

    .game-loading-text {
        font-size: 16px;
    }

    .game-error {
        padding: 30px 15px;
    }

    .game-error-icon {
        font-size: 48px;
    }

    .game-error-title {
        font-size: 20px;
    }

    .game-error-message {
        font-size: 14px;
        max-width: 300px;
    }
}

/* Extra Small Devices */
@media (max-width: 360px) {
    #game-container {
        padding: 5px;
    }

    .game-wrapper {
        border-radius: 6px;
    }

    .game-controls {
        top: 6px;
        right: 6px;
        gap: 4px;
    }

    .game-control-btn {
        width: 28px;
        height: 28px;
        font-size: 11px;
    }
}

/* 移动端游戏专用优化 */
.mobile-game-optimized {
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    user-select: none !important;
    -webkit-touch-callout: none !important;
    -webkit-tap-highlight-color: transparent !important;
    touch-action: manipulation !important;
}

/* 游戏内按钮和可交互元素优化 */
.game-wrapper button,
.game-wrapper input,
.game-wrapper select,
.game-wrapper [onclick],
.game-wrapper [role="button"],
.game-wrapper .clickable {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    cursor: pointer;
}

/* 防止游戏内文本被选中 */
.game-wrapper * {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* 允许特定元素的文本选择（如输入框） */
.game-wrapper input[type="text"],
.game-wrapper input[type="email"],
.game-wrapper input[type="password"],
.game-wrapper textarea {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

/* 移动端特殊处理：快速点击响应 */
@media (max-width: 768px) {
    .game-wrapper {
        -webkit-user-select: none !important;
        -moz-user-select: none !important;
        -ms-user-select: none !important;
        user-select: none !important;
        -webkit-touch-callout: none !important;
        -webkit-tap-highlight-color: transparent !important;
        touch-action: manipulation !important;
    }

    /* 移动端游戏内所有元素都禁用选择 */
    .game-wrapper * {
        -webkit-user-select: none !important;
        -moz-user-select: none !important;
        -ms-user-select: none !important;
        user-select: none !important;
        -webkit-touch-callout: none !important;
    }
}

