/* Top HUD — Responsive 2-Tier Mobile Layout */
    #top-hud {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      padding: 6px 10px 4px 10px;
      display: flex;
      flex-direction: column;
      gap: 4px;
      pointer-events: none;
      font-size: 12px;
      font-weight: 600;
      text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9);
      z-index: 10;
      direction: rtl;
      box-sizing: border-box;
    }

    .hud-tier {
      width: 100%;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 6px;
    }

    .hud-tier-primary {
      padding: 0 2px;
    }

    .hud-tier-secondary {
      padding: 0 2px;
    }

    .hud-title-badge {
      background: rgba(0, 229, 255, 0.12);
      border: 1px solid rgba(0, 229, 255, 0.35);
      color: #00e5ff;
      padding: 2px 8px;
      border-radius: 4px;
      font-size: 11px;
      font-family: 'Lalezar', cursive;
      letter-spacing: 0.5px;
    }

    .hud-timer {
      color: #ffffff;
      font-family: 'Estedad-Mad', 'Estedad', monospace;
      font-size: 13.5px;
      font-weight: 700;
      letter-spacing: 1px;
    }

    .hud-debug-btn {
      pointer-events: auto;
      background: rgba(255, 255, 255, 0.08);
      border: 1px solid rgba(255, 255, 255, 0.2);
      color: #a0a0a0;
      padding: 3px 6px;
      border-radius: 4px;
      font-size: 10px;
      font-family: ui-monospace, monospace;
      cursor: pointer;
      transition: all 0.15s ease;
    }

    .hud-debug-btn:hover {
      background: rgba(255, 255, 255, 0.16);
      color: #ffffff;
    }

    .hud-debug-btn.active {
      background: rgba(56, 239, 125, 0.2);
      border-color: #38ef7d;
      color: #38ef7d;
    }

    /* Power HUD */
    .power-hud {
      pointer-events: none;
      display: flex;
      align-items: center;
      gap: 6px;
      background: rgba(10, 12, 22, 0.88);
      border: 1px solid #1e2235;
      padding: 3px 8px;
      border-radius: 12px;
      transition: all 0.2s ease;
    }
    .power-hud.power-ready {
      border-color: #ffd13b;
      box-shadow: 0 0 10px rgba(255, 209, 59, 0.5);
      animation: powerReadyPulse 0.8s infinite alternate;
    }
    @keyframes powerReadyPulse {
      from { transform: scale(1.0); }
      to { transform: scale(1.05); }
    }
    .power-label {
      font-size: 9.5px;
      font-weight: 800;
      letter-spacing: 0.5px;
      color: #9da3ba;
      font-family: 'Estedad', 'Vazirmatn', sans-serif;
    }
    .power-hud.power-ready .power-label {
      color: #ffd13b;
    }
    .power-bar-track {
      width: 48px;
      height: 6px;
      background: #141724;
      border-radius: 3px;
      overflow: hidden;
      border: 1px solid #222638;
    }
    .power-bar-fill {
      width: 0%;
      height: 100%;
      background: #00e5ff;
      border-radius: 2px;
      transition: width 0.15s ease-out;
    }
    .power-hud.power-ready .power-bar-fill {
      background: #ffd13b;
      box-shadow: 0 0 8px #ffd13b;
    }
    .power-val {
      font-size: 10px;
      font-family: 'Estedad-Mad', 'Estedad', sans-serif;
      font-weight: 700;
      color: #ffffff;
      min-width: 24px;
    }
    .power-hud.power-ready .power-val {
      color: #ffd13b;
    }

    /* Active Special Weapon HUD Banner — hidden per user direction as background gradient displays active power */
    #weapon-active-hud {
      display: none !important;
      position: absolute;
      top: 48px;
      left: 50%;
      transform: translateX(-50%);
      background: rgba(13, 16, 28, 0.94);
      border: 1px solid #00e5ff;
      box-shadow: 0 4px 16px rgba(0, 229, 255, 0.3);
      padding: 4px 12px;
      border-radius: 14px;
      flex-direction: column;
      align-items: center;
      gap: 3px;
      z-index: 12;
      pointer-events: none;
      transition: opacity 0.2s ease;
    }
    #weapon-active-hud.warning {
      border-color: #ff4757;
      box-shadow: 0 0 12px rgba(255, 71, 87, 0.6);
      animation: weaponExpiring 0.5s infinite alternate;
    }
    @keyframes weaponExpiring {
      from { opacity: 0.7; }
      to { opacity: 1.0; }
    }
    .weapon-active-header {
      display: flex;
      align-items: center;
      gap: 8px;
      font-family: 'Estedad', sans-serif;
    }
    .weapon-name {
      font-size: 13px;
      font-weight: 800;
      letter-spacing: 0;
      color: #00e5ff;
      font-family: 'Lalezar', cursive;
    }
    .weapon-time {
      display: none;
      font-size: 11px;
      font-weight: 700;
      color: #ffffff;
      font-family: 'Estedad-Mad', 'Estedad', sans-serif;
    }
    .weapon-bar-track {
      width: 90px;
      height: 4px;
      background: #101322;
      border-radius: 2px;
      overflow: hidden;
    }
    .weapon-bar-fill {
      width: 100%;
      height: 100%;
      background: #00e5ff;
      border-radius: 2px;
    }
    #weapon-active-hud.warning .weapon-bar-fill {
      background: #ff4757;
    }

    /* Bottom Defense Capacity Magazine HUD */
    #capacity-hud {
      position: absolute;
      bottom: 12px;
      left: 10px;
      right: 120px;
      transform: none;
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 4px;
      pointer-events: none;
      z-index: 15;
      transition: transform 0.1s ease;
    }

    .capacity-hud-row {
      display: flex;
      align-items: center;
      gap: 9px;
    }

    /* City Lives / Health HUD */
    .city-health-hud {
      display: flex;
      align-items: center;
      gap: 4px;
      background: rgba(14, 18, 34, 0.90);
      border: 1.5px solid rgba(255, 71, 87, 0.45);
      box-shadow: 0 0 10px rgba(255, 71, 87, 0.25), inset 0 0 6px rgba(255, 71, 87, 0.12);
      padding: 3px 9px;
      border-radius: 20px;
      backdrop-filter: blur(6px);
      -webkit-backdrop-filter: blur(6px);
      direction: ltr;
      transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
      user-select: none;
      pointer-events: auto;
      height: 28px;
      box-sizing: border-box;
    }

    .city-heart-icon {
      font-size: 15px;
      line-height: 1;
      display: inline-block;
      transition: transform 0.22s cubic-bezier(0.175, 0.885, 0.32, 1.275);
      filter: drop-shadow(0 0 5px rgba(255, 71, 87, 0.7));
    }

    .city-health-cross {
      font-size: 12px;
      color: #ff6b81;
      font-weight: 800;
      opacity: 0.85;
      margin: 0 1px;
    }

    .city-health-count {
      font-size: 15px;
      font-weight: 900;
      color: #ffffff;
      font-family: 'Estedad-Mad', monospace, sans-serif;
      text-shadow: 0 0 8px rgba(255, 71, 87, 0.6);
      min-width: 12px;
      text-align: center;
    }

    /* Heart break animation when city hit */
    .city-health-hud.heart-break {
      animation: heartHudShake 0.45s ease-out;
      border-color: #ff3838;
      background: rgba(255, 56, 56, 0.35);
      box-shadow: 0 0 20px rgba(255, 56, 56, 0.8), inset 0 0 10px rgba(255, 56, 56, 0.3);
    }

    .city-heart-icon.breaking {
      animation: heartShatter 0.45s ease-out;
    }

    .city-health-hud.critical {
      border-color: #ff1744;
      animation: heartPulseDanger 0.8s infinite alternate;
    }

    .city-health-hud.depleted {
      border-color: #57606f;
      background: rgba(30, 39, 46, 0.8);
      opacity: 0.7;
    }

    @keyframes heartHudShake {
      0% { transform: scale(1.0); }
      20% { transform: scale(1.22) translateX(-4px); }
      40% { transform: scale(1.18) translateX(4px); }
      60% { transform: scale(1.08) translateX(-2px); }
      80% { transform: scale(1.03) translateX(2px); }
      100% { transform: scale(1.0); }
    }

    @keyframes heartShatter {
      0% { transform: scale(1.0); opacity: 1; }
      25% { transform: scale(1.6) rotate(-18deg); filter: drop-shadow(0 0 12px #ff1744); }
      50% { transform: scale(0.8) rotate(15deg); opacity: 0.7; }
      100% { transform: scale(1.0) rotate(0deg); opacity: 1; }
    }

    @keyframes heartPulseDanger {
      0% { box-shadow: 0 0 6px rgba(255, 23, 68, 0.35); }
      100% { box-shadow: 0 0 20px rgba(255, 23, 68, 0.85); }
    }

    /* Stage 3 Developer Preset Bar */
    .dev-stage3-bar {
      position: absolute;
      top: 48px;
      left: 50%;
      transform: translateX(-50%);
      display: flex;
      align-items: center;
      gap: 6px;
      background: rgba(10, 13, 24, 0.94);
      border: 1px solid rgba(0, 229, 255, 0.5);
      border-radius: 6px;
      padding: 3px 8px;
      z-index: 45;
      box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
      font-family: ui-monospace, monospace;
      font-size: 10px;
    }
    .dev-preset-label {
      color: #7d829e;
      font-weight: 700;
      letter-spacing: 0.5px;
      margin-right: 2px;
    }
    .dev-preset-btn-group {
      display: flex;
      gap: 4px;
    }
    .btn-dev-preset {
      background: #141724;
      border: 1px solid #2e344e;
      color: #9da3ba;
      font-size: 9.5px;
      font-weight: 700;
      padding: 3px 7px;
      border-radius: 4px;
      cursor: pointer;
      font-family: ui-monospace, monospace;
      transition: all 0.15s ease;
    }
    .btn-dev-preset:hover {
      border-color: #00e5ff;
      color: #ffffff;
    }
    .btn-dev-preset.active[data-preset="CURRENT"] {
      background: rgba(0, 229, 255, 0.2);
      border-color: #00e5ff;
      color: #00e5ff;
      box-shadow: 0 0 8px rgba(0, 229, 255, 0.4);
    }
    .btn-dev-preset.active[data-preset="PRESSURE"] {
      background: rgba(255, 209, 59, 0.2);
      border-color: #ffd13b;
      color: #ffd13b;
      box-shadow: 0 0 8px rgba(255, 209, 59, 0.4);
    }
    .btn-dev-preset.active[data-preset="SCARCITY"] {
      background: rgba(255, 71, 87, 0.2);
      border-color: #ff4757;
      color: #ff4757;
      box-shadow: 0 0 8px rgba(255, 71, 87, 0.4);
    }
    .res-preset-row {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 4px;
      background: rgba(18, 22, 38, 0.8);
      border: 1px dashed rgba(0, 229, 255, 0.4);
      border-radius: 6px;
      padding: 6px 10px;
    }
    .res-preset-title {
      font-size: 10px;
      font-weight: 800;
      color: #00e5ff;
      letter-spacing: 1px;
    }
    .res-preset-buttons {
      display: flex;
      gap: 6px;
    }
    .btn-res-preset {
      background: #141724;
      border: 1px solid #2e344e;
      color: #9da3ba;
      font-size: 10px;
      font-weight: 700;
      padding: 4px 8px;
      border-radius: 4px;
      cursor: pointer;
      font-family: ui-monospace, monospace;
    }
    .btn-res-preset:hover {
      border-color: #00e5ff;
      color: #ffffff;
    }
    .btn-res-preset.active[data-preset="CURRENT"] {
      background: rgba(0, 229, 255, 0.25);
      border-color: #00e5ff;
      color: #00e5ff;
    }
    .btn-res-preset.active[data-preset="PRESSURE"] {
      background: rgba(255, 209, 59, 0.25);
      border-color: #ffd13b;
      color: #ffd13b;
    }
    .btn-res-preset.active[data-preset="SCARCITY"] {
      background: rgba(255, 71, 87, 0.25);
      border-color: #ff4757;
      color: #ff4757;
    }

    #capacity-hud.dry-fire-shake {
      animation: dryFireShake 0.18s ease-in-out;
    }

    @keyframes dryFireShake {
      0% { transform: translateX(-50%); }
      25% { transform: translateX(calc(-50% - 6px)); }
      50% { transform: translateX(calc(-50% + 6px)); }
      75% { transform: translateX(calc(-50% - 3px)); }
      100% { transform: translateX(-50%); }
    }

    .capacity-label {
      display: none !important;
      font-size: 11.5px;
      font-weight: 700;
      letter-spacing: 0.5px;
      color: #7b809a;
      font-family: 'Lalezar', cursive;
      transition: color 0.15s ease;
    }

    .capacity-label.last-charge {
      color: #ffa502;
      animation: pulseAlert 0.8s infinite alternate;
    }

    .capacity-label.empty {
      color: #ff4757;
    }

    @keyframes pulseAlert {
      from { opacity: 0.6; }
      to { opacity: 1.0; }
    }

    .charges-container {
      display: flex;
      align-items: center;
      gap: 6px;
      width: calc(var(--magazine-slots, 4) * 26px + 10px);
      justify-content: center;
      flex-shrink: 0;
      background: rgba(8, 10, 18, 0.82);
      padding: 10px 8px;
      border-radius: 20px;
      border: 1px solid #1e2235;
      box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
      transition: border-color 0.2s ease, box-shadow 0.2s ease;
    }

    .charges-container.last-charge {
      border-color: rgba(255, 165, 2, 0.6);
      box-shadow: 0 0 14px rgba(255, 165, 2, 0.35);
    }

    .charges-container.empty {
      border-color: rgba(255, 71, 87, 0.6);
      box-shadow: 0 0 14px rgba(255, 71, 87, 0.35);
    }

    .charge-slot {
      position: relative;
      width: 20px;
      flex-shrink: 0;
      height: 22px;
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    /* Ready Charge: bright green core with outer glow */
    .charge-slot.ready .charge-core {
      width: 14px;
      height: 14px;
      border-radius: 50%;
      background: #38ef7d;
      box-shadow: 0 0 10px rgba(56, 239, 125, 0.85);
      transition: all 0.15s ease;
    }

    /* Ready Pulse on restoration */
    .charge-slot.ready-pulse .charge-core {
      animation: readyPulseAnim 0.28s ease-out;
    }

    @keyframes readyPulseAnim {
      0% { transform: scale(1.0); }
      50% { transform: scale(1.35); filter: brightness(1.4); }
      100% { transform: scale(1.0); }
    }

    /* Recharging Charge: circular progress SVG */
    .charge-slot.recharging .charge-ring-svg {
      display: block;
    }

    .charge-slot.recharging .charge-core {
      width: 6px;
      height: 6px;
      border-radius: 50%;
      background: #202436;
    }

    /* Almost Ready (last 20% / <0.5s remaining) */
    .charge-slot.recharging.almost-ready .charge-ring-fill {
      stroke: #38ef7d;
      filter: drop-shadow(0 0 3px #38ef7d);
    }

    .charge-slot.recharging.almost-ready .charge-core {
      background: #38ef7d;
      opacity: 0.5;
    }

    /* Empty waiting slot */
    .charge-slot.empty-wait .charge-core {
      width: 12px;
      height: 12px;
      border-radius: 50%;
      border: 1px solid #282d42;
      background: #0d0f18;
    }

    .charge-ring-svg {
      position: absolute;
      top: 0;
      left: 0;
      width: 22px;
      height: 22px;
      transform: rotate(-90deg);
      display: none;
    }

    .charge-ring-bg {
      fill: none;
      stroke: #1b1e2c;
      stroke-width: 2;
    }

    .charge-ring-fill {
      fill: none;
      stroke: #00e5ff;
      stroke-width: 2.4;
      stroke-dasharray: 56.5;
      stroke-dashoffset: 56.5;
      stroke-linecap: round;
      transition: stroke 0.15s ease;
    }
