*, *::before, *::after { box-sizing: border-box; }
html, body {
    height: 100%; margin: 0; padding: 0; overflow: hidden;
    background: #05080f; color: #dbe6f2;
    font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
    user-select: none; -webkit-user-select: none;
}
#apps { display: flex; flex-direction: column; height: 100%; width: 100%; }

/* ============================================================
 * 顶部 HUD（单行紧凑展示所有实时指标）
 * ========================================================== */
#hud {
    flex: 0 0 auto; display: flex; align-items: center; gap: 10px;
    height: 52px; padding: 0 12px;
    background: linear-gradient(180deg, #131a26 0%, #0b111b 100%);
    border-bottom: 1px solid rgba(96, 165, 250, .16);
    box-shadow: 0 2px 14px rgba(0, 0, 0, .5); z-index: 30;
}
.hud-brand {
    display: flex; align-items: center; gap: 7px;
    font-weight: 700; font-size: 14px; letter-spacing: .5px;
    color: #7dd3fc; white-space: nowrap;
    text-shadow: 0 0 14px rgba(56, 189, 248, .45);
}
.hud-brand .glyphicon { font-size: 16px; }
.hud-metrics { display: flex; align-items: center; gap: 6px; flex: 1 1 auto; overflow: hidden; }
.metric {
    display: flex; align-items: center; gap: 4px;
    padding: 3px 9px; border-radius: 7px;
    background: rgba(255, 255, 255, .04);
    border: 1px solid rgba(255, 255, 255, .07);
    font-size: 12px; line-height: 1; white-space: nowrap;
    transition: background .18s, border-color .18s, transform .18s;
}
.metric .glyphicon { font-size: 12px; color: #60a5fa; }
.metric b { font-size: 13px; color: #f8fafc; font-weight: 700; font-variant-numeric: tabular-nums; }
.metric em { font-style: normal; font-size: 10px; color: #7f8fa6; letter-spacing: .4px; }
.metric.hot { background: rgba(251, 146, 60, .16); border-color: rgba(251, 146, 60, .5); transform: scale(1.06); }
.metric.hot .glyphicon, .metric.hot b { color: #fdba74; }
.metric.danger { background: rgba(239, 68, 68, .18); border-color: rgba(239, 68, 68, .55); }
.metric.danger .glyphicon, .metric.danger b { color: #fca5a5; }
.hud-actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.hud-actions .btn {
    background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .12);
    color: #cbd5e1; border-radius: 7px; padding: 5px 10px; font-size: 12px;
    transition: all .16s;
}
.hud-actions .btn:hover, .hud-actions .btn:focus {
    background: rgba(56, 189, 248, .18); border-color: rgba(56, 189, 248, .55);
    color: #e0f2fe; outline: none;
}
.hud-actions .btn .glyphicon { margin-right: 3px; }
.hud-actions .btn.icon-only .glyphicon { margin-right: 0; }

/* ============================================================
 * 3D 舞台
 * ========================================================== */
#stage { position: relative; flex: 1 1 auto; overflow: hidden; background: #05080f; min-height: 200px; }
#gl { display: block; width: 100%; height: 100%; cursor: crosshair; }

/* 准星 */
#crosshair {
    position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
    width: 30px; height: 30px; pointer-events: none; z-index: 10;
}
#crosshair::before, #crosshair::after {
    content: ''; position: absolute; background: rgba(220, 245, 255, .92);
}
#crosshair::before {
    left: 50%; top: 0; width: 2px; height: 9px; transform: translateX(-50%);
    box-shadow: 0 0 6px rgba(56, 189, 248, .9);
}
#crosshair::after {
    left: 0; top: 50%; height: 2px; width: 9px; transform: translateY(-50%);
    box-shadow: 0 0 6px rgba(56, 189, 248, .9);
}
#crosshair .dot {
    position: absolute; left: 50%; top: 50%;
    width: 3px; height: 3px; border-radius: 50%;
    background: rgba(220, 245, 255, .92);
    transform: translate(-50%, -50%);
}
#crosshair.hit { animation: crosshairHit .15s ease; }
@keyframes crosshairHit {
    0% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(1.4); filter: brightness(2); }
    100% { transform: translate(-50%, -50%) scale(1); }
}
#crosshair.miss::before, #crosshair.miss::after, #crosshair.miss .dot {
    background: rgba(248, 113, 113, .95);
    box-shadow: 0 0 8px rgba(248, 113, 113, .9);
}

