.spinner {
    height: 50px;
    width: 50px;
    margin: 0 auto;
    -webkit-animation: rotation .8s linear infinite;
    -moz-animation: rotation .8s linear infinite;
    -o-animation: rotation .8s linear infinite;
    animation: rotation .8s linear infinite;
    border-left: 10px solid #0096f0;
    border-right: 10px solid #0096f0;
    border-bottom: 10px solid #0096f0;
    border-top: 10px solid #6400c8;
    border-radius: 100%;
    background-color: #c864fa
}

@-webkit-keyframes rotation {
    from {
        -webkit-transform: rotate(0)
    }

    to {
        -webkit-transform: rotate(360deg)
    }
}

@-moz-keyframes rotation {
    from {
        -moz-transform: rotate(0)
    }

    to {
        -moz-transform: rotate(360deg)
    }
}

@-o-keyframes rotation {
    from {
        -o-transform: rotate(0)
    }

    to {
        -o-transform: rotate(360deg)
    }
}

@keyframes rotation {
    from {
        transform: rotate(0)
    }

    to {
        transform: rotate(360deg)
    }
}

/* 加载容器 - 居中显示 */
#spinner {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 99999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    padding: 40px 60px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 24px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    animation: fadeInScale 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    opacity: 1;
    transition: opacity 0.5s ease, transform 0.5s ease;
}

/* 隐藏状态 */
#spinner[hidden] {
    display: flex !important; /* 覆盖默认的 display: none */
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.8);
    pointer-events: none;
    animation: none;
}

/* 延迟完全隐藏 */
#spinner[hidden] {
    transition: opacity 0.5s ease, transform 0.5s ease, visibility 0s 0.5s;
    visibility: hidden;
}

@keyframes fadeInScale {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* 优化spinner动画 */
#spinner .spinner {
    height: 60px;
    width: 60px;
    margin: 0;
    animation: rotation 1s linear infinite;
    border-left: 8px solid #10b981;
    border-right: 8px solid #3b82f6;
    border-bottom: 8px solid #8b5cf6;
    border-top: 8px solid #ec4899;
    border-radius: 100%;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.3) 0%, rgba(139, 92, 246, 0.3) 100%);
    box-shadow: 0 0 30px rgba(139, 92, 246, 0.5);
}

/* 状态文本样式 */
#status {
    background: transparent;
    opacity: 1;
    position: relative;
    bottom: auto;
    left: auto;
    color: #ffffff;
    padding: 8px 24px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    letter-spacing: 0.5px;
    animation: pulse 2s ease-in-out infinite;
    max-width: 300px;
    word-wrap: break-word;
    transition: opacity 0.3s ease;
}

/* status隐藏状态 */
#status[hidden] {
    display: block !important;
    opacity: 0;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

/* 加载完成后的淡出效果 */
#spinner.loading-complete {
    animation: fadeOutScale 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}

@keyframes fadeOutScale {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
        pointer-events: none;
    }
}

#canvas {
    background-color: #000;
    padding: 0;
    margin: 0 auto;
    display: block;
    border: 0 none;
    width: 100%;
    height: 100%;
    max-height: 100vh;
    max-width: 100vw
}

#fullscreen {
    position: absolute;
    top: 16px;
    left: 16px;
    z-index: 9999;
    cursor: pointer;
    width: 52px;
    height: 52px;
    background: rgba(102, 126, 234, 0.2);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 32px 0 rgba(102, 126, 234, 0.37);
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    opacity: 0.7;
}

#fullscreen:hover {
    opacity: 1;
    transform: scale(1.15) rotate(180deg);
    background: rgba(118, 75, 162, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    box-shadow: 0 12px 48px 0 rgba(118, 75, 162, 0.5);
}

#fullscreen::before {
    content: '';
    position: absolute;
    width: 120%;
    height: 120%;
    border-radius: 50%;
    border: 2px solid rgba(102, 126, 234, 0.4);
    animation: ripple 3s infinite;
    pointer-events: none;
}

