/* =================================================================
   NEW WEAPON HUD (Bottom-center overlay)
   Adapted from "Finalized Weapon HUD Component" styles.
   ~20% height reduction applied; equipped-card highlight enhanced.
   ================================================================= */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&family=JetBrains+Mono:ital,wght@0,400;0,600;0,700;0,800;0,900;1,700&display=swap');

:root {
    --hud-bg-surface: rgba(18, 22, 29, 0.98);
    --hud-card-bg: rgba(28, 33, 42, 0.85);
    --hud-card-locked-bg: rgba(14, 17, 23, 0.94);
    --hud-border: rgba(255, 255, 255, 0.08);
    --hud-border-highlight: rgba(0, 229, 255, 0.35);
    --hud-cyan-accent: #00e5ff;
    --hud-cyan-glow: rgba(0, 229, 255, 0.5);
    --hud-watermark-locked: rgba(255, 255, 255, 0.04);
}

/* Root overlay position for the game */
#weapon-hud-root {
    position: absolute;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%);
    z-index: 25;
    width: min(96vw, 1150px);
    pointer-events: none;
    user-select: none;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #ffffff;
}

/* =================================================================
   RESPONSIVE / MOBILE ADAPTATION
   Strategy: fluid clamp() sizing + coarse-pointer & narrow-screen
   media queries. Muzzle-flash offsets (#flash-pistol, #flash-sniper, ...)
   stay pixel-
   calibrated because they live INSIDE .weapon-assembly, which is
   uniformly scaled with the tile — their relative geometry holds.
   ================================================================= */

/* Corner HUD: Lives / Points — fluid typography */
.corner-label {
    font-size: clamp(12px, 2.5vw, 15px);
}
#hud-points-value {
    font-size: clamp(18px, 4vw, 26px);
}

/* Ammo counter: replaces the old fixed @media (min-width: 640px) bump */
.ammo-counter-large {
    font-size: clamp(0.95rem, 2.5vw, 1.15rem);
}
@media (min-width: 640px) {
    .ammo-counter-large {
        font-size: clamp(1.1rem, 2vw, 1.3rem);
    }
}

/* Weapon picture box height scales with the tile */
.weapon-picture-box {
    height: clamp(34px, 6vw, 44px);
}

/* Narrow screens (phones / small tablets): shrink tiles & weapon art */
@media (max-width: 768px) {
    .hud-slot-tile {
        min-height: 0;
        padding-top: 0.25rem;
        padding-bottom: 0.25rem;
    }
    .weapon-picture-box {
        height: 30px;
    }
    .weapon-assembly {
        height: 56px;           /* keep internal design; scaled below */
        transform: scale(0.46); /* flashes scale with it — stays aligned */
    }
    .hud-watermark {
        font-size: 22px;
        right: 8px;
    }
    /* Keep the dock above the touch FIRE/JUMP buttons */
    #weapon-hud-root {
        bottom: calc(96px + env(safe-area-inset-bottom, 0px));
        width: 98vw;
    }
}

/* Very small phones: hide the weapon illustration box entirely */
@media (max-width: 480px) {
    .weapon-picture-box {
        height: 0;
        margin: 0;
        visibility: hidden;
    }
    #weapon-hud-root {
        bottom: calc(90px + env(safe-area-inset-bottom, 0px));
    }
}

#weapon-hud-root .hud-slot-tile,
#weapon-hud-root #hud-header-row {
    pointer-events: auto;
}

/* Main HUD dock container */
.hud-dock-panel {
    background: linear-gradient(180deg, rgba(23, 27, 34, 0.98) 0%, rgba(12, 14, 19, 0.99) 100%);
    border: 1px solid var(--hud-border);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.85), 0 0 25px rgba(0, 229, 255, 0.05);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 14px;
    position: relative;
}