#edge-indicators { position: absolute; inset: 0; pointer-events: none; z-index: 9; }
.edge-ind {
    position: absolute; width: 10px; height: 10px;
    border-radius: 50%; background: rgba(250, 204, 21, .85);
    box-shadow: 0 0 10px rgba(250, 204, 21, .9);
    transform: translate(-50%, -50%);
}

/* 道具栏 */
#item-bar {
    position: absolute; left: 50%; bottom: 52px; transform: translateX(-50%);
    display: flex; gap: 8px; z-index: 12; flex-wrap: wrap; justify-content: center;
    max-width: 92%;
}
.item-slot {
    display: flex; align-items: center; gap: 5px;
    padding: 5px 10px; border-radius: 8px;
    background: rgba(8,15,26,.78); border: 1px solid rgba(56,189,248,.25);
    font-size: 12px; color: #bae6fd;
    transition: all .18s; cursor: pointer;
}
.item-slot:hover { background: rgba(56,189,248,.2); border-color: rgba(56,189,248,.6); }
.item-slot .glyphicon { font-size: 14px; color: #38bdf8; }
.item-slot kbd {
    background: #1e293b; border: 1px solid #334155; border-radius: 4px;
    padding: 1px 5px; font-size: 10px; color: #93c5fd;
}
.item-slot.empty { opacity: .35; cursor: default; }
.item-slot b { color: #fde047; font-size: 12px; }

/* 提示语都放在屏幕上方，不遮挡中间的目标文字 */
.stage-tip {
    position: absolute; left: 50%; top: 140px; transform: translateX(-50%);
    padding: 8px 20px; border-radius: 999px;
    background: rgba(8, 15, 26, .82); border: 1px solid rgba(56, 189, 248, .35);
    font-size: 13px; color: #bae6fd; letter-spacing: .6px;
    backdrop-filter: blur(6px); pointer-events: none;
    opacity: 0; transition: opacity .3s; white-space: nowrap; z-index: 13;
}
.stage-tip.show { opacity: 1; }

#weapon-hint {
    position: absolute; right: 16px; bottom: 16px;
    padding: 6px 12px; border-radius: 8px;
    background: rgba(8, 15, 26, .75); border: 1px solid rgba(56, 189, 248, .3);
    font-size: 12px; color: #bae6fd; pointer-events: none;
    letter-spacing: .5px; z-index: 12;
}
#weapon-hint .glyphicon { color: #38bdf8; margin-right: 4px; }
#cam-hint {
    position: absolute; left: 16px; bottom: 16px;
    padding: 6px 12px; border-radius: 8px;
    background: rgba(8, 15, 26, .75); border: 1px solid rgba(56, 189, 248, .3);
    font-size: 12px; color: #bae6fd; pointer-events: none;
    letter-spacing: .5px; z-index: 12;
}

/* Toast */
#toast-wrap {
    position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
    z-index: 2000; pointer-events: none; display: flex; flex-direction: column;
    align-items: center; gap: 10px;
}
.kb-toast {
    padding: 12px 26px; border-radius: 12px; font-size: 15px; font-weight: 600;
    color: #f0f9ff; background: rgba(14, 24, 40, .94);
    border: 1px solid rgba(56, 189, 248, .5);
    box-shadow: 0 10px 40px rgba(0, 0, 0, .7), 0 0 26px rgba(56, 189, 248, .22);
    animation: toastIn .3s cubic-bezier(.2, 1.4, .4, 1) both;
    letter-spacing: .5px; white-space: nowrap;
}
.kb-toast.ok    { border-color: rgba(74, 222, 128, .6);  box-shadow: 0 10px 40px rgba(0,0,0,.7), 0 0 26px rgba(74,222,128,.3); }
.kb-toast.bad   { border-color: rgba(248, 113, 113, .6); box-shadow: 0 10px 40px rgba(0,0,0,.7), 0 0 26px rgba(248,113,113,.3); }
.kb-toast.gold  { border-color: rgba(250, 204, 21, .7);  box-shadow: 0 10px 40px rgba(0,0,0,.7), 0 0 30px rgba(250,204,21,.38); }
.kb-toast.fade-out { animation: toastOut .4s ease forwards; }
@keyframes toastIn  { from { opacity: 0; transform: translateY(16px) scale(.86); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-20px) scale(.94); } }

