* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 确保html和body元素允许滚动 */
html {
    overflow-y: auto !important;
    height: 100%;
    touch-action: pan-y !important;
}

body {
    font-family: Arial, sans-serif;
    background-color: #f0f0f0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    margin: 0;
    padding: 10px;
    overflow-x: hidden;
    overflow-y: auto !important; /* 允许垂直滚动 */
    touch-action: pan-y !important; /* 只允许垂直滚动，禁用其他触摸行为 */
    display: block; /* 移除flex布局，改用block布局允许正常滚动 */
    height: auto !important; /* 允许高度自动增长 */
    min-height: 100vh;
    position: static !important;
}

/* 重置所有链接样式，确保覆盖浏览器默认样式 */
a,
a:link,
a:visited,
a:hover,
a:active {
    color: #666 !important;
    text-decoration: none !important;
}

.game-container {
    background-color: #fff;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
    padding: 20px;
    text-align: center;
    max-width: 900px;
    width: 100%;
    box-sizing: border-box;
    overflow: visible; /* 允许内容溢出，不阻止页面滚动 */
    display: block;
    margin: 0 auto;
}

.game-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    background-color: #333;
    color: #fff;
    padding: 10px 20px;
    border-radius: 5px;
    font-weight: bold;
}

.game-header div {
    flex: 1;
}

#gameCanvas {
    border: 3px solid #333;
    border-radius: 5px;
    background-color: #000;
    display: block;
    margin: 0 auto 20px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
    max-width: 100%;
    height: auto;
    object-fit: contain;
    width: 100%;
}

@media (max-width: 768px) {
    .game-container {
        padding: 10px;
        max-width: 100%;
    }
    
    .game-header {
        flex-direction: row;
        gap: 5px;
        text-align: center;
        padding: 8px;
        font-size: 14px;
    }
    
    .game-controls {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
    }
    
    .game-controls button {
        margin: 0 5px 10px;
        padding: 8px 16px;
        font-size: 12px;
        flex: 1;
        min-width: 100px;
    }
    
    /* 手机端图标调整 */
    .game-controls button::after {
        font-size: 16px;
        margin-left: 5px;
    }
    
    .instructions {
        padding: 10px;
    }
    
    .instructions p {
        font-size: 12px;
    }
}

/* 触摸控制样式 */
.touch-controls {
    display: flex;
    justify-content: space-around;
    align-items: center;
    margin: 10px auto 10px;
    gap: 20px;
    max-width: 800px;
    touch-action: manipulation; /* 允许基本触摸操作，如点击，同时允许页面滚动 */
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* 轮盘样式 */
.joystick-container {
    position: relative;
    width: 150px;
    height: 150px;
    margin: 10px auto;
    touch-action: none; /* 禁用浏览器默认的触摸行为 */
}

/* 轮盘背景 */
.joystick-base {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background-color: rgba(51, 51, 51, 0.7);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    border: 3px solid #555;
}

/* 可拖动的轮盘拇指 */
.joystick-thumb {
    position: absolute;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.9);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    cursor: pointer;
    transition: transform 0.1s ease;
    z-index: 10;
    border: 3px solid #333;
}

/* 发射按钮样式保持不变 */
.fire-btn-container {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 190px; /* 与方向键区域高度匹配 */
    margin-top: -10px; /* 往上移10px */
}

.fire-btn {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background-color: #ff3333;
    color: white;
    border: none;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    transition: all 0.1s ease;
    display: flex;
    justify-content: center;
    align-items: center;
}

.fire-btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    background-color: #ff5555;
}

/* 响应式调整 */
@media (max-width: 768px) {
    .joystick-container {
        width: 120px;
        height: 120px;
    }
    
    .joystick-thumb {
        width: 50px;
        height: 50px;
    }
}

/* 响应式触摸控制 */
@media (max-width: 768px) {
    .touch-controls {
        margin-top: 15px;
        gap: 10px;
    }
    
    .dpad-btn {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
    
    /* 调整发射按钮容器高度，与手机端方向键区域匹配 */
    .fire-btn-container {
        min-height: 180px; /* 与手机端方向键区域高度匹配 */
        margin-top: -10px; /* 往上移10px */
    }
    
    .fire-btn {
        width: 70px;
        height: 70px;
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .dpad-btn {
        width: 45px;
        height: 45px;
        font-size: 18px;
    }
    
    /* 调整发射按钮容器高度，与小手机端方向键区域匹配 */
    .fire-btn-container {
        min-height: 170px; /* 与小手机端方向键区域高度匹配 */
        margin-top: -10px; /* 往上移10px */
    }
    
    .fire-btn {
        width: 65px;
        height: 65px;
        font-size: 14px;
    }
}

/* 桌面端隐藏触摸控制 */
@media (min-width: 769px) {
    .touch-controls {
        display: none;
    }
}

.game-controls {
    margin: 10px auto 20px;
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
    max-width: 800px;
}

.game-controls button {
    background-color: #4CAF50;
    color: white;
    border: none;
    padding: 10px 30px;
    font-size: 18px;
    cursor: pointer;
    border-radius: 50px;
    transition: all 0.3s ease;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    text-transform: uppercase;
    letter-spacing: 1px;
    min-width: 120px;
    position: relative;
    overflow: hidden;
}

.game-controls button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: all 0.5s ease;
}

.game-controls button:hover::before {
    left: 100%;
}

.game-controls button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
    filter: brightness(1.1);
}

.game-controls button:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.game-controls button:nth-child(1) {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
}

.game-controls button:nth-child(2) {
    background: linear-gradient(135deg, #ff9800 0%, #e68a00 100%);
}

/* 添加图标效果 - 移除emoji */
.game-controls button::after {
    content: '';
    font-size: 0;
    vertical-align: middle;
}

/* 手机端调整游戏控制按钮大小 */
@media (max-width: 768px) {
    .game-controls {
        gap: 10px;
        margin-bottom: 15px;
    }
    
    .game-controls button {
        padding: 10px 20px;
        font-size: 14px;
        min-width: 90px;
        border-radius: 40px;
        letter-spacing: 0.5px;
    }
    
    /* 移除手机端按钮的emoji */
    .game-controls button::after {
        content: '';
        font-size: 0;
        margin-left: 0;
    }
}

.instructions {
    background-color: #f9f9f9;
    padding: 15px;
    border-radius: 5px;
    border: 1px solid #ddd;
    margin-bottom: 0; /* 移除底部外边距，避免margin折叠 */
}

.instructions h3 {
    margin-bottom: 10px;
    color: #333;
}

.instructions p {
    color: #666;
    font-size: 14px;
}

.gamerise-link {
    margin-top: 30px !important;
    margin-bottom: 15px !important;
    text-align: center;
    font-size: 16px;
    display: block;
    clear: both;
    padding-top: 15px;
    border-top: 1px solid #eee;
}

/* 全面重置链接样式，确保覆盖所有浏览器默认样式 */
.gamerise-link a,
.gamerise-link a:link,
.gamerise-link a:visited,
.gamerise-link a:hover,
.gamerise-link a:active {
    color: #666 !important;
    text-decoration: none !important;
    font-weight: bold;
    outline: none;
    border: none;
    background: none;
    display: inline;
    padding: 0;
    margin: 0;
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    cursor: pointer;
}