body {
    text-align: center;
    background: linear-gradient(rgb(213, 229, 235), rgb(171, 205, 218));
    background-repeat: no-repeat;
    background-attachment: fixed;
    font-family: Arial, sans-serif;
}
canvas {
    background: #222;
    display: block;
    margin: 10px auto 20px auto;
    border: 2px solid black;
}
h1{
    color: rgb(9, 35, 77);
    margin: 10px 10px; 
    padding: 6px 10px;
    border-radius: 8px;
    border: 2px solid rgba(0, 0, 0, 0.3);
    background: rgba(210, 225, 229, 0.75);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    width: 480px;
    margin: 20px auto;
    margin-bottom: 10px;
}
.hud {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    width: 100%;
    max-width: 500px; /* optional: align with canvas width */
    margin: 0 auto;
    padding: 0px 0;
}
#score, #bullet, #live, #kill { 
    display: inline-block;
    font-size: 20px; 
    font-weight: bold;
    margin: 5px 10px; 
    padding: 6px 10px;
    border-radius: 8px;
    border: 2px solid rgba(0, 0, 0, 0.3);
    background: rgba(255, 255, 255, 0.75);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}
.content-text{
    font-size: 16px;
    color: #000000;
    margin: 5px 30px;
    text-align: left;
    padding: 0px 0px;
}
.btn {
    color: rgb(34, 37, 43);
    font-size: 20px; 
    font-weight: bold;
    margin: 20px 10px; 
    margin-bottom: 18px; 
    padding: 6px 10px;
    border-radius: 8px;
    border: 2px solid rgba(0, 0, 0, 0.3);
    background: rgba(200, 214, 221, 0.75);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}
.ene-types{
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 5px 10px; /* 12px row gap (vertical), 10px column gap (horizontal) */
    margin: 12px 20px;
    border: 5px solid rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.75);
    padding: 18px 15px;
}
.types{
    display: flex;
    align-items: center;
    gap: 15px;
    width: 100%;
    margin: -10px 0px;
}
#longer {
    grid-column: span 2;
    padding:2px 0px;
}
.description{
    font-size: 14px;
    color: #333;
    text-align: left;
}
.imgs{
    width: 40px;
    height: 40px;
}
.main-wrapper {
    position: relative;
    width: 500px;
    margin: 15px auto;
}
#highest-scores {
    position: absolute;
    left: 520px;   /* 500 + 20 gap */
    top: 0;

    width: 180px;
    min-height: 400px;

    background: rgb(55, 55, 55);
    color: #fff;
    border-radius: 8px;
    border: 2px solid black;
    padding: 10px;
    box-sizing: border-box;
    text-align: left;
}
#gameCanvas {
    background: #222;
    border: 2px solid #404040;
    cursor: crosshair;
    touch-action: none; /* 极其重要：防止手机浏览器滑动刷新 */
    margin: 0; /* ensure canvas itself stays centered inside container */
    border-radius: 8px;
    box-sizing: border-box;
}
#highest-scores h2 {
    text-align: center;
    margin-top: 0;
    font-size: 18px;
}
#highest-scores ol {
    padding-left: 20px;
    margin: 8px 0 0;
}
.btn2{
    font-size: 20px; 
    font-weight: bold;
    margin: 10px 10px 10px 10px;
    padding: 6px 10px;
    border-radius: 8px;
    border: 2px solid rgba(0, 0, 0, 0.3);
    background: rgba(200, 214, 221, 0.75);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}
.btn3{
    font-size: 20px; 
    font-weight: bold;
    margin: 10px 0px 25px 0px;
    padding: 6px 10px;
    border-radius: 8px;
    border: 2px solid rgba(0, 0, 0, 0.3);
    background: rgba(200, 214, 221, 0.75);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}
.btn:active, .btn2:active, .btn3:active{
    background-color: rgba(171, 189, 199, 0.75);
}
#controlMode {
    padding: 6px 10px;
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.3);
    background: white;
    cursor: pointer;
    font-weight: bold;
}
.header-container{
    position: relative;
    margin: 10px auto; /* center horizontally and give vertical spacing */
    width: 500px;
    height: 55px;
}
#control-selector{
    position: absolute;  /* 绝对定位 */
    left: 520px;        /* 定位在 Canvas 右侧 (500px 宽度 + 10px 间距) */
    top: 0;
    width: 180px;
    height: 70px;        /* 自动与容器（Canvas）等高 */
    background: rgb(55, 55, 55);
    color: #fff;
    border-radius: 8px;
    border: 2px solid black;
    padding: 5px 10px;
    box-sizing: border-box;
    text-align: left;
}
.canvas-wrapper {
    width: 500px;   /* 固定canvas宽度 */
    display: flex;
    justify-content: center;
}

.keyboard-mode #highest-scores {
    position: absolute;
    left: 520px;
    top: 0;
}
/* --- 修改后的布局核心 --- */

/* 1. 修正介绍区域整体容器 */
.content-wrapper {
    position: relative;   /* 关键：为 Touch 模式下的排行榜提供定位基准 */
    width: 100%;          /* 占满全屏宽度以便计算中心 */
    display: flex;
    justify-content: center; /* 无论什么模式，内容物水平居中 */
    margin-top: 20px;
    margin-bottom: 20px;
}

.content-box {
    width: 480px;         /* 保持和标题、Canvas 一致的宽度感 */
    margin: 0;            /* 交给父元素 flex 居中，不再需要 auto */
    padding: 10px;
    background: rgba(255, 255, 255, 0.75);
    border-radius: 15px;
    border: 2px solid rgba(0, 0, 0, 0.3);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    flex-shrink: 0;       /* 防止被挤压 */
}

#scores-touch-container {
    position: absolute;
    /* 定位逻辑：50%(屏幕中心) + 240px(介绍盒的一半) + 20px(间距) */
    left: calc(50% + 270px); 
    top: 0;
    width: 180px;
}

/* 确保排行榜在 Touch 模式下显示正常 */
.touch-mode #highest-scores {
    position: static !important; /* 回归正常流，受父容器 #scores-touch-container 控制 */
    width: 180px;
    min-height: 400px;
    background: rgb(55, 55, 55);
    border-radius: 8px;
    border: 2px solid black;
}
/* 隐藏 main-wrapper 里的旧位置，防止重复 */
.touch-mode .main-wrapper #highest-scores {
    display: none;
}
#restart-btn {
    display: block;       /* 强制独占一行 */
    margin: 20px auto;    /* 上下20px，左右auto实现绝对居中 */
    float: none;          /* 确保没有浮动干扰 */
}
#bottom-btn{
    max-width: 500px;
    margin: 0 auto;
}
#controlMode {
    margin-top: 5px; /* 效果是一样的，从左侧推开距离 */

}
select {
    appearance: none;
    -webkit-appearance: none;
    color: rgb(0, 0, 0) !important;
}
button {
    touch-action: manipulation;
    -webkit-appearance: none;
    appearance: none;
    color: rgb(34, 37, 43) !important;
}