/* ============================================================
   TankMeHtml - style.css
   ============================================================ */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    background: #1a1a24;
    color: #ddd;
    font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
    min-height: 100vh;
    display: flex;
    justify-content: center;
}

#wrap {
    width: 100%;
    max-width: 980px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

header {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: space-between;
    align-items: center;
    padding: 6px 4px 14px;
}

.controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.speed-ctl {
    font-size: 13px;
    color: #aab;
    display: flex;
    align-items: center;
    gap: 6px;
}

.speed-ctl select {
    font-size: 14px;
    padding: 5px 10px;
    border-radius: 6px;
    background: #23232f;
    color: #e8b339;
    border: 1px solid #4a4a5c;
    -webkit-appearance: none;
    appearance: none;
}

header h1 { font-size: 22px; letter-spacing: 4px; }
header h1 .en { font-size: 14px; color: #888; letter-spacing: 1px; }

#main {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

/* ---------- 舞台 ---------- */
#stage {
    position: relative;
    border: 4px solid #555;
    box-shadow: 0 0 24px rgba(0, 0, 0, .6);
    line-height: 0;
}

canvas#game {
    width: min(624px, 92vw);   /* 桌面放大上限 624，手机自动缩到屏宽内 */
    height: auto;
    max-width: 100%;
    aspect-ratio: 1 / 1;       /* 保证始终正方形，不受加载时机影响 */
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    background: #000;
    outline: none;
    touch-action: none;        /* 触屏操作时禁止页面滚动/缩放 */
}

/* ---------- 遮罩层 ---------- */
#overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .78);
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1.5;
}

#overlay.hidden { display: none; }

#overlay-panel { text-align: center; padding: 20px; }

.game-title {
    font-size: 52px;
    color: #e8b339;
    letter-spacing: 12px;
    text-shadow: 3px 3px 0 #7a3b00;
    margin-bottom: 6px;
}

.game-title.small { font-size: 40px; }

.gameover-img { width: 300px; image-rendering: pixelated; margin-bottom: 10px; }

.subtitle { color: #9ab; margin-bottom: 18px; font-size: 15px; }

.help {
    display: inline-block;
    text-align: left;
    color: #aab;
    font-size: 14px;
    margin-bottom: 20px;
}
.help b { color: #e8b339; }

.btn {
    display: inline-block;
    padding: 10px 26px;
    font-size: 16px;
    color: #111;
    background: #e8b339;
    border: none;
    border-bottom: 4px solid #a97b12;
    cursor: pointer;
    letter-spacing: 2px;
}
.btn:hover { background: #f5c654; }
.btn:active { transform: translateY(2px); border-bottom-width: 2px; }
.btn.small { padding: 6px 14px; font-size: 13px; border-bottom-width: 3px; }

/* ---------- HUD ---------- */
#hud {
    width: 200px;
    background: #23232f;
    border: 2px solid #3c3c4c;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.hud-block {
    background: #181820;
    border: 1px solid #33333f;
    padding: 10px;
    text-align: center;
}

.hud-label { font-size: 12px; color: #889; margin-bottom: 4px; }
.hud-value { font-size: 24px; color: #e8b339; font-weight: bold; }

.hud-help { font-size: 12px; color: #667; line-height: 1.9; margin-top: 4px; }

/* ---------- 触屏虚拟按键 ---------- */
#touchpad {
    display: none;
    margin-top: 18px;
    width: 100%;
    justify-content: space-between;
    align-items: center;
    padding: 0 10px;
}

@media (pointer: coarse) {
    #touchpad { display: flex; }
}

.dpad {
    display: grid;
    grid-template-areas: ". u ." "l . r" ". d .";
    gap: 6px;
}

.pad, .fire {
    width: 58px;
    height: 58px;
    font-size: 20px;
    color: #ddd;
    background: #2c2c3a;
    border: 1px solid #4a4a5c;
    border-radius: 10px;
    touch-action: none;
    user-select: none;
}

#btn-up { grid-area: u; }
#btn-down { grid-area: d; }
#btn-left { grid-area: l; }
#btn-right { grid-area: r; }

.fire {
    width: 84px;
    height: 84px;
    border-radius: 50%;
    background: #7a2a2a;
    border-color: #a33;
    font-size: 16px;
}

.pad.active, .fire.active { background: #4a4a6a; }

footer {
    margin-top: 18px;
    font-size: 12px;
    color: #556;
}

/* ---------- 小屏适配 ---------- */
@media (max-width: 900px) {
    #wrap { padding: 10px 8px; }
    canvas#game { width: 92vw; }
    #main { flex-direction: column; align-items: center; }
    #hud { width: 92vw; max-width: 100%; flex-direction: row; flex-wrap: wrap; }
    .hud-block { flex: 1; min-width: 88px; }
    .hud-help { display: none; }
    .game-title { font-size: 30px; letter-spacing: 4px; }
    .game-title.small { font-size: 26px; }
    .gameover-img { width: 70vw; max-width: 300px; }
    .subtitle { font-size: 13px; margin-bottom: 14px; }
    .btn { padding: 8px 20px; font-size: 15px; }
}