/* 受击红闪（不抖动镜头） */
#flash {
    position: absolute; inset: 0; pointer-events: none; opacity: 0;
    background: radial-gradient(circle at 50% 60%, rgba(239, 68, 68, 0) 45%, rgba(239, 68, 68, .55) 100%);
    transition: opacity .16s; z-index: 14;
}
#flash.on { opacity: 1; transition: none; }

/* 里程碑金色闪光（每 5 次击杀触发） */
#milestone-flash {
    position: fixed; inset: 0; pointer-events: none; z-index: 1450; opacity: 0;
    background: radial-gradient(circle at 50% 50%, rgba(250, 204, 21, 0) 35%, rgba(250, 204, 21, .35) 100%);
}
#milestone-flash.on { animation: milestonePulse .9s ease-out; }
@keyframes milestonePulse {
    0% { opacity: 0; } 25% { opacity: 1; } 100% { opacity: 0; }
}

#combo-fx {
    position: absolute; left: 50%; top: 30%; transform: translate(-50%, -50%);
    font-size: 46px; font-weight: 900; letter-spacing: 3px; pointer-events: none;
    color: #fde047; text-shadow: 0 0 22px rgba(250, 204, 21, .85), 0 4px 14px rgba(0,0,0,.6);
    opacity: 0; z-index: 15;
}
#combo-fx.pop { animation: comboPop .75s cubic-bezier(.2, 1.5, .4, 1) both; }
@keyframes comboPop {
    0%   { opacity: 0; transform: translate(-50%, -50%) scale(.4); }
    30%  { opacity: 1; transform: translate(-50%, -50%) scale(1.18); }
    70%  { opacity: 1; transform: translate(-50%, -60%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -90%) scale(.9); }
}

#guide-bubble {
    position: absolute; left: 50%; top: 76px; transform: translateX(-50%);
    padding: 12px 22px; border-radius: 12px;
    background: linear-gradient(180deg, rgba(56,189,248,.28), rgba(14,24,40,.94));
    border: 1px solid rgba(56, 189, 248, .7);
    box-shadow: 0 12px 40px rgba(0,0,0,.6), 0 0 26px rgba(56, 189, 248, .4);
    color: #e0f2fe; font-size: 14px; font-weight: 600; letter-spacing: .6px;
    pointer-events: none; z-index: 20; opacity: 0; transition: opacity .3s;
    white-space: nowrap;
}
#guide-bubble.show { opacity: 1; }
#guide-bubble .glyphicon { color: #fde047; margin-right: 6px; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.15); } }

/* ============================================================
 * 弹层
 * ========================================================== */
