@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Exo+2:wght@300;400;700&display=swap');

body {
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    min-height: 100vh;
    background: #0a0a0a;
    font-family: 'Orbitron', monospace;
    overflow: hidden;
    position: relative;
    /* Nuclear option for mobile webview compatibility */
    overscroll-behavior: none !important;
    touch-action: manipulation !important;
    -ms-touch-action: manipulation !important;
    -webkit-touch-action: manipulation !important;
    user-select: none !important;
    -webkit-user-select: none !important;
    -ms-user-select: none !important;
    -moz-user-select: none !important;
    -webkit-touch-callout: none !important;
    -webkit-tap-highlight-color: transparent !important;
}



canvas {
    display: block;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    border: 2px solid #00d4ff;
    border-radius: 10px;
    box-shadow: 0 0 30px rgba(0, 212, 255, 0.3), 
                inset 0 0 30px rgba(0, 212, 255, 0.1);
    transition: filter 0.5s ease-in-out;
}

/* Game over blur effect */
canvas.game-over-blur {
    filter: blur(8px);
}

#messageBox {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.95), rgba(30, 60, 114, 0.8));
    color: white;
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    border: 2px solid rgba(0, 212, 255, 0.5);
    box-shadow: 0 0 30px rgba(0, 212, 255, 0.3);
    backdrop-filter: blur(10px);
    font-family: 'Orbitron', monospace;
}

#messageContent {
    display: flex;
    flex-direction: column;
    align-items: center;
}

#messageText {
    font-size: 18px;
    font-weight: 700;
    text-shadow: 0 0 10px rgba(0, 212, 255, 0.5);
    margin-bottom: 20px;
}

.hidden {
    display: none !important;
}

/* 菜单显示状态控制 */
.menu {
    display: none;
}

.menu.active {
    display: flex !important;
}

#gameMenu {
    display: none;
}

#gameMenu.active {
    display: block !important;
}

button {
    margin-top: 20px;
    padding: 12px 25px;
    border: none;
    background: linear-gradient(135deg, #00d4ff, #0099cc);
    color: white;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    border-radius: 25px;
    transition: all 0.3s ease;
    font-family: 'Orbitron', monospace;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 4px 15px rgba(0, 212, 255, 0.3);
    /* Mobile touch optimization */
    touch-action: manipulation !important;
    -webkit-touch-action: manipulation !important;
    -ms-touch-action: manipulation !important;
    user-select: none !important;
    -webkit-user-select: none !important;
    -webkit-touch-callout: none !important;
    -webkit-tap-highlight-color: rgba(0, 212, 255, 0.3) !important;
}

button:hover {
    background: linear-gradient(135deg, #0099cc, #00d4ff);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 212, 255, 0.5);
}

/* 菜单样式 */
.menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.95), rgba(30, 60, 114, 0.9));
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    font-family: 'Orbitron', monospace;
}

.menu-content {
    text-align: center;
    padding: 40px;
}

.menu h1 {
    font-size: 48px;
    color: #00d4ff;
    margin-bottom: 10px;
    text-shadow: 0 0 20px rgba(0, 212, 255, 0.7);
    font-weight: 900;
}

.menu h2 {
    font-size: 32px;
    color: #00d4ff;
    margin-bottom: 20px;
    text-shadow: 0 0 15px rgba(0, 212, 255, 0.7);
    font-weight: 700;
}

.subtitle {
    font-size: 16px;
    color: #ffffff;
    margin-bottom: 30px;
    opacity: 0.8;
    font-family: 'Exo 2', sans-serif;
}

.menu-button {
    display: block;
    width: 250px;
    margin: 15px auto;
    padding: 15px 30px;
    background: linear-gradient(135deg, #00d4ff, #0099cc);
    color: white;
    border: none;
    border-radius: 30px;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Orbitron', monospace;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 4px 15px rgba(0, 212, 255, 0.3);
    /* Mobile touch optimization */
    touch-action: manipulation !important;
    -webkit-touch-action: manipulation !important;
    -ms-touch-action: manipulation !important;
    user-select: none !important;
    -webkit-user-select: none !important;
    -webkit-touch-callout: none !important;
    -webkit-tap-highlight-color: rgba(0, 212, 255, 0.3) !important;
}

.menu-button:hover {
    background: linear-gradient(135deg, #0099cc, #00d4ff);
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 212, 255, 0.5);
}

.menu-button.secondary {
    background: linear-gradient(135deg, #666, #888);
    box-shadow: 0 4px 15px rgba(100, 100, 100, 0.3);
}

.menu-button.secondary:hover {
    background: linear-gradient(135deg, #888, #666);
    box-shadow: 0 6px 20px rgba(100, 100, 100, 0.5);
}

/* 游戏UI样式 */
.game-ui {
    position: fixed;
    right: 30px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 100;
    display: flex;
    gap: 12px;
    flex-direction: column;
    transition: all 0.3s ease;
}

.ui-button {
    padding: 10px 20px;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.8), rgba(30, 60, 114, 0.6));
    color: white;
    border: 2px solid rgba(0, 212, 255, 0.5);
    border-radius: 20px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Orbitron', monospace;
    backdrop-filter: blur(5px);
}

.ui-button:hover {
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.8), rgba(30, 60, 114, 0.8));
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 212, 255, 0.3);
}