/* Weapon slot tile */
.hud-slot-tile {
    position: relative;
    background: var(--hud-card-bg);
    border: 1px solid var(--hud-border);
    border-radius: 10px;
    overflow: hidden;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.hud-slot-tile:not(.is-locked):hover {
    background: rgba(36, 43, 56, 0.95);
    border-color: var(--hud-border-highlight);
    transform: translateY(-2px);
}

/* Empty dock tile: the loadout chose fewer than 4 weapons, so this slot is open.
   (The dock is always 4 tiles — tiles hold whatever the loadout assigned.) */
.hud-slot-tile.is-empty {
    background: rgba(11, 14, 19, 0.72);
    border: 1px dashed rgba(255, 255, 255, 0.07);
    cursor: default;
}
.hud-slot-tile.is-empty:hover {
    transform: none;
    background: rgba(11, 14, 19, 0.72);
    border-color: rgba(255, 255, 255, 0.07);
}

/* Hidden template library holding one authored copy of every weapon's card art.
   js/hud.js MOVES the matching .weapon-assembly node into a dock tile when the
   loadout is applied, so 4 fixed tiles can display any weapon in the roster. */
#weapon-art-library {
    display: none;
}

/* Locked state */
.hud-slot-tile.is-locked {
    background: var(--hud-card-locked-bg);
    border-color: rgba(255, 255, 255, 0.04);
    cursor: not-allowed;
}

/* Equipped active state - strong highlight */
.hud-slot-tile.is-active,
.hud-slot-tile.is-active:hover {
    background: rgba(32, 45, 60, 0.98);
    border: 2px solid #00e5ff;
    box-shadow: 0 0 30px rgba(0, 229, 255, 0.6), 0 0 60px rgba(0, 229, 255, 0.25), inset 0 0 18px rgba(0, 229, 255, 0.14);
}

/* Faint watermark behind weapon slot only when locked */
.hud-watermark {
    position: absolute;
    right: 12px;
    bottom: 8px;
    font-size: 34px;
    font-weight: 900;
    letter-spacing: 0.02em;
    color: var(--hud-watermark-locked);
    pointer-events: none;
    transition: opacity 0.2s ease;
    text-transform: uppercase;
    font-family: 'JetBrains Mono', monospace;
    line-height: 0.85;
    z-index: 1;
}

/* Centered Weapon Presentation Box (reduced height ~20%) */
.weapon-picture-box {
    position: relative;
    width: 100%;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 2px 0;
    z-index: 10;
}

/* Combined weapon + flash container that stays centered */
.weapon-assembly {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.weapon-illustration {
    max-width: 82%;
    max-height: 100%;
    transform-origin: 30% 70%;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.8));
    transition: filter 0.2s ease, opacity 0.2s ease;
    will-change: transform, filter;
}

.hud-slot-tile.is-active .weapon-illustration {
    filter: drop-shadow(0 0 8px rgba(0, 229, 255, 0.45)) drop-shadow(0 2px 4px rgba(0, 0, 0, 0.9));
}

.hud-slot-tile.is-locked .weapon-illustration {
    opacity: 0.25;
    filter: grayscale(100%) brightness(55%);
}

/* Cyan heart glow for lives */
.hud-cyan-heart {
    color: #ff3b3b;
    filter: drop-shadow(0 0 6px rgba(255, 59, 59, 0.85));
    transition: transform 0.2s ease, opacity 0.2s ease, filter 0.2s ease;
}

.hud-cyan-heart.heart-lost {
    color: rgba(255, 255, 255, 0.12);
    filter: none;
    transform: scale(0.82);
    opacity: 0.45;
}

/* Large, bold single-number ammo typography (~20% smaller) */
.ammo-counter-large {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.15rem;
    line-height: 1;
    letter-spacing: -0.04em;
    font-weight: 900;
}

@media (min-width: 640px) {
    .ammo-counter-large {
        font-size: 1.3rem;
    }
}

/* =================================================================
   WEAPON-SPECIFIC RECOIL KEYFRAMES
   ================================================================= */
@keyframes fire-recoil-pistol {
    0% { transform: scale(1) translate(0, 0) rotate(0deg); }
    20% { transform: scale(0.97) translate(-7px, -4px) rotate(-6.5deg); }
    50% { transform: scale(0.99) translate(-2px, -1px) rotate(-2deg); }
    100% { transform: scale(1) translate(0, 0) rotate(0deg); }
}

@keyframes fire-recoil-shotgun {
    0% { transform: scale(1) translate(0, 0) rotate(0deg); }
    18% { transform: scale(0.95) translate(-14px, -2px) rotate(-4.5deg); }
    45% { transform: scale(0.98) translate(-6px, 1px) rotate(-1deg); }
    100% { transform: scale(1) translate(0, 0) rotate(0deg); }
}

