/* ==========================================================
   暗巷突围 · 2D 俯视角枪战
   ========================================================== */

:root {
    --bg: #070a0e;
    --panel: rgba(13, 18, 25, .93);
    --line: #1b2531;
    --ink: #e6eef7;
    --ink-soft: #8a99ab;
    --cyan: #22d3ee;
    --cyan-dark: #0e9fb5;
    --red: #ef4444;
    --amber: #f59e0b;
    --green: #22c55e;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
    background: var(--bg);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
    user-select: none;
}

.stage {
    position: relative;
    width: 100%;
    height: 100vh;
    overflow: hidden;
    background: radial-gradient(circle at 50% 40%, #0d141c 0%, #05080b 70%);
}

#game {
    display: block;
    width: 100%;
    height: 100%;
    cursor: crosshair;
}

/* ---------------- 顶部 HUD ---------------- */
.hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 20px;
    pointer-events: none;
    z-index: 10;
}

.hud-left,
.hud-right {
    display: flex;
    align-items: center;
    gap: 12px;
    pointer-events: auto;
}

.hud-right {
    justify-content: flex-end;
}

.hp-bar {
    position: relative;
    width: 190px;
    height: 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .07);
    border: 1px solid rgba(255, 255, 255, .1);
    overflow: hidden;
}

.hp-bar i {
    display: block;
    height: 100%;
    width: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #22c55e, #4ade80);
    transition: width .18s linear, background-color .3s ease;
}

.hp-bar.is-warn i {
    background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.hp-bar.is-danger i {
    background: linear-gradient(90deg, #dc2626, #ef4444);
}

.hp-bar span {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .5px;
    color: #eaf6ff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, .7);
    font-variant-numeric: tabular-nums;
}

.buff {
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(34, 211, 238, .16);
    border: 1px solid rgba(34, 211, 238, .45);
    color: var(--cyan);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .5px;
    animation: buffPulse 1s ease-in-out infinite;
}

@keyframes buffPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .5; }
}

.hud-mid {
    display: flex;
    align-items: baseline;
    gap: 6px;
    padding: 8px 18px;
    border-radius: 999px;
    background: rgba(10, 15, 21, .7);
    border: 1px solid rgba(255, 255, 255, .08);
    backdrop-filter: blur(8px);
}

.wave-label {
    font-size: 12px;
    color: var(--ink-soft);
}

.hud-mid b {
    font-size: 20px;
    font-weight: 800;
    color: var(--cyan);
    font-variant-numeric: tabular-nums;
}

.stat-mini {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 54px;
    line-height: 1.1;
}

.stat-mini span {
    font-size: 10.5px;
    color: var(--ink-soft);
    letter-spacing: .5px;
}

.stat-mini b {
    font-size: 17px;
    font-weight: 800;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}

.btn-exit {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: rgba(255, 255, 255, .06);
    border: 1px solid rgba(255, 255, 255, .12);
    color: var(--ink);
    font-size: 15px;
    text-decoration: none;
    transition: background-color .18s ease, border-color .18s ease, transform .18s ease;
}

.btn-exit:hover {
    background: rgba(34, 211, 238, .16);
    border-color: rgba(34, 211, 238, .5);
    color: var(--cyan);
    transform: translateX(-2px);
}

/* ---------------- 波次提示 ---------------- */
.wave-flash {
    position: absolute;
    left: 50%;
    top: 42%;
    transform: translate(-50%, -50%) scale(.9);
    font-size: 44px;
    font-weight: 900;
    letter-spacing: 6px;
    color: #fff;
    text-shadow: 0 0 24px rgba(34, 211, 238, .8), 0 4px 18px rgba(0, 0, 0, .8);
    opacity: 0;
    pointer-events: none;
    z-index: 12;
    white-space: nowrap;
}

.wave-flash.is-show {
    animation: waveIn 1.5s cubic-bezier(.2, .9, .3, 1) forwards;
}

@keyframes waveIn {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(.7); }
    18% { opacity: 1; transform: translate(-50%, -50%) scale(1.06); }
    30% { transform: translate(-50%, -50%) scale(1); }
    75% { opacity: 1; }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(1.04); }
}

/* ---------------- 遮罩面板 ---------------- */
.overlay {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(4, 7, 10, .82);
    backdrop-filter: blur(8px);
    opacity: 0;
    visibility: hidden;
    transition: opacity .25s ease, visibility .25s ease;
    z-index: 30;
}

.overlay.is-visible {
    opacity: 1;
    visibility: visible;
}