/* 说明页面样式 */
.instructions {
    text-align: left;
    margin: 20px 0;
    padding: 20px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    border: 1px solid rgba(0, 212, 255, 0.3);
}

.instructions p {
    color: #ffffff;
    font-size: 16px;
    margin: 10px 0;
    font-family: 'Exo 2', sans-serif;
}

/* 高分榜样式 */
.high-score-list {
    margin: 20px 0;
    padding: 20px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    border: 1px solid rgba(0, 212, 255, 0.3);
    min-height: 200px;
}

.score-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    margin: 5px 0;
    background: rgba(0, 212, 255, 0.1);
    border-radius: 5px;
    color: white;
    font-family: 'Orbitron', monospace;
}

.score-rank {
    font-weight: 700;
    color: #00d4ff;
}

.score-value {
    font-weight: 700;
    color: #ffffff;
}

/* 移动设备适配 */
@media (max-width: 768px) {
    canvas {
        width: 100%;
        height: auto;
        max-width: 400px;
        max-height: 600px; /* Allow taller canvas for portrait mode */
    }

    .menu h1 {
        font-size: 32px;
    }

    .menu h2 {
        font-size: 24px;
    }

    .menu-button {
        width: 200px;
        font-size: 16px;
        padding: 12px 20px;
    }

    .menu-content {
        padding: 20px;
        margin: 20px;
    }

    /* 优化触摸指引 */
    .touch-guide-content {
        padding: 30px 20px;
        max-width: 90%;
    }

    .touch-guide-content h3 {
        font-size: 22px;
    }

    .touch-guide-content p {
        font-size: 15px;
    }
    
    .game-ui {
        /* 移动端：按钮放在底部中央 */
        position: fixed;
        bottom: 15px;
        left: 50%;
        right: auto;
        top: auto;
        transform: translateX(-50%);
        flex-direction: row;
        gap: 12px;
        justify-content: center;
        width: auto;
    }

    .ui-button {
        padding: 10px 16px;
        font-size: 12px;
        white-space: nowrap;
        min-width: 90px;
    }
    
    .instructions p {
        font-size: 14px;
    }
    
    .high-score-list {
        font-size: 14px;
    }
    
    /* Developer Branding Mobile Styles */
    .developer-branding {
        margin-top: 30px;
        padding: 15px;
    }
    
    .chan-logo {
        height: 35px;
    }
    
    .developer-name {
        font-size: 14px;
    }
    
    .developer-tagline {
        font-size: 12px;
        margin: 8px 0 12px 0;
    }
    
    .developer-links {
        gap: 10px;
    }
    
    .dev-link {
        padding: 6px 12px;
        font-size: 11px;
    }
}

@media (max-width: 480px) {
    canvas {
        max-width: 320px;
        max-height: 480px; /* Allow taller canvas for portrait mode on small screens */
    }

    body {
        font-size: 14px;
    }

    .menu h1 {
        font-size: 24px;
        margin-bottom: 8px;
    }

    .menu h2 {
        font-size: 20px;
        margin-bottom: 15px;
    }

    .subtitle {
        font-size: 13px;
        margin-bottom: 20px;
    }

    .menu-button {
        width: 180px;
        font-size: 14px;
        padding: 10px 15px;
        margin: 10px auto;
    }

    .menu-content {
        padding: 15px;
        margin: 10px;
        max-width: 95%;
    }

    .game-ui {
        bottom: 10px;
        gap: 8px;
    }

    .ui-button {
        padding: 8px 12px;
        font-size: 11px;
        min-width: 75px;
    }

    /* 优化消息框 */
    #messageBox {
        padding: 20px;
    }

    #messageContent {
        padding: 20px;
    }

    #messageText {
        font-size: 16px;
    }

    /* 优化触摸指引 */
    .touch-guide-content {
        padding: 25px 15px;
        max-width: 95%;
        margin: 10px;
    }

    .touch-guide-content h3 {
        font-size: 18px;
        margin-bottom: 12px;
    }

    .touch-guide-content p {
        font-size: 13px;
        line-height: 1.4;
    }

    /* 优化说明文本 */
    .instructions {
        padding: 15px;
        margin: 15px 0;
    }

    .instructions p {
        font-size: 13px;
        margin: 8px 0;
    }

    /* 优化高分榜 */
    .high-score-list {
        font-size: 13px;
        padding: 15px;
        margin: 15px 0;
    }

    .score-item {
        padding: 8px;
        margin: 4px 0;
    }
    
    /* Developer Branding Very Small Mobile Styles */
    .developer-branding {
        margin-top: 20px;
        padding: 12px;
    }
    
    .chan-logo {
        height: 30px;
    }
    
    .developer-name {
        font-size: 13px;
    }
    
    .developer-tagline {
        font-size: 11px;
        margin: 6px 0 10px 0;
    }
    
    .developer-links {
        gap: 8px;
        flex-direction: column;
        align-items: center;
    }
    
    .dev-link {
        padding: 5px 10px;
        font-size: 10px;
        min-width: 80px;
    }
}