@keyframes fire-recoil-rifle {
    0% { transform: scale(1) translate(0, 0) rotate(0deg); }
    25% { transform: scale(0.98) translate(-7px, -1px) rotate(-2.5deg); }
    55% { transform: scale(0.99) translate(-3px, 0.5px) rotate(1deg); }
    100% { transform: scale(1) translate(0, 0) rotate(0deg); }
}

@keyframes fire-recoil-minigun {
    0% { transform: scale(1) translate(0, 0); }
    25% { transform: scale(0.985) translate(-5px, -1px); }
    50% { transform: scale(0.99) translate(-3px, 1px); }
    75% { transform: scale(0.985) translate(-6px, 0); }
    100% { transform: scale(1) translate(0, 0); }
}

.recoil-pistol { animation: fire-recoil-pistol 0.16s cubic-bezier(0.1, 0.9, 0.2, 1); }
.recoil-shotgun { animation: fire-recoil-shotgun 0.26s cubic-bezier(0.1, 0.9, 0.2, 1); }
.recoil-rifle { animation: fire-recoil-rifle 0.11s cubic-bezier(0.1, 0.9, 0.2, 1); }
.recoil-minigun { animation: fire-recoil-minigun 0.08s infinite linear; }

/* .50 BMG bolt-action: the heaviest single kick of the five */
@keyframes fire-recoil-sniper {
    0% { transform: scale(1) translate(0, 0) rotate(0deg); }
    12% { transform: scale(0.93) translate(-20px, -3px) rotate(-7deg); }
    40% { transform: scale(0.97) translate(-10px, 1px) rotate(-2.5deg); }
    70% { transform: scale(0.99) translate(-4px, 0) rotate(0.5deg); }
    100% { transform: scale(1) translate(0, 0) rotate(0deg); }
}
.recoil-sniper { animation: fire-recoil-sniper 0.34s cubic-bezier(0.1, 0.9, 0.2, 1); }

/* 84mm launcher: a two-stage shove — the launch kick, then the tube settling
   back. Longer than the sniper's because the reload window is (1.7s). */
@keyframes fire-recoil-rocket {
    0% { transform: scale(1) translate(0, 0) rotate(0deg); }
    14% { transform: scale(0.90) translate(-24px, -2px) rotate(-5deg); }
    45% { transform: scale(0.96) translate(-12px, 2px) rotate(-1.5deg); }
    75% { transform: scale(0.99) translate(-5px, -1px) rotate(0.5deg); }
    100% { transform: scale(1) translate(0, 0) rotate(0deg); }
}
.recoil-rocket { animation: fire-recoil-rocket 0.42s cubic-bezier(0.1, 0.9, 0.2, 1); }

/* Arc-Caster: a fast electrical buzz rather than a mechanical kick. The whole
   cycle is barely one fire interval (0.09s) and it jitters on BOTH axes, which is
   what separates a held beam from a weapon that shoves backwards per shot. */
@keyframes fire-recoil-lightning {
    0% { transform: scale(1) translate(0, 0) rotate(0deg); }
    20% { transform: scale(0.985) translate(-4px, 1.5px) rotate(0.8deg); }
    45% { transform: scale(0.995) translate(2px, -2px) rotate(-0.9deg); }
    70% { transform: scale(0.99) translate(-2px, 1px) rotate(0.4deg); }
    100% { transform: scale(1) translate(0, 0) rotate(0deg); }
}
.recoil-lightning { animation: fire-recoil-lightning 0.10s cubic-bezier(0.2, 0.9, 0.3, 1); }

/* Card shockwave pulse on fire */
@keyframes card-shockwave {
    0% { box-shadow: 0 0 30px rgba(0, 229, 255, 0.6), inset 0 0 18px rgba(0, 229, 255, 0.14); }
    30% { box-shadow: 0 0 35px rgba(0, 229, 255, 0.8), inset 0 0 24px rgba(255, 180, 50, 0.25); }
    100% { box-shadow: 0 0 30px rgba(0, 229, 255, 0.6), inset 0 0 18px rgba(0, 229, 255, 0.14); }
}
.card-fire-shock { animation: card-shockwave 0.18s ease-out; }

/* =================================================================
   INLINE MUZZLE FLASH OVERLAYS AT BARREL END
   ================================================================= */
.muzzle-flash-box {
    position: absolute;
    pointer-events: none;
    opacity: 0;
    z-index: 30;
    transform-origin: left center;
}

/* Offsets are per weapon ART (they travel with the art into whichever tile it
   is assigned to), so they are keyed by weapon instead of dock-tile index. */
