.tank-tool-wrapper { --p-bg: #ffffff; --p-border: #e2e8f0; --p-primary: #f59e0b; --p-text: #0f172a; width: 100%; max-width: 1000px; margin: 0 auto; background: var(--p-bg); border-radius: 24px; padding: 32px; border: 1px solid var(--p-border); box-shadow: 0 10px 25px -5px rgba(0,0,0,0.05); transition: 0.3s; display: flex; flex-direction: column; align-items: center; }
.tank-header-main { font-size: 1.5rem; font-weight: 600; color: var(--p-text); margin-bottom: 8px; display: flex; align-items: center; justify-content: center; gap: 12px; width: 100%; }
.tank-badge { background: #fef3c7; color: #b45309; padding: 4px 12px; border-radius: 30px; font-size: 0.8rem; font-weight: 500; }
.tank-subtitle { color: #64748b; font-size: 0.95rem; padding-bottom: 16px; border-bottom: 1px solid var(--p-border); margin-bottom: 24px; text-align: center; width: 100%; }

/* 游戏运行环境隔离沙盒 */
.tank-game-env {
    position: relative;
    width: 100%;
    min-height: 600px;
    background: #000;
    font-family: 'Courier New', monospace;
    color: #fff;
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    outline: none;
    user-select: none;
    -webkit-touch-callout: none;
    touch-action: none;
    box-shadow: inset 0 0 20px rgba(0,0,0,1);
}

#gameWrapper {
    display: flex;
    align-items: center;
    gap: 20px;
    z-index: 1;
}

#gameContainer {
    position: relative;
    border: 3px solid #666;
    background: #000;
    line-height: 0;
}

#gameContainer canvas {
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    max-width: 100%;
    height: auto;
}

#sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 130px;
}

.info-panel {
    background: #1a1a1a;
    border: 2px solid #444;
    padding: 12px;
}

.info-panel h3 {
    color: #ff0;
    font-size: 14px;
    margin-bottom: 10px;
    text-align: center;
    letter-spacing: 2px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    margin: 6px 0;
}

.info-row .label { color: #aaa; }
.info-row .value { color: #0f0; font-weight: bold; }

#enemyIcons {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 8px;
}

.enemy-icon {
    width: 14px; height: 14px;
    background: #e44;
}

/* 遮罩层 UI */
.overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.85);
    z-index: 10;
}

.overlay.hidden { display: none; }

.overlay h1 {
    font-size: 32px;
    color: #ff0;
    margin-bottom: 16px;
    text-shadow: 2px 2px #a00;
    letter-spacing: 4px;
    line-height: 1.2;
}

.overlay h2 {
    font-size: 24px;
    color: #f44;
    margin-bottom: 12px;
}

.overlay p {
    font-size: 14px;
    color: #ccc;
    margin: 6px 0;
    text-align: center;
}

.overlay .highlight { color: #0f0; font-weight: bold; font-size: 16px; }

.btn {
    margin-top: 24px;
    padding: 12px 32px;
    font-family: 'Courier New', monospace;
    font-size: 16px;
    font-weight: bold;
    color: #000;
    background: #ff0;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    letter-spacing: 2px;
    transition: 0.2s;
}

.btn:hover { background: #fc0; transform: scale(1.05); }
.btn:active { background: #fa0; transform: scale(0.95); }

/* 移动端控件 (改为绝对定位，防止穿透页面覆盖底部) */
#mobileControls {
    display: none;
    position: absolute;
    bottom: 0; left: 0; right: 0;
    padding: 16px 24px;
    z-index: 100;
    background: linear-gradient(to top, rgba(0,0,0,0.9), transparent);
    justify-content: space-between;
    align-items: flex-end;
}

#mobileControls.active { display: flex; }

.dpad {
    position: relative;
    width: 140px; height: 140px;
}

.dpad-btn {
    position: absolute;
    width: 46px; height: 46px;
    background: rgba(255,255,255,0.15);
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,0.8);
    font-size: 20px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.dpad-btn:active, .dpad-btn.pressed {
    background: rgba(255,255,0,0.4);
    border-color: #ff0;
}

.dpad-up { top: 0; left: 47px; }
.dpad-down { bottom: 0; left: 47px; }
.dpad-left { top: 47px; left: 0; }
.dpad-right { top: 47px; right: 0; }

.fire-btn {
    width: 72px; height: 72px;
    border-radius: 50%;
    background: rgba(255,50,50,0.3);
    border: 3px solid rgba(255,50,50,0.6);
    color: #fbb;
    font-size: 15px;
    font-weight: bold;
    font-family: 'Courier New', monospace;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.fire-btn:active, .fire-btn.pressed {
    background: rgba(255,50,50,0.6);
    border-color: #f00;
    color: #fff;
}

#pauseBtn {
    position: absolute;
    top: 8px; right: 8px;
    width: 36px; height: 36px;
    background: rgba(255,255,255,0.1);
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 6px;
    color: #fff;
    font-size: 16px;
    font-family: 'Courier New', monospace;
    cursor: pointer;
    z-index: 20;
    display: none;
    -webkit-tap-highlight-color: transparent;
}
#pauseBtn.active { display: block; }

/* 响应式适配 */
@media screen and (max-width: 800px) {
    .tank-game-env { padding: 10px; min-height: 75vh; }
    #gameWrapper { flex-direction: column; gap: 12px; width: 100%; }
    #gameContainer { width: 100%; max-width: 520px; border-width: 2px; }
    #gameContainer canvas { width: 100% !important; height: auto !important; }
    
    #sidebar { flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 8px; width: 100%; }
    .info-panel { padding: 8px 12px; min-width: 100px; flex: 1; }
    .info-panel h3 { font-size: 12px; margin-bottom: 6px; }
    .info-row { font-size: 12px; }
}

.mobile-hint { display: none; line-height: 2.2; }
@media (pointer: coarse) {
    .mobile-hint { display: block; margin: 6px 0; }
    .desktop-hint { display: none; }
}

/* 全局黑夜模式对接 */
[data-theme="dark"] .tank-tool-wrapper { background: #1e293b !important; border-color: #334155 !important; }
[data-theme="dark"] .tank-subtitle { border-bottom-color: #334155; }