@keyframes starField {
    0% { transform: translateY(0px); }
    100% { transform: translateY(-100px); }
}

@keyframes nebula {
    0% { background-position: 0% 0%; }
    50% { background-position: 100% 100%; }
    100% { background-position: 0% 0%; }
}

@keyframes glow {
    0% { box-shadow: 0 0 20px rgba(0, 212, 255, 0.3); }
    50% { box-shadow: 0 0 40px rgba(0, 212, 255, 0.6); }
    100% { box-shadow: 0 0 20px rgba(0, 212, 255, 0.3); }
}

body::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(2px 2px at 20px 30px, #fff, transparent),
        radial-gradient(2px 2px at 40px 70px, #fff, transparent),
        radial-gradient(1px 1px at 90px 40px, #fff, transparent),
        radial-gradient(1px 1px at 130px 80px, #fff, transparent),
        radial-gradient(2px 2px at 160px 30px, #fff, transparent),
        linear-gradient(45deg, #1e3c72 0%, #2a5298 50%, #1e3c72 100%);
    background-repeat: repeat;
    background-size: 200px 100px;
    animation: nebula 15s ease-in-out infinite;
    z-index: -1;
}

#gameContainer {
    position: relative;
    animation: glow 3s ease-in-out infinite;
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

@media (min-width: 769px) {
    #gameContainer {
        margin-bottom: 0; /* 桌面端不需要底部间距 */
    }
}

/* Developer Branding Styles */
.developer-branding {
    margin-top: 40px;
    padding: 20px;
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.1), rgba(30, 60, 114, 0.1));
    border: 1px solid rgba(0, 212, 255, 0.3);
    border-radius: 15px;
    backdrop-filter: blur(5px);
    text-align: center;
    transition: all 0.3s ease;
}

.developer-branding:hover {
    border-color: rgba(0, 212, 255, 0.5);
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.2);
}

.developer-logo {
    margin-bottom: 15px;
}

.chan-logo {
    height: 40px;
    width: auto;
    filter: brightness(0) invert(1);
    opacity: 0.9;
    transition: all 0.3s ease;
}

.chan-logo:hover {
    opacity: 1;
    filter: brightness(0) invert(1) drop-shadow(0 0 10px rgba(0, 212, 255, 0.5));
}

.developer-info {
    font-family: 'Exo 2', sans-serif;
}

.developer-name {
    font-size: 16px;
    color: #ffffff;
    margin: 8px 0;
    opacity: 0.9;
}

.developer-name strong {
    color: #00d4ff;
    font-weight: 700;
}

.developer-tagline {
    font-size: 14px;
    color: #ffffff;
    margin: 10px 0 15px 0;
    opacity: 0.8;
    font-style: italic;
    line-height: 1.4;
}

.developer-links {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.dev-link {
    display: inline-block;
    padding: 8px 16px;
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.2), rgba(30, 60, 114, 0.2));
    color: #00d4ff;
    text-decoration: none;
    border: 1px solid rgba(0, 212, 255, 0.3);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    font-family: 'Orbitron', monospace;
    transition: all 0.3s ease;
    backdrop-filter: blur(3px);
}

.dev-link:hover {
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.3), rgba(30, 60, 114, 0.3));
    border-color: rgba(0, 212, 255, 0.6);
    color: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 212, 255, 0.3);
}


/* 触摸指引样式 */
.touch-guide {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1500;
    font-family: 'Orbitron', monospace;
    backdrop-filter: blur(5px);
}

.touch-guide-content {
    text-align: center;
    padding: 40px;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.9), rgba(30, 60, 114, 0.7));
    border-radius: 20px;
    border: 2px solid rgba(0, 212, 255, 0.5);
    box-shadow: 0 0 30px rgba(0, 212, 255, 0.3);
    max-width: 400px;
    animation: fadeInScale 0.3s ease-out;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.touch-guide-content h3 {
    font-size: 28px;
    color: #00d4ff;
    margin-bottom: 20px;
    text-shadow: 0 0 15px rgba(0, 212, 255, 0.7);
}

.touch-guide-content p {
    font-size: 16px;
    color: #ffffff;
    margin-bottom: 25px;
    font-family: 'Exo 2', sans-serif;
    line-height: 1.5;
}