#flash-pistol {
    left: 133px;
    top: 24.5px;
    transform: translateY(-50%);
    width: 38px;
    height: 38px;
}

#flash-shotgun {
    left: 147px;
    top: 27.25px;
    transform: translateY(-50%);
    width: 46px;
    height: 46px;
}

#flash-machinegun {
    left: 149px;
    top: 29px;
    transform: translateY(-50%);
    width: 42px;
    height: 42px;
}

#flash-minigun {
    left: 147px;
    top: 31.5px;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
}

#flash-sniper {
    left: 150px;
    top: 32.5px;
    transform: translateY(-50%);
    width: 54px;
    height: 54px;
}

/* Sits on the rocket art's tube mouth (x=155..161, tube centreline y=35). */
#flash-rocket {
    left: 152px;
    top: 35px;
    transform: translateY(-50%);
    width: 60px;
    height: 60px;
}

/* The arc discharges in the GAP between the two prong tips (x=170, y=17.25 and
   y=50.25), so the box is centred on the midpoint and the burst is drawn larger
   than any other weapon's — it is a bolt, not a bang. */
#flash-lightning {
    left: 140px;
    top: 34px;
    transform: translateY(-50%);
    width: 62px;
    height: 62px;
}

@keyframes flash-burst-snappy {
    0% { opacity: 0; transform: translateY(-50%) scale(0.3) rotate(0deg); }
    20% { opacity: 1; transform: translateY(-50%) scale(1.25) rotate(15deg); }
    50% { opacity: 0.85; transform: translateY(-50%) scale(1.05) rotate(5deg); }
    100% { opacity: 0; transform: translateY(-50%) scale(0.4) rotate(-10deg); }
}

@keyframes flash-burst-heavy {
    0% { opacity: 0; transform: translateY(-50%) scale(0.3) scaleX(0.7); }
    25% { opacity: 1; transform: translateY(-50%) scale(1.35) scaleX(1.5); }
    60% { opacity: 0.7; transform: translateY(-50%) scale(1.05) scaleX(1.2); }
    100% { opacity: 0; transform: translateY(-50%) scale(0.5) scaleX(0.9); }
}

@keyframes flash-burst-rapid {
    0% { opacity: 0; transform: translateY(-50%) scale(0.4) rotate(0deg); }
    35% { opacity: 1; transform: translateY(-50%) scale(1.2) rotate(-12deg); }
    100% { opacity: 0; transform: translateY(-50%) scale(0.3) rotate(12deg); }
}

.active-flash-pistol { animation: flash-burst-snappy 0.12s ease-out forwards; }
.active-flash-shotgun { animation: flash-burst-heavy 0.22s ease-out forwards; }
.active-flash-rifle { animation: flash-burst-rapid 0.09s ease-out forwards; }
.active-flash-minigun { animation: flash-burst-rapid 0.07s infinite alternate ease-in-out; }

/* .50 BMG muzzle-brake flash: long, wide and bright */
@keyframes flash-burst-sniper {
    0% { opacity: 0; transform: translateY(-50%) scale(0.35) scaleX(0.8); }
    18% { opacity: 1; transform: translateY(-50%) scale(1.5) scaleX(1.7); }
    45% { opacity: 0.85; transform: translateY(-50%) scale(1.2) scaleX(1.35); }
    100% { opacity: 0; transform: translateY(-50%) scale(0.55) scaleX(1); }
}
.active-flash-sniper { animation: flash-burst-sniper 0.3s ease-out forwards; }

/* 84mm backblast bloom: the biggest, longest flash in the dock */
@keyframes flash-burst-rocket {
    0% { opacity: 0; transform: translateY(-50%) scale(0.35) scaleX(0.8); }
    16% { opacity: 1; transform: translateY(-50%) scale(1.7) scaleX(1.9); }
    50% { opacity: 0.75; transform: translateY(-50%) scale(1.3) scaleX(1.45); }
    100% { opacity: 0; transform: translateY(-50%) scale(0.6) scaleX(1); }
}
.active-flash-rocket { animation: flash-burst-rocket 0.42s ease-out forwards; }

/* Arc-Caster: a white-hot core with a blue corona that SNAPS apart rather than
   blooming, because the bolt itself is the projectile. Repeats while held, like
   the minigun's, since the trigger is a continuous discharge. */
