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

html, body {
    height: 100%;
    background: #1a1a2e;
    color: #eaeaea;
    font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
    overflow: hidden;
    user-select: none;
}

#app {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 12px;
}

#game-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

/* ---------- HUD ---------- */
#hud {
    width: 624px;
    height: 40px;
    background: #16213e;
    border: 2px solid #3a3a5e;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 0 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.hud-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 18px;
    font-weight: bold;
}

.hud-label {
    color: #8be9fd;
    font-size: 14px;
    letter-spacing: 1px;
}

#hud-lives {
    color: #ff5555;
    letter-spacing: 2px;
}

#hud-score {
    color: #f1fa8c;
}

/* 血条：3 格 HP，每格心形/方块，受伤后变暗 */
.hp-bar {
    display: inline-flex;
    gap: 3px;
    margin-left: 6px;
}
.hp-pip {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #ff4040;
    border: 1px solid #8a1f1f;
    box-shadow: 0 0 4px rgba(255, 80, 80, 0.6);
    transition: background 0.15s, box-shadow 0.15s;
}
.hp-pip.empty {
    background: #3a2020;
    box-shadow: none;
}

/* ---------- 静音按钮 ---------- */
.btn-mute {
    width: 36px;
    height: 36px;
    margin-left: 8px;
    padding: 0;
    font-size: 18px;
    line-height: 1;
    color: #fff;
    background: #2a2a4e;
    border: 2px solid #3a3a5e;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, transform 0.1s;
}

.btn-mute:hover {
    background: #3a3a6e;
    transform: scale(1.08);
}

.btn-mute:active {
    transform: scale(0.95);
}

.mute-icon {
    pointer-events: none;
}

/* ---------- Canvas ---------- */
#canvas-holder {
    position: relative;
    width: 624px;
    height: 624px;
    border: 3px solid #3a3a5e;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 6px 20px rgba(0,0,0,0.6);
    background: #000;
}

#game {
    width: 624px;
    height: 624px;
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* ---------- Overlay ---------- */
.overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.screen {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    background: rgba(10, 12, 30, 0.85);
    text-align: center;
    pointer-events: auto;
    padding: 24px;
}

.screen.hidden {
    display: none;
}

.screen-title {
    font-size: 52px;
    font-weight: 900;
    color: #ffd700;
    text-shadow: 0 0 18px rgba(255, 215, 0, 0.6), 4px 4px 0 #b8860b;
    letter-spacing: 4px;
}

.subtitle {
    font-size: 20px;
    color: #cfcfcf;
    margin-bottom: 6px;
}

.btn {
    margin-top: 6px;
    padding: 12px 36px;
    font-size: 22px;
    font-weight: bold;
    color: #1a1a2e;
    background: linear-gradient(180deg, #ffe066, #ffaa00);
    border: 3px solid #b8860b;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s;
    box-shadow: 0 4px 0 #8b6508;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #8b6508;
}

.btn:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 #8b6508;
}

.btn-secondary {
    background: linear-gradient(180deg, #8be9fd, #3a8ee6);
    border-color: #1e6bb8;
    color: #fff;
    box-shadow: 0 4px 0 #16527f;
}
.btn-secondary:hover { box-shadow: 0 6px 0 #16527f; }
.btn-secondary:active { box-shadow: 0 1px 0 #16527f; }

/* 全局隐藏类（用于 HUD 子项、新纪录标记等非 .screen 元素） */
.hidden {
    display: none !important;
}

.help {
    margin-top: 14px;
    padding: 14px 22px;
    background: rgba(255,255,255,0.06);
    border: 1px solid #3a3a5e;
    border-radius: 8px;
    font-size: 16px;
    line-height: 1.7;
    color: #d0d0d0;
    max-width: 380px;
}

.help b {
    color: #8be9fd;
}

.help .tip {
    color: #f1fa8c;
    font-size: 14px;
}

/* ---------- 加载进度条 ---------- */
.loading-bar {
    width: 320px;
    height: 18px;
    background: #2a2a4e;
    border: 2px solid #3a3a5e;
    border-radius: 10px;
    overflow: hidden;
}

#loading-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #50fa7b, #8be9fd);
    transition: width 0.15s;
}

#loading-text {
    font-size: 16px;
    color: #bd93f9;
}

/* ---------- Buff 状态条 ---------- */
#buffs {
    width: 624px;
    min-height: 26px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    padding: 2px;
}

.buff-chip {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 10px;
    font-size: 14px;
    font-weight: bold;
    border-radius: 12px;
    border: 1px solid #3a3a5e;
    background: #16213e;
}

