* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Rajdhani', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    min-height: 100vh;
    min-height: 100dvh;
    color: #fff;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

#bg-image {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('assets/11.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: -1;
    opacity: 0.3;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
    z-index: 1;
}

.header {
    text-align: center;
    padding: 40px 0;
}

.logo {
    max-width: 300px;
    height: auto;
    margin-bottom: 20px;
    filter: drop-shadow(0 0 20px rgba(0, 217, 255, 0.5));
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.title {
    font-family: 'Orbitron', 'Courier New', monospace;
    font-size: 48px;
    color: #00d9ff;
    text-shadow: 0 0 30px rgba(0, 217, 255, 0.8), 0 0 60px rgba(0, 217, 255, 0.4);
    letter-spacing: 4px;
    margin-bottom: 10px;
}

.subtitle {
    font-size: 24px;
    color: #ffd700;
    text-shadow: 0 0 15px rgba(255, 215, 0, 0.6);
    letter-spacing: 2px;
}

.game-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
    padding: 30px 0;
    margin-top: 20px;
}

/* 移动设备游戏网格优化 */
@media (max-width: 480px) {
    .game-grid {
        grid-template-columns: 1fr;
        gap: 12px;
        padding: 15px 0;
    }
    
    .game-card {
        padding: 15px;
    }
    
    .game-icon {
        font-size: 32px;
    }
    
    .game-name {
        font-size: 16px;
    }
    
    .game-desc {
        font-size: 12px;
    }

    .header {
        padding: 20px 0;
    }

    .logo {
        max-width: 180px;
    }

    .title {
        font-size: 26px;
        letter-spacing: 2px;
    }

    .subtitle {
        font-size: 14px;
    }
}

.game-card {
    background: linear-gradient(145deg, rgba(26, 26, 46, 0.9), rgba(15, 52, 96, 0.8));
    border: 2px solid rgba(0, 217, 255, 0.3);
    border-radius: 15px;
    padding: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.game-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(0, 217, 255, 0.1) 0%, transparent 70%);
    transform: rotate(45deg);
    transition: all 0.5s ease;
    opacity: 0;
}

.game-card:hover {
    transform: translateY(-8px) scale(1.02);
    border-color: #00d9ff;
    box-shadow: 0 15px 40px rgba(0, 217, 255, 0.3), 0 0 20px rgba(0, 217, 255, 0.2);
}

.game-card:hover::before {
    opacity: 1;
}

.game-icon {
    font-size: 48px;
    margin-bottom: 15px;
    display: block;
    filter: drop-shadow(0 0 10px rgba(0, 217, 255, 0.5));
}

.game-name {
    font-family: 'Orbitron', monospace;
    font-size: 22px;
    color: #00d9ff;
    margin-bottom: 10px;
    text-shadow: 0 0 10px rgba(0, 217, 255, 0.5);
}

.game-desc {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.6;
}

.game-highscore {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid rgba(0, 217, 255, 0.2);
    font-size: 14px;
    color: #ffd700;
}

#game-container {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    background: rgba(10, 10, 20, 0.95);
    z-index: 100;
    overflow: hidden;
}

.game-view {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    height: 100%;
    height: 100dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    display: flex;
    flex-direction: column;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: linear-gradient(145deg, rgba(26, 26, 46, 0.95), rgba(15, 52, 96, 0.9));
    border-bottom: 2px solid rgba(0, 217, 255, 0.3);
    border-radius: 10px 10px 0 0;
}

.game-title {
    font-family: 'Orbitron', monospace;
    font-size: 28px;
    color: #00d9ff;
    text-shadow: 0 0 15px rgba(0, 217, 255, 0.6);
}

.game-score {
    font-size: 24px;
    color: #ffd700;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.game-controls-top {
    display: flex;
    gap: 15px;
    margin-top: 15px;
}