@keyframes flash-burst-lightning {
    0% { opacity: 0; transform: translateY(-50%) scale(0.45) rotate(0deg); }
    25% { opacity: 1; transform: translateY(-50%) scale(1.35) rotate(-9deg); }
    60% { opacity: 0.8; transform: translateY(-50%) scale(1.05) rotate(7deg); }
    100% { opacity: 0; transform: translateY(-50%) scale(0.5) rotate(-5deg); }
}
.active-flash-lightning { animation: flash-burst-lightning 0.09s infinite alternate ease-in-out; }

/* Minigun Barrel Rotation Simulation */
@keyframes minigun-barrel-spin {
    0% { stroke-dashoffset: 0; }
    100% { stroke-dashoffset: 24; }
}
.spinning-barrels {
    animation: minigun-barrel-spin 0.08s linear infinite;
}

/* ~20% height reduction: uniformly scale weapon art + flash overlays */
.weapon-assembly {
    height: 72px; /* fixed design layout so muzzle-flash offsets stay aligned */
    transform: scale(0.61);
    transform-origin: center center;
}

/* Equipped card lift (overrides hover) */
.hud-slot-tile.is-active,
.hud-slot-tile.is-active:hover {
    transform: translateY(-4px) scale(1.03);
    opacity: 1;
    filter: none;
}

/* ============ Corner HUD: Lives (top-left) / Points (top-right) ============ */
#hud-lives-corner,
#hud-points-corner {
    position: absolute;
    top: 12px;
    z-index: 30;
    pointer-events: none;
    user-select: none;
    font-family: Inter, sans-serif;
    display: flex;
    align-items: center;
    gap: 10px;
}
#hud-lives-corner { left: 15px; }
#hud-points-corner { right: 15px; }
.corner-label {
    font-size: clamp(12px, 2.5vw, 15px);
    font-weight: 900;
    letter-spacing: 1px;
    color: #ffffff;
    text-shadow: 0 0 8px rgba(0, 0, 0, 0.95), 2px 2px 4px rgba(0, 0, 0, 0.9);
}
#hud-lives-container {
    display: flex;
    align-items: center;
    gap: 5px;
}
#hud-points-value {
    font-family: JetBrains Mono, monospace;
    font-size: clamp(18px, 4vw, 26px);
    font-weight: 900;
    letter-spacing: -0.02em;
    color: #00e5ff;
    text-shadow: 0 0 12px rgba(0, 229, 255, 0.6), 2px 2px 4px rgba(0, 0, 0, 0.9);
}

/* ============ Minimap (bottom-left) ============
   A read-only 2D readout of the arena with a red dot per live mob; js/minimap.js draws into
   the canvas. pointer-events are deliberately off: the panel sits over the play area, so a
   shot aimed into that corner has to reach the canvas underneath it. */
#minimap-panel {
    position: absolute;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    left: 12px;
    /* 20, not 30: the corner HUD's band. Being UNDER the dock (25) is deliberate -- on a
       narrow window the two can meet, and the weapon cards are not the thing to cover. */
    z-index: 20;
    pointer-events: none;
    user-select: none;
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 7px 7px 5px;
    /* The dock panel's recipe, at corner-HUD scale. */
    background: linear-gradient(180deg, rgba(23, 27, 34, 0.92) 0%, rgba(12, 14, 19, 0.96) 100%);
    border: 1px solid var(--hud-border);
    border-radius: 14px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}
#minimap-label {
    font-size: 10px;
    letter-spacing: 2px;
    color: #9fb4c8;
    text-shadow: none;
}
/* The map ships at 1.5x the size it was first built at; js/minimap.js scales its markers by
   the same factor (MARKER_SCALE), so it reads exactly as it did -- just bigger.
   26vw is what keeps it off the centred dock: it only starts to shrink below ~860px wide,
   so a PC window and a tablet in landscape both get the full 222px. */
#minimap-canvas {
    display: block;
    width: clamp(156px, 26vw, 222px);
    height: clamp(156px, 26vw, 222px);
}
/* Narrow screens: lift the whole panel above the dock (bottom 12px / 96px under 768px) AND
   above the centred stamina bar (bottom 140px / 200px under 768px), the same way those two
   already make room for each other. Below this width there is no room for a 222px panel
   beside a centred dock, so it goes above it rather than behind it. */
@media (max-width: 880px) {
    #minimap-panel {
        bottom: calc(244px + env(safe-area-inset-bottom, 0px));
    }
}