.panel {
    width: min(440px, 100%);
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    padding: 26px 28px 24px;
    border-radius: 20px;
    background: linear-gradient(180deg, rgba(18, 24, 33, .98), rgba(11, 15, 21, .98));
    border: 1px solid var(--line);
    box-shadow: 0 26px 70px rgba(0, 0, 0, .6), inset 0 1px 0 rgba(255, 255, 255, .05);
    text-align: center;
    transform: translateY(14px) scale(.97);
    transition: transform .3s cubic-bezier(.22, 1.2, .4, 1);
}

.overlay.is-visible .panel {
    transform: none;
}

.panel-tag {
    display: inline-block;
    margin-bottom: 12px;
    padding: 3px 10px;
    border-radius: 999px;
    background: rgba(34, 211, 238, .12);
    border: 1px solid rgba(34, 211, 238, .3);
    color: var(--cyan);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.4px;
}

.panel h1 {
    margin: 0 0 8px;
    font-size: 30px;
    font-weight: 900;
    letter-spacing: 3px;
    background: linear-gradient(180deg, #ffffff, #9fb2c6);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.lead {
    margin: 0 0 18px;
    font-size: 13px;
    line-height: 1.8;
    color: var(--ink-soft);
}

.keys {
    display: grid;
    gap: 8px;
    margin-bottom: 16px;
    padding: 14px 16px;
    border-radius: 12px;
    background: rgba(255, 255, 255, .03);
    border: 1px solid var(--line);
}

.key-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--ink-soft);
}

.key-row span {
    margin-left: 6px;
}

kbd {
    display: inline-grid;
    place-items: center;
    min-width: 26px;
    height: 24px;
    padding: 0 7px;
    border-radius: 6px;
    background: rgba(255, 255, 255, .08);
    border: 1px solid rgba(255, 255, 255, .16);
    border-bottom-width: 2px;
    color: var(--ink);
    font-family: inherit;
    font-size: 11px;
    font-weight: 700;
}

kbd.wide {
    min-width: 78px;
}

.tips {
    margin: 0 0 20px;
    padding: 12px 16px 12px 30px;
    text-align: left;
    border-radius: 12px;
    background: rgba(239, 68, 68, .07);
    border: 1px solid rgba(239, 68, 68, .2);
    font-size: 12px;
    line-height: 1.95;
    color: var(--ink-soft);
}

.tips b {
    color: #fca5a5;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 46px;
    margin-top: 8px;
    border: none;
    border-radius: 12px;
    font-family: inherit;
    font-size: 14.5px;
    font-weight: 800;
    letter-spacing: 1.5px;
    text-decoration: none;
    cursor: pointer;
    transition: transform .16s ease, box-shadow .2s ease, background-color .2s ease, border-color .2s ease;
}

.btn-primary {
    color: #04141a;
    background: linear-gradient(180deg, #4ee5f5, #22d3ee);
    box-shadow: 0 10px 26px rgba(34, 211, 238, .32);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 32px rgba(34, 211, 238, .44);
}

.btn-primary:active {
    transform: translateY(0) scale(.98);
}

.btn-ghost {
    color: var(--ink-soft);
    background: transparent;
    border: 1px solid var(--line);
}

.btn-ghost:hover {
    background: rgba(255, 255, 255, .05);
    border-color: rgba(255, 255, 255, .2);
    color: var(--ink);
}

.best {
    margin: 14px 0 0;
    font-size: 11.5px;
    color: var(--ink-soft);
}

.best b {
    color: var(--cyan);
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin: 4px 0 18px;
}

.result-grid > div {
    padding: 12px 8px;
    border-radius: 12px;
    background: rgba(255, 255, 255, .04);
    border: 1px solid var(--line);
}

.result-grid span {
    display: block;
    font-size: 10.5px;
    color: var(--ink-soft);
    margin-bottom: 5px;
    letter-spacing: .5px;
}

.result-grid b {
    font-size: 20px;
    font-weight: 900;
    color: var(--cyan);
    font-variant-numeric: tabular-nums;
}

/* ---------------- 移动端 ---------------- */
@media (max-width: 720px) {
    .hud {
        padding: 10px 12px;
    }

    .hp-bar {
        width: 130px;
        height: 12px;
    }

    .hud-mid {
        padding: 6px 12px;
    }

    .hud-mid b {
        font-size: 16px;
    }

    .stat-mini {
        min-width: 44px;
    }

    .stat-mini b {
        font-size: 14px;
    }

    .wave-flash {
        font-size: 30px;
        letter-spacing: 3px;
    }

    .panel {
        padding: 20px 18px;
    }

    .panel h1 {
        font-size: 24px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        transition-duration: .01ms !important;
    }
}