.btn {
    padding: 12px 30px;
    font-family: 'Orbitron', monospace;
    font-size: 16px;
    border: 2px solid #00d9ff;
    background: rgba(0, 217, 255, 0.1);
    color: #00d9ff;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn:hover {
    background: rgba(0, 217, 255, 0.3);
    box-shadow: 0 0 20px rgba(0, 217, 255, 0.4);
    transform: translateY(-2px);
}

.btn:active {
    transform: translateY(0);
}

.btn-secondary {
    border-color: #ffd700;
    color: #ffd700;
    background: rgba(255, 215, 0, 0.1);
}

.btn-secondary:hover {
    background: rgba(255, 215, 0, 0.3);
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.4);
}

#game-canvas {
    display: block;
    margin: 0 auto;
    background: rgba(0, 0, 0, 0.8);
    border: 3px solid rgba(0, 217, 255, 0.5);
    border-radius: 10px;
    box-shadow: 0 0 30px rgba(0, 217, 255, 0.3);
    max-width: 100%;
    height: auto;
    object-fit: contain;
}

/* 游戏画布容器 */
.game-canvas-container {
    position: relative;
    max-width: 100%;
    margin: 0 auto;
    overflow: hidden;
    border-radius: 10px;
    box-shadow: 0 0 30px rgba(0, 217, 255, 0.3);
}

/* 移动设备Canvas优化 */
@media (max-width: 480px) {
    #game-canvas {
        max-width: 100%;
        height: auto !important;
        border-width: 2px;
    }
    
    .game-canvas-container {
        margin-bottom: 10px;
        flex-shrink: 0;
    }
    
    /* 针对横屏模式的Canvas调整 */
    @media (orientation: landscape) and (max-height: 600px) {
        #game-canvas {
            max-height: 50vh;
            width: auto;
        }
        
        .game-canvas-container {
            max-height: 50vh;
            overflow: hidden;
        }

        .game-view {
            padding-bottom: 140px;
            padding-bottom: calc(140px + env(safe-area-inset-bottom, 0px));
        }
    }
}

.game-info {
    margin-top: 20px;
    padding: 20px;
    background: linear-gradient(145deg, rgba(26, 26, 46, 0.9), rgba(15, 52, 96, 0.8));
    border-radius: 10px;
    border: 1px solid rgba(0, 217, 255, 0.2);
}

.game-info h3 {
    font-family: 'Orbitron', monospace;
    color: #00d9ff;
    margin-bottom: 15px;
    font-size: 20px;
}

.game-info p {
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.8;
    margin-bottom: 10px;
}

.game-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 10;
}

.overlay-content {
    background: linear-gradient(145deg, rgba(26, 26, 46, 0.98), rgba(15, 52, 96, 0.95));
    padding: 40px;
    border-radius: 20px;
    border: 3px solid rgba(0, 217, 255, 0.5);
    box-shadow: 0 0 50px rgba(0, 217, 255, 0.4);
}

.overlay-title {
    font-family: 'Orbitron', monospace;
    font-size: 36px;
    color: #00d9ff;
    text-shadow: 0 0 20px rgba(0, 217, 255, 0.8);
    margin-bottom: 20px;
}

.overlay-score {
    font-size: 28px;
    color: #ffd700;
    margin-bottom: 30px;
    text-shadow: 0 0 15px rgba(255, 215, 0, 0.6);
}

.overlay-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
}

.footer {
    text-align: center;
    padding: 40px 0;
    color: rgba(255, 255, 255, 0.6);
    font-size: 14px;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.fade-in {
    animation: fadeIn 0.5s ease-out;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.pulse {
    animation: pulse 2s infinite;
}

.hidden {
    display: none !important;
}

canvas {
    touch-action: none;
}

/* 滑动条样式 */
.game-view::-webkit-scrollbar {
    width: 8px;
}

.game-view::-webkit-scrollbar-track {
    background: rgba(0, 217, 255, 0.1);
    border-radius: 10px;
}

.game-view::-webkit-scrollbar-thumb {
    background: rgba(0, 217, 255, 0.5);
    border-radius: 10px;
}

.game-view::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 217, 255, 0.8);
}