.kb-modal {
    position: fixed; inset: 0; z-index: 1500;
    display: none; align-items: center; justify-content: center;
    padding: 16px; overflow-y: auto;
    background: rgba(3, 7, 14, .82); backdrop-filter: blur(5px);
}
.kb-modal.is-open { display: flex; animation: modalFade .22s ease both; }
@keyframes modalFade { from { opacity: 0; } to { opacity: 1; } }
.kb-modal-box {
    position: relative; width: 100%; max-width: 560px; margin: auto;
    background: linear-gradient(180deg, #141d2c 0%, #0b1119 100%);
    border: 1px solid rgba(96, 165, 250, .22);
    border-radius: 16px; padding: 26px 26px 22px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, .8), inset 0 1px 0 rgba(255, 255, 255, .06);
    animation: modalPop .32s cubic-bezier(.2, 1.3, .4, 1) both;
}
@keyframes modalPop { from { opacity: 0; transform: scale(.9) translateY(18px); } to { opacity: 1; transform: none; } }
.kb-modal-box h2 {
    margin: 0 0 6px; font-size: 22px; font-weight: 800; text-align: center;
    color: #e2f2ff; letter-spacing: 1px; text-shadow: 0 0 22px rgba(56, 189, 248, .4);
}
.kb-modal-box h2 .glyphicon { color: #38bdf8; margin-right: 6px; }
.kb-modal-box .sub {
    text-align: center; font-size: 13px; color: #7f96b3; margin-bottom: 18px; line-height: 1.6;
}
.kb-modal-box .sub kbd, .rule-list kbd {
    display: inline-block; background: #1e293b; border: 1px solid #334155;
    border-radius: 4px; padding: 1px 6px; font-size: 11px; color: #93c5fd;
    font-family: inherit; line-height: 1.5;
}
.opt-group { margin-bottom: 14px; }
.opt-group > label.opt-title {
    display: block; font-size: 12px; color: #7f96b3; letter-spacing: 1px;
    margin-bottom: 7px; font-weight: 600;
}
.opt-row { display: flex; gap: 8px; flex-wrap: wrap; }
.opt-btn {
    flex: 1 1 0; min-width: 84px; padding: 9px 8px; text-align: center;
    border-radius: 9px; cursor: pointer; font-size: 13px;
    background: rgba(255, 255, 255, .04); border: 1px solid rgba(255, 255, 255, .1);
    color: #a9bbd0; transition: all .16s; user-select: none;
}
.opt-btn:hover { background: rgba(56, 189, 248, .1); border-color: rgba(56, 189, 248, .4); color: #d7ecff; }
.opt-btn.active {
    background: linear-gradient(180deg, rgba(56, 189, 248, .28), rgba(37, 99, 235, .22));
    border-color: rgba(56, 189, 248, .8); color: #e8f6ff;
    box-shadow: 0 0 18px rgba(56, 189, 248, .32), inset 0 1px 0 rgba(255, 255, 255, .16);
}
.opt-btn small { display: block; font-size: 10px; opacity: .68; margin-top: 2px; }
.kb-btn-row { display: flex; gap: 10px; margin-top: 20px; }
.kb-btn-row .btn {
    flex: 1 1 0; padding: 11px 12px; border-radius: 10px; font-size: 14px; font-weight: 700;
    letter-spacing: .6px; border: 1px solid rgba(255, 255, 255, .14);
    background: rgba(255, 255, 255, .06); color: #cbd5e1; transition: all .16s;
    text-decoration: none; text-align: center;
}
.kb-btn-row .btn:hover { background: rgba(255, 255, 255, .13); color: #fff; text-decoration: none; }
.kb-btn-row .btn-primary {
    background: linear-gradient(180deg, #38bdf8, #1d6fd6); border-color: #38bdf8; color: #04121f;
    box-shadow: 0 6px 22px rgba(56, 189, 248, .4);
}
.kb-btn-row .btn-primary:hover { background: linear-gradient(180deg, #7dd3fc, #2b82e8); color: #04121f; }
.kb-btn-row .btn-warn {
    background: linear-gradient(180deg, #fb923c, #d97706); border-color: #fb923c; color: #1a0c00;
    box-shadow: 0 6px 22px rgba(251, 146, 60, .35);
}
.kb-btn-row .btn-warn:hover { background: linear-gradient(180deg, #fdba74, #ea8a1a); color: #1a0c00; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 18px 0 4px; }
.stat-cell {
    background: rgba(255, 255, 255, .045); border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 11px; padding: 12px 6px; text-align: center;
}
.stat-cell .glyphicon { font-size: 17px; color: #38bdf8; display: block; margin-bottom: 5px; }
.stat-cell b { display: block; font-size: 20px; font-weight: 800; color: #f1f5f9; font-variant-numeric: tabular-nums; }
.stat-cell small { display: block; font-size: 11px; color: #7f96b3; margin-top: 2px; letter-spacing: .5px; }
.result-title.win  { color: #86efac; text-shadow: 0 0 30px rgba(74, 222, 128, .6); animation: titleWin .9s ease both; }
.result-title.lose { color: #fca5a5; text-shadow: 0 0 30px rgba(239, 68, 68, .6); animation: titleShake .7s ease both; }
@keyframes titleWin {
    0%   { transform: scale(.5); opacity: 0; }
    55%  { transform: scale(1.16); opacity: 1; }
    100% { transform: scale(1); }
}
@keyframes titleShake {
    0%, 100% { transform: translateX(0); }
    15% { transform: translateX(-12px) rotate(-1.5deg); }
    35% { transform: translateX(11px) rotate(1.5deg); }
    55% { transform: translateX(-8px); }
    75% { transform: translateX(6px); }
}
.upg-list { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.upg-card {
    display: flex; align-items: center; gap: 13px; padding: 13px 15px;
    border-radius: 11px; cursor: pointer; text-align: left;
    background: rgba(255, 255, 255, .045); border: 1px solid rgba(255, 255, 255, .1);
    transition: all .16s;
}
.upg-card:hover {
    background: rgba(56, 189, 248, .13); border-color: rgba(56, 189, 248, .6);
    transform: translateX(4px);
}
.upg-card .glyphicon { font-size: 24px; color: #38bdf8; flex: 0 0 auto; }
.upg-card strong { display: block; font-size: 14px; color: #e2f2ff; margin-bottom: 3px; }
.upg-card span { font-size: 12px; color: #8ba1bd; }
.upg-card kbd {
    margin-left: auto; background: #1e293b; border: 1px solid #334155;
    border-radius: 5px; padding: 3px 8px; font-size: 12px; color: #93c5fd;
}
.rule-list { list-style: none; padding: 0; margin: 0; }
.rule-list li {
    display: flex; gap: 10px; padding: 8px 0; font-size: 13px; color: #a9bbd0;
    border-bottom: 1px dashed rgba(255, 255, 255, .07); line-height: 1.6;
}
.rule-list li:last-child { border-bottom: none; }
.rule-list .glyphicon { color: #38bdf8; margin-top: 2px; flex: 0 0 auto; }

#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 1900; display: none; }
#confetti.on { display: block; }
#vignette-fail {
    position: fixed; inset: 0; pointer-events: none; z-index: 1490; opacity: 0;
    background: radial-gradient(circle at 50% 50%, rgba(120, 0, 0, 0) 40%, rgba(150, 10, 10, .65) 100%);
}
#vignette-fail.on { animation: failPulse 1.5s ease-out; }
@keyframes failPulse {
    0% { opacity: 0; } 22% { opacity: 1; } 100% { opacity: 0; }
}
#boot-error {
    position: fixed; inset: 0; display: none;
    align-items: center; justify-content: center;
    background: #05080f; color: #fca5a5;
    font-size: 16px; text-align: center; padding: 20px; z-index: 3000;
}
#boot-error.show { display: flex; }

@media (max-width: 1180px) {
    .metric em { display: none; }
    .hud-brand span { display: none; }
}
@media (max-width: 860px) {
    .hud-metrics { gap: 4px; }
    .metric { padding: 3px 6px; }
    .metric b { font-size: 12px; }
    .hud-actions .btn span { display: none; }
    .hud-actions .btn .glyphicon { margin-right: 0; }
    #hud { height: 46px; padding: 0 8px; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .kb-modal-box { padding: 20px 16px 16px; }
    #weapon-hint, #cam-hint { font-size: 11px; padding: 4px 8px; }
    #item-bar { bottom: 46px; gap: 5px; }
    .item-slot { padding: 4px 7px; font-size: 11px; }
    #guide-bubble { top: 60px; font-size: 12px; padding: 8px 14px; }
    .stage-tip { top: 110px; font-size: 11px; }
}
@media (max-width: 560px) {
    .metric:nth-child(n+5) { display: none; }
}