.buff-chip.lightning { color: #f1fa8c; border-color: #f1fa8c; }
.buff-chip.shield    { color: #8be9fd; border-color: #8be9fd; }
.buff-chip.star      { color: #ffd700; border-color: #ffd700; }

/* ============= 移动端响应式适配 ============= */
@media (max-width: 720px) {
    #hud, #canvas-holder, #buffs {
        width: 95vw !important;
        max-width: 624px;
    }
    #canvas-holder {
        height: 95vw !important;
        max-height: 624px;
        aspect-ratio: 1 / 1;
    }
    #game {
        width: 100% !important;
        height: 100% !important;
    }
    .screen-title { font-size: 38px; }
    .subtitle { font-size: 16px; }
    .btn {
        padding: 14px 28px;
        font-size: 20px;
        min-width: 180px;
        min-height: 48px;
    }
    .help { font-size: 14px; padding: 12px 14px; }
    #hud { padding: 0 8px; height: 36px; }
    .hud-item { font-size: 14px; gap: 4px; }
    .hud-label { font-size: 12px; }
    .btn-mute { width: 32px; height: 32px; font-size: 16px; margin-left: 4px; }
}

/* 横屏适配 */
@media (max-height: 520px) and (orientation: landscape) {
    #hud, #canvas-holder, #buffs {
        width: auto !important;
        max-width: none;
    }
    #canvas-holder {
        height: 86vh !important;
        width: 86vh !important;
        max-height: 624px;
        max-width: 624px;
    }
    .screen-title { font-size: 32px; }
    .btn { padding: 10px 20px; font-size: 18px; min-height: 44px; }
}

/* ============= 移动端虚拟按键 ============= */
.mobile-controls {
    position: fixed;
    left: 0; right: 0; bottom: 14px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 0 18px;
    pointer-events: none;
    z-index: 30;
}
.mobile-controls.hidden { display: none !important; }

.dpad {
    position: relative;
    width: 180px;
    height: 180px;
    pointer-events: auto;
}
.vbtn {
    position: absolute;
    border-radius: 50%;
    background: rgba(255,255,255,0.18);
    border: 2px solid rgba(255,255,255,0.45);
    color: #fff;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.08s, transform 0.08s, border-color 0.08s;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}
.vbtn-dir {
    width: 70px;       /* === 60px -> 70px 加 === */
    height: 70px;
    font-size: 24px;
}
.vbtn-up    { top: 0;   left: 50%; transform: translateX(-50%); }
.vbtn-down  { bottom: 0; left: 50%; transform: translateX(-50%); }
.vbtn-left  { left: 0;  top: 50%;  transform: translateY(-50%); }
.vbtn-right { right: 0; top: 50%;  transform: translateY(-50%); }

.vbtn-attack {
    position: relative;
    width: 90px;        /* === 80px -> 90px === */
    height: 90px;
    font-size: 28px;
    pointer-events: auto;
    background: rgba(255, 110, 110, 0.28);
    border-color: rgba(255, 140, 140, 0.6);
    box-shadow: 0 0 20px rgba(255, 120, 120, 0.25);
}

.vbtn.is-pressed {
    /* === 按下半透明高亮反馈 + 轻微缩小（新增）=== */
    background: rgba(255, 255, 255, 0.78) !important;
    border-color: #fff !important;
    color: #1a1a2e !important;
    box-shadow: 0 0 24px rgba(255, 255, 255, 0.6), inset 0 0 14px rgba(255,255,255,0.5) !important;
    transform: scale(0.9);
    -webkit-tap-highlight-color: transparent;
    outline: none;
}
.vbtn-up.is-pressed    { transform: translateX(-50%) scale(0.9); }
.vbtn-down.is-pressed  { transform: translateX(-50%) scale(0.9); }
.vbtn-left.is-pressed  { transform: translateY(-50%) scale(0.9); }
.vbtn-right.is-pressed { transform: translateY(-50%) scale(0.9); }

.vbtn.is-cooldown {
    background: rgba(120,120,120,0.35) !important;
    border-color: rgba(180,180,180,0.5) !important;
    color: rgba(255,255,255,0.6) !important;
    cursor: not-allowed;
}

/* ============================================================
   真正的纯触屏设备才强制显示虚拟按键
   条件必须同时满足：
     (hover: none)    → 设备无法悬停（就是没有鼠标）
     (pointer: coarse) → 主指针是"粗指针"（手指不是鼠标笔）
   故意删除了 any-pointer:coarse，避免二合一笔记本/带触屏的台式机误显示
   ============================================================ */
@media (hover: none) and (pointer: coarse) {
    .mobile-controls { display: flex !important; }
    .mobile-controls.hidden { display: flex !important; }
}
/* 如果用户手动加了 body[data-touch="0"]（PC 端检测结果），
   就算媒体查询命中也要强制隐藏 —— 以 JS 检测+手动覆盖为准 */
body[data-touch="0"] .mobile-controls { display: none !important; }