@media (max-width: 768px) {
    .title {
        font-size: 32px;
    }

    .subtitle {
        font-size: 18px;
    }

    .game-grid {
        grid-template-columns: 1fr;
    }

    .game-header {
        flex-direction: column;
        gap: 10px;
        text-align: center;
        padding: 12px;
    }

    .game-controls-top {
        flex-wrap: wrap;
        justify-content: center;
    }

    .btn {
        padding: 10px 20px;
        font-size: 14px;
    }

    .game-view {
        padding: 10px;
        padding-top: env(safe-area-inset-top, 10px);
        /* 为虚拟控制器预留底部空间 */
        padding-bottom: 180px;
        padding-bottom: calc(180px + env(safe-area-inset-bottom, 0px));
    }

    .game-info {
        margin-top: 10px;
        padding: 12px;
    }

    .game-info h3 {
        font-size: 16px;
        margin-bottom: 8px;
    }

    .game-info p {
        font-size: 13px;
        margin-bottom: 5px;
    }

    .game-canvas-container {
        flex-shrink: 0;
    }

    #game-canvas {
        max-width: 100%;
        height: auto !important;
        border-width: 2px;
    }
}

#virtual-controller {
    pointer-events: auto;
}

#virtual-controller .vkey-btn {
    transition: transform 0.05s, box-shadow 0.05s;
}

#virtual-controller .vkey-btn:active,
#virtual-controller .vkey-btn.vkey-active {
    transform: scale(0.92);
    box-shadow: 0 2px 10px rgba(0, 217, 255, 0.6);
}

#virtual-controller .vkey-btn.vkey-btn-large {
    font-size: 18px;
    border-radius: 50%;
}

#virtual-controller .vkey-dpad,
#virtual-controller .vkey-trackpad,
#virtual-controller .vkey-flappy,
#virtual-controller .vkey-numpad,
#virtual-controller > div > div {
    pointer-events: auto;
}

@media (max-width: 480px) {
    #virtual-controller {
        bottom: 0;
        padding: 8px 12px;
        padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    }

    #virtual-controller .vkey-btn {
        min-width: 48px;
        min-height: 48px;
        font-size: 16px;
    }

    .game-view {
        padding: 8px;
        padding-top: env(safe-area-inset-top, 8px);
    }

    .game-header {
        padding: 10px 8px;
    }

    .game-title {
        font-size: 20px;
    }

    .overlay-content {
        padding: 20px;
        max-width: 90vw;
    }

    .overlay-title {
        font-size: 24px;
    }

    .overlay-score {
        font-size: 22px;
    }

    .overlay-buttons {
        flex-direction: column;
        gap: 10px;
    }

    .overlay-buttons .btn {
        width: 100%;
    }
}

@media (min-width: 768px) and (max-width: 1024px) {
    #virtual-controller {
        bottom: 80px;
    }

    #virtual-controller .vkey-btn {
        min-width: 50px;
        min-height: 50px;
    }
}

@media (orientation: landscape) and (max-height: 600px) {
    #virtual-controller {
        bottom: 0;
        padding: 4px 15px;
        padding-bottom: calc(4px + env(safe-area-inset-bottom, 0px));
    }

    #virtual-controller .vkey-btn {
        min-width: 40px;
        min-height: 40px;
        font-size: 14px;
    }

    .game-canvas-container {
        max-height: 55vh;
    }

    .game-view {
        padding-bottom: 120px;
        padding-bottom: calc(120px + env(safe-area-inset-bottom, 0px));
    }
}

.vkey-btn::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    right: 2px;
    height: 50%;
    background: linear-gradient(to bottom, rgba(255,255,255,0.2), transparent);
    border-radius: 10px 10px 50% 50%;
    pointer-events: none;
}

@media (hover: hover) {
    #virtual-controller .vkey-btn:hover {
        box-shadow: 0 4px 20px rgba(0, 217, 255, 0.5);
    }
}