#fullscreen::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.3) 0%, rgba(118, 75, 162, 0.3) 100%);
    animation: rotate-gradient 4s linear infinite;
    z-index: -1;
}

@keyframes ripple {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }
    50% {
        transform: scale(1.3);
        opacity: 0.3;
    }
    100% {
        transform: scale(1);
        opacity: 0.8;
    }
}

@keyframes rotate-gradient {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

#fullscreen > svg {
    height: 26px;
    width: 26px;
    fill: #ffffff;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.4));
    transition: all 0.3s ease;
    position: relative;
    z-index: 1;
}

/* 页内全屏状态 */
#fullscreen.page-fullscreen {
    background: rgba(240, 147, 251, 0.25);
    border-color: rgba(255, 255, 255, 0.4);
}

#fullscreen.page-fullscreen::after {
    background: linear-gradient(135deg, rgba(240, 147, 251, 0.3) 0%, rgba(245, 87, 108, 0.3) 100%);
}

#fullscreen.page-fullscreen:hover {
    background: rgba(245, 87, 108, 0.3);
}

/* 浏览器全屏状态 */
#fullscreen.browser-fullscreen {
    background: rgba(16, 185, 129, 0.25);
    border-color: rgba(255, 255, 255, 0.4);
}

#fullscreen.browser-fullscreen::after {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.3) 0%, rgba(5, 150, 105, 0.3) 100%);
}

#fullscreen.browser-fullscreen:hover {
    background: rgba(5, 150, 105, 0.3);
}

/* 全屏容器样式 */
#webgame-fullscreen-container {
    position: relative;
    width: 100%;
    height: 100%;
    transition: all 0.3s ease;
}

/* 页内全屏模式 */
#webgame-fullscreen-container.page-fullscreen-mode {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 99999;
    background: #000;
}

#webgame-fullscreen-container.page-fullscreen-mode #canvas {
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
}

/* 浏览器全屏模式 */
#webgame-fullscreen-container.browser-fullscreen-mode {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 99999;
    background: #000;
}

#webgame-fullscreen-container.browser-fullscreen-mode #canvas {
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
}

/* 全屏模式提示 */
#fullscreen-mode-indicator {
    position: absolute;
    top: 80px;
    left: 16px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #fff;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 12px;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 9998;
}

#fullscreen-mode-indicator.show {
    opacity: 1;
}

/* 移动设备页内全屏优化 */
@media (max-width: 768px) {
    #webgame-fullscreen-container.page-fullscreen-mode {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw !important;
        height: 100vh !important;
        z-index: 99999;
        background: #000;
        /* 支持安全区域（刘海屏等） */
        padding-top: env(safe-area-inset-top);
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    #webgame-fullscreen-container.page-fullscreen-mode #canvas {
        width: 100vw !important;
        height: calc(100vh - env(safe-area-inset-top) - env(safe-area-inset-bottom)) !important;
        max-width: 100vw !important;
        max-height: calc(100vh - env(safe-area-inset-top) - env(safe-area-inset-bottom)) !important;
        margin-top: 0 !important;
    }
    
    /* 移动设备全屏按钮位置调整 */
    #fullscreen {
        top: calc(16px + env(safe-area-inset-top));
        left: calc(16px + env(safe-area-inset-right));
    }
    
    #fullscreen-mode-indicator {
        top: calc(80px + env(safe-area-inset-top));
        left: calc(16px + env(safe-area-inset-right));
    }
}

/* 针对 iOS 设备的额外优化 */
@supports (-webkit-touch-callout: none) {
    #webgame-fullscreen-container.page-fullscreen-mode {
        /* iOS Safari 状态栏适配 */
        padding-top: constant(safe-area-inset-top);
        padding-top: env(safe-area-inset-top);
    }
    
    #webgame-fullscreen-container.page-fullscreen-mode #canvas {
        height: calc(100vh - constant(safe-area-inset-top) - constant(safe-area-inset-bottom)) !important;
        height: calc(100vh - env(safe-area-inset-top) - env(safe-area-inset-bottom)) !important;
    }
}