body {
    margin: 0;
    padding: 0;
    background-color: #5c94fc; /* 经典马里奥天空蓝 */
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    font-family: Arial, sans-serif;
    overflow: hidden;
    /* 禁止移动端长按选中文本 */
    user-select: none;
    -webkit-user-select: none;
}

#game-container {
    position: relative;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    width: 800px;
    max-width: 100%;
    aspect-ratio: 4/3;
}

canvas {
    display: block;
    background-color: #5c94fc;
    width: 100%;
    height: 100%;
}

#instructions {
    position: absolute;
    top: 10px;
    left: 10px;
    color: white;
    background-color: rgba(0, 0, 0, 0.5);
    padding: 10px;
    border-radius: 5px;
    pointer-events: none;
    font-size: 14px;
}

#start-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    cursor: pointer;
    z-index: 10;
}

#start-screen h1 {
    font-size: 48px;
    margin-bottom: 20px;
    color: #ff3333;
    text-shadow: 2px 2px 0 #fff;
    text-align: center;
}

/* 虚拟按键样式 */
#touch-controls {
    display: none; /* 默认隐藏 */
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 120px;
    pointer-events: none; /* 让点击穿透到下面的元素（如果有的话），但按钮本身会有 pointer-events: auto */
    padding: 0 20px;
    box-sizing: border-box;
    z-index: 20;
}

#d-pad {
    position: absolute;
    bottom: 10px;
    left: 20px;
    pointer-events: auto;
}

#action-buttons {
    position: absolute;
    bottom: 10px;
    right: 20px;
    pointer-events: auto;
}

#touch-controls button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.5);
    color: white;
    font-size: 24px;
    font-weight: bold;
    margin: 5px;
    touch-action: manipulation; /* 优化触摸响应 */
    outline: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

#touch-controls button:active {
    background: rgba(255, 255, 255, 0.6);
    transform: scale(0.95);
}

#btn-jump {
    background: rgba(0, 255, 0, 0.3);
    margin-bottom: 20px; /* A键稍微靠上一点 */
}

#btn-shoot {
    background: rgba(255, 0, 0, 0.3);
    margin-right: 10px;
}

#btn-help {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 60px;
    height: 40px;
    background: rgba(255, 215, 0, 0.6); /* 金色半透明 */
    border: 2px solid #fff;
    border-radius: 20px;
    color: white;
    font-weight: bold;
    font-size: 16px;
    cursor: pointer;
    z-index: 30;
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
    touch-action: manipulation;
    outline: none;
    display: none; /* 默认隐藏，游戏开始后显示 */
}

#btn-help:active {
    background: rgba(255, 215, 0, 0.9);
    transform: scale(0.95);
}

/* 移动端适配 */
@media (max-width: 850px) {
    #game-container {
        width: 100vw;
        height: 75vw; /* 保持 4:3 比例 */
        max-height: 100vh;
        box-shadow: none;
    }
    
    #instructions {
        display: none; /* 移动端屏幕小，隐藏说明文字 */
    }

    #touch-controls {
        display: block; /* 显示虚拟按键 */
    }
}

/* 如果是横屏手机，可能需要全屏显示 */
@media (max-width: 900px) and (orientation: landscape) {
    #game-container {
        width: 100vh; /* 宽度由高度决定，保持比例 */
        height: 100vh;
        aspect-ratio: 4/3; 
        margin: 0 auto;
    }
}
